Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src/sys/arch/i386/stand Pull up following revision(s) (reques...



details:   https://anonhg.NetBSD.org/src/rev/91224976f20f
branches:  netbsd-6
changeset: 776416:91224976f20f
user:      riz <riz%NetBSD.org@localhost>
date:      Sat Aug 10 22:42:29 2013 +0000

description:
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).

diffstat:

 sys/arch/i386/stand/boot/boot2.c   |  30 ++++++++++++++-
 sys/arch/i386/stand/lib/bootmenu.c |  74 ++++++++++++++++++++++++++-----------
 sys/arch/i386/stand/lib/bootmenu.h |   3 +-
 3 files changed, 82 insertions(+), 25 deletions(-)

diffs (195 lines):

diff -r ab0d8d338a4c -r 91224976f20f sys/arch/i386/stand/boot/boot2.c
--- a/sys/arch/i386/stand/boot/boot2.c  Thu Aug 08 21:59:43 2013 +0000
+++ b/sys/arch/i386/stand/boot/boot2.c  Sat Aug 10 22:42:29 2013 +0000
@@ -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_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 @@
        { "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 @@
               "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 @@
                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 @@
        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)
 {
diff -r ab0d8d338a4c -r 91224976f20f sys/arch/i386/stand/lib/bootmenu.c
--- a/sys/arch/i386/stand/lib/bootmenu.c        Thu Aug 08 21:59:43 2013 +0000
+++ b/sys/arch/i386/stand/lib/bootmenu.c        Sat Aug 10 22:42:29 2013 +0000
@@ -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 @@
        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 @@
                        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);
                }
 
        }
diff -r ab0d8d338a4c -r 91224976f20f sys/arch/i386/stand/lib/bootmenu.h
--- a/sys/arch/i386/stand/lib/bootmenu.h        Thu Aug 08 21:59:43 2013 +0000
+++ b/sys/arch/i386/stand/lib/bootmenu.h        Sat Aug 10 22:42:29 2013 +0000
@@ -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 {



Home | Main Index | Thread Index | Old Index