aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Ungerer <gerg@linux-m68k.org>2016-09-05 01:23:50 -0400
committerGreg Ungerer <gerg@linux-m68k.org>2016-09-25 22:02:59 -0400
commitaa5ac789bd96c7a6628a8167de562fa660f1f481 (patch)
tree3cba478fe5cc7c0eec6154dda3d37e7aa7bf77c7
parent2a744007c332f9d604b95aaecb106596c52ab001 (diff)
m68k: generalize uboot command line support
The uboot command line support needs to be used by both MMU and no-MMU setups, but currently we only have the code in the no-MMU code paths. Move the uboot command line processing code into its own file. Add appropriate calls to it from both the MMU and no-MMU arch setup code. Signed-off-by: Greg Ungerer <gerg@linux-m68k.org> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
-rw-r--r--arch/m68k/include/asm/bootinfo.h6
-rw-r--r--arch/m68k/kernel/Makefile1
-rw-r--r--arch/m68k/kernel/setup_mm.c1
-rw-r--r--arch/m68k/kernel/setup_no.c81
-rw-r--r--arch/m68k/kernel/uboot.c107
5 files changed, 117 insertions, 79 deletions
diff --git a/arch/m68k/include/asm/bootinfo.h b/arch/m68k/include/asm/bootinfo.h
index 8e213267f8e7..81c91af8ec6c 100644
--- a/arch/m68k/include/asm/bootinfo.h
+++ b/arch/m68k/include/asm/bootinfo.h
@@ -22,6 +22,12 @@ extern void save_bootinfo(const struct bi_record *bi);
22static inline void save_bootinfo(const struct bi_record *bi) {} 22static inline void save_bootinfo(const struct bi_record *bi) {}
23#endif 23#endif
24 24
25#ifdef CONFIG_UBOOT
26void process_uboot_commandline(char *commandp, int size);
27#else
28static inline void process_uboot_commandline(char *commandp, int size) {}
29#endif
30
25#endif /* __ASSEMBLY__ */ 31#endif /* __ASSEMBLY__ */
26 32
27 33
diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile
index e47778f8588d..8a1c4d3f91c8 100644
--- a/arch/m68k/kernel/Makefile
+++ b/arch/m68k/kernel/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_HAS_DMA) += dma.o
24 24
25obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o 25obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
26obj-$(CONFIG_BOOTINFO_PROC) += bootinfo_proc.o 26obj-$(CONFIG_BOOTINFO_PROC) += bootinfo_proc.o
27obj-$(CONFIG_UBOOT) += uboot.o
27 28
28obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 29obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
29 30
diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c
index 9afad2b64c13..9f61f517f810 100644
--- a/arch/m68k/kernel/setup_mm.c
+++ b/arch/m68k/kernel/setup_mm.c
@@ -274,6 +274,7 @@ void __init setup_arch(char **cmdline_p)
274 strncpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE); 274 strncpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE);
275 m68k_command_line[CL_SIZE - 1] = 0; 275 m68k_command_line[CL_SIZE - 1] = 0;
276#endif /* CONFIG_BOOTPARAM */ 276#endif /* CONFIG_BOOTPARAM */
277 process_uboot_commandline(&m68k_command_line[0], CL_SIZE);
277 *cmdline_p = m68k_command_line; 278 *cmdline_p = m68k_command_line;
278 memcpy(boot_command_line, *cmdline_p, CL_SIZE); 279 memcpy(boot_command_line, *cmdline_p, CL_SIZE);
279 280
diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c
index 9309789215a8..4bde2c1c8289 100644
--- a/arch/m68k/kernel/setup_no.c
+++ b/arch/m68k/kernel/setup_no.c
@@ -34,6 +34,7 @@
34#include <linux/rtc.h> 34#include <linux/rtc.h>
35 35
36#include <asm/setup.h> 36#include <asm/setup.h>
37#include <asm/bootinfo.h>
37#include <asm/irq.h> 38#include <asm/irq.h>
38#include <asm/machdep.h> 39#include <asm/machdep.h>
39#include <asm/pgtable.h> 40#include <asm/pgtable.h>
@@ -82,69 +83,6 @@ void (*mach_power_off)(void);
82#define CPU_INSTR_PER_JIFFY 16 83#define CPU_INSTR_PER_JIFFY 16
83#endif 84#endif
84 85
85#if defined(CONFIG_UBOOT)
86/*
87 * parse_uboot_commandline
88 *
89 * Copies u-boot commandline arguments and store them in the proper linux
90 * variables.
91 *
92 * Assumes:
93 * _init_sp global contains the address in the stack pointer when the
94 * kernel starts (see head.S::_start)
95 *
96 * U-Boot calling convention:
97 * (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
98 *
99 * _init_sp can be parsed as such
100 *
101 * _init_sp+00 = u-boot cmd after jsr into kernel (skip)
102 * _init_sp+04 = &kernel board_info (residual data)
103 * _init_sp+08 = &initrd_start
104 * _init_sp+12 = &initrd_end
105 * _init_sp+16 = &cmd_start
106 * _init_sp+20 = &cmd_end
107 *
108 * This also assumes that the memory locations pointed to are still
109 * unmodified. U-boot places them near the end of external SDRAM.
110 *
111 * Argument(s):
112 * commandp = the linux commandline arg container to fill.
113 * size = the sizeof commandp.
114 *
115 * Returns:
116 */
117static void __init parse_uboot_commandline(char *commandp, int size)
118{
119 extern unsigned long _init_sp;
120 unsigned long *sp;
121 unsigned long uboot_kbd;
122 unsigned long uboot_initrd_start, uboot_initrd_end;
123 unsigned long uboot_cmd_start, uboot_cmd_end;
124
125
126 sp = (unsigned long *)_init_sp;
127 uboot_kbd = sp[1];
128 uboot_initrd_start = sp[2];
129 uboot_initrd_end = sp[3];
130 uboot_cmd_start = sp[4];
131 uboot_cmd_end = sp[5];
132
133 if (uboot_cmd_start && uboot_cmd_end)
134 strncpy(commandp, (const char *)uboot_cmd_start, size);
135#if defined(CONFIG_BLK_DEV_INITRD)
136 if (uboot_initrd_start && uboot_initrd_end &&
137 (uboot_initrd_end > uboot_initrd_start)) {
138 initrd_start = uboot_initrd_start;
139 initrd_end = uboot_initrd_end;
140 ROOT_DEV = Root_RAM0;
141 printk(KERN_INFO "initrd at 0x%lx:0x%lx\n",
142 initrd_start, initrd_end);
143 }
144#endif /* if defined(CONFIG_BLK_DEV_INITRD) */
145}
146#endif /* #if defined(CONFIG_UBOOT) */
147
148void __init setup_arch(char **cmdline_p) 86void __init setup_arch(char **cmdline_p)
149{ 87{
150 int bootmap_size; 88 int bootmap_size;
@@ -164,22 +102,7 @@ void __init setup_arch(char **cmdline_p)
164 command_line[sizeof(command_line) - 1] = 0; 102 command_line[sizeof(command_line) - 1] = 0;
165#endif /* CONFIG_BOOTPARAM */ 103#endif /* CONFIG_BOOTPARAM */
166 104
167#if defined(CONFIG_UBOOT) 105 process_uboot_commandline(&command_line[0], sizeof(command_line));
168 /* CONFIG_UBOOT and CONFIG_BOOTPARAM defined, concatenate cmdline */
169 #if defined(CONFIG_BOOTPARAM)
170 /* Add the whitespace separator */
171 command_line[strlen(CONFIG_BOOTPARAM_STRING)] = ' ';
172 /* Parse uboot command line into the rest of the buffer */
173 parse_uboot_commandline(
174 &command_line[(strlen(CONFIG_BOOTPARAM_STRING)+1)],
175 (sizeof(command_line) -
176 (strlen(CONFIG_BOOTPARAM_STRING)+1)));
177 /* Only CONFIG_UBOOT defined, create cmdline */
178 #else
179 parse_uboot_commandline(&command_line[0], sizeof(command_line));
180 #endif /* CONFIG_BOOTPARAM */
181 command_line[sizeof(command_line) - 1] = 0;
182#endif /* CONFIG_UBOOT */
183 106
184 printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU_NAME "\n"); 107 printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU_NAME "\n");
185 108
diff --git a/arch/m68k/kernel/uboot.c b/arch/m68k/kernel/uboot.c
new file mode 100644
index 000000000000..b3536a82a262
--- /dev/null
+++ b/arch/m68k/kernel/uboot.c
@@ -0,0 +1,107 @@
1/*
2 * uboot.c -- uboot arguments support
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive
6 * for more details.
7 */
8
9#include <linux/kernel.h>
10#include <linux/sched.h>
11#include <linux/delay.h>
12#include <linux/interrupt.h>
13#include <linux/fb.h>
14#include <linux/module.h>
15#include <linux/mm.h>
16#include <linux/console.h>
17#include <linux/errno.h>
18#include <linux/string.h>
19#include <linux/bootmem.h>
20#include <linux/seq_file.h>
21#include <linux/init.h>
22#include <linux/initrd.h>
23#include <linux/root_dev.h>
24#include <linux/rtc.h>
25
26#include <asm/setup.h>
27#include <asm/irq.h>
28#include <asm/machdep.h>
29#include <asm/pgtable.h>
30#include <asm/sections.h>
31
32/*
33 * parse_uboot_commandline
34 *
35 * Copies u-boot commandline arguments and store them in the proper linux
36 * variables.
37 *
38 * Assumes:
39 * _init_sp global contains the address in the stack pointer when the
40 * kernel starts (see head.S::_start)
41 *
42 * U-Boot calling convention:
43 * (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
44 *
45 * _init_sp can be parsed as such
46 *
47 * _init_sp+00 = u-boot cmd after jsr into kernel (skip)
48 * _init_sp+04 = &kernel board_info (residual data)
49 * _init_sp+08 = &initrd_start
50 * _init_sp+12 = &initrd_end
51 * _init_sp+16 = &cmd_start
52 * _init_sp+20 = &cmd_end
53 *
54 * This also assumes that the memory locations pointed to are still
55 * unmodified. U-boot places them near the end of external SDRAM.
56 *
57 * Argument(s):
58 * commandp = the linux commandline arg container to fill.
59 * size = the sizeof commandp.
60 *
61 * Returns:
62 */
63static void __init parse_uboot_commandline(char *commandp, int size)
64{
65 extern unsigned long _init_sp;
66 unsigned long *sp;
67 unsigned long uboot_kbd;
68 unsigned long uboot_initrd_start, uboot_initrd_end;
69 unsigned long uboot_cmd_start, uboot_cmd_end;
70
71 sp = (unsigned long *)_init_sp;
72 uboot_kbd = sp[1];
73 uboot_initrd_start = sp[2];
74 uboot_initrd_end = sp[3];
75 uboot_cmd_start = sp[4];
76 uboot_cmd_end = sp[5];
77
78 if (uboot_cmd_start && uboot_cmd_end)
79 strncpy(commandp, (const char *)uboot_cmd_start, size);
80#if defined(CONFIG_BLK_DEV_INITRD)
81 if (uboot_initrd_start && uboot_initrd_end &&
82 (uboot_initrd_end > uboot_initrd_start)) {
83 initrd_start = uboot_initrd_start;
84 initrd_end = uboot_initrd_end;
85 ROOT_DEV = Root_RAM0;
86 printk(KERN_INFO "initrd at 0x%lx:0x%lx\n",
87 initrd_start, initrd_end);
88 }
89#endif /* if defined(CONFIG_BLK_DEV_INITRD) */
90}
91
92__init void process_uboot_commandline(char *commandp, int size)
93{
94 int len, n;
95
96 n = strnlen(commandp, size);
97 commandp += n;
98 len = size - n;
99 if (len) {
100 /* Add the whitespace separator */
101 *commandp++ = ' ';
102 len--;
103 }
104
105 parse_uboot_commandline(commandp, len);
106 commandp[size - 1] = 0;
107}