]> git.sur5r.net Git - u-boot/blobdiff - lib_microblaze/microblaze_linux.c
[new uImage] Cleanup image header pointer use in bootm code
[u-boot] / lib_microblaze / microblaze_linux.c
index 7cd97995e8ad3dc1e0c6b52c01e55c709685d301..a4fce5a73c90aaa07a3911025dd04fa0e05d060d 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
-extern image_header_t header;  /* from cmd_bootm.c */
-/*cmd_boot.c*/
 extern int do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]);
 
 void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
-                    ulong addr, ulong * len_ptr, int verify)
+                    image_header_t *hdr, int verify)
 {
-       ulong len = 0, checksum;
+       int i;
+       ulong checksum;
+
+       ulong rd_data, rd_len;
        ulong initrd_start, initrd_end;
-       ulong data;
+       image_header_t *rd_hdr;
+
        /* First parameter is mapped to $r5 for kernel boot args */
        void (*theKernel) (char *);
-       image_header_t *hdr = &header;
        char *commandline = getenv ("bootargs");
-       int i;
 
        theKernel = (void (*)(char *))image_get_ep (hdr);
 
@@ -54,33 +54,30 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
        if (argc >= 3) {
                show_boot_progress (9);
 
-               addr = simple_strtoul (argv[2], NULL, 16);
-               hdr = (image_header_t *)addr;
+               rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16);
+               printf ("## Loading Ramdisk Image at %08lx ...\n", rd_hdr);
 
-               printf ("## Loading Ramdisk Image at %08lx ...\n", addr);
-
-               if (!image_check_magic (hdr)) {
+               if (!image_check_magic (rd_hdr)) {
                        printf ("Bad Magic Number\n");
                        show_boot_progress (-10);
                        do_reset (cmdtp, flag, argc, argv);
                }
 
-               if (!image_check_magic (hdr)) {
+               if (!image_check_magic (rd_hdr)) {
                        printf ("Bad Header Checksum\n");
                        show_boot_progress (-11);
                        do_reset (cmdtp, flag, argc, argv);
                }
 
                show_boot_progress (10);
+               print_image_hdr (rd_hdr);
 
-               print_image_hdr (hdr);
-
-               data = image_get_data (hdr);
-               len = image_get_data_size (hdr);
+               rd_data = image_get_data (rd_hdr);
+               rd_en = image_get_data_size (rd_hdr);
 
                if (verify) {
                        printf ("   Verifying Checksum ... ");
-                       if (!image_check_dcrc (hdr)) {
+                       if (!image_check_dcrc (rd_hdr)) {
                                printf ("Bad Data CRC\n");
                                show_boot_progress (-12);
                                do_reset (cmdtp, flag, argc, argv);
@@ -90,9 +87,9 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
 
                show_boot_progress (11);
 
-               if (!image_check_os (hdr, IH_OS_LINUX) ||
-                   !image_check_arch (hdr, IH_ARCH_MICROBLAZE) ||
-                   !image_check_type (hdr, IH_TYPE_RAMDISK)) {
+               if (!image_check_os (rd_hdr, IH_OS_LINUX) ||
+                   !image_check_arch (rd_hdr, IH_ARCH_MICROBLAZE) ||
+                   !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) {
                        printf ("No Linux Microblaze Ramdisk Image\n");
                        show_boot_progress (-13);
                        do_reset (cmdtp, flag, argc, argv);
@@ -101,42 +98,30 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
                /*
                 * Now check if we have a multifile image
                 */
-       } else if (image_check_type (hdr, IH_TYPE_MULTI) && (len_ptr[1])) {
-               ulong tail = image_to_cpu (len_ptr[0]) % 4;
-
+       } else if (image_check_type (hdr, IH_TYPE_MULTI)) {
+               /*
+                * Get second entry data start address and len
+                */
                show_boot_progress (13);
-
-               /* skip kernel length and terminator */
-               data = (ulong) (&len_ptr[2]);
-               /* skip any additional image length fields */
-               for (i = 1; len_ptr[i]; ++i)
-                       data += 4;
-               /* add kernel length, and align */
-               data += image_to_cpu (len_ptr[0]);
-               if (tail) {
-                       data += 4 - tail;
-               }
-
-               len = image_to_cpu (len_ptr[1]);
-
+               image_multi_getimg (hdr, 1, &rd_data, &rd_len);
        } else {
                /*
                 * no initrd image
                 */
                show_boot_progress (14);
 
-               data = 0;
+               rd_data = rd_len = 0;
        }
 
 #ifdef  DEBUG
-       if (!data) {
+       if (!rd_data) {
                printf ("No initrd\n");
        }
 #endif
 
-       if (data) {
-               initrd_start = data;
-               initrd_end = initrd_start + len;
+       if (rd_data) {
+               initrd_start = rd_data;
+               initrd_end = initrd_start + rd_len;
        } else {
                initrd_start = 0;
                initrd_end = 0;