]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/image.c
fastboot: sparse: fix sparse blocks calculation
[people/ms/u-boot.git] / common / image.c
index e6071099d6365ecc63483c2c1ab4b1df400997ac..26d6c9a59279f9953643996c17fdbd123c8830c1 100644 (file)
@@ -29,7 +29,7 @@
 #include <image.h>
 #include <mapmem.h>
 
-#if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT)
+#if IMAGE_ENABLE_FIT || IMAGE_ENABLE_OF_LIBFDT
 #include <libfdt.h>
 #include <fdt_support.h>
 #endif
@@ -158,6 +158,7 @@ static const table_entry_t uimage_type[] = {
        {       IH_TYPE_RKIMAGE,    "rkimage",    "Rockchip Boot Image" },
        {       IH_TYPE_RKSD,       "rksd",       "Rockchip SD Boot Image" },
        {       IH_TYPE_RKSPI,      "rkspi",      "Rockchip SPI Boot Image" },
+       {       IH_TYPE_ZYNQIMAGE,  "zynqimage",  "Xilinx Zynq Boot Image" },
        {       -1,                 "",           "",                   },
 };
 
@@ -457,24 +458,29 @@ ulong getenv_bootm_low(void)
 
 phys_size_t getenv_bootm_size(void)
 {
-       phys_size_t tmp;
+       phys_size_t tmp, size;
+       phys_addr_t start;
        char *s = getenv("bootm_size");
        if (s) {
                tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
                return tmp;
        }
+
+#if defined(CONFIG_ARM) && defined(CONFIG_NR_DRAM_BANKS)
+       start = gd->bd->bi_dram[0].start;
+       size = gd->bd->bi_dram[0].size;
+#else
+       start = gd->bd->bi_memstart;
+       size = gd->bd->bi_memsize;
+#endif
+
        s = getenv("bootm_low");
        if (s)
                tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
        else
-               tmp = 0;
-
+               tmp = start;
 
-#if defined(CONFIG_ARM) && defined(CONFIG_NR_DRAM_BANKS)
-       return gd->bd->bi_dram[0].size - tmp;
-#else
-       return gd->bd->bi_memsize - tmp;
-#endif
+       return size - (tmp - start);
 }
 
 phys_size_t getenv_bootm_mapsize(void)
@@ -602,11 +608,9 @@ const char *genimg_get_type_name(uint8_t type)
        return (get_table_entry_name(uimage_type, "Unknown Image", type));
 }
 
-const char *genimg_get_type_short_name(uint8_t type)
+static const char *genimg_get_short_name(const table_entry_t *table, int val)
 {
-       const table_entry_t *table;
-
-       table = get_table_entry(uimage_type, type);
+       table = get_table_entry(table, val);
        if (!table)
                return "unknown";
 #if defined(USE_HOSTCC) || !defined(CONFIG_NEEDS_MANUAL_RELOC)
@@ -616,12 +620,32 @@ const char *genimg_get_type_short_name(uint8_t type)
 #endif
 }
 
+const char *genimg_get_type_short_name(uint8_t type)
+{
+       return genimg_get_short_name(uimage_type, type);
+}
+
 const char *genimg_get_comp_name(uint8_t comp)
 {
        return (get_table_entry_name(uimage_comp, "Unknown Compression",
                                        comp));
 }
 
+const char *genimg_get_comp_short_name(uint8_t comp)
+{
+       return genimg_get_short_name(uimage_comp, comp);
+}
+
+const char *genimg_get_os_short_name(uint8_t os)
+{
+       return genimg_get_short_name(uimage_os, os);
+}
+
+const char *genimg_get_arch_short_name(uint8_t arch)
+{
+       return genimg_get_short_name(uimage_arch, arch);
+}
+
 /**
  * get_table_entry_id - translate short entry name to id
  * @table: pointer to a translation table for entries of a specific type
@@ -701,7 +725,7 @@ ulong genimg_get_kernel_addr_fit(char * const img_addr,
                kernel_addr = load_addr;
                debug("*  kernel: default image load address = 0x%08lx\n",
                      load_addr);
-#if defined(CONFIG_FIT)
+#if CONFIG_IS_ENABLED(FIT)
        } else if (fit_parse_conf(img_addr, load_addr, &kernel_addr,
                                  fit_uname_config)) {
                debug("*  kernel: config '%s' from image at 0x%08lx\n",
@@ -756,7 +780,7 @@ int genimg_get_format(const void *img_addr)
        if (image_check_magic(hdr))
                return IMAGE_FORMAT_LEGACY;
 #endif
-#if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT)
+#if IMAGE_ENABLE_FIT || IMAGE_ENABLE_OF_LIBFDT
        if (fdt_check_header(img_addr) == 0)
                return IMAGE_FORMAT_FIT;
 #endif
@@ -793,7 +817,7 @@ ulong genimg_get_image(ulong img_addr)
 
                /* get header size */
                h_size = image_get_header_size();
