summaryrefslogtreecommitdiff
path: root/usr/src/boot/forth/menu-commands.4th
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/boot/forth/menu-commands.4th')
-rw-r--r--usr/src/boot/forth/menu-commands.4th114
1 files changed, 114 insertions, 0 deletions
diff --git a/usr/src/boot/forth/menu-commands.4th b/usr/src/boot/forth/menu-commands.4th
index 5fe6c8c62f..4938608fb5 100644
--- a/usr/src/boot/forth/menu-commands.4th
+++ b/usr/src/boot/forth/menu-commands.4th
@@ -41,6 +41,43 @@ variable kmdb_state
also menu-namespace also menu-command-helpers
+\ PATH_MAX + 6
+create chaincmd 1030 chars allot
+
+\
+\ Rollback to previous platform image.
+\ Used by Joyent Triton
+\
+: rollback_boot ( N -- NOTREACHED )
+ dup
+ s" prev-platform" getenv s" bootfile" setenv
+ s" prev-archive" getenv s" boot_archive" set-module-path
+ s" prev-hash" getenv s" boot_archive.hash" set-module-path
+ 0 boot ( state -- )
+;
+
+\
+\ Boot from ipxe kernel
+\ Used by Joyent Triton when booted in BIOS/CSM mode
+\
+: ipxe_boot ( N -- NOTREACHED )
+ dup
+ s" ipxe-bootfile" getenv s" bootfile" setenv
+ s" ipxe-archive" getenv s" boot_archive" set-module-path
+ s" boot_archive.hash" disable-module
+ 0 boot ( state -- )
+;
+
+\
+\ Chainload the ipxe EFI binary
+\ Used by Joyent Triton when booted in UEFI mode
+\
+: ipxe_chainload ( N -- NOTREACHED )
+ s" chain " chaincmd place
+ s" ipxe-efi" getenv chaincmd append
+ chaincmd count evaluate
+;
+
\
\ Boot
\
@@ -102,6 +139,25 @@ also menu-namespace also menu-command-helpers
;
\
+\ Platform-image selection for standalone SmartOS is mostly in pi.rc.
+\ We will also steal a boot environment routine in pi_draw_screen (way below).
+
+: init_pi ( -- )
+ s" bootpi" getenv? 0= if
+ s" default" s" bootpi" setenv
+ then
+
+ \ Reset the "options" text to show current bootpi selected.
+ s" set menu_optionstext=${pitext}${bootpi}" evaluate
+ s" set pimenu_optionstext=${pitext}${bootpi}" evaluate
+;
+
+\ Shorter than inlining this in pi.rc.
+: pi_unload ( -- )
+ s" unload" evaluate
+;
+
+\
\ Single User Mode
\
@@ -246,6 +302,53 @@ also menu-namespace also menu-command-helpers
;
\
+\ Disaster Recovery boot
+\
+
+: rescue_enabled? ( -- flag )
+ s" noimport" getenv -1 <> dup if
+ swap drop ( c-addr flag -- flag )
+ then
+;
+
+: rescue_enable ( -- )
+ s" set noimport=true" evaluate
+ s" smartos" getenv? if
+ s" set standalone=true" evaluate
+ s" set smartos=false" evaluate
+ then
+;
+
+: rescue_disable ( -- )
+ s" noimport" unsetenv
+ s" standalone" unsetenv
+ s" smartos" getenv? if
+ s" set smartos=true" evaluate
+ then
+;
+
+: init_rescue ( N -- N )
+ rescue_enabled? if
+ toggle_menuitem ( n -- n )
+ then
+;
+
+: toggle_rescue ( N -- N TRUE )
+ toggle_menuitem
+ menu-redraw
+
+ \ Now we're going to make the change effective
+
+ dup toggle_stateN @ 0= if
+ rescue_disable
+ else
+ rescue_enable
+ then
+
+ TRUE \ loop menu again
+;
+
+\
\ Escape to Prompt
\
@@ -505,6 +608,17 @@ also menu-namespace also menu-command-helpers
menu-init \ Initialize menu and draw bounding box (in menu.4th)
;
+\ PI reuse of be_draw_screen, plus some other things to be used by pi.rc.
+
+: pi_draw_screen ( -- TRUE )
+ \ So we can make SURE we have the current boot PI on display.
+ init_pi
+
+ be_draw_screen
+ menu-redraw
+ TRUE
+;
+
\
\ Select a boot environment
\