From: Andi Kleen <ak@muc.de>

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/head64.c   |   21 ----
 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    |  167 ++++++++++++++++------------------
 25-akpm/arch/x86_64/mm/numa.c         |   10 +-
 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 
 9 files changed, 110 insertions(+), 116 deletions(-)

diff -puN arch/x86_64/kernel/e820.c~early-param-x86_64-fix arch/x86_64/kernel/e820.c
--- 25/arch/x86_64/kernel/e820.c~early-param-x86_64-fix	2004-03-31 00:56:18.861805512 -0800
+++ 25-akpm/arch/x86_64/kernel/e820.c	2004-03-31 00:56:18.874803536 -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/head64.c~early-param-x86_64-fix arch/x86_64/kernel/head64.c
--- 25/arch/x86_64/kernel/head64.c~early-param-x86_64-fix	2004-03-31 00:56:18.862805360 -0800
+++ 25-akpm/arch/x86_64/kernel/head64.c	2004-03-31 00:56:18.874803536 -0800
@@ -34,10 +34,11 @@ extern char x86_boot_params[2048];
 #define OLD_CL_BASE_ADDR        0x90000
 #define OLD_CL_OFFSET           0x90022
 
+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);
@@ -49,8 +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));
-	printk("Bootdata ok (command line is %s)\n", 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)
@@ -72,23 +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(command_line, "console="))
-		strcat(command_line, " console=tty0");
-#ifdef CONFIG_DISCONTIGMEM
-	s = strstr(command_line, "numa=");
-	if (s != NULL)
-		numa_setup(s+5);
-#endif
-#ifdef CONFIG_X86_IO_APIC
-	if (strstr(command_line, "disableapic"))
-		disable_apic = 1;
-#endif
 	setup_boot_cpu_data();
 	start_kernel();
 }
diff -puN arch/x86_64/kernel/mpparse.c~early-param-x86_64-fix arch/x86_64/kernel/mpparse.c
--- 25/arch/x86_64/kernel/mpparse.c~early-param-x86_64-fix	2004-03-31 00:56:18.863805208 -0800
+++ 25-akpm/arch/x86_64/kernel/mpparse.c	2004-03-31 00:56:18.875803384 -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-fix arch/x86_64/kernel/pci-gart.c
--- 25/arch/x86_64/kernel/pci-gart.c~early-param-x86_64-fix	2004-03-31 00:56:18.865804904 -0800
+++ 25-akpm/arch/x86_64/kernel/pci-gart.c	2004-03-31 00:56:18.876803232 -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/kernel/setup.c~early-param-x86_64-fix arch/x86_64/kernel/setup.c
--- 25/arch/x86_64/kernel/setup.c~early-param-x86_64-fix	2004-03-31 00:56:18.867804600 -0800
+++ 25-akpm/arch/x86_64/kernel/setup.c	2004-03-31 00:56:18.878802928 -0800
@@ -191,100 +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;
-
-	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)
@@ -422,7 +421,7 @@ 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);
 
 	/*
diff -puN arch/x86_64/mm/numa.c~early-param-x86_64-fix arch/x86_64/mm/numa.c
--- 25/arch/x86_64/mm/numa.c~early-param-x86_64-fix	2004-03-31 00:56:18.868804448 -0800
+++ 25-akpm/arch/x86_64/mm/numa.c	2004-03-31 00:56:18.878802928 -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-fix include/asm-x86_64/e820.h
--- 25/include/asm-x86_64/e820.h~early-param-x86_64-fix	2004-03-31 00:56:18.869804296 -0800
+++ 25-akpm/include/asm-x86_64/e820.h	2004-03-31 00:56:18.879802776 -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-fix include/asm-x86_64/pci.h
--- 25/include/asm-x86_64/pci.h~early-param-x86_64-fix	2004-03-31 00:56:18.871803992 -0800
+++ 25-akpm/include/asm-x86_64/pci.h	2004-03-31 00:56:18.879802776 -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-fix include/asm-x86_64/proto.h
--- 25/include/asm-x86_64/proto.h~early-param-x86_64-fix	2004-03-31 00:56:18.872803840 -0800
+++ 25-akpm/include/asm-x86_64/proto.h	2004-03-31 00:56:18.880802624 -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);

_