]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/boot/forth/menu-commands.4th
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / boot / forth / menu-commands.4th
1 \ Copyright (c) 2006-2011 Devin Teske <devinteske@hotmail.com>
2 \ All rights reserved.
3
4 \ Redistribution and use in source and binary forms, with or without
5 \ modification, are permitted provided that the following conditions
6 \ are met:
7 \ 1. Redistributions of source code must retain the above copyright
8 \    notice, this list of conditions and the following disclaimer.
9 \ 2. Redistributions in binary form must reproduce the above copyright
10 \    notice, this list of conditions and the following disclaimer in the
11 \    documentation and/or other materials provided with the distribution.
12
13 \ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 \ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 \ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 \ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 \ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 \ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 \ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 \ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 \ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 \ SUCH DAMAGE.
24
25 \ $FreeBSD$
26
27 marker task-menu-commands.4th
28
29 : acpi_enable ( -- )
30         s" set acpi_load=YES" evaluate \ XXX deprecated but harmless
31         s" set hint.acpi.0.disabled=0" evaluate
32         s" loader.acpi_disabled_by_user" unsetenv
33 ;
34
35 : acpi_disable ( -- )
36         s" acpi_load" unsetenv \ XXX deprecated but harmless
37         s" set hint.acpi.0.disabled=1" evaluate
38         s" set loader.acpi_disabled_by_user=1" evaluate
39 ;
40
41 : toggle_acpi ( N -- N TRUE )
42
43         \ Make changes effective _before_ calling menu-redraw
44
45         acpienabled? if
46                 acpi_disable
47         else
48                 acpi_enable
49         then
50
51         menu-redraw
52
53         TRUE \ loop menu again
54 ;
55
56 : toggle_safemode ( N -- N TRUE )
57         toggle_menuitem
58
59         \ Now we're going to make the change effective
60
61         s" toggle_stateN @"      \ base name of toggle state var
62         -rot 2dup 12 + c! rot    \ replace 'N' with ASCII numeral
63
64         evaluate 0= if
65                 s" hint.apic.0.disabled" unsetenv
66                 s" hw.ata.ata_dma" unsetenv
67                 s" hw.ata.atapi_dma" unsetenv
68                 s" hw.ata.wc" unsetenv
69                 s" hw.eisa_slots" unsetenv
70                 s" hint.kbdmux.0.disabled" unsetenv
71         else
72                 \ 
73                 \ Toggle ACPI elements if necessary
74                 \ 
75                 acpipresent? if acpienabled? if
76                         menuacpi @ dup 0<> if
77                                 toggle_menuitem ( N -- N )
78                         then
79                         drop
80                         acpi_disable
81                 then then
82
83                 s" set hint.apic.0.disabled=1" evaluate
84                 s" set hw.ata.ata_dma=0" evaluate
85                 s" set hw.ata.atapi_dma=0" evaluate
86                 s" set hw.ata.wc=0" evaluate
87                 s" set hw.eisa_slots=0" evaluate
88                 s" set hint.kbdmux.0.disabled=1" evaluate
89         then
90
91         menu-redraw
92
93         TRUE \ loop menu again
94 ;
95
96 : toggle_singleuser ( N -- N TRUE )
97         toggle_menuitem
98         menu-redraw
99
100         \ Now we're going to make the change effective
101
102         s" toggle_stateN @"      \ base name of toggle state var
103         -rot 2dup 12 + c! rot    \ replace 'N' with ASCII numeral
104
105         evaluate 0= if
106                 s" boot_single" unsetenv
107         else
108                 s" set boot_single=YES" evaluate
109         then
110
111         TRUE \ loop menu again
112 ;
113
114 : toggle_verbose ( N -- N TRUE )
115         toggle_menuitem
116         menu-redraw
117
118         \ Now we're going to make the change effective
119
120         s" toggle_stateN @"      \ base name of toggle state var
121         -rot 2dup 12 + c! rot    \ replace 'N' with ASCII numeral
122
123         evaluate 0= if
124                 s" boot_verbose" unsetenv
125         else
126                 s" set boot_verbose=YES" evaluate
127         then
128
129         TRUE \ loop menu again
130 ;
131
132 : goto_prompt ( N -- N FALSE )
133
134         s" set autoboot_delay=NO" evaluate
135
136         cr
137         ." To get back to the menu, type `menu' and press ENTER" cr
138         ." or type `boot' and press ENTER to start FreeBSD." cr
139         cr
140
141         FALSE \ exit the menu
142 ;
143
144 : cycle_kernel ( N -- N TRUE )
145         cycle_menuitem
146         menu-redraw
147
148         \ Now we're going to make the change effective
149
150         s" cycle_stateN"         \ base name of array state var
151         -rot 2dup 11 + c! rot    \ replace 'N' with ASCII numeral
152         evaluate                 \ translate name into address
153         @                        \ dereference address into value
154         48 +                     \ convert to ASCII numeral
155
156         \ Since we are [in this file] going to override the standard `boot'
157         \ routine with a custom one, you should know that we use $kernel
158         \ when referencing the desired kernel. Set $kernel below.
159
160         s" set kernel=${kernel_prefix}${kernel[N]}${kernel_suffix}"
161                                   \ command to assemble full kernel-path
162         -rot tuck 36 + c! swap    \ replace 'N' with array index value
163         evaluate                  \ sets $kernel to full kernel-path
164
165         TRUE \ loop menu again
166 ;
167
168 : cycle_root ( N -- N TRUE )
169         cycle_menuitem
170         menu-redraw
171
172         \ Now we're going to make the change effective
173
174         s" cycle_stateN"         \ base name of array state var
175         -rot 2dup 11 + c! rot    \ replace 'N' with ASCII numeral
176         evaluate                 \ translate name into address
177         @                        \ dereference address into value
178         48 +                     \ convert to ASCII numeral
179
180         \ Since we are [in this file] going to override the standard `boot'
181         \ routine with a custom one, you should know that we use $root when
182         \ booting. Set $root below.
183
184         s" set root=${root_prefix}${root[N]}${root_prefix}"
185                                   \ command to assemble full kernel-path
186         -rot tuck 30 + c! swap    \ replace 'N' with array index value
187         evaluate                  \ sets $kernel to full kernel-path
188
189         TRUE \ loop menu again
190 ;