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

Daniel Khodabakhsh posted 1 patch 1 week, 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 1 week, 3 days ago
After poking around I realised boot-fail-wait supports a negative
integer input, so instead of introducing a new configuration I made a
change to support negative integer input for boot-menu-wait.
Please disregard the previous patch and consider this one instead:

From 17a5b1cd90a10661652911a541afc13b69709ebf Mon Sep 17 00:00:00 2001
From: Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
Date: Thu, 7 Nov 2024 18:46:16 -0800
Subject: [PATCH] Force display of the boot menu when boot-menu-wait is a
 negative number.

---
 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
From 17a5b1cd90a10661652911a541afc13b69709ebf Mon Sep 17 00:00:00 2001
From: Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
Date: Thu, 7 Nov 2024 18:46:16 -0800
Subject: [PATCH] Force display of the boot menu when boot-menu-wait is a
 negative number.

---
 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
[SeaBIOS] Re: [PATCH] Add force-boot-menu runtime configuration
Posted by Gerd Hoffmann 1 week, 1 day ago
On Mon, Nov 11, 2024 at 03:41:16AM +0000, Daniel Khodabakhsh wrote:
> After poking around I realised boot-fail-wait supports a negative
> integer input, so instead of introducing a new configuration I made a
> change to support negative integer input for boot-menu-wait.
> Please disregard the previous patch and consider this one instead:
> 
> From 17a5b1cd90a10661652911a541afc13b69709ebf Mon Sep 17 00:00:00 2001
> From: Daniel Khodabakhsh <d.khodabakhsh@gmail.com>
> Date: Thu, 7 Nov 2024 18:46:16 -0800
> Subject: [PATCH] Force display of the boot menu when boot-menu-wait is a
>  negative number.

Looks good to me.

take care,
  Gerd

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org