Skip to content

Commit 0f0d586

Browse files
committed
bootutil: Extract common loader functions
Reduce the size of loader.c as well as bootutil_misc.c files by extracting common functions into a separate files. Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent b192716 commit 0f0d586

File tree

12 files changed

+1208
-926
lines changed

12 files changed

+1208
-926
lines changed

boot/bootutil/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ target_sources(bootutil
2121
src/bootutil_img_hash.c
2222
src/bootutil_img_security_cnt.c
2323
src/bootutil_misc.c
24+
src/bootutil_area.c
25+
src/bootutil_loader.c
2426
src/bootutil_public.c
2527
src/caps.c
2628
src/encrypted.c

boot/bootutil/include/bootutil/bootutil.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,36 @@ fih_ret boot_go_for_image_id(struct boot_rsp *rsp, uint32_t image_id);
8888

8989
void boot_state_clear(struct boot_loader_state *state);
9090
fih_ret context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp);
91+
92+
/**
93+
* Returns a pointer to the boot loader state structure.
94+
*
95+
* @return Pointer to the boot loader state structure.
96+
*/
9197
struct boot_loader_state *boot_get_loader_state(void);
98+
99+
#if defined(MCUBOOT_SERIAL_IMG_GRP_SLOT_INFO) || defined(MCUBOOT_DATA_SHARING)
100+
/**
101+
* Returns pointer to array of image maximum sizes.
102+
*
103+
* @note This function provides a RAW access to the structure. The sizes may not be
104+
* calculated yet. Use boot_get_max_app_size() to ensure the sizes are calculated.
105+
*
106+
* @return Pointer to array of image maximum sizes.
107+
*/
92108
struct image_max_size *boot_get_image_max_sizes(void);
109+
110+
/**
111+
* Fetches the maximum allowed size of all application images.
112+
*
113+
* @note In contrast to boot_get_image_max_sizes(), this function will fetch the sizes
114+
* if they are not yet calculated.
115+
*
116+
* @return A pointer to the structure containing the maximum sizes of images.
117+
*/
93118
const struct image_max_size *boot_get_max_app_size(void);
119+
#endif /* MCUBOOT_SERIAL_IMG_GRP_SLOT_INFO || MCUBOOT_DATA_SHARING */
120+
94121
void boot_fetch_slot_state_sizes(void);
95122
uint32_t boot_get_state_secondary_offset(struct boot_loader_state *state,
96123
const struct flash_area *fap);

0 commit comments

Comments
 (0)