Lines Matching +full:reboot +full:- +full:mode
3 \ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
28 marker task-menu.4th
33 vocabulary menu-infrastructure
34 vocabulary menu-namespace
35 vocabulary menu-command-helpers
37 only forth also menu-infrastructure definitions
65 \ Menu-item elements
68 \ Menu timer [count-down] variables
75 only forth also menu-namespace definitions
77 \ Menu-item key association/detection
134 : arch-i386? ( -- BOOL ) \ Returns TRUE (-1) on i386, FALSE (0) otherwise.
144 : acpipresent? ( -- flag ) \ Returns TRUE if ACPI is present, FALSE otherwise
146 dup -1 = if
153 : acpienabled? ( -- flag ) \ Returns TRUE if ACPI is enabled, FALSE otherwise
155 dup -1 <> if
165 : +c! ( N C-ADDR/U K -- C-ADDR/U )
166 3 pick 3 pick ( n c-addr/u k -- n c-addr/u k n c-addr )
167 rot + c! ( n c-addr/u k n c-addr -- n c-addr/u )
168 rot drop ( n c-addr/u -- c-addr/u )
171 only forth also menu-namespace definitions
174 : namespace ( C-ADDR/U N -- ) also menu-namespace +c! evaluate previous ;
175 : menukeyN ( N -- ADDR ) s" menukeyN" 7 namespace ;
176 : init_stateN ( N -- ADDR ) s" init_stateN" 10 namespace ;
177 : toggle_stateN ( N -- ADDR ) s" toggle_stateN" 12 namespace ;
178 : cycle_stateN ( N -- ADDR ) s" cycle_stateN" 11 namespace ;
179 : init_textN ( N -- C-ADDR ) s" init_textN" 9 namespace ;
182 : menu_init[x] ( N -- C-ADDR/U ) s" menu_init[x]" 10 +c! ;
183 : menu_command[x] ( N -- C-ADDR/U ) s" menu_command[x]" 13 +c! ;
184 : menu_caption[x] ( N -- C-ADDR/U ) s" menu_caption[x]" 13 +c! ;
185 : ansi_caption[x] ( N -- C-ADDR/U ) s" ansi_caption[x]" 13 +c! ;
186 : menu_keycode[x] ( N -- C-ADDR/U ) s" menu_keycode[x]" 13 +c! ;
187 : toggled_text[x] ( N -- C-ADDR/U ) s" toggled_text[x]" 13 +c! ;
188 : toggled_ansi[x] ( N -- C-ADDR/U ) s" toggled_ansi[x]" 13 +c! ;
189 : menu_caption[x][y] ( N M -- C-ADDR/U ) s" menu_caption[x][y]" 16 +c! 13 +c! ;
190 : ansi_caption[x][y] ( N M -- C-ADDR/U ) s" ansi_caption[x][y]" 16 +c! 13 +c! ;
192 also menu-infrastructure definitions
197 \ menu item. This function is called by the menu-create function. You need not
200 : printmenuitem ( menu_item_str -- ascii_keycode )
211 dup menuX @ swap at-xy
214 loader_color? dup ( -- bool bool )
220 dup menuX @ 1+ swap at-xy
227 menuX @ 3 + swap at-xy
238 : delim? ( C -- BOOL )
239 dup 32 = ( c -- c bool ) \ [sp] space
240 over 9 = or ( c bool -- c bool ) \ [ht] horizontal tab
241 over 10 = or ( c bool -- c bool ) \ [nl] newline
242 over 13 = or ( c bool -- c bool ) \ [cr] carriage return
243 over [char] , = or ( c bool -- c bool ) \ comma
244 swap drop ( c bool -- bool ) \ return boolean
247 \ illumos kernel acpi-user-options has following values:
248 \ default: 0 - system will enable acpi based on bios date
249 \ on: 1 - acpi is set on
250 \ off: 2 - acpi is set off
251 \ madt: 4 - use only MADT
252 \ legacy: 8 - use legacy mode
254 : acpi-captions ( N -- )
275 : osconsole-captions ( N -- )
294 \ default: 0 - disabled
295 \ 1 - boot with -k option
296 \ 2 - as 1 + configure NMI to drop to kmdb
297 \ 3 - boot with -k and -d options
298 \ 4 - as 3 + configure NMI to drop to kmdb
300 : kmdb-captions ( N -- )
302 dup s" [k]mdb Mode........... Off" rot 48 menu_caption[x][y] setenv
303 dup s" ^[1mk^[mmdb Mode............. ^[34;1mOff^[m" rot 48 ansi_caption[x][y] setenv
305 dup s" [k]mdb Mode........... Loaded" rot 49 menu_caption[x][y] setenv
306 dup s" ^[1mk^[mmdb Mode............. ^[32;7mLoaded^[m" rot 49 ansi_caption[x][y] setenv
308 dup s" [k]mdb Mode........... On NMI" rot 50 menu_caption[x][y] setenv
309 dup s" ^[1mk^[mmdb Mode............. ^[32;7mOn NMI^[m" rot 50 ansi_caption[x][y] setenv
311 dup s" [k]mdb Mode........... On Boot" rot 51 menu_caption[x][y] setenv
312 dup s" ^[1mk^[mmdb Mode............. ^[32;7mOn Boot^[m" rot 51 ansi_caption[x][y] setenv
314 dup s" [k]mdb Mode........... On Boot/NMI" rot 52 menu_caption[x][y] setenv
315 s" ^[1mk^[mmdb Mode............. ^[32;7mOn Boot/NMI^[m" rot 52 ansi_caption[x][y] setenv
318 : set-captions ( x y - x y )
319 \ Set the current non-ANSI caption
320 2dup swap dup ( x y -- x y y x x )
323 ( x y y x x c-addr/u -- x y )
326 2dup swap dup ( x y -- x y y x x )
329 ( x y y x x c-addr/u -- x y )
333 \ menu-display function. You need not call it directly.
335 : menu-create ( -- )
338 s" loader_menu_title" getenv dup -1 = if
342 s" loader_menu_title_align" getenv dup -1 <> if
343 2dup s" left" compare-insensitive 0= if ( 1 )
344 2drop ( c-addr/u ) drop ( bool )
345 menuX @ menuY @ 1-
347 else ( 1 ) 2dup s" right" compare-insensitive 0= if ( 2 )
348 2drop ( c-addr/u ) drop ( bool )
349 menuX @ 42 + 4 - over - menuY @ 1-
351 else ( 2 ) 2drop ( c-addr/u ) then ( 1 ) then
356 menuX @ 19 + over 2 / - menuY @ 1-
358 at-xy type
361 \ constructed dynamically -- as this function could conceivably set
364 s" menu_init" getenv dup -1 <> if
383 \ (with "Reboot" as the optional ninth and highest numbered item).
389 s" menu_osconsole" getenv -1 <> if
392 dup osconsole-captions
397 s" osconsole_state" evaluate @ 48 + ( n -- n y )
399 set-captions
402 48 - ( n y -- n k )
403 s" init_cyclestate" evaluate ( n k -- n )
406 s" activate_osconsole" evaluate ( n -- n )
415 s" menu_acpi" getenv -1 <> if
418 dup acpi-captions
423 s" acpi_state" evaluate @ 48 + ( n -- n y )
425 set-captions
428 48 - ( n y -- n k )
429 s" init_cyclestate" evaluate ( n k -- n )
431 \ Set $acpi-user-options
432 s" activate_acpi" evaluate ( n -- n )
441 s" menu_kmdb" getenv -1 <> if
444 dup kmdb-captions
449 s" kmdb_state" evaluate @ 48 + ( n -- n y )
451 set-captions
454 48 - ( n y -- n k )
455 s" init_cyclestate" evaluate ( n k -- n )
458 s" activate_kmdb" evaluate ( n -- n )
467 s" menu_options" getenv -1 <> if
475 \ Initialize "Reboot" menu state variable (prevents double-entry)
479 1- menuidx ! \ Initialize the starting index for the menu
486 \ Optionally add a reboot option to the menu
487 s" menu_reboot" getenv -1 <> if
489 s" Reboot" printmenuitem menureboot !
496 at-xy
497 s" menu_optionstext" getenv dup -1 <> if
510 getenv dup -1 <> if
526 dup -1 <> if
528 getenv dup -1 <> if
529 printmenuitem ( c-addr/u -- n )
542 \ Optionally add a reboot option to the menu
544 s" menu_reboot" getenv -1 <> if
546 s" Reboot" \ menu caption (required by printmenuitem)
558 : menu-timeout-update ( N -- )
563 menu_timeout_x @ menu_timeout_y @ at-xy \ position cursor
574 at-bl
579 \ decimal ASCII representation. This function is called by the menu-display
584 : getkey ( -- ascii_keycode )
589 ( -- )
590 seconds ( get current time: -- N )
591 dup menu_time @ <> if ( has time elapsed?: N N N -- N )
598 menu_time ! ( update time record: N -- )
599 menu_timeout @ ( "time" remaining: -- N )
600 dup 0> if ( greater than 0?: N N 0 -- N )
601 1- ( decrement counter: N -- N )
603 ( re-assign: N N Addr -- N )
605 ( -- N )
607 dup 0= swap 0< or if ( N <= 0?: N N -- )
609 0 menu_timeout ! ( 0 Addr -- )
610 0 menu_timeout_enabled ! ( 0 Addr -- )
613 \ update the timer display ( N -- )
614 menu_timeout @ menu-timeout-update
622 -1 = if
623 drop \ clean-up
629 else ( -- N )
631 drop ( N -- )
633 ( -- )
645 0 menu-timeout-update
649 \ get a non-zero ASCII code)
674 : menu-erase ( -- ) \ Erases menu and resets positioning variable to position 1.
678 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+
679 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+
680 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+
681 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+
682 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces 1+
683 2dup at-xy 38 spaces 1+ 2dup at-xy 38 spaces
687 menu_start 1- menuidx !
692 also menu-infrastructure
693 also menu-namespace
694 also menu-command-helpers definitions
696 : toggle_menuitem ( N -- N ) \ toggles caption text and internal menuitem state
698 \ ASCII numeral equal to user-selected menu item must be on the stack.
709 dup ( n -- n n ) \ key pressed
715 getenv dup -1 <> if
717 2 pick ( n c-addr/u -- n c-addr/u n )
718 init_textN ( n c-addr/u n -- n c-addr/u c-addr )
720 \ now we have the buffer c-addr on top
721 \ ( followed by c-addr/u of current caption )
724 2dup c! -rot \ store strlen at first byte
727 -rot -rot \ bring buffer addr to top
730 rot 1- \ bring buffer len to top and decrement
753 dup ( n -- n n ) \ key pressed
759 getenv dup -1 <> if
761 2 pick ( n c-addr/u -- n c-addr/u n ) \ key pressed
770 drop ( n -1 -- n ) \ getenv cruft
777 dup init_textN count ( n -- n c-addr/u )
780 2 pick ( n c-addr/u -- n c-addr/u n ) \ key pressed
795 : cycle_menuitem ( N -- N ) \ cycles through array of choices for a menuitem
797 \ ASCII numeral equal to user-selected menu item must be on the stack.
807 dup 48 + ( n addr k -- n addr k k' )
810 3 pick swap ( n addr k k' -- n addr k n k' ) \ (n,k') as (x,y)
816 ( n addr k n k' -- n addr k c-addr/u )
822 getenv dup -1 = if
825 drop ( n addr k -1 -- n addr k ) \ getenv cruft
826 drop 0 ( n addr k -- n addr 0 ) \ new value to store later
828 2 pick [char] 0 ( n addr 0 -- n addr 0 n 48 ) \ (n,48) as (x,y)
834 ( n addr 0 n 48 -- n addr 0 c-addr/u )
835 getenv dup -1 = if
845 \ n - Ascii numeral representing the menu choice (inherited)
846 \ addr - address of our internal cycle_stateN variable
847 \ k - zero-based number we intend to store to the above
848 \ c-addr/u - string value we intend to store to menu_caption[x]
854 4 pick ( n addr k c-addr/u -- n addr k c-addr/u n )
862 swap ! ( n addr k -- n ) \ update array state variable
865 only forth definitions also menu-infrastructure
870 : menu-redraw ( -- )
871 menu-erase
872 menu-create
875 : menu-box ( -- )
878 s" loader_menu_frame" getenv dup -1 = if ( 1 )
880 else ( 1 ) 2dup s" single" compare-insensitive 0= if ( 2 )
882 else ( 2 ) 2dup s" double" compare-insensitive 0= if ( 3 )
884 else ( 3 ) s" none" compare-insensitive 0= if ( 4 )
888 42 13 menuX @ 3 - menuY @ 1- box \ Draw frame (w,h,x,y)
893 \ before calling any other menu-related functions.
895 : menu-init ( -- )
897 1- menuidx ! \ Initialize the starting index for the menu
901 s" loader_menu_y" getenv dup -1 = if
911 s" loader_menu_x" getenv dup -1 = if
922 ['] menu-box console-iterate
923 at-bl
926 also menu-namespace
930 : menu-display ( -- )
935 s" menu_timeout_command" getenv -1 <> if ( Addr C -1 -- | Addr )
936 drop ( just testing existence right now: Addr -- )
942 \ read custom time-duration (if set)
943 s" autoboot_delay" getenv dup -1 = if
944 drop \ no custom duration (remove dup'd bunk -1)
949 s" NO" compare-insensitive 0= if
956 -rot 2drop
961 menu-create
962 at-bl
971 s" loader_menu_timeout_x" getenv dup -1 = if
983 s" loader_menu_timeout_y" getenv dup -1 = if
996 cursor-invisible cursor-set
997 menu-create
1001 at-bl
1005 cursor-normal cursor-set
1007 cursor-invisible cursor-set
1009 dup -1 = if
1010 cursor-normal cursor-set
1014 \ Boot if the user pressed Enter/Ctrl-M (13) or
1015 \ Ctrl-Enter/Ctrl-J (10)
1018 cursor-normal cursor-set
1023 dup menureboot @ = if 0 reboot then
1033 \ Adjust for missing ACPI menuitem on non-i386
1034 \ arch-i386? true <> menuacpi @ 0<> and if
1035 \ menuacpi @ over 2dup < -rot = or
1037 \ ( key >= menuacpi && key < 58: N -- N )
1044 getenv dup -1 <> if
1046 cursor-normal cursor-set
1049 \ We expect there to be a non-zero
1061 cursor-invisible cursor-set
1064 \ Re-adjust for missing ACPI menuitem
1065 \ arch-i386? true <> menuacpi @ 0<> and if
1067 \ menuacpi @ 1+ over 2dup < -rot = or
1069 \ 1-
1081 getenv dup -1 = if
1088 getenv dup -1 <> if
1089 cursor-normal
1090 cursor-set
1096 cursor-invisible
1097 cursor-set
1113 again \ Non-operational key was pressed; repeat
1119 : menu-unset ( -- )
1140 0 over menukeyN ! \ used by menu-create, menu-display
1141 0 over init_stateN ! \ used by menu-create
1151 s" menu_reboot" unsetenv \ Reboot menu option flag
1166 only forth definitions also menu-infrastructure
1169 \ in-preparation for another menu.
1171 : menu-clear ( -- )
1172 menu-unset
1173 menu-erase
1178 also menu-namespace