
From: Rusty Russell <rusty@rustcorp.com.au>

Much less ambitious patches.  First one only drags saved_command_line into
init/main.c, declaration in linux/init.h, and COMMAND_LINE_SIZE def in
asm/setup.h.

Second one adds early_param() (semantics like module_param), and the arch
can call parse_early_param() to parse them.  If it doesn't,
parse_early_param() gets called just before normal param parsing.

I'd love to remove the char ** arg from setup_arch and make all parsers
copy saved_command_line, but that's a job for another day.

Small testcase at the end...


Currently every arch declares its own char saved_command_line[].  Make sure
every arch defines COMMAND_LINE_SIZE in asm/setup.h, and declare
saved_command_line in linux/init.h (init/main.c contains the definition).
DESC
arch/i386/boot/compressed/misc.c warning fixes
EDESC

We're now including setup.h via init.h, which gives:

arch/i386/boot/compressed/misc.c:90: warning: `EXT_MEM_K' redefined
include/asm/setup.h:36: warning: this is the location of the previous definition
arch/i386/boot/compressed/misc.c:92: warning: `ALT_MEM_K' redefined
include/asm/setup.h:37: warning: this is the location of the previous definition
arch/i386/boot/compressed/misc.c:94: warning: `SCREEN_INFO' redefined
include/asm/setup.h:35: warning: this is the location of the previous definition
arch/i386/boot/compressed/misc.c:95: warning: `EDID_INFO' redefined
include/asm/setup.h:58: warning: this is the location of the previous definition


Signed-off-by:  Andrew Morton <akpm@osdl.org>
---
 25-akpm/arch/alpha/kernel/setup.c           |    1 
 25-akpm/arch/arm/kernel/setup.c             |    1 
 25-akpm/arch/arm26/kernel/setup.c           |    1 
 25-akpm/arch/cris/kernel/setup.c            |    3 -
 25-akpm/arch/h8300/kernel/setup.c           |    4 +-
 25-akpm/arch/i386/boot/compressed/misc.c    |   31 +++++++++---------
 25-akpm/arch/i386/kernel/setup.c            |    1 
 25-akpm/arch/ia64/kernel/setup.c            |    4 --
 25-akpm/arch/m68k/kernel/setup.c            |    1 
 25-akpm/arch/m68k/q40/config.c              |    1 
 25-akpm/arch/m68knommu/kernel/setup.c       |    4 +-
 25-akpm/arch/mips/kernel/setup.c            |    1 
 25-akpm/arch/parisc/kernel/setup.c          |    2 -
 25-akpm/arch/ppc/kernel/setup.c             |    1 
 25-akpm/arch/ppc/platforms/lopec_setup.c    |    1 
 25-akpm/arch/ppc/platforms/pmac_setup.c     |    2 -
 25-akpm/arch/ppc/platforms/pplus.c          |    2 -
 25-akpm/arch/ppc/platforms/prep_setup.c     |    1 
 25-akpm/arch/ppc64/kernel/head.S            |    3 +
 25-akpm/arch/ppc64/kernel/setup.c           |    1 
 25-akpm/arch/s390/kernel/setup.c            |    1 
 25-akpm/arch/sh/kernel/setup.c              |    2 -
 25-akpm/arch/sparc/kernel/setup.c           |    3 -
 25-akpm/arch/sparc/kernel/sparc_ksyms.c     |    2 -
 25-akpm/arch/sparc64/kernel/setup.c         |    3 -
 25-akpm/arch/sparc64/kernel/sparc64_ksyms.c |    2 -
 25-akpm/arch/um/kernel/user_util.c          |    1 
 25-akpm/arch/v850/kernel/setup.c            |    4 +-
 25-akpm/arch/x86_64/kernel/setup.c          |    1 
 25-akpm/drivers/sbus/char/openprom.c        |    1 
 25-akpm/fs/proc/kcore.c                     |    3 -
 25-akpm/fs/proc/proc_misc.c                 |    1 
 25-akpm/include/asm-alpha/setup.h           |    6 +++
 25-akpm/include/asm-alpha/system.h          |    1 
 25-akpm/include/asm-cris/setup.h            |    3 +
 25-akpm/include/asm-h8300/setup.h           |    7 +++-
 25-akpm/include/asm-i386/param.h            |    1 
 25-akpm/include/asm-ia64/setup.h            |    6 +++
 25-akpm/include/asm-m68k/setup.h            |    1 
 25-akpm/include/asm-m68knommu/setup.h       |    4 ++
 25-akpm/include/asm-mips/bootinfo.h         |    3 +
 25-akpm/include/asm-mips/setup.h            |    8 ++++
 25-akpm/include/asm-parisc/setup.h          |   12 ++-----
 25-akpm/include/asm-ppc/machdep.h           |    1 
 25-akpm/include/asm-ppc/setup.h             |    3 +
 25-akpm/include/asm-ppc64/machdep.h         |    3 -
 25-akpm/include/asm-ppc64/setup.h           |    2 -
 25-akpm/include/asm-sh/setup.h              |    8 ++++
 25-akpm/include/asm-sparc/setup.h           |    1 
 25-akpm/include/asm-sparc64/setup.h         |    1 
 25-akpm/include/asm-um/setup.h              |    6 +++
 25-akpm/include/asm-v850/setup.h            |    6 +++
 25-akpm/include/asm-x86_64/bootsetup.h      |    1 
 25-akpm/include/asm-x86_64/setup.h          |    6 ---
 25-akpm/include/linux/init.h                |   22 ++++++++++---
 25-akpm/init/main.c                         |   47 +++++++++++++++++++++++++++-
 56 files changed, 161 insertions(+), 88 deletions(-)