-#if defined(CONFIG_FIT)
+#if IMAGE_ENABLE_FIT
                if (sizeof(struct fdt_header) > h_size)
                        h_size = sizeof(struct fdt_header);
 #endif
@@ -815,7 +839,7 @@ ulong genimg_get_image(ulong img_addr)
                                        ram_addr, d_size);
                        break;
 #endif
-#if defined(CONFIG_FIT)
+#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, "
@@ -856,7 +880,7 @@ ulong genimg_get_image(ulong img_addr)
  */
 int genimg_has_config(bootm_headers_t *images)
 {
-#if defined(CONFIG_FIT)
+#if IMAGE_ENABLE_FIT
        if (images->fit_uname_cfg)
                return 1;
 #endif
@@ -897,7 +921,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
 #ifdef CONFIG_SUPPORT_RAW_INITRD
        char *end;
 #endif
-#if defined(CONFIG_FIT)
+#if IMAGE_ENABLE_FIT
        const char      *fit_uname_config = images->fit_uname_cfg;
        const char      *fit_uname_ramdisk = NULL;
        ulong           default_addr;
@@ -913,7 +937,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
         * Look for an Android boot image.
         */
        buf = map_sysmem(images->os.start, 0);
-       if (genimg_get_format(buf) == IMAGE_FORMAT_ANDROID)
+       if (buf && genimg_get_format(buf) == IMAGE_FORMAT_ANDROID)
                select = argv[0];
 #endif
 
@@ -928,7 +952,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
                debug("## Skipping init Ramdisk\n");
                rd_len = rd_data = 0;
        } else if (select || genimg_has_config(images)) {
-#if defined(CONFIG_FIT)
+#if IMAGE_ENABLE_FIT
                if (select) {
                        /*
                         * If the init ramdisk comes from the FIT image and
@@ -959,7 +983,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
                                                "0x%08lx\n",
                                                rd_addr);
                        }
-#if defined(CONFIG_FIT)
+#if IMAGE_ENABLE_FIT
                } else {
                        /* use FIT configuration provided in first bootm
                         * command argument. If the property is not defined,
@@ -1002,7 +1026,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
                        rd_load = image_get_load(rd_hdr);
                        break;
 #endif
-#if defined(CONFIG_FIT)
+#if IMAGE_ENABLE_FIT
                case IMAGE_FORMAT_FIT:
                        rd_noffset = fit_image_load(images,
                                        rd_addr, &fit_uname_ramdisk,
@@ -1112,8 +1136,7 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
                if (initrd_high == ~0)
                        initrd_copy_to_ram = 0;
        } else {
-               /* not set, no restrictions to load high */
-               initrd_high = ~0;
+               initrd_high = getenv_bootm_mapsize() + getenv_bootm_low();
        }
 
 
@@ -1179,14 +1202,14 @@ error:
 int boot_get_setup(bootm_headers_t *images, uint8_t arch,
                   ulong *setup_start, ulong *setup_len)
 {
-#if defined(CONFIG_FIT)
+#if IMAGE_ENABLE_FIT
        return boot_get_setup_fit(images, arch, setup_start, setup_len);
 #else
        return -ENOENT;
 #endif
 }
 
-#if defined(CONFIG_FIT)
+#if IMAGE_ENABLE_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)
 {
@@ -1265,7 +1288,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 + getenv_bootm_low() address. If "bootargs" U-Boot environemnt
  * variable is present its contents is copied to allocated kernel
  * command line.
  *