1 \ Copyright (c) 2006-2013 Devin Teske <dteske@FreeBSD.org>
4 \ Redistribution and use in source and binary forms, with or without
5 \ modification, are permitted provided that the following conditions
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.
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
27 marker task-menu-commands.4th
29 include /boot/menusets.4th
40 : init_boot ( N -- N )
42 s" boot_single" getenv -1 <> if
43 drop ( n n c-addr -- n n ) \ unused
44 toggle_menuitem ( n n -- n n )
45 s" set menu_keycode[N]=115" \ base command to execute
47 s" set menu_keycode[N]=98" \ base command to execute
49 17 +c! \ replace 'N' with ASCII numeral
57 : init_altboot ( N -- N )
59 s" boot_single" getenv -1 <> if
60 drop ( n c-addr -- n ) \ unused
61 toggle_menuitem ( n -- n )
62 s" set menu_keycode[N]=109" \ base command to execute
64 s" set menu_keycode[N]=115" \ base command to execute
66 17 +c! \ replace 'N' with ASCII numeral
71 s" boot_single" 2dup getenv -1 <> if
72 drop ( c-addr/u c-addr -- c-addr/u ) \ unused
73 unsetenv ( c-addr/u -- )
75 2drop ( c-addr/u -- ) \ unused
76 s" set boot_single=YES" evaluate
86 s" set acpi_load=YES" evaluate \ XXX deprecated but harmless
87 s" set hint.acpi.0.disabled=0" evaluate
88 s" loader.acpi_disabled_by_user" unsetenv
92 s" acpi_load" unsetenv \ XXX deprecated but harmless
93 s" set hint.acpi.0.disabled=1" evaluate
94 s" set loader.acpi_disabled_by_user=1" evaluate
97 : toggle_acpi ( N -- N TRUE )
99 \ Make changes effective _before_ calling menu-redraw
109 TRUE \ loop menu again
116 : safemode_enabled? ( -- flag )
117 s" kern.smp.disabled" getenv -1 <> dup if
118 swap drop ( c-addr flag -- flag )
122 : safemode_enable ( -- )
123 s" set kern.smp.disabled=1" evaluate
124 s" set hw.ata.ata_dma=0" evaluate
125 s" set hw.ata.atapi_dma=0" evaluate
126 s" set hw.ata.wc=0" evaluate
127 s" set hw.eisa_slots=0" evaluate
128 s" set kern.eventtimer.periodic=1" evaluate
129 s" set kern.geom.part.check_integrity=0" evaluate
132 : safemode_disable ( -- )
133 s" kern.smp.disabled" unsetenv
134 s" hw.ata.ata_dma" unsetenv
135 s" hw.ata.atapi_dma" unsetenv
136 s" hw.ata.wc" unsetenv
137 s" hw.eisa_slots" unsetenv
138 s" kern.eventtimer.periodic" unsetenv
139 s" kern.geom.part.check_integrity" unsetenv
142 : init_safemode ( N -- N )
144 toggle_menuitem ( n -- n )
148 : toggle_safemode ( N -- N TRUE )
151 \ Now we're going to make the change effective
153 dup toggle_stateN @ 0= if
161 TRUE \ loop menu again
168 : singleuser_enabled? ( -- flag )
169 s" boot_single" getenv -1 <> dup if
170 swap drop ( c-addr flag -- flag )
174 : singleuser_enable ( -- )
175 s" set boot_single=YES" evaluate
178 : singleuser_disable ( -- )
179 s" boot_single" unsetenv
182 : init_singleuser ( N -- N )
183 singleuser_enabled? if
184 toggle_menuitem ( n -- n )
188 : toggle_singleuser ( N -- N TRUE )
192 \ Now we're going to make the change effective
194 dup toggle_stateN @ 0= if
200 TRUE \ loop menu again
207 : verbose_enabled? ( -- flag )
208 s" boot_verbose" getenv -1 <> dup if
209 swap drop ( c-addr flag -- flag )
213 : verbose_enable ( -- )
214 s" set boot_verbose=YES" evaluate
217 : verbose_disable ( -- )
218 s" boot_verbose" unsetenv
221 : init_verbose ( N -- N )
223 toggle_menuitem ( n -- n )
227 : toggle_verbose ( N -- N TRUE )
231 \ Now we're going to make the change effective
233 dup toggle_stateN @ 0= if
239 TRUE \ loop menu again
246 : goto_prompt ( N -- N FALSE )
248 s" set autoboot_delay=NO" evaluate
251 ." To get back to the menu, type `menu' and press ENTER" cr
252 ." or type `boot' and press ENTER to start FreeBSD." cr
255 FALSE \ exit the menu
259 \ Cyclestate (used by kernel/root below)
262 : init_cyclestate ( N K -- N )
263 over cycle_stateN ( n k -- n k addr )
265 tuck @ ( n k addr -- n addr k c )
266 over <> ( n addr k c -- n addr k 0|-1 )
268 rot ( n addr k -- addr k n )
270 swap rot ( addr k n -- n k addr )
272 2drop ( n k addr -- n )
279 : init_kernel ( N -- N )
280 kernel_state @ ( n -- n k )
281 init_cyclestate ( n k -- n )
284 : activate_kernel ( N -- N )
285 dup cycle_stateN @ ( n -- n n2 )
286 dup kernel_state ! ( n n2 -- n n2 ) \ copy for re-initialization
287 48 + ( n n2 -- n n2' ) \ kernel_state to ASCII num
289 s" set kernel=${kernel_prefix}${kernel[N]}${kernel_suffix}"
290 36 +c! ( n n2 c-addr/u -- n c-addr/u ) \ 'N' to ASCII num
291 evaluate ( n c-addr/u -- n ) \ sets $kernel to full kernel-path
294 : cycle_kernel ( N -- N TRUE )
295 cycle_menuitem \ cycle cycle_stateN to next value
296 activate_kernel \ apply current cycle_stateN
297 menu-redraw \ redraw menu
298 TRUE \ loop menu again
305 : init_root ( N -- N )
306 root_state @ ( n -- n k )
307 init_cyclestate ( n k -- n )
310 : activate_root ( N -- N )
311 dup cycle_stateN @ ( n -- n n2 )
312 dup root_state ! ( n n2 -- n n2 ) \ copy for re-initialization
313 48 + ( n n2 -- n n2' ) \ root_state to ASCII num
315 s" set root=${root_prefix}${root[N]}${root_suffix}"
316 30 +c! ( n n2 c-addr/u -- n c-addr/u ) \ 'N' to ASCII num
317 evaluate ( n c-addr/u -- n ) \ sets $root to full kernel-path
320 : cycle_root ( N -- N TRUE )
321 cycle_menuitem \ cycle cycle_stateN to next value
322 activate_root \ apply current cycle_stateN
323 menu-redraw \ redraw menu
324 TRUE \ loop menu again
331 : goto_menu ( N M -- N TRUE )
333 menuset-loadsetnum ( n m -- n )
335 TRUE \ Loop menu again
342 : set_default_boot_options ( N -- N TRUE )