Module Name:    src
Committed By:   phx
Date:           Wed May 19 15:05:58 UTC 2010

Modified Files:
        src/sys/arch/sandpoint/stand/netboot: Makefile entry.S main.c

Log Message:
Implemented support for boot arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sandpoint/stand/netboot/Makefile
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/stand/netboot/entry.S
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sandpoint/stand/netboot/main.c

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/sandpoint/stand/netboot/Makefile
diff -u src/sys/arch/sandpoint/stand/netboot/Makefile:1.17 src/sys/arch/sandpoint/stand/netboot/Makefile:1.18
--- src/sys/arch/sandpoint/stand/netboot/Makefile:1.17	Mon May 17 17:50:08 2010
+++ src/sys/arch/sandpoint/stand/netboot/Makefile	Wed May 19 15:05:58 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.17 2010/05/17 17:50:08 phx Exp $
+#	$NetBSD: Makefile,v 1.18 2010/05/19 15:05:58 phx Exp $
 
 S=		${.CURDIR}/../../../..
 
@@ -11,7 +11,6 @@
 CPPFLAGS+=	-D_STANDALONE -DSUPPORT_DHCP
 #CPPFLAGS+=	-DCONSNAME=\"com\" -DCONSPORT=0x3f8 -DCONSSPEED=115200
 #CPPFLAGS+=	-DCONSNAME=\"eumb\" -DCONSPORT=0x4600 -DCONSSPEED=57600
-#CPPFLAGS+=	-DSTART_DDB_SESSION
 CPPFLAGS+=	-nostdinc -I. -I${.OBJDIR} -I${S}
 DBG=		-Os
 

Index: src/sys/arch/sandpoint/stand/netboot/entry.S
diff -u src/sys/arch/sandpoint/stand/netboot/entry.S:1.6 src/sys/arch/sandpoint/stand/netboot/entry.S:1.7
--- src/sys/arch/sandpoint/stand/netboot/entry.S:1.6	Thu May 13 10:40:02 2010
+++ src/sys/arch/sandpoint/stand/netboot/entry.S	Wed May 19 15:05:58 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: entry.S,v 1.6 2010/05/13 10:40:02 phx Exp $ */
+/* $NetBSD: entry.S,v 1.7 2010/05/19 15:05:58 phx Exp $ */
 
 #include <powerpc/psl.h>
 #include <powerpc/spr.h>
@@ -9,6 +9,8 @@
 	.text
 	.globl _start
 _start:
+	mr	30,3
+	mr	31,4
 	mfspr	11,SPR_HID0
 	andi.	0,11,HID0_DCE
 	ori	11,11,HID0_ICE
@@ -89,6 +91,8 @@
 	addi	1,1,-4
 
 	bl	brdsetup
+	mr	3,30
+	mr	4,31
 	bl	main
 
 hang:	b	hang

Index: src/sys/arch/sandpoint/stand/netboot/main.c
diff -u src/sys/arch/sandpoint/stand/netboot/main.c:1.30 src/sys/arch/sandpoint/stand/netboot/main.c:1.31
--- src/sys/arch/sandpoint/stand/netboot/main.c:1.30	Tue May 18 15:07:50 2010
+++ src/sys/arch/sandpoint/stand/netboot/main.c	Wed May 19 15:05:58 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.30 2010/05/18 15:07:50 phx Exp $ */
+/* $NetBSD: main.c,v 1.31 2010/05/19 15:05:58 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -40,6 +40,23 @@
 
 #include "globals.h"
 
+static const struct bootarg {
+	const char *name;
+	int value;
+} bootargs[] = {
+	{ "multi",	RB_AUTOBOOT },
+	{ "auto",	RB_AUTOBOOT },
+	{ "ask",	RB_ASKNAME },
+	{ "single",	RB_SINGLE },
+	{ "ddb",	RB_KDB },
+	{ "userconf",	RB_USERCONF },
+	{ "norm",	AB_NORMAL },
+	{ "quiet",	AB_QUIET },
+	{ "verb",	AB_VERBOSE },
+	{ "silent",	AB_SILENT },
+	{ "debug",	AB_DEBUG }
+};
+
 void *bootinfo; /* low memory reserved to pass bootinfo structures */
 int bi_size;	/* BOOTINFO_MAXSIZE */
 char *bi_next;
@@ -48,7 +65,7 @@
 char rootdev[4];	/* NIF nickname, filled by netif_init() */
 uint8_t en[6];		/* NIC macaddr, fill by netif_init() */
 
-void main(void);
+void main(int, char **);
 void bi_init(void *);
 void bi_add(void *, int, int);
 
@@ -62,7 +79,7 @@
 uint32_t busclock, cpuclock;
 
 void
-main(void)
+main(int argc, char *argv[])
 {
 	struct btinfo_memory bi_mem;
 	struct btinfo_console bi_cons;
@@ -73,7 +90,7 @@
 	unsigned long marks[MARK_MAX];
 	unsigned lata[1][2], lnif[1][2];
 	unsigned memsize, tag;
-	int b, d, f, fd, howto, n;
+	int b, d, f, fd, howto, i, n;
 
 	/* determine SDRAM size */
 	memsize = mpc107memsize();
@@ -143,10 +160,19 @@
 	if (fdloadfile(fd, marks, LOAD_KERNEL) < 0)
 		goto loadfail;
 
-	howto = RB_SINGLE | AB_VERBOSE;
-#ifdef START_DDB_SESSION
-	howto |= RB_KDB;
-#endif
+	/* get boot mode and boot options */
+	howto = RB_AUTOBOOT;
+	for (n = 1; n < argc; n++) {
+		for (i = 0; i < sizeof(bootargs) / sizeof(bootargs[0]); i++) {
+			if (strncasecmp(argv[n], bootargs[i].name,
+			    strlen(bootargs[i].name)) == 0) {
+				howto |= bootargs[i].value;
+				break;
+			}
+		}
+		if (i >= sizeof(bootargs) / sizeof(bootargs[0]))
+			break;	/* break on first garbage argument */
+	}
 
 	bootinfo = (void *)0x4000;
 	bi_init(bootinfo);

Reply via email to