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: src/sys/boot/forth/beastie.4th,v 1.10.2.2 2006/04/04 17:03:44 emax Exp $ |
---|
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 rundisplaywiz |
---|
46 | variable bootsinglekey |
---|
47 | variable escapekey |
---|
48 | variable rebootkey |
---|
49 | variable bootsafe_set |
---|
50 | variable xvesa |
---|
51 | variable xvesa_set |
---|
52 | variable xwiz_set |
---|
53 | variable kernelkey |
---|
54 | variable kerncurrent |
---|
55 | variable kerncurrent_set |
---|
56 | variable kernold |
---|
57 | variable kernold_set |
---|
58 | variable kerngeneric |
---|
59 | variable kerngeneric_set |
---|
60 | |
---|
61 | 46 constant dot |
---|
62 | |
---|
63 | \ The BSD Daemon. He is 19 rows high and 34 columns wide |
---|
64 | : beastie-logo ( x y -- ) |
---|
65 | \ 2dup at-xy ." [1;31m, ," 1+ |
---|
66 | \ 2dup at-xy ." /( )`" 1+ |
---|
67 | \ 2dup at-xy ." \ \___ / |" 1+ |
---|
68 | \ 2dup at-xy ." /- [37m_[31m `-/ '" 1+ |
---|
69 | \ 2dup at-xy ." ([37m/\/ \[31m \ /\" 1+ |
---|
70 | \ 2dup at-xy ." [37m/ / |[31m ` \" 1+ |
---|
71 | \ 2dup at-xy ." [34mO O [37m) [31m/ |" 1+ |
---|
72 | \ 2dup at-xy ." [37m`-^--'[31m`< '" 1+ |
---|
73 | \ 2dup at-xy ." (_.) _ ) /" 1+ |
---|
74 | \ 2dup at-xy ." `.___/` / " 1+ |
---|
75 | \ 2dup at-xy ." `-----' /" 1+ |
---|
76 | \ 2dup at-xy ." [33m<----.[31m __ / __ \" 1+ |
---|
77 | \ 2dup at-xy ." [33m<----|====[31mO)))[33m==[31m) \) /[33m====|" 1+ |
---|
78 | \ 2dup at-xy ." [33m<----'[31m `--' `.__,' \" 1+ |
---|
79 | \ 2dup at-xy ." | |" 1+ |
---|
80 | \ 2dup at-xy ." \ / /\" 1+ |
---|
81 | \ 2dup at-xy ." [36m______[31m( (_ / \______/" 1+ |
---|
82 | \ 2dup at-xy ." [36m,' ,-----' |" 1+ |
---|
83 | \ at-xy ." `--{__________) [0m" |
---|
84 | ; |
---|
85 | |
---|
86 | : beastiebw-logo ( x y -- ) |
---|
87 | \ 2dup at-xy ." , ," 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 | \ 2dup at-xy ." O O ) / |" 1+ |
---|
94 | \ 2dup at-xy ." `-^--'`< '" 1+ |
---|
95 | \ 2dup at-xy ." (_.) _ ) /" 1+ |
---|
96 | \ 2dup at-xy ." `.___/` /" 1+ |
---|
97 | \ 2dup at-xy ." `-----' /" 1+ |
---|
98 | \ 2dup at-xy ." <----. __ / __ \" 1+ |
---|
99 | \ 2dup at-xy ." <----|====O)))==) \) /====" 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 | \ at-xy ." `--{__________)" |
---|
106 | ; |
---|
107 | |
---|
108 | : fbsdbw-logo ( x y -- ) |
---|
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 | at-xy ." /_____/____/_____/" |
---|
119 | ; |
---|
120 | |
---|
121 | : print-logo ( x y -- ) |
---|
122 | s" loader_logo" getenv |
---|
123 | dup -1 = if |
---|
124 | drop |
---|
125 | fbsdbw-logo |
---|
126 | exit |
---|
127 | then |
---|
128 | 2dup s" fbsdbw" compare-insensitive 0= if |
---|
129 | 2drop |
---|
130 | fbsdbw-logo |
---|
131 | exit |
---|
132 | then |
---|
133 | 2dup s" beastiebw" compare-insensitive 0= if |
---|
134 | 2drop |
---|
135 | beastiebw-logo |
---|
136 | exit |
---|
137 | then |
---|
138 | 2dup s" beastie" compare-insensitive 0= if |
---|
139 | 2drop |
---|
140 | beastie-logo |
---|
141 | exit |
---|
142 | then |
---|
143 | 2dup s" none" compare-insensitive 0= if |
---|
144 | 2drop |
---|
145 | \ no logo |
---|
146 | exit |
---|
147 | then |
---|
148 | 2drop |
---|
149 | fbsdbw-logo |
---|
150 | ; |
---|
151 | |
---|
152 | : acpienabled? ( -- flag ) |
---|
153 | s" acpi_load" getenv |
---|
154 | dup -1 = if |
---|
155 | drop false exit |
---|
156 | then |
---|
157 | s" YES" compare-insensitive 0<> if |
---|
158 | false exit |
---|
159 | then |
---|
160 | s" hint.acpi.0.disabled" getenv |
---|
161 | dup -1 <> if |
---|
162 | s" 0" compare 0<> if |
---|
163 | false exit |
---|
164 | then |
---|
165 | else |
---|
166 | drop |
---|
167 | then |
---|
168 | true |
---|
169 | ; |
---|
170 | |
---|
171 | : printmenuitem ( -- n ) |
---|
172 | menuidx @ |
---|
173 | 1+ dup |
---|
174 | menuidx ! |
---|
175 | menuY @ + dup menuX @ swap at-xy |
---|
176 | menuidx @ . |
---|
177 | menuX @ 1+ swap at-xy |
---|
178 | menubllt @ emit |
---|
179 | menuidx @ 48 + |
---|
180 | ; |
---|
181 | |
---|
182 | : options-menu ( -- ) |
---|
183 | 0 menuidx ! |
---|
184 | dot menubllt ! |
---|
185 | 8 menuY ! |
---|
186 | 5 menuX ! |
---|
187 | clear |
---|
188 | 24 1 at-xy ." ____ ______ ____ _____ ____" |
---|
189 | 24 2 at-xy ." / __ \/ ____/ / __ ) ___// __ \" |
---|
190 | 24 3 at-xy ." / /_/ / / / __ \__ \/ / / /" |
---|
191 | 24 4 at-xy ." / ____/ /___ / /_/ /__/ / /_/ /" |
---|
192 | 24 5 at-xy ." /_/ \____/ /_____/____/_____/" |
---|
193 | 24 6 at-xy ." " |
---|
194 | 24 7 at-xy ." Press any key for boot options" |
---|
195 | ; |
---|
196 | |
---|
197 | : kernels-menu ( -- ) |
---|
198 | 0 menuidx ! |
---|
199 | dot menubllt ! |
---|
200 | 8 menuY ! |
---|
201 | 5 menuX ! |
---|
202 | clear |
---|
203 | 46 4 print-logo |
---|
204 | 43 15 2 2 box |
---|
205 | 13 6 at-xy ." Select kernel to boot in" |
---|
206 | printmenuitem ." Current kernel (kernel)" kerncurrent ! |
---|
207 | s" kernelold_show" getenv |
---|
208 | dup -1 <> if |
---|
209 | s" YES" compare-insensitive 0 = if |
---|
210 | printmenuitem ." Previous kernel (kernel.old)" kernold ! |
---|
211 | then |
---|
212 | else |
---|
213 | drop |
---|
214 | then |
---|
215 | s" kernelgeneric_show" getenv |
---|
216 | dup -1 <> if |
---|
217 | s" YES" compare-insensitive 0 = if |
---|
218 | printmenuitem ." Generic PC-BSD kernel (kernel.pcbsd)" kerngeneric ! |
---|
219 | then |
---|
220 | else |
---|
221 | drop |
---|
222 | then |
---|
223 | menuX @ 15 at-xy |
---|
224 | ." Select option, [Enter] for go back" |
---|
225 | menuX @ 21 at-xy |
---|
226 | ; |
---|
227 | |
---|
228 | : beastie-menu ( -- ) |
---|
229 | -1 menuidx ! |
---|
230 | dot menubllt ! |
---|
231 | 8 menuY ! |
---|
232 | 5 menuX ! |
---|
233 | clear |
---|
234 | 46 4 print-logo |
---|
235 | 43 22 2 2 box |
---|
236 | 13 5 at-xy ." Welcome to PC-BSD!" |
---|
237 | printmenuitem ." Boot PC-BSD [default]" bootkey ! |
---|
238 | printmenuitem ." Boot PC-BSD in single user mode" bootsinglekey ! |
---|
239 | printmenuitem ." Boot PC-BSD with verbose logging" bootverbosekey ! |
---|
240 | s" arch-i386" environment? if |
---|
241 | drop |
---|
242 | printmenuitem ." Toggle ACPI " bootacpikey ! |
---|
243 | acpienabled? if |
---|
244 | ." (Enabled)" |
---|
245 | else |
---|
246 | ." (Disabled)" |
---|
247 | then |
---|
248 | else |
---|
249 | -2 bootacpikey ! |
---|
250 | then |
---|
251 | printmenuitem ." Toggle Safe Mode " bootsafekey ! |
---|
252 | bootsafe_set @ 1 = if |
---|
253 | ." (Enabled)" |
---|
254 | else |
---|
255 | ." (Disabled)" |
---|
256 | then |
---|
257 | printmenuitem ." Toggle X in VESA mode " xvesa ! |
---|
258 | xvesa_set @ 1 = if |
---|
259 | ." (Enabled)" |
---|
260 | else |
---|
261 | ." (Disabled)" |
---|
262 | then |
---|
263 | printmenuitem ." Run the Display Wizard " rundisplaywiz ! |
---|
264 | xwiz_set @ 1 = if |
---|
265 | ." (Enabled)" |
---|
266 | else |
---|
267 | ." (Disabled)" |
---|
268 | then |
---|
269 | printmenuitem ." Escape to loader prompt" escapekey ! |
---|
270 | s" kernelmenu_show" getenv |
---|
271 | dup -1 <> if |
---|
272 | s" YES" compare-insensitive 0 = if |
---|
273 | printmenuitem ." Select kernel " kernelkey ! |
---|
274 | kerngeneric_set @ 1 = if |
---|
275 | ." (kernel.pcbsd)" |
---|
276 | then |
---|
277 | kernold_set @ 1 = if |
---|
278 | ." (kernel.old)" |
---|
279 | then |
---|
280 | then |
---|
281 | else |
---|
282 | drop |
---|
283 | then |
---|
284 | printmenuitem ." Reboot" rebootkey ! |
---|
285 | menuX @ 20 at-xy |
---|
286 | ." Select option, [Enter] for default" |
---|
287 | menuX @ 21 at-xy |
---|
288 | ; |
---|
289 | |
---|
290 | : tkeynotimer |
---|
291 | seconds + |
---|
292 | begin 1 while |
---|
293 | key? if |
---|
294 | drop |
---|
295 | key |
---|
296 | exit |
---|
297 | then |
---|
298 | 50 ms |
---|
299 | repeat |
---|
300 | ; |
---|
301 | |
---|
302 | : tkeyhidetimer |
---|
303 | seconds + |
---|
304 | begin 1 while |
---|
305 | over 0<> if |
---|
306 | dup seconds u< if |
---|
307 | drop |
---|
308 | -1 |
---|
309 | exit |
---|
310 | then |
---|
311 | then |
---|
312 | key? if |
---|
313 | drop |
---|
314 | key |
---|
315 | exit |
---|
316 | then |
---|
317 | 50 ms |
---|
318 | repeat |
---|
319 | ; |
---|
320 | |
---|
321 | |
---|
322 | set-current |
---|
323 | |
---|
324 | : beastie-start |
---|
325 | s" beastie_disable" getenv |
---|
326 | dup -1 <> if |
---|
327 | s" YES" compare-insensitive 0= if |
---|
328 | exit |
---|
329 | then |
---|
330 | else |
---|
331 | drop |
---|
332 | then |
---|
333 | s" NO" s" xvesa" setenv |
---|
334 | 0 bootsafe_set ! |
---|
335 | 0 xvesa_set ! |
---|
336 | 0 xwiz_set ! |
---|
337 | 1 kerncurrent_set ! |
---|
338 | 0 kernold_set ! |
---|
339 | 0 kerngeneric_set ! |
---|
340 | s" autoboot_delay" getenv |
---|
341 | dup -1 = if |
---|
342 | s" 02" s" autoboot_delay" setenv |
---|
343 | then |
---|
344 | s" autoboot_delay" getenv |
---|
345 | dup -1 = if |
---|
346 | drop |
---|
347 | 10 |
---|
348 | else |
---|
349 | 0 0 2swap >number drop drop drop |
---|
350 | then |
---|
351 | begin |
---|
352 | s" autoboot_delay" getenv |
---|
353 | dup -1 <> if |
---|
354 | s" NO" compare-insensitive 0= if |
---|
355 | beastie-menu |
---|
356 | dup tkeynotimer |
---|
357 | 0 25 at-xy |
---|
358 | dup 32 = if nip 0 swap then |
---|
359 | dup -1 = if 0 boot then |
---|
360 | dup 13 = if 0 boot then |
---|
361 | dup bootkey @ = if 0 boot then |
---|
362 | dup bootacpikey @ = if |
---|
363 | acpienabled? if |
---|
364 | s" acpi_load" unsetenv |
---|
365 | s" 1" s" hint.acpi.0.disabled" setenv |
---|
366 | s" 1" s" loader.acpi_disabled_by_user" setenv |
---|
367 | else |
---|
368 | s" YES" s" acpi_load" setenv |
---|
369 | s" 0" s" hint.acpi.0.disabled" setenv |
---|
370 | then |
---|
371 | then |
---|
372 | dup bootsafekey @ = if |
---|
373 | bootsafe_set @ 1 = if |
---|
374 | s" 0" s" hw.ata.ata_dma" setenv |
---|
375 | s" 0" s" hw.ata.atapi_dma" setenv |
---|
376 | s" 0" s" hw.ata.wc" setenv |
---|
377 | s" 0" s" hw.eisa_slots" setenv |
---|
378 | s" 1" s" hint.kbdmux.0.disabled" setenv |
---|
379 | 0 bootsafe_set ! |
---|
380 | else |
---|
381 | s" 1" s" hw.ata.ata_dma" setenv |
---|
382 | s" 1" s" hw.ata.atapi_dma" setenv |
---|
383 | s" 1" s" hw.ata.wc" setenv |
---|
384 | s" 1" s" hw.eisa_slots" setenv |
---|
385 | s" 0" s" hint.kbdmux.0.disabled" setenv |
---|
386 | 1 bootsafe_set ! |
---|
387 | then |
---|
388 | then |
---|
389 | dup bootverbosekey @ = if |
---|
390 | s" YES" s" boot_verbose" setenv |
---|
391 | 0 boot |
---|
392 | then |
---|
393 | dup xvesa @ = if |
---|
394 | xvesa_set @ 1 = if |
---|
395 | s" NO" s" xvesa" setenv |
---|
396 | 0 xvesa_set ! |
---|
397 | else |
---|
398 | s" YES" s" xvesa" setenv |
---|
399 | 1 xvesa_set ! |
---|
400 | then |
---|
401 | then |
---|
402 | dup rundisplaywiz @ = if |
---|
403 | xwiz_set @ 1 = if |
---|
404 | s" NO" s" runwiz" setenv |
---|
405 | 0 xwiz_set ! |
---|
406 | else |
---|
407 | s" YES" s" runwiz" setenv |
---|
408 | 1 xwiz_set ! |
---|
409 | then |
---|
410 | then |
---|
411 | dup bootsinglekey @ = if |
---|
412 | s" YES" s" boot_single" setenv |
---|
413 | 0 boot |
---|
414 | then |
---|
415 | dup kernelkey @ = if |
---|
416 | kernels-menu |
---|
417 | dup tkeynotimer |
---|
418 | dup kerncurrent @ = if |
---|
419 | 1 kerncurrent_set ! |
---|
420 | 0 kernold_set ! |
---|
421 | 0 kerngeneric_set ! |
---|
422 | then |
---|
423 | dup kerngeneric @ = if |
---|
424 | 0 kerncurrent_set ! |
---|
425 | 0 kernold_set ! |
---|
426 | 1 kerngeneric_set ! |
---|
427 | then |
---|
428 | dup kernold @ = if |
---|
429 | 0 kerncurrent_set ! |
---|
430 | 1 kernold_set ! |
---|
431 | 0 kerngeneric_set ! |
---|
432 | then |
---|
433 | 0 1 unload drop |
---|
434 | kerncurrent_set @ 1 = if |
---|
435 | s" kernel" s" kernel" setenv |
---|
436 | then |
---|
437 | kerngeneric_set @ 1 = if |
---|
438 | s" kernel.pcbsd" s" kernel" setenv |
---|
439 | then |
---|
440 | kernold_set @ 1 = if |
---|
441 | s" kernel.old" s" kernel" setenv |
---|
442 | then |
---|
443 | then |
---|
444 | dup escapekey @ = if |
---|
445 | 2drop |
---|
446 | s" NO" s" autoboot_delay" setenv |
---|
447 | exit |
---|
448 | then |
---|
449 | rebootkey @ = if 0 reboot then |
---|
450 | else |
---|
451 | options-menu |
---|
452 | dup tkeyhidetimer |
---|
453 | dup 32 = if nip 0 swap then |
---|
454 | clear |
---|
455 | dup -1 = if 0 boot then |
---|
456 | s" NO" s" autoboot_delay" setenv |
---|
457 | then |
---|
458 | else |
---|
459 | clear |
---|
460 | 0 boot |
---|
461 | then |
---|
462 | again |
---|
463 | ; |
---|
464 | |
---|
465 | previous |
---|