beastie.4th revision 138258
1115410Sscottl\ Copyright (c) 2003 Scott Long <scottl@freebsd.org> 2120031Sscottl\ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com> 3115410Sscottl\ All rights reserved. 4115410Sscottl\ 5115410Sscottl\ Redistribution and use in source and binary forms, with or without 6115410Sscottl\ modification, are permitted provided that the following conditions 7115410Sscottl\ are met: 8115410Sscottl\ 1. Redistributions of source code must retain the above copyright 9115410Sscottl\ notice, this list of conditions and the following disclaimer. 10115410Sscottl\ 2. Redistributions in binary form must reproduce the above copyright 11115410Sscottl\ notice, this list of conditions and the following disclaimer in the 12115410Sscottl\ documentation and/or other materials provided with the distribution. 13115410Sscottl\ 14115410Sscottl\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15115410Sscottl\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16115410Sscottl\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17115410Sscottl\ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18115410Sscottl\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19115410Sscottl\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20115410Sscottl\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21115410Sscottl\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22115410Sscottl\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23115410Sscottl\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24115410Sscottl\ SUCH DAMAGE. 25115410Sscottl\ 26115410Sscottl\ $FreeBSD: head/sys/boot/forth/beastie.4th 138258 2004-12-01 07:17:57Z scottl $ 27115410Sscottl 28115410Sscottlmarker task-beastie.4th 29115410Sscottl 30115410Sscottlinclude /boot/screen.4th 31115410Sscottlinclude /boot/frames.4th 32115410Sscottl 33115410Sscottlhide 34115410Sscottl 35115410Sscottlvariable menuidx 36115410Sscottlvariable menubllt 37115410Sscottlvariable menuX 38115410Sscottlvariable menuY 39115410Sscottlvariable promptwidth 40115410Sscottl 41115410Sscottlvariable bootkey 42115410Sscottlvariable bootacpikey 43137071Sbrooksvariable bootusbkey 44115410Sscottlvariable bootsafekey 45115410Sscottlvariable bootverbosekey 46115410Sscottlvariable bootsinglekey 47115410Sscottlvariable escapekey 48115410Sscottlvariable rebootkey 49115410Sscottl 50115410Sscottl46 constant dot 51115410Sscottl 52115410Sscottl\ The BSD Daemon. He is 19 rows high and 34 columns wide 53120031Sscottl: technicolor-beastie ( x y -- ) 54120031Sscottl2dup at-xy ." [1;31m, ," 1+ 55120031Sscottl2dup at-xy ." /( )`" 1+ 56120031Sscottl2dup at-xy ." \ \___ / |" 1+ 57120031Sscottl2dup at-xy ." /- [37m_[31m `-/ '" 1+ 58120031Sscottl2dup at-xy ." ([37m/\/ \[31m \ /\" 1+ 59120031Sscottl2dup at-xy ." [37m/ / |[31m ` \" 1+ 60120031Sscottl2dup at-xy ." [34mO O [37m) [31m/ |" 1+ 61120031Sscottl2dup at-xy ." [37m`-^--'[31m`< '" 1+ 62120031Sscottl2dup at-xy ." (_.) _ ) /" 1+ 63120031Sscottl2dup at-xy ." `.___/` / " 1+ 64120031Sscottl2dup at-xy ." `-----' /" 1+ 65120031Sscottl2dup at-xy ." [33m<----.[31m __ / __ \" 1+ 66120031Sscottl2dup at-xy ." [33m<----|====[31mO)))[33m==[31m) \) /[33m====|" 1+ 67120031Sscottl2dup at-xy ." [33m<----'[31m `--' `.__,' \" 1+ 68120031Sscottl2dup at-xy ." | |" 1+ 69120031Sscottl2dup at-xy ." \ / /\" 1+ 70120031Sscottl2dup at-xy ." [36m______[31m( (_ / \______/" 1+ 71120031Sscottl2dup at-xy ." [36m,' ,-----' |" 1+ 72138258Sscottlat-xy ." `--{__________) [0m" 73120031Sscottl; 74120031Sscottl 75120031Sscottl: boring-beastie ( x y -- ) 76115410Sscottl 2dup at-xy ." , ," 1+ 77115410Sscottl 2dup at-xy ." /( )`" 1+ 78115451Sscottl 2dup at-xy ." \ \___ / |" 1+ 79115410Sscottl 2dup at-xy ." /- _ `-/ '" 1+ 80115451Sscottl 2dup at-xy ." (/\/ \ \ /\" 1+ 81115451Sscottl 2dup at-xy ." / / | ` \" 1+ 82115410Sscottl 2dup at-xy ." O O ) / |" 1+ 83115410Sscottl 2dup at-xy ." `-^--'`< '" 1+ 84115410Sscottl 2dup at-xy ." (_.) _ ) /" 1+ 85115410Sscottl 2dup at-xy ." `.___/` /" 1+ 86115410Sscottl 2dup at-xy ." `-----' /" 1+ 87115451Sscottl 2dup at-xy ." <----. __ / __ \" 1+ 88115451Sscottl 2dup at-xy ." <----|====O)))==) \) /====" 1+ 89115451Sscottl 2dup at-xy ." <----' `--' `.__,' \" 1+ 90115410Sscottl 2dup at-xy ." | |" 1+ 91115451Sscottl 2dup at-xy ." \ / /\" 1+ 92115451Sscottl 2dup at-xy ." ______( (_ / \______/" 1+ 93115410Sscottl 2dup at-xy ." ,' ,-----' |" 1+ 94115410Sscottl at-xy ." `--{__________)" 95115410Sscottl; 96115410Sscottl 97120031Sscottl: print-beastie ( x y -- ) 98120031Sscottl s" loader_color" getenv 99120031Sscottl dup -1 = if 100120031Sscottl drop 101120031Sscottl boring-beastie 102120031Sscottl exit 103120031Sscottl then 104120031Sscottl s" YES" compare-insensitive 0<> if 105120031Sscottl boring-beastie 106120031Sscottl exit 107120031Sscottl then 108120031Sscottl technicolor-beastie 109120031Sscottl; 110120031Sscottl 111115410Sscottl: acpienabled? ( -- flag ) 112115410Sscottl s" acpi_load" getenv 113115410Sscottl dup -1 = if 114115410Sscottl drop false exit 115115410Sscottl then 116115410Sscottl s" YES" compare-insensitive 0<> if 117115410Sscottl false exit 118115410Sscottl then 119115410Sscottl s" hint.acpi.0.disabled" getenv 120115410Sscottl dup -1 <> if 121115410Sscottl s" 0" compare 0<> if 122115410Sscottl false exit 123115410Sscottl then 124138258Sscottl else 125138258Sscottl drop 126115410Sscottl then 127115410Sscottl true 128115410Sscottl; 129115410Sscottl 130115410Sscottl: printmenuitem ( -- n ) 131115410Sscottl menuidx @ 132115410Sscottl 1+ dup 133115410Sscottl menuidx ! 134115410Sscottl menuY @ + dup menuX @ swap at-xy 135115410Sscottl menuidx @ . 136115410Sscottl menuX @ 1+ swap at-xy 137115410Sscottl menubllt @ emit 138115410Sscottl menuidx @ 48 + 139115410Sscottl; 140115410Sscottl 141115410Sscottl: beastie-menu ( -- ) 142115410Sscottl 0 menuidx ! 143115410Sscottl dot menubllt ! 144115410Sscottl 8 menuY ! 145115410Sscottl 5 menuX ! 146115410Sscottl clear 147115410Sscottl 46 4 print-beastie 148115410Sscottl 42 20 2 2 box 149115410Sscottl 13 6 at-xy ." Welcome to FreeBSD!" 150115410Sscottl printmenuitem ." Boot FreeBSD [default]" bootkey ! 151115410Sscottl s" arch-i386" environment? if 152138258Sscottl drop 153115410Sscottl printmenuitem ." Boot FreeBSD with ACPI " bootacpikey ! 154115410Sscottl acpienabled? if 155115410Sscottl ." disabled" 156115410Sscottl else 157115410Sscottl ." enabled" 158115410Sscottl then 159115410Sscottl else 160115410Sscottl -2 bootacpikey ! 161115410Sscottl then 162115410Sscottl printmenuitem ." Boot FreeBSD in Safe Mode" bootsafekey ! 163115410Sscottl printmenuitem ." Boot FreeBSD in single user mode" bootsinglekey ! 164115410Sscottl printmenuitem ." Boot FreeBSD with verbose logging" bootverbosekey ! 165115410Sscottl printmenuitem ." Escape to loader prompt" escapekey ! 166137071Sbrooks s" arch-i386" environment? if 167138258Sscottl drop 168137071Sbrooks printmenuitem ." Boot FreeBSD with USB keyboard" bootusbkey ! 169137071Sbrooks else 170138258Sscottl -2 bootusbkey ! 171137071Sbrooks then 172115410Sscottl printmenuitem ." Reboot" rebootkey ! 173115410Sscottl menuX @ 20 at-xy 174115410Sscottl ." Select option, [Enter] for default" 175115410Sscottl menuX @ 21 at-xy 176115410Sscottl s" or [Space] to pause timer " dup 2 - promptwidth ! 177115410Sscottl type 178115410Sscottl; 179115410Sscottl 180115410Sscottl: tkey 181115410Sscottl seconds + 182115410Sscottl begin 1 while 183115410Sscottl over 0<> if 184115410Sscottl dup seconds u< if 185115410Sscottl drop 186115410Sscottl -1 187115410Sscottl exit 188115410Sscottl then 189115410Sscottl menuX @ promptwidth @ + 21 at-xy dup seconds - . 190115410Sscottl then 191115410Sscottl key? if 192115410Sscottl drop 193115410Sscottl key 194115410Sscottl exit 195115410Sscottl then 196115410Sscottl 50 ms 197115410Sscottl repeat 198115410Sscottl; 199115410Sscottl 200115410Sscottlset-current 201115410Sscottl 202115410Sscottl: beastie-start 203116175Sscottl s" beastie_disable" getenv 204116175Sscottl dup -1 <> if 205116175Sscottl s" YES" compare-insensitive 0= if 206116175Sscottl exit 207116175Sscottl then 208138258Sscottl else 209138258Sscottl drop 210116175Sscottl then 211115410Sscottl beastie-menu 212115410Sscottl s" autoboot_delay" getenv 213115410Sscottl dup -1 = if 214115410Sscottl drop 215115410Sscottl 10 216115410Sscottl else 217115410Sscottl 0 0 2swap >number drop drop drop 218115410Sscottl then 219138258Sscottl begin 220115410Sscottl dup tkey 221115410Sscottl 0 25 at-xy 222115410Sscottl dup 32 = if nip 0 swap then 223121618Sscottl dup -1 = if 0 boot then 224121618Sscottl dup 13 = if 0 boot then 225121618Sscottl dup bootkey @ = if 0 boot then 226115410Sscottl dup bootacpikey @ = if 227115410Sscottl acpienabled? if 228115410Sscottl s" acpi_load" unsetenv 229115410Sscottl s" 1" s" hint.acpi.0.disabled" setenv 230115434Sscottl s" 1" s" loader.acpi_disabled_by_user" setenv 231115410Sscottl else 232115410Sscottl s" YES" s" acpi_load" setenv 233115410Sscottl s" 0" s" hint.acpi.0.disabled" setenv 234115410Sscottl then 235121618Sscottl 0 boot 236115410Sscottl then 237137071Sbrooks dup bootusbkey @ = if 238137071Sbrooks s" 0x1" s" hint.atkbd.0.flags" setenv 239137071Sbrooks 0 boot 240137071Sbrooks then 241115410Sscottl dup bootsafekey @ = if 242115410Sscottl s" arch-i386" environment? if 243138258Sscottl drop 244115410Sscottl s" acpi_load" unsetenv 245115410Sscottl s" 1" s" hint.acpi.0.disabled" setenv 246115434Sscottl s" 1" s" loader.acpi_disabled_by_user" setenv 247124306Sscottl s" 1" s" hint.apic.0.disabled" setenv 248115410Sscottl then 249115410Sscottl s" 0" s" hw.ata.ata_dma" setenv 250115410Sscottl s" 0" s" hw.ata.atapi_dma" setenv 251115410Sscottl s" 0" s" hw.ata.wc" setenv 252115410Sscottl s" 0" s" hw.eisa_slots" setenv 253121618Sscottl 0 boot 254115410Sscottl then 255115410Sscottl dup bootverbosekey @ = if 256115410Sscottl s" YES" s" boot_verbose" setenv 257121618Sscottl 0 boot 258115410Sscottl then 259115410Sscottl dup bootsinglekey @ = if 260115410Sscottl s" YES" s" boot_single" setenv 261121618Sscottl 0 boot 262115410Sscottl then 263116175Sscottl dup escapekey @ = if 264116175Sscottl 2drop 265116175Sscottl s" NO" s" autoboot_delay" setenv 266116175Sscottl exit 267116175Sscottl then 268121632Sscottl rebootkey @ = if 0 reboot then 269138258Sscottl again 270115410Sscottl; 271115410Sscottl 272115410Sscottlprevious 273