Re: [U-Boot] [PATCH v2 3/4] add boot_get_loadables() to load listed images
Hi Karl, On 15 May 2015 at 15:13, Karl Apsite karl.aps...@dornerworks.com wrote: From: Karl Apsite karl.aps...@dornerworks.com 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_getthing'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.aps...@dornerworks.com --- Looks good to me - but see comment below. common/bootm.c | 26 ++-- common/image-fit.c | 8 +- common/image.c | 71 + include/bootstage.h | 1 + include/image.h | 27 +++- 5 files changed, 129 insertions(+), 4 deletions(-) diff --git a/common/bootm.c b/common/bootm.c index 6842029..f42fb66 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -214,7 +214,7 @@ static int bootm_find_ramdisk(int flag, int argc, char * const argv[]) ret = boot_get_ramdisk(argc, argv, images, IH_INITRD_ARCH, images.rd_start, images.rd_end); if (ret) { - puts(Ramdisk image is corrupt or invalid\n); + printf(Ramdisk image is corrupt or invalid\n); This seems unrelated to your patch - can you pull out this clean-up into a separate patch? It could precede this one in the stack. return 1; } @@ -230,7 +230,7 @@ static int bootm_find_fdt(int flag, int argc, char * const argv[]) ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, images, images.ft_addr, images.ft_len); if (ret) { - puts(Could not find a valid device tree\n); + printf(Could not find a valid device tree\n); return 1; } @@ -240,6 +240,23 @@ static int bootm_find_fdt(int flag, int argc, char * const argv[]) } #endif +#if defined(CONFIG_FIT) +static int bootm_find_loadables(int flag, int argc, char * const argv[]) +{ + int ret; + + /* find all of the loadables */ + ret = boot_get_loadable(argc, argv, images, IH_ARCH_DEFAULT, + NULL, NULL); + if (ret) { + printf(Loadable(s) is corrupt or invalid\n); + return 1; + } + + return 0; +} +#endif + int bootm_find_ramdisk_fdt(int flag, int argc, char * const argv[]) { if (bootm_find_ramdisk(flag, argc, argv)) @@ -250,6 +267,11 @@ int bootm_find_ramdisk_fdt(int flag, int argc, char * const argv[]) return 1; #endif +#if defined(CONFIG_FIT) + if (bootm_find_loadables(flag, argc, argv)) + return 1; +#endif + return 0; } diff --git a/common/image-fit.c b/common/image-fit.c index fc9ea1f..ecd3e67 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1544,6 +1544,8 @@ static const char *fit_get_image_type_property(int type) return FIT_RAMDISK_PROP; case IH_TYPE_X86_SETUP: return FIT_SETUP_PROP; + case IH_TYPE_LOADABLE: + return FIT_LOADABLE_PROP; } return unknown; @@ -1661,7 +1663,11 @@ int fit_image_load(bootm_headers_t *images, ulong addr, os_ok = image_type == IH_TYPE_FLATDT || fit_image_check_os(fit, noffset, IH_OS_LINUX) || fit_image_check_os(fit, noffset, IH_OS_OPENRTOS); - if (!type_ok || !os_ok) { + + /* If either of the checks fail, we should report an error, but +* if the image type is coming from the loadables field, we +* don't care what it is */ + if ((!type_ok || !os_ok) image_type != IH_TYPE_LOADABLE) { fit_image_get_os(fit, noffset, os); printf(No %s %s %s Image\n, genimg_get_os_name(os), diff --git a/common/image.c b/common/image.c index fdec496..e5cff05 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
[U-Boot] [PATCH v2 3/4] add boot_get_loadables() to load listed images
From: Karl Apsite karl.aps...@dornerworks.com 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_getthing'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.aps...@dornerworks.com --- common/bootm.c | 26 ++-- common/image-fit.c | 8 +- common/image.c | 71 + include/bootstage.h | 1 + include/image.h | 27 +++- 5 files changed, 129 insertions(+), 4 deletions(-) diff --git a/common/bootm.c b/common/bootm.c index 6842029..f42fb66 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -214,7 +214,7 @@ static int bootm_find_ramdisk(int flag, int argc, char * const argv[]) ret = boot_get_ramdisk(argc, argv, images, IH_INITRD_ARCH, images.rd_start, images.rd_end); if (ret) { - puts(Ramdisk image is corrupt or invalid\n); + printf(Ramdisk image is corrupt or invalid\n); return 1; } @@ -230,7 +230,7 @@ static int bootm_find_fdt(int flag, int argc, char * const argv[]) ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, images, images.ft_addr, images.ft_len); if (ret) { - puts(Could not find a valid device tree\n); + printf(Could not find a valid device tree\n); return 1; } @@ -240,6 +240,23 @@ static int bootm_find_fdt(int flag, int argc, char * const argv[]) } #endif +#if defined(CONFIG_FIT) +static int bootm_find_loadables(int flag, int argc, char * const argv[]) +{ + int ret; + + /* find all of the loadables */ + ret = boot_get_loadable(argc, argv, images, IH_ARCH_DEFAULT, + NULL, NULL); + if (ret) { + printf(Loadable(s) is corrupt or invalid\n); + return 1; + } + + return 0; +} +#endif + int bootm_find_ramdisk_fdt(int flag, int argc, char * const argv[]) { if (bootm_find_ramdisk(flag, argc, argv)) @@ -250,6 +267,11 @@ int bootm_find_ramdisk_fdt(int flag, int argc, char * const argv[]) return 1; #endif +#if defined(CONFIG_FIT) + if (bootm_find_loadables(flag, argc, argv)) + return 1; +#endif + return 0; } diff --git a/common/image-fit.c b/common/image-fit.c index fc9ea1f..ecd3e67 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1544,6 +1544,8 @@ static const char *fit_get_image_type_property(int type) return FIT_RAMDISK_PROP; case IH_TYPE_X86_SETUP: return FIT_SETUP_PROP; + case IH_TYPE_LOADABLE: + return FIT_LOADABLE_PROP; } return unknown; @@ -1661,7 +1663,11 @@ int fit_image_load(bootm_headers_t *images, ulong addr, os_ok = image_type == IH_TYPE_FLATDT || fit_image_check_os(fit, noffset, IH_OS_LINUX) || fit_image_check_os(fit, noffset, IH_OS_OPENRTOS); - if (!type_ok || !os_ok) { + + /* If either of the checks fail, we should report an error, but +* if the image type is coming from the loadables field, we +* don't care what it is */ + if ((!type_ok || !os_ok) image_type != IH_TYPE_LOADABLE) { fit_image_get_os(fit, noffset, os); printf(No %s %s %s Image\n, genimg_get_os_name(os), diff --git a/common/image.c b/common/image.c index fdec496..e5cff05 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);