Module Name: src Committed By: riz Date: Sat Aug 10 22:42:29 UTC 2013
Modified Files: src/sys/arch/i386/stand/boot [netbsd-6]: boot2.c src/sys/arch/i386/stand/lib [netbsd-6]: bootmenu.c bootmenu.h Log Message: Pull up following revision(s) (requested by he in ticket #925): sys/arch/i386/stand/lib/bootmenu.c: revision 1.11 sys/arch/i386/stand/lib/bootmenu.h: revision 1.3 sys/arch/i386/stand/boot/boot2.c: revision 1.59 Two changes for the i386 boot loader related to the boot menu which can be defined in boot.cfg: * Add a "menu" command which re-displays the menu and initiates the timed countdown * Use any default command defined in boot.cfg as default args if the user runs "boot" with no arguments This is useful in circumstances where you e.g. need to interrupt the normal boot process to switch to serial console, and where simply "boot netbsd" is no longer sufficient (e.g. as with install media which needs the miniroot kernel module loaded). To generate a diff of this commit: cvs rdiff -u -r1.57.2.1 -r1.57.2.2 src/sys/arch/i386/stand/boot/boot2.c cvs rdiff -u -r1.10 -r1.10.8.1 src/sys/arch/i386/stand/lib/bootmenu.c cvs rdiff -u -r1.2 -r1.2.26.1 src/sys/arch/i386/stand/lib/bootmenu.h 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.57.2.1 src/sys/arch/i386/stand/boot/boot2.c:1.57.2.2 --- src/sys/arch/i386/stand/boot/boot2.c:1.57.2.1 Sun Aug 12 18:56:54 2012 +++ src/sys/arch/i386/stand/boot/boot2.c Sat Aug 10 22:42:29 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: boot2.c,v 1.57.2.1 2012/08/12 18:56:54 martin Exp $ */ +/* $NetBSD: boot2.c,v 1.57.2.2 2013/08/10 22:42:29 riz Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -120,6 +120,9 @@ void command_quit(char *); void command_boot(char *); void command_dev(char *); void command_consdev(char *); +#ifndef SMALL +void command_menu(char *); +#endif void command_modules(char *); void command_multiboot(char *); @@ -131,6 +134,9 @@ const struct bootblk_command commands[] { "boot", command_boot }, { "dev", command_dev }, { "consdev", command_consdev }, +#ifndef SMALL + { "menu", command_menu }, +#endif { "modules", command_modules }, { "load", module_add }, { "multiboot", command_multiboot }, @@ -394,6 +400,9 @@ command_help(char *arg) "dev xd[N[x]]:\n" "consdev {pc|com[0123]|com[0123]kbd|auto}\n" "vesa {modenum|on|off|enabled|disabled|list}\n" +#ifndef SMALL + "menu (reenters boot menu, if defined in boot.cfg)\n" +#endif "modules {on|off|enabled|disabled}\n" "load {path_to_module}\n" "multiboot [xdNx:][filename] [<args>]\n" @@ -439,6 +448,10 @@ command_boot(char *arg) bootit(filename, howto, tell); } else { int i; + +#ifndef SMALL + bootdefault(); +#endif for (i = 0; i < NUMNAMES; i++) { bootit(names[i][0], howto, tell); bootit(names[i][1], howto, tell); @@ -504,6 +517,21 @@ command_consdev(char *arg) printf("invalid console device.\n"); } +#ifndef SMALL +/* ARGSUSED */ +void +command_menu(char *arg) +{ + + if (bootconf.nummenu > 0) { + /* Does not return */ + doboottypemenu(); + } else { + printf("No menu defined in boot.cfg\n"); + } +} +#endif /* !SMALL */ + void command_modules(char *arg) { Index: src/sys/arch/i386/stand/lib/bootmenu.c diff -u src/sys/arch/i386/stand/lib/bootmenu.c:1.10 src/sys/arch/i386/stand/lib/bootmenu.c:1.10.8.1 --- src/sys/arch/i386/stand/lib/bootmenu.c:1.10 Thu Aug 18 13:20:04 2011 +++ src/sys/arch/i386/stand/lib/bootmenu.c Sat Aug 10 22:42:29 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: bootmenu.c,v 1.10 2011/08/18 13:20:04 christos Exp $ */ +/* $NetBSD: bootmenu.c,v 1.10.8.1 2013/08/10 22:42:29 riz Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -41,6 +41,8 @@ #define isnum(c) ((c) >= '0' && (c) <= '9') +static void docommandchoice(int); + extern struct x86_boot_params boot_params; extern const char bootprog_name[], bootprog_rev[], bootprog_kernrev[]; @@ -297,11 +299,57 @@ getchoicefrominput(char *input, int def) return choice; } +static void +docommandchoice(int choice) +{ + char input[80], *ic, *oc; + + ic = bootconf.command[choice]; + /* Split command string at ; into separate commands */ + do { + oc = input; + /* Look for ; separator */ + for (; *ic && *ic != COMMAND_SEPARATOR; ic++) + *oc++ = *ic; + if (*input == '\0') + continue; + /* Strip out any trailing spaces */ + oc--; + for (; *oc == ' ' && oc > input; oc--); + *++oc = '\0'; + if (*ic == COMMAND_SEPARATOR) + ic++; + /* Stop silly command strings like ;;; */ + if (*input != '\0') + docommand(input); + /* Skip leading spaces */ + for (; *ic == ' '; ic++); + } while (*ic); +} + +void +bootdefault(void) +{ + int choice; + static int entered; + + if (bootconf.nummenu > 0) { + if (entered) { + printf("default boot twice, skipping...\n"); + return; + } + entered = 1; + choice = bootconf.def; + printf("command(s): %s\n", bootconf.command[choice]); + docommandchoice(choice); + } +} + void doboottypemenu(void) { int choice; - char input[80], *ic, *oc; + char input[80]; printf("\n"); /* Display menu */ @@ -357,27 +405,7 @@ doboottypemenu(void) printf("type \"?\" or \"help\" for help.\n"); bootmenu(); /* does not return */ } else { - ic = bootconf.command[choice]; - /* Split command string at ; into separate commands */ - do { - oc = input; - /* Look for ; separator */ - for (; *ic && *ic != COMMAND_SEPARATOR; ic++) - *oc++ = *ic; - if (*input == '\0') - continue; - /* Strip out any trailing spaces */ - oc--; - for (; *oc == ' ' && oc > input; oc--); - *++oc = '\0'; - if (*ic == COMMAND_SEPARATOR) - ic++; - /* Stop silly command strings like ;;; */ - if (*input != '\0') - docommand(input); - /* Skip leading spaces */ - for (; *ic == ' '; ic++); - } while (*ic); + docommandchoice(choice); } } Index: src/sys/arch/i386/stand/lib/bootmenu.h diff -u src/sys/arch/i386/stand/lib/bootmenu.h:1.2 src/sys/arch/i386/stand/lib/bootmenu.h:1.2.26.1 --- src/sys/arch/i386/stand/lib/bootmenu.h:1.2 Sat Dec 13 23:30:54 2008 +++ src/sys/arch/i386/stand/lib/bootmenu.h Sat Aug 10 22:42:29 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: bootmenu.h,v 1.2 2008/12/13 23:30:54 christos Exp $ */ +/* $NetBSD: bootmenu.h,v 1.2.26.1 2013/08/10 22:42:29 riz Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -36,6 +36,7 @@ void parsebootconf(const char *); void doboottypemenu(void); +void bootdefault(void); int atoi(const char *); struct bootconf_def {