]> git.sur5r.net Git - u-boot/blobdiff - common/cmd_ide.c
[new uImage] Define a API for image handling operations
[u-boot] / common / cmd_ide.c
index c38be4f1a7d0d0c36335f44e6ab7e190326393c9..bcd132554629acb7f601e06835cf3cf0a6535460 100644 (file)
@@ -366,7 +366,7 @@ int do_diskboot (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;
@@ -448,27 +448,23 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
        hdr = (image_header_t *)addr;
 
-       if (ntohl(hdr->ih_magic) != IH_MAGIC) {
+       if (!image_check_magic (hdr)) {
                printf("\n** Bad Magic Number **\n");
                show_boot_progress (-49);
                return 1;
        }
        show_boot_progress (49);
 
-       checksum = ntohl(hdr->ih_hcrc);
-       hdr->ih_hcrc = 0;
-
-       if (crc32 (0, (uchar *)hdr, sizeof(image_header_t)) != checksum) {
+       if (!image_check_hcrc (hdr)) {
                puts ("\n** Bad Header Checksum **\n");
                show_boot_progress (-50);
                return 1;
        }
        show_boot_progress (50);
-       hdr->ih_hcrc = htonl(checksum); /* restore checksum for later use */
 
        print_image_hdr (hdr);
 
-       cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t));
+       cnt = image_get_image_size (hdr);
        cnt += info.blksz - 1;
        cnt /= info.blksz;
        cnt -= 1;