From 6180178869e65de2d666609d1b9a050e20d09edc Mon Sep 17 00:00:00 2001 From: Avik Sil Date: Wed, 5 Mar 2014 16:51:31 +0530 Subject: [PATCH] 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 Signed-off-by: Nikunj A Dadhania --- board-qemu/slof/OF.fs | 12 ++++++ slof/fs/start-up.fs | 93 +++++++++++++++++++++++++++++++++++++++---- 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