[Midnightbsd-cvs] src [10199] trunk/sys/boot/forth/menu-commands.4th: update menu commands

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri Jun 1 19:57:15 EDT 2018


Revision: 10199
          http://svnweb.midnightbsd.org/src/?rev=10199
Author:   laffer1
Date:     2018-06-01 19:57:14 -0400 (Fri, 01 Jun 2018)
Log Message:
-----------
update menu commands

Modified Paths:
--------------
    trunk/sys/boot/forth/menu-commands.4th

Modified: trunk/sys/boot/forth/menu-commands.4th
===================================================================
--- trunk/sys/boot/forth/menu-commands.4th	2018-06-01 23:56:29 UTC (rev 10198)
+++ trunk/sys/boot/forth/menu-commands.4th	2018-06-01 23:57:14 UTC (rev 10199)
@@ -1,4 +1,4 @@
-\ Copyright (c) 2006-2013 Devin Teske <dteske at FreeBSD.org>
+\ Copyright (c) 2006-2015 Devin Teske <dteske at FreeBSD.org>
 \ All rights reserved.
 \ 
 \ Redistribution and use in source and binary forms, with or without
@@ -21,19 +21,23 @@
 \ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 \ SUCH DAMAGE.
-\ 
+\
 \ $MidnightBSD$
-\ $FreeBSD: stable/9/sys/boot/forth/menu-commands.4th 263701 2014-03-25 03:19:03Z dteske $
+\ $FreeBSD: stable/10/sys/boot/forth/menu-commands.4th 293802 2016-01-13 01:50:02Z allanjude $
 
 marker task-menu-commands.4th
 
 include /boot/menusets.4th
 
+only forth definitions
+
 variable kernel_state
 variable root_state
 0 kernel_state !
 0 root_state !
 
+also menu-namespace also menu-command-helpers
+
 \ 
 \ Boot
 \ 
@@ -68,7 +72,7 @@
 	evaluate
 ;
 
-: altboot ( -- )
+: altboot ( N -- NOTREACHED )
 	s" boot_single" 2dup getenv -1 <> if
 		drop ( c-addr/u c-addr -- c-addr/u ) \ unused
 		unsetenv ( c-addr/u -- )
@@ -347,3 +351,69 @@
 	verbose_disable
 	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



More information about the Midnightbsd-cvs mailing list