From: Wu Zhangjin <wuzj@lemote.com>
add a new init function: prom_init_env() to split environment arguments
initialization out of cmdline.c, the environment arguments are passed
from bootloader, currently is PMON.
Signed-off-by: Wu Zhangjin <wuzj@lemote.com>
---
arch/mips/include/asm/mach-loongson/loongson.h | 5 +-
arch/mips/loongson/common/Makefile | 2 +-
arch/mips/loongson/common/cmdline.c | 36 ++------------
arch/mips/loongson/common/env.c | 59 ++++++++++++++++++++++++
arch/mips/loongson/common/init.c | 1 +
5 files changed, 69 insertions(+), 34 deletions(-)
create mode 100644 arch/mips/loongson/common/env.c
diff --git a/arch/mips/include/asm/mach-loongson/loongson.h
b/arch/mips/include/asm/mach-loongson/loongson.h
index 656511e..ca591ed 100644
--- a/arch/mips/include/asm/mach-loongson/loongson.h
+++ b/arch/mips/include/asm/mach-loongson/loongson.h
@@ -20,16 +20,17 @@
/* loongson internal northbridge initialization */
extern void bonito_irq_init(void);
-/* command line arguments */
+/* environment arguments from bootloader */
extern unsigned long bus_clock, cpu_clock_freq;
extern unsigned long memsize, highmemsize;
/* loongson-based machines specific reboot setup */
extern void loongson_reboot_setup(void);
-/* loongson-specific command line and memory initialization */
+/* loongson-specific command line, env and memory initialization */
extern void __init prom_init_memory(void);
extern void __init prom_init_cmdline(void);
+extern void __init prom_init_env(void);
/* irq operation functions */
extern void bonito_irqdispatch(void);
diff --git a/arch/mips/loongson/common/Makefile
b/arch/mips/loongson/common/Makefile
index 79b2736..030a0a0 100644
--- a/arch/mips/loongson/common/Makefile
+++ b/arch/mips/loongson/common/Makefile
@@ -2,7 +2,7 @@
# Makefile for loongson based machines.
#
-obj-y += setup.o init.o cmdline.o time.o reset.o irq.o \
+obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \
pci.o bonito-irq.o mem.o misc.o
#
diff --git a/arch/mips/loongson/common/cmdline.c
b/arch/mips/loongson/common/cmdline.c
index 6f603ac..12bb606 100644
--- a/arch/mips/loongson/common/cmdline.c
+++ b/arch/mips/loongson/common/cmdline.c
@@ -18,31 +18,23 @@
* option) any later version.
*/
-#include <linux/bootmem.h>
-
#include <asm/bootinfo.h>
-unsigned long bus_clock, cpu_clock_freq;
-unsigned long memsize, highmemsize;
+#include <loongson.h>
+#include <cmdline.h>
int prom_argc;
/* pmon passes arguments in 32bit pointers */
-int *_prom_argv, *_prom_envp;
-
-#define parse_even_earlier(res, option, p) \
-do { \
- if (strncmp(option, (char *)p, strlen(option)) == 0) \
- strict_strtol((char *)p + strlen(option"="), \
- 10, &res); \
-} while (0)
+int *_prom_argv;
void __init prom_init_cmdline(void)
{
int i;
long l;
+
+ /* firmware arguments are initialized in head.S */
prom_argc = fw_arg0;
_prom_argv = (int *)fw_arg1;
- _prom_envp = (int *)fw_arg2;
/* arg[0] is "g", the rest is boot parameters */
arcs_cmdline[0] = '\0';
@@ -55,26 +47,8 @@ void __init prom_init_cmdline(void)
strcat(arcs_cmdline, " ");
}
- /* handle console, root, busclock, cpuclock, memsize, highmemsize
- arguments */
-
if ((strstr(arcs_cmdline, "console=")) == NULL)
strcat(arcs_cmdline, " console=ttyS0,115200");
if ((strstr(arcs_cmdline, "root=")) == NULL)
strcat(arcs_cmdline, " root=/dev/hda1");
-
- l = (long)*_prom_envp;
- while (l != 0) {
- parse_even_earlier(bus_clock, "busclock", l);
- parse_even_earlier(cpu_clock_freq, "cpuclock", l);
- parse_even_earlier(memsize, "memsize", l);
- parse_even_earlier(highmemsize, "highmemsize", l);
- _prom_envp++;
- l = (long)*_prom_envp;
- }
- if (memsize == 0)
- memsize = 256;
-
- pr_info("busclock=%ld, cpuclock=%ld, memsize=%ld, highmemsize=%ld\n",
- bus_clock, cpu_clock_freq, memsize, highmemsize);
}
diff --git a/arch/mips/loongson/common/env.c b/arch/mips/loongson/common/env.c
new file mode 100644
index 0000000..1a02428
--- /dev/null
+++ b/arch/mips/loongson/common/env.c
@@ -0,0 +1,59 @@
+/*
+ * Based on Ocelot Linux port, which is
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ * Copyright 2003 ICT CAS
+ * Author: Michael Guo <guoyi@ict.ac.cn>
+ *
+ * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology
+ * Author: Fuxin Zhang, zhangfx@lemote.com
+ *
+ * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <asm/bootinfo.h>
+
+#include <loongson.h>
+
+unsigned long bus_clock, cpu_clock_freq;
+unsigned long memsize, highmemsize;
+
+/* pmon passes arguments in 32bit pointers */
+int *_prom_envp;
+
+#define parse_even_earlier(res, option, p) \
+do { \
+ if (strncmp(option, (char *)p, strlen(option)) == 0) \
+ strict_strtol((char *)p + strlen(option"="), \
+ 10, &res); \
+} while (0)
+
+void __init prom_init_env(void)
+{
+ long l;
+
+ /* firmware arguments are initialized in head.S */
+ _prom_envp = (int *)fw_arg2;
+
+ l = (long)*_prom_envp;
+ while (l != 0) {
+ parse_even_earlier(bus_clock, "busclock", l);
+ parse_even_earlier(cpu_clock_freq, "cpuclock", l);
+ parse_even_earlier(memsize, "memsize", l);
+ parse_even_earlier(highmemsize, "highmemsize", l);
+ _prom_envp++;
+ l = (long)*_prom_envp;
+ }
+ if (memsize == 0)
+ memsize = 256;
+
+ pr_info("busclock=%ld, cpuclock=%ld, memsize=%ld, highmemsize=%ld\n",
+ bus_clock, cpu_clock_freq, memsize, highmemsize);
+}
diff --git a/arch/mips/loongson/common/init.c b/arch/mips/loongson/common/init.c
index 76e6fda..1c5a0e6 100644
--- a/arch/mips/loongson/common/init.c
+++ b/arch/mips/loongson/common/init.c
@@ -32,6 +32,7 @@ void __init prom_init(void)
ioremap(LOONGSON_PCIIO_BASE, LOONGSON_PCIIO_SIZE));
prom_init_cmdline();
+ prom_init_env();
prom_init_memory();
}
--
1.6.0.4
|