X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fimage.c;h=4d4248f234fb2ef11d4e152b1d11a0ad9a644c58;hb=2bc18ce570ab4f1ba91974376bb5377ca4990203;hp=a058eb85e107bce98c7a155344250cc30f16ef18;hpb=470135be276b2d92c6da464c68839202d4ff0d08;p=oweals%2Fu-boot.git diff --git a/common/image.c b/common/image.c index a058eb85e1..4d4248f234 100644 --- a/common/image.c +++ b/common/image.c @@ -1,10 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2008 Semihalf * * (C) Copyright 2000-2006 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * SPDX-License-Identifier: GPL-2.0+ */ #ifndef USE_HOSTCC @@ -15,14 +14,6 @@ #include #endif -#ifdef CONFIG_HAS_DATAFLASH -#include -#endif - -#ifdef CONFIG_LOGBUFFER -#include -#endif - #include #include @@ -30,7 +21,7 @@ #include #if IMAGE_ENABLE_FIT || IMAGE_ENABLE_OF_LIBFDT -#include +#include #include #include #include @@ -94,11 +85,13 @@ static const table_entry_t uimage_arch[] = { { IH_ARCH_ARC, "arc", "ARC", }, { IH_ARCH_X86_64, "x86_64", "AMD x86_64", }, { IH_ARCH_XTENSA, "xtensa", "Xtensa", }, + { IH_ARCH_RISCV, "riscv", "RISC-V", }, { -1, "", "", }, }; static const table_entry_t uimage_os[] = { { IH_OS_INVALID, "invalid", "Invalid OS", }, + { IH_OS_ARM_TRUSTED_FIRMWARE, "arm-trusted-firmware", "ARM Trusted Firmware" }, { IH_OS_LINUX, "linux", "Linux", }, #if defined(CONFIG_LYNXKDI) || defined(USE_HOSTCC) { IH_OS_LYNXOS, "lynxos", "LynxOS", }, @@ -107,6 +100,7 @@ static const table_entry_t uimage_os[] = { { IH_OS_OSE, "ose", "Enea OSE", }, { IH_OS_PLAN9, "plan9", "Plan 9", }, { IH_OS_RTEMS, "rtems", "RTEMS", }, + { IH_OS_TEE, "tee", "Trusted Execution Environment" }, { IH_OS_U_BOOT, "u-boot", "U-Boot", }, { IH_OS_VXWORKS, "vxworks", "VxWorks", }, #if defined(CONFIG_CMD_ELF) || defined(USE_HOSTCC) @@ -145,13 +139,16 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_KERNEL_NOLOAD, "kernel_noload", "Kernel Image (no loading done)", }, { IH_TYPE_KWBIMAGE, "kwbimage", "Kirkwood Boot Image",}, { IH_TYPE_IMXIMAGE, "imximage", "Freescale i.MX Boot Image",}, + { IH_TYPE_IMX8IMAGE, "imx8image", "NXP i.MX8 Boot Image",}, + { IH_TYPE_IMX8MIMAGE, "imx8mimage", "NXP i.MX8M Boot Image",}, { IH_TYPE_INVALID, "invalid", "Invalid Image", }, { IH_TYPE_MULTI, "multi", "Multi-File Image", }, { IH_TYPE_OMAPIMAGE, "omapimage", "TI OMAP SPL With GP CH",}, { IH_TYPE_PBLIMAGE, "pblimage", "Freescale PBL Boot Image",}, { IH_TYPE_RAMDISK, "ramdisk", "RAMDisk Image", }, { IH_TYPE_SCRIPT, "script", "Script", }, - { IH_TYPE_SOCFPGAIMAGE, "socfpgaimage", "Altera SOCFPGA preloader",}, + { IH_TYPE_SOCFPGAIMAGE, "socfpgaimage", "Altera SoCFPGA CV/AV preloader",}, + { IH_TYPE_SOCFPGAIMAGE_V1, "socfpgaimage_v1", "Altera SoCFPGA A10 preloader",}, { IH_TYPE_STANDALONE, "standalone", "Standalone Program", }, { IH_TYPE_UBLIMAGE, "ublimage", "Davinci UBL image",}, { IH_TYPE_MXSIMAGE, "mxsimage", "Freescale MXS Boot Image",}, @@ -164,9 +161,13 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_VYBRIDIMAGE, "vybridimage", "Vybrid Boot Image", }, { IH_TYPE_ZYNQIMAGE, "zynqimage", "Xilinx Zynq Boot Image" }, { IH_TYPE_ZYNQMPIMAGE, "zynqmpimage", "Xilinx ZynqMP Boot Image" }, + { IH_TYPE_ZYNQMPBIF, "zynqmpbif", "Xilinx ZynqMP Boot Image (bif)" }, { IH_TYPE_FPGA, "fpga", "FPGA Image" }, { IH_TYPE_TEE, "tee", "Trusted Execution Environment Image",}, { IH_TYPE_FIRMWARE_IVT, "firmware_ivt", "Firmware with HABv4 IVT" }, + { IH_TYPE_PMMC, "pmmc", "TI Power Management Micro-Controller Firmware",}, + { IH_TYPE_STM32IMAGE, "stm32image", "STMicroelectronics STM32 Image" }, + { IH_TYPE_MTKIMAGE, "mtk_image", "MediaTek BootROM loadable Image" }, { -1, "", "", }, }; @@ -388,9 +389,6 @@ void image_print_contents(const void *ptr) * flag. Verification done covers data and header integrity and os/type/arch * fields checking. * - * If dataflash support is enabled routine checks for dataflash addresses - * and handles required dataflash reads. - * * returns: * pointer to a ramdisk image header, if image was found and valid * otherwise, return NULL @@ -888,81 +886,6 @@ int genimg_get_format(const void *img_addr) return IMAGE_FORMAT_INVALID; } -/** - * genimg_get_image - get image from special storage (if necessary) - * @img_addr: image start address - * - * genimg_get_image() checks if provided image start address is located - * in a dataflash storage. If so, image is moved to a system RAM memory. - * - * returns: - * image start address after possible relocation from special storage - */ -ulong genimg_get_image(ulong img_addr) -{ - ulong ram_addr = img_addr; - -#ifdef CONFIG_HAS_DATAFLASH - ulong h_size, d_size; - - if (addr_dataflash(img_addr)) { - void *buf; - - /* ger RAM address */ - ram_addr = CONFIG_SYS_LOAD_ADDR; - - /* get header size */ - h_size = image_get_header_size(); -#if IMAGE_ENABLE_FIT - if (sizeof(struct fdt_header) > h_size) - h_size = sizeof(struct fdt_header); -#endif - - /* read in header */ - debug(" Reading image header from dataflash address " - "%08lx to RAM address %08lx\n", img_addr, ram_addr); - - buf = map_sysmem(ram_addr, 0); - read_dataflash(img_addr, h_size, buf); - - /* get data size */ - switch (genimg_get_format(buf)) { -#if defined(CONFIG_IMAGE_FORMAT_LEGACY) - case IMAGE_FORMAT_LEGACY: - d_size = image_get_data_size(buf); - debug(" Legacy format image found at 0x%08lx, " - "size 0x%08lx\n", - ram_addr, d_size); - break; -#endif -#if IMAGE_ENABLE_FIT - case IMAGE_FORMAT_FIT: - d_size = fit_get_size(buf) - h_size; - debug(" FIT/FDT format image found at 0x%08lx, " - "size 0x%08lx\n", - ram_addr, d_size); - break; -#endif - default: - printf(" No valid image found at 0x%08lx\n", - img_addr); - return ram_addr; - } - - /* read in image data */ - debug(" Reading image remaining data from dataflash address " - "%08lx to RAM address %08lx\n", img_addr + h_size, - ram_addr + h_size); - - read_dataflash(img_addr + h_size, d_size, - (char *)(buf + h_size)); - - } -#endif /* CONFIG_HAS_DATAFLASH */ - - return ram_addr; -} - /** * fit_has_config - check if there is a valid FIT configuration * @images: pointer to the bootm command headers structure @@ -1095,9 +1018,6 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, } #endif - /* copy from dataflash if needed */ - rd_addr = genimg_get_image(rd_addr); - /* * Check if there is an initrd image at the * address provided in the second bootm argument @@ -1237,11 +1157,6 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len, } -#ifdef CONFIG_LOGBUFFER - /* Prevent initrd from overwriting logbuffer */ - lmb_reserve(lmb, logbuffer_base() - LOGBUFF_OVERHEAD, LOGBUFF_RESERVE); -#endif - debug("## initrd_high = 0x%08lx, copy_to_ram = %d\n", initrd_high, initrd_copy_to_ram); @@ -1278,7 +1193,8 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len, * AMP boot scenarios in which we might not be * HW cache coherent */ - flush_cache((unsigned long)*initrd_start, rd_len); + flush_cache((unsigned long)*initrd_start, + ALIGN(rd_len, ARCH_DMA_MINALIGN)); #endif puts("OK\n"); } @@ -1307,7 +1223,7 @@ int boot_get_setup(bootm_headers_t *images, uint8_t arch, } #if IMAGE_ENABLE_FIT -#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_XILINX) +#if defined(CONFIG_FPGA) int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images, uint8_t arch, const ulong *ld_start, ulong * const ld_len) { @@ -1318,8 +1234,6 @@ int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images, const char *uname, *name; int err; int devnum = 0; /* TODO support multi fpga platforms */ - const fpga_desc * const desc = fpga_get_desc(devnum); - xilinx_desc *desc_xilinx = desc->devdesc; /* Check to see if the images struct has a FIT configuration */ if (!genimg_has_config(images)) { @@ -1329,10 +1243,8 @@ int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images, /* * 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 @@ -1366,7 +1278,7 @@ int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images, return fit_img_result; } - if (img_len >= desc_xilinx->size) { + if (!fpga_is_partial_data(devnum, img_len)) { name = "full"; err = fpga_loadbitstream(devnum, (char *)img_data, img_len, BIT_FULL); @@ -1441,10 +1353,8 @@ int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images, /* * 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 @@ -1506,7 +1416,7 @@ int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images, * @cmd_end: pointer to a ulong variable, will hold cmdline end * * boot_get_cmdline() allocates space for kernel command line below - * BOOTMAPSZ + env_get_bootm_low() address. If "bootargs" U-Boot environemnt + * BOOTMAPSZ + env_get_bootm_low() address. If "bootargs" U-Boot environment * variable is present its contents is copied to allocated kernel * command line. *