diff -puN arch/alpha/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/alpha/kernel/setup.c
--- 25/arch/alpha/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.275783912 -0700
+++ 25-akpm/arch/alpha/kernel/setup.c	2004-05-25 22:10:40.429760504 -0700
@@ -122,7 +122,6 @@ static void get_sysnames(unsigned long, 
 static void determine_cpu_caches (unsigned int);
 
 static char command_line[COMMAND_LINE_SIZE];
-char saved_command_line[COMMAND_LINE_SIZE];
 
 /*
  * The format of "screen_info" is strange, and due to early
diff -puN arch/arm26/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/arm26/kernel/setup.c
--- 25/arch/arm26/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.277783608 -0700
+++ 25-akpm/arch/arm26/kernel/setup.c	2004-05-25 22:10:40.430760352 -0700
@@ -76,7 +76,6 @@ struct processor processor;
 
 unsigned char aux_device_present;
 char elf_platform[ELF_PLATFORM_SIZE];
-char saved_command_line[COMMAND_LINE_SIZE];
 
 unsigned long phys_initrd_start __initdata = 0;
 unsigned long phys_initrd_size __initdata = 0;
diff -puN arch/arm/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/arm/kernel/setup.c
--- 25/arch/arm/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.278783456 -0700
+++ 25-akpm/arch/arm/kernel/setup.c	2004-05-25 22:10:40.431760200 -0700
@@ -95,7 +95,6 @@ unsigned char aux_device_present;
 char elf_platform[ELF_PLATFORM_SIZE];
 EXPORT_SYMBOL(elf_platform);
 
-char saved_command_line[COMMAND_LINE_SIZE];
 unsigned long phys_initrd_start __initdata = 0;
 unsigned long phys_initrd_size __initdata = 0;
 
diff -puN arch/cris/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/cris/kernel/setup.c
--- 25/arch/cris/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.279783304 -0700
+++ 25-akpm/arch/cris/kernel/setup.c	2004-05-25 22:10:40.431760200 -0700
@@ -28,10 +28,7 @@ unsigned char aux_device_present;
 extern int root_mountflags;
 extern char _etext, _edata, _end;
 
-#define COMMAND_LINE_SIZE 256
-
 static char command_line[COMMAND_LINE_SIZE] = { 0, };
-       char saved_command_line[COMMAND_LINE_SIZE];
 
 extern const unsigned long text_start, edata; /* set by the linker script */
 extern unsigned long dram_start, dram_end;
diff -puN arch/h8300/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/h8300/kernel/setup.c
--- 25/arch/h8300/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.280783152 -0700
+++ 25-akpm/arch/h8300/kernel/setup.c	2004-05-25 22:10:40.431760200 -0700
@@ -30,6 +30,7 @@
 #include <linux/major.h>
 #include <linux/bootmem.h>
 #include <linux/seq_file.h>
+#include <linux/init.h>
 
 #include <asm/setup.h>
 #include <asm/irq.h>
@@ -54,8 +55,7 @@ unsigned long rom_length;
 unsigned long memory_start;
 unsigned long memory_end;
 
-char command_line[512];
-char saved_command_line[512];
+char command_line[COMMAND_LINE_SIZE];
 
 extern int _stext, _etext, _sdata, _edata, _sbss, _ebss, _end;
 extern int _ramstart, _ramend;
diff -puN arch/i386/boot/compressed/misc.c~Move-saved_command_line-to-init-mainc arch/i386/boot/compressed/misc.c
--- 25/arch/i386/boot/compressed/misc.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.282782848 -0700
+++ 25-akpm/arch/i386/boot/compressed/misc.c	2004-05-25 22:10:40.432760048 -0700
@@ -87,12 +87,11 @@ static void gzip_release(void **);
  */
 static unsigned char *real_mode; /* Pointer to real-mode data */
 
-#define EXT_MEM_K   (*(unsigned short *)(real_mode + 0x2))
+#define RM_EXT_MEM_K   (*(unsigned short *)(real_mode + 0x2))
 #ifndef STANDARD_MEMORY_BIOS_CALL
-#define ALT_MEM_K   (*(unsigned long *)(real_mode + 0x1e0))
+#define RM_ALT_MEM_K   (*(unsigned long *)(real_mode + 0x1e0))
 #endif
-#define SCREEN_INFO (*(struct screen_info *)(real_mode+0))
-#define EDID_INFO   (*(struct edid_info *)(real_mode+0x440))
+#define RM_SCREEN_INFO (*(struct screen_info *)(real_mode+0))
 
 extern char input_data[];
 extern int input_len;
@@ -174,8 +173,8 @@ static void putstr(const char *s)
 	int x,y,pos;
 	char c;
 
-	x = SCREEN_INFO.orig_x;
-	y = SCREEN_INFO.orig_y;
+	x = RM_SCREEN_INFO.orig_x;
+	y = RM_SCREEN_INFO.orig_y;
 
 	while ( ( c = *s++ ) != '\0' ) {
 		if ( c == '\n' ) {
@@ -196,8 +195,8 @@ static void putstr(const char *s)
 		}
 	}
 
-	SCREEN_INFO.orig_x = x;
-	SCREEN_INFO.orig_y = y;
+	RM_SCREEN_INFO.orig_x = x;
+	RM_SCREEN_INFO.orig_y = y;
 
 	pos = (x + cols * y) * 2;	/* Update cursor position */
 	outb_p(14, vidport);
@@ -306,9 +305,9 @@ struct {
 static void setup_normal_output_buffer(void)
 {
 #ifdef STANDARD_MEMORY_BIOS_CALL
-	if (EXT_MEM_K < 1024) error("Less than 2MB of memory");
+	if (RM_EXT_MEM_K < 1024) error("Less than 2MB of memory");
 #else
-	if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < 1024) error("Less than 2MB of memory");
+	if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) < 1024) error("Less than 2MB of memory");
 #endif
 	output_data = (char *)0x100000; /* Points to 1M */
 	free_mem_end_ptr = (long)real_mode;
