Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Support userconf(4) command in boot(8)/boot.cfg(5) on i386/a...
details: https://anonhg.NetBSD.org/src/rev/8499b880fb49
branches: trunk
changeset: 765421:8499b880fb49
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Thu May 26 04:25:26 2011 +0000
description:
Support userconf(4) command in boot(8)/boot.cfg(5) on i386/amd64.
>From jmmv@, no objections seen in the proposed thread:
http://mail-index.netbsd.org/tech-kern/2009/01/22/msg004081.html
diffstat:
share/man/man5/boot.cfg.5 | 9 ++-
share/man/man8/man8.i386/boot.8 | 13 ++++-
sys/arch/i386/stand/boot/boot2.c | 6 +-
sys/arch/i386/stand/lib/bootmenu.c | 4 +-
sys/arch/i386/stand/lib/exec.c | 97 +++++++++++++++++++++++++++++++++++++-
sys/arch/i386/stand/lib/libi386.h | 3 +-
sys/arch/i386/stand/pxeboot/main.c | 4 +-
sys/arch/x86/include/bootinfo.h | 13 ++++-
sys/arch/x86/include/cpu.h | 4 +-
sys/arch/x86/x86/x86_machdep.c | 25 +++++++++-
sys/kern/init_main.c | 7 +-
sys/kern/subr_userconf.c | 18 +++---
sys/sys/userconf.h | 14 ++++-
13 files changed, 189 insertions(+), 28 deletions(-)
diffs (truncated from 536 to 300 lines):
diff -r 16c8d6410962 -r 8499b880fb49 share/man/man5/boot.cfg.5
--- a/share/man/man5/boot.cfg.5 Thu May 26 02:37:25 2011 +0000
+++ b/share/man/man5/boot.cfg.5 Thu May 26 04:25:26 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: boot.cfg.5,v 1.21 2010/10/28 14:29:18 jruoho Exp $
+.\" $NetBSD: boot.cfg.5,v 1.22 2011/05/26 04:25:26 uebayasi Exp $
.\"
.\" Copyright (c) 2007 Stephen Borrill
.\" All rights reserved.
@@ -25,7 +25,7 @@
.\" INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd October 28, 2010
+.Dd May 26, 2011
.Dt BOOT.CFG 5
.Os
.Sh NAME
@@ -143,6 +143,10 @@
immediately.
If the timeout value is negative or is not a number, there will be no
time limit for the user to choose an option.
+.It Sy userconf
+Passes a
+.Xr userconf 4
+command to the kernel at boot time .
.El
.Sh EXAMPLES
Here is an example
@@ -165,6 +169,7 @@
clear=1
timeout=-1
default=1
+userconf disable ehci*
# Always load ramdisk module
load=/miniroot.kmod
.Ed
diff -r 16c8d6410962 -r 8499b880fb49 share/man/man8/man8.i386/boot.8
--- a/share/man/man8/man8.i386/boot.8 Thu May 26 02:37:25 2011 +0000
+++ b/share/man/man8/man8.i386/boot.8 Thu May 26 04:25:26 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: boot.8,v 1.56 2011/01/13 10:03:29 jym Exp $
+.\" $NetBSD: boot.8,v 1.57 2011/05/26 04:25:26 uebayasi Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -32,7 +32,7 @@
.\"
.\" @(#)boot_i386.8 8.2 (Berkeley) 4/19/94
.\"
-.Dd November 7, 2010
+.Dd May 26, 2011
.Dt BOOT 8 i386
.Os
.Sh NAME
@@ -558,6 +558,15 @@
.El
.It Ic quit
Reboot the system.
+.It Ic userconf Va command
+Pass the
+.Va command
+to
+.Xr userconf 4
+at boot time .
+These commands are processed before the interactive
+.Xr userconf 4
+shell is executed, if requested .
.El
.Pp
In an emergency, the bootstrap methods described in the
diff -r 16c8d6410962 -r 8499b880fb49 sys/arch/i386/stand/boot/boot2.c
--- a/sys/arch/i386/stand/boot/boot2.c Thu May 26 02:37:25 2011 +0000
+++ b/sys/arch/i386/stand/boot/boot2.c Thu May 26 04:25:26 2011 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: boot2.c,v 1.53 2011/03/18 18:24:09 jakllsch Exp $ */
+/* $NetBSD: boot2.c,v 1.54 2011/05/26 04:25:27 uebayasi Exp $ */
/*-
- * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -136,6 +136,7 @@
{ "multiboot", command_multiboot },
{ "vesa", command_vesa },
{ "splash", splash_add },
+ { "userconf", userconf_add },
{ NULL, NULL },
};
@@ -395,6 +396,7 @@
"modules {on|off|enabled|disabled}\n"
"load {path_to_module}\n"
"multiboot [xdNx:][filename] [<args>]\n"
+ "userconf {command}\n"
"help|?\n"
"quit\n");
}
diff -r 16c8d6410962 -r 8499b880fb49 sys/arch/i386/stand/lib/bootmenu.c
--- a/sys/arch/i386/stand/lib/bootmenu.c Thu May 26 02:37:25 2011 +0000
+++ b/sys/arch/i386/stand/lib/bootmenu.c Thu May 26 04:25:26 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bootmenu.c,v 1.8 2009/09/14 10:42:42 jmcneill Exp $ */
+/* $NetBSD: bootmenu.c,v 1.9 2011/05/26 04:25:27 uebayasi Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -232,6 +232,8 @@
}
} else if (!strncmp(key, "clear", 5)) {
bootconf.clear = !!atoi(value);
+ } else if (!strncmp(key, "userconf", 8)) {
+ userconf_add(value);
}
}
switch (bootconf.menuformat) {
diff -r 16c8d6410962 -r 8499b880fb49 sys/arch/i386/stand/lib/exec.c
--- a/sys/arch/i386/stand/lib/exec.c Thu May 26 02:37:25 2011 +0000
+++ b/sys/arch/i386/stand/lib/exec.c Thu May 26 04:25:26 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.46 2011/02/06 23:16:05 jmcneill Exp $ */
+/* $NetBSD: exec.c,v 1.47 2011/05/26 04:25:27 uebayasi Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -126,6 +126,13 @@
bool boot_modules_enabled = true;
bool kernel_loaded;
+typedef struct userconf_command {
+ char *uc_text;
+ size_t uc_len;
+ struct userconf_command *uc_next;
+} userconf_command_t;
+userconf_command_t *userconf_commands = NULL;
+
static struct btinfo_framebuffer btinfo_framebuffer;
static struct btinfo_modulelist *btinfo_modulelist;
@@ -134,9 +141,14 @@
static char module_base[64] = "/";
static int howto;
+static struct btinfo_userconfcommands *btinfo_userconfcommands = NULL;
+static size_t btinfo_userconfcommands_size = 0;
+
static void module_init(const char *);
static void module_add_common(char *, uint8_t);
+static void userconf_init(void);
+
void
framebuffer_configure(struct btinfo_framebuffer *fb)
{
@@ -191,6 +203,46 @@
}
}
+void
+userconf_add(char *cmd)
+{
+ userconf_command_t *uc;
+ size_t len;
+ char *text;
+
+ while (*cmd == ' ' || *cmd == '\t')
+ ++cmd;
+
+ uc = alloc(sizeof(*uc));
+ if (uc == NULL) {
+ printf("couldn't allocate command\n");
+ return;
+ }
+
+ len = strlen(cmd) + 1;
+ text = alloc(len);
+ if (text == NULL) {
+ dealloc(uc, sizeof(*uc));
+ printf("couldn't allocate command\n");
+ return;
+ }
+ memcpy(text, cmd, len);
+
+ uc->uc_text = text;
+ uc->uc_len = len;
+ uc->uc_next = NULL;
+
+ if (userconf_commands == NULL)
+ userconf_commands = uc;
+ else {
+ userconf_command_t *ucp;
+ for (ucp = userconf_commands; ucp->uc_next != NULL;
+ ucp = ucp->uc_next)
+ ;
+ ucp->uc_next = uc;
+ }
+}
+
static int
common_load_kernel(const char *file, u_long *basemem, u_long *extmem,
physaddr_t loadaddr, int floppy, u_long marks[MARK_MAX])
@@ -319,6 +371,11 @@
}
}
+ userconf_init();
+ if (btinfo_userconfcommands != NULL)
+ BI_ADD(btinfo_userconfcommands, BTINFO_USERCONFCOMMANDS,
+ btinfo_userconfcommands_size);
+
#ifdef DEBUG
printf("Start @ 0x%lx [%ld=0x%lx-0x%lx]...\n", marks[MARK_ENTRY],
marks[MARK_NSYM], marks[MARK_SYM], marks[MARK_END]);
@@ -543,6 +600,44 @@
}
}
+static void
+userconf_init(void)
+{
+ size_t count, len;
+ userconf_command_t *uc;
+ char *buf;
+ off_t off;
+
+ /* Calculate the userconf commands list size */
+ count = 0;
+ for (uc = userconf_commands; uc != NULL; uc = uc->uc_next)
+ count++;
+ len = sizeof(btinfo_userconfcommands) +
+ count * sizeof(struct bi_userconfcommand);
+
+ /* Allocate the userconf commands list */
+ btinfo_userconfcommands = alloc(len);
+ if (btinfo_userconfcommands == NULL) {
+ printf("WARNING: couldn't allocate userconf commands list\n");
+ return;
+ }
+ memset(btinfo_userconfcommands, 0, len);
+ btinfo_userconfcommands_size = len;
+
+ /* Fill in btinfo structure */
+ buf = (char *)btinfo_userconfcommands;
+ off = sizeof(*btinfo_userconfcommands);
+ btinfo_userconfcommands->num = 0;
+ for (uc = userconf_commands; uc != NULL; uc = uc->uc_next) {
+ struct bi_userconfcommand *bi;
+ bi = (struct bi_userconfcommand *)(buf + off);
+ strncpy(bi->text, uc->uc_text, sizeof(bi->text) - 1);
+
+ off += sizeof(*bi);
+ btinfo_userconfcommands->num++;
+ }
+}
+
int
exec_multiboot(const char *file, char *args)
{
diff -r 16c8d6410962 -r 8499b880fb49 sys/arch/i386/stand/lib/libi386.h
--- a/sys/arch/i386/stand/lib/libi386.h Thu May 26 02:37:25 2011 +0000
+++ b/sys/arch/i386/stand/lib/libi386.h Thu May 26 04:25:26 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: libi386.h,v 1.35 2011/02/21 00:39:54 dyoung Exp $ */
+/* $NetBSD: libi386.h,v 1.36 2011/05/26 04:25:27 uebayasi Exp $ */
/*
* Copyright (c) 1996
@@ -138,6 +138,7 @@
void module_add(char *);
void splash_add(char *);
+void userconf_add(char *);
struct btinfo_framebuffer;
void framebuffer_configure(struct btinfo_framebuffer *);
diff -r 16c8d6410962 -r 8499b880fb49 sys/arch/i386/stand/pxeboot/main.c
--- a/sys/arch/i386/stand/pxeboot/main.c Thu May 26 02:37:25 2011 +0000
+++ b/sys/arch/i386/stand/pxeboot/main.c Thu May 26 04:25:26 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.28 2011/03/18 18:21:38 jakllsch Exp $ */
+/* $NetBSD: main.c,v 1.29 2011/05/26 04:25:27 uebayasi Exp $ */
/*
* Copyright (c) 1996
@@ -76,6 +76,7 @@
{ "multiboot", command_multiboot },
{ "load", module_add },
{ "vesa", command_vesa },
+ { "userconf", userconf_add },
{ NULL, NULL },
};
@@ -201,6 +202,7 @@
"multiboot [filename] [<args>]\n"
"modules {on|off|enabled|disabled}\n"
"load {path_to_module}\n"
+ "userconf {command}\n"
"help|?\n"
Home |
Main Index |
Thread Index |
Old Index