beastie.4th revision 121632
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 121632 2003-10-28 17:18:42Z 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
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
52120031Sscottl: technicolor-beastie ( 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+
71120031Sscottlat-xy ."         `--{__________) [0m" 1+
72120031Sscottl;
73120031Sscottl
74120031Sscottl: boring-beastie ( 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
96120031Sscottl: print-beastie ( x y -- )
97120031Sscottl	s" loader_color" getenv
98120031Sscottl	dup -1 = if
99120031Sscottl		drop
100120031Sscottl		boring-beastie
101120031Sscottl		exit
102120031Sscottl	then
103120031Sscottl	s" YES" compare-insensitive 0<> if
104120031Sscottl		boring-beastie
105120031Sscottl		exit
106120031Sscottl	then
107120031Sscottl	technicolor-beastie
108120031Sscottl;
109120031Sscottl
110115410Sscottl: acpienabled? ( -- flag )
111115410Sscottl	s" acpi_load" getenv
112115410Sscottl	dup -1 = if
113115410Sscottl		drop false exit
114115410Sscottl	then
115115410Sscottl	s" YES" compare-insensitive 0<> if
116115410Sscottl		false exit
117115410Sscottl	then
118115410Sscottl	s" hint.acpi.0.disabled" getenv
119115410Sscottl	dup -1 <> if
120115410Sscottl		s" 0" compare 0<> if
121115410Sscottl			false exit
122115410Sscottl		then
123115410Sscottl	then
124115410Sscottl	true
125115410Sscottl;
126115410Sscottl
127115410Sscottl: printmenuitem ( -- n )
128115410Sscottl	menuidx @
129115410Sscottl	1+ dup
130115410Sscottl	menuidx !
131115410Sscottl	menuY @ + dup menuX @ swap at-xy
132115410Sscottl	menuidx @ .
133115410Sscottl	menuX @ 1+ swap at-xy
134115410Sscottl	menubllt @ emit
135115410Sscottl	menuidx @ 48 +
136115410Sscottl;
137115410Sscottl
138115410Sscottl: beastie-menu ( -- )
139115410Sscottl	0 menuidx !
140115410Sscottl	dot menubllt !
141115410Sscottl	8 menuY !
142115410Sscottl	5 menuX !
143115410Sscottl	clear
144115410Sscottl	46 4 print-beastie
145115410Sscottl	42 20 2 2 box
146115410Sscottl	13 6 at-xy ." Welcome to FreeBSD!"
147115410Sscottl	printmenuitem ."  Boot FreeBSD [default]" bootkey !
148115410Sscottl	s" arch-i386" environment? if
149115410Sscottl		printmenuitem ."  Boot FreeBSD with ACPI " bootacpikey !
150115410Sscottl		acpienabled? if
151115410Sscottl			." disabled"
152115410Sscottl		else
153115410Sscottl			." enabled"
154115410Sscottl		then
155115410Sscottl	else
156115410Sscottl		-2 bootacpikey !
157115410Sscottl	then
158115410Sscottl	printmenuitem ."  Boot FreeBSD in Safe Mode" bootsafekey !
159115410Sscottl	printmenuitem ."  Boot FreeBSD in single user mode" bootsinglekey !
160115410Sscottl	printmenuitem ."  Boot FreeBSD with verbose logging" bootverbosekey !
161115410Sscottl	printmenuitem ."  Escape to loader prompt" escapekey !
162115410Sscottl	printmenuitem ."  Reboot" rebootkey !
163115410Sscottl	menuX @ 20 at-xy
164115410Sscottl	." Select option, [Enter] for default"
165115410Sscottl	menuX @ 21 at-xy
166115410Sscottl	s" or [Space] to pause timer    " dup 2 - promptwidth !
167115410Sscottl	type
168115410Sscottl;
169115410Sscottl
170115410Sscottl: tkey
171115410Sscottl	dup
172115410Sscottl	seconds +
173115410Sscottl	begin 1 while
174115410Sscottl		over 0<> if
175115410Sscottl			dup seconds u< if
176115410Sscottl				drop
177115410Sscottl				-1
178115410Sscottl				exit
179115410Sscottl			then
180115410Sscottl			menuX @ promptwidth @ + 21 at-xy dup seconds - .
181115410Sscottl		then
182115410Sscottl		key? if
183115410Sscottl			drop
184115410Sscottl			key
185115410Sscottl			exit
186115410Sscottl		then
187115410Sscottl	50 ms
188115410Sscottl	repeat
189115410Sscottl;
190115410Sscottl
191115410Sscottlset-current
192115410Sscottl
193115410Sscottl: beastie-start
194116175Sscottl	s" beastie_disable" getenv
195116175Sscottl	dup -1 <> if
196116175Sscottl		s" YES" compare-insensitive 0= if
197116175Sscottl			exit
198116175Sscottl		then
199116175Sscottl	then
200115410Sscottl	beastie-menu
201115410Sscottl	s" autoboot_delay" getenv
202115410Sscottl	dup -1 = if
203115410Sscottl		drop
204115410Sscottl		10
205115410Sscottl	else
206115410Sscottl		0 0 2swap >number drop drop drop
207115410Sscottl	then
208115410Sscottl	begin true while
209115410Sscottl		dup tkey
210115410Sscottl		0 25 at-xy
211115410Sscottl		dup 32 = if nip 0 swap then
212121618Sscottl		dup -1 = if 0 boot then
213121618Sscottl		dup 13 = if 0 boot then
214121618Sscottl		dup bootkey @ = if 0 boot then
215115410Sscottl		dup bootacpikey @ = if
216115410Sscottl			acpienabled? if
217115410Sscottl				s" acpi_load" unsetenv
218115410Sscottl				s" 1" s" hint.acpi.0.disabled" setenv
219115434Sscottl				s" 1" s" loader.acpi_disabled_by_user" setenv
220115410Sscottl			else
221115410Sscottl				s" YES" s" acpi_load" setenv
222115410Sscottl				s" 0" s" hint.acpi.0.disabled" setenv
223115410Sscottl			then
224121618Sscottl			0 boot
225115410Sscottl		then
226115410Sscottl		dup bootsafekey @ = if
227115410Sscottl			s" arch-i386" environment? if
228115410Sscottl				s" acpi_load" unsetenv
229115410Sscottl				s" 1" s" hint.acpi.0.disabled" setenv
230115434Sscottl				s" 1" s" loader.acpi_disabled_by_user" setenv
231115410Sscottl			then
232115410Sscottl			s" 0" s" hw.ata.ata_dma" setenv
233115410Sscottl			s" 0" s" hw.ata.atapi_dma" setenv
234115410Sscottl			s" 0" s" hw.ata.wc" setenv
235115410Sscottl			s" 0" s" hw.eisa_slots" setenv
236121618Sscottl			0 boot
237115410Sscottl		then
238115410Sscottl		dup bootverbosekey @ = if
239115410Sscottl			s" YES" s" boot_verbose" setenv
240121618Sscottl			0 boot
241115410Sscottl		then
242115410Sscottl		dup bootsinglekey @ = if
243115410Sscottl			s" YES" s" boot_single" setenv
244121618Sscottl			0 boot
245115410Sscottl		then
246116175Sscottl		dup escapekey @ = if
247116175Sscottl			2drop
248116175Sscottl			s" NO" s" autoboot_delay" setenv
249116175Sscottl			exit
250116175Sscottl		then
251121632Sscottl		rebootkey @ = if 0 reboot then
252115410Sscottl	repeat
253115410Sscottl;
254115410Sscottl
255115410Sscottlprevious
256