Skip to content

Commit 11099a7

Browse files
committed
loader: Move boot_get_max_app_size(..) API
Move the boot_get_max_app_size(..) API into bootutil_misc.c as this file has the remaining functions, that operate on the size array (i.e. boot_fetch_slot_state_sizes(..)) and is independent from the update type, thus moving it will reduce the code duplication in the future. Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent 9d40cef commit 11099a7

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

boot/bootutil/src/bootutil_misc.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,31 @@ void boot_fetch_slot_state_sizes(void)
594594
memset(state, 0, sizeof(struct boot_loader_state));
595595
}
596596
#endif
597+
#if defined(MCUBOOT_SERIAL_IMG_GRP_SLOT_INFO) || defined(MCUBOOT_DATA_SHARING)
598+
const struct image_max_size *boot_get_max_app_size(void)
599+
{
600+
const struct image_max_size *image_max_sizes = boot_get_image_max_sizes();
601+
602+
#if defined(MCUBOOT_SERIAL_IMG_GRP_SLOT_INFO)
603+
uint8_t i = 0;
604+
605+
while (i < BOOT_IMAGE_NUMBER) {
606+
if (image_max_sizes[i].calculated == true) {
607+
break;
608+
}
609+
610+
++i;
611+
}
612+
613+
if (i == BOOT_IMAGE_NUMBER) {
614+
/* Information not available, need to fetch it */
615+
boot_fetch_slot_state_sizes();
616+
}
617+
#endif
618+
619+
return image_max_sizes;
620+
}
621+
#endif
597622

598623
/**
599624
* Clears the boot state, so that previous operations have no effect on new

boot/bootutil/src/loader.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,33 +2883,6 @@ boot_close_all_flash_areas(struct boot_loader_state *state)
28832883
}
28842884
}
28852885

2886-
#if defined(MCUBOOT_SERIAL_IMG_GRP_SLOT_INFO) || defined(MCUBOOT_DATA_SHARING)
2887-
/**
2888-
* Fetches the maximum allowed size of the image
2889-
*/
2890-
const struct image_max_size *boot_get_max_app_size(void)
2891-
{
2892-
#if defined(MCUBOOT_SERIAL_IMG_GRP_SLOT_INFO)
2893-
uint8_t i = 0;
2894-
2895-
while (i < BOOT_IMAGE_NUMBER) {
2896-
if (image_max_sizes[i].calculated == true) {
2897-
break;
2898-
}
2899-
2900-
++i;
2901-
}
2902-
2903-
if (i == BOOT_IMAGE_NUMBER) {
2904-
/* Information not available, need to fetch it */
2905-
boot_fetch_slot_state_sizes();
2906-
}
2907-
#endif
2908-
2909-
return image_max_sizes;
2910-
}
2911-
#endif
2912-
29132886
#if defined(MCUBOOT_SWAP_USING_OFFSET)
29142887
uint32_t boot_get_state_secondary_offset(struct boot_loader_state *state,
29152888
const struct flash_area *fap)

0 commit comments

Comments
 (0)