Current-Users archive

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

Re: Patch for boot loader: "menu" command



>> > How about change "boot" to use whatever boot.cfg says is the default
>> > boot option, and "boot ...anything..." to be the override-the-menu
>> > command?
>>
>> How does the attached look?  It should implement the suggested idea.
>
> The changes you propose sound like a good idea, however, I'm not sure
> I completely understand how the bootloader is changing.  Do you mind
> "prototyping" the interaction in an email?  I.e., simulate a typescript
> of someone operating bootloader with the changes in place?  [It may be
> less trouble to create an actual typescript. :-)]

Sure, I'll give it a try:

[ First boot-up will display on VGA: ]

Welcome to the NetBSD 5.3 installation CD
=========================================================================

ACPI should work on all modern and legacy hardware, however if you have 
problems, please try disabling it.

If you encounter problems on hardware manufactured after 1998 with ACPI
enabled, please file a problem report including output from the 'dmesg'
command.

1) Install NetBSD
2) Install NetBSD (no ACPI)
3) Install NetBSD (no ACPI, no SMP)
4) Drop to boot prompt

Choose an option; RETURN for default; SPACE to stop countdown.

Option 1 will be chosen in 30

[ press "4" using the PC keyboard ]

type "?" or "help" for help.
> consdev com0

[ ...and on the com0 serial port you will get: ]

Welcome to the NetBSD 5.3 installation CD
===============================================================================

ACPI should work on all modern and legacy hardware, however if you have 
problems, please try disabling it.

If you encounter problems on hardware manufactured after 1998 with ACPI
enabled, please file a problem report including output from the 'dmesg'
command.
> 

[ Now, with my diff, if you simply do "boot", you will instead of
  just cycling through the kernel names the boot loader knows
  about, you will instead get the command from the default menu
  entry: ]

> boot
command(s): load /miniroot.kmod;boot netbsd
booting cd0a:netbsd
10089136+518916+618576 [521152+509152]=0xbb28d8
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All

etc.


This is with the slightly modified diff, attached.

One problem is that if boot.cfg only contains "boot" as a
command, that will create an infinite loop in the boot loader.  I
can add a static int to allow bootdefault()'s body only to be
invoked once, breaking this loop.

I still think it's a good idea to add the "menu" command, in that
case the interaction could go something like this:


[ First boot-up will display on VGA: ]

Welcome to the NetBSD 5.3 installation CD
=========================================================================

ACPI should work on all modern and legacy hardware, however if you have 
problems, please try disabling it.

If you encounter problems on hardware manufactured after 1998 with ACPI
enabled, please file a problem report including output from the 'dmesg'
command.

1) Install NetBSD
2) Install NetBSD (no ACPI)
3) Install NetBSD (no ACPI, no SMP)
4) Drop to boot prompt

Choose an option; RETURN for default; SPACE to stop countdown.

Option 1 will be chosen in 30

[ press "4" using the PC keyboard ]

type "?" or "help" for help.
> consdev com0

[ ...and on the com0 serial port you will get: ]

Welcome to the NetBSD 5.3 installation CD
===============================================================================

ACPI should work on all modern and legacy hardware, however if you have 
problems, please try disabling it.

If you encounter problems on hardware manufactured after 1998 with ACPI
enabled, please file a problem report including output from the 'dmesg'
command.
> 
> menu
Welcome to the NetBSD 5.3 installation CD
=========================================================================

ACPI should work on all modern and legacy hardware, however if you have 
problems, please try disabling it.

If you encounter problems on hardware manufactured after 1998 with ACPI
enabled, please file a problem report including output from the 'dmesg'
command.

1) Install NetBSD
2) Install NetBSD (no ACPI)
3) Install NetBSD (no ACPI, no SMP)
4) Drop to boot prompt

Choose an option; RETURN for default; SPACE to stop countdown.

Option 1 will be chosen in 30

[ and you can then chose whichever option you want ]

Regards,

- Håvard
Index: boot/boot2.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/boot/boot2.c,v
retrieving revision 1.58
diff -u -r1.58 boot2.c
--- boot/boot2.c        4 Aug 2012 03:51:27 -0000       1.58
+++ boot/boot2.c        26 Jul 2013 18:26:50 -0000
@@ -439,6 +439,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);
Index: lib/bootmenu.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/lib/bootmenu.c,v
retrieving revision 1.10
diff -u -r1.10 bootmenu.c
--- lib/bootmenu.c      18 Aug 2011 13:20:04 -0000      1.10
+++ lib/bootmenu.c      26 Jul 2013 18:26:50 -0000
@@ -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,51 @@
        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;
+
+       if (bootconf.nummenu > 0) {
+               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 +399,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);
                }
 
        }
Index: lib/bootmenu.h
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/lib/bootmenu.h,v
retrieving revision 1.2
diff -u -r1.2 bootmenu.h
--- lib/bootmenu.h      13 Dec 2008 23:30:54 -0000      1.2
+++ lib/bootmenu.h      26 Jul 2013 18:26:50 -0000
@@ -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