[SeaBIOS] Re: [PATCH] Add force-boot-menu runtime configuration

Daniel Khodabakhsh posted 1 patch 2 weeks, 3 days ago
docs/Runtime_config.md |  2 +-
src/boot.c             | 29 ++++++++++++++++-------------
2 files changed, 17 insertions(+), 14 deletions(-)
[SeaBIOS] Re: [PATCH] Add force-boot-menu runtime configuration
Posted by Daniel Khodabakhsh 2 weeks, 3 days ago
>
> Thanks.  Looks fine to me, but a patch would require a signed-off-by
> line - see: https://www.seabios.org/Contributing
>

Apologies, alright I've added the sign-off line, here is my patch:

Force display of the boot menu when boot-menu-wait is a negative number.

Signed-off-by: Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
---
 docs/Runtime_config.md |  2 +-
 src/boot.c             | 29 ++++++++++++++++-------------
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/docs/Runtime_config.md b/docs/Runtime_config.md
index 5795382b..f5e0cbd5 100644
--- a/docs/Runtime_config.md
+++ b/docs/Runtime_config.md
@@ -176,7 +176,7 @@ There are several additional configuration options
available in the
 | show-boot-menu      | Controls the display of the boot menu. Valid
values are 0: Disable the boot menu, 1: Display boot menu
unconditionally, 2: Skip boot menu if only one device is present. The
default is 1.
 | boot-menu-message   | Customize the text boot menu message.
Normally, when in text mode SeaBIOS will report the string "\\nPress
ESC for boot menu.\\n\\n". This field allows the string to be changed.
(This is a string field, and is added as a file containing the raw
string.)
 | boot-menu-key       | Controls which key activates the boot menu.
The value stored is the DOS scan code (eg, 0x86 for F12, 0x01 for
Esc). If this field is set, be sure to also customize the
**boot-menu-message** field above.
-| boot-menu-wait      | Amount of time (in milliseconds) to wait at
the boot menu prompt before selecting the default boot.
+| boot-menu-wait      | Amount of time (in milliseconds) to wait at
the boot menu prompt before selecting the default boot. Set to a
negative number such as -1 to force the display of the boot menu.
 | boot-fail-wait      | If no boot devices are found SeaBIOS will
reboot after 60 seconds. Set this to the amount of time (in
milliseconds) to customize the reboot delay or set to -1 to disable
rebooting when no boot devices are found
 | extra-pci-roots     | If the target machine has multiple
independent root buses set this to a positive value. The SeaBIOS PCI
probe will then search for the given number of extra root buses.
 | ps2-keyboard-spinup | Some laptops that emulate PS2 keyboards don't
respond to keyboard commands immediately after powering on. One may
specify the amount of time (in milliseconds) here to allow as
additional time for the keyboard to become responsive. When this field
is set, SeaBIOS will repeatedly attempt to detect the keyboard until
the keyboard is found or the specified timeout is reached.
diff --git a/src/boot.c b/src/boot.c
index 1effd802..5c37dafd 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -708,20 +708,23 @@ interactive_bootmenu(void)
         return;
     }

-    while (get_keystroke(0) >= 0)
-        ;
-
-    char *bootmsg = romfile_loadfile("etc/boot-menu-message", NULL);
+    int menutime = romfile_loadint("etc/boot-menu-wait",
DEFAULT_BOOTMENU_WAIT);
     int menukey = romfile_loadint("etc/boot-menu-key", 1);
-    printf("%s", bootmsg ?: "\nPress ESC for boot menu.\n\n");
-    free(bootmsg);
-
-    u32 menutime = romfile_loadint("etc/boot-menu-wait",
DEFAULT_BOOTMENU_WAIT);
-    enable_bootsplash();
-    int scan_code = get_keystroke(menutime);
-    disable_bootsplash();
-    if (scan_code != menukey)
-        return;
+    int scan_code;
+    if (menutime >= 0) {
+        while (get_keystroke(0) >= 0)
+            ;
+
+        char *bootmsg = romfile_loadfile("etc/boot-menu-message", NULL);
+        printf("%s", bootmsg ?: "\nPress ESC for boot menu.\n\n");
+        free(bootmsg);
+
+        enable_bootsplash();
+        scan_code = get_keystroke(menutime);
+        disable_bootsplash();
+        if (scan_code != menukey)
+            return;
+    }

     while (get_keystroke(0) >= 0)
         ;
-- 
2.46.0
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org