Commit 98a6681d authored by Ederson de Souza's avatar Ederson de Souza Committed by Jamie
Browse files

boot/bootutil: Get bootloader state



Add `boot_get_loader_state()` to allow one have a reference to current
bootloader state. While this state is internal - and struct is opaque -
it will be important to be able to "pass it around" when using hooks
that will be introduced in future patches.

While at it, make Zephyr single loader also expose it.

Signed-off-by: default avatarEderson de Souza <ederson.desouza@intel.com>
parent dbbcb78b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -86,9 +86,9 @@ struct image_max_size {
fih_ret boot_go(struct boot_rsp *rsp);
fih_ret boot_go_for_image_id(struct boot_rsp *rsp, uint32_t image_id);

struct boot_loader_state;
void boot_state_clear(struct boot_loader_state *state);
fih_ret context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp);
struct boot_loader_state *boot_get_loader_state(void);
const struct image_max_size *boot_get_max_app_size(void);
uint32_t boot_get_state_secondary_offset(struct boot_loader_state *state,
                                         const struct flash_area *fap);
+2 −0
Original line number Diff line number Diff line
@@ -145,6 +145,8 @@ _Static_assert(MCUBOOT_BOOT_MAX_ALIGN >= 8 && MCUBOOT_BOOT_MAX_ALIGN <= 32,
#endif
#endif

struct boot_loader_state;

struct boot_swap_state {
    uint8_t magic;      /* One of the BOOT_MAGIC_[...] values. */
    uint8_t swap_type;  /* One of the BOOT_SWAP_TYPE_[...] values. */
+5 −0
Original line number Diff line number Diff line
@@ -118,6 +118,11 @@ static struct sector_buffer_t sector_buffers;
        boot_copy_region(state, fap_pri, fap_sec, pri_off, sec_off, sz)
#endif

struct boot_loader_state *boot_get_loader_state(void)
{
    return &boot_data;
}

static int
boot_read_image_headers(struct boot_loader_state *state, bool require_all,
        struct boot_status *bs)
+6 −0
Original line number Diff line number Diff line
@@ -21,6 +21,12 @@ BOOT_LOG_MODULE_DECLARE(mcuboot);
/* Variables passed outside of unit via poiters. */
static const struct flash_area *_fa_p;
static struct image_header _hdr = { 0 };
static struct boot_loader_state boot_data;

struct boot_loader_state *boot_get_loader_state(void)
{
    return &boot_data;
}

#if defined(MCUBOOT_VALIDATE_PRIMARY_SLOT) || defined(MCUBOOT_VALIDATE_PRIMARY_SLOT_ONCE)
/**