
Use this function instead of fit_image_get_emb_data() data, since it works will FITs that use external data.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Fix unbalanced {}
arch/arm/cpu/armv8/sec_firmware.c | 12 ++++++------ arch/arm/mach-k3/r5/sysfw-loader.c | 9 +-------- arch/x86/lib/bootm.c | 9 +++------ common/splash_source.c | 20 ++++++-------------- common/update.c | 2 +- 5 files changed, 17 insertions(+), 35 deletions(-)
diff --git a/arch/arm/cpu/armv8/sec_firmware.c b/arch/arm/cpu/armv8/sec_firmware.c index e768859acfb..e3f8a6dcd60 100644 --- a/arch/arm/cpu/armv8/sec_firmware.c +++ b/arch/arm/cpu/armv8/sec_firmware.c @@ -83,6 +83,8 @@ static int sec_firmware_check_copy_loadable(const void *sec_firmware_img, { phys_addr_t sec_firmware_loadable_addr = 0; int conf_node_off, ld_node_off, images; + const void *data; + size_t size; const char *name, *str, *type; ulong load; int len; @@ -112,8 +114,6 @@ static int sec_firmware_check_copy_loadable(const void *sec_firmware_img,
for (str = name; str && ((str - name) < len); str = strchr(str, '\0') + 1) { - struct abuf buf; - printf("%s: '%s'\n", type, str); ld_node_off = fdt_subnode_offset(sec_firmware_img, images, str); if (ld_node_off < 0) { @@ -128,8 +128,8 @@ static int sec_firmware_check_copy_loadable(const void *sec_firmware_img, return -EINVAL; }
- if (fit_image_get_emb_data(sec_firmware_img, ld_node_off, - &buf)) { + if (fit_image_get_data(sec_firmware_img, ld_node_off, + &data, &size)) { printf("SEC Loadable: Can't get subimage data/size"); return -ENOENT; } @@ -147,9 +147,9 @@ static int sec_firmware_check_copy_loadable(const void *sec_firmware_img, /* Copy loadable to secure memory and flush dcache */ debug("%s copied to address 0x%p\n", FIT_LOADABLE_PROP, (void *)sec_firmware_loadable_addr); - memcpy((void *)sec_firmware_loadable_addr, buf.data, buf.size); + memcpy((void *)sec_firmware_loadable_addr, data, size); flush_dcache_range(sec_firmware_loadable_addr, - sec_firmware_loadable_addr + buf.size); + sec_firmware_loadable_addr + size);
/* Populate loadable address only for Trusted OS */ if (!strcmp(str, "trustedOS@1")) { diff --git a/arch/arm/mach-k3/r5/sysfw-loader.c b/arch/arm/mach-k3/r5/sysfw-loader.c index 1895fb385a5..f0ad7559b97 100644 --- a/arch/arm/mach-k3/r5/sysfw-loader.c +++ b/arch/arm/mach-k3/r5/sysfw-loader.c @@ -117,14 +117,7 @@ static int fit_get_data_by_name(const void *fit, int images, const char *name, if (node_offset < 0) return -ENOENT;
- ret = fit_image_get_emb_data(fit, node_offset, &buf); - if (ret) - return ret; - - *addr = buf.data; - *size = buf.size; - - return 0; + return fit_image_get_data(fit, node_offset, addr, size); }
static void k3_start_system_controller(int rproc_id, bool rproc_loaded, diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c index 16980c15081..2a7933cdaf8 100644 --- a/arch/x86/lib/bootm.c +++ b/arch/x86/lib/bootm.c @@ -106,16 +106,13 @@ static int boot_prep_linux(struct bootm_headers *images) is_zimage = 1; #if defined(CONFIG_FIT) } else if (images->fit_uname_os && is_zimage) { - struct abuf buf; - - ret = fit_image_get_emb_data(images->fit_hdr_os, - images->fit_noffset_os, &buf); + ret = fit_image_get_data(images->fit_hdr_os, + images->fit_noffset_os, + (const void **)&data, &len); if (ret) { puts("Can't get image data/size!\n"); goto error; } - data = buf.data; - len = buf.size; is_zimage = 1; #endif } diff --git a/common/splash_source.c b/common/splash_source.c index 37648b8b9f3..2df78a4f2d7 100644 --- a/common/splash_source.c +++ b/common/splash_source.c @@ -347,6 +347,8 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr) int res; int node_offset; const char *splash_file; + const void *internal_splash_data; + size_t internal_splash_size; int external_splash_addr; int external_splash_size; bool is_splash_external = false; @@ -354,7 +356,6 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr) const u32 *fit_header; u32 fit_size; const size_t header_size = sizeof(struct legacy_img_hdr); - struct abuf buf;
/* Read in image header */ res = splash_storage_read_raw(location, bmp_load_addr, header_size); @@ -394,19 +395,10 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr) }
/* Extract the splash data from FIT */ - /* 1. Test if splash is in FIT internal data. */ - if (!fit_image_get_emb_data(fit_header, node_offset, &buf)) { - memmove((void *)(uintptr_t)bmp_load_addr, buf.data, buf.size); - /* 2. Test if splash is in FIT external data with fixed position. */ - } else if (!fit_image_get_data_position(fit_header, node_offset, &external_splash_addr)) - is_splash_external = true; - /* 3. Test if splash is in FIT external data with offset. */ - else if (!fit_image_get_data_offset(fit_header, node_offset, &external_splash_addr)) { - /* Align data offset to 4-byte boundary */ - fit_size = ALIGN(fdt_totalsize(fit_header), 4); - /* External splash offset means the offset by end of FIT header */ - external_splash_addr += location->offset + fit_size; - is_splash_external = true; + if (!fit_image_get_data(fit_header, node_offset, &internal_splash_data, + &internal_splash_size)) { + memmove((void *)(uintptr_t)bmp_load_addr, internal_splash_data, + internal_splash_size); } else { printf("Failed to get splash image from FIT\n"); return -ENODATA; diff --git a/common/update.c b/common/update.c index d149ca18e78..6801b49479d 100644 --- a/common/update.c +++ b/common/update.c @@ -200,7 +200,7 @@ static int update_fit_getparams(const void *fit, int noffset, ulong *addr, { const void *data;
- if (fit_image_get_emb_data(fit, noffset, &data, (size_t *)size)) + if (fit_image_get_data(fit, noffset, &data, (size_t *)size)) return 1;
if (fit_image_get_load(fit, noffset, (ulong *)fladdr))