beastie.4th revision 151873
1115410Sscottl\ Copyright (c) 2003 Scott Long <scottl@freebsd.org>
2120031Sscottl\ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com>
3115410Sscottl\ All rights reserved.
4115410Sscottl\
5115410Sscottl\ Redistribution and use in source and binary forms, with or without
6115410Sscottl\ modification, are permitted provided that the following conditions
7115410Sscottl\ are met:
8115410Sscottl\ 1. Redistributions of source code must retain the above copyright
9115410Sscottl\    notice, this list of conditions and the following disclaimer.
10115410Sscottl\ 2. Redistributions in binary form must reproduce the above copyright
11115410Sscottl\    notice, this list of conditions and the following disclaimer in the
12115410Sscottl\    documentation and/or other materials provided with the distribution.
13115410Sscottl\
14115410Sscottl\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15115410Sscottl\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16115410Sscottl\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17115410Sscottl\ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18115410Sscottl\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19115410Sscottl\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20115410Sscottl\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21115410Sscottl\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22115410Sscottl\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23115410Sscottl\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24115410Sscottl\ SUCH DAMAGE.
25115410Sscottl\
26115410Sscottl\ $FreeBSD: head/sys/boot/forth/beastie.4th 151873 2005-10-30 05:36:23Z scottl $
27115410Sscottl
28115410Sscottlmarker task-beastie.4th
29115410Sscottl
30115410Sscottlinclude /boot/screen.4th
31115410Sscottlinclude /boot/frames.4th
32115410Sscottl
33115410Sscottlhide
34115410Sscottl
35115410Sscottlvariable menuidx
36115410Sscottlvariable menubllt
37115410Sscottlvariable menuX
38115410Sscottlvariable menuY
39115410Sscottlvariable promptwidth
40115410Sscottl
41115410Sscottlvariable bootkey
42115410Sscottlvariable bootacpikey
43137071Sbrooksvariable bootusbkey
44115410Sscottlvariable bootsafekey
45115410Sscottlvariable bootverbosekey
46115410Sscottlvariable bootsinglekey
47115410Sscottlvariable escapekey
48115410Sscottlvariable rebootkey
49115410Sscottl
50115410Sscottl46 constant dot
51115410Sscottl
52115410Sscottl\ The BSD Daemon.  He is 19 rows high and 34 columns wide
53151873Sscottl: beastie-logo ( x y -- )
54120031Sscottl2dup at-xy ."               [1;31m,        ," 1+
55120031Sscottl2dup at-xy ."              /(        )`" 1+
56120031Sscottl2dup at-xy ."              \ \___   / |" 1+
57120031Sscottl2dup at-xy ."              /- [37m_[31m  `-/  '" 1+
58120031Sscottl2dup at-xy ."             ([37m/\/ \[31m \   /\" 1+
59120031Sscottl2dup at-xy ."             [37m/ /   |[31m `    \" 1+
60120031Sscottl2dup at-xy ."             [34mO O   [37m) [31m/    |" 1+
61120031Sscottl2dup at-xy ."             [37m`-^--'[31m`<     '" 1+
62120031Sscottl2dup at-xy ."            (_.)  _  )   /" 1+
63120031Sscottl2dup at-xy ."             `.___/`    /       " 1+
64120031Sscottl2dup at-xy ."               `-----' /" 1+
65120031Sscottl2dup at-xy ."  [33m<----.[31m     __ / __   \" 1+
66120031Sscottl2dup at-xy ."  [33m<----|====[31mO)))[33m==[31m) \) /[33m====|" 1+
67120031Sscottl2dup at-xy ."  [33m<----'[31m    `--' `.__,' \" 1+
68120031Sscottl2dup at-xy ."               |        |" 1+
69120031Sscottl2dup at-xy ."                \       /       /\" 1+
70120031Sscottl2dup at-xy ."           [36m______[31m( (_  / \______/" 1+
71120031Sscottl2dup at-xy ."         [36m,'  ,-----'   |" 1+
72138258Sscottlat-xy ."         `--{__________) [0m"
73120031Sscottl;
74120031Sscottl
75151873Sscottl: beastiebw-logo ( x y -- )
76115410Sscottl	2dup at-xy ."              ,        ," 1+
77115410Sscottl	2dup at-xy ."             /(        )`" 1+
78115451Sscottl	2dup at-xy ."             \ \___   / |" 1+
79115410Sscottl	2dup at-xy ."             /- _  `-/  '" 1+
80115451Sscottl	2dup at-xy ."            (/\/ \ \   /\" 1+
81115451Sscottl	2dup at-xy ."            / /   | `    \" 1+
82115410Sscottl	2dup at-xy ."            O O   ) /    |" 1+
83115410Sscottl	2dup at-xy ."            `-^--'`<     '" 1+
84115410Sscottl	2dup at-xy ."           (_.)  _  )   /" 1+
85115410Sscottl	2dup at-xy ."            `.___/`    /" 1+
86115410Sscottl	2dup at-xy ."              `-----' /" 1+
87115451Sscottl	2dup at-xy ." <----.     __ / __   \" 1+
88115451Sscottl	2dup at-xy ." <----|====O)))==) \) /====" 1+
89115451Sscottl	2dup at-xy ." <----'    `--' `.__,' \" 1+
90115410Sscottl	2dup at-xy ."              |        |" 1+
91115451Sscottl	2dup at-xy ."               \       /       /\" 1+
92115451Sscottl	2dup at-xy ."          ______( (_  / \______/" 1+
93115410Sscottl	2dup at-xy ."        ,'  ,-----'   |" 1+
94115410Sscottl	     at-xy ."        `--{__________)"
95115410Sscottl;
96115410Sscottl
97151873Sscottl: fbsdbw-logo ( x y -- )
98151873Sscottl	2dup at-xy ."      ______" 1+
99151873Sscottl	2dup at-xy ."     |  ____| __ ___  ___ " 1+
100151873Sscottl	2dup at-xy ."     | |__ | '__/ _ \/ _ \" 1+
101151873Sscottl	2dup at-xy ."     |  __|| | |  __/  __/" 1+
102151873Sscottl	2dup at-xy ."     | |   | | |    |    |" 1+
103151873Sscottl	2dup at-xy ."     |_|   |_|  \___|\___|" 1+
104151873Sscottl	2dup at-xy ."      ____   _____ _____" 1+
105151873Sscottl	2dup at-xy ."     |  _ \ / ____|  __ \" 1+
106151873Sscottl	2dup at-xy ."     | |_) | (___ | |  | |" 1+
107151873Sscottl	2dup at-xy ."     |  _ < \___ \| |  | |" 1+
108151873Sscottl	2dup at-xy ."     | |_) |____) | |__| |" 1+
109151873Sscottl	2dup at-xy ."     |     |      |      |" 1+
110151873Sscottl	     at-xy ."     |____/|_____/|_____/"
111151873Sscottl;
112151873Sscottl
113151873Sscottl: print-logo ( x y -- )
114151873Sscottl	s" loader_logo" getenv
115120031Sscottl	dup -1 = if
116120031Sscottl		drop
117151873Sscottl		fbsdbw-logo
118120031Sscottl		exit
119120031Sscottl	then
120151873Sscottl	2dup s" fbsdbw" compare-insensitive 0= if
121151873Sscottl		2drop
122151873Sscottl		fbsdbw-logo
123120031Sscottl		exit
124120031Sscottl	then
125151873Sscottl	2dup s" beastiebw" compare-insensitive 0= if
126151873Sscottl		2drop
127151873Sscottl		beastiebw-logo
128151873Sscottl		exit
129151873Sscottl	then
130151873Sscottl	2dup s" beastie" compare-insensitive 0= if
131151873Sscottl		2drop
132151873Sscottl		beastie-logo
133151873Sscottl		exit
134151873Sscottl	then
135151873Sscottl	2dup s" none" compare-insensitive 0= if
136151873Sscottl		2drop
137151873Sscottl		\ no logo
138151873Sscottl		exit
139151873Sscottl	then
140151873Sscottl	2drop
141151873Sscottl	fbsdbw-logo
142120031Sscottl;
143120031Sscottl
144115410Sscottl: acpienabled? ( -- flag )
145115410Sscottl	s" acpi_load" getenv
146115410Sscottl	dup -1 = if
147115410Sscottl		drop false exit
148115410Sscottl	then
149115410Sscottl	s" YES" compare-insensitive 0<> if
150115410Sscottl		false exit
151115410Sscottl	then
152115410Sscottl	s" hint.acpi.0.disabled" getenv
153115410Sscottl	dup -1 <> if
154115410Sscottl		s" 0" compare 0<> if
155115410Sscottl			false exit
156115410Sscottl		then
157138258Sscottl	else
158138258Sscottl		drop
159115410Sscottl	then
160115410Sscottl	true
161115410Sscottl;
162115410Sscottl
163115410Sscottl: printmenuitem ( -- n )
164115410Sscottl	menuidx @
165115410Sscottl	1+ dup
166115410Sscottl	menuidx !
167115410Sscottl	menuY @ + dup menuX @ swap at-xy
168115410Sscottl	menuidx @ .
169115410Sscottl	menuX @ 1+ swap at-xy
170115410Sscottl	menubllt @ emit
171115410Sscottl	menuidx @ 48 +
172115410Sscottl;
173115410Sscottl
174115410Sscottl: beastie-menu ( -- )
175115410Sscottl	0 menuidx !
176115410Sscottl	dot menubllt !
177115410Sscottl	8 menuY !
178115410Sscottl	5 menuX !
179115410Sscottl	clear
180151873Sscottl	46 4 print-logo
181115410Sscottl	42 20 2 2 box
182115410Sscottl	13 6 at-xy ." Welcome to FreeBSD!"
183115410Sscottl	printmenuitem ."  Boot FreeBSD [default]" bootkey !
184115410Sscottl	s" arch-i386" environment? if
185138258Sscottl		drop
186115410Sscottl		printmenuitem ."  Boot FreeBSD with ACPI " bootacpikey !
187115410Sscottl		acpienabled? if
188115410Sscottl			." disabled"
189115410Sscottl		else
190115410Sscottl			." enabled"
191115410Sscottl		then
192115410Sscottl	else
193115410Sscottl		-2 bootacpikey !
194115410Sscottl	then
195115410Sscottl	printmenuitem ."  Boot FreeBSD in Safe Mode" bootsafekey !
196115410Sscottl	printmenuitem ."  Boot FreeBSD in single user mode" bootsinglekey !
197115410Sscottl	printmenuitem ."  Boot FreeBSD with verbose logging" bootverbosekey !
198115410Sscottl	printmenuitem ."  Escape to loader prompt" escapekey !
199137071Sbrooks	s" arch-i386" environment? if
200138258Sscottl		drop
201137071Sbrooks		printmenuitem ."  Boot FreeBSD with USB keyboard" bootusbkey !
202137071Sbrooks	else
203138258Sscottl		-2 bootusbkey !
204137071Sbrooks	then
205115410Sscottl	printmenuitem ."  Reboot" rebootkey !
206115410Sscottl	menuX @ 20 at-xy
207115410Sscottl	." Select option, [Enter] for default"
208115410Sscottl	menuX @ 21 at-xy
209115410Sscottl	s" or [Space] to pause timer    " dup 2 - promptwidth !
210115410Sscottl	type
211115410Sscottl;
212115410Sscottl
213115410Sscottl: tkey
214115410Sscottl	seconds +
215115410Sscottl	begin 1 while
216115410Sscottl		over 0<> if
217115410Sscottl			dup seconds u< if
218115410Sscottl				drop
219115410Sscottl				-1
220115410Sscottl				exit
221115410Sscottl			then
222115410Sscottl			menuX @ promptwidth @ + 21 at-xy dup seconds - .
223115410Sscottl		then
224115410Sscottl		key? if
225115410Sscottl			drop
226115410Sscottl			key
227115410Sscottl			exit
228115410Sscottl		then
229115410Sscottl	50 ms
230115410Sscottl	repeat
231115410Sscottl;
232115410Sscottl
233115410Sscottlset-current
234115410Sscottl
235115410Sscottl: beastie-start
236116175Sscottl	s" beastie_disable" getenv
237116175Sscottl	dup -1 <> if
238116175Sscottl		s" YES" compare-insensitive 0= if
239116175Sscottl			exit
240116175Sscottl		then
241138258Sscottl	else
242138258Sscottl		drop
243116175Sscottl	then
244115410Sscottl	beastie-menu
245115410Sscottl	s" autoboot_delay" getenv
246115410Sscottl	dup -1 = if
247115410Sscottl		drop
248115410Sscottl		10
249115410Sscottl	else
250115410Sscottl		0 0 2swap >number drop drop drop
251115410Sscottl	then
252138258Sscottl	begin
253115410Sscottl		dup tkey
254115410Sscottl		0 25 at-xy
255115410Sscottl		dup 32 = if nip 0 swap then
256121618Sscottl		dup -1 = if 0 boot then
257121618Sscottl		dup 13 = if 0 boot then
258121618Sscottl		dup bootkey @ = if 0 boot then
259115410Sscottl		dup bootacpikey @ = if
260115410Sscottl			acpienabled? if
261115410Sscottl				s" acpi_load" unsetenv
262115410Sscottl				s" 1" s" hint.acpi.0.disabled" setenv
263115434Sscottl				s" 1" s" loader.acpi_disabled_by_user" setenv
264115410Sscottl			else
265115410Sscottl				s" YES" s" acpi_load" setenv
266115410Sscottl				s" 0" s" hint.acpi.0.disabled" setenv
267115410Sscottl			then
268121618Sscottl			0 boot
269115410Sscottl		then
270137071Sbrooks		dup bootusbkey @ = if
271137071Sbrooks			s" 0x1" s" hint.atkbd.0.flags" setenv
272137071Sbrooks			0 boot
273137071Sbrooks		then
274115410Sscottl		dup bootsafekey @ = if
275115410Sscottl			s" arch-i386" environment? if
276138258Sscottl				drop
277115410Sscottl				s" acpi_load" unsetenv
278115410Sscottl				s" 1" s" hint.acpi.0.disabled" setenv
279115434Sscottl				s" 1" s" loader.acpi_disabled_by_user" setenv
280124306Sscottl				s" 1" s" hint.apic.0.disabled" setenv
281115410Sscottl			then
282115410Sscottl			s" 0" s" hw.ata.ata_dma" setenv
283115410Sscottl			s" 0" s" hw.ata.atapi_dma" setenv
284115410Sscottl			s" 0" s" hw.ata.wc" setenv
285115410Sscottl			s" 0" s" hw.eisa_slots" setenv
286121618Sscottl			0 boot
287115410Sscottl		then
288115410Sscottl		dup bootverbosekey @ = if
289115410Sscottl			s" YES" s" boot_verbose" setenv
290121618Sscottl			0 boot
291115410Sscottl		then
292115410Sscottl		dup bootsinglekey @ = if
293115410Sscottl			s" YES" s" boot_single" setenv
294121618Sscottl			0 boot
295115410Sscottl		then
296116175Sscottl		dup escapekey @ = if
297116175Sscottl			2drop
298116175Sscottl			s" NO" s" autoboot_delay" setenv
299116175Sscottl			exit
300116175Sscottl		then
301121632Sscottl		rebootkey @ = if 0 reboot then
302138258Sscottl	again
303115410Sscottl;
304115410Sscottl
305115410Sscottlprevious
306