Deleted Added
full compact
25c25
< \ $FreeBSD: head/sys/boot/forth/loader.4th 65621 2000-09-08 21:11:57Z dcs $
---
> \ $FreeBSD: head/sys/boot/forth/loader.4th 65630 2000-09-09 04:52:34Z dcs $
61,86d60
< : bootpath s" /boot/" ;
< : modulepath s" module_path" ;
<
< : saveenv ( addr len | 0 -1 -- addr' len | 0 -1 )
< dup -1 = if exit then
< dup allocate abort" Out of memory"
< swap 2dup 2>r
< move
< 2r>
< ;
<
< : freeenv ( addr len | 0 -1 )
< -1 = if drop else free abort" Freeing error" then
< ;
<
< : restoreenv ( addr len | 0 -1 -- )
< dup -1 = if ( it wasn't set )
< 2drop
< modulepath unsetenv
< else
< over >r
< modulepath setenv
< r> free abort" Freeing error"
< then
< ;
<
169,178d142
< : load-kernel ( addr len -- addr len error? )
< s" temp_options" getenv dup -1 = if
< drop 2dup 1
< else
< 2over 2
< then
<
< 1 load
< ;
<
180,181d143
< 0 1 unload drop
<
184,257c146,147
<
< if ( there are arguments )
< load-kernel if ( load command failed )
< \ Set the environment variable module_path, and try loading
< \ the kernel again.
<
< \ First, save module_path value
< modulepath getenv saveenv dup -1 = if 0 swap then 2>r
<
< \ Sets the new value
< 2dup modulepath setenv
<
< \ Try to load the kernel
< s" load ${kernel} ${temp_options}" ['] evaluate catch
< if ( load failed yet again )
< \ Remove garbage from the stack
< 2drop
<
< \ Try prepending /boot/
< bootpath 2over nip over + allocate
< if ( out of memory )
< 2drop 2drop
< 2r> restoreenv
< 100 exit
< then
<
< 0 2swap strcat 2swap strcat
< 2dup modulepath setenv
<
< drop free if ( freeing memory error )
< 2drop
< 2r> restoreenv
< 100 exit
< then
<
< \ Now, once more, try to load the kernel
< s" load ${kernel} ${temp_options}" ['] evaluate catch
< if ( failed once more )
< 2drop
< 2r> restoreenv
< 100 exit
< then
<
< else ( we found the kernel on the path passed )
<
< 2drop ( discard command line arguments )
<
< then ( could not load kernel from directory passed )
<
< \ Load the remaining modules, if the kernel was loaded at all
< ['] load_modules catch if 2r> restoreenv 100 exit then
<
< \ Return 0 to indicate success
< 0
<
< \ Keep new module_path
< 2r> freeenv
<
< exit
< then ( could not load kernel with name passed )
<
< 2drop ( discard command line arguments )
<
< else ( try just a straight-forward kernel load )
< s" load ${kernel} ${temp_options}" ['] evaluate catch
< if ( kernel load failed ) 2drop 100 exit then
<
< then ( there are command line arguments )
<
< \ Load the remaining modules, if the kernel was loaded at all
< ['] load_modules catch if 100 exit then
<
< \ Return 0 to indicate success
< 0
---
> s" temp_options" getenv -1 <> if 2swap 2 else 1 then
> load_kernel_and_modules
262a153,163
> \ Unload only if a path was passed
> >in @ parse-word rot >in !
> if
> c@ [char] - <> if
> 0 1 unload drop
> else
> get-arguments 1 boot exit
> then
> else
> 0 1 boot exit
> then
267a169
> 0 1 unload drop