From: Tom Rini - Remove saved_command_line (and saving of the command line). - Call parse_early_options - Convert earlyprintk= DESC Fix x86-64 early command line parsing EDESC From: Andi Kleen Convert x86-64 properly to the new early command line parsing and make it compile again. --- 25-akpm/arch/x86_64/kernel/e820.c | 8 - 25-akpm/arch/x86_64/kernel/early_printk.c | 2 25-akpm/arch/x86_64/kernel/head64.c | 25 ---- 25-akpm/arch/x86_64/kernel/mpparse.c | 7 + 25-akpm/arch/x86_64/kernel/pci-gart.c | 5 25-akpm/arch/x86_64/kernel/setup.c | 174 ++++++++++++++---------------- 25-akpm/arch/x86_64/kernel/vmlinux.lds.S | 3 25-akpm/arch/x86_64/mm/numa.c | 10 + 25-akpm/include/asm-x86_64/bootsetup.h | 1 25-akpm/include/asm-x86_64/e820.h | 2 25-akpm/include/asm-x86_64/pci.h | 2 25-akpm/include/asm-x86_64/proto.h | 4 25-akpm/include/asm-x86_64/setup.h | 6 - 13 files changed, 116 insertions(+), 133 deletions(-) diff -puN arch/x86_64/kernel/early_printk.c~early-param-x86_64 arch/x86_64/kernel/early_printk.c --- 25/arch/x86_64/kernel/early_printk.c~early-param-x86_64 2004-04-02 10:33:04.763315848 -0800 +++ 25-akpm/arch/x86_64/kernel/early_printk.c 2004-04-02 10:33:04.775314024 -0800 @@ -219,4 +219,4 @@ void __init disable_early_printk(void) } } -__setup("earlyprintk=", setup_early_printk); +__early_param("earlyprintk=", setup_early_printk); diff -puN arch/x86_64/kernel/head64.c~early-param-x86_64 arch/x86_64/kernel/head64.c --- 25/arch/x86_64/kernel/head64.c~early-param-x86_64 2004-04-02 10:33:04.764315696 -0800 +++ 25-akpm/arch/x86_64/kernel/head64.c 2004-04-02 10:33:07.858845256 -0800 @@ -34,12 +34,11 @@ extern char x86_boot_params[2048]; #define OLD_CL_BASE_ADDR 0x90000 #define OLD_CL_OFFSET 0x90022 -extern char saved_command_line[]; +char *early_command_line __initdata; static void __init copy_bootdata(char *real_mode_data) { int new_data; - char * command_line; memcpy(x86_boot_params, real_mode_data, 2048); new_data = *(int *) (x86_boot_params + NEW_CL_POINTER); @@ -51,9 +50,8 @@ static void __init copy_bootdata(char *r new_data = OLD_CL_BASE_ADDR + * (u16 *) OLD_CL_OFFSET; printk("old bootloader convention, maybe loadlin?\n"); } - command_line = (char *) ((u64)(new_data)); - memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); - printk("Bootdata ok (command line is %s)\n", saved_command_line); + early_command_line = (char *) ((u64)(new_data)); + printk("Bootdata ok (command line is %s)\n", early_command_line); } static void __init setup_boot_cpu_data(void) @@ -75,26 +73,9 @@ static void __init setup_boot_cpu_data(v void __init x86_64_start_kernel(char * real_mode_data) { - char *s; - clear_bss(); pda_init(0); copy_bootdata(real_mode_data); - /* default console: */ - if (!strstr(saved_command_line, "console=")) - strcat(saved_command_line, " console=tty0"); - s = strstr(saved_command_line, "earlyprintk="); - if (s != NULL) - setup_early_printk(s); -#ifdef CONFIG_DISCONTIGMEM - s = strstr(saved_command_line, "numa="); - if (s != NULL) - numa_setup(s+5); -#endif -#ifdef CONFIG_X86_IO_APIC - if (strstr(saved_command_line, "disableapic")) - disable_apic = 1; -#endif setup_boot_cpu_data(); start_kernel(); } diff -puN arch/x86_64/kernel/setup.c~early-param-x86_64 arch/x86_64/kernel/setup.c --- 25/arch/x86_64/kernel/setup.c~early-param-x86_64 2004-04-02 10:33:04.766315392 -0800 +++ 25-akpm/arch/x86_64/kernel/setup.c 2004-04-02 10:33:07.862844648 -0800 @@ -55,6 +55,7 @@ #include #include #include +#include /* For COMMAND_LINE_SIZE */ /* * Machine setup.. @@ -100,7 +101,6 @@ extern int root_mountflags; extern char _text, _etext, _edata, _end; char command_line[COMMAND_LINE_SIZE]; -char saved_command_line[COMMAND_LINE_SIZE]; struct resource standard_io_resources[] = { { "dma1", 0x00, 0x1f, IORESOURCE_BUSY }, @@ -191,104 +191,99 @@ static void __init probe_roms(void) } } -static __init void parse_cmdline_early (char ** cmdline_p) +#ifdef CONFIG_ACPI_BOOT +/* should be moved elsewhere */ +static __init int early_acpi(char *s) { - char c = ' ', *to = command_line, *from = COMMAND_LINE; - int len = 0; - - /* Save unparsed command line copy for /proc/cmdline */ - memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE); - saved_command_line[COMMAND_LINE_SIZE-1] = '\0'; - - for (;;) { - if (c != ' ') - goto next_char; - -#ifdef CONFIG_SMP - /* - * If the BIOS enumerates physical processors before logical, - * maxcpus=N at enumeration-time can be used to disable HT. - */ - else if (!memcmp(from, "maxcpus=", 8)) { - extern unsigned int maxcpus; + /* "acpi=off" disables both ACPI table parsing and interpreter init */ + if (!strcmp(s, "off")) + acpi_disabled = 1; + + else if (!strcmp(s, "force")) { + /* add later when we do DMI horrors: */ + /* acpi_force = 1; */ + acpi_disabled = 0; + } + + /* acpi=ht just means: do ACPI MADT parsing + at bootup, but don't enable the full ACPI interpreter */ + else if (!strcmp(s, "ht")) + acpi_ht = 1; + + /* acpi=strict disables out-of-spec workarounds */ + else if (!strcmp(s, "strict")) + acpi_strict = 1; + else + return -1; - maxcpus = simple_strtoul(from + 8, NULL, 0); - } -#endif -#ifdef CONFIG_ACPI_BOOT - /* "acpi=off" disables both ACPI table parsing and interpreter init */ - if (!memcmp(from, "acpi=off", 8)) - acpi_disabled = 1; - - if (!memcmp(from, "acpi=force", 10)) { - /* add later when we do DMI horrors: */ - /* acpi_force = 1; */ - acpi_disabled = 0; - } + return 0; +} +__early_param("acpi=", early_acpi); - /* acpi=ht just means: do ACPI MADT parsing - at bootup, but don't enable the full ACPI interpreter */ - if (!memcmp(from, "acpi=ht", 7)) { - acpi_ht = 1; - } - else if (!memcmp(from, "pci=noacpi", 10)) - acpi_noirq_set(); +static __init int early_acpi_sci(char *s) +{ + if (!strcmp(s, "edge")) + acpi_sci_flags.trigger = 1; + else if (!strcmp(s, "level")) + acpi_sci_flags.trigger = 3; + else if (!strcmp(s, "high")) + acpi_sci_flags.polarity = 1; + else if (!strcmp(s, "low")) + acpi_sci_flags.polarity = 3; + else + return -1; + return 0; +} +__early_param("acpi_sci=", early_acpi_sci); - else if (!memcmp(from, "acpi_sci=edge", 13)) - acpi_sci_flags.trigger = 1; - else if (!memcmp(from, "acpi_sci=level", 14)) - acpi_sci_flags.trigger = 3; - else if (!memcmp(from, "acpi_sci=high", 13)) - acpi_sci_flags.polarity = 1; - else if (!memcmp(from, "acpi_sci=low", 12)) - acpi_sci_flags.polarity = 3; - - /* acpi=strict disables out-of-spec workarounds */ - else if (!memcmp(from, "acpi=strict", 11)) { - acpi_strict = 1; - } +static __init int early_pci(char *s) +{ + if (!strcmp(s, "noacpi")) + acpi_noirq_set(); + else + return -1; + return 0; +} +__early_param("pci=", early_pci); #endif - if (!memcmp(from, "nolapic", 7) || - !memcmp(from, "disableapic", 11)) - disable_apic = 1; - - if (!memcmp(from, "noapic", 6)) - skip_ioapic_setup = 1; - - if (!memcmp(from, "apic", 4)) { - skip_ioapic_setup = 0; - ioapic_force = 1; - } - - if (!memcmp(from, "mem=", 4)) - parse_memopt(from+4, &from); +static __init int early_nolapic(char *s) +{ + disable_apic = 1; + return 0; +} +__early_param("nolapic", early_nolapic); -#ifdef CONFIG_DISCONTIGMEM - if (!memcmp(from, "numa=", 5)) - numa_setup(from+5); -#endif +/* alias for compatibility */ +static __init int early_disableapic(char *s) +{ + disable_apic = 1; + return 0; +} +__early_param("disableapic", early_disableapic); -#ifdef CONFIG_GART_IOMMU - if (!memcmp(from,"iommu=",6)) { - iommu_setup(from+6); - } -#endif +static __init int early_no_ioapic(char *s) +{ + skip_ioapic_setup = 1; + return 0; +} +__early_param("noapic", early_no_ioapic); - if (!memcmp(from,"oops=panic", 10)) - panic_on_oops = 1; +static __init int early_apic(char *s) +{ + skip_ioapic_setup = 0; + ioapic_force = 1; + return 0; +} +__early_param("apic", early_apic); - next_char: - c = *(from++); - if (!c) - break; - if (COMMAND_LINE_SIZE <= ++len) - break; - *(to++) = c; - } - *to = '\0'; - *cmdline_p = command_line; +static __init int early_oopspanic(char *s) +{ + panic_on_oops = 1; + return 0; } +__early_param("oops=panic", early_oopspanic); + #ifndef CONFIG_DISCONTIGMEM static void __init contig_initmem_init(void) @@ -426,7 +421,8 @@ void __init setup_arch(char **cmdline_p) data_resource.start = virt_to_phys(&_etext); data_resource.end = virt_to_phys(&_edata)-1; - parse_cmdline_early(cmdline_p); + *cmdline_p = early_command_line; + parse_early_options(cmdline_p); /* * partially used pages are not usable - thus diff -puN arch/x86_64/kernel/vmlinux.lds.S~early-param-x86_64 arch/x86_64/kernel/vmlinux.lds.S --- 25/arch/x86_64/kernel/vmlinux.lds.S~early-param-x86_64 2004-04-02 10:33:04.768315088 -0800 +++ 25-akpm/arch/x86_64/kernel/vmlinux.lds.S 2004-04-02 10:33:04.777313720 -0800 @@ -90,6 +90,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 include/asm-x86_64/bootsetup.h~early-param-x86_64 include/asm-x86_64/bootsetup.h --- 25/include/asm-x86_64/bootsetup.h~early-param-x86_64 2004-04-02 10:33:04.769314936 -0800 +++ 25-akpm/include/asm-x86_64/bootsetup.h 2004-04-02 10:33:04.777313720 -0800 @@ -30,7 +30,6 @@ extern char x86_boot_params[2048]; #define EDD_NR (*(unsigned char *) (PARAM+EDDNR)) #define EDD_BUF ((struct edd_info *) (PARAM+EDDBUF)) #define COMMAND_LINE saved_command_line -#define COMMAND_LINE_SIZE 256 #define RAMDISK_IMAGE_START_MASK 0x07FF #define RAMDISK_PROMPT_FLAG 0x8000 diff -puN include/asm-x86_64/setup.h~early-param-x86_64 include/asm-x86_64/setup.h --- 25/include/asm-x86_64/setup.h~early-param-x86_64 2004-04-02 10:33:04.771314632 -0800 +++ 25-akpm/include/asm-x86_64/setup.h 2004-04-02 10:33:04.777313720 -0800 @@ -1,10 +1,6 @@ -/* - * Just a place holder. We don't want to have to test x86 before - * we include stuff - */ - #ifndef _x8664_SETUP_H #define _x8664_SETUP_H +#define COMMAND_LINE_SIZE 256 #endif diff -puN arch/x86_64/kernel/e820.c~early-param-x86_64 arch/x86_64/kernel/e820.c --- 25/arch/x86_64/kernel/e820.c~early-param-x86_64 2004-04-02 10:33:07.665874592 -0800 +++ 25-akpm/arch/x86_64/kernel/e820.c 2004-04-02 10:33:07.858845256 -0800 @@ -505,7 +505,7 @@ void __init setup_memory_region(void) e820_print_map(who); } -void __init parse_memopt(char *p, char **from) +static int __init parse_memopt(char *s) { /* * mem=XXX[kKmM] limits kernel memory to XXX+1MB @@ -520,8 +520,10 @@ void __init parse_memopt(char *p, char * * limit, you cannot force usage of memory not in e820. * * -AK - */ - end_user_pfn = memparse(p, from) + HIGH_MEMORY; + */ + end_user_pfn = memparse(s, &s) + HIGH_MEMORY; end_user_pfn >>= PAGE_SHIFT; + return 0; } +__early_param("mem=",parse_memopt); diff -puN arch/x86_64/kernel/mpparse.c~early-param-x86_64 arch/x86_64/kernel/mpparse.c --- 25/arch/x86_64/kernel/mpparse.c~early-param-x86_64 2004-04-02 10:33:07.712867448 -0800 +++ 25-akpm/arch/x86_64/kernel/mpparse.c 2004-04-02 10:33:07.859845104 -0800 @@ -976,3 +976,10 @@ void __init mp_parse_prt (void) #endif /*CONFIG_X86_IO_APIC*/ #endif /*CONFIG_ACPI_BOOT*/ + +static __init int early_maxcpus(char *s) +{ + maxcpus = simple_strtoul(s, NULL, 0); + return 0; +} +__early_param("maxcpus=", early_maxcpus); diff -puN arch/x86_64/kernel/pci-gart.c~early-param-x86_64 arch/x86_64/kernel/pci-gart.c --- 25/arch/x86_64/kernel/pci-gart.c~early-param-x86_64 2004-04-02 10:33:07.736863800 -0800 +++ 25-akpm/arch/x86_64/kernel/pci-gart.c 2004-04-02 10:33:07.860844952 -0800 @@ -853,7 +853,7 @@ fs_initcall(pci_iommu_init); allowed overwrite iommu off workarounds for specific chipsets. soft Use software bounce buffering (default for Intel machines) */ -__init int iommu_setup(char *opt) +static __init int iommu_setup(char *opt) { int arg; char *p = opt; @@ -913,5 +913,6 @@ __init int iommu_setup(char *opt) return 0; } while (*p++ != ','); } - return 1; + return 0; } +__early_param("iommu=",iommu_setup); diff -puN arch/x86_64/mm/numa.c~early-param-x86_64 arch/x86_64/mm/numa.c --- 25/arch/x86_64/mm/numa.c~early-param-x86_64 2004-04-02 10:33:07.783856656 -0800 +++ 25-akpm/arch/x86_64/mm/numa.c 2004-04-02 10:33:07.862844648 -0800 @@ -178,11 +178,13 @@ void __init paging_init(void) } /* [numa=off] */ -__init int numa_setup(char *opt) +static __init int numa_setup(char *opt) { - if (!strncmp(opt,"off",3)) + if (!strcmp(opt,"off")) numa_off = 1; - return 1; + else + return -1; + return 0; } - +__early_param("numa=", numa_setup); diff -puN include/asm-x86_64/e820.h~early-param-x86_64 include/asm-x86_64/e820.h --- 25/include/asm-x86_64/e820.h~early-param-x86_64 2004-04-02 10:33:07.808852856 -0800 +++ 25-akpm/include/asm-x86_64/e820.h 2004-04-02 10:33:07.863844496 -0800 @@ -54,8 +54,6 @@ extern int e820_mapped(unsigned long sta extern void e820_bootmem_free(pg_data_t *pgdat, unsigned long start,unsigned long end); -extern void __init parse_memopt(char *p, char **end); - extern struct e820map e820; #endif/*!__ASSEMBLY__*/ diff -puN include/asm-x86_64/pci.h~early-param-x86_64 include/asm-x86_64/pci.h --- 25/include/asm-x86_64/pci.h~early-param-x86_64 2004-04-02 10:33:07.831849360 -0800 +++ 25-akpm/include/asm-x86_64/pci.h 2004-04-02 10:33:07.863844496 -0800 @@ -46,8 +46,6 @@ int pcibios_set_irq_routing(struct pci_d struct pci_dev; -extern int iommu_setup(char *opt); - extern dma_addr_t bad_dma_address; #define pci_dma_mapping_error(x) ((x) == bad_dma_address) diff -puN include/asm-x86_64/proto.h~early-param-x86_64 include/asm-x86_64/proto.h --- 25/include/asm-x86_64/proto.h~early-param-x86_64 2004-04-02 10:33:07.855845712 -0800 +++ 25-akpm/include/asm-x86_64/proto.h 2004-04-02 10:33:07.864844344 -0800 @@ -33,8 +33,6 @@ extern void time_init_smp(void); extern void do_softirq_thunk(void); -extern int numa_setup(char *opt); - extern int setup_early_printk(char *); extern void early_printk(const char *fmt, ...) __attribute__((format(printf,1,2))); @@ -104,6 +102,8 @@ extern int iommu_aperture; extern int iommu_aperture_disabled; extern int iommu_aperture_allowed; +extern char *early_command_line; + extern void smp_local_timer_interrupt(struct pt_regs * regs); long do_arch_prctl(struct task_struct *task, int code, unsigned long addr); _