bootstage: Use show_boot_error() for -ve progress numbers
[pandora-u-boot.git] / common / image.c
index aacae5a..8df03f5 100644 (file)
@@ -94,6 +94,7 @@ static const table_entry_t uimage_arch[] = {
        {       IH_ARCH_BLACKFIN,       "blackfin",     "Blackfin",     },
        {       IH_ARCH_AVR32,          "avr32",        "AVR32",        },
        {       IH_ARCH_NDS32,          "nds32",        "NDS32",        },
+       {       IH_ARCH_OPENRISC,       "or1k",         "OpenRISC 1000",},
        {       -1,                     "",             "",             },
 };
 
@@ -372,13 +373,13 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
 
        if (!image_check_magic(rd_hdr)) {
                puts("Bad Magic Number\n");
-               show_boot_progress(-10);
+               show_boot_error(10);
                return NULL;
        }
 
        if (!image_check_hcrc(rd_hdr)) {
                puts("Bad Header Checksum\n");
-               show_boot_progress(-11);
+               show_boot_error(11);
                return NULL;
        }
 
@@ -389,7 +390,7 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
                puts("   Verifying Checksum ... ");
                if (!image_check_dcrc(rd_hdr)) {
                        puts("Bad Data CRC\n");
-                       show_boot_progress(-12);
+                       show_boot_error(12);
                        return NULL;
                }
                puts("OK\n");
@@ -402,7 +403,7 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
            !image_check_type(rd_hdr, IH_TYPE_RAMDISK)) {
                printf("No Linux %s Ramdisk Image\n",
                                genimg_get_arch_name(arch));
-               show_boot_progress(-13);
+               show_boot_error(13);
                return NULL;
        }
 
@@ -914,7 +915,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
                        show_boot_progress(120);
                        if (!fit_check_format(fit_hdr)) {
                                puts("Bad FIT ramdisk image format!\n");
-                               show_boot_progress(-120);
+                               show_boot_error(120);
                                return 1;
                        }
                        show_boot_progress(121);
@@ -931,7 +932,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
                                if (cfg_noffset < 0) {
                                        puts("Could not find configuration "
                                                "node\n");
-                                       show_boot_progress(-122);
+                                       show_boot_error(122);
                                        return 1;
                                }
                                fit_uname_config = fdt_get_name(fit_hdr,
@@ -951,7 +952,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
                        }
                        if (rd_noffset < 0) {
                                puts("Could not find subimage node\n");
-                               show_boot_progress(-124);
+                               show_boot_error(124);
                                return 1;
                        }
 
@@ -967,7 +968,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
                        if (fit_image_get_data(fit_hdr, rd_noffset, &data,
                                                &size)) {
                                puts("Could not find ramdisk subimage data!\n");
-                               show_boot_progress(-127);
+                               show_boot_error(127);
                                return 1;
                        }
                        show_boot_progress(128);
@@ -978,7 +979,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
                        if (fit_image_get_load(fit_hdr, rd_noffset, &rd_load)) {
                                puts("Can't get ramdisk subimage load "
                                        "address!\n");
-                               show_boot_progress(-129);
+                               show_boot_error(129);
                                return 1;
                        }
                        show_boot_progress(129);
@@ -1104,6 +1105,14 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
                        memmove_wd((void *)*initrd_start,
                                        (void *)rd_data, rd_len, CHUNKSZ);
 
+#ifdef CONFIG_MP
+                       /*
+                        * Ensure the image is flushed to memory to handle
+                        * AMP boot scenarios in which we might not be
+                        * HW cache coherent
+                        */
+                       flush_cache((unsigned long)*initrd_start, rd_len);
+#endif
                        puts("OK\n");
                }
        } else {
@@ -1280,16 +1289,14 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
 
                if (((ulong) desired_addr) == ~0UL) {
                        /* All ones means use fdt in place */
-                       desired_addr = fdt_blob;
+                       of_start = fdt_blob;
+                       lmb_reserve(lmb, (ulong)of_start, of_len);
                        disable_relocation = 1;
-               }
-               if (desired_addr) {
+               } else if (desired_addr) {
                        of_start =
                            (void *)(ulong) lmb_alloc_base(lmb, of_len, 0x1000,
-                                                          ((ulong)
-                                                           desired_addr)
-                                                          + of_len);
-                       if (desired_addr && of_start != desired_addr) {
+                                                          (ulong)desired_addr);
+                       if (of_start == 0) {
                                puts("Failed using fdt_high value for Device Tree");
                                goto error;
                        }
@@ -1367,7 +1374,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[],
        const image_header_t *fdt_hdr;
        ulong           fdt_addr;
        char            *fdt_blob = NULL;
-       ulong           image_start, image_end;
+       ulong           image_start, image_data, image_end;
        ulong           load_start, load_end;
 #if defined(CONFIG_FIT)
        void            *fit_hdr;
@@ -1475,21 +1482,28 @@ int boot_get_fdt(int flag, int argc, char * const argv[],
                         * make sure we don't overwrite initial image
                         */
                        image_start = (ulong)fdt_hdr;
+                       image_data = (ulong)image_get_data(fdt_hdr);
                        image_end = image_get_image_end(fdt_hdr);
 
                        load_start = image_get_load(fdt_hdr);
                        load_end = load_start + image_get_data_size(fdt_hdr);
 
+                       if (load_start == image_start ||
+                           load_start == image_data) {
+                               fdt_blob = (char *)image_data;
+                               break;
+                       }
+
                        if ((load_start < image_end) && (load_end > image_start)) {
                                fdt_error("fdt overwritten");
                                goto error;
                        }
 
                        debug("   Loading FDT from 0x%08lx to 0x%08lx\n",
-                                       image_get_data(fdt_hdr), load_start);
+                                       image_data, load_start);
 
                        memmove((void *)load_start,
-                                       (void *)image_get_data(fdt_hdr),
+                                       (void *)image_data,
                                        image_get_data_size(fdt_hdr));
 
                        fdt_blob = (char *)load_start;
@@ -3162,7 +3176,7 @@ static int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch,
                puts("   Verifying Hash Integrity ... ");
                if (!fit_image_check_hashes(fit, rd_noffset)) {
                        puts("Bad Data Hash\n");
-                       show_boot_progress(-125);
+                       show_boot_error(125);
                        return 0;
                }
                puts("OK\n");
@@ -3174,7 +3188,7 @@ static int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch,
            !fit_image_check_type(fit, rd_noffset, IH_TYPE_RAMDISK)) {
                printf("No Linux %s Ramdisk Image\n",
                                genimg_get_arch_name(arch));
-               show_boot_progress(-126);
+               show_boot_error(126);
                return 0;
        }