]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/cmd_scsi.c
i.MX31: Fix architecture numbers for ADS and Litekit boards
[karo-tx-uboot.git] / common / cmd_scsi.c
index b2d4eb635c7500a6340a655fe7f7408293536449..f49531e96b708d5d0de7fd2cc665e2216f48905a 100644 (file)
@@ -34,8 +34,6 @@
 #include <image.h>
 #include <pci.h>
 
-#if defined(CONFIG_CMD_SCSI)
-
 #ifdef CONFIG_SCSI_SYM53C8XX
 #define SCSI_VEND_ID   0x1000
 #ifndef CONFIG_SCSI_DEV_ID
@@ -209,10 +207,13 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        char *boot_device = NULL;
        char *ep;
        int dev, part = 0;
-       ulong addr, cnt, checksum;
+       ulong addr, cnt;
        disk_partition_t info;
        image_header_t *hdr;
        int rcode = 0;
+#if defined(CONFIG_FIT)
+       const void *fit_hdr;
+#endif
 
        switch (argc) {
        case 1:
@@ -275,24 +276,35 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                return 1;
        }
 
-       hdr = (image_header_t *)addr;
+       switch (genimg_get_format ((void *)addr)) {
+       case IMAGE_FORMAT_LEGACY:
+               hdr = (image_header_t *)addr;
 
-       if (ntohl(hdr->ih_magic) == IH_MAGIC) {
-               printf("\n** Bad Magic Number **\n");
-               return 1;
-       }
+               if (!image_check_hcrc (hdr)) {
+                       puts ("\n** Bad Header Checksum **\n");
+                       return 1;
+               }
 
-       checksum = ntohl(hdr->ih_hcrc);
-       hdr->ih_hcrc = 0;
+               image_print_contents (hdr);
+               cnt = image_get_image_size (hdr);
+               break;
+#if defined(CONFIG_FIT)
+       case IMAGE_FORMAT_FIT:
+               fit_hdr = (const void *)addr;
+               if (!fit_check_format (fit_hdr)) {
+                       puts ("** Bad FIT image format\n");
+                       return 1;
+               }
+               puts ("Fit image detected...\n");
 
-       if (crc32 (0, (uchar *)hdr, sizeof(image_header_t)) != checksum) {
-               puts ("\n** Bad Header Checksum **\n");
+               cnt = fit_get_size (fit_hdr);
+               break;
+#endif
+       default:
+               puts ("** Unknown image type\n");
                return 1;
        }
-       hdr->ih_hcrc = htonl(checksum); /* restore checksum for later use */
 
-       print_image_hdr (hdr);
-       cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t));
        cnt += info.blksz - 1;
        cnt /= info.blksz;
        cnt -= 1;
@@ -302,6 +314,13 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                printf ("** Read error on %d:%d\n", dev, part);
                return 1;
        }
+
+#if defined(CONFIG_FIT)
+       /* This cannot be done earlier, we need complete FIT image in RAM first */
+       if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
+               fit_print_contents ((const void *)addr);
+#endif
+
        /* Loading ok, update default load address */
        load_addr = addr;
 
@@ -611,5 +630,3 @@ U_BOOT_CMD(
        "scsiboot- boot from SCSI device\n",
        "loadAddr dev:part\n"
 );
-
-#endif