Skip to content

Commit 11ffc6f

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: Ederson de Souza <[email protected]>
1 parent f5454f1 commit 11ffc6f

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

9494
#define SPLIT_GO_OK (0)

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
@@ -110,6 +110,11 @@ static struct sector_buffer_t sector_buffers;
110110
#define BUF_SZ 1024
111111
#endif
112112

113+
struct boot_loader_state *boot_get_loader_state(void)
114+
{
115+
return &boot_data;
116+
}
117+
113118
static int
114119
boot_read_image_headers(struct boot_loader_state *state, bool require_all,
115120
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)