[PATCH] [ppc64] Clean up kernel command line code

Anton Blanchard anton at samba.org
Fri Sep 10 22:12:38 EST 2004


Clean up some of our command line code:

- We were copying the command line out of the device tree twice, but the
  first time we forgot to add CONFIG_CMDLINE. Fix this and remove the
  second copy.
- The command line birec code ran after we had done some command line 
  parsing in prom.c. This had the opportunity to really confuse the
  user, with some options being parsed out of the device tree and the
  other out of birecs. Luckily we could find no user of the command
  line birecs, so remove them.
- remove duplicate printing of kernel command line;
- clean up iseries inits and create an iSeries_parse_cmdline.

Signed-off-by: Anton Blanchard <anton at samba.org>

diff --exclude-from=/home/anton/dontdiff -urN foobar2/arch/ppc64/kernel/chrp_setup.c foobar3/arch/ppc64/kernel/chrp_setup.c
--- foobar2/arch/ppc64/kernel/chrp_setup.c	2004-09-10 19:33:10.910718416 +1000
+++ foobar3/arch/ppc64/kernel/chrp_setup.c	2004-09-10 19:29:44.431528121 +1000
@@ -140,8 +140,6 @@
 		ROOT_DEV = Root_SDA2;
 	}
 
-	printk("Boot arguments: %s\n", cmd_line);
-
 	fwnmi_init();
 
 #ifndef CONFIG_PPC_ISERIES
diff --exclude-from=/home/anton/dontdiff -urN foobar2/arch/ppc64/kernel/iSeries_setup.c foobar3/arch/ppc64/kernel/iSeries_setup.c
--- foobar2/arch/ppc64/kernel/iSeries_setup.c	2004-09-10 19:33:10.918717801 +1000
+++ foobar3/arch/ppc64/kernel/iSeries_setup.c	2004-09-10 19:30:32.042107395 +1000
@@ -333,32 +333,31 @@
 #endif
 	if (itLpNaca.xPirEnvironMode == 0) 
 		piranha_simulator = 1;
+
+	/* Associate Lp Event Queue 0 with processor 0 */
+	HvCallEvent_setLpEventQueueInterruptProc(0, 0);
+
+	mf_init();
+	mf_initialized = 1;
+	mb();
 }
 
-void __init iSeries_init(unsigned long r3, unsigned long r4, unsigned long r5, 
-	   unsigned long r6, unsigned long r7)
+void __init iSeries_parse_cmdline(void)
 {
 	char *p, *q;
 
-	/* Associate Lp Event Queue 0 with processor 0 */
-	HvCallEvent_setLpEventQueueInterruptProc(0, 0);
-
 	/* copy the command line parameter from the primary VSP  */
 	HvCallEvent_dmaToSp(cmd_line, 2 * 64* 1024, 256,
 			HvLpDma_Direction_RemoteToLocal);
 
 	p = cmd_line;
 	q = cmd_line + 255;
-	while( p < q ) {
+	while(p < q) {
 		if (!*p || *p == '\n')
 			break;
 		++p;
 	}
 	*p = 0;
-
-	mf_init();
-	mf_initialized = 1;
-	mb();
 }
 
 /*
diff --exclude-from=/home/anton/dontdiff -urN foobar2/arch/ppc64/kernel/prom.c foobar3/arch/ppc64/kernel/prom.c
--- foobar2/arch/ppc64/kernel/prom.c	2004-09-10 19:33:10.928717033 +1000
+++ foobar3/arch/ppc64/kernel/prom.c	2004-09-10 19:35:32.146053659 +1000
@@ -1707,6 +1707,9 @@
 	}
 
 	RELOC(cmd_line[0]) = 0;
+#ifdef CONFIG_CMDLINE
+	strlcpy(RELOC(cmd_line), CONFIG_CMDLINE, sizeof(cmd_line));
+#endif /* CONFIG_CMDLINE */
 	if ((long)_prom->chosen > 0) {
 		prom_getprop(_prom->chosen, "bootargs", p, sizeof(cmd_line));
 		if (p != NULL && p[0] != 0)
diff --exclude-from=/home/anton/dontdiff -urN foobar2/arch/ppc64/kernel/setup.c foobar3/arch/ppc64/kernel/setup.c
--- foobar2/arch/ppc64/kernel/setup.c	2004-09-10 19:33:10.934716571 +1000
+++ foobar3/arch/ppc64/kernel/setup.c	2004-09-10 19:32:10.785258973 +1000
@@ -68,7 +68,6 @@
 		       unsigned long r7);
 
 extern void fw_feature_init(void);
-extern void iSeries_init( void );
 extern void iSeries_init_early( void );
 extern void pSeries_init_early( void );
 extern void pSeriesLP_init_early(void);
@@ -77,6 +76,7 @@
 extern void pseries_secondary_smp_init(unsigned long); 
 extern int  idle_setup(void);
 extern void vpa_init(int cpu);
+extern void iSeries_parse_cmdline(void);
 
 unsigned long decr_overclock = 1;
 unsigned long decr_overclock_proc0 = 1;
@@ -87,10 +87,6 @@
 
 unsigned char aux_device_present;
 
-void parse_cmd_line(unsigned long r3, unsigned long r4, unsigned long r5,
-		    unsigned long r6, unsigned long r7);
-int parse_bootinfo(void);
-
 #ifdef CONFIG_MAGIC_SYSRQ
 unsigned long SYSRQ_KEY;
 #endif /* CONFIG_MAGIC_SYSRQ */
@@ -282,19 +278,16 @@
 	case PLATFORM_PSERIES:
 		fw_feature_init();
 		pSeries_init_early();
-		parse_bootinfo();
 		break;
 
 	case PLATFORM_PSERIES_LPAR:
 		fw_feature_init();
 		pSeriesLP_init_early();
-		parse_bootinfo();
 		break;
 #endif /* CONFIG_PPC_PSERIES */
 #ifdef CONFIG_PPC_PMAC
 	case PLATFORM_POWERMAC:
 		pmac_init_early();
-		parse_bootinfo();
 #endif /* CONFIG_PPC_PMAC */
 	}
 
