svn commit: r254109 - stable/9/sys/boot/forth

Devin Teske dteske at FreeBSD.org
Thu Aug 8 22:49:22 UTC 2013


Author: dteske
Date: Thu Aug  8 22:49:18 2013
New Revision: 254109
URL: http://svnweb.freebsd.org/changeset/base/254109

Log:
  Synchronize stable/9 Forth code with head via MFC of 22 revisions:
  227727, 233941, 235560, 238431, 241310, 241361, 241363, 241365, 241367,
  241523, 242667-242669, 242923, 243114, 243660, 244048, 244089, 244158,
  253715, 254105, and 254108.
  
  This includes critical fixes that sadly should have been merged prior.
  Namely, SVN r244158 fixes a possible regression.

Added:
  stable/9/sys/boot/forth/menusets.4th
     - copied, changed from r242667, head/sys/boot/forth/menusets.4th
  stable/9/sys/boot/forth/menusets.4th.8
     - copied unchanged from r242667, head/sys/boot/forth/menusets.4th.8
Modified:
  stable/9/sys/boot/forth/beastie.4th
  stable/9/sys/boot/forth/beastie.4th.8
  stable/9/sys/boot/forth/brand.4th
  stable/9/sys/boot/forth/brand.4th.8
  stable/9/sys/boot/forth/check-password.4th
  stable/9/sys/boot/forth/check-password.4th.8
  stable/9/sys/boot/forth/color.4th
  stable/9/sys/boot/forth/color.4th.8
  stable/9/sys/boot/forth/delay.4th
  stable/9/sys/boot/forth/delay.4th.8
  stable/9/sys/boot/forth/frames.4th
  stable/9/sys/boot/forth/loader.4th
  stable/9/sys/boot/forth/loader.4th.8
  stable/9/sys/boot/forth/loader.conf
  stable/9/sys/boot/forth/loader.conf.5
  stable/9/sys/boot/forth/loader.rc
  stable/9/sys/boot/forth/menu-commands.4th
  stable/9/sys/boot/forth/menu.4th
  stable/9/sys/boot/forth/menu.4th.8
  stable/9/sys/boot/forth/menu.rc
  stable/9/sys/boot/forth/shortcuts.4th
  stable/9/sys/boot/forth/support.4th
  stable/9/sys/boot/forth/version.4th
  stable/9/sys/boot/forth/version.4th.8
Directory Properties:
  stable/9/sys/boot/forth/   (props changed)

Modified: stable/9/sys/boot/forth/beastie.4th
==============================================================================
--- stable/9/sys/boot/forth/beastie.4th	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/beastie.4th	Thu Aug  8 22:49:18 2013	(r254109)
@@ -1,6 +1,6 @@
 \ Copyright (c) 2003 Scott Long <scottl at freebsd.org>
 \ Copyright (c) 2003 Aleksander Fafula <alex at fafula.com>
-\ Copyright (c) 2006-2011 Devin Teske <devinteske at hotmail.com>
+\ Copyright (c) 2006-2013 Devin Teske <dteske at FreeBSD.org>
 \ All rights reserved.
 \ 
 \ Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,6 @@
 
 marker task-beastie.4th
 
-include /boot/color.4th
 include /boot/delay.4th
 
 variable logoX
@@ -182,8 +181,8 @@ variable logoY
 \ 	beastie     Color ``Helper Daemon'' mascot (19 rows x 34 columns)
 \ 	beastiebw   B/W ``Helper Daemon'' mascot (19 rows x 34 columns)
 \ 	fbsdbw      "FreeBSD" logo in B/W (13 rows x 21 columns)
