Module Name:    src
Committed By:   drochner
Date:           Thu Jan 14 17:49:32 UTC 2010

Modified Files:
        src/sys/arch/i386/stand/boot: boot2.c
        src/sys/arch/i386/stand/lib: boot_params.S
        src/sys/arch/i386/stand/pxeboot: Makefile main.c
        src/sys/sys: bootblock.h
        src/usr.sbin/installboot: installboot.8 installboot.c installboot.h
        src/usr.sbin/installboot/arch: i386.c

Log Message:
On i386/amd64, define two flag bits in the boot parameters which control
whether modules are loaded and whether boot.cfg is evaluated, and
set both to "off" per default in the PXE bootloader.
Extend "installboot" to toggle the bits.
This way, pxeboot works with existing dhcp server setups (and as
described in the manpage) out of the box. Also, boot.cfg reading
involves a stat() call which is horribly inefficient with the
TFTP pseudo file system.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/i386/stand/boot/boot2.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/lib/boot_params.S
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/i386/stand/pxeboot/Makefile
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/i386/stand/pxeboot/main.c
cvs rdiff -u -r1.48 -r1.49 src/sys/sys/bootblock.h
cvs rdiff -u -r1.73 -r1.74 src/usr.sbin/installboot/installboot.8
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/installboot/installboot.c
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/installboot/installboot.h
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/installboot/arch/i386.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/i386/stand/boot/boot2.c
diff -u src/sys/arch/i386/stand/boot/boot2.c:1.45 src/sys/arch/i386/stand/boot/boot2.c:1.46
--- src/sys/arch/i386/stand/boot/boot2.c:1.45	Sun Sep 13 22:45:27 2009
+++ src/sys/arch/i386/stand/boot/boot2.c	Thu Jan 14 17:49:31 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot2.c,v 1.45 2009/09/13 22:45:27 jmcneill Exp $	*/
+/*	$NetBSD: boot2.c,v 1.46 2010/01/14 17:49:31 drochner Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -291,6 +291,8 @@
 #endif
 	gateA20();
 
+	boot_modules_enabled = !!(boot_params.bp_flags
+				  & X86_BP_FLAGS_LOADMODULES);
 	if (boot_params.bp_flags & X86_BP_FLAGS_RESET_VIDEO)
 		biosvideomode();
 
@@ -308,7 +310,8 @@
 	default_filename = DEFFILENAME;
 
 #ifndef SMALL
-	parsebootconf(BOOTCONF);
+	if (boot_params.bp_flags & X86_BP_FLAGS_READBOOTCONF)
+		parsebootconf(BOOTCONF);
 
 	/*
 	 * If console set in boot.cfg, switch to it.

Index: src/sys/arch/i386/stand/lib/boot_params.S
diff -u src/sys/arch/i386/stand/lib/boot_params.S:1.4 src/sys/arch/i386/stand/lib/boot_params.S:1.5
--- src/sys/arch/i386/stand/lib/boot_params.S:1.4	Sun Dec 11 12:17:48 2005
+++ src/sys/arch/i386/stand/lib/boot_params.S	Thu Jan 14 17:49:31 2010
@@ -1,8 +1,12 @@
-/*	$NetBSD: boot_params.S,v 1.4 2005/12/11 12:17:48 christos Exp $	*/
+/*	$NetBSD: boot_params.S,v 1.5 2010/01/14 17:49:31 drochner Exp $	*/
 
 /* Default boot parameters - must match struct x86_boot_params in bootblock.h */
 
-	.long	0			/* flags */
+#ifdef BOOTPARAM_DEFFLAGS
+	.long	BOOTPARAM_DEFFLAGS
+#else
+	.long	0x0c			/* flags: bootconf+modules */
+#endif
 	.long	5			/* timeout in seconds */
 	.long	0			/* console device 0 => CONSDEV_PC */
 	.long	9600			/* serial baud rate */

Index: src/sys/arch/i386/stand/pxeboot/Makefile
diff -u src/sys/arch/i386/stand/pxeboot/Makefile:1.17 src/sys/arch/i386/stand/pxeboot/Makefile:1.18
--- src/sys/arch/i386/stand/pxeboot/Makefile:1.17	Mon Mar 30 09:22:53 2009
+++ src/sys/arch/i386/stand/pxeboot/Makefile	Thu Jan 14 17:49:31 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.17 2009/03/30 09:22:53 tsutsui Exp $
+#	$NetBSD: Makefile,v 1.18 2010/01/14 17:49:31 drochner Exp $
 
 S=	${.CURDIR}/../../../..
 
