Index: stable/10/sys/boot/forth/loader.4th =================================================================== --- stable/10/sys/boot/forth/loader.4th (revision 262703) +++ stable/10/sys/boot/forth/loader.4th (revision 262704) @@ -1,239 +1,248 @@ \ Copyright (c) 1999 Daniel C. Sobral \ All rights reserved. \ \ Redistribution and use in source and binary forms, with or without \ modification, are permitted provided that the following conditions \ are met: \ 1. Redistributions of source code must retain the above copyright \ notice, this list of conditions and the following disclaimer. \ 2. Redistributions in binary form must reproduce the above copyright \ notice, this list of conditions and the following disclaimer in the \ documentation and/or other materials provided with the distribution. \ \ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND \ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE \ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE \ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL \ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS \ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) \ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \ SUCH DAMAGE. \ \ $FreeBSD$ s" arch-i386" environment? [if] [if] s" loader_version" environment? [if] 11 < [if] .( Loader version 1.1+ required) cr abort [then] [else] .( Could not get loader version!) cr abort [then] [then] [then] 256 dictthreshold ! \ 256 cells minimum free space 2048 dictincrease ! \ 2048 additional cells each time include /boot/support.4th include /boot/color.4th include /boot/delay.4th only forth also support-functions also builtins definitions : bootmsg ( -- ) loader_color? if ." Booting..." cr else ." Booting..." cr then ; : try-menu-unset \ menu-unset may not be present s" beastie_disable" getenv dup -1 <> if s" YES" compare-insensitive 0= if exit then else drop then s" menu-unset" sfind if execute else drop then s" menusets-unset" sfind if execute else drop then ; : boot 0= if ( interpreted ) get_arguments then \ Unload only if a path was passed dup if >r over r> swap c@ [char] - <> if 0 1 unload drop else s" kernelname" getenv? if ( a kernel has been loaded ) try-menu-unset bootmsg 1 boot exit then load_kernel_and_modules ?dup if exit then try-menu-unset bootmsg 0 1 boot exit then else s" kernelname" getenv? if ( a kernel has been loaded ) try-menu-unset bootmsg 1 boot exit then load_kernel_and_modules ?dup if exit then try-menu-unset bootmsg 0 1 boot exit then load_kernel_and_modules ?dup 0= if bootmsg 0 1 boot then ; \ ***** boot-conf \ \ Prepares to boot as specified by loaded configuration files. : boot-conf 0= if ( interpreted ) get_arguments then 0 1 unload drop load_kernel_and_modules ?dup 0= if 0 1 autoboot then ; also forth definitions also builtins builtin: boot builtin: boot-conf only forth definitions also support-functions include /boot/check-password.4th \ ***** start \ \ Initializes support.4th global variables, sets loader_conf_files, \ processes conf files, and, if any one such file was succesfully \ read to the end, loads kernel and modules. : start ( -- ) ( throws: abort & user-defined ) s" /boot/defaults/loader.conf" initialize include_conf_files include_nextboot_file \ Will *NOT* try to load kernel and modules if no configuration file \ was succesfully loaded! any_conf_read? if s" loader_delay" getenv -1 = if load_kernel load_modules else drop ." Loading Kernel and Modules (Ctrl-C to Abort)" cr s" also support-functions" evaluate s" set delay_command='load_kernel load_modules'" evaluate s" set delay_showdots" evaluate delay_execute then then ; \ ***** initialize \ \ Overrides support.4th initialization word with one that does \ everything start one does, short of loading the kernel and \ modules. Returns a flag : initialize ( -- flag ) s" /boot/defaults/loader.conf" initialize include_conf_files include_nextboot_file any_conf_read? ; \ ***** read-conf \ \ Read a configuration file, whose name was specified on the command \ line, if interpreted, or given on the stack, if compiled in. : (read-conf) ( addr len -- ) conf_files string= include_conf_files \ Will recurse on new loader_conf_files definitions ; : read-conf ( | addr len -- ) ( throws: abort & user-defined ) state @ if \ Compiling postpone (read-conf) else \ Interpreting bl parse (read-conf) then ; immediate \ show, enable, disable, toggle module loading. They all take module from \ the next word : set-module-flag ( module_addr val -- ) \ set and print flag over module.flag ! dup module.name strtype module.flag @ if ." will be loaded" else ." will not be loaded" then cr ; : enable-module find-module ?dup if true set-module-flag then ; : disable-module find-module ?dup if false set-module-flag then ; : toggle-module find-module ?dup if dup module.flag @ 0= set-module-flag then ; \ ***** show-module \ \ Show loading information about a module. : show-module ( -- ) find-module ?dup if show-one-module then ; \ Words to be used inside configuration files : retry false ; \ For use in load error commands : ignore true ; \ For use in load error commands \ Return to strict forth vocabulary : #type over - >r type r> spaces ; : .? 2 spaces 2swap 15 #type 2 spaces type cr ; : ? ['] ? execute s" boot-conf" s" load kernel and modules, then autoboot" .? s" read-conf" s" read a configuration file" .? s" enable-module" s" enable loading of a module" .? s" disable-module" s" disable loading of a module" .? s" toggle-module" s" toggle loading of a module" .? s" show-module" s" show module load data" .? + s" try-include" s" try to load/interpret files" .? ; + +: try-include ( -- ) \ see loader.4th(8) + ['] include ( -- xt ) \ get the execution token of `include' + catch ( xt -- exception# | 0 ) if \ failed + LF parse ( c -- s-addr/u ) 2drop \ advance >in to EOL (drop data) + \ ... prevents words unused by `include' from being interpreted + then +; immediate \ interpret immediately for access to `source' (aka tib) only forth also Index: stable/10/sys/boot/forth/loader.4th.8 =================================================================== --- stable/10/sys/boot/forth/loader.4th.8 (revision 262703) +++ stable/10/sys/boot/forth/loader.4th.8 (revision 262704) @@ -1,226 +1,233 @@ .\" Copyright (c) 1999 Daniel C. Sobral .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd October 17, 2013 +.Dd November 13, 2013 .Dt LOADER.4TH 8 .Os .Sh NAME .Nm loader.4th .Nd loader.conf processing tools .Sh DESCRIPTION The file that goes by the name of .Nm is a set of commands designed to manipulate .Xr loader.conf 5 files. The default .Pa /boot/loader.rc includes .Nm and uses one of its commands to automatically read and process the standard .Xr loader.conf 5 files. Other commands exists to help the user specify alternate configurations. .Pp The commands of .Nm by themselves are not enough for most uses. Please refer to the examples below for the most common situations, and to .Xr loader 8 for additional commands. .Pp Before using any of the commands provided in .Nm , it must be included through the command: .Pp .Dl include loader.4th .Pp This line is present in the default .Pa /boot/loader.rc file, so it is not needed (and should not be re-issued) in a normal setup. .Pp The commands provided by it are: .Bl -tag -width disable-module_module -compact -offset indent .It Ic boot .It Ic boot Ar kernelname Op Cm ... .It Ic boot Ar directory Op Cm ... .It Ic boot Fl flag Cm ... Boot as specified by the .Xr loader.conf 5 files read. .Pp Depending on the arguments passed, it can override boot flags and either the kernel name or the search path for kernel and modules. .Pp .It Ic boot-conf .It Ic boot-conf Ar kernelname Op Cm ... .It Ic boot-conf Ar directory Op Cm ... .It Ic boot-conf Fl flag Cm ... Works like .Ic boot described above, but instead of booting immediately, uses .Ic autoboot , so it can be stopped. .Pp .It Ic start Reads .Pa /boot/defaults/loader.conf , all other .Xr loader.conf 5 files specified in it, then loads the desired kernel and modules .Pq if not already loaded . After which you can use the .Ic boot or .Ic autoboot commmands or simply exit (provided .Va autoboot_delay is not set to NO) to boot the system. .Ic start is the command used in the default .Pa /boot/loader.rc file .Pq see Xr loader 8 . .Pp .It Ic initialize Initialize the support library so commands can be used without executing .Ic start first. Like .Ic start , it reads .Pa /boot/defaults/loader.conf and all other .Xr loader.conf 5 files specified in it .Pq but does not load kernel or modules . Returns a flag on the stack to indicate if any configuration files were successfully loaded. .Pp .It Ic read-conf Ar filename Reads and processes a .Xr loader.conf 5 file. Does not proceed to boot. .Pp .It Ic enable-module Ar module Enables the loading of .Ar module . .Pp .It Ic disable-module Ar module Disables the loading of .Ar module . .Pp .It Ic toggle-module Ar module Toggles the loading of .Ar module on and off. .Pp .It Ic show-module Ar module Shows the information gathered in the .Xr loader.conf 5 files about the module .Ar module . .Pp .It Ic retry Used inside .Xr loader.conf 5 files to specify the action after a module loading fails. .Pp .It Ic ignore Used inside .Xr loader.conf 5 files to specify the action after a module loading fails. +.It Ic try-include Ar file Op Ar +Process script files if they exist. +Each file, in turn, is completely read into memory, +and then each of its lines is passed to the command line interpreter. +If any error is returned by the interpreter, the try-include +command aborts immediately, without reading any other files, and +silently returns without error. .El .Sh FILES .Bl -tag -width /boot/loader.4th -compact .It Pa /boot/loader The .Xr loader 8 . .It Pa /boot/loader.4th .Nm itself. .It Pa /boot/loader.rc .Xr loader 8 bootstrapping script. .It Pa /boot/defaults/loader.conf File loaded by the .Ic start command. .El .Sh EXAMPLES Standard .Pa /boot/loader.rc : .Pp .Bd -literal -offset indent -compact include /boot/loader.4th start .Ed .Pp Load a different kernel with the standard configuration: .Pp .Bd -literal -offset indent -compact set kernel="kernel.old" unload boot-conf .Ed .Pp Read an additional configuration file and then proceed to boot: .Pp .Bd -literal -offset indent -compact unload read-conf /boot/special.conf boot-conf .Ed .Pp Disable the loading of the splash screen module and bitmap and then proceed to boot: .Pp .Bd -literal -offset indent -compact unload disable-module splash_bmp disable-module bitmap boot-conf .Ed .Sh SEE ALSO .Xr loader.conf 5 , .Xr loader 8 .Sh HISTORY The .Nm set of commands first appeared in .Fx 3.2 . .Sh AUTHORS The .Nm set of commands was written by .An Daniel C. Sobral Aq dcs@FreeBSD.org . .Sh BUGS A British espionage series. Index: stable/10/sys/boot/forth/loader.rc =================================================================== --- stable/10/sys/boot/forth/loader.rc (revision 262703) +++ stable/10/sys/boot/forth/loader.rc (revision 262704) @@ -1,19 +1,20 @@ \ Loader.rc \ $FreeBSD$ \ \ Includes additional commands include /boot/loader.4th +try-include /boot/loader.rc.local \ Reads and processes loader.conf variables \ NOTE: Change to `initialize' if you enable the below boot menu start \ Tests for password -- executes autoboot first if a password was defined check-password \ Uncomment to enable boot menu \ include /boot/beastie.4th \ beastie-start \ Unless set otherwise, autoboot is automatic at this point Index: stable/10/sys/boot/forth/menu.rc =================================================================== --- stable/10/sys/boot/forth/menu.rc (revision 262703) +++ stable/10/sys/boot/forth/menu.rc (revision 262704) @@ -1,126 +1,130 @@ \ Menu.rc \ $FreeBSD$ \ \ Load required Forth modules include /boot/version.4th include /boot/brand.4th include /boot/menu.4th include /boot/menu-commands.4th include /boot/shortcuts.4th \ Screen prep clear \ clear the screen (see `screen.4th') print_version \ print version string (bottom-right; see `version.4th') draw-beastie \ draw freebsd mascot (on right; see `beastie.4th') draw-brand \ draw the FreeBSD title (top-left; see `brand.4th') menu-init \ initialize the menu area (see `menu.4th') \ Initialize main menu constructs (see `menu.4th') \ NOTE: To use `non-ansi' variants, add `loader_color=0' to loader.conf(5) \ \ MAIN MENU \ set menuset_name1="main" set mainmenu_init[1]="init_boot" set mainmenu_caption[1]="Boot Multi User [Enter]" set maintoggled_text[1]="Boot [S]ingle User [Enter]" set mainmenu_command[1]="boot" set mainansi_caption[1]="Boot Multi User [Enter]" set maintoggled_ansi[1]="Boot Single User [Enter]" \ keycode set by init_boot set mainmenu_init[2]="init_altboot" set mainmenu_caption[2]="Boot [S]ingle User" set maintoggled_text[2]="Boot [M]ulti User" set mainmenu_command[2]="altboot" set mainansi_caption[2]="Boot Single User" set maintoggled_ansi[2]="Boot Multi User" \ keycode set by init_altboot set mainmenu_caption[3]="[Esc]ape to loader prompt" set mainmenu_command[3]="goto_prompt" set mainmenu_keycode[3]=27 set mainansi_caption[3]="Escape to loader prompt" \ Enable built-in "Reboot" trailing menuitem \ NOTE: appears before menu_options if configured \ set mainmenu_reboot \ Enable "Options:" separator. When set to a numerical value (1-8), a visual \ separator is inserted before that menuitem number. \ set mainmenu_options=5 set mainmenu_kernel=5 set mainmenu_command[5]="cycle_kernel" set mainmenu_keycode[5]=107 set mainmenu_caption[6]="Configure Boot [O]ptions..." set mainmenu_command[6]="2 goto_menu" set mainmenu_keycode[6]=111 set mainansi_caption[6]="Configure Boot Options..." \ \ BOOT OPTIONS MENU \ set menuset_name2="options" set optionsmenu_caption[1]="Back to Main Menu [Backspace]" set optionsmenu_command[1]="1 goto_menu" set optionsmenu_keycode[1]=8 set optionsansi_caption[1]="Back to Main Menu [Backspace]" set optionsmenu_caption[2]="Load System [D]efaults" set optionsmenu_command[2]="set_default_boot_options" set optionsmenu_keycode[2]=100 set optionsansi_caption[2]="Load System Defaults" set optionsmenu_options=3 set optionsmenu_optionstext="Boot Options:" set optionsmenu_acpi=3 set optionsmenu_caption[3]="[A]CPI Support off" set optionstoggled_text[3]="[A]CPI Support On" set optionsmenu_command[3]="toggle_acpi" set optionsmenu_keycode[3]=97 set optionsansi_caption[3]="ACPI Support Off" set optionstoggled_ansi[3]="ACPI Support On" set optionsmenu_init[4]="init_safemode" set optionsmenu_caption[4]="Safe [M]ode... off" set optionstoggled_text[4]="Safe [M]ode... On" set optionsmenu_command[4]="toggle_safemode" set optionsmenu_keycode[4]=109 set optionsansi_caption[4]="Safe Mode... Off" set optionstoggled_ansi[4]="Safe Mode... On" set optionsmenu_init[5]="init_singleuser" set optionsmenu_caption[5]="[S]ingle User. off" set optionstoggled_text[5]="[S]ingle User. On" set optionsmenu_command[5]="toggle_singleuser" set optionsmenu_keycode[5]=115 set optionsansi_caption[5]="Single User. Off" set optionstoggled_ansi[5]="Single User. On" set optionsmenu_init[6]="init_verbose" set optionsmenu_caption[6]="[V]erbose..... off" set optionstoggled_text[6]="[V]erbose..... On" set optionsmenu_command[6]="toggle_verbose" set optionsmenu_keycode[6]=118 set optionsansi_caption[6]="Verbose..... Off" set optionstoggled_ansi[6]="Verbose..... On" \ Enable automatic booting (add ``autoboot_delay=N'' to loader.conf(5) to \ customize the timeout; default is 10-seconds) \ set menu_timeout_command="boot" +\ Include optional elements defined in a local file +\ +try-include /boot/menu.rc.local + \ Display the main menu (see `menu.4th') set menuset_initial=1 menuset-loadinitial menu-display Index: stable/10/sys/boot/i386/loader/loader.rc =================================================================== --- stable/10/sys/boot/i386/loader/loader.rc (revision 262703) +++ stable/10/sys/boot/i386/loader/loader.rc (revision 262704) @@ -1,17 +1,18 @@ \ Loader.rc \ $FreeBSD$ \ \ Includes additional commands include /boot/loader.4th +try-include /boot/loader.rc.local \ Reads and processes loader.conf variables initialize \ Tests for password -- executes autoboot first if a password was defined check-password \ Load in the boot menu include /boot/beastie.4th \ Start the boot menu beastie-start Index: stable/10 =================================================================== --- stable/10 (revision 262703) +++ stable/10 (revision 262704) Property changes on: stable/10 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r258270