]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/boot/forth/beastie.4th
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / boot / forth / beastie.4th
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$
27
28 marker task-beastie.4th
29
30 include /boot/screen.4th
31 include /boot/frames.4th
32
33 hide
34
35 variable menuidx
36 variable menubllt
37 variable menuX
38 variable menuY
39 variable promptwidth
40
41 variable bootkey
42 variable bootacpikey
43 variable bootsafekey
44 variable bootverbosekey
45 variable bootsinglekey
46 variable escapekey
47 variable rebootkey
48
49 46 constant dot
50
51 \ The BSD Daemon.  He is 19 rows high and 34 columns wide
52 : beastie-logo ( x y -- )
53 2dup at-xy ."               \e[1;31m,        ," 1+
54 2dup at-xy ."              /(        )`" 1+
55 2dup at-xy ."              \ \___   / |" 1+
56 2dup at-xy ."              /- \e[37m_\e[31m  `-/  '" 1+
57 2dup at-xy ."             (\e[37m/\/ \\e[31m \   /\" 1+
58 2dup at-xy ."             \e[37m/ /   |\e[31m `    \" 1+
59 2dup at-xy ."             \e[34mO O   \e[37m) \e[31m/    |" 1+
60 2dup at-xy ."             \e[37m`-^--'\e[31m`<     '" 1+
61 2dup at-xy ."            (_.)  _  )   /" 1+
62 2dup at-xy ."             `.___/`    /       " 1+
63 2dup at-xy ."               `-----' /" 1+
64 2dup at-xy ."  \e[33m<----.\e[31m     __ / __   \" 1+
65 2dup at-xy ."  \e[33m<----|====\e[31mO)))\e[33m==\e[31m) \) /\e[33m====|" 1+
66 2dup at-xy ."  \e[33m<----'\e[31m    `--' `.__,' \" 1+
67 2dup at-xy ."               |        |" 1+
68 2dup at-xy ."                \       /       /\" 1+
69 2dup at-xy ."           \e[36m______\e[31m( (_  / \______/" 1+
70 2dup at-xy ."         \e[36m,'  ,-----'   |" 1+
71 at-xy ."         `--{__________) \e[0m"
72 ;
73
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 ."        `--{__________)"
94 ;
95
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 ."     |____/|_____/|_____/"
110 ;
111
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
141 ;
142
143 : acpienabled? ( -- flag )
144         s" acpi_load" getenv
145         dup -1 = if
146                 drop false exit
147         then
148         s" YES" compare-insensitive 0<> if
149                 false exit
150         then
151         s" hint.acpi.0.disabled" getenv
152         dup -1 <> if
153                 s" 0" compare 0<> if
154                         false exit
155                 then
156         else
157                 drop
158         then
159         true
160 ;
161
162 : printmenuitem ( -- n )
163         menuidx @
164         1+ dup
165         menuidx !
166         menuY @ + dup menuX @ swap at-xy
167         menuidx @ .
168         menuX @ 1+ swap at-xy
169         menubllt @ emit
170         menuidx @ 48 +
171 ;
172
173 : beastie-menu ( -- )
174         0 menuidx !
175         dot menubllt !
176         8 menuY !
177         5 menuX !
178         clear
179         46 4 print-logo
180         42 20 2 2 box
181         13 6 at-xy ." Welcome to FreeBSD!"
182         printmenuitem ."  Boot FreeBSD [default]" bootkey !
183         s" arch-i386" environment? if
184                 drop
185                 printmenuitem ."  Boot FreeBSD with ACPI " bootacpikey !
186                 acpienabled? if
187                         ." disabled"
188                 else
189                         ." enabled"
190                 then
191         else
192                 -2 bootacpikey !
193         then
194         printmenuitem ."  Boot FreeBSD in Safe Mode" bootsafekey !
195         printmenuitem ."  Boot FreeBSD in single user mode" bootsinglekey !
196         printmenuitem ."  Boot FreeBSD with verbose logging" bootverbosekey !
197         printmenuitem ."  Escape to loader prompt" escapekey !
198         printmenuitem ."  Reboot" rebootkey !
199         menuX @ 20 at-xy
200         ." Select option, [Enter] for default"
201         menuX @ 21 at-xy
202         s" or [Space] to pause timer    " dup 2 - promptwidth !
203         type
204 ;
205
206 : tkey
207         seconds +
208         begin 1 while
209                 over 0<> if
210                         dup seconds u< if
211                                 drop
212                                 -1
213                                 exit
214                         then
215                         menuX @ promptwidth @ + 21 at-xy dup seconds - .
216                 then
217                 key? if
218                         drop
219                         key
220                         exit
221                 then
222         50 ms
223         repeat
224 ;
225
226 set-current
227
228 : beastie-start
229         s" beastie_disable" getenv
230         dup -1 <> if
231                 s" YES" compare-insensitive 0= if
232                         exit
233                 then
234         else
235                 drop
236         then
237         beastie-menu
238         s" autoboot_delay" getenv
239         dup -1 = if
240                 drop
241                 10
242         else
243                 0 0 2swap >number drop drop drop
244         then
245         begin
246                 dup tkey
247                 0 25 at-xy
248                 dup 32 = if nip 0 swap then
249                 dup -1 = if 0 boot then
250                 dup 13 = if 0 boot then
251                 dup bootkey @ = if 0 boot then
252                 dup bootacpikey @ = if
253                         acpienabled? if
254                                 s" acpi_load" unsetenv
255                                 s" 1" s" hint.acpi.0.disabled" setenv
256                                 s" 1" s" loader.acpi_disabled_by_user" setenv
257                         else
258                                 s" YES" s" acpi_load" setenv
259                                 s" 0" s" hint.acpi.0.disabled" setenv
260                         then
261                         0 boot
262                 then
263                 dup bootsafekey @ = if
264                         s" arch-i386" environment? if
265                                 drop
266                                 s" acpi_load" unsetenv
267                                 s" 1" s" hint.acpi.0.disabled" setenv
268                                 s" 1" s" loader.acpi_disabled_by_user" setenv
269                                 s" 1" s" hint.apic.0.disabled" setenv
270                         then
271                         s" 0" s" hw.ata.ata_dma" setenv
272                         s" 0" s" hw.ata.atapi_dma" setenv
273                         s" 0" s" hw.ata.wc" setenv
274                         s" 0" s" hw.eisa_slots" setenv
275                         s" 1" s" hint.kbdmux.0.disabled" setenv
276                         0 boot
277                 then
278                 dup bootverbosekey @ = if
279                         s" YES" s" boot_verbose" setenv
280                         0 boot
281                 then
282                 dup bootsinglekey @ = if
283                         s" YES" s" boot_single" setenv
284                         0 boot
285                 then
286                 dup escapekey @ = if
287                         2drop
288                         s" NO" s" autoboot_delay" setenv
289                         exit
290                 then
291                 rebootkey @ = if 0 reboot then
292         again
293 ;
294
295 previous