Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+117 -79
+6
arch/m68k/include/asm/bootinfo.h
··· 22 22 static inline void save_bootinfo(const struct bi_record *bi) {} 23 23 #endif 24 24 25 + #ifdef CONFIG_UBOOT 26 + void process_uboot_commandline(char *commandp, int size); 27 + #else 28 + static inline void process_uboot_commandline(char *commandp, int size) {} 29 + #endif 30 + 25 31 #endif /* __ASSEMBLY__ */ 26 32 27 33
+1
arch/m68k/kernel/Makefile
··· 24 24 25 25 obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o 26 26 obj-$(CONFIG_BOOTINFO_PROC) += bootinfo_proc.o 27 + obj-$(CONFIG_UBOOT) += uboot.o 27 28 28 29 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 29 30
+1
arch/m68k/kernel/setup_mm.c
··· 274 274 strncpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE); 275 275 m68k_command_line[CL_SIZE - 1] = 0; 276 276 #endif /* CONFIG_BOOTPARAM */ 277 + process_uboot_commandline(&m68k_command_line[0], CL_SIZE); 277 278 *cmdline_p = m68k_command_line; 278 279 memcpy(boot_command_line, *cmdline_p, CL_SIZE); 279 280
+2 -79
arch/m68k/kernel/setup_no.c
··· 34 34 #include <linux/rtc.h> 35 35 36 36 #include <asm/setup.h> 37 + #include <asm/bootinfo.h> 37 38 #include <asm/irq.h> 38 39 #include <asm/machdep.h> 39 40 #include <asm/pgtable.h> ··· 83 82 #define CPU_INSTR_PER_JIFFY 16 84 83 #endif 85 84 86 - #if defined(CONFIG_UBOOT) 87 - /* 88 - * parse_uboot_commandline 89 - * 90 - * Copies u-boot commandline arguments and store them in the proper linux 91 - * variables. 92 - * 93 - * Assumes: 94 - * _init_sp global contains the address in the stack pointer when the 95 - * kernel starts (see head.S::_start) 96 - * 97 - * U-Boot calling convention: 98 - * (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end); 99 - * 100 - * _init_sp can be parsed as such 101 - * 102 - * _init_sp+00 = u-boot cmd after jsr into kernel (skip) 103 - * _init_sp+04 = &kernel board_info (residual data) 104 - * _init_sp+08 = &initrd_start 105 - * _init_sp+12 = &initrd_end 106 - * _init_sp+16 = &cmd_start 107 - * _init_sp+20 = &cmd_end 108 - * 109 - * This also assumes that the memory locations pointed to are still 110 - * unmodified. U-boot places them near the end of external SDRAM. 111 - * 112 - * Argument(s): 113 - * commandp = the linux commandline arg container to fill. 114 - * size = the sizeof commandp. 115 - * 116 - * Returns: 117 - */ 118 - static void __init parse_uboot_commandline(char *commandp, int size) 119 - { 120 - extern unsigned long _init_sp; 121 - unsigned long *sp; 122 - unsigned long uboot_kbd; 123 - unsigned long uboot_initrd_start, uboot_initrd_end; 124 - unsigned long uboot_cmd_start, uboot_cmd_end; 125 - 126 - 127 - sp = (unsigned long *)_init_sp; 128 - uboot_kbd = sp[1]; 129 - uboot_initrd_start = sp[2]; 130 - uboot_initrd_end = sp[3]; 131 - uboot_cmd_start = sp[4]; 132 - uboot_cmd_end = sp[5]; 133 - 134 - if (uboot_cmd_start && uboot_cmd_end) 135 - strncpy(commandp, (const char *)uboot_cmd_start, size); 136 - #if defined(CONFIG_BLK_DEV_INITRD) 137 - if (uboot_initrd_start && uboot_initrd_end && 138 - (uboot_initrd_end > uboot_initrd_start)) { 139 - initrd_start = uboot_initrd_start; 140 - initrd_end = uboot_initrd_end; 141 - ROOT_DEV = Root_RAM0; 142 - printk(KERN_INFO "initrd at 0x%lx:0x%lx\n", 143 - initrd_start, initrd_end); 144 - } 145 - #endif /* if defined(CONFIG_BLK_DEV_INITRD) */ 146 - } 147 - #endif /* #if defined(CONFIG_UBOOT) */ 148 - 149 85 void __init setup_arch(char **cmdline_p) 150 86 { 151 87 int bootmap_size; ··· 102 164 command_line[sizeof(command_line) - 1] = 0; 103 165 #endif /* CONFIG_BOOTPARAM */ 104 166 105 - #if defined(CONFIG_UBOOT) 106 - /* CONFIG_UBOOT and CONFIG_BOOTPARAM defined, concatenate cmdline */ 107 - #if defined(CONFIG_BOOTPARAM) 108 - /* Add the whitespace separator */ 109 - command_line[strlen(CONFIG_BOOTPARAM_STRING)] = ' '; 110 - /* Parse uboot command line into the rest of the buffer */ 111 - parse_uboot_commandline( 112 - &command_line[(strlen(CONFIG_BOOTPARAM_STRING)+1)], 113 - (sizeof(command_line) - 114 - (strlen(CONFIG_BOOTPARAM_STRING)+1))); 115 - /* Only CONFIG_UBOOT defined, create cmdline */ 116 - #else 117 - parse_uboot_commandline(&command_line[0], sizeof(command_line)); 118 - #endif /* CONFIG_BOOTPARAM */ 119 - command_line[sizeof(command_line) - 1] = 0; 120 - #endif /* CONFIG_UBOOT */ 167 + process_uboot_commandline(&command_line[0], sizeof(command_line)); 121 168 122 169 printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU_NAME "\n"); 123 170
+107
arch/m68k/kernel/uboot.c
··· 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 + */ 63 + static 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 + }