menu-commands.4th revision 241367
1241310Sdteske\ Copyright (c) 2006-2012 Devin Teske <dteske@FreeBSD.org>
2222417Sjulian\ All rights reserved.
3222417Sjulian\ 
4222417Sjulian\ Redistribution and use in source and binary forms, with or without
5222417Sjulian\ modification, are permitted provided that the following conditions
6222417Sjulian\ are met:
7222417Sjulian\ 1. Redistributions of source code must retain the above copyright
8222417Sjulian\    notice, this list of conditions and the following disclaimer.
9222417Sjulian\ 2. Redistributions in binary form must reproduce the above copyright
10222417Sjulian\    notice, this list of conditions and the following disclaimer in the
11222417Sjulian\    documentation and/or other materials provided with the distribution.
12222417Sjulian\ 
13222417Sjulian\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14222417Sjulian\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15222417Sjulian\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16222417Sjulian\ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17222417Sjulian\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18222417Sjulian\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19222417Sjulian\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20222417Sjulian\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21222417Sjulian\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22222417Sjulian\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23222417Sjulian\ SUCH DAMAGE.
24222417Sjulian\ 
25222417Sjulian\ $FreeBSD: head/sys/boot/forth/menu-commands.4th 241367 2012-10-09 03:54:53Z dteske $
26222417Sjulian
27222417Sjulianmarker task-menu-commands.4th
28222417Sjulian
29222417Sjulian: acpi_enable ( -- )
30222417Sjulian	s" set acpi_load=YES" evaluate \ XXX deprecated but harmless
31222417Sjulian	s" set hint.acpi.0.disabled=0" evaluate
32222417Sjulian	s" loader.acpi_disabled_by_user" unsetenv
33222417Sjulian;
34222417Sjulian
35222417Sjulian: acpi_disable ( -- )
36222417Sjulian	s" acpi_load" unsetenv \ XXX deprecated but harmless
37222417Sjulian	s" set hint.acpi.0.disabled=1" evaluate
38222417Sjulian	s" set loader.acpi_disabled_by_user=1" evaluate
39222417Sjulian;
40222417Sjulian
41222417Sjulian: toggle_acpi ( N -- N TRUE )
42222417Sjulian
43222417Sjulian	\ Make changes effective _before_ calling menu-redraw
44222417Sjulian
45222417Sjulian	acpienabled? if
46222417Sjulian		acpi_disable
47222417Sjulian	else
48222417Sjulian		acpi_enable
49222417Sjulian	then
50222417Sjulian
51222417Sjulian	menu-redraw
52222417Sjulian
53222417Sjulian	TRUE \ loop menu again
54222417Sjulian;
55222417Sjulian
56222417Sjulian: toggle_safemode ( N -- N TRUE )
57222417Sjulian	toggle_menuitem
58222417Sjulian
59222417Sjulian	\ Now we're going to make the change effective
60222417Sjulian
61222417Sjulian	s" toggle_stateN @"      \ base name of toggle state var
62222417Sjulian	-rot 2dup 12 + c! rot    \ replace 'N' with ASCII numeral
63222417Sjulian
64222417Sjulian	evaluate 0= if
65233941Savg		s" kern.smp.disabled" unsetenv
66222417Sjulian		s" hw.ata.ata_dma" unsetenv
67222417Sjulian		s" hw.ata.atapi_dma" unsetenv
68222417Sjulian		s" hw.ata.wc" unsetenv
69222417Sjulian		s" hw.eisa_slots" unsetenv
70233941Savg		s" kern.eventtimer.periodic" unsetenv
71233941Savg		s" kern.geom.part.check_integrity" unsetenv
72222417Sjulian	else
73233941Savg		s" set kern.smp.disabled=1" evaluate
74222417Sjulian		s" set hw.ata.ata_dma=0" evaluate
75222417Sjulian		s" set hw.ata.atapi_dma=0" evaluate
76222417Sjulian		s" set hw.ata.wc=0" evaluate
77222417Sjulian		s" set hw.eisa_slots=0" evaluate
78233941Savg		s" set kern.eventtimer.periodic=1" evaluate
79233941Savg		s" set kern.geom.part.check_integrity=0" evaluate
80222417Sjulian	then
81222417Sjulian
82222417Sjulian	menu-redraw
83222417Sjulian
84222417Sjulian	TRUE \ loop menu again
85222417Sjulian;
86222417Sjulian
87222417Sjulian: toggle_singleuser ( N -- N TRUE )
88222417Sjulian	toggle_menuitem
89222417Sjulian	menu-redraw
90222417Sjulian
91222417Sjulian	\ Now we're going to make the change effective
92222417Sjulian
93222417Sjulian	s" toggle_stateN @"      \ base name of toggle state var
94222417Sjulian	-rot 2dup 12 + c! rot    \ replace 'N' with ASCII numeral
95222417Sjulian
96222417Sjulian	evaluate 0= if
97222417Sjulian		s" boot_single" unsetenv
98222417Sjulian	else
99222417Sjulian		s" set boot_single=YES" evaluate
100222417Sjulian	then
101222417Sjulian
102222417Sjulian	TRUE \ loop menu again
103222417Sjulian;
104222417Sjulian
105222417Sjulian: toggle_verbose ( N -- N TRUE )
106222417Sjulian	toggle_menuitem
107222417Sjulian	menu-redraw
108222417Sjulian
109222417Sjulian	\ Now we're going to make the change effective
110222417Sjulian
111222417Sjulian	s" toggle_stateN @"      \ base name of toggle state var
112222417Sjulian	-rot 2dup 12 + c! rot    \ replace 'N' with ASCII numeral
113222417Sjulian
114222417Sjulian	evaluate 0= if
115222417Sjulian		s" boot_verbose" unsetenv
116222417Sjulian	else
117222417Sjulian		s" set boot_verbose=YES" evaluate
118222417Sjulian	then
119222417Sjulian
120222417Sjulian	TRUE \ loop menu again
121222417Sjulian;
122222417Sjulian
123222417Sjulian: goto_prompt ( N -- N FALSE )
124222417Sjulian
125222417Sjulian	s" set autoboot_delay=NO" evaluate
126222417Sjulian
127222417Sjulian	cr
128222417Sjulian	." To get back to the menu, type `menu' and press ENTER" cr
129222417Sjulian	." or type `boot' and press ENTER to start FreeBSD." cr
130222417Sjulian	cr
131222417Sjulian
132222417Sjulian	FALSE \ exit the menu
133222417Sjulian;
134222417Sjulian
135222417Sjulian: cycle_kernel ( N -- N TRUE )
136222417Sjulian	cycle_menuitem
137222417Sjulian	menu-redraw
138222417Sjulian
139222417Sjulian	\ Now we're going to make the change effective
140222417Sjulian
141222417Sjulian	s" cycle_stateN"         \ base name of array state var
142222417Sjulian	-rot 2dup 11 + c! rot    \ replace 'N' with ASCII numeral
143222417Sjulian	evaluate                 \ translate name into address
144222417Sjulian	@                        \ dereference address into value
145222417Sjulian	48 +                     \ convert to ASCII numeral
146222417Sjulian
147222417Sjulian	s" set kernel=${kernel_prefix}${kernel[N]}${kernel_suffix}"
148222417Sjulian	                          \ command to assemble full kernel-path
149222417Sjulian	-rot tuck 36 + c! swap    \ replace 'N' with array index value
150222417Sjulian	evaluate                  \ sets $kernel to full kernel-path
151222417Sjulian
152222417Sjulian	TRUE \ loop menu again
153222417Sjulian;
154222417Sjulian
155222417Sjulian: cycle_root ( N -- N TRUE )
156222417Sjulian	cycle_menuitem
157222417Sjulian	menu-redraw
158222417Sjulian
159222417Sjulian	\ Now we're going to make the change effective
160222417Sjulian
161222417Sjulian	s" cycle_stateN"         \ base name of array state var
162222417Sjulian	-rot 2dup 11 + c! rot    \ replace 'N' with ASCII numeral
163222417Sjulian	evaluate                 \ translate name into address
164222417Sjulian	@                        \ dereference address into value
165222417Sjulian	48 +                     \ convert to ASCII numeral
166222417Sjulian
167241367Sdteske	s" set root=${root_prefix}${root[N]}${root_suffix}"
168241367Sdteske	                          \ command to assemble root image-path
169222417Sjulian	-rot tuck 30 + c! swap    \ replace 'N' with array index value
170222417Sjulian	evaluate                  \ sets $kernel to full kernel-path
171222417Sjulian
172222417Sjulian	TRUE \ loop menu again
173222417Sjulian;
174