@@ -334,6 +327,10 @@
 	}
 #endif /* CONFIG_PPC_PSERIES */
 
+#ifdef CONFIG_PPC_ISERIES
+	iSeries_parse_cmdline();
+#endif
+
 #ifdef CONFIG_SMP
 #ifndef CONFIG_PPC_ISERIES
 	/*
@@ -393,18 +390,6 @@
 
 	/* Select the correct idle loop for the platform. */
 	idle_setup();
-
-	switch (systemcfg->platform) {
-#ifdef CONFIG_PPC_ISERIES
-	case PLATFORM_ISERIES_LPAR:
-		iSeries_init();
-		break;
-#endif
-	default:
-		/* The following relies on the device tree being */
-		/* fully configured.                             */
-		parse_cmd_line(r3, r4, r5, r6, r7);
-	}
 }
 
 void machine_restart(char *cmd)
@@ -528,31 +513,6 @@
 	.show =	show_cpuinfo,
 };
 
-/*
- * Fetch the cmd_line from open firmware. 
- */
-void parse_cmd_line(unsigned long r3, unsigned long r4, unsigned long r5,
-		  unsigned long r6, unsigned long r7)
-{
-	cmd_line[0] = 0;
-
-#ifdef CONFIG_CMDLINE
-	strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line));
-#endif /* CONFIG_CMDLINE */
-
-#ifdef CONFIG_PPC_PSERIES
-	{
-	struct device_node *chosen;
-
-	chosen = of_find_node_by_name(NULL, "chosen");
-	if (chosen != NULL) {
-		char *p;
-		p = get_property(chosen, "bootargs", NULL);
-		if (p != NULL && p[0] != 0)
-			strlcpy(cmd_line, p, sizeof(cmd_line));
-		of_node_put(chosen);
-	}
-	}
 #endif
 
 	/* Look for mem= option on command line */
@@ -652,26 +612,6 @@
 
 }
 console_initcall(set_preferred_console);
-
-int parse_bootinfo(void)
-{
-	struct bi_record *rec;
-
-	rec = prom.bi_recs;
-
-	if ( rec == NULL || rec->tag != BI_FIRST )
-		return -1;
-
-	for ( ; rec->tag != BI_LAST ; rec = bi_rec_next(rec) ) {
-		switch (rec->tag) {
-		case BI_CMD_LINE:
-			strlcpy(cmd_line, (void *)rec->data, sizeof(cmd_line));
-			break;
-		}
-	}
-
-	return 0;
-}
 #endif
 
 int __init ppc_init(void)



More information about the Linuxppc64-dev mailing list