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
46 \ Prepares to boot as specified by loaded configuration files.
48 only forth also support-functions also builtins definitions
51 0= if ( interpreted ) get_arguments then
53 \ Unload only if a path was passed
59 s" kernelname" getenv? if ( a kernel has been loaded )
62 load_kernel_and_modules
67 s" kernelname" getenv? if ( a kernel has been loaded )
70 load_kernel_and_modules
74 load_kernel_and_modules
75 ?dup 0= if 0 1 boot then
79 0= if ( interpreted ) get_arguments then
81 load_kernel_and_modules
82 ?dup 0= if 0 1 autoboot then
85 also forth definitions also builtins
90 only forth definitions also support-functions
92 include /boot/check-password.4th
96 \ Initializes support.4th global variables, sets loader_conf_files,
97 \ process conf files, and, if any one such file was succesfully
98 \ read to the end, load kernel and modules.
100 : start ( -- ) ( throws: abort & user-defined )
101 s" /boot/defaults/loader.conf" initialize
103 include_nextboot_file
104 \ Will *NOT* try to load kernel and modules if no configuration file
105 \ was succesfully loaded!
114 \ Overrides support.4th initialization word with one that does
115 \ everything start one does, short of loading the kernel and
116 \ modules. Returns a flag
118 : initialize ( -- flag )
119 s" /boot/defaults/loader.conf" initialize
121 include_nextboot_file
127 \ Read a configuration file, whose name was specified on the command
128 \ line, if interpreted, or given on the stack, if compiled in.
130 : (read-conf) ( addr len -- )
132 include_conf_files \ Will recurse on new loader_conf_files definitions
135 : read-conf ( <filename> | addr len -- ) ( throws: abort & user-defined )
145 \ show, enable, disable, toggle module loading. They all take module from
148 : set-module-flag ( module_addr val -- ) \ set and print flag
150 dup module.name strtype
151 module.flag @ if ." will be loaded" else ." will not be loaded" then cr
154 : enable-module find-module ?dup if true set-module-flag then ;
156 : disable-module find-module ?dup if false set-module-flag then ;
158 : toggle-module find-module ?dup if dup module.flag @ 0= set-module-flag then ;
162 \ Show loading information about a module.
164 : show-module ( <module> -- ) find-module ?dup if show-one-module then ;
166 \ Words to be used inside configuration files
168 : retry false ; \ For use in load error commands
169 : ignore true ; \ For use in load error commands
171 \ Return to strict forth vocabulary
179 : .? 2 spaces 2swap 15 #type 2 spaces type cr ;
183 s" boot-conf" s" load kernel and modules, then autoboot" .?
184 s" read-conf" s" read a configuration file" .?
185 s" enable-module" s" enable loading of a module" .?
186 s" disable-module" s" disable loading of a module" .?
187 s" toggle-module" s" toggle loading of a module" .?
188 s" show-module" s" show module load data" .?