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 bootemergencykey |
---|
46 | variable bootsinglekey |
---|
47 | variable escapekey |
---|
48 | variable rebootkey |
---|
49 | variable xvesa |
---|
50 | variable xvesa_set |
---|
51 | |
---|
52 | 46 constant dot |
---|
53 | |
---|
54 | : pcbsd-logo ( x y -- ) |
---|
55 | 2dup at-xy ." ____ ______" 1+ |
---|
56 | 2dup at-xy ." / __ \/ ____/" 1+ |
---|
57 | 2dup at-xy ." / /_/ / /" 1+ |
---|
58 | 2dup at-xy ." / ____/ /___" 1+ |
---|
59 | 2dup at-xy ." /_/ \____/" 1+ |
---|
60 | 2dup at-xy ." ____ _____ ____" 1+ |
---|
61 | 2dup at-xy ." / __ ) ___// __ \" 1+ |
---|
62 | 2dup at-xy ." / __ \__ \/ / / /" 1+ |
---|
63 | 2dup at-xy ." / /_/ /__/ / /_/ /" 1+ |
---|
64 | at-xy ." /_____/____/_____/" |
---|
65 | ; |
---|
66 | |
---|
67 | : print-logo ( x y -- ) |
---|
68 | s" loader_logo" getenv |
---|
69 | dup -1 = if |
---|
70 | drop |
---|
71 | pcbsd-logo |
---|
72 | exit |
---|
73 | then |
---|
74 | 2dup s" fbsdbw" compare-insensitive 0= if |
---|
75 | 2drop |
---|
76 | pcbsd-logo |
---|
77 | exit |
---|
78 | then |
---|
79 | 2dup s" beastiebw" compare-insensitive 0= if |
---|
80 | 2drop |
---|
81 | exit |
---|
82 | then |
---|
83 | 2dup s" beastie" compare-insensitive 0= if |
---|
84 | 2drop |
---|
85 | exit |
---|
86 | then |
---|
87 | 2dup s" none" compare-insensitive 0= if |
---|
88 | 2drop |
---|
89 | \ no logo |
---|
90 | exit |
---|
91 | then |
---|
92 | 2dup s" pcbsd" compare-insensitive 0= if |
---|
93 | 2drop |
---|
94 | pcbsd-logo |
---|
95 | exit |
---|
96 | then |
---|
97 | 2drop |
---|
98 | pcbsd-logo |
---|
99 | ; |
---|
100 | |
---|
101 | : acpienabled? ( -- flag ) |
---|
102 | s" acpi_load" getenv |
---|
103 | dup -1 = if |
---|
104 | drop false exit |
---|
105 | then |
---|
106 | s" YES" compare-insensitive 0<> if |
---|
107 | false exit |
---|
108 | then |
---|
109 | s" hint.acpi.0.disabled" getenv |
---|
110 | dup -1 <> if |
---|
111 | s" 0" compare 0<> if |
---|
112 | false exit |
---|
113 | then |
---|
114 | else |
---|
115 | drop |
---|
116 | then |
---|
117 | true |
---|
118 | ; |
---|
119 | |
---|
120 | : printmenuitem ( -- n ) |
---|
121 | menuidx @ |
---|
122 | 1+ dup |
---|
123 | menuidx ! |
---|
124 | menuY @ + dup menuX @ swap at-xy |
---|
125 | menuidx @ . |
---|
126 | menuX @ 1+ swap at-xy |
---|
127 | menubllt @ emit |
---|
128 | menuidx @ 48 + |
---|
129 | ; |
---|
130 | |
---|
131 | : beastie-menu ( -- ) |
---|
132 | 0 menuidx ! |
---|
133 | dot menubllt ! |
---|
134 | 8 menuY ! |
---|
135 | 5 menuX ! |
---|
136 | clear |
---|
137 | 46 4 print-logo |
---|
138 | 42 20 2 2 box |
---|
139 | 13 6 at-xy ." Welcome to PC-BSD!" |
---|
140 | printmenuitem ." Boot [default]" bootkey ! |
---|
141 | s" arch-i386" environment? if |
---|
142 | drop |
---|
143 | printmenuitem ." Boot with ACPI " bootacpikey ! |
---|
144 | acpienabled? if |
---|
145 | ." disabled" |
---|
146 | else |
---|
147 | ." enabled" |
---|
148 | then |
---|
149 | else |
---|
150 | -2 bootacpikey ! |
---|
151 | then |
---|
152 | printmenuitem ." Boot in Safe Mode" bootsafekey ! |
---|
153 | printmenuitem ." Boot with verbose logging" bootverbosekey ! |
---|
154 | printmenuitem ." Boot to emergency console" bootemergencykey ! |
---|
155 | printmenuitem ." Boot with X in VESA mode" xvesa ! |
---|
156 | printmenuitem ." Escape to loader prompt" escapekey ! |
---|
157 | menuX @ 20 at-xy |
---|
158 | ." Select option, [Enter] for default" |
---|
159 | menuX @ 21 at-xy |
---|
160 | s" or [Space] to pause timer " dup 2 - promptwidth ! |
---|
161 | type |
---|
162 | ; |
---|
163 | |
---|
164 | : tkey |
---|
165 | seconds + |
---|
166 | begin 1 while |
---|
167 | over 0<> if |
---|
168 | dup seconds u< if |
---|
169 | drop |
---|
170 | -1 |
---|
171 | exit |
---|
172 | then |
---|
173 | menuX @ promptwidth @ + 21 at-xy dup seconds - . |
---|
174 | then |
---|
175 | key? if |
---|
176 | drop |
---|
177 | key |
---|
178 | exit |
---|
179 | then |
---|
180 | 50 ms |
---|
181 | repeat |
---|
182 | ; |
---|
183 | |
---|
184 | set-current |
---|
185 | |
---|
186 | : beastie-start |
---|
187 | s" beastie_disable" getenv |
---|
188 | dup -1 <> if |
---|
189 | s" YES" compare-insensitive 0= if |
---|
190 | exit |
---|
191 | then |
---|
192 | else |
---|
193 | drop |
---|
194 | then |
---|
195 | s" NO" s" xvesa" setenv |
---|
196 | 0 xvesa_set ! |
---|
197 | beastie-menu |
---|
198 | s" autoboot_delay" getenv |
---|
199 | dup -1 = if |
---|
200 | drop |
---|
201 | 10 |
---|
202 | else |
---|
203 | 0 0 2swap >number drop drop drop |
---|
204 | then |
---|
205 | begin |
---|
206 | dup tkey |
---|
207 | 0 25 at-xy |
---|
208 | dup 32 = if nip 0 swap then |
---|
209 | dup -1 = if 0 boot then |
---|
210 | dup 13 = if 0 boot then |
---|
211 | dup bootkey @ = if 0 boot then |
---|
212 | dup bootacpikey @ = if |
---|
213 | acpienabled? if |
---|
214 | s" acpi_load" unsetenv |
---|
215 | s" 1" s" hint.acpi.0.disabled" setenv |
---|
216 | s" 1" s" loader.acpi_disabled_by_user" setenv |
---|
217 | else |
---|
218 | s" YES" s" acpi_load" setenv |
---|
219 | s" 0" s" hint.acpi.0.disabled" setenv |
---|
220 | then |
---|
221 | 0 boot |
---|
222 | then |
---|
223 | dup bootsafekey @ = if |
---|
224 | s" arch-i386" environment? if |
---|
225 | drop |
---|
226 | s" acpi_load" unsetenv |
---|
227 | s" 1" s" hint.acpi.0.disabled" setenv |
---|
228 | s" 1" s" loader.acpi_disabled_by_user" setenv |
---|
229 | s" 1" s" hint.apic.0.disabled" setenv |
---|
230 | then |
---|
231 | s" 0" s" hw.ata.ata_dma" setenv |
---|
232 | s" 0" s" hw.ata.atapi_dma" setenv |
---|
233 | s" 0" s" hw.ata.wc" setenv |
---|
234 | s" 0" s" hw.eisa_slots" setenv |
---|
235 | s" 1" s" hint.kbdmux.0.disabled" setenv |
---|
236 | 0 boot |
---|
237 | then |
---|
238 | dup bootverbosekey @ = if |
---|
239 | s" YES" s" boot_verbose" setenv |
---|
240 | 0 boot |
---|
241 | then |
---|
242 | dup bootemergencykey @ = if |
---|
243 | s" /boot/kernel;/boot/modules;/CONSOLE/" s" module_path" setenv |
---|
244 | 0 boot |
---|
245 | then |
---|
246 | dup xvesa @ = if |
---|
247 | xvesa_set @ 1 = if |
---|
248 | menuX @ 23 at-xy |
---|
249 | ." xvesa unset" |
---|
250 | s" NO" s" xvesa" setenv |
---|
251 | 0 xvesa_set ! |
---|
252 | else |
---|
253 | menuX @ 23 at-xy |
---|
254 | ." xvesa set " |
---|
255 | s" YES" s" xvesa" setenv |
---|
256 | 1 xvesa_set ! |
---|
257 | then |
---|
258 | then |
---|
259 | dup bootsinglekey @ = if |
---|
260 | s" YES" s" boot_single" setenv |
---|
261 | 0 boot |
---|
262 | then |
---|
263 | dup escapekey @ = if |
---|
264 | 2drop |
---|
265 | s" NO" s" autoboot_delay" setenv |
---|
266 | exit |
---|
267 | then |
---|
268 | rebootkey @ = if 0 reboot then |
---|
269 | again |
---|
270 | ; |
---|
271 | |
---|
272 | previous |
---|