diff options
author | dcs <dcs@FreeBSD.org> | 2000-09-15 08:05:52 +0000 |
---|---|---|
committer | dcs <dcs@FreeBSD.org> | 2000-09-15 08:05:52 +0000 |
commit | c1fd1180abc11b64bb99d2cc07092becce34d0b7 (patch) | |
tree | 1a85c87ff5d5193f19daf476676a9d98c5173c72 /sys/boot/forth/loader.4th | |
parent | d58c3debc91741b2f3251a0dd9c79eee21424eb0 (diff) | |
download | FreeBSD-src-c1fd1180abc11b64bb99d2cc07092becce34d0b7.zip FreeBSD-src-c1fd1180abc11b64bb99d2cc07092becce34d0b7.tar.gz |
Factorize, reorganize, and move code around.
The boot-conf and boot code had various bugs, and some of it was big,
ugly, unwieldy, and, sometimes, plain incorrect. I'm just about
completely replaced these ugly parts with something much more manageable.
Minor changes were made to the well-factorized parts of it, to accomodate
the new code.
Of note:
* make sure boot-conf has the exact same behavior wrt boot order
as start.
* Correct both boot and boot-conf so they'll work correctly when
compiled in, as they both had some bugs, minor and major.
* Remove all the crud from loader.4th back into support.4th, for
the first time since boot-conf was first improved. Hurray!
I'm fairly satisfied with the code at this time. Time to see about those
man pages...
Diffstat (limited to 'sys/boot/forth/loader.4th')
-rw-r--r-- | sys/boot/forth/loader.4th | 106 |
1 files changed, 9 insertions, 97 deletions
diff --git a/sys/boot/forth/loader.4th b/sys/boot/forth/loader.4th index 7a4dbcd..a125e70 100644 --- a/sys/boot/forth/loader.4th +++ b/sys/boot/forth/loader.4th @@ -50,130 +50,42 @@ s" arch-i386" environment? [if] [if] include /boot/support.4th -only forth definitions also support-functions - \ ***** boot-conf \ \ Prepares to boot as specified by loaded configuration files. -also support-functions definitions - -: set-tempoptions ( addrN lenN ... addr1 len1 N -- addr len 1 | 0 ) - \ No options, set the default ones - dup 0= if - s" kernel_options" getenv dup -1 = if - drop - else - s" temp_options" setenv - then - exit - then - - \ Skip filename - 2 pick - c@ - [char] - <> if - swap >r swap >r - 1 >r \ Filename present - 1 - \ One less argument - else - 0 >r \ Filename not present - then - - \ If no other arguments exist, use default options - ?dup 0= if - s" kernel_options" getenv dup -1 = if - drop - else - s" temp_options" setenv - then - \ Put filename back on the stack, if necessary - r> if r> r> 1 else 0 then - exit - then - - \ Concatenate remaining arguments into a single string - >r strdup r> - 1 ?do - \ Allocate new buffer - 2over nip over + 1+ - allocate if out_of_memory throw then - \ Copy old buffer over - 0 2swap over >r strcat - \ Free old buffer - r> free if free_error throw then - \ Copy a space - s" " strcat - \ Copy next string (do not free) - 2swap strcat - loop - - \ Set temp_options variable, free whatever memory that needs freeing - over >r - s" temp_options" setenv - r> free if free_error throw then - - \ Put filename back on the stack, if necessary - r> if r> r> 1 else 0 then -; - -: get-arguments ( -- addrN lenN ... addr1 len1 N ) - 0 - begin - \ Get next word on the command line - parse-word - ?dup while - 2>r ( push to the rstack, so we can retrieve in the correct order ) - 1+ - repeat - drop ( empty string ) - dup - begin - dup - while - 2r> rot - >r rot r> - 1 - - repeat - drop -; - -also builtins - -: load-conf ( args 1 | 0 "args" -- flag ) - 0= if ( interpreted ) get-arguments then - set-tempoptions - s" temp_options" getenv -1 <> if 2swap 2 else 1 then - load_kernel_and_modules -; - only forth also support-functions also builtins definitions : boot + 0= if ( interpreted ) get-arguments then + \ Unload only if a path was passed - >in @ parse-word rot >in ! - if + dup if + >r over r> swap c@ [char] - <> if 0 1 unload drop else - get-arguments 1 boot exit + 1 boot exit then else - 0 1 boot exit + 1 boot exit then load-conf ?dup 0= if 0 1 boot then ; : boot-conf + 0= if ( interpreted ) get-arguments then 0 1 unload drop load-conf ?dup 0= if 0 1 autoboot then ; also forth definitions also builtins + builtin: boot builtin: boot-conf + only forth definitions also support-functions \ ***** check-password |