beastie.4th revision 215345
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 215345 2010-11-15 19:55:19Z jhb $ 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 43115410Sscottlvariable bootsafekey 44115410Sscottlvariable bootverbosekey 45115410Sscottlvariable bootsinglekey 46115410Sscottlvariable escapekey 47115410Sscottlvariable rebootkey 48115410Sscottl 49115410Sscottl46 constant dot 50115410Sscottl 51115410Sscottl\ The BSD Daemon. He is 19 rows high and 34 columns wide 52151873Sscottl: beastie-logo ( x y -- ) 53120031Sscottl2dup at-xy ." [1;31m, ," 1+ 54120031Sscottl2dup at-xy ." /( )`" 1+ 55120031Sscottl2dup at-xy ." \ \___ / |" 1+ 56120031Sscottl2dup at-xy ." /- [37m_[31m `-/ '" 1+ 57120031Sscottl2dup at-xy ." ([37m/\/ \[31m \ /\" 1+ 58120031Sscottl2dup at-xy ." [37m/ / |[31m ` \" 1+ 59120031Sscottl2dup at-xy ." [34mO O [37m) [31m/ |" 1+ 60120031Sscottl2dup at-xy ." [37m`-^--'[31m`< '" 1+ 61120031Sscottl2dup at-xy ." (_.) _ ) /" 1+ 62120031Sscottl2dup at-xy ." `.___/` / " 1+ 63120031Sscottl2dup at-xy ." `-----' /" 1+ 64120031Sscottl2dup at-xy ." [33m<----.[31m __ / __ \" 1+ 65120031Sscottl2dup at-xy ." [33m<----|====[31mO)))[33m==[31m) \) /[33m====|" 1+ 66120031Sscottl2dup at-xy ." [33m<----'[31m `--' `.__,' \" 1+ 67120031Sscottl2dup at-xy ." | |" 1+ 68120031Sscottl2dup at-xy ." \ / /\" 1+ 69120031Sscottl2dup at-xy ." [36m______[31m( (_ / \______/" 1+ 70120031Sscottl2dup at-xy ." [36m,' ,-----' |" 1+ 71138258Sscottlat-xy ." `--{__________) [0m" 72120031Sscottl; 73120031Sscottl 74151873Sscottl: beastiebw-logo ( x y -- ) 75115410Sscottl 2dup at-xy ." , ," 1+ 76115410Sscottl 2dup at-xy ." /( )`" 1+ 77115451Sscottl 2dup at-xy ." \ \___ / |" 1+ 78115410Sscottl 2dup at-xy ." /- _ `-/ '" 1+ 79115451Sscottl 2dup at-xy ." (/\/ \ \ /\" 1+ 80115451Sscottl 2dup at-xy ." / / | ` \" 1+ 81115410Sscottl 2dup at-xy ." O O ) / |" 1+ 82115410Sscottl 2dup at-xy ." `-^--'`< '" 1+ 83115410Sscottl 2dup at-xy ." (_.) _ ) /" 1+ 84115410Sscottl 2dup at-xy ." `.___/` /" 1+ 85115410Sscottl 2dup at-xy ." `-----' /" 1+ 86115451Sscottl 2dup at-xy ." <----. __ / __ \" 1+ 87115451Sscottl 2dup at-xy ." <----|====O)))==) \) /====" 1+ 88115451Sscottl 2dup at-xy ." <----' `--' `.__,' \" 1+ 89115410Sscottl 2dup at-xy ." | |" 1+ 90115451Sscottl 2dup at-xy ." \ / /\" 1+ 91115451Sscottl 2dup at-xy ." ______( (_ / \______/" 1+ 92115410Sscottl 2dup at-xy ." ,' ,-----' |" 1+ 93115410Sscottl at-xy ." `--{__________)" 94115410Sscottl; 95115410Sscottl 96151873Sscottl: fbsdbw-logo ( x y -- ) 97151873Sscottl 2dup at-xy ." ______" 1+ 98151873Sscottl 2dup at-xy ." | ____| __ ___ ___ " 1+ 99151873Sscottl 2dup at-xy ." | |__ | '__/ _ \/ _ \" 1+ 100151873Sscottl 2dup at-xy ." | __|| | | __/ __/" 1+ 101151873Sscottl 2dup at-xy ." | | | | | | |" 1+ 102151873Sscottl 2dup at-xy ." |_| |_| \___|\___|" 1+ 103151873Sscottl 2dup at-xy ." ____ _____ _____" 1+ 104151873Sscottl 2dup at-xy ." | _ \ / ____| __ \" 1+ 105151873Sscottl 2dup at-xy ." | |_) | (___ | | | |" 1+ 106151873Sscottl 2dup at-xy ." | _ < \___ \| | | |" 1+ 107151873Sscottl 2dup at-xy ." | |_) |____) | |__| |" 1+ 108151873Sscottl 2dup at-xy ." | | | |" 1+ 109151873Sscottl at-xy ." |____/|_____/|_____/" 110151873Sscottl; 111151873Sscottl 112151873Sscottl: print-logo ( x y -- ) 113151873Sscottl s" loader_logo" getenv 114120031Sscottl dup -1 = if 115120031Sscottl drop 116151873Sscottl fbsdbw-logo 117120031Sscottl exit 118120031Sscottl then 119151873Sscottl 2dup s" fbsdbw" compare-insensitive 0= if 120151873Sscottl 2drop 121151873Sscottl fbsdbw-logo 122120031Sscottl exit 123120031Sscottl then 124151873Sscottl 2dup s" beastiebw" compare-insensitive 0= if 125151873Sscottl 2drop 126151873Sscottl beastiebw-logo 127151873Sscottl exit 128151873Sscottl then 129151873Sscottl 2dup s" beastie" compare-insensitive 0= if 130151873Sscottl 2drop 131151873Sscottl beastie-logo 132151873Sscottl exit 133151873Sscottl then 134151873Sscottl 2dup s" none" compare-insensitive 0= if 135151873Sscottl 2drop 136151873Sscottl \ no logo 137151873Sscottl exit 138151873Sscottl then 139151873Sscottl 2drop 140151873Sscottl fbsdbw-logo 141120031Sscottl; 142120031Sscottl 143215345Sjhb: acpipresent? ( -- flag ) 144215016Sjhb s" hint.acpi.0.rsdp" getenv 145115410Sscottl dup -1 = if 146115410Sscottl drop false exit 147115410Sscottl then 148215016Sjhb 2drop 149215345Sjhb true 150215345Sjhb; 151215345Sjhb 152215345Sjhb: acpienabled? ( -- flag ) 153115410Sscottl s" hint.acpi.0.disabled" getenv 154115410Sscottl dup -1 <> if 155115410Sscottl s" 0" compare 0<> if 156115410Sscottl false exit 157115410Sscottl then 158138258Sscottl else 159138258Sscottl drop 160115410Sscottl then 161115410Sscottl true 162115410Sscottl; 163115410Sscottl 164115410Sscottl: printmenuitem ( -- n ) 165115410Sscottl menuidx @ 166115410Sscottl 1+ dup 167115410Sscottl menuidx ! 168115410Sscottl menuY @ + dup menuX @ swap at-xy 169115410Sscottl menuidx @ . 170115410Sscottl menuX @ 1+ swap at-xy 171115410Sscottl menubllt @ emit 172115410Sscottl menuidx @ 48 + 173115410Sscottl; 174115410Sscottl 175115410Sscottl: beastie-menu ( -- ) 176115410Sscottl 0 menuidx ! 177115410Sscottl dot menubllt ! 178115410Sscottl 8 menuY ! 179115410Sscottl 5 menuX ! 180115410Sscottl clear 181151873Sscottl 46 4 print-logo 182115410Sscottl 42 20 2 2 box 183115410Sscottl 13 6 at-xy ." Welcome to FreeBSD!" 184115410Sscottl printmenuitem ." Boot FreeBSD [default]" bootkey ! 185115410Sscottl s" arch-i386" environment? if 186138258Sscottl drop 187215345Sjhb acpipresent? if 188215345Sjhb printmenuitem ." Boot FreeBSD with ACPI " bootacpikey ! 189215345Sjhb acpienabled? if 190215345Sjhb ." disabled" 191215345Sjhb else 192215345Sjhb ." enabled" 193215345Sjhb then 194115410Sscottl else 195215345Sjhb menuidx @ 196215345Sjhb 1+ dup 197215345Sjhb menuidx ! 198215345Sjhb -2 bootacpikey ! 199115410Sscottl then 200115410Sscottl else 201115410Sscottl -2 bootacpikey ! 202115410Sscottl then 203115410Sscottl printmenuitem ." Boot FreeBSD in Safe Mode" bootsafekey ! 204115410Sscottl printmenuitem ." Boot FreeBSD in single user mode" bootsinglekey ! 205115410Sscottl printmenuitem ." Boot FreeBSD with verbose logging" bootverbosekey ! 206115410Sscottl printmenuitem ." Escape to loader prompt" escapekey ! 207115410Sscottl printmenuitem ." Reboot" rebootkey ! 208115410Sscottl menuX @ 20 at-xy 209115410Sscottl ." Select option, [Enter] for default" 210115410Sscottl menuX @ 21 at-xy 211115410Sscottl s" or [Space] to pause timer " dup 2 - promptwidth ! 212115410Sscottl type 213115410Sscottl; 214115410Sscottl 215115410Sscottl: tkey 216115410Sscottl seconds + 217115410Sscottl begin 1 while 218115410Sscottl over 0<> if 219115410Sscottl dup seconds u< if 220115410Sscottl drop 221115410Sscottl -1 222115410Sscottl exit 223115410Sscottl then 224115410Sscottl menuX @ promptwidth @ + 21 at-xy dup seconds - . 225115410Sscottl then 226115410Sscottl key? if 227115410Sscottl drop 228115410Sscottl key 229115410Sscottl exit 230115410Sscottl then 231115410Sscottl 50 ms 232115410Sscottl repeat 233115410Sscottl; 234115410Sscottl 235115410Sscottlset-current 236115410Sscottl 237115410Sscottl: beastie-start 238116175Sscottl s" beastie_disable" getenv 239116175Sscottl dup -1 <> if 240116175Sscottl s" YES" compare-insensitive 0= if 241116175Sscottl exit 242116175Sscottl then 243138258Sscottl else 244138258Sscottl drop 245116175Sscottl then 246115410Sscottl beastie-menu 247115410Sscottl s" autoboot_delay" getenv 248115410Sscottl dup -1 = if 249115410Sscottl drop 250115410Sscottl 10 251115410Sscottl else 252212338Sjhb 2dup s" -1" compare 0= if 253212338Sjhb 0 boot 254212338Sjhb then 255212338Sjhb 0 s>d 2swap >number 2drop drop 256115410Sscottl then 257138258Sscottl begin 258115410Sscottl dup tkey 259115410Sscottl 0 25 at-xy 260115410Sscottl dup 32 = if nip 0 swap then 261121618Sscottl dup -1 = if 0 boot then 262121618Sscottl dup 13 = if 0 boot then 263121618Sscottl dup bootkey @ = if 0 boot then 264115410Sscottl dup bootacpikey @ = if 265115410Sscottl acpienabled? if 266115410Sscottl s" 1" s" hint.acpi.0.disabled" setenv 267115434Sscottl s" 1" s" loader.acpi_disabled_by_user" setenv 268115410Sscottl else 269115410Sscottl s" 0" s" hint.acpi.0.disabled" setenv 270115410Sscottl then 271121618Sscottl 0 boot 272115410Sscottl then 273115410Sscottl dup bootsafekey @ = if 274115410Sscottl s" arch-i386" environment? if 275138258Sscottl drop 276115410Sscottl s" 1" s" hint.acpi.0.disabled" setenv 277115434Sscottl s" 1" s" loader.acpi_disabled_by_user" setenv 278124306Sscottl s" 1" s" hint.apic.0.disabled" setenv 279115410Sscottl then 280115410Sscottl s" 0" s" hw.ata.ata_dma" setenv 281115410Sscottl s" 0" s" hw.ata.atapi_dma" setenv 282115410Sscottl s" 0" s" hw.ata.wc" setenv 283115410Sscottl s" 0" s" hw.eisa_slots" setenv 284157339Sscottl s" 1" s" hint.kbdmux.0.disabled" setenv 285121618Sscottl 0 boot 286115410Sscottl then 287115410Sscottl dup bootverbosekey @ = if 288115410Sscottl s" YES" s" boot_verbose" setenv 289121618Sscottl 0 boot 290115410Sscottl then 291115410Sscottl dup bootsinglekey @ = if 292115410Sscottl s" YES" s" boot_single" setenv 293121618Sscottl 0 boot 294115410Sscottl then 295116175Sscottl dup escapekey @ = if 296116175Sscottl 2drop 297116175Sscottl s" NO" s" autoboot_delay" setenv 298116175Sscottl exit 299116175Sscottl then 300121632Sscottl rebootkey @ = if 0 reboot then 301138258Sscottl again 302115410Sscottl; 303115410Sscottl 304115410Sscottlprevious 305