loader.4th revision 44603
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. 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. 12\ 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 23\ SUCH DAMAGE. 24\ 25\ $Id$ 26 27include /boot/support.4th 28 29only forth definitions also support-functions 30 31\ ***** boot-conf 32\ 33\ Prepares to boot as specified by loaded configuration files. 34 35: boot-conf 36 load_kernel 37 load_modules 38 0 autoboot 39; 40 41\ ***** start 42\ 43\ Initializes support.4th global variables, sets loader_conf_files, 44\ process conf files, and, if any one such file was succesfully 45\ read to the end, load kernel and modules. 46 47: start ( -- ) ( throws: abort & user-defined ) 48 s" /boot/defaults/loader.conf" initialize 49 include_conf_files 50 \ Will *NOT* try to load kernel and modules if no configuration file 51 \ was succesfully loaded! 52 any_conf_read? if 53 load_kernel 54 load_modules 55 then 56; 57 58\ ***** read-conf 59\ 60\ Read a configuration file, whose name was specified on the command 61\ line, if interpreted, or given on the stack, if compiled in. 62 63: (read-conf) ( addr len -- ) 64 conf_files .addr @ ?dup if free abort" Fatal error freeing memory" then 65 strdup conf_files .len ! conf_files .addr ! 66 include_conf_files \ Will recurse on new loader_conf_files definitions 67; 68 69: read-conf ( <filename> | addr len -- ) ( throws: abort & user-defined ) 70 state @ if 71 \ Compiling 72 postpone (read-conf) 73 else 74 \ Interpreting 75 bl parse (read-conf) 76 then 77; immediate 78 79\ ***** show-module 80\ 81\ Show loading information about a module. 82 83: show-module ( <module> -- ) 84 bl parse module_options @ >r 85 begin 86 r@ 87 while 88 2dup 89 r@ module.name dup .addr @ swap .len @ 90 compare 0= if 91 2drop 92 ." Name: " r@ module.name dup .addr @ swap .len @ type cr 93 ." Path: " r@ module.loadname dup .addr @ swap .len @ type cr 94 ." Type: " r@ module.type dup .addr @ swap .len @ type cr 95 ." Flags: " r@ module.args dup .addr @ swap .len @ type cr 96 ." Before load: " r@ module.beforeload dup .addr @ swap .len @ type cr 97 ." After load: " r@ module.afterload dup .addr @ swap .len @ type cr 98 ." Error: " r@ module.loaderror dup .addr @ swap .len @ type cr 99 ." Status: " r> module.flag @ if ." Load" else ." Don't load" then cr 100 exit 101 then 102 r> module.next @ >r 103 repeat 104; 105 106\ Words to be used inside configuration files 107 108: retry false ; \ For use in load error commands 109: ignore true ; \ For use in load error commands 110 111\ Return to strict forth vocabulary 112 113only forth also 114 115