X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fimage-fit.c;h=109ecfaaccb79f2a6401938e2180c511e3af9eef;hb=27ec910e8c32a0880a57f02c6c4cb7aa3fb5a1fe;hp=1b0234a90cb1eefcc7533f630491e8a68098292a;hpb=58c8c0963b1c720802c46ac4288c897e5f9cd296;p=u-boot diff --git a/common/image-fit.c b/common/image-fit.c index 1b0234a90c..109ecfaacc 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -14,6 +14,7 @@ #include #else #include +#include #include #include #include @@ -776,6 +777,54 @@ int fit_image_get_data(const void *fit, int noffset, return 0; } +/** + * Get 'data-offset' property from a given image node. + * + * @fit: pointer to the FIT image header + * @noffset: component image node offset + * @data_offset: holds the data-offset property + * + * returns: + * 0, on success + * -ENOENT if the property could not be found + */ +int fit_image_get_data_offset(const void *fit, int noffset, int *data_offset) +{ + const fdt32_t *val; + + val = fdt_getprop(fit, noffset, FIT_DATA_OFFSET_PROP, NULL); + if (!val) + return -ENOENT; + + *data_offset = fdt32_to_cpu(*val); + + return 0; +} + +/** + * Get 'data-size' property from a given image node. + * + * @fit: pointer to the FIT image header + * @noffset: component image node offset + * @data_size: holds the data-size property + * + * returns: + * 0, on success + * -ENOENT if the property could not be found + */ +int fit_image_get_data_size(const void *fit, int noffset, int *data_size) +{ + const fdt32_t *val; + + val = fdt_getprop(fit, noffset, FIT_DATA_SIZE_PROP, NULL); + if (!val) + return -ENOENT; + + *data_size = fdt32_to_cpu(*val); + + return 0; +} + /** * fit_image_hash_get_algo - get hash algorithm name * @fit: pointer to the FIT format image header @@ -1026,7 +1075,7 @@ int fit_image_verify(const void *fit, int image_noffset) } /* Process all hash subnodes of the component image node */ - fdt_for_each_subnode(fit, noffset, image_noffset) { + fdt_for_each_subnode(noffset, fit, image_noffset) { const char *name = fit_get_name(fit, noffset, NULL); /* @@ -1161,11 +1210,18 @@ int fit_image_check_os(const void *fit, int noffset, uint8_t os) int fit_image_check_arch(const void *fit, int noffset, uint8_t arch) { uint8_t image_arch; + int aarch32_support = 0; + +#ifdef CONFIG_ARM64_SUPPORT_AARCH32 + aarch32_support = 1; +#endif if (fit_image_get_arch(fit, noffset, &image_arch)) return 0; return (arch == image_arch) || - (arch == IH_ARCH_I386 && image_arch == IH_ARCH_X86_64); + (arch == IH_ARCH_I386 && image_arch == IH_ARCH_X86_64) || + (arch == IH_ARCH_ARM64 && image_arch == IH_ARCH_ARM && + aarch32_support); } /** @@ -1457,7 +1513,7 @@ int fit_conf_get_prop_node(const void *fit, int noffset, void fit_conf_print(const void *fit, int noffset, const char *p) { char *desc; - char *uname; + const char *uname; int ret; int loadables_index; @@ -1469,7 +1525,7 @@ void fit_conf_print(const void *fit, int noffset, const char *p) else printf("%s\n", desc); - uname = (char *)fdt_getprop(fit, noffset, FIT_KERNEL_PROP, NULL); + uname = fdt_getprop(fit, noffset, FIT_KERNEL_PROP, NULL); printf("%s Kernel: ", p); if (uname == NULL) printf("unavailable\n"); @@ -1477,26 +1533,23 @@ void fit_conf_print(const void *fit, int noffset, const char *p) printf("%s\n", uname); /* Optional properties */ - uname = (char *)fdt_getprop(fit, noffset, FIT_RAMDISK_PROP, NULL); + uname = fdt_getprop(fit, noffset, FIT_RAMDISK_PROP, NULL); if (uname) printf("%s Init Ramdisk: %s\n", p, uname); - uname = (char *)fdt_getprop(fit, noffset, FIT_FDT_PROP, NULL); + uname = fdt_getprop(fit, noffset, FIT_FDT_PROP, NULL); if (uname) printf("%s FDT: %s\n", p, uname); - uname = (char *)fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL); + uname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL); if (uname) printf("%s FPGA: %s\n", p, uname); /* Print out all of the specified loadables */ for (loadables_index = 0; - fdt_get_string_index(fit, noffset, - FIT_LOADABLE_PROP, - loadables_index, - (const char **)&uname) == 0; - loadables_index++) - { + uname = fdt_stringlist_get(fit, noffset, FIT_LOADABLE_PROP, + loadables_index, NULL), uname; + loadables_index++) { if (loadables_index == 0) { printf("%s Loadables: ", p); } else { @@ -1508,12 +1561,6 @@ void fit_conf_print(const void *fit, int noffset, const char *p) static int fit_image_select(const void *fit, int rd_noffset, int verify) { -#if !defined(USE_HOSTCC) && defined(CONFIG_FIT_IMAGE_POST_PROCESS) - const void *data; - size_t size; - int ret; -#endif - fit_image_print(fit, rd_noffset, " "); if (verify) { @@ -1525,23 +1572,6 @@ static int fit_image_select(const void *fit, int rd_noffset, int verify) puts("OK\n"); } -#if !defined(USE_HOSTCC) && defined(CONFIG_FIT_IMAGE_POST_PROCESS) - ret = fit_image_get_data(fit, rd_noffset, &data, &size); - if (ret) - return ret; - - /* perform any post-processing on the image data */ - board_fit_image_post_process((void **)&data, &size); - - /* - * update U-Boot's understanding of the "data" property start address - * and size according to the performed post-processing - */ - ret = fdt_setprop((void *)fit, rd_noffset, FIT_DATA_PROP, data, size); - if (ret) - return ret; -#endif - return 0; } @@ -1617,6 +1647,9 @@ int fit_image_load(bootm_headers_t *images, ulong addr, int type_ok, os_ok; ulong load, data, len; uint8_t os; +#ifndef USE_HOSTCC + uint8_t os_arch; +#endif const char *prop_name; int ret; @@ -1700,6 +1733,12 @@ int fit_image_load(bootm_headers_t *images, ulong addr, return -ENOEXEC; } #endif + +#ifndef USE_HOSTCC + fit_image_get_arch(fit, noffset, &os_arch); + images->os.arch = os_arch; +#endif + if (image_type == IH_TYPE_FLATDT && !fit_image_check_comp(fit, noffset, IH_COMP_NONE)) { puts("FDT image is compressed"); @@ -1741,6 +1780,12 @@ int fit_image_load(bootm_headers_t *images, ulong addr, bootstage_error(bootstage_id + BOOTSTAGE_SUB_GET_DATA); return -ENOENT; } + +#if !defined(USE_HOSTCC) && defined(CONFIG_FIT_IMAGE_POST_PROCESS) + /* perform any post-processing on the image data */ + board_fit_image_post_process((void **)&buf, &size); +#endif + len = (ulong)size; /* verify that image data is a proper FDT blob */