@@ -63,6 +63,10 @@
 CPPFLAGS+= -DPASS_MEMMAP
 CPPFLAGS+= -DEPIA_HACK
 
+# modules and boot.cfg need special DHCP server setup, disable
+# per default for compatibility with existing setups
+CPPFLAGS+= -DBOOTPARAM_DEFFLAGS=0
+
 #CFLAGS= -O2 -fomit-frame-pointer -fno-defer-pop
 CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-main
 

Index: src/sys/arch/i386/stand/pxeboot/main.c
diff -u src/sys/arch/i386/stand/pxeboot/main.c:1.22 src/sys/arch/i386/stand/pxeboot/main.c:1.23
--- src/sys/arch/i386/stand/pxeboot/main.c:1.22	Sun Dec 13 23:01:42 2009
+++ src/sys/arch/i386/stand/pxeboot/main.c	Thu Jan 14 17:49:31 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.22 2009/12/13 23:01:42 jakllsch Exp $	*/
+/*	$NetBSD: main.c,v 1.23 2010/01/14 17:49:31 drochner Exp $	*/
 
 /*
  * Copyright (c) 1996
@@ -130,9 +130,12 @@
 	initio(CONSDEV_PC);
 #endif
 	gateA20();
+	boot_modules_enabled = !!(boot_params.bp_flags
+				  & X86_BP_FLAGS_LOADMODULES);
 
 #ifndef SMALL
-	parsebootconf(BOOTCONF);
+	if (boot_params.bp_flags & X86_BP_FLAGS_READBOOTCONF)
+		parsebootconf(BOOTCONF);
 
 	/*
 	 * If console set in boot.cfg, switch to it.

Index: src/sys/sys/bootblock.h
diff -u src/sys/sys/bootblock.h:1.48 src/sys/sys/bootblock.h:1.49
--- src/sys/sys/bootblock.h:1.48	Mon Oct 26 14:22:47 2009
+++ src/sys/sys/bootblock.h	Thu Jan 14 17:49:31 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootblock.h,v 1.48 2009/10/26 14:22:47 tsutsui Exp $	*/
+/*	$NetBSD: bootblock.h,v 1.49 2010/01/14 17:49:31 drochner Exp $	*/
 
 /*-
  * Copyright (c) 2002-2004 The NetBSD Foundation, Inc.
@@ -1068,6 +1068,8 @@
 		/* values for bp_flags */
 #define	X86_BP_FLAGS_RESET_VIDEO	1
 #define	X86_BP_FLAGS_PASSWORD		2
+#define	X86_BP_FLAGS_LOADMODULES	4
+#define	X86_BP_FLAGS_READBOOTCONF	8
 
 		/* values for bp_consdev */
 #define	X86_BP_CONSDEV_PC	0

Index: src/usr.sbin/installboot/installboot.8
diff -u src/usr.sbin/installboot/installboot.8:1.73 src/usr.sbin/installboot/installboot.8:1.74
--- src/usr.sbin/installboot/installboot.8:1.73	Thu May  7 07:09:49 2009
+++ src/usr.sbin/installboot/installboot.8	Thu Jan 14 17:49:32 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: installboot.8,v 1.73 2009/05/07 07:09:49 lukem Exp $
+.\"	$NetBSD: installboot.8,v 1.74 2010/01/14 17:49:32 drochner Exp $
 .\"
 .\" Copyright (c) 2002-2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 12, 2008
+.Dd January 11, 2010
 .Dt INSTALLBOOT 8
 .Os
 .Sh NAME
@@ -305,6 +305,18 @@
 .Sy [ amd64 ,
 .Sy i386 ]
 Set the timeout before the automatic boot begins to the given number of seconds.
