]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/mpl/common/common_util.c
[new uImage] Rename and move print_image_hdr() routine
[karo-tx-uboot.git] / board / mpl / common / common_util.c
index 06d021a026a04abc22dc225e75ebd704322454d8..b171ca51736b427f5102dcca68b7dd62da3081f9 100644 (file)
 
 #ifdef CONFIG_PIP405
 #include "../pip405/pip405.h"
-#include <405gp_pci.h>
+#include <asm/4xx_pci.h>
 #endif
 #ifdef CONFIG_MIP405
 #include "../mip405/mip405.h"
-#include <405gp_pci.h>
+#include <asm/4xx_pci.h>
 #endif
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -57,9 +57,6 @@ extern int mem_test(ulong start, ulong ramsize, int quiet);
 
 extern flash_info_t flash_info[];      /* info for FLASH chips */
 
-static image_header_t header;
-
-
 static int
 mpl_prg(uchar *src, ulong size)
 {
@@ -77,7 +74,7 @@ mpl_prg(uchar *src, ulong size)
        info = &flash_info[0];
 
 #if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) || defined(CONFIG_PATI)
-       if (ntohl(magic[0]) != IH_MAGIC) {
+       if (image_to_cpu (magic[0]) != IH_MAGIC) {
                puts("Bad Magic number\n");
                return -1;
        }
@@ -179,44 +176,39 @@ mpl_prg(uchar *src, ulong size)
 static int
 mpl_prg_image(uchar *ld_addr)
 {
-       unsigned long len, checksum;
+       unsigned long len;
        uchar *data;
-       image_header_t *hdr = &header;
+       image_header_t *hdr = (image_header_t *)ld_addr;
        int rc;
 
-       /* Copy header so we can blank CRC field for re-calculation */
-       memcpy (&header, (char *)ld_addr, sizeof(image_header_t));
-       if (ntohl(hdr->ih_magic)  != IH_MAGIC) {
+       if (!image_check_magic (hdr)) {
                puts("Bad Magic Number\n");
                return 1;
        }
-       print_image_hdr(hdr);
-       if (hdr->ih_os  != IH_OS_U_BOOT) {
+       image_print_contents (hdr);
+       if (!image_check_os (hdr, IH_OS_U_BOOT)) {
                puts("No U-Boot Image\n");
                return 1;
        }
-       if (hdr->ih_type  != IH_TYPE_FIRMWARE) {
+       if (!image_check_type (hdr, IH_TYPE_FIRMWARE)) {
                puts("No Firmware Image\n");
                return 1;
        }
-       data = (uchar *)&header;
-       len  = sizeof(image_header_t);
-       checksum = ntohl(hdr->ih_hcrc);
-       hdr->ih_hcrc = 0;
-       if (crc32 (0, (uchar *)data, len) != checksum) {
+       if (!image_check_hcrc (hdr)) {
                puts("Bad Header Checksum\n");
                return 1;
        }
-       data = ld_addr + sizeof(image_header_t);
-       len  = ntohl(hdr->ih_size);
        puts("Verifying Checksum ... ");
-       if (crc32 (0, (uchar *)data, len) != ntohl(hdr->ih_dcrc)) {
+       if (!image_check_dcrc (hdr)) {
                puts("Bad Data CRC\n");
                return 1;
        }
        puts("OK\n");
 
-       if (hdr->ih_comp != IH_COMP_NONE) {
+       data = (uchar *)image_get_data (hdr);
+       len = image_get_data_size (hdr);
+
+       if (image_get_comp (hdr) != IH_COMP_NONE) {
                uchar *buf;
                /* reserve space for uncompressed image */
                if ((buf = malloc(IMAGE_SIZE)) == NULL) {
@@ -224,7 +216,7 @@ mpl_prg_image(uchar *ld_addr)
                        return 1;
                }
 
-               switch (hdr->ih_comp) {
+               switch (image_get_comp (hdr)) {
                case IH_COMP_GZIP:
                        puts("Uncompressing (GZIP) ... ");
                        rc = gunzip ((void *)(buf), IMAGE_SIZE, data, &len);
@@ -253,7 +245,8 @@ mpl_prg_image(uchar *ld_addr)
                        break;
 #endif
                default:
-                       printf ("Unimplemented compression type %d\n", hdr->ih_comp);
+                       printf ("Unimplemented compression type %d\n",
+                               image_get_comp (hdr));
                        free(buf);
                        return 1;
                }
@@ -471,7 +464,7 @@ int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
        if (strcmp(argv[1], "flash") == 0)
        {
-#if (CONFIG_COMMANDS & CFG_CMD_FDC)
+#if defined(CONFIG_CMD_FDC)
                if (strcmp(argv[2], "floppy") == 0) {
                        char *local_args[3];
                        extern int do_fdcboot (cmd_tbl_t *, int, int, char *[]);
@@ -491,7 +484,7 @@ int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                        result=mpl_prg_image((uchar *)ld_addr);
                        return result;
                }
-#endif /* (CONFIG_COMMANDS & CFG_CMD_FDC) */
+#endif
                if (strcmp(argv[2], "mem") == 0) {
                        if(argc==4) {
                                ld_addr=simple_strtoul(argv[3], NULL, 16);
@@ -564,7 +557,7 @@ int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 }
 
 
-#if (CONFIG_COMMANDS & CFG_CMD_DOC)
+#if defined(CONFIG_CMD_DOC)
 extern void doc_probe(ulong physadr);
 void doc_init (void)
 {
@@ -587,7 +580,7 @@ extern int get_boot_mode(void);
 void video_get_info_str (int line_number, char *info)
 {
        /* init video info strings for graphic console */
-       PPC405_SYS_INFO sys_info;
+       PPC4xx_SYS_INFO sys_info;
        char rev;
        int i,boot;
        unsigned long pvr;