Commit d1721f9c authored by Ederson de Souza's avatar Ederson de Souza Committed by Jamie McCrae
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.

Note: This PR has been modified from the upstream commit due to
a merge failure from other changes that are not being brought into
Zephyr 3.7

Signed-off-by: default avatarEderson de Souza <ederson.desouza@intel.com>
(cherry picked from commit 98a6681d)
parent 5ee8ede0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -81,9 +81,9 @@ struct image_trailer {
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);

#define SPLIT_GO_OK                 (0)
#define SPLIT_GO_NON_MATCHING       (-1)
+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
@@ -91,6 +91,11 @@ static struct boot_loader_state boot_data;

#define NO_ACTIVE_SLOT UINT32_MAX

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
@@ -19,6 +19,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)
/**