Deleted Added
full compact
loader.4th (65621) loader.4th (65630)
1\ Copyright (c) 1999 Daniel C. Sobral <dcs@freebsd.org>
2\ All rights reserved.
3\
4\ Redistribution and use in source and binary forms, with or without
5\ modification, are permitted provided that the following conditions
6\ are met:
7\ 1. Redistributions of source code must retain the above copyright
8\ notice, this list of conditions and the following disclaimer.

--- 8 unchanged lines hidden (view full) ---

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
23\ SUCH DAMAGE.
24\
1\ Copyright (c) 1999 Daniel C. Sobral <dcs@freebsd.org>
2\ All rights reserved.
3\
4\ Redistribution and use in source and binary forms, with or without
5\ modification, are permitted provided that the following conditions
6\ are met:
7\ 1. Redistributions of source code must retain the above copyright
8\ notice, this list of conditions and the following disclaimer.

--- 8 unchanged lines hidden (view full) ---

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
23\ SUCH DAMAGE.
24\
25\ $FreeBSD: head/sys/boot/forth/loader.4th 65621 2000-09-08 21:11:57Z dcs $
25\ $FreeBSD: head/sys/boot/forth/loader.4th 65630 2000-09-09 04:52:34Z dcs $
26
27s" arch-alpha" environment? [if] [if]
28 s" loader_version" environment? [if]
29 3 < [if]
30 .( Loader version 0.3+ required) cr
31 abort
32 [then]
33 [else]

--- 19 unchanged lines hidden (view full) ---

53only forth definitions also support-functions
54
55\ ***** boot-conf
56\
57\ Prepares to boot as specified by loaded configuration files.
58
59also support-functions definitions
60
26
27s" arch-alpha" environment? [if] [if]
28 s" loader_version" environment? [if]
29 3 < [if]
30 .( Loader version 0.3+ required) cr
31 abort
32 [then]
33 [else]

--- 19 unchanged lines hidden (view full) ---

53only forth definitions also support-functions
54
55\ ***** boot-conf
56\
57\ Prepares to boot as specified by loaded configuration files.
58
59also support-functions definitions
60
61: bootpath s" /boot/" ;
62: modulepath s" module_path" ;
63
64: saveenv ( addr len | 0 -1 -- addr' len | 0 -1 )
65 dup -1 = if exit then
66 dup allocate abort" Out of memory"
67 swap 2dup 2>r
68 move
69 2r>
70;
71
72: freeenv ( addr len | 0 -1 )
73 -1 = if drop else free abort" Freeing error" then
74;
75
76: restoreenv ( addr len | 0 -1 -- )
77 dup -1 = if ( it wasn't set )
78 2drop
79 modulepath unsetenv
80 else
81 over >r
82 modulepath setenv
83 r> free abort" Freeing error"
84 then
85;
86
87: set-tempoptions ( addrN lenN ... addr1 len1 N -- addr len 1 | 0 )
88 \ No options, set the default ones
89 dup 0= if
90 s" kernel_options" getenv dup -1 = if
91 drop
92 else
93 s" temp_options" setenv
94 then

--- 66 unchanged lines hidden (view full) ---

161 >r rot r>
162 1 -
163 repeat
164 drop
165;
166
167also builtins
168
61: set-tempoptions ( addrN lenN ... addr1 len1 N -- addr len 1 | 0 )
62 \ No options, set the default ones
63 dup 0= if
64 s" kernel_options" getenv dup -1 = if
65 drop
66 else
67 s" temp_options" setenv
68 then

--- 66 unchanged lines hidden (view full) ---

135 >r rot r>
136 1 -
137 repeat
138 drop
139;
140
141also builtins
142
169: load-kernel ( addr len -- addr len error? )
170 s" temp_options" getenv dup -1 = if
171 drop 2dup 1
172 else
173 2over 2
174 then
175
176 1 load
177;
178
179: load-conf ( args 1 | 0 "args" -- flag )
143: load-conf ( args 1 | 0 "args" -- flag )
180 0 1 unload drop
181
182 0= if ( interpreted ) get-arguments then
183 set-tempoptions
144 0= if ( interpreted ) get-arguments then
145 set-tempoptions
184
185 if ( there are arguments )
186 load-kernel if ( load command failed )
187 \ Set the environment variable module_path, and try loading
188 \ the kernel again.
189
190 \ First, save module_path value
191 modulepath getenv saveenv dup -1 = if 0 swap then 2>r
192
193 \ Sets the new value
194 2dup modulepath setenv
195
196 \ Try to load the kernel
197 s" load ${kernel} ${temp_options}" ['] evaluate catch
198 if ( load failed yet again )
199 \ Remove garbage from the stack
200 2drop
201
202 \ Try prepending /boot/
203 bootpath 2over nip over + allocate
204 if ( out of memory )
205 2drop 2drop
206 2r> restoreenv
207 100 exit
208 then
209
210 0 2swap strcat 2swap strcat
211 2dup modulepath setenv
212
213 drop free if ( freeing memory error )
214 2drop
215 2r> restoreenv
216 100 exit
217 then
218
219 \ Now, once more, try to load the kernel
220 s" load ${kernel} ${temp_options}" ['] evaluate catch
221 if ( failed once more )
222 2drop
223 2r> restoreenv
224 100 exit
225 then
226
227 else ( we found the kernel on the path passed )
228
229 2drop ( discard command line arguments )
230
231 then ( could not load kernel from directory passed )
232
233 \ Load the remaining modules, if the kernel was loaded at all
234 ['] load_modules catch if 2r> restoreenv 100 exit then
235
236 \ Return 0 to indicate success
237 0
238
239 \ Keep new module_path
240 2r> freeenv
241
242 exit
243 then ( could not load kernel with name passed )
244
245 2drop ( discard command line arguments )
246
247 else ( try just a straight-forward kernel load )
248 s" load ${kernel} ${temp_options}" ['] evaluate catch
249 if ( kernel load failed ) 2drop 100 exit then
250
251 then ( there are command line arguments )
252
253 \ Load the remaining modules, if the kernel was loaded at all
254 ['] load_modules catch if 100 exit then
255
256 \ Return 0 to indicate success
257 0
146 s" temp_options" getenv -1 <> if 2swap 2 else 1 then
147 load_kernel_and_modules
258;
259
260only forth also support-functions also builtins definitions
261
262: boot
148;
149
150only forth also support-functions also builtins definitions
151
152: boot
153 \ Unload only if a path was passed
154 >in @ parse-word rot >in !
155 if
156 c@ [char] - <> if
157 0 1 unload drop
158 else
159 get-arguments 1 boot exit
160 then
161 else
162 0 1 boot exit
163 then
263 load-conf
264 ?dup 0= if 0 1 boot then
265;
266
267: boot-conf
164 load-conf
165 ?dup 0= if 0 1 boot then
166;
167
168: boot-conf
169 0 1 unload drop
268 load-conf
269 ?dup 0= if 0 1 autoboot then
270;
271
272also forth definitions also builtins
273builtin: boot
274builtin: boot-conf
275only forth definitions also support-functions

--- 189 unchanged lines hidden ---
170 load-conf
171 ?dup 0= if 0 1 autoboot then
172;
173
174also forth definitions also builtins
175builtin: boot
176builtin: boot-conf
177only forth definitions also support-functions

--- 189 unchanged lines hidden ---