beastie.4th revision 212338
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 212338 2010-09-08 20:10:29Z jhb $
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
43115410Sscottlvariable bootsafekey
44115410Sscottlvariable bootverbosekey
45115410Sscottlvariable bootsinglekey
46115410Sscottlvariable escapekey
47115410Sscottlvariable rebootkey
48115410Sscottl
49115410Sscottl46 constant dot
50115410Sscottl
51115410Sscottl\ The BSD Daemon.  He is 19 rows high and 34 columns wide
52151873Sscottl: beastie-logo ( x y -- )
53120031Sscottl2dup at-xy ."               [1;31m,        ," 1+
54120031Sscottl2dup at-xy ."              /(        )`" 1+
55120031Sscottl2dup at-xy ."              \ \___   / |" 1+
56120031Sscottl2dup at-xy ."              /- [37m_[31m  `-/  '" 1+
57120031Sscottl2dup at-xy ."             ([37m/\/ \[31m \   /\" 1+
58120031Sscottl2dup at-xy ."             [37m/ /   |[31m `    \" 1+
59120031Sscottl2dup at-xy ."             [34mO O   [37m) [31m/    |" 1+
60120031Sscottl2dup at-xy ."             [37m`-^--'[31m`<     '" 1+
61120031Sscottl2dup at-xy ."            (_.)  _  )   /" 1+
62120031Sscottl2dup at-xy ."             `.___/`    /       " 1+
63120031Sscottl2dup at-xy ."               `-----' /" 1+
64120031Sscottl2dup at-xy ."  [33m<----.[31m     __ / __   \" 1+
65120031Sscottl2dup at-xy ."  [33m<----|====[31mO)))[33m==[31m) \) /[33m====|" 1+
66120031Sscottl2dup at-xy ."  [33m<----'[31m    `--' `.__,' \" 1+
67120031Sscottl2dup at-xy ."               |        |" 1+
68120031Sscottl2dup at-xy ."                \       /       /\" 1+
69120031Sscottl2dup at-xy ."           [36m______[31m( (_  / \______/" 1+
70120031Sscottl2dup at-xy ."         [36m,'  ,-----'   |" 1+
71138258Sscottlat-xy ."         `--{__________) [0m"
72120031Sscottl;
73120031Sscottl
74151873Sscottl: beastiebw-logo ( x y -- )
75115410Sscottl	2dup at-xy ."              ,        ," 1+
76115410Sscottl	2dup at-xy ."             /(        )`" 1+
77115451Sscottl	2dup at-xy ."             \ \___   / |" 1+
78115410Sscottl	2dup at-xy ."             /- _  `-/  '" 1+
79115451Sscottl	2dup at-xy ."            (/\/ \ \   /\" 1+
80115451Sscottl	2dup at-xy ."            / /   | `    \" 1+
81115410Sscottl	2dup at-xy ."            O O   ) /    |" 1+
82115410Sscottl	2dup at-xy ."            `-^--'`<     '" 1+
83115410Sscottl	2dup at-xy ."           (_.)  _  )   /" 1+
84115410Sscottl	2dup at-xy ."            `.___/`    /" 1+
85115410Sscottl	2dup at-xy ."              `-----' /" 1+
86115451Sscottl	2dup at-xy ." <----.     __ / __   \" 1+
87115451Sscottl	2dup at-xy ." <----|====O)))==) \) /====" 1+
88115451Sscottl	2dup at-xy ." <----'    `--' `.__,' \" 1+
89115410Sscottl	2dup at-xy ."              |        |" 1+
90115451Sscottl	2dup at-xy ."               \       /       /\" 1+
91115451Sscottl	2dup at-xy ."          ______( (_  / \______/" 1+
92115410Sscottl	2dup at-xy ."        ,'  ,-----'   |" 1+
93115410Sscottl	     at-xy ."        `--{__________)"
94115410Sscottl;
95115410Sscottl
96151873Sscottl: fbsdbw-logo ( x y -- )
97151873Sscottl	2dup at-xy ."      ______" 1+
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	     at-xy ."     |____/|_____/|_____/"
110151873Sscottl;
111151873Sscottl
112151873Sscottl: print-logo ( x y -- )
113151873Sscottl	s" loader_logo" getenv
114120031Sscottl	dup -1 = if
115120031Sscottl		drop
116151873Sscottl		fbsdbw-logo
117120031Sscottl		exit
118120031Sscottl	then
119151873Sscottl	2dup s" fbsdbw" compare-insensitive 0= if
120151873Sscottl		2drop
121151873Sscottl		fbsdbw-logo
122120031Sscottl		exit
123120031Sscottl	then
124151873Sscottl	2dup s" beastiebw" compare-insensitive 0= if
125151873Sscottl		2drop
126151873Sscottl		beastiebw-logo
127151873Sscottl		exit
128151873Sscottl	then
129151873Sscottl	2dup s" beastie" compare-insensitive 0= if
130151873Sscottl		2drop
131151873Sscottl		beastie-logo
132151873Sscottl		exit
133151873Sscottl	then
134151873Sscottl	2dup s" none" compare-insensitive 0= if
135151873Sscottl		2drop
136151873Sscottl		\ no logo
137151873Sscottl		exit
138151873Sscottl	then
139151873Sscottl	2drop
140151873Sscottl	fbsdbw-logo
141120031Sscottl;
142120031Sscottl
143115410Sscottl: acpienabled? ( -- flag )
144115410Sscottl	s" acpi_load" getenv
145115410Sscottl	dup -1 = if
146115410Sscottl		drop false exit
147115410Sscottl	then
148115410Sscottl	s" YES" compare-insensitive 0<> if
149115410Sscottl		false exit
150115410Sscottl	then
151115410Sscottl	s" hint.acpi.0.disabled" getenv
152115410Sscottl	dup -1 <> if
153115410Sscottl		s" 0" compare 0<> if
154115410Sscottl			false exit
155115410Sscottl		then
156138258Sscottl	else
157138258Sscottl		drop
158115410Sscottl	then
159115410Sscottl	true
160115410Sscottl;
161115410Sscottl
162115410Sscottl: printmenuitem ( -- n )
163115410Sscottl	menuidx @
164115410Sscottl	1+ dup
165115410Sscottl	menuidx !
166115410Sscottl	menuY @ + dup menuX @ swap at-xy
167115410Sscottl	menuidx @ .
168115410Sscottl	menuX @ 1+ swap at-xy
169115410Sscottl	menubllt @ emit
170115410Sscottl	menuidx @ 48 +
171115410Sscottl;
172115410Sscottl
173115410Sscottl: beastie-menu ( -- )
174115410Sscottl	0 menuidx !
175115410Sscottl	dot menubllt !
176115410Sscottl	8 menuY !
177115410Sscottl	5 menuX !
178115410Sscottl	clear
179151873Sscottl	46 4 print-logo
180115410Sscottl	42 20 2 2 box
181115410Sscottl	13 6 at-xy ." Welcome to FreeBSD!"
182115410Sscottl	printmenuitem ."  Boot FreeBSD [default]" bootkey !
183115410Sscottl	s" arch-i386" environment? if
184138258Sscottl		drop
185115410Sscottl		printmenuitem ."  Boot FreeBSD with ACPI " bootacpikey !
186115410Sscottl		acpienabled? if
187115410Sscottl			." disabled"
188115410Sscottl		else
189115410Sscottl			." enabled"
190115410Sscottl		then
191115410Sscottl	else
192115410Sscottl		-2 bootacpikey !
193115410Sscottl	then
194115410Sscottl	printmenuitem ."  Boot FreeBSD in Safe Mode" bootsafekey !
195115410Sscottl	printmenuitem ."  Boot FreeBSD in single user mode" bootsinglekey !
196115410Sscottl	printmenuitem ."  Boot FreeBSD with verbose logging" bootverbosekey !
197115410Sscottl	printmenuitem ."  Escape to loader prompt" escapekey !
198115410Sscottl	printmenuitem ."  Reboot" rebootkey !
199115410Sscottl	menuX @ 20 at-xy
200115410Sscottl	." Select option, [Enter] for default"
201115410Sscottl	menuX @ 21 at-xy
202115410Sscottl	s" or [Space] to pause timer    " dup 2 - promptwidth !
203115410Sscottl	type
204115410Sscottl;
205115410Sscottl
206115410Sscottl: tkey
207115410Sscottl	seconds +
208115410Sscottl	begin 1 while
209115410Sscottl		over 0<> if
210115410Sscottl			dup seconds u< if
211115410Sscottl				drop
212115410Sscottl				-1
213115410Sscottl				exit
214115410Sscottl			then
215115410Sscottl			menuX @ promptwidth @ + 21 at-xy dup seconds - .
216115410Sscottl		then
217115410Sscottl		key? if
218115410Sscottl			drop
219115410Sscottl			key
220115410Sscottl			exit
221115410Sscottl		then
222115410Sscottl	50 ms
223115410Sscottl	repeat
224115410Sscottl;
225115410Sscottl
226115410Sscottlset-current
227115410Sscottl
228115410Sscottl: beastie-start
229116175Sscottl	s" beastie_disable" getenv
230116175Sscottl	dup -1 <> if
231116175Sscottl		s" YES" compare-insensitive 0= if
232116175Sscottl			exit
233116175Sscottl		then
234138258Sscottl	else
235138258Sscottl		drop
236116175Sscottl	then
237115410Sscottl	beastie-menu
238115410Sscottl	s" autoboot_delay" getenv
239115410Sscottl	dup -1 = if
240115410Sscottl		drop
241115410Sscottl		10
242115410Sscottl	else
243212338Sjhb		2dup s" -1" compare 0= if
244212338Sjhb			0 boot
245212338Sjhb		then
246212338Sjhb		0 s>d 2swap >number 2drop drop
247115410Sscottl	then
248138258Sscottl	begin
249115410Sscottl		dup tkey
250115410Sscottl		0 25 at-xy
251115410Sscottl		dup 32 = if nip 0 swap then
252121618Sscottl		dup -1 = if 0 boot then
253121618Sscottl		dup 13 = if 0 boot then
254121618Sscottl		dup bootkey @ = if 0 boot then
255115410Sscottl		dup bootacpikey @ = if
256115410Sscottl			acpienabled? if
257115410Sscottl				s" acpi_load" unsetenv
258115410Sscottl				s" 1" s" hint.acpi.0.disabled" setenv
259115434Sscottl				s" 1" s" loader.acpi_disabled_by_user" setenv
260115410Sscottl			else
261115410Sscottl				s" YES" s" acpi_load" setenv
262115410Sscottl				s" 0" s" hint.acpi.0.disabled" setenv
263115410Sscottl			then
264121618Sscottl			0 boot
265115410Sscottl		then
266115410Sscottl		dup bootsafekey @ = if
267115410Sscottl			s" arch-i386" environment? if
268138258Sscottl				drop
269115410Sscottl				s" acpi_load" unsetenv
270115410Sscottl				s" 1" s" hint.acpi.0.disabled" setenv
271115434Sscottl				s" 1" s" loader.acpi_disabled_by_user" setenv
272124306Sscottl				s" 1" s" hint.apic.0.disabled" setenv
273115410Sscottl			then
274115410Sscottl			s" 0" s" hw.ata.ata_dma" setenv
275115410Sscottl			s" 0" s" hw.ata.atapi_dma" setenv
276115410Sscottl			s" 0" s" hw.ata.wc" setenv
277115410Sscottl			s" 0" s" hw.eisa_slots" setenv
278157339Sscottl			s" 1" s" hint.kbdmux.0.disabled" setenv
279121618Sscottl			0 boot
280115410Sscottl		then
281115410Sscottl		dup bootverbosekey @ = if
282115410Sscottl			s" YES" s" boot_verbose" setenv
283121618Sscottl			0 boot
284115410Sscottl		then
285115410Sscottl		dup bootsinglekey @ = if
286115410Sscottl			s" YES" s" boot_single" setenv
287121618Sscottl			0 boot
288115410Sscottl		then
289116175Sscottl		dup escapekey @ = if
290116175Sscottl			2drop
291116175Sscottl			s" NO" s" autoboot_delay" setenv
292116175Sscottl			exit
293116175Sscottl		then
294121632Sscottl		rebootkey @ = if 0 reboot then
295138258Sscottl	again
296115410Sscottl;
297115410Sscottl
298115410Sscottlprevious
299