Add boot menu support

This patch adds boot menu support to SLOF. When boot menu is enabled from qemu
commandline with '-boot menu=on', on pressing F12 key it displays the list of
devices to boot from and waits for user's input. This is in line with x86 qemu
bios feature.

Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
This commit is contained in:
Avik Sil 2014-03-05 16:51:31 +05:30 committed by Nikunj A Dadhania
parent f1c40e50b5
commit 6180178869
2 changed files with 98 additions and 7 deletions

View File

@ -119,6 +119,18 @@ d# 512000000 VALUE tb-frequency \ default value - needed for "ms" to work
370 cp
: check-boot-menu
s" qemu,boot-menu" get-chosen IF
decode-int 1 = IF
." Press F12 for boot menu." cr cr
THEN
2drop
THEN
;
check-boot-menu
380 cp
\ Grab rtas from qemu
#include "rtas.fs"

View File

@ -44,7 +44,7 @@
key CASE
4f OF (function-key) ENDOF
5b OF
key key drop (function-key) ENDOF
key key (function-key) ENDOF
dup OF 0 ENDOF
ENDCASE
THEN
@ -68,18 +68,97 @@
\ Watchdog will be rearmed during load if use-load-watchdog variable is TRUE
TRUE VALUE use-load-watchdog?
1 value my-boot-dev
1 value digit-val
0 value boot-dev-no
: boot-selected
1 to my-boot-dev
BEGIN parse-word dup WHILE
boot-dev-no my-boot-dev = IF
s" boot " 2swap $cat
['] evaluate catch ?dup IF \ and execute it
." boot attempt returned: "
abort"-str @ count type cr
throw
THEN
0 0 load-list 2!
UNLOOP EXIT
ELSE
2drop
THEN
my-boot-dev 1 + to my-boot-dev
REPEAT 2drop 0 0 load-list 2!
(boot)
;
: boot-start
\ Remove multiple F12 key presses if any
BEGIN key? WHILE
key drop
REPEAT
decimal
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
dup isdigit IF
dup 30 - to digit-val
boot-dev-no a * digit-val + to boot-dev-no
THEN
d = UNTIL
boot-dev-no my-boot-dev < IF
s" boot-selected " s" $bootdev" evaluate $cat strdup evaluate
ELSE
." Invalid choice!" cr
THEN
hex
;
: boot-menu-start
." Select boot device:" cr cr
s" boot-start " s" $bootdev" evaluate $cat strdup evaluate
;
: boot-menu-enabled? ( -- true|false )
s" qemu,boot-menu" get-chosen IF
decode-int 1 = IF
2drop TRUE EXIT
THEN
2drop
THEN
FALSE
;
: f12-pressed?
34 = >r 32 = r> and IF
TRUE
ELSE
FALSE
THEN
;
: start-it ( -- )
key? IF
key CASE
[char] s OF (s-pressed) ENDOF
1b OF
(esc-sequence) CASE
1 OF console-clean-fifo sms-start (boot) ENDOF
dup OF (boot?) ENDOF
ENDCASE
(esc-sequence) CASE
1 OF
console-clean-fifo
f12-pressed? boot-menu-enabled? and IF
boot-menu-start
ELSE
(boot?)
THEN
ENDOF
dup OF (boot?) ENDOF
ENDCASE
ENDOF
dup OF (boot?) ENDOF
ENDCASE