1\ Copyright (c) 2003 Scott Long <scottl@freebsd.org> 2\ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com>
| 1\ Copyright (c) 2003 Scott Long <scottl@freebsd.org> 2\ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com>
|
| 3\ Copyright (c) 2006-2011 Devin Teske <devinteske@hotmail.com>
|
3\ All rights reserved.
| 4\ All rights reserved.
|
4\
| 5\
|
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.
| 6\ Redistribution and use in source and binary forms, with or without 7\ modification, are permitted provided that the following conditions 8\ are met: 9\ 1. Redistributions of source code must retain the above copyright 10\ notice, this list of conditions and the following disclaimer. 11\ 2. Redistributions in binary form must reproduce the above copyright 12\ notice, this list of conditions and the following disclaimer in the 13\ documentation and/or other materials provided with the distribution.
|
13\
| 14\
|
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.
| 15\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18\ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25\ SUCH DAMAGE.
|
25\ 26\ $FreeBSD: head/sys/boot/forth/beastie.4th 217644 2011-01-20 16:03:28Z jhb $
| 26\ 27\ $FreeBSD: head/sys/boot/forth/beastie.4th 222417 2011-05-28 08:50:38Z julian $
|
27 28marker task-beastie.4th 29
| 28 29marker task-beastie.4th 30
|
30include /boot/screen.4th 31include /boot/frames.4th
| 31include /boot/color.4th 32include /boot/delay.4th
|
32
| 33
|
33hide
| 34variable logoX 35variable logoY
|
34
| 36
|
35variable menuidx 36variable menubllt 37variable menuX 38variable menuY 39variable promptwidth
| 37\ Initialize logo placement to defaults 3846 logoX ! 394 logoY !
|
40
| 40
|
41variable bootkey 42variable bootacpikey 43variable bootsafekey 44variable bootverbosekey 45variable bootsinglekey 46variable escapekey 47variable rebootkey
| 41: beastie-logo ( x y -- ) \ color BSD mascot (19 rows x 34 columns)
|
48
| 42
|
4946 constant dot 50 51\ The BSD Daemon. He is 19 rows high and 34 columns wide 52: beastie-logo ( x y -- ) 532dup at-xy ." [1;31m, ," 1+
| 432dup at-xy ." [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+
| 442dup at-xy ." /( )`" 1+ 452dup at-xy ." \ \___ / |" 1+ 462dup at-xy ." /- [37m_[31m `-/ '" 1+ 472dup at-xy ." ([37m/\/ \[31m \ /\" 1+ 482dup at-xy ." [37m/ / |[31m ` \" 1+ 492dup at-xy ." [34mO O [37m) [31m/ |" 1+ 502dup at-xy ." [37m`-^--'[31m`< '" 1+ 512dup at-xy ." (_.) _ ) /" 1+
|
622dup at-xy ." `.___/` / " 1+
| 522dup 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+
| 532dup at-xy ." `-----' /" 1+ 542dup at-xy ." [33m<----.[31m __ / __ \" 1+ 552dup at-xy ." [33m<----|====[31mO)))[33m==[31m) \) /[33m====|" 1+ 562dup at-xy ." [33m<----'[31m `--' `.__,' \" 1+ 572dup at-xy ." | |" 1+ 582dup at-xy ." \ / /\" 1+ 592dup at-xy ." [36m______[31m( (_ / \______/" 1+ 602dup at-xy ." [36m,' ,-----' |" 1+
|
71at-xy ." `--{__________) [0m"
| 61 at-xy ." `--{__________)[37m" 62 63 \ Put the cursor back at the bottom 64 0 25 at-xy
|
72; 73
| 65; 66
|
74: beastiebw-logo ( 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 ." `--{__________)"
| 67: beastiebw-logo ( x y -- ) \ B/W BSD mascot (19 rows x 34 columns) 68 69 2dup at-xy ." , ," 1+ 70 2dup at-xy ." /( )`" 1+ 71 2dup at-xy ." \ \___ / |" 1+ 72 2dup at-xy ." /- _ `-/ '" 1+ 73 2dup at-xy ." (/\/ \ \ /\" 1+ 74 2dup at-xy ." / / | ` \" 1+ 75 2dup at-xy ." O O ) / |" 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)))==) \) /====|" 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 at-xy ." `--{__________)" 88 89 \ Put the cursor back at the bottom 90 0 25 at-xy
|
94; 95
| 91; 92
|
96: fbsdbw-logo ( x y -- ) 97 2dup at-xy ." ______" 1+ 98 2dup at-xy ." | ____| __ ___ ___ " 1+ 99 2dup at-xy ." | |__ | '__/ _ \/ _ \" 1+ 100 2dup at-xy ." | __|| | | __/ __/" 1+ 101 2dup at-xy ." | | | | | | |" 1+ 102 2dup at-xy ." |_| |_| \___|\___|" 1+ 103 2dup at-xy ." ____ _____ _____" 1+ 104 2dup at-xy ." | _ \ / ____| __ \" 1+ 105 2dup at-xy ." | |_) | (___ | | | |" 1+ 106 2dup at-xy ." | _ < \___ \| | | |" 1+ 107 2dup at-xy ." | |_) |____) | |__| |" 1+ 108 2dup at-xy ." | | | |" 1+ 109 at-xy ." |____/|_____/|_____/"
| 93: fbsdbw-logo ( x y -- ) \ "FreeBSD" logo in B/W (13 rows x 21 columns) 94 95 \ We used to use the beastie himself as our default... until the 96 \ eventual complaint derided his reign of the advanced boot-menu. 97 \ 98 \ This is the replacement of beastie to satiate the haters of our 99 \ beloved helper-daemon (ready to track down and spear bugs with 100 \ his trident and sporty sneakers; see above). 101 \ 102 \ Since we merely just changed the default and not the default- 103 \ location, below is an adjustment to the passed-in coordinates, 104 \ forever influenced by the proper location of beastie himself 105 \ kept as the default loader_logo_x/loader_logo_y values. 106 \ 107 5 + swap 6 + swap 108 109 2dup at-xy ." ______" 1+ 110 2dup at-xy ." | ____| __ ___ ___ " 1+ 111 2dup at-xy ." | |__ | '__/ _ \/ _ \" 1+ 112 2dup at-xy ." | __|| | | __/ __/" 1+ 113 2dup at-xy ." | | | | | | |" 1+ 114 2dup at-xy ." |_| |_| \___|\___|" 1+ 115 2dup at-xy ." ____ _____ _____" 1+ 116 2dup at-xy ." | _ \ / ____| __ \" 1+ 117 2dup at-xy ." | |_) | (___ | | | |" 1+ 118 2dup at-xy ." | _ < \___ \| | | |" 1+ 119 2dup at-xy ." | |_) |____) | |__| |" 1+ 120 2dup at-xy ." | | | |" 1+ 121 at-xy ." |____/|_____/|_____/" 122 123 \ Put the cursor back at the bottom 124 0 25 at-xy
|
110; 111
| 125; 126
|
112: print-logo ( x y -- ) 113 s" loader_logo" getenv 114 dup -1 = if 115 drop 116 fbsdbw-logo 117 exit 118 then 119 2dup s" fbsdbw" compare-insensitive 0= if 120 2drop 121 fbsdbw-logo 122 exit 123 then 124 2dup s" beastiebw" compare-insensitive 0= if 125 2drop 126 beastiebw-logo 127 exit 128 then 129 2dup s" beastie" compare-insensitive 0= if 130 2drop 131 beastie-logo 132 exit 133 then 134 2dup s" none" compare-insensitive 0= if 135 2drop 136 \ no logo 137 exit 138 then 139 2drop 140 fbsdbw-logo
| 127: orb-logo ( x y -- ) \ color Orb mascot (15 rows x 30 columns) 128 129 3 + \ beastie adjustment (see `fbsdbw-logo' comments above) 130 131 2dup at-xy ." [31m``` [31;1m`[31m" 1+ 132 2dup at-xy ." s` `.....---...[31;1m....--.``` -/[31m" 1+ 133 2dup at-xy ." +o .--` [31;1m/y:` +.[31m" 1+ 134 2dup at-xy ." yo`:. [31;1m:o `+-[31m" 1+ 135 2dup at-xy ." y/ [31;1m-/` -o/[31m" 1+ 136 2dup at-xy ." .- [31;1m::/sy+:.[31m" 1+ 137 2dup at-xy ." / [31;1m`-- /[31m" 1+ 138 2dup at-xy ." `: [31;1m:`[31m" 1+ 139 2dup at-xy ." `: [31;1m:`[31m" 1+ 140 2dup at-xy ." / [31;1m/[31m" 1+ 141 2dup at-xy ." .- [31;1m-.[31m" 1+ 142 2dup at-xy ." -- [31;1m-.[31m" 1+ 143 2dup at-xy ." `:` [31;1m`:`" 1+ 144 2dup at-xy ." [31;1m.-- `--." 1+ 145 at-xy ." .---.....----.[37m" 146 147 \ Put the cursor back at the bottom 148 0 25 at-xy
|
141; 142
| 149; 150
|
143: acpipresent? ( -- flag ) 144 s" hint.acpi.0.rsdp" getenv 145 dup -1 = if 146 drop false exit 147 then 148 2drop 149 true
| 151: orbbw-logo ( x y -- ) \ B/W Orb mascot (15 rows x 32 columns) 152 153 3 + \ beastie adjustment (see `fbsdbw-logo' comments above) 154 155 2dup at-xy ." ``` `" 1+ 156 2dup at-xy ." s` `.....---.......--.``` -/" 1+ 157 2dup at-xy ." +o .--` /y:` +." 1+ 158 2dup at-xy ." yo`:. :o `+-" 1+ 159 2dup at-xy ." y/ -/` -o/" 1+ 160 2dup at-xy ." .- ::/sy+:." 1+ 161 2dup at-xy ." / `-- /" 1+ 162 2dup at-xy ." `: :`" 1+ 163 2dup at-xy ." `: :`" 1+ 164 2dup at-xy ." / /" 1+ 165 2dup at-xy ." .- -." 1+ 166 2dup at-xy ." -- -." 1+ 167 2dup at-xy ." `:` `:`" 1+ 168 2dup at-xy ." .-- `--." 1+ 169 at-xy ." .---.....----." 170 171 \ Put the cursor back at the bottom 172 0 25 at-xy
|
150; 151
| 173; 174
|
152: acpienabled? ( -- flag ) 153 s" hint.acpi.0.disabled" getenv 154 dup -1 <> if 155 s" 0" compare 0<> if 156 false exit 157 then
| 175\ This function draws any number of beastie logos at (loader_logo_x, 176\ loader_logo_y) if defined, else (46,4) (to the right of the menu). To choose 177\ your beastie, set the variable `loader_logo' to the respective logo name. 178\ 179\ Currently available: 180\ 181\ NAME DESCRIPTION 182\ beastie Color ``Helper Daemon'' mascot (19 rows x 34 columns) 183\ beastiebw B/W ``Helper Daemon'' mascot (19 rows x 34 columns) 184\ fbsdbw "FreeBSD" logo in B/W (13 rows x 21 columns) 185\ orb Color ``Orb'' mascot (15 rows x 30 columns) 186\ orbbw B/W ``Orb'' mascot (15 rows x 32 columns) (default) 187\ 188\ NOTE: Setting `loader_logo' to an undefined value (such as "none") will 189\ prevent beastie from being drawn. 190\ 191: draw-beastie ( -- ) \ at (loader_logo_x,loader_logo_y), else (46,4) 192 193 s" loader_logo_x" getenv dup -1 <> if 194 ?number 1 = if logoX ! then
|
158 else 159 drop 160 then
| 195 else 196 drop 197 then
|
161 true 162; 163 164: printmenuitem ( -- n ) 165 menuidx @ 166 1+ dup 167 menuidx ! 168 menuY @ + dup menuX @ swap at-xy 169 menuidx @ . 170 menuX @ 1+ swap at-xy 171 menubllt @ emit 172 menuidx @ 48 + 173; 174 175: beastie-menu ( -- ) 176 0 menuidx ! 177 dot menubllt ! 178 8 menuY ! 179 5 menuX ! 180 clear 181 46 4 print-logo 182 42 20 2 2 box 183 13 6 at-xy ." Welcome to FreeBSD!" 184 printmenuitem ." Boot FreeBSD [default]" bootkey ! 185 s" arch-i386" environment? if
| 198 s" loader_logo_y" getenv dup -1 <> if 199 ?number 1 = if logoY ! then 200 else
|
186 drop
| 201 drop
|
187 acpipresent? if 188 printmenuitem ." Boot FreeBSD with ACPI " bootacpikey ! 189 acpienabled? if 190 ." disabled" 191 else 192 ." enabled" 193 then
| 202 then 203 204 s" loader_logo" getenv dup -1 = if 205 logoX @ logoY @ 206 loader_color? if 207 orb-logo
|
194 else
| 208 else
|
195 menuidx @ 196 1+ 197 menuidx ! 198 -2 bootacpikey !
| 209 orbbw-logo
|
199 then
| 210 then
|
200 else 201 -2 bootacpikey !
| 211 drop exit
|
202 then
| 212 then
|
203 printmenuitem ." Boot FreeBSD in Safe Mode" bootsafekey ! 204 printmenuitem ." Boot FreeBSD in single user mode" bootsinglekey ! 205 printmenuitem ." Boot FreeBSD with verbose logging" bootverbosekey ! 206 printmenuitem ." Escape to loader prompt" escapekey ! 207 printmenuitem ." Reboot" rebootkey ! 208 menuX @ 20 at-xy 209 ." Select option, [Enter] for default" 210 menuX @ 21 at-xy 211 s" or [Space] to pause timer " dup 2 - promptwidth ! 212 type 213;
| |
214
| 213
|
215: tkey 216 seconds + 217 begin 1 while 218 over 0<> if 219 dup seconds u< if 220 drop 221 -1 222 exit 223 then 224 menuX @ promptwidth @ + 21 at-xy dup seconds - . 225 then 226 key? if 227 drop 228 key 229 exit 230 then 231 50 ms 232 repeat
| 214 2dup s" beastie" compare-insensitive 0= if 215 logoX @ logoY @ beastie-logo 216 2drop exit 217 then 218 2dup s" beastiebw" compare-insensitive 0= if 219 logoX @ logoY @ beastiebw-logo 220 2drop exit 221 then 222 2dup s" fbsdbw" compare-insensitive 0= if 223 logoX @ logoY @ fbsdbw-logo 224 2drop exit 225 then 226 2dup s" orb" compare-insensitive 0= if 227 logoX @ logoY @ orb-logo 228 2drop exit 229 then 230 2dup s" orbbw" compare-insensitive 0= if 231 logoX @ logoY @ orbbw-logo 232 2drop exit 233 then 234 235 2drop
|
233; 234
| 236; 237
|
235set-current
| 238: clear-beastie ( -- ) \ clears beastie from the screen 239 logoX @ logoY @ 240 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ 241 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ 242 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ 243 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ 244 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ 245 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ 246 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ 247 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ 248 2dup at-xy 34 spaces 1+ 2dup at-xy 34 spaces 1+ 249 2dup at-xy 34 spaces 2drop
|
236
| 250
|
237: beastie-start
| 251 \ Put the cursor back at the bottom 252 0 25 at-xy 253; 254 255: beastie-start ( -- ) \ starts the menu
|
238 s" beastie_disable" getenv 239 dup -1 <> if 240 s" YES" compare-insensitive 0= if 241 exit 242 then 243 else 244 drop 245 then
| 256 s" beastie_disable" getenv 257 dup -1 <> if 258 s" YES" compare-insensitive 0= if 259 exit 260 then 261 else 262 drop 263 then
|
246 beastie-menu 247 s" autoboot_delay" getenv 248 dup -1 = if 249 drop 250 10
| 264 265 s" loader_delay" getenv 266 -1 = if 267 s" include /boot/menu.rc" evaluate
|
251 else
| 268 else
|
252 2dup s" -1" compare 0= if 253 0 boot 254 then 255 0 s>d 2swap >number 2drop drop
| 269 drop 270 ." Loading Menu (Ctrl-C to Abort)" cr 271 s" set delay_command='include /boot/menu.rc'" evaluate 272 s" set delay_showdots" evaluate 273 delay_execute
|
256 then
| 274 then
|
257 begin 258 dup tkey 259 0 25 at-xy 260 dup 32 = if nip 0 swap then 261 dup -1 = if 0 boot then 262 dup 13 = if 0 boot then 263 dup bootkey @ = if 0 boot then 264 dup bootacpikey @ = if 265 acpienabled? if 266 s" 1" s" hint.acpi.0.disabled" setenv 267 s" 1" s" loader.acpi_disabled_by_user" setenv 268 else 269 s" 0" s" hint.acpi.0.disabled" setenv 270 then 271 0 boot 272 then 273 dup bootsafekey @ = if 274 s" arch-i386" environment? if 275 drop 276 s" 1" s" hint.acpi.0.disabled" setenv 277 s" 1" s" loader.acpi_disabled_by_user" setenv 278 s" 1" s" hint.apic.0.disabled" setenv 279 then 280 s" 0" s" hw.ata.ata_dma" setenv 281 s" 0" s" hw.ata.atapi_dma" setenv 282 s" 0" s" hw.ata.wc" setenv 283 s" 0" s" hw.eisa_slots" setenv 284 s" 1" s" hint.kbdmux.0.disabled" setenv 285 0 boot 286 then 287 dup bootverbosekey @ = if 288 s" YES" s" boot_verbose" setenv 289 0 boot 290 then 291 dup bootsinglekey @ = if 292 s" YES" s" boot_single" setenv 293 0 boot 294 then 295 dup escapekey @ = if 296 2drop 297 s" NO" s" autoboot_delay" setenv 298 exit 299 then 300 rebootkey @ = if 0 reboot then 301 again
| |
302;
| 275;
|
303 304previous
| |
| |