beastie.4th revision 115434
1\ Copyright (c) 2003 Scott Long <scottl@freebsd.org> 2\ All rights reserved. 3\ 4\ Redistribution and use in source and binary forms, with or without 5\ modification, are permitted provided that the following conditions 6\ are met: 7\ 1. Redistributions of source code must retain the above copyright 8\ notice, this list of conditions and the following disclaimer. 9\ 2. Redistributions in binary form must reproduce the above copyright 10\ notice, this list of conditions and the following disclaimer in the 11\ documentation and/or other materials provided with the distribution. 12\ 13\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16\ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23\ SUCH DAMAGE. 24\ 25\ $FreeBSD: head/sys/boot/forth/beastie.4th 115434 2003-05-31 11:19:11Z scottl $ 26 27marker task-beastie.4th 28 29include /boot/screen.4th 30include /boot/frames.4th 31 32hide 33 34variable menuidx 35variable menubllt 36variable menuX 37variable menuY 38variable promptwidth 39 40variable bootkey 41variable bootacpikey 42variable bootsafekey 43variable bootverbosekey 44variable bootsinglekey 45variable escapekey 46variable rebootkey 47 4846 constant dot 49 50\ The BSD Daemon. He is 19 rows high and 34 columns wide 51: print-beastie ( x y -- ) 52 2dup at-xy ." , ," 1+ 53 2dup at-xy ." /( )`" 1+ 54 2dup at-xy ." \\ \\___ / |" 1+ 55 2dup at-xy ." /- _ `-/ '" 1+ 56 2dup at-xy ." (/\\/ \\ \\ /\\" 1+ 57 2dup at-xy ." / / | ` \\" 1+ 58 2dup at-xy ." O O ) / |" 1+ 59 2dup at-xy ." `-^--'`< '" 1+ 60 2dup at-xy ." (_.) _ ) /" 1+ 61 2dup at-xy ." `.___/` /" 1+ 62 2dup at-xy ." `-----' /" 1+ 63 2dup at-xy ." <----. __ / __ \\" 1+ 64 2dup at-xy ." <----|====O)))==) \\) /====" 1+ 65 2dup at-xy ." <----' `--' `.__,' \\" 1+ 66 2dup at-xy ." | |" 1+ 67 2dup at-xy ." \\ / /\\" 1+ 68 2dup at-xy ." ______( (_ / \\______/" 1+ 69 2dup at-xy ." ,' ,-----' |" 1+ 70 at-xy ." `--{__________)" 71; 72 73: acpienabled? ( -- flag ) 74 s" acpi_load" getenv 75 dup -1 = if 76 drop false exit 77 then 78 s" YES" compare-insensitive 0<> if 79 false exit 80 then 81 s" hint.acpi.0.disabled" getenv 82 dup -1 <> if 83 s" 0" compare 0<> if 84 false exit 85 then 86 then 87 true 88; 89 90: printmenuitem ( -- n ) 91 menuidx @ 92 1+ dup 93 menuidx ! 94 menuY @ + dup menuX @ swap at-xy 95 menuidx @ . 96 menuX @ 1+ swap at-xy 97 menubllt @ emit 98 menuidx @ 48 + 99; 100 101: beastie-menu ( -- ) 102 0 menuidx ! 103 dot menubllt ! 104 8 menuY ! 105 5 menuX ! 106 clear 107 46 4 print-beastie 108 42 20 2 2 box 109 13 6 at-xy ." Welcome to FreeBSD!" 110 printmenuitem ." Boot FreeBSD [default]" bootkey ! 111 s" arch-i386" environment? if 112 printmenuitem ." Boot FreeBSD with ACPI " bootacpikey ! 113 acpienabled? if 114 ." disabled" 115 else 116 ." enabled" 117 then 118 else 119 -2 bootacpikey ! 120 then 121 printmenuitem ." Boot FreeBSD in Safe Mode" bootsafekey ! 122 printmenuitem ." Boot FreeBSD in single user mode" bootsinglekey ! 123 printmenuitem ." Boot FreeBSD with verbose logging" bootverbosekey ! 124 printmenuitem ." Escape to loader prompt" escapekey ! 125 printmenuitem ." Reboot" rebootkey ! 126 menuX @ 20 at-xy 127 ." Select option, [Enter] for default" 128 menuX @ 21 at-xy 129 s" or [Space] to pause timer " dup 2 - promptwidth ! 130 type 131; 132 133: tkey 134 dup 135 seconds + 136 begin 1 while 137 over 0<> if 138 dup seconds u< if 139 drop 140 -1 141 exit 142 then 143 menuX @ promptwidth @ + 21 at-xy dup seconds - . 144 then 145 key? if 146 drop 147 key 148 exit 149 then 150 50 ms 151 repeat 152; 153 154set-current 155 156: beastie-start 157 beastie-menu 158 s" autoboot_delay" getenv 159 dup -1 = if 160 drop 161 10 162 else 163 0 0 2swap >number drop drop drop 164 then 165 begin true while 166 dup tkey 167 0 25 at-xy 168 dup 32 = if nip 0 swap then 169 dup -1 = if s" boot" evaluate then 170 dup 13 = if s" boot" evaluate then 171 dup bootkey @ = if s" boot" evaluate then 172 dup bootacpikey @ = if 173 acpienabled? if 174 s" acpi_load" unsetenv 175 s" 1" s" hint.acpi.0.disabled" setenv 176 s" 1" s" loader.acpi_disabled_by_user" setenv 177 else 178 s" YES" s" acpi_load" setenv 179 s" 0" s" hint.acpi.0.disabled" setenv 180 then 181 s" boot" evaluate 182 then 183 dup bootsafekey @ = if 184 s" arch-i386" environment? if 185 s" acpi_load" unsetenv 186 s" 1" s" hint.acpi.0.disabled" setenv 187 s" 1" s" loader.acpi_disabled_by_user" setenv 188 then 189 s" 0" s" hw.ata.ata_dma" setenv 190 s" 0" s" hw.ata.atapi_dma" setenv 191 s" 0" s" hw.ata.wc" setenv 192 s" 0" s" hw.eisa_slots" setenv 193 s" boot" evaluate 194 then 195 dup bootverbosekey @ = if 196 s" YES" s" boot_verbose" setenv 197 s" boot" evaluate 198 then 199 dup bootsinglekey @ = if 200 s" YES" s" boot_single" setenv 201 s" boot" evaluate 202 then 203 dup escapekey @ = if 2drop exit then 204 rebootkey @ = if s" reboot" evaluate then 205 repeat 206; 207 208previous 209