beastie.4th revision 215016
11897Swollman\ Copyright (c) 2003 Scott Long <scottl@freebsd.org> 299979Salfred\ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com> 399979Salfred\ All rights reserved. 499979Salfred\ 51897Swollman\ Redistribution and use in source and binary forms, with or without 61897Swollman\ modification, are permitted provided that the following conditions 71897Swollman\ are met: 81897Swollman\ 1. Redistributions of source code must retain the above copyright 91897Swollman\ notice, this list of conditions and the following disclaimer. 101897Swollman\ 2. Redistributions in binary form must reproduce the above copyright 11100441Scharnier\ notice, this list of conditions and the following disclaimer in the 121897Swollman\ documentation and/or other materials provided with the distribution. 131897Swollman\ 141897Swollman\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15100441Scharnier\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 161897Swollman\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 171897Swollman\ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 181897Swollman\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19100441Scharnier\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 201897Swollman\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 211897Swollman\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 221897Swollman\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23100441Scharnier\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 241897Swollman\ SUCH DAMAGE. 251897Swollman\ 261897Swollman\ $FreeBSD: head/sys/boot/forth/beastie.4th 215016 2010-11-08 21:50:45Z jhb $ 27100441Scharnier 281897Swollmanmarker task-beastie.4th 291897Swollman 301897Swollmaninclude /boot/screen.4th 311897Swollmaninclude /boot/frames.4th 3299979Salfred 331897Swollmanhide 3412798Swpaul 3512798Swpaulvariable menuidx 3612798Swpaulvariable menubllt 3712798Swpaulvariable menuX 3812798Swpaulvariable menuY 3912798Swpaulvariable promptwidth 4012798Swpaul 4112798Swpaulvariable bootkey 4212798Swpaulvariable bootacpikey 4312798Swpaulvariable bootsafekey 4412798Swpaulvariable bootverbosekey 4512798Swpaulvariable bootsinglekey 4612798Swpaulvariable escapekey 4712798Swpaulvariable rebootkey 4812798Swpaul 4912798Swpaul46 constant dot 5012798Swpaul 5112798Swpaul\ The BSD Daemon. He is 19 rows high and 34 columns wide 5212798Swpaul: beastie-logo ( x y -- ) 53100441Scharnier2dup at-xy ." [1;31m, ," 1+ 5412798Swpaul2dup at-xy ." /( )`" 1+ 55100441Scharnier2dup at-xy ." \ \___ / |" 1+ 5612798Swpaul2dup at-xy ." /- [37m_[31m `-/ '" 1+ 5712798Swpaul2dup at-xy ." ([37m/\/ \[31m \ /\" 1+ 5812798Swpaul2dup at-xy ." [37m/ / |[31m ` \" 1+ 5912798Swpaul2dup at-xy ." [34mO O [37m) [31m/ |" 1+ 6012798Swpaul2dup at-xy ." [37m`-^--'[31m`< '" 1+ 61100441Scharnier2dup at-xy ." (_.) _ ) /" 1+ 6212798Swpaul2dup at-xy ." `.___/` / " 1+ 6312798Swpaul2dup at-xy ." `-----' /" 1+ 6412798Swpaul2dup at-xy ." [33m<----.[31m __ / __ \" 1+ 651897Swollman2dup at-xy ." [33m<----|====[31mO)))[33m==[31m) \) /[33m====|" 1+ 66100441Scharnier2dup at-xy ." [33m<----'[31m `--' `.__,' \" 1+ 671897Swollman2dup at-xy ." | |" 1+ 6812798Swpaul2dup at-xy ." \ / /\" 1+ 6912798Swpaul2dup at-xy ." [36m______[31m( (_ / \______/" 1+ 701897Swollman2dup at-xy ." [36m,' ,-----' |" 1+ 71100441Scharnierat-xy ." `--{__________) [0m" 721897Swollman; 7312798Swpaul 7412798Swpaul: beastiebw-logo ( x y -- ) 751897Swollman 2dup at-xy ." , ," 1+ 761897Swollman 2dup at-xy ." /( )`" 1+ 7712798Swpaul 2dup at-xy ." \ \___ / |" 1+ 781897Swollman 2dup at-xy ." /- _ `-/ '" 1+ 791897Swollman 2dup at-xy ." (/\/ \ \ /\" 1+ 801897Swollman 2dup at-xy ." / / | ` \" 1+ 811897Swollman 2dup at-xy ." O O ) / |" 1+ 8212798Swpaul 2dup at-xy ." `-^--'`< '" 1+ 8312798Swpaul 2dup at-xy ." (_.) _ ) /" 1+ 8412798Swpaul 2dup at-xy ." `.___/` /" 1+ 8512798Swpaul 2dup at-xy ." `-----' /" 1+ 8612798Swpaul 2dup at-xy ." <----. __ / __ \" 1+ 8712798Swpaul 2dup at-xy ." <----|====O)))==) \) /====" 1+ 8812798Swpaul 2dup at-xy ." <----' `--' `.__,' \" 1+ 8912798Swpaul 2dup at-xy ." | |" 1+ 9012798Swpaul 2dup at-xy ." \ / /\" 1+ 9112798Swpaul 2dup at-xy ." ______( (_ / \______/" 1+ 9212798Swpaul 2dup at-xy ." ,' ,-----' |" 1+ 9312798Swpaul at-xy ." `--{__________)" 9412798Swpaul; 9512798Swpaul 9612798Swpaul: fbsdbw-logo ( x y -- ) 9712798Swpaul 2dup at-xy ." ______" 1+ 9812798Swpaul 2dup at-xy ." | ____| __ ___ ___ " 1+ 9912798Swpaul 2dup at-xy ." | |__ | '__/ _ \/ _ \" 1+ 10012798Swpaul 2dup at-xy ." | __|| | | __/ __/" 1+ 10112798Swpaul 2dup at-xy ." | | | | | | |" 1+ 10212798Swpaul 2dup at-xy ." |_| |_| \___|\___|" 1+ 10312798Swpaul 2dup at-xy ." ____ _____ _____" 1+ 10412798Swpaul 2dup at-xy ." | _ \ / ____| __ \" 1+ 10512798Swpaul 2dup at-xy ." | |_) | (___ | | | |" 1+ 10612798Swpaul 2dup at-xy ." | _ < \___ \| | | |" 1+ 1071897Swollman 2dup at-xy ." | |_) |____) | |__| |" 1+ 108100441Scharnier 2dup at-xy ." | | | |" 1+ 1091897Swollman at-xy ." |____/|_____/|_____/" 11012798Swpaul; 1111897Swollman 1121897Swollman: print-logo ( x y -- ) 1131897Swollman s" loader_logo" getenv 1141897Swollman dup -1 = if 1151897Swollman drop 1161897Swollman fbsdbw-logo 1171897Swollman exit 1181897Swollman then 1191897Swollman 2dup s" fbsdbw" compare-insensitive 0= if 1201897Swollman 2drop 12112798Swpaul fbsdbw-logo 12212798Swpaul exit 12312798Swpaul then 12412798Swpaul 2dup s" beastiebw" compare-insensitive 0= if 12512798Swpaul 2drop 1261897Swollman beastiebw-logo 12712798Swpaul exit 1281897Swollman then 12912798Swpaul 2dup s" beastie" compare-insensitive 0= if 130100441Scharnier 2drop 13112798Swpaul beastie-logo 13212798Swpaul exit 13312798Swpaul then 13412798Swpaul 2dup s" none" compare-insensitive 0= if 13512798Swpaul 2drop 13612798Swpaul \ no logo 13712798Swpaul exit 13812798Swpaul then 13912798Swpaul 2drop 14012798Swpaul fbsdbw-logo 14112798Swpaul; 14212798Swpaul 14312798Swpaul: acpienabled? ( -- flag ) 14412798Swpaul s" hint.acpi.0.rsdp" getenv 14512798Swpaul dup -1 = if 14612798Swpaul drop false exit 14712798Swpaul then 14812798Swpaul 2drop 14912798Swpaul s" hint.acpi.0.disabled" getenv 15012798Swpaul dup -1 <> if 15112798Swpaul s" 0" compare 0<> if 152100441Scharnier false exit 15312798Swpaul then 15417142Sjkh else 15517142Sjkh drop 15617142Sjkh then 1571897Swollman true 158100441Scharnier; 159100441Scharnier 160100441Scharnier: printmenuitem ( -- n ) 1611897Swollman menuidx @ 16212798Swpaul 1+ dup 16312798Swpaul menuidx ! 1641897Swollman menuY @ + dup menuX @ swap at-xy 16512798Swpaul menuidx @ . 1661897Swollman menuX @ 1+ swap at-xy 16712798Swpaul menubllt @ emit 16812798Swpaul menuidx @ 48 + 1691897Swollman; 1701897Swollman 1711897Swollman: beastie-menu ( -- ) 17212798Swpaul 0 menuidx ! 17312798Swpaul dot menubllt ! 1741897Swollman 8 menuY ! 1751897Swollman 5 menuX ! 1761897Swollman clear 1771897Swollman 46 4 print-logo 1781897Swollman 42 20 2 2 box 1791897Swollman 13 6 at-xy ." Welcome to FreeBSD!" 1801897Swollman printmenuitem ." Boot FreeBSD [default]" bootkey ! 1811897Swollman s" arch-i386" environment? if 1821897Swollman drop 1831897Swollman printmenuitem ." Boot FreeBSD with ACPI " bootacpikey ! 18412798Swpaul acpienabled? if 1851897Swollman ." disabled" 186100441Scharnier else 1871897Swollman ." enabled" 1881897Swollman then 1891897Swollman else 1901897Swollman -2 bootacpikey ! 1911897Swollman then 192100441Scharnier printmenuitem ." Boot FreeBSD in Safe Mode" bootsafekey ! 1931897Swollman printmenuitem ." Boot FreeBSD in single user mode" bootsinglekey ! 1941897Swollman printmenuitem ." Boot FreeBSD with verbose logging" bootverbosekey ! 19512798Swpaul printmenuitem ." Escape to loader prompt" escapekey ! 19612798Swpaul printmenuitem ." Reboot" rebootkey ! 1971897Swollman menuX @ 20 at-xy 1981897Swollman ." Select option, [Enter] for default" 199100441Scharnier menuX @ 21 at-xy 2001897Swollman s" or [Space] to pause timer " dup 2 - promptwidth ! 2011897Swollman type 2021897Swollman; 2031897Swollman 20412798Swpaul: tkey 20512798Swpaul seconds + 20612798Swpaul begin 1 while 20712798Swpaul over 0<> if 20812798Swpaul dup seconds u< if 2091897Swollman drop 2101897Swollman -1 2111897Swollman exit 2121897Swollman then 21312798Swpaul menuX @ promptwidth @ + 21 at-xy dup seconds - . 21412798Swpaul then 21512798Swpaul key? if 21612798Swpaul drop 21712798Swpaul key 218 exit 219 then 220 50 ms 221 repeat 222; 223 224set-current 225 226: beastie-start 227 s" beastie_disable" getenv 228 dup -1 <> if 229 s" YES" compare-insensitive 0= if 230 exit 231 then 232 else 233 drop 234 then 235 beastie-menu 236 s" autoboot_delay" getenv 237 dup -1 = if 238 drop 239 10 240 else 241 2dup s" -1" compare 0= if 242 0 boot 243 then 244 0 s>d 2swap >number 2drop drop 245 then 246 begin 247 dup tkey 248 0 25 at-xy 249 dup 32 = if nip 0 swap then 250 dup -1 = if 0 boot then 251 dup 13 = if 0 boot then 252 dup bootkey @ = if 0 boot then 253 dup bootacpikey @ = if 254 acpienabled? if 255 s" 1" s" hint.acpi.0.disabled" setenv 256 s" 1" s" loader.acpi_disabled_by_user" setenv 257 else 258 s" 0" s" hint.acpi.0.disabled" setenv 259 then 260 0 boot 261 then 262 dup bootsafekey @ = if 263 s" arch-i386" environment? if 264 drop 265 s" 1" s" hint.acpi.0.disabled" setenv 266 s" 1" s" loader.acpi_disabled_by_user" setenv 267 s" 1" s" hint.apic.0.disabled" setenv 268 then 269 s" 0" s" hw.ata.ata_dma" setenv 270 s" 0" s" hw.ata.atapi_dma" setenv 271 s" 0" s" hw.ata.wc" setenv 272 s" 0" s" hw.eisa_slots" setenv 273 s" 1" s" hint.kbdmux.0.disabled" setenv 274 0 boot 275 then 276 dup bootverbosekey @ = if 277 s" YES" s" boot_verbose" setenv 278 0 boot 279 then 280 dup bootsinglekey @ = if 281 s" YES" s" boot_single" setenv 282 0 boot 283 then 284 dup escapekey @ = if 285 2drop 286 s" NO" s" autoboot_delay" setenv 287 exit 288 then 289 rebootkey @ = if 0 reboot then 290 again 291; 292 293previous 294