From 84a07dbfd8e916788d685a4227f9a4e770375ffd Mon Sep 17 00:00:00 2001 From: Karl Apsite Date: Thu, 21 May 2015 09:52:48 -0400 Subject: add boot_get_loadables() to load listed images Added a trimmed down instance of boot_get_() to satisfy the minimum requierments of the added feature. The function follows the normal patterns set by other boot_get's, which should make it a bit easier to combine them all together into one boot_get_image() function in a later refactor. Documentation for the new function can be found in source: include/image.h Signed-off-by: Karl Apsite Reviewed-by: Simon Glass --- common/image.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'common/image.c') diff --git a/common/image.c b/common/image.c index fdec496c4b..0f5274f1be 100644 --- a/common/image.c +++ b/common/image.c @@ -1165,6 +1165,77 @@ int boot_get_setup(bootm_headers_t *images, uint8_t arch, #endif } +#if defined(CONFIG_FIT) +int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images, + uint8_t arch, const ulong *ld_start, ulong * const ld_len) +{ + /* + * These variables are used to hold the current image location + * in system memory. + */ + ulong tmp_img_addr; + /* + * These two variables are requirements for fit_image_load, but + * their values are not used + */ + ulong img_data, img_len; + void *buf; + int loadables_index; + int conf_noffset; + int fit_img_result; + char *uname; + + /* Check to see if the images struct has a FIT configuration */ + if (!genimg_has_config(images)) { + debug("## FIT configuration was not specified\n"); + return 0; + } + + /* + * Obtain the os FIT header from the images struct + * copy from dataflash if needed + */ + tmp_img_addr = map_to_sysmem(images->fit_hdr_os); + tmp_img_addr = genimg_get_image(tmp_img_addr); + buf = map_sysmem(tmp_img_addr, 0); + /* + * Check image type. For FIT images get FIT node + * and attempt to locate a generic binary. + */ + switch (genimg_get_format(buf)) { + case IMAGE_FORMAT_FIT: + conf_noffset = fit_conf_get_node(buf, images->fit_uname_cfg); + + for (loadables_index = 0; + !fdt_get_string_index(buf, conf_noffset, + FIT_LOADABLE_PROP, + loadables_index, + (const char **)&uname) > 0; + loadables_index++) + { + fit_img_result = fit_image_load(images, + tmp_img_addr, + (const char **)&uname, + &(images->fit_uname_cfg), arch, + IH_TYPE_LOADABLE, + BOOTSTAGE_ID_FIT_LOADABLE_START, + FIT_LOAD_OPTIONAL_NON_ZERO, + &img_data, &img_len); + if (fit_img_result < 0) { + /* Something went wrong! */ + return fit_img_result; + } + } + break; + default: + printf("The given image format is not supported (corrupt?)\n"); + return 1; + } + + return 0; +} +#endif + #ifdef CONFIG_SYS_BOOT_GET_CMDLINE /** * boot_get_cmdline - allocate and initialize kernel cmdline -- cgit v1.2.1