Commit c9aa7fd9 authored by Ederson de Souza's avatar Ederson de Souza Committed by Jamie
Browse files

boot/bootutil: Make RAM loading methods public



RAM loading methods are currently private, which prevents external
modules with hooks from using them. This patch makes them public.

An interesting note is that a new method,
`boot_load_image_from_flash_to_sram()`, is added so that code can
actually set the image to be loaded - currently, that is inferred from
current boot loader state, but external code can't directly access
members of relevant `struct boot_loader_state`.

Signed-off-by: default avatarEderson de Souza <ederson.desouza@intel.com>
parent 98a6681d
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -311,6 +311,41 @@ int
boot_image_load_header(const struct flash_area *fa_p,
                       struct image_header *hdr);

#ifdef MCUBOOT_RAM_LOAD
/**
 * Loads image with given header to RAM.
 *
 * Destination on RAM and size is described on image header.
 *
 * @param[in]   state   boot loader state
 * @param[in]   hdr     image header
 *
 * @return              0 on success, error code otherwise
 */
int boot_load_image_from_flash_to_sram(struct boot_loader_state *state,
                                       struct image_header *hdr);

/**
 * Removes an image from SRAM, by overwriting it with zeros.
 *
 * @param  state        Boot loader status information.
 *
 * @return              0 on success; nonzero on failure.
 */
int boot_remove_image_from_sram(struct boot_loader_state *state);

/**
 * Removes an image from flash by erasing the corresponding flash area
 *
 * @param  state    Boot loader status information.
 * @param  slot     The flash slot of the image to be erased.
 *
 * @return          0 on success; nonzero on failure.
 */
int boot_remove_image_from_flash(struct boot_loader_state *state,
                                 uint32_t slot);
#endif

#ifdef __cplusplus
}
#endif
+0 −3
Original line number Diff line number Diff line
@@ -503,9 +503,6 @@ struct bootsim_ram_info *bootsim_get_ram_info(void);
    (size)), 0)

int boot_load_image_to_sram(struct boot_loader_state *state);
int boot_remove_image_from_sram(struct boot_loader_state *state);
int boot_remove_image_from_flash(struct boot_loader_state *state,
                                 uint32_t slot);
#else
#define IMAGE_RAM_BASE ((uintptr_t)0)

+14 −0
Original line number Diff line number Diff line
@@ -438,3 +438,17 @@ boot_remove_image_from_flash(struct boot_loader_state *state, uint32_t slot)

    return rc;
}

int boot_load_image_from_flash_to_sram(struct boot_loader_state *state,
                                       struct image_header *hdr)
{
    int active_slot;

    /* boot_load_image_to_sram will load the image from state active_slot,
     * so force it before loading the image.
     */
    active_slot = state->slot_usage[BOOT_CURR_IMG(state)].active_slot;
    BOOT_IMG(state, active_slot).hdr = *hdr;

    return boot_load_image_to_sram(state);
}