Skip to content

Commit a312656

Browse files
committed
bootutil: Add boot_loader_state_init
boot_loader_state initialization function. Signed-off-by: Dominik Ermel <[email protected]>
1 parent e925518 commit a312656

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

boot/bootutil/include/bootutil/bootutil.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ fih_ret context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp);
9696
*/
9797
struct boot_loader_state *boot_get_loader_state(void);
9898

99+
/**
100+
* Initialize boot_loader_state object
101+
*
102+
* @param state Bootloader state.
103+
*/
104+
void boot_state_init(struct boot_loader_state *state);
105+
99106
#if defined(MCUBOOT_SERIAL_IMG_GRP_SLOT_INFO) || defined(MCUBOOT_DATA_SHARING)
100107
/**
101108
* Returns pointer to array of image maximum sizes.

boot/bootutil/src/bootutil_loader.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,21 @@ boot_close_all_flash_areas(struct boot_loader_state *state)
381381
}
382382
}
383383
#endif /* !MCUBOOT_SINGLE_APPLICATION_SLOT_RAM_LOAD && !MCUBOOT_SINGLE_APPLICATION_SLOT */
384+
385+
void boot_state_init(struct boot_loader_state *state)
386+
{
387+
#if defined(MCUBOOT_ENC_IMAGES)
388+
int image;
389+
int slot;
390+
#endif
391+
392+
memset(state, 0, sizeof(*state));
393+
394+
#if defined(MCUBOOT_ENC_IMAGES)
395+
for (image = 0; image < BOOT_IMAGE_NUMBER; ++image) {
396+
for (slot = 0; slot < BOOT_NUM_SLOTS; ++slot) {
397+
boot_enc_init(&state->enc[image][slot]);
398+
}
399+
}
400+
#endif
401+
}

0 commit comments

Comments
 (0)