From: Tom Rini - Remove saved_command_line (and saving of the command line). - Call parse_early_options - Convert "gdb", "xmon", "adb_sync" to __early_param. - Move the PPCBUG_NVRAM bits from platforms/platform.c into setup.c so that it's done in time to grab the command line and parse any early options found there. - Slightly related to all of this, change the mem= parsing logic to use memparse, instead of duplicating that specific logic. DESC further early_param fixes EDESC From: Tom Rini From: Paul Mackerras Tom's patches to add early_param also added some code to read the command line from nvram in setup_arch on PReP boxes. This broke powermacs, though, since init_prep_nvram() calls the ppc_md.nvram_read_val pointer, which is initialized later on powermac. In any case we don't want to call the prep nvram code on powermacs, but do want to call it if we aren't on PPC_MULTIARCH (tested here with PPC_PREP, as this code specific to the PREP subportion of PPC_MULTIARCH). This patch fixes it, and also eliminates a compile warning about early_adb_sync. --- 25-akpm/arch/ppc/kernel/ppc-stub.c | 17 +++++++++ 25-akpm/arch/ppc/kernel/setup.c | 57 +++++++++++++++++-------------- 25-akpm/arch/ppc/kernel/vmlinux.lds.S | 3 + 25-akpm/arch/ppc/mm/init.c | 16 +------- 25-akpm/arch/ppc/platforms/lopec_setup.c | 16 -------- 25-akpm/arch/ppc/platforms/pplus.c | 17 --------- 25-akpm/arch/ppc/platforms/prep_setup.c | 15 -------- 25-akpm/arch/ppc/xmon/xmon.c | 8 ++++ 25-akpm/include/asm-ppc/machdep.h | 3 - 25-akpm/include/asm-ppc/setup.h | 5 ++ 10 files changed, 69 insertions(+), 88 deletions(-) diff -puN arch/ppc/kernel/ppc-stub.c~early-param-ppc arch/ppc/kernel/ppc-stub.c --- 25/arch/ppc/kernel/ppc-stub.c~early-param-ppc 2004-04-02 10:32:34.938849856 -0800 +++ 25-akpm/arch/ppc/kernel/ppc-stub.c 2004-04-02 10:32:34.954847424 -0800 @@ -105,6 +105,7 @@ #include #include #include +#include #include #include @@ -834,6 +835,22 @@ breakpoint(void) breakinst: .long 0x7d821008"); } +/* Give us an early hook in. */ +static void __init early_kgdb(char **ign) +{ + if (ppc_md.kgdb_map_scc) + ppc_md.kgdb_map_scc(); + + set_debug_traps(); + + if (ppc_md.progress) + ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000); + printk("kgdb breakpoint activated\n"); + + breakpoint(); +} +__early_param("gdb", early_kgdb); + #ifdef CONFIG_KGDB_CONSOLE /* Output string in GDB O-packet format if GDB has connected. If nothing output, returns 0 (caller must then handle output). */ diff -puN arch/ppc/kernel/setup.c~early-param-ppc arch/ppc/kernel/setup.c --- 25/arch/ppc/kernel/setup.c~early-param-ppc 2004-04-02 10:32:34.939849704 -0800 +++ 25-akpm/arch/ppc/kernel/setup.c 2004-04-02 10:32:41.442861096 -0800 @@ -36,6 +36,7 @@ #include #include #include +#include #include #if defined CONFIG_KGDB @@ -53,7 +54,6 @@ extern void ppc6xx_idle(void); extern void power4_idle(void); extern boot_infos_t *boot_infos; -char saved_command_line[COMMAND_LINE_SIZE]; unsigned char aux_device_present; struct ide_machdep_calls ppc_ide_md; char *sysmap; @@ -457,12 +457,6 @@ platform_init(unsigned long r3, unsigned } } } -#ifdef CONFIG_ADB - if (strstr(cmd_line, "adb_sync")) { - extern int __adb_probe_sync; - __adb_probe_sync = 1; - } -#endif /* CONFIG_ADB */ switch (_machine) { case _MACH_Pmac: @@ -473,6 +467,17 @@ platform_init(unsigned long r3, unsigned break; } } + +#ifdef CONFIG_ADB +/* Allow us to say that ADB probing will be done synchronously. */ +static int __init early_adb_sync(char *ign) +{ + extern int __adb_probe_sync; + __adb_probe_sync = 1; + return 0; +} +__early_param("adb_sync", early_adb_sync); +#endif /* CONFIG_ADB */ #endif /* CONFIG_PPC_MULTIPLATFORM */ struct bi_record *find_bootinfo(void) @@ -637,23 +642,10 @@ void __init setup_arch(char **cmdline_p) #ifdef CONFIG_XMON xmon_map_scc(); - if (strstr(cmd_line, "xmon")) - xmon(0); -#endif /* CONFIG_XMON */ - if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab); - -#if defined(CONFIG_KGDB) - if (ppc_md.kgdb_map_scc) - ppc_md.kgdb_map_scc(); - set_debug_traps(); - if (strstr(cmd_line, "gdb")) { - if (ppc_md.progress) - ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000); - printk("kgdb breakpoint activated\n"); - breakpoint(); - } #endif + if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab); + /* * Set cache line size based on type of cpu as a default. * Systems with OF can look in the properties on the cpu node(s) @@ -670,14 +662,29 @@ void __init setup_arch(char **cmdline_p) /* reboot on panic */ panic_timeout = 180; + /* See if we need to grab the command line params from PPCBUG. */ +#ifdef CONFIG_PPCBUG_NVRAM +#ifdef CONFIG_PPC_PREP + if (_machine == _MACH_prep) +#endif + { + /* Read in NVRAM data */ + init_prep_nvram(); + + if (cmd_line[0] == '\0') { + char *bootargs = prep_nvram_get_var("bootargs"); + if (bootargs != NULL) + strlcpy(cmd_line, bootargs, sizeof(cmd_line)); + } + } +#endif + init_mm.start_code = PAGE_OFFSET; init_mm.end_code = (unsigned long) _etext; init_mm.end_data = (unsigned long) _edata; init_mm.brk = (unsigned long) klimit; - - /* Save unparsed command line copy for /proc/cmdline */ - strlcpy(saved_command_line, cmd_line, sizeof(saved_command_line)); *cmdline_p = cmd_line; + parse_early_options(cmdline_p); /* set up the bootmem stuff with available memory */ do_init_bootmem(); diff -puN arch/ppc/kernel/vmlinux.lds.S~early-param-ppc arch/ppc/kernel/vmlinux.lds.S --- 25/arch/ppc/kernel/vmlinux.lds.S~early-param-ppc 2004-04-02 10:32:34.941849400 -0800 +++ 25-akpm/arch/ppc/kernel/vmlinux.lds.S 2004-04-02 10:32:34.956847120 -0800 @@ -102,6 +102,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/ppc/mm/init.c~early-param-ppc arch/ppc/mm/init.c --- 25/arch/ppc/mm/init.c~early-param-ppc 2004-04-02 10:32:34.942849248 -0800 +++ 25-akpm/arch/ppc/mm/init.c 2004-04-02 10:32:34.956847120 -0800 @@ -209,19 +209,9 @@ void MMU_setup(void) char *p, *q; unsigned long maxmem = 0; - for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) { - q = p + 4; - if (p > cmd_line && p[-1] != ' ') - continue; - maxmem = simple_strtoul(q, &q, 0); - if (*q == 'k' || *q == 'K') { - maxmem <<= 10; - ++q; - } else if (*q == 'm' || *q == 'M') { - maxmem <<= 20; - ++q; - } - } + for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) + maxmem = memparse(p + 4, &q); + __max_memory = maxmem; } } diff -puN arch/ppc/platforms/lopec_setup.c~early-param-ppc arch/ppc/platforms/lopec_setup.c --- 25/arch/ppc/platforms/lopec_setup.c~early-param-ppc 2004-04-02 10:32:34.943849096 -0800 +++ 25-akpm/arch/ppc/platforms/lopec_setup.c 2004-04-02 10:32:34.957846968 -0800 @@ -33,7 +33,6 @@ #include #include -extern char saved_command_line[]; extern void lopec_find_bridges(void); /* @@ -327,21 +326,6 @@ lopec_setup_arch(void) #ifdef CONFIG_VT conswitchp = &dummy_con; #endif -#ifdef CONFIG_PPCBUG_NVRAM - /* Read in NVRAM data */ - init_prep_nvram(); - - /* if no bootargs, look in NVRAM */ - if ( cmd_line[0] == '\0' ) { - char *bootargs; - bootargs = prep_nvram_get_var("bootargs"); - if (bootargs != NULL) { - strcpy(cmd_line, bootargs); - /* again.. */ - strcpy(saved_command_line, cmd_line); - } - } -#endif } void __init diff -puN arch/ppc/platforms/pplus.c~early-param-ppc arch/ppc/platforms/pplus.c --- 25/arch/ppc/platforms/pplus.c~early-param-ppc 2004-04-02 10:32:34.945848792 -0800 +++ 25-akpm/arch/ppc/platforms/pplus.c 2004-04-02 10:32:34.958846816 -0800 @@ -48,8 +48,6 @@ TODC_ALLOC(); -extern char saved_command_line[]; - extern void pplus_setup_hose(void); extern void pplus_set_VIA_IDE_native(void); @@ -588,21 +586,6 @@ static void __init pplus_setup_arch(void #elif defined(CONFIG_DUMMY_CONSOLE) conswitchp = &dummy_con; #endif -#ifdef CONFIG_PPCBUG_NVRAM - /* Read in NVRAM data */ - init_prep_nvram(); - - /* if no bootargs, look in NVRAM */ - if (cmd_line[0] == '\0') { - char *bootargs; - bootargs = prep_nvram_get_var("bootargs"); - if (bootargs != NULL) { - strcpy(cmd_line, bootargs); - /* again.. */ - strcpy(saved_command_line, cmd_line); - } - } -#endif if (ppc_md.progress) ppc_md.progress("pplus_setup_arch: exit", 0); } diff -puN arch/ppc/platforms/prep_setup.c~early-param-ppc arch/ppc/platforms/prep_setup.c --- 25/arch/ppc/platforms/prep_setup.c~early-param-ppc 2004-04-02 10:32:34.947848488 -0800 +++ 25-akpm/arch/ppc/platforms/prep_setup.c 2004-04-02 10:32:34.959846664 -0800 @@ -76,7 +76,6 @@ extern void rs_nvram_write_val(int addr, extern void ibm_prep_init(void); extern void prep_find_bridges(void); -extern char saved_command_line[]; int _prep_type; @@ -774,20 +773,6 @@ prep_setup_arch(void) break; } - /* Read in NVRAM data */ - init_prep_nvram(); - - /* if no bootargs, look in NVRAM */ - if ( cmd_line[0] == '\0' ) { - char *bootargs; - bootargs = prep_nvram_get_var("bootargs"); - if (bootargs != NULL) { - strcpy(cmd_line, bootargs); - /* again.. */ - strcpy(saved_command_line, cmd_line); - } - } - #ifdef CONFIG_SOUND_CS4232 prep_init_sound(); #endif /* CONFIG_SOUND_CS4232 */ diff -puN arch/ppc/xmon/xmon.c~early-param-ppc arch/ppc/xmon/xmon.c --- 25/arch/ppc/xmon/xmon.c~early-param-ppc 2004-04-02 10:32:34.948848336 -0800 +++ 25-akpm/arch/ppc/xmon/xmon.c 2004-04-02 10:32:34.960846512 -0800 @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -262,6 +263,13 @@ xmon(struct pt_regs *excp) get_tb(start_tb[smp_processor_id()]); } +/* Allow us a hook to drop in early. */ +static void __init early_xmon(char **ign) +{ + xmon(0); +} +__early_param("xmon", early_xmon); + irqreturn_t xmon_irq(int irq, void *d, struct pt_regs *regs) { diff -puN include/asm-ppc/machdep.h~early-param-ppc include/asm-ppc/machdep.h --- 25/include/asm-ppc/machdep.h~early-param-ppc 2004-04-02 10:32:34.949848184 -0800 +++ 25-akpm/include/asm-ppc/machdep.h 2004-04-02 10:32:34.961846360 -0800 @@ -8,6 +8,7 @@ #ifdef CONFIG_APUS #include #endif +#include struct pt_regs; struct pci_bus; @@ -106,8 +107,6 @@ struct machdep_calls { }; extern struct machdep_calls ppc_md; -#define COMMAND_LINE_SIZE 512 -extern char cmd_line[COMMAND_LINE_SIZE]; extern void setup_pci_ptrs(void); diff -puN include/asm-ppc/setup.h~early-param-ppc include/asm-ppc/setup.h --- 25/include/asm-ppc/setup.h~early-param-ppc 2004-04-02 10:32:34.951847880 -0800 +++ 25-akpm/include/asm-ppc/setup.h 2004-04-02 10:32:34.961846360 -0800 @@ -2,10 +2,15 @@ #ifndef _PPC_SETUP_H #define _PPC_SETUP_H +#ifdef CONFIG_APUS #define m68k_num_memory num_memory #define m68k_memory memory #include +#endif + +#define COMMAND_LINE_SIZE 512 +extern char cmd_line[COMMAND_LINE_SIZE]; #endif /* _PPC_SETUP_H */ #endif /* __KERNEL__ */ _