]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/image.c
configs: Migrate CONFIG_SPL_FRAMEWORK
[people/ms/u-boot.git] / common / image.c
index 8c35327745ba2f129b04c6a12403614e7632862e..e9609cd4f7ffad6fb443d42f81e96db27a62f3ac 100644 (file)
 #include <status_led.h>
 #endif
 
-#ifdef CONFIG_HAS_DATAFLASH
-#include <dataflash.h>
-#endif
-
-#ifdef CONFIG_LOGBUFFER
-#include <logbuff.h>
-#endif
-
 #include <rtc.h>
 
 #include <environment.h>
@@ -99,6 +91,7 @@ static const table_entry_t uimage_arch[] = {
 
 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",               },
@@ -167,6 +160,7 @@ static const table_entry_t uimage_type[] = {
        {       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",},
        {       -1,                 "",           "",                   },
 };
 
@@ -388,9 +382,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
@@ -465,9 +456,9 @@ static int on_loadaddr(const char *name, const char *value, enum env_op op,
 }
 U_BOOT_ENV_CALLBACK(loadaddr, on_loadaddr);
 
-ulong getenv_bootm_low(void)
+ulong env_get_bootm_low(void)
 {
-       char *s = getenv("bootm_low");
+       char *s = env_get("bootm_low");
        if (s) {
                ulong tmp = simple_strtoul(s, NULL, 16);
                return tmp;
@@ -482,11 +473,11 @@ ulong getenv_bootm_low(void)
 #endif
 }
 
-phys_size_t getenv_bootm_size(void)
+phys_size_t env_get_bootm_size(void)
 {
        phys_size_t tmp, size;
        phys_addr_t start;
-       char *s = getenv("bootm_size");
+       char *s = env_get("bootm_size");
        if (s) {
                tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
                return tmp;
@@ -500,7 +491,7 @@ phys_size_t getenv_bootm_size(void)
        size = gd->bd->bi_memsize;
 #endif
 
-       s = getenv("bootm_low");
+       s = env_get("bootm_low");
        if (s)
                tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
        else
@@ -509,10 +500,10 @@ phys_size_t getenv_bootm_size(void)
        return size - (tmp - start);
 }
 
-phys_size_t getenv_bootm_mapsize(void)
+phys_size_t env_get_bootm_mapsize(void)
 {
        phys_size_t tmp;
-       char *s = getenv("bootm_mapsize");
+       char *s = env_get("bootm_mapsize");
        if (s) {
                tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
                return tmp;
@@ -521,7 +512,7 @@ phys_size_t getenv_bootm_mapsize(void)
 #if defined(CONFIG_SYS_BOOTMAPSZ)
        return CONFIG_SYS_BOOTMAPSZ;
 #else
-       return getenv_bootm_size();
+       return env_get_bootm_size();
 #endif
 }
 
@@ -561,7 +552,7 @@ void genimg_print_size(uint32_t size)
        printf("%d Bytes = ", size);
        print_size(size, "\n");
 #else
-       printf("%d Bytes = %.2f kB = %.2f MB\n",
+       printf("%d Bytes = %.2f KiB = %.2f MiB\n",
                        size, (double)size / 1.024e3,
                        (double)size / 1.048576e6);
 #endif
@@ -888,81 +879,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 +1011,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
@@ -1224,7 +1137,8 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
        ulong   initrd_high;
        int     initrd_copy_to_ram = 1;
 
-       if ((s = getenv("initrd_high")) != NULL) {
+       s = env_get("initrd_high");
+       if (s) {
                /* a value of "no" or a similar string will act like 0,
                 * turning the "load high" feature off. This is intentional.
                 */
@@ -1232,15 +1146,10 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
                if (initrd_high == ~0)
                        initrd_copy_to_ram = 0;
        } else {
-               initrd_high = getenv_bootm_mapsize() + getenv_bootm_low();
+               initrd_high = env_get_bootm_mapsize() + env_get_bootm_low();
        }
 
 
-#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);
 
@@ -1277,7 +1186,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");
                }
@@ -1306,7 +1216,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)
 {
@@ -1317,8 +1227,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)) {
@@ -1328,10 +1236,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
@@ -1365,7 +1271,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);
@@ -1440,10 +1346,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
@@ -1505,7 +1409,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 + getenv_bootm_low() address. If "bootargs" U-Boot environemnt
+ * BOOTMAPSZ + env_get_bootm_low() address. If "bootargs" U-Boot environemnt
  * variable is present its contents is copied to allocated kernel
  * command line.
  *
@@ -1519,12 +1423,13 @@ int boot_get_cmdline(struct lmb *lmb, ulong *cmd_start, ulong *cmd_end)
        char *s;
 
        cmdline = (char *)(ulong)lmb_alloc_base(lmb, CONFIG_SYS_BARGSIZE, 0xf,
-                               getenv_bootm_mapsize() + getenv_bootm_low());
+                               env_get_bootm_mapsize() + env_get_bootm_low());
 
        if (cmdline == NULL)
                return -1;
 
-       if ((s = getenv("bootargs")) == NULL)
+       s = env_get("bootargs");
+       if (!s)
                s = "";
 
        strcpy(cmdline, s);
@@ -1545,7 +1450,7 @@ int boot_get_cmdline(struct lmb *lmb, ulong *cmd_start, ulong *cmd_end)
  * @kbd: double pointer to board info data
  *
  * boot_get_kbd() allocates space for kernel copy of board info data below
- * BOOTMAPSZ + getenv_bootm_low() address and kernel board info is initialized
+ * BOOTMAPSZ + env_get_bootm_low() address and kernel board info is initialized
  * with the current u-boot board info data.
  *
  * returns:
@@ -1555,7 +1460,7 @@ int boot_get_cmdline(struct lmb *lmb, ulong *cmd_start, ulong *cmd_end)
 int boot_get_kbd(struct lmb *lmb, bd_t **kbd)
 {
        *kbd = (bd_t *)(ulong)lmb_alloc_base(lmb, sizeof(bd_t), 0xf,
-                               getenv_bootm_mapsize() + getenv_bootm_low());
+                               env_get_bootm_mapsize() + env_get_bootm_low());
        if (*kbd == NULL)
                return -1;
 
@@ -1576,10 +1481,7 @@ int image_setup_linux(bootm_headers_t *images)
 {
        ulong of_size = images->ft_len;
        char **of_flat_tree = &images->ft_addr;
-       ulong *initrd_start = &images->initrd_start;
-       ulong *initrd_end = &images->initrd_end;
        struct lmb *lmb = &images->lmb;
-       ulong rd_len;
        int ret;
 
        if (IMAGE_ENABLE_OF_LIBFDT)
@@ -1593,13 +1495,6 @@ int image_setup_linux(bootm_headers_t *images)
                        return ret;
                }
        }
-       if (IMAGE_ENABLE_RAMDISK_HIGH) {
-               rd_len = images->rd_end - images->rd_start;
-               ret = boot_ramdisk_high(lmb, images->rd_start, rd_len,
-                               initrd_start, initrd_end);
-               if (ret)
-                       return ret;
-       }
 
        if (IMAGE_ENABLE_OF_LIBFDT) {
                ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size);