]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/boot/forth/beastie.4th
Update LLDB snapshot to upstream r225923 (git 2b588ecd)
[FreeBSD/FreeBSD.git] / sys / boot / forth / beastie.4th
1 \ Copyright (c) 2003 Scott Long <scottl@freebsd.org>
2 \ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com>
3 \ Copyright (c) 2006-2013 Devin Teske <dteske@FreeBSD.org>
4 \ All rights reserved.
5
6 \ Redistribution and use in source and binary forms, with or without
7 \ modification, are permitted provided that the following conditions
8 \ are met:
9 \ 1. Redistributions of source code must retain the above copyright
10 \    notice, this list of conditions and the following disclaimer.
11 \ 2. Redistributions in binary form must reproduce the above copyright
12 \    notice, this list of conditions and the following disclaimer in the
13 \    documentation and/or other materials provided with the distribution.
14
15 \ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 \ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 \ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 \ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 \ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 \ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 \ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 \ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 \ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 \ SUCH DAMAGE.
26
27 \ $FreeBSD$
28
29 marker task-beastie.4th
30
31 only forth definitions also support-functions
32
33 variable logoX
34 variable logoY
35
36 \ Initialize logo placement to defaults
37 46 logoX !
38 4  logoY !
39
40 : beastie-logo ( x y -- ) \ color BSD mascot (19 rows x 34 columns)
41
42 2dup at-xy ."               \e[31m,        ," 1+
43 2dup at-xy ."              /(        )`" 1+
44 2dup at-xy ."              \ \___   / |" 1+
45 2dup at-xy ."              /- \e[37m_\e[31m  `-/  '" 1+
46 2dup at-xy ."             (\e[37m/\/ \\e[31m \   /\" 1+
47 2dup at-xy ."             \e[37m/ /   |\e[31m `    \" 1+
48 2dup at-xy ."             \e[34mO O   \e[37m) \e[31m/    |" 1+
49 2dup at-xy ."             \e[37m`-^--'\e[31m`<     '" 1+
50 2dup at-xy ."            (_.)  _  )   /" 1+
51 2dup at-xy ."             `.___/`    /" 1+
52 2dup at-xy ."               `-----' /" 1+
53 2dup at-xy ."  \e[33m<----.\e[31m     __ / __   \" 1+
54 2dup at-xy ."  \e[33m<----|====\e[31mO)))\e[33m==\e[31m) \) /\e[33m====|" 1+
55 2dup at-xy ."  \e[33m<----'\e[31m    `--' `.__,' \" 1+
56 2dup at-xy ."               |        |" 1+
57 2dup at-xy ."                \       /       /\" 1+
58 2dup at-xy ."           \e[36m______\e[31m( (_  / \______/" 1+
59 2dup at-xy ."         \e[36m,'  ,-----'   |" 1+
60      at-xy ."         `--{__________)\e[37m"
61
62         \ Put the cursor back at the bottom
63         0 25 at-xy
64 ;
65
66 : beastiebw-logo ( x y -- ) \ B/W BSD mascot (19 rows x 34 columns)
67
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 ."             / /   | `    \" 1+
74         2dup at-xy ."             O O   ) /    |" 1+
75         2dup at-xy ."             `-^--'`<     '" 1+
76         2dup at-xy ."            (_.)  _  )   /" 1+
77         2dup at-xy ."             `.___/`    /" 1+
78         2dup at-xy ."               `-----' /" 1+
79         2dup at-xy ."  <----.     __ / __   \" 1+
80         2dup at-xy ."  <----|====O)))==) \) /====|" 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              at-xy ."         `--{__________)"
87
88         \ Put the cursor back at the bottom
89         0 25 at-xy
90 ;
91
92 : fbsdbw-logo ( x y -- ) \ "FreeBSD" logo in B/W (12 rows x 21 columns)
93
94         \ We used to use the beastie himself as our default... until the
95         \ eventual complaint derided his reign of the advanced boot-menu.
96         \ 
97         \ This is the replacement of beastie to satiate the haters of our
98         \ beloved helper-daemon (ready to track down and spear bugs with
99         \ his trident and sporty sneakers; see above).
100         \ 
101         \ Since we merely just changed the default and not the default-
102         \ location, below is an adjustment to the passed-in coordinates,
103         \ forever influenced by the proper location of beastie himself
104         \ kept as the default loader_logo_x/loader_logo_y values.
105         \ 
106         5 + swap 6 + swap
107
108         2dup at-xy ."  ______" 1+
109         2dup at-xy ." |  ____|" 1+
110         2dup at-xy ." | |__  _ __ ___  ___ " 1+
111         2dup at-xy ." |  __|| '__/ _ \/ _ \" 1+
112         2dup at-xy ." | |   | | |  __/  __/" 1+
113         2dup at-xy ." |_|   |_|  \___|\___|" 1+
114         2dup at-xy ."  ____   _____ _____" 1+
115         2dup at-xy ." |  _ \ / ____|  __ \" 1+
116         2dup at-xy ." | |_) | (___ | |  | |" 1+
117         2dup at-xy ." |  _ < \___ \| |  | |" 1+
118         2dup at-xy ." | |_) |____) | |__| |" 1+
119              at-xy ." |____/|_____/|_____/"
120
121         \ Put the cursor back at the bottom
122         0 25 at-xy
123 ;
124
125 : orb-logo ( x y -- ) \ color Orb mascot (15 rows x 30 columns)
126
127         3 + \ beastie adjustment (see `fbsdbw-logo' comments above)
128
129         2dup at-xy ."  \e[31m```                        \e[31;1m`\e[31m" 1+
130         2dup at-xy ." s` `.....---...\e[31;1m....--.```   -/\e[31m" 1+
131         2dup at-xy ." +o   .--`         \e[31;1m/y:`      +.\e[31m" 1+
132         2dup at-xy ."  yo`:.            \e[31;1m:o      `+-\e[31m" 1+
133         2dup at-xy ."   y/               \e[31;1m-/`   -o/\e[31m" 1+
134         2dup at-xy ."  .-                  \e[31;1m::/sy+:.\e[31m" 1+
135         2dup at-xy ."  /                     \e[31;1m`--  /\e[31m" 1+
136         2dup at-xy ." `:                          \e[31;1m:`\e[31m" 1+
137         2dup at-xy ." `:                          \e[31;1m:`\e[31m" 1+
138         2dup at-xy ."  /                          \e[31;1m/\e[31m" 1+
139         2dup at-xy ."  .-                        \e[31;1m-.\e[31m" 1+
140         2dup at-xy ."   --                      \e[31;1m-.\e[31m" 1+
141         2dup at-xy ."    `:`                  \e[31;1m`:`" 1+
142         2dup at-xy ."      \e[31;1m.--             `--." 1+
143              at-xy ."         .---.....----.\e[37m"
144
145         \ Put the cursor back at the bottom
146         0 25 at-xy
147 ;
148
149 : orbbw-logo ( x y -- ) \ B/W Orb mascot (15 rows x 32 columns)
150
151         3 + \ beastie adjustment (see `fbsdbw-logo' comments above)
152
153         2dup at-xy ."  ```                        `" 1+
154         2dup at-xy ." s` `.....---.......--.```   -/" 1+
155         2dup at-xy ." +o   .--`         /y:`      +." 1+
156         2dup at-xy ."  yo`:.            :o      `+-" 1+
157         2dup at-xy ."   y/               -/`   -o/" 1+
158         2dup at-xy ."  .-                  ::/sy+:." 1+
159         2dup at-xy ."  /                     `--  /" 1+
160         2dup at-xy ." `:                          :`" 1+
161         2dup at-xy ." `:                          :`" 1+
162         2dup at-xy ."  /                          /" 1+
163         2dup at-xy ."  .-                        -." 1+
164         2dup at-xy ."   --                      -." 1+
165         2dup at-xy ."    `:`                  `:`" 1+
166         2dup at-xy ."      .--             `--." 1+
167              at-xy ."         .---.....----."
168
169         \ Put the cursor back at the bottom
170         0 25 at-xy
171 ;
172
173 \ This function draws any number of beastie logos at (loader_logo_x,
174 \ loader_logo_y) if defined, else (46,4) (to the right of the menu). To choose
175 \ your beastie, set the variable `loader_logo' to the respective logo name.
176
177 \ Currently available:
178
179 \       NAME        DESCRIPTION
180 \       beastie     Color ``Helper Daemon'' mascot (19 rows x 34 columns)
181 \       beastiebw   B/W ``Helper Daemon'' mascot (19 rows x 34 columns)
182 \       fbsdbw      "FreeBSD" logo in B/W (13 rows x 21 columns)
183 \       orb         Color ``Orb'' mascot (15 rows x 30 columns) (2nd default)
184 \       orbbw       B/W ``Orb'' mascot (15 rows x 32 columns)
185 \       tribute     Color ``Tribute'' (must fit 19 rows x 34 columns) (default)
186 \       tributebw   B/W ``Tribute'' (must fit 19 rows x 34 columns)
187
188 \ NOTE: Setting `loader_logo' to an undefined value (such as "none") will
189 \       prevent beastie from being drawn.
190
191 : draw-beastie ( -- ) \ at (loader_logo_x,loader_logo_y), else (46,4)
192
193         s" loader_logo_x" getenv dup -1 <> if
194                 ?number 1 = if logoX ! then
195         else
196                 drop
197         then
198         s" loader_logo_y" getenv dup -1 <> if
199                 ?number 1 = if logoY ! then
200         else
201                 drop
202         then
203
204         s" loader_logo" getenv dup -1 <> if
205                 dup 5 + allocate if ENOMEM throw then
206                 0 2swap strcat s" -logo" strcat
207                 over -rot ( a-addr/u -- a-addr a-addr/u )
208                 sfind     ( a-addr a-addr/u -- a-addr xt bool )
209                 rot       ( a-addr xt bool -- xt bool a-addr )
210                 free      ( xt bool a-addr -- xt bool ior )
211                 if EFREE throw then
212         else
213                 0 ( cruft -- cruft bool ) \ load the default below
214         then
215         0= if
216                 drop ( cruft -- )
217                 loader_color? if
218                         ['] orb-logo
219                 else
220                         ['] orbbw-logo
221                 then
222         then
223         logoX @ logoY @ rot execute
224 ;
225
226 : clear-beastie ( -- ) \ clears beastie from the screen
227         logoX @ logoY @
228         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
229         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
230         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
231         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
232         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
233         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
234         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
235         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
236         2dup at-xy 34 spaces 1+         2dup at-xy 34 spaces 1+
237         2dup at-xy 34 spaces            2drop
238
239         \ Put the cursor back at the bottom
240         0 25 at-xy
241 ;
242
243 : beastie-start ( -- ) \ starts the menu
244         s" console" getenv dup -1 <> if
245                 s" efi" 2swap contains? if
246                         s" set beastie_disable=YES" evaluate
247                 then
248         else drop then
249         s" beastie_disable" getenv
250         dup -1 <> if
251                 s" YES" compare-insensitive 0= if
252                         any_conf_read? if
253                                 load_xen_throw
254                                 load_kernel
255                                 load_modules
256                         then
257                         exit \ to autoboot (default)
258                 then
259         else
260                 drop
261         then
262
263         s" loader_delay" getenv
264         -1 = if
265                 s" include /boot/menu.rc" evaluate
266         else
267                 drop
268                 ." Loading Menu (Ctrl-C to Abort)" cr
269                 s" set delay_command='include /boot/menu.rc'" evaluate
270                 s" set delay_showdots" evaluate
271                 delay_execute
272         then
273 ;
274
275 only forth also