summaryrefslogtreecommitdiffstats
path: root/sys/boot/forth/menu-commands.4th
diff options
context:
space:
mode:
authorallanjude <allanjude@FreeBSD.org>2016-01-13 01:50:02 +0000
committerallanjude <allanjude@FreeBSD.org>2016-01-13 01:50:02 +0000
commite72f532e157a4f8c7f6ce72a3f59d2a2d865662b (patch)
treefeae895cdd35fc83efbdb3a5e6ead7ec7dbf874f /sys/boot/forth/menu-commands.4th
parent46a82c43e860b1c5e14e6808ca205ee9b5199616 (diff)
downloadFreeBSD-src-e72f532e157a4f8c7f6ce72a3f59d2a2d865662b.zip
FreeBSD-src-e72f532e157a4f8c7f6ce72a3f59d2a2d865662b.tar.gz
MFC: r293001
Introduce the ZFS Boot Environments menu to the loader menu MFC: r293414 Add ZFS Boot Environments menu to userboot MFC: r293454 Only call init_zfs_bootenv when the system is booted with ZFS MFC: r293612 Fix calling init_zfs_bootenv to early, resulting in empty ZFS BE menu Relnotes: yes Sponsored by: ScaleEngine Inc.
Diffstat (limited to 'sys/boot/forth/menu-commands.4th')
-rw-r--r--sys/boot/forth/menu-commands.4th64
1 files changed, 64 insertions, 0 deletions
diff --git a/sys/boot/forth/menu-commands.4th b/sys/boot/forth/menu-commands.4th
index 0784676..9adf30a 100644
--- a/sys/boot/forth/menu-commands.4th
+++ b/sys/boot/forth/menu-commands.4th
@@ -351,4 +351,68 @@ also menu-namespace also menu-command-helpers
2 goto_menu
;
+\
+\ Set boot environment defaults
+\
+
+: init_bootenv ( -- )
+ s" set menu_caption[1]=${bemenu_current}${vfs.root.mountfrom}" evaluate
+ s" set ansi_caption[1]=${beansi_current}${vfs.root.mountfrom}" evaluate
+ s" set menu_caption[2]=${bemenu_bootfs}${zfs_be_active}" evaluate
+ s" set ansi_caption[2]=${beansi_bootfs}${zfs_be_active}" evaluate
+ s" set menu_caption[3]=${bemenu_page}${zfs_be_currpage}${bemenu_pageof}${zfs_be_pages}" evaluate
+ s" set ansi_caption[3]=${beansi_page}${zfs_be_currpage}${bemenu_pageof}${zfs_be_pages}" evaluate
+;
+
+\
+\ Redraw the entire screen. A long BE name can corrupt the menu
+\
+
+: be_draw_screen
+ clear \ Clear the screen (in screen.4th)
+ print_version \ print version string (bottom-right; see version.4th)
+ draw-beastie \ Draw FreeBSD logo at right (in beastie.4th)
+ draw-brand \ Draw brand.4th logo at top (in brand.4th)
+ menu-init \ Initialize menu and draw bounding box (in menu.4th)
+;
+
+\
+\ Select a boot environment
+\
+
+: set_bootenv ( N -- N TRUE )
+ dup s" set vfs.root.mountfrom=${bootenv_root[E]}" 38 +c! evaluate
+ s" set currdev=${vfs.root.mountfrom}:" evaluate
+ s" unload" evaluate
+ free-module-options
+ s" /boot/defaults/loader.conf" read-conf
+ s" /boot/loader.conf" read-conf
+ s" /boot/loader.conf.local" read-conf
+ init_bootenv
+ be_draw_screen
+ menu-redraw
+ TRUE
+;
+
+\
+\ Switch to the next page of boot environments
+\
+
+: set_be_page ( N -- N TRUE )
+ s" zfs_be_currpage" getenv dup -1 = if
+ drop s" 1"
+ else
+ 0 s>d 2swap
+ >number ( ud caddr/u -- ud' caddr'/u' ) \ convert string to numbers
+ 2drop \ drop the string
+ 1 um/mod ( ud u1 -- u2 u3 ) \ convert double ud' to single u3' and remainder u2
+ swap drop ( ud2 u3 -- u3 ) \ drop the remainder u2
+ 1+ \ increment the page number
+ s>d <# #s #> \ convert back to a string
+ then
+ s" zfs_be_currpage" setenv
+ s" reloadbe" evaluate
+ 3 goto_menu
+;
+
only forth definitions
OpenPOWER on IntegriCloud