Module Name:    src
Committed By:   matt
Date:           Sun Jul 29 21:39:43 UTC 2012

Modified Files:
        src/sys/arch/evbppc/mpc85xx: autoconf.c machdep.c
        src/sys/arch/powerpc/include/booke: cpuvar.h

Log Message:
Add command line processing from uboot
bootm $loadaddr [opts] [device]
where opts is -[advqs] and device is the boot device.
cpu_rootconf will now wait a bit for devices to appear until the boot device
appears.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/evbppc/mpc85xx/autoconf.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/evbppc/mpc85xx/machdep.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/include/booke/cpuvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbppc/mpc85xx/autoconf.c
diff -u src/sys/arch/evbppc/mpc85xx/autoconf.c:1.6 src/sys/arch/evbppc/mpc85xx/autoconf.c:1.7
--- src/sys/arch/evbppc/mpc85xx/autoconf.c:1.6	Sun Jul 29 18:05:42 2012
+++ src/sys/arch/evbppc/mpc85xx/autoconf.c	Sun Jul 29 21:39:43 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.6 2012/07/29 18:05:42 mlelstv Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.7 2012/07/29 21:39:43 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.6 2012/07/29 18:05:42 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.7 2012/07/29 21:39:43 matt Exp $");
 
 #define __INTR_PRIVATE
 
@@ -43,11 +43,12 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 
 #include <sys/param.h>
 #include <sys/conf.h>
+#include <sys/cpu.h>
 #include <sys/device.h>
 #include <sys/intr.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
 #include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/cpu.h>
 
 #include <powerpc/booke/cpuvar.h>
 
@@ -67,6 +68,8 @@ cpu_configure(void)
 	spl0();
 }
 
+static volatile int rootconf_timo = 1;
+
 /*
  * Setup root device.
  * Configure swap area.
@@ -74,6 +77,23 @@ cpu_configure(void)
 void
 cpu_rootconf(void)
 {
+	/*
+	 * We wait up to 10 seconds for a bootable device to be found.
+	 */
+	while (rootconf_timo-- > 0) {
+		if (booted_device != NULL) {
+			aprint_normal_dev(booted_device, "boot device\n");
+			break;
+		}
+
+		if (root_string[0] != '\0'
+		    && (booted_device = device_find_by_xname(root_string)) != NULL) {
+			aprint_normal_dev(booted_device, "boot device\n");
+			break;
+		}
+
+		kpause("autoconf", true, 1, NULL);
+	}
 
 	rootconf();
 }
@@ -83,6 +103,16 @@ device_register(device_t dev, void *aux)
 {
 	if (cpu_md_ops.md_device_register != NULL)
 		(*cpu_md_ops.md_device_register)(dev, aux);
+
+	if (booted_device == NULL) {
+		if (root_string[0] != '\0'
+		    && !strcmp(device_xname(dev), root_string)) {
+			aprint_normal_dev(dev, "boot device\n");
+			booted_device = dev;
+		} else {
+			rootconf_timo = 5 * hz;
+		}
+	}
 }
 
 static bool mainbus_found;

Index: src/sys/arch/evbppc/mpc85xx/machdep.c
diff -u src/sys/arch/evbppc/mpc85xx/machdep.c:1.28 src/sys/arch/evbppc/mpc85xx/machdep.c:1.29
--- src/sys/arch/evbppc/mpc85xx/machdep.c:1.28	Sun Jul 22 23:46:10 2012
+++ src/sys/arch/evbppc/mpc85xx/machdep.c	Sun Jul 29 21:39:43 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.28 2012/07/22 23:46:10 matt Exp $	*/
+/*	$NetBSD: machdep.c,v 1.29 2012/07/29 21:39:43 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -59,7 +59,7 @@ __KERNEL_RCSID(0, "$NetSBD$");
 #include <sys/bitops.h>
 #include <sys/bus.h>
 #include <sys/extent.h>
-#include <sys/malloc.h>
+#include <sys/reboot.h>
 #include <sys/module.h>
 
 #include <uvm/uvm_extern.h>
@@ -114,12 +114,14 @@ struct uboot_bdinfo {
 /*4e*/	uint16_t bd_pad;
 };
 
