]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - arch/mips/lib/bootm.c
MIPS: bootm: refactor preparation of Linux kernel command line
[karo-tx-uboot.git] / arch / mips / lib / bootm.c
index 66340ea47046319083cdfc0556b5dc292681b980..a028a47ab9b5f32691ef354927fe818b92365bbf 100644 (file)
@@ -6,10 +6,7 @@
  */
 
 #include <common.h>
-#include <command.h>
 #include <image.h>
-#include <u-boot/zlib.h>
-#include <asm/byteorder.h>
 #include <asm/addrspace.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -17,10 +14,16 @@ DECLARE_GLOBAL_DATA_PTR;
 #define        LINUX_MAX_ENVS          256
 #define        LINUX_MAX_ARGS          256
 
-#if defined(CONFIG_QEMU_MALTA)
-#define mips_boot_qemu_malta   1
+#if defined(CONFIG_MALTA)
+#define mips_boot_malta                1
 #else
-#define mips_boot_qemu_malta   0
+#define mips_boot_malta                0
+#endif
+
+#if defined(CONFIG_MIPS_BOOT_CMDLINE_LEGACY)
+#define mips_boot_cmdline_legacy       1
+#else
+#define mips_boot_cmdline_legacy       0
 #endif
 
 static int linux_argc;
@@ -52,6 +55,20 @@ void arch_lmb_reserve(struct lmb *lmb)
        lmb_reserve(lmb, sp, CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp);
 }
 
+static int boot_setup_linux(bootm_headers_t *images)
+{
+       int ret;
+       ulong rd_len;
+
+       rd_len = images->rd_end - images->rd_start;
+       ret = boot_ramdisk_high(&images->lmb, images->rd_start,
+               rd_len, &images->initrd_start, &images->initrd_end);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
 static void linux_cmdline_init(void)
 {
        linux_argc = 1;
@@ -81,7 +98,7 @@ static void linux_cmdline_dump(void)
                debug("   arg %03d: %s\n", i, linux_argv[i]);
 }
 
-static void boot_cmdline_linux(bootm_headers_t *images)
+static void linux_cmdline_legacy(bootm_headers_t *images)
 {
        const char *bootargs, *next, *quote;
 
@@ -119,8 +136,14 @@ static void boot_cmdline_linux(bootm_headers_t *images)
 
                bootargs = next;
        }
+}
 
-       linux_cmdline_dump();
+static void boot_cmdline_linux(bootm_headers_t *images)
+{
+       if (mips_boot_cmdline_legacy) {
+               linux_cmdline_legacy(images);
+               linux_cmdline_dump();
+       }
 }
 
 static void linux_env_init(void)
@@ -139,7 +162,7 @@ static void linux_env_set(const char *env_name, const char *env_val)
                strcpy(linux_env_p, env_name);
                linux_env_p += strlen(env_name);
 
-               if (mips_boot_qemu_malta) {
+               if (mips_boot_malta) {
                        linux_env_p++;
                        linux_env[++linux_env_idx] = linux_env_p;
                } else {
@@ -196,8 +219,10 @@ static void boot_prep_linux(bootm_headers_t *images)
        if (cp)
                linux_env_set("eth1addr", cp);
 
-       if (mips_boot_qemu_malta)
-               linux_env_set("modetty0", "38400n8r");
+       if (mips_boot_malta) {
+               sprintf(env_buf, "%un8r", gd->baudrate);
+               linux_env_set("modetty0", env_buf);
+       }
 }
 
 static void boot_jump_linux(bootm_headers_t *images)
@@ -210,7 +235,7 @@ static void boot_jump_linux(bootm_headers_t *images)
 
        bootstage_mark(BOOTSTAGE_ID_RUN_OS);
 
-       if (mips_boot_qemu_malta)
+       if (mips_boot_malta)
                linux_extra = gd->ram_size;
 
        /* we assume that the kernel is in place */
@@ -222,6 +247,8 @@ static void boot_jump_linux(bootm_headers_t *images)
 int do_bootm_linux(int flag, int argc, char * const argv[],
                        bootm_headers_t *images)
 {
+       int ret;
+
        /* No need for those on MIPS */
        if (flag & BOOTM_STATE_OS_BD_T)
                return -1;
@@ -241,6 +268,10 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
                return 0;
        }
 
+       ret = boot_setup_linux(images);
+       if (ret)
+               return ret;
+
        boot_cmdline_linux(images);
        boot_prep_linux(images);
        boot_jump_linux(images);