-\ 	orb         Color ``Orb'' mascot (15 rows x 30 columns)
-\ 	orbbw       B/W ``Orb'' mascot (15 rows x 32 columns) (default)
+\ 	orb         Color ``Orb'' mascot (15 rows x 30 columns) (default)
+\ 	orbbw       B/W ``Orb'' mascot (15 rows x 32 columns)
 \ 
 \ NOTE: Setting `loader_logo' to an undefined value (such as "none") will
 \       prevent beastie from being drawn.

Modified: stable/9/sys/boot/forth/beastie.4th.8
==============================================================================
--- stable/9/sys/boot/forth/beastie.4th.8	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/beastie.4th.8	Thu Aug  8 22:49:18 2013	(r254109)
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2011 Devin Teske
+.\" Copyright (c) 2011-2012 Devin Teske
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -94,8 +94,9 @@ The
 variable can be configured in
 .Xr loader.conf 5
 to the number of seconds you would like to delay loading the boot menu.
-During the delay the user can press Ctrl-C to fall back to autoboot or ENTER
-to proceed.
+During the delay the user can press Ctrl-C to fall back to
+.Ic autoboot
+or ENTER to proceed.
 The default behavior is to not delay.
 .El
 .Pp
@@ -168,4 +169,4 @@ set of commands was written by
 .An Scott Long Aq scottl at FreeBSD.org ,
 .An Aleksander Fafula Aq alex at fafula.com
 and
-.An Devin Teske Aq devinteske at hotmail.com .
+.An Devin Teske Aq dteske at FreeBSD.org .

Modified: stable/9/sys/boot/forth/brand.4th
==============================================================================
--- stable/9/sys/boot/forth/brand.4th	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/brand.4th	Thu Aug  8 22:49:18 2013	(r254109)
@@ -1,4 +1,4 @@
-\ Copyright (c) 2006-2011 Devin Teske <devinteske at hotmail.com>
+\ Copyright (c) 2006-2011 Devin Teske <dteske at FreeBSD.org>
 \ All rights reserved.
 \ 
 \ Redistribution and use in source and binary forms, with or without

Modified: stable/9/sys/boot/forth/brand.4th.8
==============================================================================
--- stable/9/sys/boot/forth/brand.4th.8	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/brand.4th.8	Thu Aug  8 22:49:18 2013	(r254109)
@@ -122,4 +122,4 @@ The
 .Nm
 set of commands was written by
 .An -nosplit
-.An Devin Teske Aq devinteske at hotmail.com .
+.An Devin Teske Aq dteske at FreeBSD.org .

Modified: stable/9/sys/boot/forth/check-password.4th
==============================================================================
--- stable/9/sys/boot/forth/check-password.4th	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/check-password.4th	Thu Aug  8 22:49:18 2013	(r254109)
@@ -1,4 +1,4 @@
-\ Copyright (c) 2006-2011 Devin Teske <devinteske at hotmail.com>
+\ Copyright (c) 2006-2012 Devin Teske <dteske at FreeBSD.org>
 \ All rights reserved.
 \ 
 \ Redistribution and use in source and binary forms, with or without
@@ -74,7 +74,7 @@ variable readlen        \ input length
    again
 ;
 
-: read ( -- String prompt )
+: read ( String prompt -- )
 
 	0 25 at-xy           \ Move the cursor to the bottom-left
 	dup 1+ read-start !  \ Store X offset after the prompt
@@ -134,23 +134,37 @@ variable readlen        \ input length
 
 : check-password ( -- )
 
-	\ Exit if a password was not set
-	s" password" getenv dup -1 = if
-		drop exit
+	\ Do not allow the user to proceed beyond this point if a boot-lock
+	\ password has been set (preventing even boot from proceeding)
+	s" bootlock_password" getenv dup -1 <> if
+		begin
+			s" Boot Password: " read ( prompt -- )
+			2dup readval readlen @ compare 0<>
+		while
+			3000 ms ." loader: incorrect password" 10 emit
+		repeat
+		2drop ( c-addr/u )
+	else
+		drop ( -1 ) \ getenv cruft
 	then
 
-	begin \ Loop as long as it takes to get the right password
+	\ Exit if a password was not set
+	s" password" getenv -1 = if exit else drop then
+
+	\ We should prevent the user from visiting the menu or dropping to the
+	\ interactive loader(8) prompt, but still allow the machine to boot...
 
-		s" Password: " \ Output a prompt for a password
-		read           \ Read the user's input until Enter
+	0 autoboot
 
+	\ Only reached if autoboot fails for any reason (including if/when
+	\ the user aborts/escapes the countdown sequence leading to boot).
+
+	s" password" getenv
+	begin
+		s" Password: " read ( prompt -- )
 		2dup readval readlen @ compare 0= if
 			2drop exit \ Correct password
 		then
-
-		\ Bad Password
-		3000 ms
-		." loader: incorrect password" 10 emit
-
-	again \ Not the right password; repeat
+		3000 ms ." loader: incorrect password" 10 emit
+	again
 ;

Modified: stable/9/sys/boot/forth/check-password.4th.8
==============================================================================
--- stable/9/sys/boot/forth/check-password.4th.8	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/check-password.4th.8	Thu Aug  8 22:49:18 2013	(r254109)
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2011 Devin Teske
+.\" Copyright (c) 2011-2012 Devin Teske
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 18, 2011
+.Dd December 10, 2012
 .Dt CHECK-PASSWORD.4TH 8
 .Os
 .Sh NAME
@@ -33,7 +33,8 @@
 .Sh DESCRIPTION
 The file that goes by the name of
 .Nm
-is a set of commands designed to prevent booting without the proper password.
+is a set of commands designed to either prevent booting or prevent modification
+of boot options without an appropriately configured password.
 The commands of
 .Nm
 by themselves are not enough for most uses.
@@ -57,30 +58,36 @@ The commands provided by it are:
 .Pp
 .Bl -tag -width disable-module_module -compact -offset indent
 .It Ic check-password
-Once called, the user cannot continue until the correct password is entered.
-If the user enters the correct password the function returns.
+Dual-purpose function that can either protect the interactive boot menu or
+prevent boot without password (separately).
 .Pp
-The password that is required is configured by setting the
-.Ic password
-variable in
-.Xr loader.conf 5 .
-.Pp
-Subsequent calls after a successful password
-has been entered will not cause reprompting
-\(em the function will silently return.
+First checks
+.Va bootlock_password
+and if-set, the user cannot continue until the correct password is entered.
+.Pp
+Next checks
+.Va password
+and if-set, tries to
+.Ic autoboot
+and only prompts for password on failure or user-interrupt.
+See
+.Xr loader.conf 5
+for additional information.
 .El
 .Pp
 The environment variables that effect its behavior are:
-.Bl -tag -width bootfile -offset indent
+.Bl -tag -width bootlock_password -offset indent
+.It Va bootlock_password
+Sets the bootlock password (up to 16 characters long) that is required by
+.Ic check-password
+to be entered before the system is allowed to boot.
 .It Va password
 Sets the password (up to 16 characters long) that is required by
 .Ic check-password
-to be entered before the system is allowed to boot. If unset (default) or NULL,
-.Ic check-password
-will silently abort.
+before the user is allowed to visit the boot menu.
 .El
 .Sh FILES
-.Bl -tag -width /boot/loader.4th -compact
+.Bl -tag -width /boot/check-password.4th -compact
 .It Pa /boot/loader
 The
 .Xr loader 8 .
@@ -101,11 +108,20 @@ check-password
 .Ed
 .Pp
 Set a password in
-.Xr loader.conf 5 :
+.Xr loader.conf 5
+to prevent modification of boot options:
 .Pp
 .Bd -literal -offset indent -compact
 password="abc123"
 .Ed
+.Pp
+Set a password in
+.Xr loader.conf 5
+to prevent booting without password:
+.Pp
+.Bd -literal -offset indent -compact
+bootlock_password="boot"
+.Ed
 .Sh SEE ALSO
 .Xr loader.conf 5 ,
 .Xr loader 8 ,
@@ -120,4 +136,4 @@ The
 .Nm
 set of commands was written by
 .An -nosplit
-.An Devin Teske Aq devinteske at hotmail.com .
+.An Devin Teske Aq dteske at FreeBSD.org .

Modified: stable/9/sys/boot/forth/color.4th
==============================================================================
--- stable/9/sys/boot/forth/color.4th	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/color.4th	Thu Aug  8 22:49:18 2013	(r254109)
@@ -1,4 +1,4 @@
-\ Copyright (c) 2011 Devin Teske <devinteske at hotmail.com>
+\ Copyright (c) 2011-2013 Devin Teske <dteske at FreeBSD.org>
 \ All rights reserved.
 \ 
 \ Redistribution and use in source and binary forms, with or without
@@ -26,23 +26,24 @@
 
 marker task-color.4th
 
-\ This function returns TRUE if the `loader_color' environment variable is set
-\ to YES, yes, or 1. Otherwise, FALSE is returned.
+\ This function returns FALSE if the `loader_color' environment variable is set
+\ to NO, no, or 0. Otherwise, TRUE is returned (unless booting serial).
 \ 
 : loader_color? ( -- N )
 
 	s" loader_color" getenv dup -1 <> if
 
-		2dup s" YES" compare-insensitive 0= if
+		2dup s" NO" compare-insensitive 0= if
 			2drop
-			TRUE exit
+			FALSE exit
 		then
-		2dup s" 1" compare 0= if
+		2dup s" 0" compare 0= if
 			2drop
-			TRUE exit
+			FALSE exit
 		then
 		drop
 	then
+	drop
 
-	drop FALSE exit
+	boot_serial? if FALSE else TRUE then
 ;

Modified: stable/9/sys/boot/forth/color.4th.8
==============================================================================
--- stable/9/sys/boot/forth/color.4th.8	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/color.4th.8	Thu Aug  8 22:49:18 2013	(r254109)
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2011 Devin Teske
+.\" Copyright (c) 2011-2013 Devin Teske
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 18, 2011
+.Dd August 6, 2013
 .Dt COLOR.4TH 8
 .Os
 .Sh NAME
@@ -50,33 +50,33 @@ through the command:
 .Dl include color.4th
 .Pp
 This line is present in
-.Pa /boot/beastie.4th
+.Pa /boot/loader.4th
 file, so it is not needed (and should not be re-issued) in a normal setup.
 .Pp
 The commands provided by it are:
 .Pp
 .Bl -tag -width disable-module_module -compact -offset indent
 .It Ic loader_color?
-Returns TRUE if the
+Returns FALSE if the
 .Ic loader_color
 environment variable is set to
-.Dq YES
+.Dq NO
 (case-insensitive) or
-.Dq 1 .
-Otherwise returns FALSE.
+.Dq 0 .
+Otherwise returns TRUE
+.Pq unless booting serial .
 .El
 .Pp
 The environment variables that effect its behavior are:
 .Bl -tag -width bootfile -offset indent
 .It Va loader_color
 If set to
-.Dq YES
+.Dq NO
 (case-insensitive) or
-.Dq 1 ,
+.Dq 0 ,
 causes
 .Ic loader_color?
-to return TRUE, indicating to many other modules that color should be used
-whenever/wherever possible.
+to return FALSE, indicating to many modules that color should not be used.
 .El
 .Sh FILES
 .Bl -tag -width /boot/loader.4th -compact
@@ -102,7 +102,6 @@ loader_color="YES"
 .Sh SEE ALSO
 .Xr loader.conf 5 ,
 .Xr loader 8 ,
-.Xr beastie.4th 8 ,
 .Xr loader.4th 8
 .Sh HISTORY
 The
@@ -114,4 +113,4 @@ The
 .Nm
 set of commands was written by
 .An -nosplit
-.An Devin Teske Aq devinteske at hotmail.com .
+.An Devin Teske Aq dteske at FreeBSD.org .

Modified: stable/9/sys/boot/forth/delay.4th
==============================================================================
--- stable/9/sys/boot/forth/delay.4th	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/delay.4th	Thu Aug  8 22:49:18 2013	(r254109)
@@ -1,4 +1,4 @@
-\ Copyright (c) 2008-2011 Devin Teske <devinteske at hotmail.com>
+\ Copyright (c) 2008-2011 Devin Teske <dteske at FreeBSD.org>
 \ All rights reserved.
 \ 
 \ Redistribution and use in source and binary forms, with or without

Modified: stable/9/sys/boot/forth/delay.4th.8
==============================================================================
--- stable/9/sys/boot/forth/delay.4th.8	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/delay.4th.8	Thu Aug  8 22:49:18 2013	(r254109)
@@ -123,4 +123,4 @@ The
 .Nm
 set of commands was written by
 .An -nosplit
-.An Devin Teske Aq devinteske at hotmail.com .
+.An Devin Teske Aq dteske at FreeBSD.org .

Modified: stable/9/sys/boot/forth/frames.4th
==============================================================================
--- stable/9/sys/boot/forth/frames.4th	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/frames.4th	Thu Aug  8 22:49:18 2013	(r254109)
@@ -12,6 +12,11 @@ variable rt_el
 variable rb_el
 variable fill
 
+\ ASCII frames (used when serial console is detected)
+ 45 constant ascii_dash
+124 constant ascii_pipe
+ 43 constant ascii_plus
+
 s" arch-pc98" environment? [if]
 	\ Single frames
 	149 constant sh_el
@@ -63,7 +68,17 @@ s" arch-pc98" environment? [if]
 	loop
 ;
 
+: f_ascii ( -- )	( -- )	\ set frames to ascii
+	ascii_dash h_el !
+	ascii_pipe v_el !
+	ascii_plus lt_el !
+	ascii_plus lb_el !
+	ascii_plus rt_el !
+	ascii_plus rb_el !
+;
+
 : f_single	( -- )	\ set frames to single
+	boot_serial? if f_ascii exit then
 	sh_el h_el !
 	sv_el v_el !
 	slt_el lt_el !
@@ -73,6 +88,7 @@ s" arch-pc98" environment? [if]
 ;
 
 : f_double	( -- )	\ set frames to double
+	boot_serial? if f_ascii exit then
 	dh_el h_el !
 	dv_el v_el !
 	dlt_el lt_el !

Modified: stable/9/sys/boot/forth/loader.4th
==============================================================================
--- stable/9/sys/boot/forth/loader.4th	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/loader.4th	Thu Aug  8 22:49:18 2013	(r254109)
@@ -40,6 +40,7 @@ s" arch-i386" environment? [if] [if]
 2048 dictincrease !  \ 2048 additional cells each time
 
 include /boot/support.4th
+include /boot/color.4th
 
 only forth also support-functions also builtins definitions
 
@@ -59,11 +60,23 @@ only forth also support-functions also b
   else
     drop
   then
+  s" menusets-unset"
+  sfind if
+    execute
+  else
+    drop
+  then
 ;
 
 : boot
   0= if ( interpreted ) get_arguments then
 
+  loader_color? if
+    ." Booting..." cr
+  else
+    ." Booting..." cr
+  then
+
   \ Unload only if a path was passed
   dup if
     >r over r> swap

Modified: stable/9/sys/boot/forth/loader.4th.8
==============================================================================
--- stable/9/sys/boot/forth/loader.4th.8	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/loader.4th.8	Thu Aug  8 22:49:18 2013	(r254109)
@@ -99,7 +99,7 @@ This
 is the command used in the default
 .Pa /boot/loader.rc
 file, and it uses the
-.Pa autoboot
+.Ic autoboot
 command (see
 .Xr loader 8 ) ,
 so it can be stopped for further interaction with

Modified: stable/9/sys/boot/forth/loader.conf
==============================================================================
--- stable/9/sys/boot/forth/loader.conf	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/loader.conf	Thu Aug  8 22:49:18 2013	(r254109)
@@ -48,7 +48,7 @@ bitmap_type="splash_image_data" # and pl
 				# escape to the loader prompt, set to
 				# "NO" to disable autobooting
 #beastie_disable="NO"		# Turn the beastie boot menu on and off
-#loader_logo="fbsdbw"		# Desired logo: fbsdbw, beastiebw, beastie, none
+#loader_logo="orbbw"		# Desired logo: orbbw, orb, fbsdbw, beastiebw, beastie, none
 #comconsole_speed="9600"	# Set the current serial console speed
 #console="vidconsole"		# A comma separated list of console(s)
 #currdev="disk1s1a"		# Set the current device

Modified: stable/9/sys/boot/forth/loader.conf.5
==============================================================================
--- stable/9/sys/boot/forth/loader.conf.5	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/loader.conf.5	Thu Aug  8 22:49:18 2013	(r254109)
@@ -23,7 +23,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD$
-.Dd July 20, 2011
+.Dd August 6, 2013
 .Dt LOADER.CONF 5
 .Os
 .Sh NAME
@@ -113,8 +113,23 @@ that contains a kernel.
 .It Ar kernel_options
 Flags to be passed to the kernel.
 .It Ar password
+Protect boot menu with a password without interrupting
+.Ic autoboot
+process.
+The password should be in clear text format.
+If a password is set, boot menu will not appear until any key is pressed during
+countdown period specified by
+.Va autoboot_delay
+variable or
+.Ic autoboot
+process fails.
+In both cases user should provide specified password to be able to access boot
+menu.
+.It Ar bootlock_password
 Provides a password to be required by check-password before execution is
 allowed to continue.
+The password should be in clear text format.
+If a password is set, the user must provide specified password to boot.
 .It Ar verbose_loading
 If set to
 .Dq YES ,
@@ -230,8 +245,8 @@ and
 .Dq Li none .
 .It Va loader_color
 If set to
-.Dq YES ,
-the beastie boot menu will be displayed using ANSI coloring where possible.
+.Dq NO ,
+the beastie boot menu will be displayed without ANSI coloring.
 .El
 .Sh FILES
 .Bl -tag -width /boot/defaults/loader.conf -compact

Modified: stable/9/sys/boot/forth/loader.rc
==============================================================================
--- stable/9/sys/boot/forth/loader.rc	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/loader.rc	Thu Aug  8 22:49:18 2013	(r254109)
@@ -10,5 +10,9 @@ start
 \ Tests for password -- executes autoboot first if a password was defined
 check-password
 
+\ Uncomment to enable boot menu
+\ include /boot/beastie.4th
+\ beastie-start
+
 \ Unless set otherwise, autoboot is automatic at this point
 

Modified: stable/9/sys/boot/forth/menu-commands.4th
==============================================================================
--- stable/9/sys/boot/forth/menu-commands.4th	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/menu-commands.4th	Thu Aug  8 22:49:18 2013	(r254109)
@@ -1,4 +1,4 @@
-\ Copyright (c) 2006-2011 Devin Teske <devinteske at hotmail.com>
+\ Copyright (c) 2006-2012 Devin Teske <dteske at FreeBSD.org>
 \ All rights reserved.
 \ 
 \ Redistribution and use in source and binary forms, with or without
@@ -26,6 +26,60 @@
 
 marker task-menu-commands.4th
 
+include /boot/menusets.4th
+
+variable kernel_state
+variable root_state
+
+\ 
+\ Boot
+\ 
+
+: init_boot ( N -- N )
+	dup
+	s" boot_single" getenv -1 <> if
+		drop ( n n c-addr -- n n ) \ unused
+		toggle_menuitem ( n n -- n n )
+		s" set menu_keycode[N]=115" \ base command to execute
+	else
+		s" set menu_keycode[N]=98" \ base command to execute
+	then
+	17 +c! \ replace 'N' with ASCII numeral
+	evaluate
+;
+
+\ 
+\ Alternate Boot
+\ 
+
+: init_altboot ( N -- N )
+	dup
+	s" boot_single" getenv -1 <> if
+		drop ( n c-addr -- n ) \ unused
+		toggle_menuitem ( n -- n )
+		s" set menu_keycode[N]=109" \ base command to execute
+	else
+		s" set menu_keycode[N]=115" \ base command to execute
+	then
+	17 +c! \ replace 'N' with ASCII numeral
+	evaluate
+;
+
+: altboot ( -- )
+	s" boot_single" 2dup getenv -1 <> if
+		drop ( c-addr/u c-addr -- c-addr/u ) \ unused
+		unsetenv ( c-addr/u -- )
+	else
+		2drop ( c-addr/u -- ) \ unused
+		s" set boot_single=YES" evaluate
+	then
+	0 boot ( state -- )
+;
+
+\ 
+\ ACPI
+\ 
+
 : acpi_enable ( -- )
 	s" set acpi_load=YES" evaluate \ XXX deprecated but harmless
 	s" set hint.acpi.0.disabled=0" evaluate
@@ -53,39 +107,51 @@ marker task-menu-commands.4th
 	TRUE \ loop menu again
 ;
 
+\ 
+\ Safe Mode
+\ 
+
+: safemode_enabled? ( -- flag )
+	s" kern.smp.disabled" getenv -1 <> dup if
+		swap drop ( c-addr flag -- flag )
+	then
+;
+
+: safemode_enable ( -- )
+	s" set kern.smp.disabled=1" evaluate
+	s" set hw.ata.ata_dma=0" evaluate
+	s" set hw.ata.atapi_dma=0" evaluate
+	s" set hw.ata.wc=0" evaluate
+	s" set hw.eisa_slots=0" evaluate
+	s" set kern.eventtimer.periodic=1" evaluate
+	s" set kern.geom.part.check_integrity=0" evaluate
+;
+
+: safemode_disable ( -- )
+	s" kern.smp.disabled" unsetenv
+	s" hw.ata.ata_dma" unsetenv
+	s" hw.ata.atapi_dma" unsetenv
+	s" hw.ata.wc" unsetenv
+	s" hw.eisa_slots" unsetenv
+	s" kern.eventtimer.periodic" unsetenv
+	s" kern.geom.part.check_integrity" unsetenv
+;
+
+: init_safemode ( N -- N )
+	safemode_enabled? if
+		toggle_menuitem ( n -- n )
+	then
+;
+
 : toggle_safemode ( N -- N TRUE )
 	toggle_menuitem
 
 	\ Now we're going to make the change effective
 
-	s" toggle_stateN @"      \ base name of toggle state var
-	-rot 2dup 12 + c! rot    \ replace 'N' with ASCII numeral
-
-	evaluate 0= if
-		s" hint.apic.0.disabled" unsetenv
-		s" hw.ata.ata_dma" unsetenv
-		s" hw.ata.atapi_dma" unsetenv
-		s" hw.ata.wc" unsetenv
-		s" hw.eisa_slots" unsetenv
-		s" hint.kbdmux.0.disabled" unsetenv
-	else
-		\ 
-		\ Toggle ACPI elements if necessary
-		\ 
-		acpipresent? if acpienabled? if
-			menuacpi @ dup 0<> if
-				toggle_menuitem ( N -- N )
-			then
-			drop
-			acpi_disable
-		then then
-
-		s" set hint.apic.0.disabled=1" evaluate
-		s" set hw.ata.ata_dma=0" evaluate
-		s" set hw.ata.atapi_dma=0" evaluate
-		s" set hw.ata.wc=0" evaluate
-		s" set hw.eisa_slots=0" evaluate
-		s" set hint.kbdmux.0.disabled=1" evaluate
+	dup toggle_stateN @ 0= if
+		safemode_disable
+	else
+		safemode_enable
 	then
 
 	menu-redraw
@@ -93,42 +159,88 @@ marker task-menu-commands.4th
 	TRUE \ loop menu again
 ;
 
+\ 
+\ Single User Mode
+\ 
+
+: singleuser_enabled? ( -- flag )
+	s" boot_single" getenv -1 <> dup if
+		swap drop ( c-addr flag -- flag )
+	then
+;
+
+: singleuser_enable ( -- )
+	s" set boot_single=YES" evaluate
+;
+
+: singleuser_disable ( -- )
+	s" boot_single" unsetenv
+;
+
+: init_singleuser ( N -- N )
+	singleuser_enabled? if
+		toggle_menuitem ( n -- n )
+	then
+;
+
 : toggle_singleuser ( N -- N TRUE )
 	toggle_menuitem
 	menu-redraw
 
 	\ Now we're going to make the change effective
 
-	s" toggle_stateN @"      \ base name of toggle state var
-	-rot 2dup 12 + c! rot    \ replace 'N' with ASCII numeral
-
-	evaluate 0= if
-		s" boot_single" unsetenv
+	dup toggle_stateN @ 0= if
+		singleuser_disable
 	else
-		s" set boot_single=YES" evaluate
+		singleuser_enable
 	then
 
 	TRUE \ loop menu again
 ;
 
+\ 
+\ Verbose Boot
+\ 
+
+: verbose_enabled? ( -- flag )
+	s" boot_verbose" getenv -1 <> dup if
+		swap drop ( c-addr flag -- flag )
+	then
+;
+
+: verbose_enable ( -- )
+	s" set boot_verbose=YES" evaluate
+;
+
+: verbose_disable ( -- )
+	s" boot_verbose" unsetenv
+;
+
+: init_verbose ( N -- N )
+	verbose_enabled? if
+		toggle_menuitem ( n -- n )
+	then
+;
+
 : toggle_verbose ( N -- N TRUE )
 	toggle_menuitem
 	menu-redraw
 
 	\ Now we're going to make the change effective
 
-	s" toggle_stateN @"      \ base name of toggle state var
-	-rot 2dup 12 + c! rot    \ replace 'N' with ASCII numeral
-
-	evaluate 0= if
-		s" boot_verbose" unsetenv
+	dup toggle_stateN @ 0= if
+		verbose_disable
 	else
-		s" set boot_verbose=YES" evaluate
+		verbose_enable
 	then
 
 	TRUE \ loop menu again
 ;
 
+\ 
+\ Escape to Prompt
+\ 
+
 : goto_prompt ( N -- N FALSE )
 
 	s" set autoboot_delay=NO" evaluate
@@ -141,50 +253,94 @@ marker task-menu-commands.4th
 	FALSE \ exit the menu
 ;
 
+\ 
+\ Cyclestate (used by kernel/root below)
+\ 
+
+: init_cyclestate ( N K -- N )
+	over cycle_stateN ( n k -- n k addr )
+	begin
+		tuck @  ( n k addr -- n addr k c )
+		over <> ( n addr k c -- n addr k 0|-1 )
+	while
+		rot ( n addr k -- addr k n )
+		cycle_menuitem
+		swap rot ( addr k n -- n k addr )
+	repeat
+	2drop ( n k addr -- n )
+;
+
+\
+\ Kernel
+\ 
+
+: init_kernel ( N -- N )
+	kernel_state @  ( n -- n k )
+	init_cyclestate ( n k -- n )
+;
+
 : cycle_kernel ( N -- N TRUE )
 	cycle_menuitem
 	menu-redraw
 
 	\ Now we're going to make the change effective
 
-	s" cycle_stateN"         \ base name of array state var
-	-rot 2dup 11 + c! rot    \ replace 'N' with ASCII numeral
-	evaluate                 \ translate name into address
-	@                        \ dereference address into value
+	dup cycle_stateN @
+	dup kernel_state !       \ save a copy for re-initialization
 	48 +                     \ convert to ASCII numeral
 
-	\ Since we are [in this file] going to override the standard `boot'
-	\ routine with a custom one, you should know that we use $kernel
-	\ when referencing the desired kernel. Set $kernel below.
-
 	s" set kernel=${kernel_prefix}${kernel[N]}${kernel_suffix}"
