]> git.sur5r.net Git - u-boot/blobdiff - common/cmd_bootm.c
Motion-PRO: Change maximum console buffer size from 256 to 1024 bytes.
[u-boot] / common / cmd_bootm.c
index c533c00d664c60032b6fa927ddd99062d3d6dadb..7aae8a6d1b0a2f9919a1219c5a7f067f87dc7564 100644 (file)
@@ -510,7 +510,7 @@ fixup_silent_linux ()
 #endif /* CONFIG_SILENT_CONSOLE */
 
 #ifdef CONFIG_PPC
-static void
+static void  __attribute__((noinline))
 do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
                int     argc, char *argv[],
                ulong   addr,
@@ -531,6 +531,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
        image_header_t *hdr = &header;
 #ifdef CONFIG_OF_FLAT_TREE
        char    *of_flat_tree = NULL;
+       ulong   of_data = 0;
 #endif
 
        if ((s = getenv ("initrd_high")) != NULL) {
@@ -745,11 +746,8 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
 
                if  (*(ulong *)of_flat_tree == OF_DT_HEADER) {
 #ifndef CFG_NO_FLASH
-                       if (addr2info((ulong)of_flat_tree) != NULL) {
-                               printf ("Cannot modify flat device tree stored in flash\n" \
-                                       "Copy to memory before using the bootm command\n");
-                               return;
-                       }
+                       if (addr2info((ulong)of_flat_tree) != NULL)
+                               of_data = (ulong)of_flat_tree;
 #endif
                } else if (ntohl(hdr->ih_magic) == IH_MAGIC) {
                        printf("## Flat Device Tree Image at %08lX\n", hdr);
@@ -804,9 +802,37 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
                }
                printf ("   Booting using flat device tree at 0x%x\n",
                                of_flat_tree);
-       } else if(getenv("disable_of") == NULL) {
-               printf ("ERROR: bootm needs flat device tree as third argument\n");
-               return;
+       } else if ((hdr->ih_type==IH_TYPE_MULTI) && (len_ptr[1]) && (len_ptr[2])) {
+               u_long tail    = ntohl(len_ptr[0]) % 4;
+               int i;
+
+               /* skip kernel length, initrd length, and terminator */
+               of_data = (ulong)(&len_ptr[3]);
+               /* skip any additional image length fields */
+               for (i=2; len_ptr[i]; ++i)
+                       of_data += 4;
+               /* add kernel length, and align */
+               of_data += ntohl(len_ptr[0]);
+               if (tail) {
+                       of_data += 4 - tail;
+               }
+
+               /* add initrd length, and align */
+               tail = ntohl(len_ptr[1]) % 4;
+               of_data += ntohl(len_ptr[1]);
+               if (tail) {
+                       of_data += 4 - tail;
+               }
+
+               if (((struct boot_param_header *)of_data)->magic != OF_DT_HEADER) {
+                       printf ("ERROR: image is not a flat device tree\n");
+                       return;
+               }
+
+               if (((struct boot_param_header *)of_data)->totalsize != ntohl(len_ptr[2])) {
+                       printf ("ERROR: flat device tree size does not agree with image\n");
+                       return;
+               }
        }
 #endif
        if (!data) {
@@ -883,43 +909,58 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
 
        SHOW_BOOT_PROGRESS (15);
 
-#ifndef CONFIG_OF_FLAT_TREE
-
 #if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500)
        unlock_ram_in_cache();
 #endif
 
+#ifdef CONFIG_OF_FLAT_TREE
+       /* move of_flat_tree if needed */
+       if (of_data) {
+               ulong of_start, of_len;
+               of_len = ((struct boot_param_header *)of_data)->totalsize;
+               /* provide extra 8k pad */
+               if (initrd_start)
+                       of_start = initrd_start - of_len - 8192;
+               else
+                       of_start  = (ulong)kbd - of_len - 8192;
+               of_start &= ~(4096 - 1);        /* align on page */
+               debug ("## device tree at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n",
+                       of_data, of_data + of_len - 1, of_len, of_len);
+
+               of_flat_tree = (char *)of_start;
+               printf ("   Loading Device Tree to %08lx, end %08lx ... ",
+                       of_start, of_start + of_len - 1);
+               memmove ((void *)of_start, (void *)of_data, of_len);
+       }
+#endif
+
        /*
-        * Linux Kernel Parameters:
+        * Linux Kernel Parameters (passing board info data):
         *   r3: ptr to board info data
         *   r4: initrd_start or 0 if no initrd
         *   r5: initrd_end - unused if r4 is 0
         *   r6: Start of command line string
         *   r7: End   of command line string
         */
-       (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
-
-#else
-       ft_setup(of_flat_tree, kbd, initrd_start, initrd_end);
-       /* ft_dump_blob(of_flat_tree); */
-
-#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500)
-       unlock_ram_in_cache();
+#ifdef CONFIG_OF_FLAT_TREE
+       if (!of_flat_tree)      /* no device tree; boot old style */
 #endif
+               (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
+               /* does not return */
+
+#ifdef CONFIG_OF_FLAT_TREE
        /*
-        * Linux Kernel Parameters:
+        * Linux Kernel Parameters (passing device tree):
         *   r3: ptr to OF flat tree, followed by the board info data
         *   r4: physical pointer to the kernel itself
         *   r5: NULL
         *   r6: NULL
         *   r7: NULL
         */
-       if (getenv("disable_of") != NULL)
-               (*kernel) ((bd_t *)of_flat_tree, initrd_start, initrd_end,
-                       cmd_start, cmd_end);
-       else
-               (*kernel) ((bd_t *)of_flat_tree, (ulong)kernel, 0, 0, 0);
+       ft_setup(of_flat_tree, kbd, initrd_start, initrd_end);
+       /* ft_dump_blob(of_flat_tree); */
 
+       (*kernel) ((bd_t *)of_flat_tree, (ulong)kernel, 0, 0, 0);
 #endif
 }
 #endif /* CONFIG_PPC */