mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-23 05:51:11 +01:00
Since the introduction of the new advanced boot menu (r222417), options like
"boot verbose", "single user mode", "ACPI" and more are now stateful boolean menuitems rather than direct action-items. A short-coming in this new menu system is that when a user sets a non-default value in loader.conf(5), this non-default state is not reflected in the menu -- leading to confusion as to whether the option was taking effect or not. This patch adds dynamic menuitem constructors _and_ the necessary Forth callbacks to initialize these stateful menuitems -- causing the aforementioned menuitems to adhere to loader.conf(5) settings. PR: bin/172529 Approved by: adrian (co-mentor) MFC after: 21 days
This commit is contained in:
parent
d14cfe6e65
commit
55f9ff659d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=241523
@ -26,6 +26,9 @@
|
||||
|
||||
marker task-menu-commands.4th
|
||||
|
||||
variable kernel_state
|
||||
variable root_state
|
||||
|
||||
: acpi_enable ( -- )
|
||||
s" set acpi_load=YES" evaluate \ XXX deprecated but harmless
|
||||
s" set hint.acpi.0.disabled=0" evaluate
|
||||
@ -53,6 +56,13 @@ marker task-menu-commands.4th
|
||||
TRUE \ loop menu again
|
||||
;
|
||||
|
||||
: init_safemode ( N -- N )
|
||||
s" kern.smp.disabled" getenv -1 <> if
|
||||
drop ( n c-addr -- n ) \ unused
|
||||
toggle_menuitem ( n -- n )
|
||||
then
|
||||
;
|
||||
|
||||
: toggle_safemode ( N -- N TRUE )
|
||||
toggle_menuitem
|
||||
|
||||
@ -84,6 +94,13 @@ marker task-menu-commands.4th
|
||||
TRUE \ loop menu again
|
||||
;
|
||||
|
||||
: init_singleuser ( N -- N )
|
||||
s" boot_single" getenv -1 <> if
|
||||
drop ( n c-addr -- n ) \ unused
|
||||
toggle_menuitem ( n -- n )
|
||||
then
|
||||
;
|
||||
|
||||
: toggle_singleuser ( N -- N TRUE )
|
||||
toggle_menuitem
|
||||
menu-redraw
|
||||
@ -102,6 +119,13 @@ marker task-menu-commands.4th
|
||||
TRUE \ loop menu again
|
||||
;
|
||||
|
||||
: init_verbose ( N -- N )
|
||||
s" boot_verbose" getenv -1 <> if
|
||||
drop ( n c-addr -- n ) \ unused
|
||||
toggle_menuitem ( n -- n )
|
||||
then
|
||||
;
|
||||
|
||||
: toggle_verbose ( N -- N TRUE )
|
||||
toggle_menuitem
|
||||
menu-redraw
|
||||
@ -132,6 +156,27 @@ marker task-menu-commands.4th
|
||||
FALSE \ exit the menu
|
||||
;
|
||||
|
||||
: init_cyclestate ( N K -- N )
|
||||
over ( n k -- n k n )
|
||||
s" cycle_stateN" ( n k n -- n k n c-addr u )
|
||||
-rot tuck 11 + c! swap ( n k n c-addr u -- n k c-addr u )
|
||||
evaluate ( n k c-addr u -- 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 )
|
||||
;
|
||||
|
||||
: init_kernel ( N -- N )
|
||||
kernel_state @ ( n -- n k )
|
||||
init_cyclestate ( n k -- n )
|
||||
;
|
||||
|
||||
: cycle_kernel ( N -- N TRUE )
|
||||
cycle_menuitem
|
||||
menu-redraw
|
||||
@ -142,6 +187,7 @@ marker task-menu-commands.4th
|
||||
-rot 2dup 11 + c! rot \ replace 'N' with ASCII numeral
|
||||
evaluate \ translate name into address
|
||||
@ \ dereference address into value
|
||||
dup kernel_state ! \ save a copy for re-initialization
|
||||
48 + \ convert to ASCII numeral
|
||||
|
||||
s" set kernel=${kernel_prefix}${kernel[N]}${kernel_suffix}"
|
||||
@ -152,6 +198,11 @@ marker task-menu-commands.4th
|
||||
TRUE \ loop menu again
|
||||
;
|
||||
|
||||
: init_root ( N -- N )
|
||||
root_state @ ( n -- n k )
|
||||
init_cyclestate ( n k -- n )
|
||||
;
|
||||
|
||||
: cycle_root ( N -- N TRUE )
|
||||
cycle_menuitem
|
||||
menu-redraw
|
||||
@ -162,6 +213,7 @@ marker task-menu-commands.4th
|
||||
-rot 2dup 11 + c! rot \ replace 'N' with ASCII numeral
|
||||
evaluate \ translate name into address
|
||||
@ \ dereference address into value
|
||||
dup root_state ! \ save a copy for re-initialization
|
||||
48 + \ convert to ASCII numeral
|
||||
|
||||
s" set root=${root_prefix}${root[N]}${root_suffix}"
|
||||
|
@ -76,6 +76,16 @@ variable menu_timeout \ determined configurable delay duration
|
||||
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
|
||||
@ -421,6 +431,16 @@ create init_text8 255 allot
|
||||
then
|
||||
24 over 2 / - 9 at-xy type
|
||||
|
||||
\ If $menu_init is set, evaluate it (allowing for whole menus to be
|
||||
\ constructed dynamically -- as this function could conceivably set
|
||||
\ the remaining environment variables to construct the menu entirely).
|
||||
\
|
||||
s" menu_init" getenv dup -1 <> if
|
||||
evaluate
|
||||
else
|
||||
drop
|
||||
then
|
||||
|
||||
\ Print our menu options with respective key/variable associations.
|
||||
\ `printmenuitem' ends by adding the decimal ASCII value for the
|
||||
\ numerical prefix to the stack. We store the value left on the stack
|
||||
@ -499,6 +519,24 @@ create init_text8 255 allot
|
||||
dup menuacpi @ = if
|
||||
acpimenuitem ( -- C-Addr/U | -1 )
|
||||
else
|
||||
\ make sure we have not already initialized this item
|
||||
s" init_stateN"
|
||||
-rot 2dup 10 + c! rot \ repace 'N'
|
||||
evaluate dup @ 0= if
|
||||
1 swap !
|
||||
|
||||
\ If this menuitem has an initializer, run it
|
||||
s" menu_init[x]"
|
||||
-rot 2dup 10 + c! rot \ replace 'x'
|
||||
getenv dup -1 <> if
|
||||
evaluate
|
||||
else
|
||||
drop
|
||||
then
|
||||
else
|
||||
drop
|
||||
then
|
||||
|
||||
loader_color? if
|
||||
s" ansi_caption[x]"
|
||||
else
|
||||
@ -917,6 +955,10 @@ create init_text8 255 allot
|
||||
-rot 2dup 13 + c! rot \ replace 'x'
|
||||
unsetenv
|
||||
|
||||
s" menu_init[x]" \ initializer basename
|
||||
-rot 2dup 10 + c! rot \ replace 'x'
|
||||
unsetenv
|
||||
|
||||
s" menu_keycode[x]" \ keycode basename
|
||||
-rot 2dup 13 + c! rot \ replace 'x'
|
||||
unsetenv
|
||||
@ -959,6 +1001,10 @@ create init_text8 255 allot
|
||||
-rot 2dup 9 + c! rot \ replace 'N' with current iteration
|
||||
evaluate \ assign zero (0) to key assoc. var
|
||||
|
||||
s" 0 init_stateN !" \ used by menu-create
|
||||
-rot 2dup 12 + c! rot \ replace 'N'
|
||||
evaluate
|
||||
|
||||
1+ dup 56 > \ increment, continue if less than 57
|
||||
until
|
||||
drop \ iterator
|
||||
@ -979,6 +1025,8 @@ create init_text8 255 allot
|
||||
s" menu_optionstext" unsetenv
|
||||
0 menuoptions !
|
||||
|
||||
\ clear the menu initializer
|
||||
s" menu_init" unsetenv
|
||||
;
|
||||
|
||||
\ This function both unsets menu variables and visually erases the menu area
|
||||
@ -994,6 +1042,16 @@ bullet menubllt !
|
||||
10 menuY !
|
||||
5 menuX !
|
||||
|
||||
\ Initialize our menu initialization state variables
|
||||
0 init_state1 !
|
||||
0 init_state2 !
|
||||
0 init_state3 !
|
||||
0 init_state4 !
|
||||
0 init_state5 !
|
||||
0 init_state6 !
|
||||
0 init_state7 !
|
||||
0 init_state8 !
|
||||
|
||||
\ Initialize our boolean state variables
|
||||
0 toggle_state1 !
|
||||
0 toggle_state2 !
|
||||
|
@ -48,6 +48,7 @@ set toggled_ansi[4]="[1mA[37mCPI Support [32;7mOn[0;37m"
|
||||
|
||||
set menu_caption[5]="Safe [M]ode... off"
|
||||
set toggled_text[5]="Safe [M]ode... On"
|
||||
set menu_init[5]="init_safemode"
|
||||
set menu_command[5]="toggle_safemode"
|
||||
set menu_keycode[5]="109"
|
||||
set ansi_caption[5]="Safe [1mM[37mode... [34;1mOff[37m"
|
||||
@ -55,6 +56,7 @@ set toggled_ansi[5]="Safe [1mM[37mode... [32;7mOn[0;37m"
|
||||
|
||||
set menu_caption[6]="[S]ingle User. off"
|
||||
set toggled_text[6]="[S]ingle User. On"
|
||||
set menu_init[6]="init_singleuser"
|
||||
set menu_command[6]="toggle_singleuser"
|
||||
set menu_keycode[6]="115"
|
||||
set ansi_caption[6]="[1mS[37mingle User. [34;1mOff[37m"
|
||||
@ -62,6 +64,7 @@ set toggled_ansi[6]="[1mS[37mingle User. [32;7mOn[0;37m"
|
||||
|
||||
set menu_caption[7]="[V]erbose..... off"
|
||||
set toggled_text[7]="[V]erbose..... On"
|
||||
set menu_init[7]="init_verbose"
|
||||
set menu_command[7]="toggle_verbose"
|
||||
set menu_keycode[7]="118"
|
||||
set ansi_caption[7]="[1mV[37merbose..... [34;1mOff[37m"
|
||||
|
Loading…
Reference in New Issue
Block a user