beastie.4th revision 137071
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 137071 2004-10-30 13:45:13Z brooks $ 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" 1+ 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 then 125 true 126; 127 128: printmenuitem ( -- n ) 129 menuidx @ 130 1+ dup 131 menuidx ! 132 menuY @ + dup menuX @ swap at-xy 133 menuidx @ . 134 menuX @ 1+ swap at-xy 135 menubllt @ emit 136 menuidx @ 48 + 137; 138 139: beastie-menu ( -- ) 140 0 menuidx ! 141 dot menubllt ! 142 8 menuY ! 143 5 menuX ! 144 clear 145 46 4 print-beastie 146 42 20 2 2 box 147 13 6 at-xy ." Welcome to FreeBSD!" 148 printmenuitem ." Boot FreeBSD [default]" bootkey ! 149 s" arch-i386" environment? if 150 printmenuitem ." Boot FreeBSD with ACPI " bootacpikey ! 151 acpienabled? if 152 ." disabled" 153 else 154 ." enabled" 155 then 156 else 157 -2 bootacpikey ! 158 then 159 printmenuitem ." Boot FreeBSD in Safe Mode" bootsafekey ! 160 printmenuitem ." Boot FreeBSD in single user mode" bootsinglekey ! 161 printmenuitem ." Boot FreeBSD with verbose logging" bootverbosekey ! 162 printmenuitem ." Escape to loader prompt" escapekey ! 163 s" arch-i386" environment? if 164 printmenuitem ." Boot FreeBSD with USB keyboard" bootusbkey ! 165 else 166 -2 bootacpikey ! 167 then 168 printmenuitem ." Reboot" rebootkey ! 169 menuX @ 20 at-xy 170 ." Select option, [Enter] for default" 171 menuX @ 21 at-xy 172 s" or [Space] to pause timer " dup 2 - promptwidth ! 173 type 174; 175 176: tkey 177 dup 178 seconds + 179 begin 1 while 180 over 0<> if 181 dup seconds u< if 182 drop 183 -1 184 exit 185 then 186 menuX @ promptwidth @ + 21 at-xy dup seconds - . 187 then 188 key? if 189 drop 190 key 191 exit 192 then 193 50 ms 194 repeat 195; 196 197set-current 198 199: beastie-start 200 s" beastie_disable" getenv 201 dup -1 <> if 202 s" YES" compare-insensitive 0= if 203 exit 204 then 205 then 206 beastie-menu 207 s" autoboot_delay" getenv 208 dup -1 = if 209 drop 210 10 211 else 212 0 0 2swap >number drop drop drop 213 then 214 begin true while 215 dup tkey 216 0 25 at-xy 217 dup 32 = if nip 0 swap then 218 dup -1 = if 0 boot then 219 dup 13 = if 0 boot then 220 dup bootkey @ = if 0 boot then 221 dup bootacpikey @ = if 222 acpienabled? if 223 s" acpi_load" unsetenv 224 s" 1" s" hint.acpi.0.disabled" setenv 225 s" 1" s" loader.acpi_disabled_by_user" setenv 226 else 227 s" YES" s" acpi_load" setenv 228 s" 0" s" hint.acpi.0.disabled" setenv 229 then 230 0 boot 231 then 232 dup bootusbkey @ = if 233 s" 0x1" s" hint.atkbd.0.flags" setenv 234 0 boot 235 then 236 dup bootsafekey @ = if 237 s" arch-i386" environment? if 238 s" acpi_load" unsetenv 239 s" 1" s" hint.acpi.0.disabled" setenv 240 s" 1" s" loader.acpi_disabled_by_user" setenv 241 s" 1" s" hint.apic.0.disabled" setenv 242 then 243 s" 0" s" hw.ata.ata_dma" setenv 244 s" 0" s" hw.ata.atapi_dma" setenv 245 s" 0" s" hw.ata.wc" setenv 246 s" 0" s" hw.eisa_slots" setenv 247 0 boot 248 then 249 dup bootverbosekey @ = if 250 s" YES" s" boot_verbose" setenv 251 0 boot 252 then 253 dup bootsinglekey @ = if 254 s" YES" s" boot_single" setenv 255 0 boot 256 then 257 dup escapekey @ = if 258 2drop 259 s" NO" s" autoboot_delay" setenv 260 exit 261 then 262 rebootkey @ = if 0 reboot then 263 repeat 264; 265 266previous 267