Skip to content

Commit 98a6681

Browse files
edersondisouzanordicjm
authored andcommitted
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: Ederson de Souza <[email protected]>
1 parent dbbcb78 commit 98a6681

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

boot/bootutil/include/bootutil/bootutil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ struct image_max_size {
8686
fih_ret boot_go(struct boot_rsp *rsp);
8787
fih_ret boot_go_for_image_id(struct boot_rsp *rsp, uint32_t image_id);
8888

89-
struct boot_loader_state;
9089
void boot_state_clear(struct boot_loader_state *state);
9190
fih_ret context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp);
91+
struct boot_loader_state *boot_get_loader_state(void);
9292
const struct image_max_size *boot_get_max_app_size(void);
9393
uint32_t boot_get_state_secondary_offset(struct boot_loader_state *state,
9494
const struct flash_area *fap);

boot/bootutil/include/bootutil/bootutil_public.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ _Static_assert(MCUBOOT_BOOT_MAX_ALIGN >= 8 && MCUBOOT_BOOT_MAX_ALIGN <= 32,
145145
#endif
146146
#endif
147147

148+
struct boot_loader_state;
149+
148150
struct boot_swap_state {
149151
uint8_t magic; /* One of the BOOT_MAGIC_[...] values. */
150152
uint8_t swap_type; /* One of the BOOT_SWAP_TYPE_[...] values. */

boot/bootutil/src/loader.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ static struct sector_buffer_t sector_buffers;
118118
boot_copy_region(state, fap_pri, fap_sec, pri_off, sec_off, sz)
119119
#endif
120120

121+
struct boot_loader_state *boot_get_loader_state(void)
122+
{
123+
return &boot_data;
124+
}
125+
121126
static int
122127
boot_read_image_headers(struct boot_loader_state *state, bool require_all,
123128
struct boot_status *bs)

boot/zephyr/single_loader.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ BOOT_LOG_MODULE_DECLARE(mcuboot);
2121
/* Variables passed outside of unit via poiters. */
2222
static const struct flash_area *_fa_p;
2323
static struct image_header _hdr = { 0 };
24+
static struct boot_loader_state boot_data;
25+
26+
struct boot_loader_state *boot_get_loader_state(void)
27+
{
28+
return &boot_data;
29+
}
2430

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

0 commit comments

Comments
 (0)