@@ -323,9 +322,11 @@ static void setup_output_buffer_if_we_ru
 {
 	high_buffer_start = (uch *)(((ulg)&end) + HEAP_SIZE);
 #ifdef STANDARD_MEMORY_BIOS_CALL
-	if (EXT_MEM_K < (3*1024)) error("Less than 4MB of memory");
+	if (RM_EXT_MEM_K < (3*1024)) error("Less than 4MB of memory");
 #else
-	if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < (3*1024)) error("Less than 4MB of memory");
+	if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) <
+			(3*1024))
+		error("Less than 4MB of memory");
 #endif	
 	mv->low_buffer_start = output_data = (char *)LOW_BUFFER_START;
 	low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX
@@ -358,7 +359,7 @@ asmlinkage int decompress_kernel(struct 
 {
 	real_mode = rmode;
 
-	if (SCREEN_INFO.orig_video_mode == 7) {
+	if (RM_SCREEN_INFO.orig_video_mode == 7) {
 		vidmem = (char *) 0xb0000;
 		vidport = 0x3b4;
 	} else {
@@ -366,8 +367,8 @@ asmlinkage int decompress_kernel(struct 
 		vidport = 0x3d4;
 	}
 
-	lines = SCREEN_INFO.orig_video_lines;
-	cols = SCREEN_INFO.orig_video_cols;
+	lines = RM_SCREEN_INFO.orig_video_lines;
+	cols = RM_SCREEN_INFO.orig_video_cols;
 
 	if (free_mem_ptr < 0x100000) setup_normal_output_buffer();
 	else setup_output_buffer_if_we_run_high(mv);
diff -puN arch/i386/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/i386/kernel/setup.c
--- 25/arch/i386/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.283782696 -0700
+++ 25-akpm/arch/i386/kernel/setup.c	2004-05-25 22:10:40.433759896 -0700
@@ -129,7 +129,6 @@ unsigned long saved_videomode;
 #define RAMDISK_LOAD_FLAG		0x4000	
 
 static char command_line[COMMAND_LINE_SIZE];
-       char saved_command_line[COMMAND_LINE_SIZE];
 
 unsigned char __initdata boot_params[PARAM_SIZE];
 
diff -puN arch/ia64/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/ia64/kernel/setup.c
--- 25/arch/ia64/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.284782544 -0700
+++ 25-akpm/arch/ia64/kernel/setup.c	2004-05-25 22:10:40.434759744 -0700
@@ -89,10 +89,6 @@ unsigned char aux_device_present = 0xaa;
 unsigned long ia64_max_iommu_merge_mask = ~0UL;
 EXPORT_SYMBOL(ia64_max_iommu_merge_mask);
 
-#define COMMAND_LINE_SIZE	512
-
-char saved_command_line[COMMAND_LINE_SIZE]; /* used in proc filesystem */
-
 /*
  * We use a special marker for the end of memory and it uses the extra (+1) slot
  */
diff -puN arch/m68k/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/m68k/kernel/setup.c
--- 25/arch/m68k/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.286782240 -0700
+++ 25-akpm/arch/m68k/kernel/setup.c	2004-05-25 22:10:40.435759592 -0700
@@ -62,7 +62,6 @@ struct mem_info m68k_memory[NUM_MEMINFO]
 static struct mem_info m68k_ramdisk;
 
 static char m68k_command_line[CL_SIZE];
-char saved_command_line[CL_SIZE];
 
 char m68k_debug_device[6] = "";
 
diff -puN arch/m68knommu/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/m68knommu/kernel/setup.c
--- 25/arch/m68knommu/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.287782088 -0700
+++ 25-akpm/arch/m68knommu/kernel/setup.c	2004-05-25 22:10:40.435759592 -0700
@@ -31,6 +31,7 @@
 #include <linux/bootmem.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
+#include <linux/init.h>
 
 #include <asm/setup.h>
 #include <asm/irq.h>
@@ -44,8 +45,7 @@ unsigned long rom_length;
 unsigned long memory_start;
 unsigned long memory_end;
 
-char command_line[512];
-char saved_command_line[512];
+char command_line[COMMAND_LINE_SIZE];
 
 /* setup some dummy routines */
 static void dummy_waitbut(void)
diff -puN arch/m68k/q40/config.c~Move-saved_command_line-to-init-mainc arch/m68k/q40/config.c
--- 25/arch/m68k/q40/config.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.289781784 -0700
+++ 25-akpm/arch/m68k/q40/config.c	2004-05-25 22:10:40.436759440 -0700
@@ -64,7 +64,6 @@ void q40_set_vectors (void);
 
 extern void q40_mksound(unsigned int /*freq*/, unsigned int /*ticks*/ );
 
-extern char *saved_command_line;
 extern char m68k_debug_device[];
 static void q40_mem_console_write(struct console *co, const char *b,
 				    unsigned int count);
diff -puN arch/mips/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/mips/kernel/setup.c
--- 25/arch/mips/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.290781632 -0700
+++ 25-akpm/arch/mips/kernel/setup.c	2004-05-25 22:10:40.436759440 -0700
@@ -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;
 
 /*
diff -puN arch/parisc/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/parisc/kernel/setup.c
--- 25/arch/parisc/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.291781480 -0700
+++ 25-akpm/arch/parisc/kernel/setup.c	2004-05-25 22:10:40.436759440 -0700
@@ -45,8 +45,6 @@
 #include <asm/pdc_chassis.h>
 #include <asm/io.h>
 
-#define COMMAND_LINE_SIZE 1024
-char	saved_command_line[COMMAND_LINE_SIZE];
 char	command_line[COMMAND_LINE_SIZE];
 
 /* Intended for ccio/sba/cpu statistics under /proc/bus/{runway|gsc} */
diff -puN arch/ppc64/kernel/head.S~Move-saved_command_line-to-init-mainc arch/ppc64/kernel/head.S
--- 25/arch/ppc64/kernel/head.S~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.293781176 -0700
+++ 25-akpm/arch/ppc64/kernel/head.S	2004-05-25 22:10:40.443758376 -0700
@@ -35,6 +35,7 @@
 #include <asm/offsets.h>
 #include <asm/bug.h>
 #include <asm/cputable.h>
+#include <asm/setup.h>
 
 #ifdef CONFIG_PPC_ISERIES
 #define DO_SOFT_DISABLE
@@ -2277,4 +2278,4 @@ stab_array:
  */
 	.globl	cmd_line
 cmd_line:
-	.space	512	/* COMMAND_LINE_SIZE */
+	.space	COMMAND_LINE_SIZE
diff -puN arch/ppc64/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/ppc64/kernel/setup.c
--- 25/arch/ppc64/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.294781024 -0700
+++ 25-akpm/arch/ppc64/kernel/setup.c	2004-05-25 22:10:40.444758224 -0700
@@ -82,7 +82,6 @@ unsigned long decr_overclock_proc0_set =
 
 int powersave_nap;
 
-char saved_command_line[COMMAND_LINE_SIZE];
 unsigned char aux_device_present;
 
 void parse_cmd_line(unsigned long r3, unsigned long r4, unsigned long r5,
diff -puN arch/ppc/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/ppc/kernel/setup.c
--- 25/arch/ppc/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.295780872 -0700
+++ 25-akpm/arch/ppc/kernel/setup.c	2004-05-25 22:10:40.444758224 -0700
@@ -54,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;
diff -puN arch/ppc/platforms/lopec_setup.c~Move-saved_command_line-to-init-mainc arch/ppc/platforms/lopec_setup.c
--- 25/arch/ppc/platforms/lopec_setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.296780720 -0700
+++ 25-akpm/arch/ppc/platforms/lopec_setup.c	2004-05-25 22:10:40.445758072 -0700
@@ -33,7 +33,6 @@
 #include <asm/hw_irq.h>
 #include <asm/prep_nvram.h>
 
-extern char saved_command_line[];
 extern void lopec_find_bridges(void);
 
 /*
diff -puN arch/ppc/platforms/pmac_setup.c~Move-saved_command_line-to-init-mainc arch/ppc/platforms/pmac_setup.c
--- 25/arch/ppc/platforms/pmac_setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.298780416 -0700
+++ 25-akpm/arch/ppc/platforms/pmac_setup.c	2004-05-25 22:10:40.446757920 -0700
@@ -103,8 +103,6 @@ int has_l2cache = 0;
 
 static int current_root_goodness = -1;
 
-extern char saved_command_line[];
-
 extern int pmac_newworld;
 
 #define DEFAULT_ROOT_DEVICE Root_SDA1	/* sda1 - slightly silly choice */
diff -puN arch/ppc/platforms/pplus.c~Move-saved_command_line-to-init-mainc arch/ppc/platforms/pplus.c
--- 25/arch/ppc/platforms/pplus.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.299780264 -0700
+++ 25-akpm/arch/ppc/platforms/pplus.c	2004-05-25 22:10:40.446757920 -0700
@@ -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);
 
diff -puN arch/ppc/platforms/prep_setup.c~Move-saved_command_line-to-init-mainc arch/ppc/platforms/prep_setup.c
--- 25/arch/ppc/platforms/prep_setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.300780112 -0700
+++ 25-akpm/arch/ppc/platforms/prep_setup.c	2004-05-25 22:10:40.447757768 -0700
@@ -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;
 
diff -puN arch/s390/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/s390/kernel/setup.c
--- 25/arch/s390/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.302779808 -0700
+++ 25-akpm/arch/s390/kernel/setup.c	2004-05-25 22:10:40.448757616 -0700
@@ -74,7 +74,6 @@ extern int _text,_etext, _edata, _end;
 #include <asm/setup.h>
 
 static char command_line[COMMAND_LINE_SIZE] = { 0, };
-       char saved_command_line[COMMAND_LINE_SIZE];
 
 static struct resource code_resource = { "Kernel code", 0x100000, 0 };
 static struct resource data_resource = { "Kernel data", 0, 0 };
diff -puN arch/sh/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/sh/kernel/setup.c
--- 25/arch/sh/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.303779656 -0700
+++ 25-akpm/arch/sh/kernel/setup.c	2004-05-25 22:10:40.449757464 -0700
@@ -85,14 +85,12 @@ static struct sh_machine_vector* __init 
 #define INITRD_SIZE (*(unsigned long *) (PARAM+0x014))
 /* ... */
 #define COMMAND_LINE ((char *) (PARAM+0x100))
-#define COMMAND_LINE_SIZE 256
 
 #define RAMDISK_IMAGE_START_MASK  	0x07FF
 #define RAMDISK_PROMPT_FLAG		0x8000
 #define RAMDISK_LOAD_FLAG		0x4000	
 
 static char command_line[COMMAND_LINE_SIZE] = { 0, };
-       char saved_command_line[COMMAND_LINE_SIZE];
 
 struct resource standard_io_resources[] = {
 	{ "dma1", 0x00, 0x1f },
diff -puN arch/sparc64/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/sparc64/kernel/setup.c
--- 25/arch/sparc64/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.304779504 -0700
+++ 25-akpm/arch/sparc64/kernel/setup.c	2004-05-25 22:10:40.449757464 -0700
@@ -451,8 +451,7 @@ extern unsigned short ram_flags;
 
 extern int root_mountflags;
 
-char saved_command_line[256];
-char reboot_command[256];
+char reboot_command[COMMAND_LINE_SIZE];
 
 static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
 
diff -puN arch/sparc64/kernel/sparc64_ksyms.c~Move-saved_command_line-to-init-mainc arch/sparc64/kernel/sparc64_ksyms.c
--- 25/arch/sparc64/kernel/sparc64_ksyms.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.305779352 -0700
+++ 25-akpm/arch/sparc64/kernel/sparc64_ksyms.c	2004-05-25 22:10:40.450757312 -0700
@@ -24,6 +24,7 @@
 #include <linux/socket.h>
 #include <linux/syscalls.h>
 #include <linux/percpu.h>
+#include <linux/init.h>
 #include <net/compat.h>
 
 #include <asm/oplib.h>
@@ -76,7 +77,6 @@ extern int __memcmp(const void *, const 
 extern int __strncmp(const char *, const char *, __kernel_size_t);
 extern __kernel_size_t __strlen(const char *);
 extern __kernel_size_t strlen(const char *);
-extern char saved_command_line[];
 extern void linux_sparc_syscall(void);
 extern void rtrap(void);
 extern void show_regs(struct pt_regs *);
diff -puN arch/sparc/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/sparc/kernel/setup.c
--- 25/arch/sparc/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.307779048 -0700
+++ 25-akpm/arch/sparc/kernel/setup.c	2004-05-25 22:10:40.450757312 -0700
@@ -244,8 +244,7 @@ extern unsigned short ram_flags;
 
 extern int root_mountflags;
 
-char saved_command_line[256];
-char reboot_command[256];
+char reboot_command[COMMAND_LINE_SIZE];
 enum sparc_cpu sparc_cpu_model;
 
 struct tt_entry *sparc_ttable;
diff -puN arch/sparc/kernel/sparc_ksyms.c~Move-saved_command_line-to-init-mainc arch/sparc/kernel/sparc_ksyms.c
--- 25/arch/sparc/kernel/sparc_ksyms.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.308778896 -0700
+++ 25-akpm/arch/sparc/kernel/sparc_ksyms.c	2004-05-25 22:10:40.451757160 -0700
@@ -11,6 +11,7 @@
 
 #include <linux/config.h>
 #include <linux/module.h>
+#include <linux/init.h>
 #include <linux/smp.h>
 #include <linux/types.h>
 #include <linux/string.h>
@@ -74,7 +75,6 @@ extern void *__memscan_zero(void *, size
 extern void *__memscan_generic(void *, int, size_t);
 extern int __memcmp(const void *, const void *, __kernel_size_t);
 extern int __strncmp(const char *, const char *, __kernel_size_t);
-extern char saved_command_line[];
 
 extern void bcopy (const char *, char *, int);
 extern int __ashrdi3(int, int);
diff -puN arch/um/kernel/user_util.c~Move-saved_command_line-to-init-mainc arch/um/kernel/user_util.c
--- 25/arch/um/kernel/user_util.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.309778744 -0700
+++ 25-akpm/arch/um/kernel/user_util.c	2004-05-25 22:10:40.451757160 -0700
@@ -34,7 +34,6 @@
 #define COMMAND_LINE_SIZE _POSIX_ARG_MAX
 
 /* Changed in linux_main and setup_arch, which run before SMP is started */
-char saved_command_line[COMMAND_LINE_SIZE] = { 0 };
 char command_line[COMMAND_LINE_SIZE] = { 0 };
 
 void add_arg(char *cmd_line, char *arg)
diff -puN arch/v850/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/v850/kernel/setup.c
--- 25/arch/v850/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.310778592 -0700
+++ 25-akpm/arch/v850/kernel/setup.c	2004-05-25 22:10:40.452757008 -0700
@@ -20,6 +20,7 @@
 #include <linux/major.h>
 #include <linux/root_dev.h>
 #include <linux/mtd/mtd.h>
+#include <linux/init.h>
 
 #include <asm/irq.h>
 
@@ -40,8 +41,7 @@ extern char _root_fs_image_start __attri
 extern char _root_fs_image_end __attribute__ ((__weak__));
 
 
-char command_line[512];
-char saved_command_line[512];
+char command_line[COMMAND_LINE_SIZE];
 
 /* Memory not used by the kernel.  */
 static unsigned long total_ram_pages;
diff -puN arch/x86_64/kernel/setup.c~Move-saved_command_line-to-init-mainc arch/x86_64/kernel/setup.c
--- 25/arch/x86_64/kernel/setup.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.312778288 -0700
+++ 25-akpm/arch/x86_64/kernel/setup.c	2004-05-25 22:10:40.452757008 -0700
@@ -100,7 +100,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 | IORESOURCE_IO },
diff -puN drivers/sbus/char/openprom.c~Move-saved_command_line-to-init-mainc drivers/sbus/char/openprom.c
--- 25/drivers/sbus/char/openprom.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.313778136 -0700
+++ 25-akpm/drivers/sbus/char/openprom.c	2004-05-25 22:10:40.463755336 -0700
@@ -149,7 +149,6 @@ static int openprom_sunos_ioctl(struct i
 	char buffer[OPROMMAXPARAM+1], *buf;
 	struct openpromio *opp;
 	int bufsize, len, error = 0;
-	extern char saved_command_line[];
 	static int cnt;
 
 	if (cmd == OPROMSETOPT)
diff -puN fs/proc/kcore.c~Move-saved_command_line-to-init-mainc fs/proc/kcore.c
--- 25/fs/proc/kcore.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.314777984 -0700
+++ 25-akpm/fs/proc/kcore.c	2004-05-25 22:10:40.475753512 -0700
@@ -18,6 +18,7 @@
 #include <linux/elfcore.h>
 #include <linux/vmalloc.h>
 #include <linux/highmem.h>
+#include <linux/init.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
@@ -84,8 +85,6 @@ kclist_del(void *addr)
 	return 0;
 }
 
-extern char saved_command_line[];
-
 static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
 {
 	size_t try, size;
diff -puN fs/proc/proc_misc.c~Move-saved_command_line-to-init-mainc fs/proc/proc_misc.c
--- 25/fs/proc/proc_misc.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.315777832 -0700
+++ 25-akpm/fs/proc/proc_misc.c	2004-05-25 22:10:40.475753512 -0700
@@ -525,7 +525,6 @@ static int filesystems_read_proc(char *p
 static int cmdline_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
 {
-	extern char saved_command_line[];
 	int len;
 
 	len = sprintf(page, "%s\n", saved_command_line);
diff -puN /dev/null include/asm-alpha/setup.h
--- /dev/null	2003-09-15 06:40:47.000000000 -0700
+++ 25-akpm/include/asm-alpha/setup.h	2004-05-25 22:10:40.476753360 -0700
@@ -0,0 +1,6 @@
+#ifndef __ALPHA_SETUP_H
+#define __ALPHA_SETUP_H
+
+#define COMMAND_LINE_SIZE	256
+
+#endif
diff -puN include/asm-alpha/system.h~Move-saved_command_line-to-init-mainc include/asm-alpha/system.h
--- 25/include/asm-alpha/system.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.329775704 -0700
+++ 25-akpm/include/asm-alpha/system.h	2004-05-25 22:10:40.476753360 -0700
@@ -43,7 +43,6 @@
  */
 #define PARAM			ZERO_PGE
 #define COMMAND_LINE		((char*)(PARAM + 0x0000))
-#define COMMAND_LINE_SIZE	256
 #define INITRD_START		(*(unsigned long *) (PARAM+0x100))
 #define INITRD_SIZE		(*(unsigned long *) (PARAM+0x108))
 
diff -puN include/asm-cris/setup.h~Move-saved_command_line-to-init-mainc include/asm-cris/setup.h
--- 25/include/asm-cris/setup.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.339774184 -0700
+++ 25-akpm/include/asm-cris/setup.h	2004-05-25 22:10:40.476753360 -0700
@@ -1,3 +1,6 @@
 #ifndef _CRIS_SETUP_H
 #define _CRIS_SETUP_H
+
+#define COMMAND_LINE_SIZE	256
+
 #endif
diff -puN include/asm-h8300/setup.h~Move-saved_command_line-to-init-mainc include/asm-h8300/setup.h
--- 25/include/asm-h8300/setup.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.352772208 -0700
+++ 25-akpm/include/asm-h8300/setup.h	2004-05-25 22:10:40.477753208 -0700
@@ -1 +1,6 @@
-/* Nothing do */
+#ifndef __H8300_SETUP_H
+#define __H8300_SETUP_H
+
+#define COMMAND_LINE_SIZE	512
+
+#endif
diff -puN include/asm-i386/param.h~Move-saved_command_line-to-init-mainc include/asm-i386/param.h
--- 25/include/asm-i386/param.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.364770384 -0700
+++ 25-akpm/include/asm-i386/param.h	2004-05-25 22:10:40.477753208 -0700
@@ -18,5 +18,6 @@
 #endif
 
 #define MAXHOSTNAMELEN	64	/* max length of hostname */
+#define COMMAND_LINE_SIZE 256
 
 #endif
diff -puN /dev/null include/asm-ia64/setup.h
--- /dev/null	2003-09-15 06:40:47.000000000 -0700
+++ 25-akpm/include/asm-ia64/setup.h	2004-05-25 22:10:40.477753208 -0700
@@ -0,0 +1,6 @@
+#ifndef __IA64_SETUP_H
+#define __IA64_SETUP_H
+
+#define COMMAND_LINE_SIZE	512
+
+#endif
diff -puN include/asm-m68knommu/setup.h~Move-saved_command_line-to-init-mainc include/asm-m68knommu/setup.h
--- 25/include/asm-m68knommu/setup.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.379768104 -0700
+++ 25-akpm/include/asm-m68knommu/setup.h	2004-05-25 22:10:40.477753208 -0700
@@ -1 +1,5 @@
 #include <asm-m68k/setup.h>
+
+/* We have a bigger command line buffer. */
+#undef COMMAND_LINE_SIZE
+#define COMMAND_LINE_SIZE	512
diff -puN include/asm-m68k/setup.h~Move-saved_command_line-to-init-mainc include/asm-m68k/setup.h
--- 25/include/asm-m68k/setup.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.393765976 -0700
+++ 25-akpm/include/asm-m68k/setup.h	2004-05-25 22:10:40.478753056 -0700
@@ -357,6 +357,7 @@ extern int m68k_is040or060;
 
 #define NUM_MEMINFO	4
 #define CL_SIZE		256
+#define COMMAND_LINE_SIZE	CL_SIZE
 
 #ifndef __ASSEMBLY__
 extern int m68k_num_memory;		/* # of memory blocks found (and used) */
diff -puN include/asm-mips/bootinfo.h~Move-saved_command_line-to-init-mainc include/asm-mips/bootinfo.h
--- 25/include/asm-mips/bootinfo.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.409763544 -0700
+++ 25-akpm/include/asm-mips/bootinfo.h	2004-05-25 22:10:40.478753056 -0700
@@ -12,6 +12,7 @@
 #define _ASM_BOOTINFO_H
 
 #include <linux/types.h>
+#include <asm/setup.h>
 
 /*
  * The MACH_GROUP_ IDs are the equivalent to PCI vendor IDs; the remaining
@@ -209,7 +210,7 @@
 #define MACH_GROUP_TITAN       22	/* PMC-Sierra Titan		*/
 #define  MACH_TITAN_YOSEMITE	1	/* PMC-Sierra Yosemite		*/
 
-#define CL_SIZE			(256)
+#define CL_SIZE			COMMAND_LINE_SIZE
 
 const char *get_system_type(void);
 
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-05-25 22:10:40.479752904 -0700
@@ -0,0 +1,8 @@
+#ifdef __KERNEL__
+#ifndef _MIPS_SETUP_H
+#define _MIPS_SETUP_H
+
+#define COMMAND_LINE_SIZE	256
+
+#endif /* __SETUP_H */
+#endif /* __KERNEL__ */
diff -puN include/asm-parisc/setup.h~Move-saved_command_line-to-init-mainc include/asm-parisc/setup.h
--- 25/include/asm-parisc/setup.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.410763392 -0700
+++ 25-akpm/include/asm-parisc/setup.h	2004-05-25 22:10:40.479752904 -0700
@@ -1,10 +1,6 @@
-/*
- *	Just a place holder. We don't want to have to test x86 before
- *	we include stuff
- */
+#ifndef _PARISC_SETUP_H
+#define _PARISC_SETUP_H
 
-#ifndef _i386_SETUP_H
-#define _i386_SETUP_H
+#define COMMAND_LINE_SIZE	1024
 
-
-#endif /* _i386_SETUP_H */
+#endif /* _PARISC_SETUP_H */
diff -puN include/asm-ppc64/machdep.h~Move-saved_command_line-to-init-mainc include/asm-ppc64/machdep.h
--- 25/include/asm-ppc64/machdep.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.411763240 -0700
+++ 25-akpm/include/asm-ppc64/machdep.h	2004-05-25 22:10:40.479752904 -0700
@@ -11,6 +11,7 @@
 
 #include <linux/config.h>
 #include <linux/seq_file.h>
+#include <linux/init.h>
 #include <linux/dma-mapping.h>
 
 struct pt_regs;
@@ -112,9 +113,7 @@ struct machdep_calls {
 };
 
 extern struct machdep_calls ppc_md;
-#define COMMAND_LINE_SIZE 512
 extern char cmd_line[COMMAND_LINE_SIZE];
-extern char saved_command_line[COMMAND_LINE_SIZE];
 
 /* Functions to produce codes on the leds.
  * The SRC code should be unique for the message category and should
diff -puN include/asm-ppc64/setup.h~Move-saved_command_line-to-init-mainc include/asm-ppc64/setup.h
--- 25/include/asm-ppc64/setup.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.413762936 -0700
+++ 25-akpm/include/asm-ppc64/setup.h	2004-05-25 22:10:40.480752752 -0700
@@ -1,6 +1,6 @@
 #ifndef _PPC_SETUP_H
 #define _PPC_SETUP_H
 
-/* This is a place holder include */
+#define COMMAND_LINE_SIZE 512
 
 #endif /* _PPC_SETUP_H */
diff -puN include/asm-ppc/machdep.h~Move-saved_command_line-to-init-mainc include/asm-ppc/machdep.h
--- 25/include/asm-ppc/machdep.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.414762784 -0700
+++ 25-akpm/include/asm-ppc/machdep.h	2004-05-25 22:10:40.480752752 -0700
@@ -106,7 +106,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~Move-saved_command_line-to-init-mainc include/asm-ppc/setup.h
--- 25/include/asm-ppc/setup.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.415762632 -0700
+++ 25-akpm/include/asm-ppc/setup.h	2004-05-25 22:10:40.480752752 -0700
@@ -6,6 +6,9 @@
 #define m68k_memory memory
 
 #include <asm-m68k/setup.h>
+/* We have a bigger command line buffer. */
+#undef COMMAND_LINE_SIZE
+#define COMMAND_LINE_SIZE	512
 
 #endif /* _PPC_SETUP_H */
 #endif /* __KERNEL__ */
diff -puN /dev/null include/asm-sh/setup.h
--- /dev/null	2003-09-15 06:40:47.000000000 -0700
+++ 25-akpm/include/asm-sh/setup.h	2004-05-25 22:10:40.480752752 -0700
@@ -0,0 +1,8 @@
+#ifdef __KERNEL__
+#ifndef _SH_SETUP_H
+#define _SH_SETUP_H
+
+#define COMMAND_LINE_SIZE 256
+
+#endif /* _SH_SETUP_H */
+#endif /* __KERNEL__ */
diff -puN include/asm-sparc64/setup.h~Move-saved_command_line-to-init-mainc include/asm-sparc64/setup.h
--- 25/include/asm-sparc64/setup.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.417762328 -0700
+++ 25-akpm/include/asm-sparc64/setup.h	2004-05-25 22:10:40.481752600 -0700
@@ -5,5 +5,6 @@
 #ifndef _SPARC64_SETUP_H
 #define _SPARC64_SETUP_H
 
+#define COMMAND_LINE_SIZE	256
 
 #endif /* _SPARC64_SETUP_H */
diff -puN include/asm-sparc/setup.h~Move-saved_command_line-to-init-mainc include/asm-sparc/setup.h
--- 25/include/asm-sparc/setup.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.418762176 -0700
+++ 25-akpm/include/asm-sparc/setup.h	2004-05-25 22:10:40.481752600 -0700
@@ -5,5 +5,6 @@
 #ifndef _SPARC_SETUP_H
 #define _SPARC_SETUP_H
 
+#define COMMAND_LINE_SIZE	256
 
 #endif /* _SPARC_SETUP_H */
diff -puN /dev/null include/asm-um/setup.h
--- /dev/null	2003-09-15 06:40:47.000000000 -0700
+++ 25-akpm/include/asm-um/setup.h	2004-05-25 22:10:40.481752600 -0700
@@ -0,0 +1,6 @@
+#ifndef SETUP_H_INCLUDED
+#define SETUP_H_INCLUDED
+
+#define COMMAND_LINE_SIZE 512
+
+#endif		/* SETUP_H_INCLUDED */
diff -puN /dev/null include/asm-v850/setup.h
--- /dev/null	2003-09-15 06:40:47.000000000 -0700
+++ 25-akpm/include/asm-v850/setup.h	2004-05-25 22:10:40.481752600 -0700
@@ -0,0 +1,6 @@
+#ifndef _V850_SETUP_H
+#define _V850_SETUP_H
+
+#define COMMAND_LINE_SIZE	512
+
+#endif /* __SETUP_H */
diff -puN include/asm-x86_64/bootsetup.h~Move-saved_command_line-to-init-mainc include/asm-x86_64/bootsetup.h
--- 25/include/asm-x86_64/bootsetup.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.420761872 -0700
+++ 25-akpm/include/asm-x86_64/bootsetup.h	2004-05-25 22:10:40.482752448 -0700
@@ -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~Move-saved_command_line-to-init-mainc include/asm-x86_64/setup.h
--- 25/include/asm-x86_64/setup.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.421761720 -0700
+++ 25-akpm/include/asm-x86_64/setup.h	2004-05-25 22:10:40.482752448 -0700
@@ -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 include/linux/init.h~Move-saved_command_line-to-init-mainc include/linux/init.h
--- 25/include/linux/init.h~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.422761568 -0700
+++ 25-akpm/include/linux/init.h	2004-05-25 22:10:40.482752448 -0700
@@ -3,6 +3,7 @@
 
 #include <linux/config.h>
 #include <linux/compiler.h>
+#include <asm/setup.h>
 
 /* These macros are used to mark some functions or 
  * initialized data (doesn't apply to uninitialized data)
@@ -66,6 +67,9 @@ typedef void (*exitcall_t)(void);
 
 extern initcall_t __con_initcall_start, __con_initcall_end;
 extern initcall_t __security_initcall_start, __security_initcall_end;
+
+/* Defined in init/main.c */
+extern char saved_command_line[COMMAND_LINE_SIZE];
 #endif
   
 #ifndef MODULE
@@ -107,25 +111,33 @@ extern initcall_t __security_initcall_st
 struct obs_kernel_param {
 	const char *str;
 	int (*setup_func)(char *);
+	int early;
 };
 
-/* OBSOLETE: see moduleparam.h for the right way. */
-#define __setup_param(str, unique_id, fn)			\
+/* Only for really core code.  See moduleparam.h for the normal way. */
+#define __setup_param(str, unique_id, fn, early)			\
 	static char __setup_str_##unique_id[] __initdata = str;	\
 	static struct obs_kernel_param __setup_##unique_id	\
 		 __attribute_used__				\
 		 __attribute__((__section__(".init.setup")))	\
-		= { __setup_str_##unique_id, fn }
+		= { __setup_str_##unique_id, fn, early }
 
 #define __setup_null_param(str, unique_id)			\
-	__setup_param(str, unique_id, NULL)
+	__setup_param(str, unique_id, NULL, 0)
 
 #define __setup(str, fn)					\
-	__setup_param(str, fn, fn)
+	__setup_param(str, fn, fn, 0)
 
 #define __obsolete_setup(str)					\
 	__setup_null_param(str, __LINE__)
 
+/* NOTE: fn is as per module_param, not __setup!  Emits warning if fn
+ * returns non-zero. */
+#define early_param(str, fn)					\
+	__setup_param(str, fn, fn, 1)
+
+/* Relies on saved_command_line being set */
+void __init parse_early_param(void);
 #endif /* __ASSEMBLY__ */
 
 /**
diff -puN init/main.c~Move-saved_command_line-to-init-mainc init/main.c
--- 25/init/main.c~Move-saved_command_line-to-init-mainc	2004-05-25 22:10:40.423761416 -0700
+++ 25-akpm/init/main.c	2004-05-25 22:10:40.483752296 -0700
@@ -110,6 +110,9 @@ extern void time_init(void);
 void (*late_time_init)(void);
 extern void softirq_init(void);
 
+/* Untouched command line (eg. for /proc) saved by arch-specific code. */
+char saved_command_line[COMMAND_LINE_SIZE];
+
 static char *execute_command;
 
 /* Setup configured maximum number of CPUs to activate */
@@ -160,6 +163,9 @@ static int __init obsolete_checksetup(ch
 	do {
 		int n = strlen(p->str);
 		if (len <= n && !strncmp(line, p->str, n)) {
+			/* Already done in parse_early_param? */
+			if (p->early)
+				return 1;
 			if (!p->setup_func) {
 				printk(KERN_WARNING "Parameter %s is obsolete, ignored\n", p->str);
 				return 1;
@@ -393,6 +399,38 @@ static void noinline rest_init(void)
  	cpu_idle();
 } 
 
+/* Check for early params. */
+static int __init do_early_param(char *param, char *val)
+{
+	struct obs_kernel_param *p;
+	extern struct obs_kernel_param __setup_start, __setup_end;
+
+	for (p = &__setup_start; p < &__setup_end; p++) {
+		if (p->early && strcmp(param, p->str) == 0) {
+			if (p->setup_func(val) != 0)
+				printk(KERN_WARNING
+				       "Malformed early option '%s'\n", param);
+		}
+	}
+	/* We accept everything at this stage. */
+	return 0;
+}
+
+/* Arch code calls this early on, or if not, just before other parsing. */
+void __init parse_early_param(void)
+{
+	static __initdata int done = 0;
+	static __initdata char tmp_cmdline[COMMAND_LINE_SIZE];
+
+	if (done)
+		return;
+
+	/* All fall through to do_early_param. */
+	strlcpy(tmp_cmdline, saved_command_line, COMMAND_LINE_SIZE);
+	parse_args("early options", tmp_cmdline, NULL, 0, do_early_param);
+	done = 1;
+}
+
 /*
  *	Activate the first processor.
  */
@@ -400,7 +438,6 @@ static void noinline rest_init(void)
 asmlinkage void __init start_kernel(void)
 {
 	char * command_line;
-	extern char saved_command_line[];
 	extern struct kernel_param __start___param[], __stop___param[];
 /*
  * Interrupts are still disabled. Do necessary setups, then
@@ -429,6 +466,7 @@ asmlinkage void __init start_kernel(void
 	page_alloc_init();
 	trap_init();
 	printk("Kernel command line: %s\n", saved_command_line);
+	parse_early_param();
 	parse_args("Booting kernel", command_line, __start___param,
 		   __stop___param - __start___param,
 		   &unknown_bootoption);
@@ -674,3 +712,10 @@ static int init(void * unused)
 
 	panic("No init found.  Try passing init= option to kernel.");
 }
+
+static int early_param_test(char *rest)
+{
+	printk("early_parm_test: %s\n", rest ?: "(null)");
+	return rest ? 0 : -EINVAL;
+}
+early_param("testsetup", early_param_test);
_
