Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Add command line processing from uboot
details: https://anonhg.NetBSD.org/src/rev/4982166ab1bc
branches: trunk
changeset: 780569:4982166ab1bc
user: matt <matt%NetBSD.org@localhost>
date: Sun Jul 29 21:39:43 2012 +0000
description:
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.
diffstat:
sys/arch/evbppc/mpc85xx/autoconf.c | 38 +++++++++++++++++++++--
sys/arch/evbppc/mpc85xx/machdep.c | 53 ++++++++++++++++++++++++++++++--
sys/arch/powerpc/include/booke/cpuvar.h | 3 +-
3 files changed, 85 insertions(+), 9 deletions(-)
diffs (195 lines):
diff -r 738668fc516b -r 4982166ab1bc sys/arch/evbppc/mpc85xx/autoconf.c
--- a/sys/arch/evbppc/mpc85xx/autoconf.c Sun Jul 29 21:36:27 2012 +0000
+++ b/sys/arch/evbppc/mpc85xx/autoconf.c Sun Jul 29 21:39:43 2012 +0000
@@ -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 @@
#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 @@
spl0();
}
+static volatile int rootconf_timo = 1;
+
/*
* Setup root device.
* Configure swap area.
@@ -74,6 +77,23 @@
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 @@
{
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;
diff -r 738668fc516b -r 4982166ab1bc sys/arch/evbppc/mpc85xx/machdep.c
--- a/sys/arch/evbppc/mpc85xx/machdep.c Sun Jul 29 21:36:27 2012 +0000
+++ b/sys/arch/evbppc/mpc85xx/machdep.c Sun Jul 29 21:39:43 2012 +0000
@@ -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 @@
#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 @@
/*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 @@
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 @@
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.
diff -r 738668fc516b -r 4982166ab1bc sys/arch/powerpc/include/booke/cpuvar.h
--- a/sys/arch/powerpc/include/booke/cpuvar.h Sun Jul 29 21:36:27 2012 +0000
+++ b/sys/arch/powerpc/include/booke/cpuvar.h Sun Jul 29 21:39:43 2012 +0000
@@ -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 @@
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;
Home |
Main Index |
Thread Index |
Old Index