beastie.4th revision 124306
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 124306 2004-01-09 19:20:47Z 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 bootsafekey 44variable bootverbosekey 45variable bootsinglekey 46variable escapekey 47variable rebootkey 48 4946 constant dot 50 51\ The BSD Daemon. He is 19 rows high and 34 columns wide 52: technicolor-beastie ( x y -- ) 532dup at-xy ." [1;31m, ," 1+ 542dup at-xy ." /( )`" 1+ 552dup at-xy ." \ \___ / |" 1+ 562dup at-xy ." /- [37m_[31m `-/ '" 1+ 572dup at-xy ." ([37m/\/ \[31m \ /\" 1+ 582dup at-xy ." [37m/ / |[31m ` \" 1+ 592dup at-xy ." [34mO O [37m) [31m/ |" 1+ 602dup at-xy ." [37m`-^--'[31m`< '" 1+ 612dup at-xy ." (_.) _ ) /" 1+ 622dup at-xy ." `.___/` / " 1+ 632dup at-xy ." `-----' /" 1+ 642dup at-xy ." [33m<----.[31m __ / __ \" 1+ 652dup at-xy ." [33m<----|====[31mO)))[33m==[31m) \) /[33m====|" 1+ 662dup at-xy ." [33m<----'[31m `--' `.__,' \" 1+ 672dup at-xy ." | |" 1+ 682dup at-xy ." \ / /\" 1+ 692dup at-xy ." [36m______[31m( (_ / \______/" 1+ 702dup at-xy ." [36m,' ,-----' |" 1+ 71at-xy ." `--{__________) [0m" 1+ 72; 73 74: boring-beastie ( x y -- ) 75 2dup at-xy ." , ," 1+ 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 ." O O ) / |" 1+ 82 2dup at-xy ." `-^--'`< '" 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 ." <----|====O)))==) \) /====" 1+ 88 2dup at-xy ." <----' `--' `.__,' \" 1+ 89 2dup at-xy ." | |" 1+ 90 2dup at-xy ." \ / /\" 1+ 91 2dup at-xy ." ______( (_ / \______/" 1+ 92 2dup at-xy ." ,' ,-----' |" 1+ 93 at-xy ." `--{__________)" 94; 95 96: print-beastie ( x y -- ) 97 s" loader_color" getenv 98 dup -1 = if 99 drop 100 boring-beastie 101 exit 102 then 103 s" YES" compare-insensitive 0<> if 104 boring-beastie 105 exit 106 then 107 technicolor-beastie 108; 109 110: acpienabled? ( -- flag ) 111 s" acpi_load" getenv 112 dup -1 = if 113 drop false exit 114 then 115 s" YES" compare-insensitive 0<> if 116 false exit 117 then 118 s" hint.acpi.0.disabled" getenv 119 dup -1 <> if 120 s" 0" compare 0<> if 121 false exit 122 then 123 then 124 true 125; 126 127: printmenuitem ( -- n ) 128 menuidx @ 129 1+ dup 130 menuidx ! 131 menuY @ + dup menuX @ swap at-xy 132 menuidx @ . 133 menuX @ 1+ swap at-xy 134 menubllt @ emit 135 menuidx @ 48 + 136; 137 138: beastie-menu ( -- ) 139 0 menuidx ! 140 dot menubllt ! 141 8 menuY ! 142 5 menuX ! 143 clear 144 46 4 print-beastie 145 42 20 2 2 box 146 13 6 at-xy ." Welcome to FreeBSD!" 147 printmenuitem ." Boot FreeBSD [default]" bootkey ! 148 s" arch-i386" environment? if 149 printmenuitem ." Boot FreeBSD with ACPI " bootacpikey ! 150 acpienabled? if 151 ." disabled" 152 else 153 ." enabled" 154 then 155 else 156 -2 bootacpikey ! 157 then 158 printmenuitem ." Boot FreeBSD in Safe Mode" bootsafekey ! 159 printmenuitem ." Boot FreeBSD in single user mode" bootsinglekey ! 160 printmenuitem ." Boot FreeBSD with verbose logging" bootverbosekey ! 161 printmenuitem ." Escape to loader prompt" escapekey ! 162 printmenuitem ." Reboot" rebootkey ! 163 menuX @ 20 at-xy 164 ." Select option, [Enter] for default" 165 menuX @ 21 at-xy 166 s" or [Space] to pause timer " dup 2 - promptwidth ! 167 type 168; 169 170: tkey 171 dup 172 seconds + 173 begin 1 while 174 over 0<> if 175 dup seconds u< if 176 drop 177 -1 178 exit 179 then 180 menuX @ promptwidth @ + 21 at-xy dup seconds - . 181 then 182 key? if 183 drop 184 key 185 exit 186 then 187 50 ms 188 repeat 189; 190 191set-current 192 193: beastie-start 194 s" beastie_disable" getenv 195 dup -1 <> if 196 s" YES" compare-insensitive 0= if 197 exit 198 then 199 then 200 beastie-menu 201 s" autoboot_delay" getenv 202 dup -1 = if 203 drop 204 10 205 else 206 0 0 2swap >number drop drop drop 207 then 208 begin true while 209 dup tkey 210 0 25 at-xy 211 dup 32 = if nip 0 swap then 212 dup -1 = if 0 boot then 213 dup 13 = if 0 boot then 214 dup bootkey @ = if 0 boot then 215 dup bootacpikey @ = if 216 acpienabled? if 217 s" acpi_load" unsetenv 218 s" 1" s" hint.acpi.0.disabled" setenv 219 s" 1" s" loader.acpi_disabled_by_user" setenv 220 else 221 s" YES" s" acpi_load" setenv 222 s" 0" s" hint.acpi.0.disabled" setenv 223 then 224 0 boot 225 then 226 dup bootsafekey @ = if 227 s" arch-i386" environment? 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 s" 1" s" hint.apic.0.disabled" setenv 232 then 233 s" 0" s" hw.ata.ata_dma" setenv 234 s" 0" s" hw.ata.atapi_dma" setenv 235 s" 0" s" hw.ata.wc" setenv 236 s" 0" s" hw.eisa_slots" setenv 237 0 boot 238 then 239 dup bootverbosekey @ = if 240 s" YES" s" boot_verbose" setenv 241 0 boot 242 then 243 dup bootsinglekey @ = if 244 s" YES" s" boot_single" setenv 245 0 boot 246 then 247 dup escapekey @ = if 248 2drop 249 s" NO" s" autoboot_delay" setenv 250 exit 251 then 252 rebootkey @ = if 0 reboot then 253 repeat 254; 255 256previous 257