-	                          \ command to assemble full kernel-path
-	-rot tuck 36 + c! swap    \ replace 'N' with array index value
-	evaluate                  \ sets $kernel to full kernel-path
+	36 +c!   \ replace 'N' with ASCII numeral
+	evaluate \ sets $kernel to full kernel-path
 
 	TRUE \ loop menu again
 ;
 
+\ 
+\ Root
+\ 
+
+: init_root ( N -- N )
+	root_state @    ( n -- n k )
+	init_cyclestate ( n k -- n )
+;
+
 : cycle_root ( N -- N TRUE )
 	cycle_menuitem
 	menu-redraw
 
 	\ Now we're going to make the change effective
 
-	s" cycle_stateN"         \ base name of array state var
-	-rot 2dup 11 + c! rot    \ replace 'N' with ASCII numeral
-	evaluate                 \ translate name into address
-	@                        \ dereference address into value
+	dup cycle_stateN @
+	dup root_state !         \ save a copy for re-initialization
 	48 +                     \ convert to ASCII numeral
 
-	\ Since we are [in this file] going to override the standard `boot'
-	\ routine with a custom one, you should know that we use $root when
-	\ booting. Set $root below.
-
-	s" set root=${root_prefix}${root[N]}${root_prefix}"
-	                          \ command to assemble full kernel-path
-	-rot tuck 30 + c! swap    \ replace 'N' with array index value
-	evaluate                  \ sets $kernel to full kernel-path
+	s" set root=${root_prefix}${root[N]}${root_suffix}"
+	30 +c!   \ replace 'N' with ASCII numeral
+	evaluate \ sets $root to full root-path
 
 	TRUE \ loop menu again
 ;
+
+\ 
+\ Menusets
+\ 
+
+: goto_menu ( N M -- N TRUE )
+	menu-unset
+	menuset-loadsetnum ( n m -- n )
+	menu-redraw
+	TRUE \ Loop menu again
+;
+
+\ 
+\ Defaults
+\ 
+
+: set_default_boot_options ( N -- N TRUE )
+	acpi_enable
+	safemode_disable
+	singleuser_disable
+	verbose_disable
+	2 goto_menu
+;

Modified: stable/9/sys/boot/forth/menu.4th
==============================================================================
--- stable/9/sys/boot/forth/menu.4th	Thu Aug  8 22:34:00 2013	(r254108)
+++ stable/9/sys/boot/forth/menu.4th	Thu Aug  8 22:49:18 2013	(r254109)
@@ -1,6 +1,6 @@
 \ Copyright (c) 2003 Scott Long <scottl at freebsd.org>
 \ Copyright (c) 2003 Aleksander Fafula <alex at fafula.com>
-\ Copyright (c) 2006-2011 Devin Teske <devinteske at hotmail.com>
+\ Copyright (c) 2006-2013 Devin Teske <dteske at FreeBSD.org>
 \ All rights reserved.
 \ 
 \ Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,8 @@ f_double        \ Set frames to double (
                 \ f_single if you want single frames.
 46 constant dot \ ASCII definition of a period (in decimal)
 
+ 5 constant menu_default_x         \ default column position of timeout
+10 constant menu_default_y         \ default row position of timeout msg
  4 constant menu_timeout_default_x \ default column position of timeout
 23 constant menu_timeout_default_y \ default row position of timeout msg
 10 constant menu_timeout_default   \ default timeout (in seconds)
@@ -76,6 +78,16 @@ variable menu_timeout         \ determin
 variable menu_timeout_x       \ column position of timeout message
 variable menu_timeout_y       \ row position of timeout message
 
+\ Menu initialization status variables
+variable init_state1
+variable init_state2
+variable init_state3
+variable init_state4
+variable init_state5
+variable init_state6
+variable init_state7
+variable init_state8
+
 \ Boolean option status variables
 variable toggle_state1
 variable toggle_state2
@@ -106,6 +118,52 @@ create init_text6 255 allot
 create init_text7 255 allot
 create init_text8 255 allot
 
+: +c! ( N C-ADDR/U K -- C-ADDR/U )
+	3 pick 3 pick	( n c-addr/u k -- n c-addr/u k n c-addr )
+	rot + c!	( n c-addr/u k n c-addr -- n c-addr/u )
+	rot drop	( n c-addr/u -- c-addr/u )
+;
+
+: menukeyN      ( N -- ADDR )   s" menukeyN"       7 +c! evaluate ;
+: init_stateN   ( N -- ADDR )   s" init_stateN"   10 +c! evaluate ;
+: toggle_stateN ( N -- ADDR )   s" toggle_stateN" 12 +c! evaluate ;
+: cycle_stateN  ( N -- ADDR )   s" cycle_stateN"  11 +c! evaluate ;
+: init_textN    ( N -- C-ADDR ) s" init_textN"     9 +c! evaluate ;
+
+: str_loader_menu_frame       ( -- C-ADDR/U ) s" loader_menu_frame" ;
+: str_loader_menu_title       ( -- C-ADDR/U ) s" loader_menu_title" ;
+: str_loader_menu_title_align ( -- C-ADDR/U ) s" loader_menu_title_align" ;
+: str_loader_menu_x           ( -- C-ADDR/U ) s" loader_menu_x" ;
+: str_loader_menu_y           ( -- C-ADDR/U ) s" loader_menu_y" ;
+: str_loader_menu_timeout_x   ( -- C-ADDR/U ) s" loader_menu_timeout_x" ;
+: str_loader_menu_timeout_y   ( -- C-ADDR/U ) s" loader_menu_timeout_y" ;
+: str_menu_init               ( -- C-ADDR/U ) s" menu_init" ;
+: str_menu_timeout_command    ( -- C-ADDR/U ) s" menu_timeout_command" ;
+: str_menu_reboot             ( -- C-ADDR/U ) s" menu_reboot" ;
+: str_menu_acpi               ( -- C-ADDR/U ) s" menu_acpi" ;
+: str_menu_options            ( -- C-ADDR/U ) s" menu_options" ;
+: str_menu_optionstext        ( -- C-ADDR/U ) s" menu_optionstext" ;
+
+: str_menu_init[x]          ( -- C-ADDR/U ) s" menu_init[x]" ;
+: str_menu_command[x]       ( -- C-ADDR/U ) s" menu_command[x]" ;
+: str_menu_caption[x]       ( -- C-ADDR/U ) s" menu_caption[x]" ;
+: str_ansi_caption[x]       ( -- C-ADDR/U ) s" ansi_caption[x]" ;
+: str_menu_keycode[x]       ( -- C-ADDR/U ) s" menu_keycode[x]" ;
+: str_toggled_text[x]       ( -- C-ADDR/U ) s" toggled_text[x]" ;
+: str_toggled_ansi[x]       ( -- C-ADDR/U ) s" toggled_ansi[x]" ;
+: str_menu_caption[x][y]    ( -- C-ADDR/U ) s" menu_caption[x][y]" ;
+: str_ansi_caption[x][y]    ( -- C-ADDR/U ) s" ansi_caption[x][y]" ;
+
+: menu_init[x]       ( N -- C-ADDR/U )   str_menu_init[x]       10 +c! ;
+: menu_command[x]    ( N -- C-ADDR/U )   str_menu_command[x]    13 +c! ;
+: menu_caption[x]    ( N -- C-ADDR/U )   str_menu_caption[x]    13 +c! ;
+: ansi_caption[x]    ( N -- C-ADDR/U )   str_ansi_caption[x]    13 +c! ;
+: menu_keycode[x]    ( N -- C-ADDR/U )   str_menu_keycode[x]    13 +c! ;
+: toggled_text[x]    ( N -- C-ADDR/U )   str_toggled_text[x]    13 +c! ;
+: toggled_ansi[x]    ( N -- C-ADDR/U )   str_toggled_ansi[x]    13 +c! ;
+: menu_caption[x][y] ( N M -- C-ADDR/U ) str_menu_caption[x][y] 16 +c! 13 +c! ;
+: ansi_caption[x][y] ( N M -- C-ADDR/U ) str_ansi_caption[x][y] 16 +c! 13 +c! ;
+
 : arch-i386? ( -- BOOL ) \ Returns TRUE (-1) on i386, FALSE (0) otherwise.
 	s" arch-i386" environment? dup if
 		drop
@@ -162,30 +220,24 @@ create init_text8 255 allot
 	\ ASCII numeral equal to user-selected menu item must be on the stack.
 	\ We do not modify the stack, so the ASCII numeral is left on top.
 
-	s" init_textN"          \ base name of buffer
-	-rot 2dup 9 + c! rot    \ replace 'N' with ASCII num
-
-	evaluate c@ 0= if
+	dup init_textN c@ 0= if
 		\ NOTE: no need to check toggle_stateN since the first time we
 		\ are called, we will populate init_textN. Further, we don't
 		\ need to test whether menu_caption[x] (ansi_caption[x] when
-		\ loader_color=1) is available since we would not have been
+		\ loader_color?=1) is available since we would not have been

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-stable-9 mailing list