1 \ Copyright (c) 1999 Daniel C. Sobral <dcs@freebsd.org>
4 \ Redistribution and use in source and binary forms, with or without
5 \ modification, are permitted provided that the following conditions
7 \ 1. Redistributions of source code must retain the above copyright
8 \ notice, this list of conditions and the following disclaimer.
9 \ 2. Redistributions in binary form must reproduce the above copyright
10 \ notice, this list of conditions and the following disclaimer in the
11 \ documentation and/or other materials provided with the distribution.
13 \ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 \ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 \ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 \ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 \ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 \ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 \ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 \ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 \ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 s" arch-i386" environment? [if] [if]
28 s" loader_version" environment? [if]
30 .( Loader version 1.1+ required) cr
34 .( Could not get loader version!) cr
39 256 dictthreshold ! \ 256 cells minimum free space
40 2048 dictincrease ! \ 2048 additional cells each time
42 include /boot/support.4th
43 include /boot/color.4th
44 include /boot/delay.4th
46 only forth also support-functions also builtins definitions
50 ."
\e[37;44mBooting...
\e[0m" cr
57 \ menu-unset may not be present
58 s" beastie_disable" getenv
60 s" YES" compare-insensitive 0= if
81 0= if ( interpreted ) get_arguments then
83 \ Unload only if a path was passed
89 s" kernelname" getenv? if ( a kernel has been loaded )
93 load_kernel_and_modules
99 s" kernelname" getenv? if ( a kernel has been loaded )
103 load_kernel_and_modules
106 bootmsg 0 1 boot exit
108 load_kernel_and_modules
109 ?dup 0= if bootmsg 0 1 boot then
114 \ Prepares to boot as specified by loaded configuration files.
117 0= if ( interpreted ) get_arguments then
119 load_kernel_and_modules
120 ?dup 0= if 0 1 autoboot then
123 also forth definitions also builtins
128 only forth definitions also support-functions
130 include /boot/check-password.4th
134 \ Initializes support.4th global variables, sets loader_conf_files,
135 \ processes conf files, and, if any one such file was succesfully
136 \ read to the end, loads kernel and modules.
138 : start ( -- ) ( throws: abort & user-defined )
139 s" /boot/defaults/loader.conf" initialize
141 include_nextboot_file
142 \ Will *NOT* try to load kernel and modules if no configuration file
143 \ was succesfully loaded!
145 s" loader_delay" getenv -1 = if
151 ." Loading Kernel and Modules (Ctrl-C to Abort)" cr
152 s" also support-functions" evaluate
153 s" set delay_command='load_xen_throw load_kernel load_modules'" evaluate
154 s" set delay_showdots" evaluate
162 \ Overrides support.4th initialization word with one that does
163 \ everything start one does, short of loading the kernel and
164 \ modules. Returns a flag
166 : initialize ( -- flag )
167 s" /boot/defaults/loader.conf" initialize
169 include_nextboot_file
175 \ Read a configuration file, whose name was specified on the command
176 \ line, if interpreted, or given on the stack, if compiled in.
178 : (read-conf) ( addr len -- )
180 include_conf_files \ Will recurse on new loader_conf_files definitions
183 : read-conf ( <filename> | addr len -- ) ( throws: abort & user-defined )
193 \ show, enable, disable, toggle module loading. They all take module from
196 : set-module-flag ( module_addr val -- ) \ set and print flag
198 dup module.name strtype
199 module.flag @ if ." will be loaded" else ." will not be loaded" then cr
202 : enable-module find-module ?dup if true set-module-flag then ;
204 : disable-module find-module ?dup if false set-module-flag then ;
206 : toggle-module find-module ?dup if dup module.flag @ 0= set-module-flag then ;
210 \ Show loading information about a module.
212 : show-module ( <module> -- ) find-module ?dup if show-one-module then ;
214 \ Words to be used inside configuration files
216 : retry false ; \ For use in load error commands
217 : ignore true ; \ For use in load error commands
219 \ Return to strict forth vocabulary
227 : .? 2 spaces 2swap 15 #type 2 spaces type cr ;
231 s" boot-conf" s" load kernel and modules, then autoboot" .?
232 s" read-conf" s" read a configuration file" .?
233 s" enable-module" s" enable loading of a module" .?
234 s" disable-module" s" disable loading of a module" .?
235 s" toggle-module" s" toggle loading of a module" .?
236 s" show-module" s" show module load data" .?
237 s" try-include" s" try to load/interpret files" .?
240 : try-include ( -- ) \ see loader.4th(8)
241 ['] include ( -- xt ) \ get the execution token of `include'
242 catch ( xt -- exception# | 0 ) if \ failed
243 LF parse ( c -- s-addr/u ) 2drop \ advance >in to EOL (drop data)
244 \ ... prevents words unused by `include' from being interpreted
246 ; immediate \ interpret immediately for access to `source' (aka tib)