]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/cmd_doc.c
[new uImage] Add dual format uImage support framework
[people/ms/u-boot.git] / common / cmd_doc.c
index 4e624a2f3fabcebf6925ae22858dbb3a9804b888..3358b04622ed960796e87d9d1c62e3766f6c8bae 100644 (file)
 #include <command.h>
 #include <malloc.h>
 #include <asm/io.h>
-
-#ifdef CONFIG_SHOW_BOOT_PROGRESS
-# include <status_led.h>
-# define SHOW_BOOT_PROGRESS(arg)       show_boot_progress(arg)
-#else
-# define SHOW_BOOT_PROGRESS(arg)
-#endif
-
-#if (CONFIG_COMMANDS & CFG_CMD_DOC)
-
 #include <linux/mtd/nftl.h>
 #include <linux/mtd/doc2000.h>
 
@@ -216,7 +206,7 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        image_header_t *hdr;
        int rcode = 0;
 
-       SHOW_BOOT_PROGRESS (34);
+       show_boot_progress (34);
        switch (argc) {
        case 1:
                addr = CFG_LOAD_ADDR;
@@ -237,27 +227,27 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                break;
        default:
                printf ("Usage:\n%s\n", cmdtp->usage);
-               SHOW_BOOT_PROGRESS (-35);
+               show_boot_progress (-35);
                return 1;
        }
 
-       SHOW_BOOT_PROGRESS (35);
+       show_boot_progress (35);
        if (!boot_device) {
                puts ("\n** No boot device **\n");
-               SHOW_BOOT_PROGRESS (-36);
+               show_boot_progress (-36);
                return 1;
        }
-       SHOW_BOOT_PROGRESS (36);
+       show_boot_progress (36);
 
        dev = simple_strtoul(boot_device, &ep, 16);
 
        if ((dev >= CFG_MAX_DOC_DEVICE) ||
            (doc_dev_desc[dev].ChipID == DOC_ChipID_UNKNOWN)) {
                printf ("\n** Device %d not available\n", dev);
-               SHOW_BOOT_PROGRESS (-37);
+               show_boot_progress (-37);
                return 1;
        }
-       SHOW_BOOT_PROGRESS (37);
+       show_boot_progress (37);
 
        printf ("\nLoading from device %d: %s at 0x%lX (offset 0x%lX)\n",
                dev, doc_dev_desc[dev].name, doc_dev_desc[dev].physadr,
@@ -266,33 +256,45 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        if (doc_rw (doc_dev_desc + dev, 1, offset,
                    SECTORSIZE, NULL, (u_char *)addr)) {
                printf ("** Read error on %d\n", dev);
-               SHOW_BOOT_PROGRESS (-38);
+               show_boot_progress (-38);
                return 1;
        }
-       SHOW_BOOT_PROGRESS (38);
+       show_boot_progress (38);
 
-       hdr = (image_header_t *)addr;
+       switch (gen_image_get_format ((void *)addr)) {
+       case IMAGE_FORMAT_LEGACY:
+               hdr = (image_header_t *)addr;
 
-       if (hdr->ih_magic == IH_MAGIC) {
+               if (image_check_magic (hdr)) {
 
-               print_image_hdr (hdr);
+                       image_print_contents (hdr);
 
-               cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t));
-               cnt -= SECTORSIZE;
-       } else {
-               puts ("\n** Bad Magic Number **\n");
-               SHOW_BOOT_PROGRESS (-39);
+                       cnt = image_get_image_size (hdr);
+                       cnt -= SECTORSIZE;
+               } else {
+                       puts ("\n** Bad Magic Number **\n");
+                       show_boot_progress (-39);
+                       return 1;
+               }
+               break;
+#if defined(CONFIG_FIT)
+       case IMAGE_FORMAT_FIT:
+               fit_unsupported ("docboot");
+               return 1;
+#endif
+       default:
+               puts ("** Unknown image type\n");
                return 1;
        }
-       SHOW_BOOT_PROGRESS (39);
+       show_boot_progress (39);
 
        if (doc_rw (doc_dev_desc + dev, 1, offset + SECTORSIZE, cnt,
                    NULL, (u_char *)(addr+SECTORSIZE))) {
                printf ("** Read error on %d\n", dev);
-               SHOW_BOOT_PROGRESS (-40);
+               show_boot_progress (-40);
                return 1;
        }
-       SHOW_BOOT_PROGRESS (40);
+       show_boot_progress (40);
 
        /* Loading ok, update default load address */
 
@@ -1614,5 +1616,3 @@ void doc_probe(unsigned long physadr)
                puts ("No DiskOnChip found\n");
        }
 }
-
-#endif /* (CONFIG_COMMANDS & CFG_CMD_DOC) */