add boot_get_loadables() to load listed images

Added a trimmed down instance of boot_get_<thing>() to satisfy the
minimum requierments of the added feature.  The function follows the
normal patterns set by other boot_get<thing>'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 <Karl.Apsite@dornerworks.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Karl Apsite
2015-05-21 09:52:48 -04:00
committed by Tom Rini
parent ecf8cd6535
commit 84a07dbfd8
5 changed files with 129 additions and 2 deletions

View File

@ -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