Skip to content

Commit

Permalink
Add ram API
Browse files Browse the repository at this point in the history
Signed-off-by: INFINEON\DovhalA <Artem.Dovhal@infineon.com>
  • Loading branch information
DOAR-Infineon committed Jul 12, 2023
1 parent 3aaafe1 commit 99aa511
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
9 changes: 8 additions & 1 deletion boot/bootutil/include/bootutil/bootutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,19 @@ struct image_trailer {

/* you must have pre-allocated all the entries within this structure */
fih_ret boot_go(struct boot_rsp *rsp);
fih_ret boot_go_for_image_id(struct boot_rsp *rsp, uint32_t image_id);
fih_ret boot_go_for_image_id_flash(struct boot_rsp *rsp, uint32_t image_id);

#if defined(MCUBOOT_DIRECT_XIP) || defined(MCUBOOT_RAM_LOAD)
fih_ret boot_go_for_image_id_ram(struct boot_rsp *rsp, uint32_t image_id);
#endif

struct boot_loader_state;
void boot_state_clear(struct boot_loader_state *state);
fih_ret context_boot_go_flash(struct boot_loader_state *state, struct boot_rsp *rsp);

#if defined(MCUBOOT_DIRECT_XIP) || defined(MCUBOOT_RAM_LOAD)
fih_ret context_boot_go_ram(struct boot_loader_state *state, struct boot_rsp *rsp);
#endif

#define SPLIT_GO_OK (0)
#define SPLIT_GO_NON_MATCHING (-1)
Expand Down
33 changes: 32 additions & 1 deletion boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -3354,7 +3354,7 @@ boot_go(struct boot_rsp *rsp)
* @return FIH_SUCCESS on success; nonzero on failure.
*/
fih_ret
boot_go_for_image_id(struct boot_rsp *rsp, uint32_t image_id)
boot_go_for_image_id_flash(struct boot_rsp *rsp, uint32_t image_id)
{
FIH_DECLARE(fih_rc, FIH_FAILURE);

Expand All @@ -3371,6 +3371,37 @@ boot_go_for_image_id(struct boot_rsp *rsp, uint32_t image_id)
FIH_RET(fih_rc);
}

#if defined(MCUBOOT_DIRECT_XIP) || defined(MCUBOOT_RAM_LOAD)
/**
* Prepares the booting process, considering only a single image. This function
* moves images around in flash as appropriate, and tells you what address to
* boot from.
*
* @param rsp On success, indicates how booting should occur.
*
* @param image_id The image ID to prepare the boot process for.
*
* @return FIH_SUCCESS on success; nonzero on failure.
*/
fih_ret
boot_go_for_image_id_ram(struct boot_rsp *rsp, uint32_t image_id)
{
FIH_DECLARE(fih_rc, FIH_FAILURE);

if (image_id >= BOOT_IMAGE_NUMBER) {
FIH_RET(FIH_FAILURE);
}

#if BOOT_IMAGE_NUMBER > 1
memset(&boot_data.img_mask, 1, BOOT_IMAGE_NUMBER);
boot_data.img_mask[image_id] = 0;
#endif

FIH_CALL(context_boot_go_ram, fih_rc, &boot_data, rsp);
FIH_RET(fih_rc);
}
#endif

/**
* Clears the boot state, so that previous operations have no effect on new
* ones.
Expand Down
2 changes: 1 addition & 1 deletion ci/fih_test_docker/fi_tester_gdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function skip_instruction {
cat >commands.gdb <<EOF
target remote localhost: 1234
file $IMAGE_DIR/bl2.axf
b boot_go_for_image_id if image_id == 0
b boot_go_for_image_id_flash if image_id == 0
continue
delete breakpoints 1
b *$SKIP_ADDRESS
Expand Down

0 comments on commit 99aa511

Please sign in to comment.