]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - lib_ppc/bootm.c
bootm: Add subcommands
[karo-tx-uboot.git] / lib_ppc / bootm.c
index 9892aface7e19030c65087e7b75c22245d102715..6c9cf9e8b5b8658ec882091b0258fe728dce2d50 100644 (file)
 
 #endif
 
-#ifdef CFG_INIT_RAM_LOCK
+#ifdef CONFIG_SYS_INIT_RAM_LOCK
 #include <asm/cache.h>
 #endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 extern ulong get_effective_memsize(void);
 static ulong get_sp (void);
 static void set_clocks_in_mhz (bd_t *kbd);
 
-#ifndef CFG_LINUX_LOWMEM_MAX_SIZE
-#define CFG_LINUX_LOWMEM_MAX_SIZE      (768*1024*1024)
+#ifndef CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE
+#define CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE       (768*1024*1024)
 #endif
 
-void  __attribute__((noinline))
-do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-               bootm_headers_t *images)
+void arch_lmb_reserve(struct lmb *lmb)
 {
-       ulong   sp;
-
-       ulong   initrd_start, initrd_end;
-       ulong   rd_len;
-       ulong   size;
        phys_size_t bootm_size;
-
-       ulong   cmd_start, cmd_end, bootmap_base;
-       bd_t    *kbd;
-       void    (*kernel)(bd_t *, ulong r4, ulong r5, ulong r6,
-                         ulong r7, ulong r8, ulong r9);
-       int     ret;
-       ulong   of_size = images->ft_len;
-       struct lmb *lmb = &images->lmb;
-
-#if defined(CONFIG_OF_LIBFDT)
-       char    *of_flat_tree = images->ft_addr;
-#endif
-
-       kernel = (void (*)(bd_t *, ulong, ulong, ulong,
-                          ulong, ulong, ulong))images->ep;
+       ulong size, sp, bootmap_base;
 
        bootmap_base = getenv_bootm_low();
        bootm_size = getenv_bootm_size();
 
 #ifdef DEBUG
        if (((u64)bootmap_base + bootm_size) >
-           (CFG_SDRAM_BASE + (u64)gd->ram_size))
+           (CONFIG_SYS_SDRAM_BASE + (u64)gd->ram_size))
                puts("WARNING: bootm_low + bootm_size exceed total memory\n");
        if ((bootmap_base + bootm_size) > get_effective_memsize())
                puts("WARNING: bootm_low + bootm_size exceed eff. memory\n");
 #endif
 
        size = min(bootm_size, get_effective_memsize());
-       size = min(size, CFG_LINUX_LOWMEM_MAX_SIZE);
+       size = min(size, CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE);
 
        if (size < bootm_size) {
                ulong base = bootmap_base + size;
@@ -107,7 +85,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
         *
         * Allocate space for command line and board info - the
         * address should be as high as possible within the reach of
-        * the kernel (see CFG_BOOTMAPSZ settings), but in unused
+        * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
         * memory, which means far enough below the current stack
         * pointer.
         */
@@ -116,7 +94,36 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
        /* adjust sp by 1K to be safe */
        sp -= 1024;
-       lmb_reserve(lmb, sp, (CFG_SDRAM_BASE + get_effective_memsize() - sp));
+       lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + get_effective_memsize() - sp));
+
+       return ;
+}
+
+__attribute__((noinline))
+int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
+{
+       ulong   initrd_start, initrd_end;
+       ulong   rd_len;
+
+       ulong   cmd_start, cmd_end, bootmap_base;
+       bd_t    *kbd;
+       void    (*kernel)(bd_t *, ulong r4, ulong r5, ulong r6,
+                         ulong r7, ulong r8, ulong r9);
+       int     ret;
+       ulong   of_size = images->ft_len;
+       struct lmb *lmb = &images->lmb;
+
+#if defined(CONFIG_OF_LIBFDT)
+       char    *of_flat_tree = images->ft_addr;
+#endif
+
+       if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
+               return 1;
+
+       kernel = (void (*)(bd_t *, ulong, ulong, ulong,
+                          ulong, ulong, ulong))images->ep;
+
+       bootmap_base = getenv_bootm_low();
 
        if (!of_size) {
                /* allocate space and init command line */
@@ -147,8 +154,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
         * if the user wants it (the logic is in the subroutines).
         */
        if (of_size) {
-               /* pass in dummy initrd info, we'll fix up later */
-               if (fdt_chosen(of_flat_tree, images->rd_start, images->rd_end, 0) < 0) {
+               if (fdt_chosen(of_flat_tree, 1) < 0) {
                        puts ("ERROR: ");
                        puts ("/chosen node create failed");
                        puts (" - must RESET the board to recover.\n");
@@ -171,6 +177,8 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
                        goto error;
                of_size = ret;
 
+               if ((of_flat_tree) && (initrd_start && initrd_end))
+                       of_size += FDT_RAMDISK_OVERHEAD;
                /* Create a new LMB reservation */
                lmb_reserve(lmb, (ulong)of_flat_tree, of_size);
        }
@@ -190,7 +198,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
        show_boot_progress (15);
 
-#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500)
+#if defined(CONFIG_SYS_INIT_RAM_LOCK) && !defined(CONFIG_E500)
        unlock_ram_in_cache();
 #endif
 
@@ -214,7 +222,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
                debug ("   Booting using OF flat tree...\n");
                (*kernel) ((bd_t *)of_flat_tree, 0, 0, EPAPR_MAGIC,
-                          CFG_BOOTMAPSZ, 0, 0);
+                          CONFIG_SYS_BOOTMAPSZ, 0, 0);
                /* does not return */
        } else
 #endif
@@ -234,11 +242,10 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
                           cmd_start, cmd_end, 0, 0);
                /* does not return */
        }
-       return ;
+       return 1;
 
 error:
-       do_reset (cmdtp, flag, argc, argv);
-       return ;
+       return 1;
 }
 
 static ulong get_sp (void)