menu-commands.4th revision 241523
1\ Copyright (c) 2006-2012 Devin Teske <dteske@FreeBSD.org> 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: head/sys/boot/forth/menu-commands.4th 241523 2012-10-14 06:52:49Z dteske $ 26 27marker task-menu-commands.4th 28 29variable kernel_state 30variable root_state 31 32: acpi_enable ( -- ) 33 s" set acpi_load=YES" evaluate \ XXX deprecated but harmless 34 s" set hint.acpi.0.disabled=0" evaluate 35 s" loader.acpi_disabled_by_user" unsetenv 36; 37 38: acpi_disable ( -- ) 39 s" acpi_load" unsetenv \ XXX deprecated but harmless 40 s" set hint.acpi.0.disabled=1" evaluate 41 s" set loader.acpi_disabled_by_user=1" evaluate 42; 43 44: toggle_acpi ( N -- N TRUE ) 45 46 \ Make changes effective _before_ calling menu-redraw 47 48 acpienabled? if 49 acpi_disable 50 else 51 acpi_enable 52 then 53 54 menu-redraw 55 56 TRUE \ loop menu again 57; 58 59: init_safemode ( N -- N ) 60 s" kern.smp.disabled" getenv -1 <> if 61 drop ( n c-addr -- n ) \ unused 62 toggle_menuitem ( n -- n ) 63 then 64; 65 66: toggle_safemode ( N -- N TRUE ) 67 toggle_menuitem 68 69 \ Now we're going to make the change effective 70 71 s" toggle_stateN @" \ base name of toggle state var 72 -rot 2dup 12 + c! rot \ replace 'N' with ASCII numeral 73 74 evaluate 0= if 75 s" kern.smp.disabled" unsetenv 76 s" hw.ata.ata_dma" unsetenv 77 s" hw.ata.atapi_dma" unsetenv 78 s" hw.ata.wc" unsetenv 79 s" hw.eisa_slots" unsetenv 80 s" kern.eventtimer.periodic" unsetenv 81 s" kern.geom.part.check_integrity" unsetenv 82 else 83 s" set kern.smp.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 kern.eventtimer.periodic=1" evaluate 89 s" set kern.geom.part.check_integrity=0" evaluate 90 then 91 92 menu-redraw 93 94 TRUE \ loop menu again 95; 96 97: init_singleuser ( N -- N ) 98 s" boot_single" getenv -1 <> if 99 drop ( n c-addr -- n ) \ unused 100 toggle_menuitem ( n -- n ) 101 then 102; 103 104: toggle_singleuser ( N -- N TRUE ) 105 toggle_menuitem 106 menu-redraw 107 108 \ Now we're going to make the change effective 109 110 s" toggle_stateN @" \ base name of toggle state var 111 -rot 2dup 12 + c! rot \ replace 'N' with ASCII numeral 112 113 evaluate 0= if 114 s" boot_single" unsetenv 115 else 116 s" set boot_single=YES" evaluate 117 then 118 119 TRUE \ loop menu again 120; 121 122: init_verbose ( N -- N ) 123 s" boot_verbose" getenv -1 <> if 124 drop ( n c-addr -- n ) \ unused 125 toggle_menuitem ( n -- n ) 126 then 127; 128 129: toggle_verbose ( N -- N TRUE ) 130 toggle_menuitem 131 menu-redraw 132 133 \ Now we're going to make the change effective 134 135 s" toggle_stateN @" \ base name of toggle state var 136 -rot 2dup 12 + c! rot \ replace 'N' with ASCII numeral 137 138 evaluate 0= if 139 s" boot_verbose" unsetenv 140 else 141 s" set boot_verbose=YES" evaluate 142 then 143 144 TRUE \ loop menu again 145; 146 147: goto_prompt ( N -- N FALSE ) 148 149 s" set autoboot_delay=NO" evaluate 150 151 cr 152 ." To get back to the menu, type `menu' and press ENTER" cr 153 ." or type `boot' and press ENTER to start FreeBSD." cr 154 cr 155 156 FALSE \ exit the menu 157; 158 159: init_cyclestate ( N K -- N ) 160 over ( n k -- n k n ) 161 s" cycle_stateN" ( n k n -- n k n c-addr u ) 162 -rot tuck 11 + c! swap ( n k n c-addr u -- n k c-addr u ) 163 evaluate ( n k c-addr u -- n k addr ) 164 begin 165 tuck @ ( n k addr -- n addr k c ) 166 over <> ( n addr k c -- n addr k 0|-1 ) 167 while 168 rot ( n addr k -- addr k n ) 169 cycle_menuitem 170 swap rot ( addr k n -- n k addr ) 171 repeat 172 2drop ( n k addr -- n ) 173; 174 175: init_kernel ( N -- N ) 176 kernel_state @ ( n -- n k ) 177 init_cyclestate ( n k -- n ) 178; 179 180: cycle_kernel ( N -- N TRUE ) 181 cycle_menuitem 182 menu-redraw 183 184 \ Now we're going to make the change effective 185 186 s" cycle_stateN" \ base name of array state var 187 -rot 2dup 11 + c! rot \ replace 'N' with ASCII numeral 188 evaluate \ translate name into address 189 @ \ dereference address into value 190 dup kernel_state ! \ save a copy for re-initialization 191 48 + \ convert to ASCII numeral 192 193 s" set kernel=${kernel_prefix}${kernel[N]}${kernel_suffix}" 194 \ command to assemble full kernel-path 195 -rot tuck 36 + c! swap \ replace 'N' with array index value 196 evaluate \ sets $kernel to full kernel-path 197 198 TRUE \ loop menu again 199; 200 201: init_root ( N -- N ) 202 root_state @ ( n -- n k ) 203 init_cyclestate ( n k -- n ) 204; 205 206: cycle_root ( N -- N TRUE ) 207 cycle_menuitem 208 menu-redraw 209 210 \ Now we're going to make the change effective 211 212 s" cycle_stateN" \ base name of array state var 213 -rot 2dup 11 + c! rot \ replace 'N' with ASCII numeral 214 evaluate \ translate name into address 215 @ \ dereference address into value 216 dup root_state ! \ save a copy for re-initialization 217 48 + \ convert to ASCII numeral 218 219 s" set root=${root_prefix}${root[N]}${root_suffix}" 220 \ command to assemble root image-path 221 -rot tuck 30 + c! swap \ replace 'N' with array index value 222 evaluate \ sets $kernel to full kernel-path 223 224 TRUE \ loop menu again 225; 226