+.
+.It Sy modules
+.Sy [ amd64 ,
+.Sy i386 ]
+(Don't) load kernel modules.
+.
+.It Sy bootconf
+.Sy [ amd64 ,
+.Sy i386 ]
+(Don't) read a
+.Dq boot.cfg
+file.
 .El
 .
 .It Fl t Ar fstype

Index: src/usr.sbin/installboot/installboot.c
diff -u src/usr.sbin/installboot/installboot.c:1.33 src/usr.sbin/installboot/installboot.c:1.34
--- src/usr.sbin/installboot/installboot.c:1.33	Thu Jan 14 16:27:49 2010
+++ src/usr.sbin/installboot/installboot.c	Thu Jan 14 17:49:32 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: installboot.c,v 1.33 2010/01/14 16:27:49 tsutsui Exp $	*/
+/*	$NetBSD: installboot.c,v 1.34 2010/01/14 17:49:32 drochner Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(__lint)
-__RCSID("$NetBSD: installboot.c,v 1.33 2010/01/14 16:27:49 tsutsui Exp $");
+__RCSID("$NetBSD: installboot.c,v 1.34 2010/01/14 17:49:32 drochner Exp $");
 #endif	/* !__lint */
 
 #include <sys/ioctl.h>
@@ -87,6 +87,8 @@
 	{ "speed",	IB_CONSPEED,	OPT_INT,	OFFSET(conspeed) },
 	{ "sunsum",	IB_SUNSUM,	OPT_BOOL,	0 },
 	{ "timeout",	IB_TIMEOUT,	OPT_INT,	OFFSET(timeout) },
+	{ "modules",	IB_MODULES,	OPT_BOOL,	0 },
+	{ "bootconf",	IB_BOOTCONF,	OPT_BOOL,	0 },
 	{ .name = NULL },
 };
 #undef OFFSET

Index: src/usr.sbin/installboot/installboot.h
diff -u src/usr.sbin/installboot/installboot.h:1.36 src/usr.sbin/installboot/installboot.h:1.37
--- src/usr.sbin/installboot/installboot.h:1.36	Thu Jan  7 13:26:00 2010
+++ src/usr.sbin/installboot/installboot.h	Thu Jan 14 17:49:32 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: installboot.h,v 1.36 2010/01/07 13:26:00 tsutsui Exp $	*/
+/*	$NetBSD: installboot.h,v 1.37 2010/01/14 17:49:32 drochner Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -65,6 +65,8 @@
 	IB_PASSWORD =	1<<18,		/* i386 boot password */
 	IB_KEYMAP = 	1<<19,		/* i386 console keymap */
 	IB_CONSADDR = 	1<<20,		/* i386 console io address */
+	IB_MODULES =	1<<21,		/* i386: load modules */
+	IB_BOOTCONF = 	1<<22,		/* i386: read boot.conf */
 } ib_flags;
 
 typedef struct {

Index: src/usr.sbin/installboot/arch/i386.c
diff -u src/usr.sbin/installboot/arch/i386.c:1.34 src/usr.sbin/installboot/arch/i386.c:1.35
--- src/usr.sbin/installboot/arch/i386.c:1.34	Wed Dec 23 09:17:41 2009
+++ src/usr.sbin/installboot/arch/i386.c	Thu Jan 14 17:49:32 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: i386.c,v 1.34 2009/12/23 09:17:41 mbalmer Exp $ */
+/* $NetBSD: i386.c,v 1.35 2010/01/14 17:49:32 drochner Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(__lint)
-__RCSID("$NetBSD: i386.c,v 1.34 2009/12/23 09:17:41 mbalmer Exp $");
+__RCSID("$NetBSD: i386.c,v 1.35 2010/01/14 17:49:32 drochner Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -80,12 +80,14 @@
 struct ib_mach ib_mach_i386 =
 	{ "i386", i386_setboot, no_clearboot, i386_editboot,
 		IB_RESETVIDEO | IB_CONSOLE | IB_CONSPEED | IB_CONSADDR |
-		IB_KEYMAP | IB_PASSWORD | IB_TIMEOUT };
+		IB_KEYMAP | IB_PASSWORD | IB_TIMEOUT |
+		IB_MODULES | IB_BOOTCONF };
 
 struct ib_mach ib_mach_amd64 =
 	{ "amd64", i386_setboot, no_clearboot, i386_editboot,
 		IB_RESETVIDEO | IB_CONSOLE | IB_CONSPEED | IB_CONSADDR |
-		IB_KEYMAP | IB_PASSWORD | IB_TIMEOUT };
+		IB_KEYMAP | IB_PASSWORD | IB_TIMEOUT |
+		IB_MODULES | IB_BOOTCONF };
 
 /*
  * Attempting to write the 'labelsector' (or a sector near it - within 8k?)
@@ -272,6 +274,10 @@
 	}
 	if (params->flags & IB_KEYMAP)
 		strlcpy(bp.bp_keymap, params->keymap, sizeof bp.bp_keymap);
+	if (params->flags & IB_MODULES)
+		bp.bp_flags ^= htole32(X86_BP_FLAGS_LOADMODULES);
+	if (params->flags & IB_BOOTCONF)
+		bp.bp_flags ^= htole32(X86_BP_FLAGS_READBOOTCONF);
 
 	if (params->flags & (IB_NOWRITE | IB_VERBOSE))
 		show_i386_boot_params(&bp);

Reply via email to