[SLOF] [PATCH] Improve F12 key handling in boot menu

Thomas Huth thuth at redhat.com
Wed May 25 21:00:26 AEST 2016

When hitting F12 during boot multiple times (to make sure that you get
to the boot menu), it is sometimes impossible to select a menu entry
from the boot list - you always get the output "Invalid choice!" and
are dropped to the SLOF prompt.

The "boot-start" function already has some code at the beginning to
flush the keyboard input to get rid of multiple F12 keys. But if you
accidentially press F12 again after that code has been executed,
the code that checks the input for the selected boot menu entry
can not handle it and gets confused.

Fix this issue by flushing the keyboard input queue as late as possible
(i.e. after printing the boot menu items, since that could also take
a short while when the list is long and when using slow VGA text
output), and by ignoring all key sequences that start with an ESC
(like the F12 key ESC sequence) in the main keyboard input loop there.

Signed-off-by: Thomas Huth <thuth at redhat.com>
 slof/fs/start-up.fs | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/slof/fs/start-up.fs b/slof/fs/start-up.fs
index fb88f76..dc5d1ed 100644
--- a/slof/fs/start-up.fs
+++ b/slof/fs/start-up.fs
@@ -91,18 +91,27 @@ TRUE VALUE use-load-watchdog?
 : boot-start
-   \ Remove multiple F12 key presses if any
-   BEGIN key? WHILE
-      key drop
    BEGIN parse-word dup WHILE
       my-boot-dev (u.) s" . " $cat type 2dup type ." : " de-alias type cr
       my-boot-dev 1 + to my-boot-dev
    REPEAT 2drop 0 0 load-list 2!
-   cr BEGIN KEY dup emit
+   \ Clear pending keys (to remove multiple F12 key presses for example)
+   BEGIN key? WHILE
+      key drop
+   cr
+      KEY
+      dup 1b = IF         \ ESC sequence ... could be yet another F12 key press
+         BEGIN key? WHILE
+            key drop
+         REPEAT
+      ELSE
+         dup emit
+      THEN
       dup isdigit IF
          dup 30 - to digit-val
          boot-dev-no a * digit-val + to boot-dev-no

More information about the SLOF mailing list