aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvik Sil <aviksil@linux.vnet.ibm.com>2014-03-05 16:51:31 +0530
committerNikunj A Dadhania <nikunj@linux.vnet.ibm.com>2014-06-13 12:33:54 +0530
commit6180178869e65de2d666609d1b9a050e20d09edc (patch)
tree9ad66d083142bf4d138405a0dd6e53173a93e0ed
parentf1c40e50b5f58c28eae6949a8ee0525ed7da959a (diff)
downloadSLOF-6180178869e65de2d666609d1b9a050e20d09edc.zip
SLOF-6180178869e65de2d666609d1b9a050e20d09edc.tar.gz
SLOF-6180178869e65de2d666609d1b9a050e20d09edc.tar.bz2
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>
-rw-r--r--board-qemu/slof/OF.fs12
-rw-r--r--slof/fs/start-up.fs93
2 files changed, 98 insertions, 7 deletions
diff --git a/board-qemu/slof/OF.fs b/board-qemu/slof/OF.fs
index 0ed4225..561d892 100644
--- a/board-qemu/slof/OF.fs
+++ b/board-qemu/slof/OF.fs
@@ -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"
diff --git a/slof/fs/start-up.fs b/slof/fs/start-up.fs
index 0ce0f3c..f1488fa 100644
--- a/slof/fs/start-up.fs
+++ b/slof/fs/start-up.fs
@@ -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