beastie.4th revision 138258
1\ Copyright (c) 2003 Scott Long <scottl@freebsd.org> 2\ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com> 3\ All rights reserved. 4\ 5\ Redistribution and use in source and binary forms, with or without 6\ modification, are permitted provided that the following conditions 7\ are met: 8\ 1. Redistributions of source code must retain the above copyright 9\ notice, this list of conditions and the following disclaimer. 10\ 2. Redistributions in binary form must reproduce the above copyright 11\ notice, this list of conditions and the following disclaimer in the 12\ documentation and/or other materials provided with the distribution. 13\ 14\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17\ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24\ SUCH DAMAGE. 25\ 26\ $FreeBSD: head/sys/boot/forth/beastie.4th 138258 2004-12-01 07:17:57Z scottl $ 27 28marker task-beastie.4th 29 30include /boot/screen.4th 31include /boot/frames.4th 32 33hide 34 35variable menuidx 36variable menubllt 37variable menuX 38variable menuY 39variable promptwidth 40 41variable bootkey 42variable bootacpikey 43variable bootusbkey 44variable bootsafekey 45variable bootverbosekey 46variable bootsinglekey 47variable escapekey 48variable rebootkey 49 5046 constant dot 51 52\ The BSD Daemon. He is 19 rows high and 34 columns wide 53: technicolor-beastie ( x y -- ) 542dup at-xy ." [1;31m, ," 1+ 552dup at-xy ." /( )`" 1+ 562dup at-xy ." \ \___ / |" 1+ 572dup at-xy ." /- [37m_[31m `-/ '" 1+ 582dup at-xy ." ([37m/\/ \[31m \ /\" 1+ 592dup at-xy ." [37m/ / |[31m ` \" 1+ 602dup at-xy ." [34mO O [37m) [31m/ |" 1+ 612dup at-xy ." [37m`-^--'[31m`< '" 1+ 622dup at-xy ." (_.) _ ) /" 1+ 632dup at-xy ." `.___/` / " 1+ 642dup at-xy ." `-----' /" 1+ 652dup at-xy ." [33m<----.[31m __ / __ \" 1+ 662dup at-xy ." [33m<----|====[31mO)))[33m==[31m) \) /[33m====|" 1+ 672dup at-xy ." [33m<----'[31m `--' `.__,' \" 1+ 682dup at-xy ." | |" 1+ 692dup at-xy ." \ / /\" 1+ 702dup at-xy ." [36m______[31m( (_ / \______/" 1+ 712dup at-xy ." [36m,' ,-----' |" 1+ 72at-xy ." `--{__________) [0m" 73; 74 75: boring-beastie ( x y -- ) 76 2dup at-xy ." , ," 1+ 77 2dup at-xy ." /( )`" 1+ 78 2dup at-xy ." \ \___ / |" 1+ 79 2dup at-xy ." /- _ `-/ '" 1+ 80 2dup at-xy ." (/\/ \ \ /\" 1+ 81 2dup at-xy ." / / | ` \" 1+ 82 2dup at-xy ." O O ) / |" 1+ 83 2dup at-xy ." `-^--'`< '" 1+ 84 2dup at-xy ." (_.) _ ) /" 1+ 85 2dup at-xy ." `.___/` /" 1+ 86 2dup at-xy ." `-----' /" 1+ 87 2dup at-xy ." <----. __ / __ \" 1+ 88 2dup at-xy ." <----|====O)))==) \) /====" 1+ 89 2dup at-xy ." <----' `--' `.__,' \" 1+ 90 2dup at-xy ." | |" 1+ 91 2dup at-xy ." \ / /\" 1+ 92 2dup at-xy ." ______( (_ / \______/" 1+ 93 2dup at-xy ." ,' ,-----' |" 1+ 94 at-xy ." `--{__________)" 95; 96 97: print-beastie ( x y -- ) 98 s" loader_color" getenv 99 dup -1 = if 100 drop 101 boring-beastie 102 exit 103 then 104 s" YES" compare-insensitive 0<> if 105 boring-beastie 106 exit 107 then 108 technicolor-beastie 109; 110 111: acpienabled? ( -- flag ) 112 s" acpi_load" getenv 113 dup -1 = if 114 drop false exit 115 then 116 s" YES" compare-insensitive 0<> if 117 false exit 118 then 119 s" hint.acpi.0.disabled" getenv 120 dup -1 <> if 121 s" 0" compare 0<> if 122 false exit 123 then 124 else 125 drop 126 then 127 true 128; 129 130: printmenuitem ( -- n ) 131 menuidx @ 132 1+ dup 133 menuidx ! 134 menuY @ + dup menuX @ swap at-xy 135 menuidx @ . 136 menuX @ 1+ swap at-xy 137 menubllt @ emit 138 menuidx @ 48 + 139; 140 141: beastie-menu ( -- ) 142 0 menuidx ! 143 dot menubllt ! 144 8 menuY ! 145 5 menuX ! 146 clear 147 46 4 print-beastie 148 42 20 2 2 box 149 13 6 at-xy ." Welcome to FreeBSD!" 150 printmenuitem ." Boot FreeBSD [default]" bootkey ! 151 s" arch-i386" environment? if 152 drop 153 printmenuitem ." Boot FreeBSD with ACPI " bootacpikey ! 154 acpienabled? if 155 ." disabled" 156 else 157 ." enabled" 158 then 159 else 160 -2 bootacpikey ! 161 then 162 printmenuitem ." Boot FreeBSD in Safe Mode" bootsafekey ! 163 printmenuitem ." Boot FreeBSD in single user mode" bootsinglekey ! 164 printmenuitem ." Boot FreeBSD with verbose logging" bootverbosekey ! 165 printmenuitem ." Escape to loader prompt" escapekey ! 166 s" arch-i386" environment? if 167 drop 168 printmenuitem ." Boot FreeBSD with USB keyboard" bootusbkey ! 169 else 170 -2 bootusbkey ! 171 then 172 printmenuitem ." Reboot" rebootkey ! 173 menuX @ 20 at-xy 174 ." Select option, [Enter] for default" 175 menuX @ 21 at-xy 176 s" or [Space] to pause timer " dup 2 - promptwidth ! 177 type 178; 179 180: tkey 181 seconds + 182 begin 1 while 183 over 0<> if 184 dup seconds u< if 185 drop 186 -1 187 exit 188 then 189 menuX @ promptwidth @ + 21 at-xy dup seconds - . 190 then 191 key? if 192 drop 193 key 194 exit 195 then 196 50 ms 197 repeat 198; 199 200set-current 201 202: beastie-start 203 s" beastie_disable" getenv 204 dup -1 <> if 205 s" YES" compare-insensitive 0= if 206 exit 207 then 208 else 209 drop 210 then 211 beastie-menu 212 s" autoboot_delay" getenv 213 dup -1 = if 214 drop 215 10 216 else 217 0 0 2swap >number drop drop drop 218 then 219 begin 220 dup tkey 221 0 25 at-xy 222 dup 32 = if nip 0 swap then 223 dup -1 = if 0 boot then 224 dup 13 = if 0 boot then 225 dup bootkey @ = if 0 boot then 226 dup bootacpikey @ = if 227 acpienabled? if 228 s" acpi_load" unsetenv 229 s" 1" s" hint.acpi.0.disabled" setenv 230 s" 1" s" loader.acpi_disabled_by_user" setenv 231 else 232 s" YES" s" acpi_load" setenv 233 s" 0" s" hint.acpi.0.disabled" setenv 234 then 235 0 boot 236 then 237 dup bootusbkey @ = if 238 s" 0x1" s" hint.atkbd.0.flags" setenv 239 0 boot 240 then 241 dup bootsafekey @ = if 242 s" arch-i386" environment? if 243 drop 244 s" acpi_load" unsetenv 245 s" 1" s" hint.acpi.0.disabled" setenv 246 s" 1" s" loader.acpi_disabled_by_user" setenv 247 s" 1" s" hint.apic.0.disabled" setenv 248 then 249 s" 0" s" hw.ata.ata_dma" setenv 250 s" 0" s" hw.ata.atapi_dma" setenv 251 s" 0" s" hw.ata.wc" setenv 252 s" 0" s" hw.eisa_slots" setenv 253 0 boot 254 then 255 dup bootverbosekey @ = if 256 s" YES" s" boot_verbose" setenv 257 0 boot 258 then 259 dup bootsinglekey @ = if 260 s" YES" s" boot_single" setenv 261 0 boot 262 then 263 dup escapekey @ = if 264 2drop 265 s" NO" s" autoboot_delay" setenv 266 exit 267 then 268 rebootkey @ = if 0 reboot then 269 again 270; 271 272previous 273