summaryrefslogtreecommitdiffstats
path: root/common/image.c
diff options
context:
space:
mode:
authorKarl Apsite <karl.apsite@dornerworks.com>2015-05-21 09:52:48 -0400
committerTom Rini <trini@konsulko.com>2015-05-28 08:18:20 -0400
commit84a07dbfd8e916788d685a4227f9a4e770375ffd (patch)
tree544aa02e596f6125acf9e9745dc6c3ab43c76a62 /common/image.c
parentecf8cd653530acb0ed8217a1d80c93841ec2005e (diff)
downloadblackbird-obmc-uboot-84a07dbfd8e916788d685a4227f9a4e770375ffd.tar.gz
blackbird-obmc-uboot-84a07dbfd8e916788d685a4227f9a4e770375ffd.zip
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>
Diffstat (limited to 'common/image.c')
-rw-r--r--common/image.c71
1 files changed, 71 insertions, 0 deletions
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
OpenPOWER on IntegriCloud