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