From: Tom Rini - Remove saved_command_line (and saving of the command line). - Call parse_early_options - Convert mem= to __early_param --- 25-akpm/arch/mips/cobalt/setup.c | 2 25-akpm/arch/mips/kernel/setup.c | 75 ++++++++++++--------------------- 25-akpm/arch/mips/kernel/vmlinux.lds.S | 3 + 25-akpm/arch/mips/lasat/prom.c | 4 - 25-akpm/arch/mips/sibyte/cfe/setup.c | 4 - 25-akpm/include/asm-mips/bootinfo.h | 5 -- 25-akpm/include/asm-mips/setup.h | 8 +++ 7 files changed, 46 insertions(+), 55 deletions(-) diff -puN arch/mips/cobalt/setup.c~early-param-mips arch/mips/cobalt/setup.c --- 25/arch/mips/cobalt/setup.c~early-param-mips 2004-03-30 19:49:09.123551592 -0800 +++ 25-akpm/arch/mips/cobalt/setup.c 2004-03-30 19:49:09.132550224 -0800 @@ -31,7 +31,7 @@ extern void cobalt_machine_power_off(voi int cobalt_board_id; -static char my_cmdline[CL_SIZE] = { +static char my_cmdline[COMMAND_LINE_SIZE] = { "console=ttyS0,115200 " #ifdef CONFIG_IP_PNP "ip=on " diff -puN arch/mips/kernel/setup.c~early-param-mips arch/mips/kernel/setup.c --- 25/arch/mips/kernel/setup.c~early-param-mips 2004-03-30 19:49:09.124551440 -0800 +++ 25-akpm/arch/mips/kernel/setup.c 2004-03-30 19:49:09.133550072 -0800 @@ -71,7 +71,6 @@ EXPORT_SYMBOL(mips_machgroup); struct boot_mem_map boot_mem_map; static char command_line[CL_SIZE]; - char saved_command_line[CL_SIZE]; char arcs_cmdline[CL_SIZE]=CONFIG_CMDLINE; /* @@ -143,57 +142,37 @@ static void __init print_memory_map(void } } -static inline void parse_cmdline_early(void) +/* + * "mem=XXX[kKmM]" defines a memory region from 0 to , overriding + * the determined size. "mem=XXX[KkmM]@YYY[KkmM]" defines a memory region + * from to +, overriding the determined size. + */ +static int __init early_mem(char *from) { - char c = ' ', *to = command_line, *from = saved_command_line; unsigned long start_at, mem_size; int len = 0; - int usermem = 0; - printk("Determined physical RAM map:\n"); - print_memory_map(); + /* + * The user has specified the memory size, so we blow away any + * automatically generated size. + */ + boot_mem_map.nr_map = 0; - for (;;) { - /* - * "mem=XXX[kKmM]" defines a memory region from - * 0 to , overriding the determined size. - * "mem=XXX[KkmM]@YYY[KkmM]" defines a memory region from - * to +, overriding the determined size. - */ - if (c == ' ' && !memcmp(from, "mem=", 4)) { - if (to != command_line) - to--; - /* - * If a user specifies memory size, we - * blow away any automatically generated - * size. - */ - if (usermem == 0) { - boot_mem_map.nr_map = 0; - usermem = 1; - } - mem_size = memparse(from + 4, &from); - if (*from == '@') - start_at = memparse(from + 1, &from); - else - start_at = 0; - add_memory_region(start_at, mem_size, BOOT_MEM_RAM); - } - c = *(from++); - if (!c) - break; - if (CL_SIZE <= ++len) - break; - *(to++) = c; - } - *to = '\0'; + mem_size = memparse(from, &from); - if (usermem) { - printk("User-defined physical RAM map:\n"); - print_memory_map(); - } -} + if (*from == '@') + start_at = memparse(from + 1, &from); + else + start_at = 0; + + add_memory_region(start_at, mem_size, BOOT_MEM_RAM); + printk("User-defined physical RAM map:\n"); + print_memory_map(); + + return 0; +} +__early_param("mem=", early_mem); #define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT) #define PFN_DOWN(x) ((x) >> PAGE_SHIFT) @@ -484,11 +463,13 @@ void __init setup_arch(char **cmdline_p) do_earlyinitcalls(); strlcpy(command_line, arcs_cmdline, sizeof(command_line)); - strlcpy(saved_command_line, command_line, sizeof(saved_command_line)); + + printk("Determined physical RAM map:\n"); + print_memory_map(); *cmdline_p = command_line; + parse_early_options(cmdline_p); - parse_cmdline_early(); bootmem_init(); paging_init(); resource_init(); diff -puN arch/mips/kernel/vmlinux.lds.S~early-param-mips arch/mips/kernel/vmlinux.lds.S --- 25/arch/mips/kernel/vmlinux.lds.S~early-param-mips 2004-03-30 19:49:09.126551136 -0800 +++ 25-akpm/arch/mips/kernel/vmlinux.lds.S 2004-03-30 19:49:09.134549920 -0800 @@ -95,6 +95,9 @@ SECTIONS __setup_start = .; .init.setup : { *(.init.setup) } __setup_end = .; + __early_begin = .; + __early_param : { *(__early_param) } + __early_end = .; __start___param = .; __param : { *(__param) } __stop___param = .; diff -puN arch/mips/lasat/prom.c~early-param-mips arch/mips/lasat/prom.c --- 25/arch/mips/lasat/prom.c~early-param-mips 2004-03-30 19:49:09.127550984 -0800 +++ 25-akpm/arch/mips/lasat/prom.c 2004-03-30 19:49:09.135549768 -0800 @@ -111,8 +111,8 @@ void __init prom_init(void) /* Get the command line */ if (argc > 0) { - strncpy(arcs_cmdline, argv[0], CL_SIZE-1); - arcs_cmdline[CL_SIZE-1] = '\0'; + strncpy(arcs_cmdline, argv[0], COMMAND_LINE_SIZE-1); + arcs_cmdline[COMMAND_LINE_SIZE-1] = '\0'; } /* Set the I/O base address */ diff -puN arch/mips/sibyte/cfe/setup.c~early-param-mips arch/mips/sibyte/cfe/setup.c --- 25/arch/mips/sibyte/cfe/setup.c~early-param-mips 2004-03-30 19:49:09.129550680 -0800 +++ 25-akpm/arch/mips/sibyte/cfe/setup.c 2004-03-30 19:49:09.135549768 -0800 @@ -291,7 +291,7 @@ void __init prom_init(void) * boot console */ cfe_cons_handle = cfe_getstdhandle(CFE_STDHANDLE_CONSOLE); - if (cfe_getenv("LINUX_CMDLINE", arcs_cmdline, CL_SIZE) < 0) { + if (cfe_getenv("LINUX_CMDLINE", arcs_cmdline, COMMAND_LINE_SIZE) < 0) { if (argc < 0) { /* * It's OK for direct boot to not provide a @@ -338,7 +338,7 @@ void __init prom_init(void) #endif /* CONFIG_BLK_DEV_INITRD */ /* Not sure this is needed, but it's the safe way. */ - arcs_cmdline[CL_SIZE-1] = 0; + arcs_cmdline[COMMAND_LINE_SIZE-1] = 0; mips_machgroup = MACH_GROUP_SIBYTE; prom_meminit(); diff -puN include/asm-mips/bootinfo.h~early-param-mips include/asm-mips/bootinfo.h --- 25/include/asm-mips/bootinfo.h~early-param-mips 2004-03-30 19:49:09.131550376 -0800 +++ 25-akpm/include/asm-mips/bootinfo.h 2004-03-30 19:49:09.136549616 -0800 @@ -12,6 +12,7 @@ #define _ASM_BOOTINFO_H #include +#include /* * The MACH_GROUP_ IDs are the equivalent to PCI vendor IDs; the remaining @@ -208,8 +209,6 @@ #define MACH_GROUP_TITAN 22 /* PMC-Sierra Titan */ #define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */ -#define CL_SIZE (256) - const char *get_system_type(void); extern unsigned long mips_machtype; @@ -242,7 +241,7 @@ extern void prom_init(void); /* * Initial kernel command line, usually setup by prom_init() */ -extern char arcs_cmdline[CL_SIZE]; +extern char arcs_cmdline[COMMAND_LINE_SIZE]; /* * Registers a0, a1, a3 and a4 as passed to the kenrel entry by firmware diff -puN /dev/null include/asm-mips/setup.h --- /dev/null 2003-09-15 06:40:47.000000000 -0700 +++ 25-akpm/include/asm-mips/setup.h 2004-03-30 19:49:09.136549616 -0800 @@ -0,0 +1,8 @@ +#ifdef __KERNEL__ +#ifndef _MIPS_SETUP_H +#define _MIPS_SETUP_H + +#define COMMAND_LINE_SIZE 256 + +#endif /* __SETUP_H */ +#endif /* __KERNEL__ */ _