+char root_string[16];
+
 /*
  * booke kernels need to set module_machine to this for modules to work.
  */
 char module_machine_booke[] = "powerpc-booke";
 
-void	initppc(vaddr_t, vaddr_t, void *, void *, void *, void *);
+void	initppc(vaddr_t, vaddr_t, void *, void *, char *, char *);
 
 #define	MEMREGIONS	4
 phys_ram_seg_t physmemr[MEMREGIONS];		/* All memory */
@@ -1045,9 +1047,45 @@ calltozero(void)
 	panic("call to 0 from %p", __builtin_return_address(0));
 }
 
+static void
+parse_cmdline(char *cp)
+{
+	int ourhowto = 0;
+	char c;
+	bool opt = false;
+	for (; (c = *cp) != '\0'; cp++) {
+		if (c == '-') {	
+			opt = true;
+			continue;
+		}
+		if (c == ' ') {
+			opt = false;
+			continue;
+		}
+		if (opt) {
+			switch (c) {
+			case 'a': ourhowto |= RB_ASKNAME; break;
+			case 'd': ourhowto |= AB_DEBUG; break;
+			case 'q': ourhowto |= AB_QUIET; break;
+			case 's': ourhowto |= RB_SINGLE; break;
+			case 'v': ourhowto |= AB_VERBOSE; break;
+			}
+			continue;
+		}
+		strlcpy(root_string, cp, sizeof(root_string));
+		break;
+	}
+	if (ourhowto) {
+		boothowto |= ourhowto;
+		printf(" boothowto=%#x(%#x)", boothowto, ourhowto);
+	}
+	if (root_string[0])
+		printf(" root=%s", root_string);
+}
+
 void
 initppc(vaddr_t startkernel, vaddr_t endkernel,
-	void *a0, void *a1, void *a2, void *a3)
+	void *a0, void *a1, char *a2, char *a3)
 {
 	struct cpu_info * const ci = curcpu();
 	struct cpu_softc * const cpu = ci->ci_softc;
@@ -1056,6 +1094,13 @@ initppc(vaddr_t startkernel, vaddr_t end
 	printf(" initppc(%#"PRIxVADDR", %#"PRIxVADDR", %p, %p, %p, %p)<enter>",
 	    startkernel, endkernel, a0, a1, a2, a3);
 
+	if (a2[0] != '\0')
+		printf(" consdev=<%s>", a2);
+	if (a3[0] != '\0') {
+		printf(" cmdline=<%s>", a3);
+		parse_cmdline(a3);
+	}
+
 	/*
 	 * Make sure we don't enter NAP or SLEEP if PSL_POW (MSR[WE]) is set.
 	 * DOZE is ok.

Index: src/sys/arch/powerpc/include/booke/cpuvar.h
diff -u src/sys/arch/powerpc/include/booke/cpuvar.h:1.13 src/sys/arch/powerpc/include/booke/cpuvar.h:1.14
--- src/sys/arch/powerpc/include/booke/cpuvar.h:1.13	Fri Jul 27 22:24:13 2012
+++ src/sys/arch/powerpc/include/booke/cpuvar.h	Sun Jul 29 21:39:43 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuvar.h,v 1.13 2012/07/27 22:24:13 matt Exp $	*/
+/*	$NetBSD: cpuvar.h,v 1.14 2012/07/29 21:39:43 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -194,6 +194,7 @@ void	*board_info_get_object(const char *
 const void *
 	board_info_get_data(const char *, size_t *);
 
+extern char root_string[];
 extern paddr_t msgbuf_paddr;
 extern prop_dictionary_t board_properties;
 extern psize_t pmemsize;

Reply via email to