summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrochner <drochner@NetBSD.org>2010-01-14 17:49:31 +0000
committerdrochner <drochner@NetBSD.org>2010-01-14 17:49:31 +0000
commit79f027bbd6493b7fb048ae236987e2bcbc118f10 (patch)
treeaea1a582506e1b5db318bcfc3405e9d2b42e2b14
parentaa0d6833111230f3d5d93b26a96751f03c1f70b7 (diff)
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.
-rw-r--r--sys/arch/i386/stand/boot/boot2.c7
-rw-r--r--sys/arch/i386/stand/lib/boot_params.S8
-rw-r--r--sys/arch/i386/stand/pxeboot/Makefile6
-rw-r--r--sys/arch/i386/stand/pxeboot/main.c7
-rw-r--r--sys/sys/bootblock.h4
-rw-r--r--usr.sbin/installboot/arch/i386.c14
-rw-r--r--usr.sbin/installboot/installboot.816
-rw-r--r--usr.sbin/installboot/installboot.c6
-rw-r--r--usr.sbin/installboot/installboot.h4
9 files changed, 55 insertions, 17 deletions
diff --git a/sys/arch/i386/stand/boot/boot2.c b/sys/arch/i386/stand/boot/boot2.c
index d5171a431c9..029283c3759 100644
--- a/sys/arch/i386/stand/boot/boot2.c
+++ b/sys/arch/i386/stand/boot/boot2.c
@@ -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 @@ boot2(int biosdev, u_int biossector)
#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 @@ boot2(int biosdev, u_int biossector)
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.
diff --git a/sys/arch/i386/stand/lib/boot_params.S b/sys/arch/i386/stand/lib/boot_params.S
index 2dd976506fa..55041c8185b 100644
--- a/sys/arch/i386/stand/lib/boot_params.S
+++ b/sys/arch/i386/stand/lib/boot_params.S
@@ -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 */
diff --git a/sys/arch/i386/stand/pxeboot/Makefile b/sys/arch/i386/stand/pxeboot/Makefile
index 1b43a01c750..dc53ec7c988 100644
--- a/sys/arch/i386/stand/pxeboot/Makefile
+++ b/sys/arch/i386/stand/pxeboot/Makefile
@@ -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+= -DSUPPORT_NFS
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
diff --git a/sys/arch/i386/stand/pxeboot/main.c b/sys/arch/i386/stand/pxeboot/main.c
index 546955c0b9c..63d3c8c818d 100644
--- a/sys/arch/i386/stand/pxeboot/main.c
+++ b/sys/arch/i386/stand/pxeboot/main.c
@@ -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 @@ main(void)
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.
diff --git a/sys/sys/bootblock.h b/sys/sys/bootblock.h
index f86eacebc7b..b7ebec033ed 100644
--- a/sys/sys/bootblock.h
+++ b/sys/sys/bootblock.h
@@ -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 @@ struct x86_boot_params {
/* 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
diff --git a/usr.sbin/installboot/arch/i386.c b/usr.sbin/installboot/arch/i386.c
index 189740f81db..67dab44195e 100644
--- a/usr.sbin/installboot/arch/i386.c
+++ b/usr.sbin/installboot/arch/i386.c
@@ -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 @@ static int i386_editboot(ib_params *);
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 @@ update_i386_boot_params(ib_params *params, struct x86_boot_params *bpp)
}
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);
diff --git a/usr.sbin/installboot/installboot.8 b/usr.sbin/installboot/installboot.8
index 775a498c591..08b771eab19 100644
--- a/usr.sbin/installboot/installboot.8
+++ b/usr.sbin/installboot/installboot.8
@@ -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 @@ disklabel should use no more than 4 partitions.
.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
diff --git a/usr.sbin/installboot/installboot.c b/usr.sbin/installboot/installboot.c
index 3b212a33560..7573a9fe91b 100644
--- a/usr.sbin/installboot/installboot.c
+++ b/usr.sbin/installboot/installboot.c
@@ -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 @@ const struct option {
{ "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
diff --git a/usr.sbin/installboot/installboot.h b/usr.sbin/installboot/installboot.h
index 4c4b4c674d6..a206a7d946e 100644
--- a/usr.sbin/installboot/installboot.h
+++ b/usr.sbin/installboot/installboot.h
@@ -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 @@ typedef enum {
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 {