Merge branch 'vendor/OPENSSL'
[dragonfly.git] / nrelease / gui / boot / beastie.4th
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.7 2003/10/28 17:18:42 scottl Exp $
27 \ $DragonFly: src/nrelease/gui/boot/beastie.4th,v 1.1 2008/09/01 21:20:30 swildner Exp $
28
29 marker task-beastie.4th
30
31 include /boot/screen.4th
32 include /boot/frames.4th
33
34 hide
35
36 variable menuidx
37 variable menubllt
38 variable menuX
39 variable menuY
40 variable promptwidth
41
42 variable bootkey
43 variable bootacpikey
44 variable bootsmpkey
45 variable bootsmpnoapickey
46 variable bootsafekey
47 variable bootverbosekey
48 variable bootsinglekey
49 variable escapekey
50 variable rebootkey
51
52 46 constant dot
53
54 \ Fred, the official DragonFly BSD mascot.
55 \ He is 19 rows high and 34 columns wide
56 : technicolor-fred ( x y -- )
57         2dup at-xy ." " 1+
58         2dup at-xy ." " 1+
59         2dup at-xy ." ,--,           \e[31m|           \e[37m,--," 1+
60         2dup at-xy ." |   `-,       \e[31m,^,       \e[37m,-'   |" 1+
61         2dup at-xy ."  `,    `-,   \e[32m(\e[31m/ \\e[32m)   \e[37m,-'    ,'" 1+
62         2dup at-xy ."    `-,    `-,\e[31m/   \\e[37m,-'    ,-'" 1+
63         2dup at-xy ."       `------\e[31m(   )\e[37m------'" 1+
64         2dup at-xy ."   ,----------\e[31m(   )\e[37m----------," 1+
65         2dup at-xy ."  |        _,-\e[31m(   )\e[37m-,_        |" 1+
66         2dup at-xy ."   `-,__,-'   \e[31m\   /   \e[37m`-,__,-'" 1+
67         2dup at-xy ."               \e[31m| |" 1+
68         2dup at-xy ."               | |" 1+
69         2dup at-xy ."               | |" 1+
70         2dup at-xy ."               | |" 1+
71         2dup at-xy ."               | |" 1+
72         2dup at-xy ."               | |" 1+
73         2dup at-xy ."               `|'\e[0m" 1+
74         2dup at-xy ." " 1+
75              at-xy ."
76 ;
77
78 : boring-fred ( x y -- )
79         2dup at-xy ." " 1+
80         2dup at-xy ." " 1+
81         2dup at-xy ." ,--,           |           ,--," 1+
82         2dup at-xy ." |   `-,       ,^,       ,-'   |" 1+
83         2dup at-xy ."  `,    `-,   (/ \)   ,-'    ,'" 1+
84         2dup at-xy ."    `-,    `-,/   \,-'    ,-'" 1+
85         2dup at-xy ."       `------(   )------'" 1+
86         2dup at-xy ."   ,----------(   )----------," 1+
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 ."               | |" 1+
94         2dup at-xy ."               | |" 1+
95         2dup at-xy ."               `|'" 1+
96         2dup at-xy ." " 1+
97              at-xy ."
98 ;
99
100 : print-fred ( x y -- )
101         s" loader_color" getenv
102         dup -1 = if
103                 drop
104                 boring-fred
105                 exit
106         then
107         s" YES" compare-insensitive 0<> if
108                 boring-fred
109                 exit
110         then
111         technicolor-fred
112 ;
113
114 : acpienabled? ( -- flag )
115         s" acpi_load" getenv
116         dup -1 = if
117                 drop false exit
118         then
119         s" YES" compare-insensitive 0<> if
120                 false exit
121         then
122         s" hint.acpi.0.disabled" getenv
123         dup -1 <> if
124                 s" 0" compare 0<> if
125                         false exit
126                 then
127         then
128         true
129 ;
130
131 : printmenuitem ( -- n )
132         menuidx @
133         1+ dup
134         menuidx !
135         menuY @ + dup menuX @ swap at-xy
136         menuidx @ .
137         menuX @ 1+ swap at-xy
138         menubllt @ emit
139         menuidx @ 48 +
140 ;
141
142 : fred-menu ( -- )
143         0 menuidx !
144         dot menubllt !
145         8 menuY !
146         5 menuX !
147         clear
148         46 4 print-fred
149         42 20 2 2 box
150         13 6 at-xy ." Welcome to DragonFly!"
151         printmenuitem ."  Boot DragonFly [default]" bootkey !
152         s" arch-i386" environment? if
153                 printmenuitem ."  Boot DragonFly with ACPI " bootacpikey !
154                 acpienabled? if
155                         ." disabled"
156                 else
157                         ." enabled"
158                 then
159         else
160                 -2 bootacpikey !
161         then
162         printmenuitem ."  Boot DragonFly in SMP mode" bootsmpkey !
163         printmenuitem ."  Boot DragonFly in SMP-NOAPIC mode" bootsmpnoapickey !
164         printmenuitem ."  Boot DragonFly in Safe Mode" bootsafekey !
165         printmenuitem ."  Boot DragonFly in single user mode" bootsinglekey !
166         printmenuitem ."  Boot DragonFly with verbose logging" bootverbosekey !
167         printmenuitem ."  Escape to loader prompt" escapekey !
168         printmenuitem ."  Reboot" rebootkey !
169         menuX @ 20 at-xy
170         ." Select option, [Enter] for default"
171         menuX @ 21 at-xy
172         s" or [Space] to pause timer    " dup 2 - promptwidth !
173         type
174 ;
175
176 : tkey
177         dup
178         seconds +
179         begin 1 while
180                 over 0<> if
181                         dup seconds u< if
182                                 drop
183                                 -1
184                                 exit
185                         then
186                         menuX @ promptwidth @ + 21 at-xy dup seconds - .
187                 then
188                 key? if
189                         drop
190                         key
191                         exit
192                 then
193         50 ms
194         repeat
195 ;
196
197 set-current
198
199 : beastie-start
200         s" fred_disable" getenv
201         dup -1 <> if
202                 s" YES" compare-insensitive 0= if
203                         exit
204                 then
205         then
206         fred-menu
207         s" autoboot_delay" getenv
208         dup -1 = if
209                 drop
210                 10
211         else
212                 0 0 2swap >number drop drop drop
213         then
214         begin true while
215                 dup tkey
216                 0 25 at-xy
217                 dup 32 = if nip 0 swap then
218                 dup -1 = if 0 boot then
219                 dup 13 = if 0 boot then
220                 dup bootkey @ = if 0 boot then
221                 dup bootacpikey @ = if
222                         acpienabled? if
223                                 s" acpi_load" unsetenv
224                                 s" 1" s" hint.acpi.0.disabled" setenv
225                                 s" 1" s" loader.acpi_disabled_by_user" setenv
226                         else
227                                 s" YES" s" acpi_load" setenv
228                                 s" 0" s" hint.acpi.0.disabled" setenv
229                         then
230                         0 boot
231                 then
232                 dup bootsmpkey @ = if
233                         s" /kernel.smp/modules" s" module_path" setenv
234                         s" YES" s" boot_verbose" setenv
235                         s" /kernel.smp/kernel" 1 boot
236                 then
237                 dup bootsmpnoapickey @ = if
238                         s" /kernel.smp/modules" s" module_path" setenv
239                         s" YES" s" boot_verbose" setenv
240                         s" /kernel.smp/kernel.noapic" 1 boot
241                 then
242                 dup bootsafekey @ = if
243                         s" arch-i386" environment? if
244                                 s" acpi_load" unsetenv
245                                 s" 1" s" hint.acpi.0.disabled" setenv
246                                 s" 1" s" loader.acpi_disabled_by_user" setenv
247                         then
248                         s" 0" s" hw.ata.ata_dma" setenv
249                         s" 0" s" hw.ata.atapi_dma" setenv
250                         s" 0" s" hw.ata.wc" setenv
251                         s" 0" s" hw.eisa_slots" setenv
252                         0 boot
253                 then
254                 dup bootverbosekey @ = if
255                         s" YES" s" boot_verbose" setenv
256                         0 boot
257                 then
258                 dup bootsinglekey @ = if
259                         s" YES" s" boot_single" setenv
260                         0 boot
261                 then
262                 dup escapekey @ = if
263                         2drop
264                         s" NO" s" autoboot_delay" setenv
265                         exit
266                 then
267                 rebootkey @ = if 0 reboot then
268         repeat
269 ;
270
271 previous