From b5ef8da19e69225e5a661f5d6259fee2f2894117 Mon Sep 17 00:00:00 2001 From: Thomas Nikolajsen Date: Wed, 6 Oct 2010 02:43:14 +0200 Subject: [PATCH] loader(8): adjustment & man update * fix `help' command by using $base/loader.help, otherwise `help' didn't work when pwd outside $base. * allow `cd' and `optcd' without arguments, using $base as default. * use pager for `?' and `local' commands. * make `more' work with relative file names * truncate very long lines (more than 256 chars), and give warning; before they stopped include processing; these are typically just comments. * add `optcd kernel' when using ESC in `menu', like the menu item (`9') that exits via dloader.menu. * remove extra line in Fred menu (on right) (it was scrolling warning about truncated line off screen). * remove obsolete variables in loader.conf. * update `help' output. * update man pages. --- share/man/man5/loader.conf.5 | 90 ++- sys/boot/common/commands.c | 31 +- sys/boot/common/do_dloader.c | 47 +- sys/boot/common/help.common | 433 +++++++++++--- sys/boot/common/loader.8 | 724 ++++++++--------------- sys/boot/common/rel_open.c | 24 +- sys/boot/dloader/cmds.c | 46 +- sys/boot/dloader/loader-bootp.conf | 13 +- sys/boot/dloader/loader.conf | 13 +- sys/boot/dloader/subs.c | 6 +- sys/boot/pc32/loader/help.i386 | 22 +- sys/boot/pc32/pxeldr/pxeboot.8 | 26 +- sys/boot/pc32/pxeldr_tftp/pxeboot_tftp.8 | 10 +- 13 files changed, 790 insertions(+), 695 deletions(-) diff --git a/share/man/man5/loader.conf.5 b/share/man/man5/loader.conf.5 index 1e16ef18e4..9d73479207 100644 --- a/share/man/man5/loader.conf.5 +++ b/share/man/man5/loader.conf.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD: src/sys/boot/forth/loader.conf.5,v 1.18 2002/08/27 01:02:56 trhodes Exp $ .\" $DragonFly: src/sys/boot/forth/loader.conf.5,v 1.13 2008/09/15 21:23:44 thomas Exp $ -.Dd September 6, 2008 +.Dd October 6, 2010 .Dt LOADER.CONF 5 .Os .Sh NAME @@ -34,23 +34,24 @@ The file .Nm contains descriptive information on bootstrapping the system. -Through -it you can specify the kernel to be booted, parameters to be passed to -it, and additional modules to be loaded; and generally set all variables -described in +Through it you can specify the kernel to be booted, +parameters to be passed to it, +and additional kernel modules to be loaded; +and generally set all variables described in .Xr loader 8 . .Pp A file -.Pa loader.rc -must contain the following two lines for +.Pa dloader.rc +must contain the following lines for .Nm to be automatically processed: .Pp -.Dl include loader.4th -.Dl start +.Dl include defaults/loader.conf +.Dl optinclude loader.conf +.Dl optinclude loader.conf.local .Pp If no -.Pa /boot/loader.rc +.Pa /boot/dloader.rc exists at installworld time, one with the above lines will be installed. .Sh SYNTAX Though @@ -60,8 +61,7 @@ format was defined explicitly to resemble and can be sourced by .Xr sh 1 , some settings are treated in a special fashion. -Also, the -behavior of some settings is defined by the setting's suffix; +Also, the behavior of some settings is defined by the setting's suffix; the prefix identifies which module the setting controls. .Pp The general parsing rules are: @@ -80,31 +80,18 @@ All settings have the following format: .Pp .Dl variable="value" .Pp -Unless it belongs to one of the classes of settings that receive special -treatment, a setting will set the value of a -.Xr loader 8 -environment variable. -The settings that receive special -treatment are listed below. +This assigns value to a local variable. +If variable is in a list of known kernel environment variables or +is a kernel tunable, +it is also assigned to the kernel environment variable of the given name. +.Pp +The settings that receive special treatment are listed below. Settings beginning with .Aq Ar module -below define the modules to be loaded. +below define the kernel modules to be loaded. All such settings sharing a common prefix refer to the same module. -.Bl -tag -width Ar -.It Ar exec -Immediately executes a -.Xr loader 8 -command. -This type of setting cannot be processed by programs other -than -.Xr loader 8 , -so its use should be avoided. -Multiple instances of it will be processed -independently. -.It Ar loader_conf_files -Defines additional configuration files to be processed right after the -present file. +.Bl -tag -width indent .It Ar kernel Name of the kernel to be loaded. If no kernel name is set, no additional @@ -112,9 +99,6 @@ modules will be loaded. .It Ar kernel_options Flags to be passed to the kernel (see .Xr boot 8 ) . -.It Ar password -Provides a password to be required by check-password before execution is -allowed to continue. .It Ar verbose_loading If set to .Dq YES , @@ -122,7 +106,7 @@ module names will be displayed as they are loaded. .It Ao Ar module Ac Ns Ar _load If set to .Dq YES , -that module will be loaded. +that kernel module will be loaded. If no .Ao Ar module Ac Ns Ar _name is defined (see below), the @@ -132,7 +116,9 @@ module's name is taken to be Defines the name of the module. .It Ao Ar module Ac Ns Ar _type Defines the module's type. -If none is given, it defaults to a kld module. +If none is given, it defaults to a +.Xr kld 4 +module. .It Ao Ar module Ac Ns Ar _flags Flags and parameters to be passed to the module. .It Ao Ar module Ac Ns Ar _before @@ -151,12 +137,14 @@ special value which aborts the bootstrap process, use of this setting should be avoided. .El .Sh DEFAULT SETTINGS -Most of +See +.Pa /boot/defaults/loader.conf +for .Nm Ns 's -default settings can be ignored. +default settings. The few of them which are important or useful are: -.Bl -tag -width bootfile -offset indent +.Bl -tag -width indent .It Va bitmap_load .Pq Dq NO If set to @@ -189,7 +177,7 @@ to .Pq Dq NO Shows Fred on the left side of the menu rather than the right side. .It Va kernel -.Pq Dq kernel +.Pq Dq kernel . .It Va loader_color .Pq Dq NO If set to @@ -202,8 +190,6 @@ boot menu appears (remember to set to .Dq NO for this to work.) -.It Va loader_conf_files -.Pq Do loader.conf loader.conf.local Dc .It Va splash_bmp_load .Pq Dq NO If set to @@ -229,19 +215,21 @@ the vesa module will be loaded, enabling bitmaps above VGA resolution to be displayed. .El .Sh FILES -.Bl -tag -width /boot/defaults/loader.conf -compact +.Bl -tag -width ".Pa /boot/defaults/dloader.menu" -compact +.It Pa /boot/defaults/dloader.menu +default settings for menu setup -- do not change this file. .It Pa /boot/defaults/loader.conf default settings -- do not change this file. -.It Pa /boot/loader.4th -defines the commands used by loader to read and process -.Nm . +.It Pa /boot/dloader.menu +defines the commands used by +.Nm loader +to setup menus. .It Pa /boot/loader.conf user defined settings. .It Pa /boot/loader.conf.local machine-specific settings for sites with a common loader.conf. -.It Pa /boot/loader.rc -contains the instructions to automatically process -.Nm . +.It Pa /boot/dloader.rc +contains the instructions to automatically process. .El .Sh SEE ALSO .Xr boot 8 , diff --git a/sys/boot/common/commands.c b/sys/boot/common/commands.c index 16ad5b9d78..2cac41ff71 100644 --- a/sys/boot/common/commands.c +++ b/sys/boot/common/commands.c @@ -132,9 +132,13 @@ command_help(int argc, char *argv[]) /* page the help text from our load path */ /* sprintf(buf, "%s/boot/loader.help", getenv("loaddev")); */ - if ((hfd = rel_open("loader.help", NULL, O_RDONLY)) < 0) { - printf("Verbose help not available, use '?' to list commands\n"); - return(CMD_OK); + /* page the help text from our base path */ + snprintf(buf, sizeof(buf), "%sloader.help", getenv("base")); + if ((hfd = open(buf, O_RDONLY)) < 0) { + if ((hfd = rel_open("loader.help", NULL, O_RDONLY)) < 0) { + printf("Verbose help not available, use '?' to list commands\n"); + return(CMD_OK); + } } /* pick up request from arguments */ @@ -212,12 +216,18 @@ static int command_commandlist(int argc, char *argv[]) { struct bootblk_command **cmdp; + char str[81]; + pager_open(); printf("Available commands:\n"); SET_FOREACH(cmdp, Xcommand_set) { - if (((*cmdp)->c_name != NULL) && ((*cmdp)->c_desc != NULL)) - printf(" %-15s %s\n", (*cmdp)->c_name, (*cmdp)->c_desc); + if (((*cmdp)->c_name != NULL) && ((*cmdp)->c_desc != NULL)) { + snprintf(str, sizeof(str), " %-15s %s\n", + (*cmdp)->c_name, (*cmdp)->c_desc); + pager_output(str); + } } + pager_close(); return(CMD_OK); } @@ -425,9 +435,16 @@ static int page_file(char *filename) { int result; + int fd; + char *fullpath; - result = pager_file(filename); - + if ((fd = rel_open(filename, &fullpath, O_RDONLY)) != -1) { + close(fd); + result = pager_file(fullpath); + free(fullpath); + } else { + result = -1; + } if (result == -1) sprintf(command_errbuf, "error showing %s", filename); diff --git a/sys/boot/common/do_dloader.c b/sys/boot/common/do_dloader.c index f0a17f5a21..b589b1198f 100644 --- a/sys/boot/common/do_dloader.c +++ b/sys/boot/common/do_dloader.c @@ -29,8 +29,6 @@ /* * Simple commandline interpreter, toplevel and misc. - * - * XXX may be obsoleted by BootFORTH or some other, better, interpreter. */ #include @@ -39,6 +37,8 @@ #include "dloader.h" static void prompt(void); +static int iseol(char c); +static void skipeol(int fd); /* * Perform the command @@ -100,7 +100,7 @@ interact(void) /* * Read our default configuration */ - if (include("dloader.rc")!=CMD_OK) + if (include("dloader.rc") != CMD_OK) include("boot.conf"); printf("\n"); /* @@ -115,10 +115,7 @@ interact(void) */ printf("\nType '?' for a list of commands, 'help' for more detailed help.\n"); if (getenv("prompt") == NULL) - setenv("prompt", "${interpret}", 1); - if (getenv("interpret") == NULL) - setenv("interpret", "OK", 1); - + setenv("prompt", "OK", 1); for (;;) { input[0] = '\0'; @@ -169,14 +166,15 @@ command_include(int argc, char *argv[]) return(res); } -COMMAND_SET(optinclude, "optinclude", "run commands from file", + +COMMAND_SET(optinclude, "optinclude", + "run commands from file; ignore exit status", command_optinclude); static int command_optinclude(int argc, char *argv[]) { int i; - int res; char **argvbuf; /* @@ -186,15 +184,14 @@ command_optinclude(int argc, char *argv[]) for (i = 0; i < argc; i++) argvbuf[i] = strdup(argv[i]); - res=CMD_OK; - for (i = 1; (i < argc) && (res == CMD_OK); i++) + for (i = 1; (i < argc); i++) include(argvbuf[i]); for (i = 0; i < argc; i++) free(argvbuf[i]); free(argvbuf); - return(res); + return(CMD_OK); } struct includeline @@ -228,9 +225,16 @@ include(const char *filename) script = se = NULL; line = 0; - while (fgetstr(input, sizeof(input), fd) >= 0) { + while (fgets(input, sizeof(input), fd) != NULL) { line++; flags = 0; + if(strlen(input) == sizeof(input) - 1 && + !iseol(input[sizeof(input) - 2])) { + printf("WARNING: %s: %s: Line too long: truncating; have:\n", + __func__, filename); + printf("%s\n", input); + skipeol(fd); + } /* Discard comments */ if (strncmp(input+strspn(input, " "), "\\ ", 2) == 0) continue; @@ -335,3 +339,20 @@ prompt(void) putchar(' '); free(pr); } + +static int +iseol(char c) +{ + return(c == '\n' || c == '\r'); +} + +static void +skipeol(int fd) +{ + char c; + + while (read(fd, &c, 1) == 1) { + if (iseol(c)) + break; + } +} diff --git a/sys/boot/common/help.common b/sys/boot/common/help.common index 2ad539c0eb..ea006f3327 100644 --- a/sys/boot/common/help.common +++ b/sys/boot/common/help.common @@ -11,18 +11,81 @@ described by the term. A term enclosed with [...] is optional, and may not be required by all forms of the command. - Some commands may not be available. Use the '?' command to list - most available commands. + Some commands may not be available in `help'. Use the `?' command + to list most available commands. - If needed, disable the use of ACPI with: + To boot another kernel than the default in kernel/, change directory + to the kernel directory, and execute `loadall' and `boot' commands. + E.g. to do a verbose boot of kernel in kernel.XXX/: - unset acpi_load - set hint.acpi.0.disabled="1" + cd + cd kernel.XXX + loadall + boot -v - If needed, disable the use of EHCI with: + If needed, disable the ACPI driver with: - unset ehci_load - set hint.ehci.0.disabled="1" + unset acpi_load + set hint.acpi.0.disabled=1 + + If needed, disable the AHCI driver with: + + unset ahci_load + set hint.ahci.0.disabled=1 + + If needed, disable the EHCI driver with: + + unset ehci_load + set hint.ehci.0.disabled=1 + + For more information on ACPI, AHCI and EHCI use `help' on these topics. + +################################################################################ +# T= DAssign value to variable + + = + + Assign value to variable. Value is always assigned to local variable + . If is in list of known kernel environment + variables or is a kernel tunable, it is also assigned to the kernel + environment variable of the given name. + is unset if is empty. + + Two kinds of variables are maintained by this program (loader(8)): + local variables, that is for loader(8) use only, and kernel + environment variables, that kernel will have access to when it starts. + The assignment described above, will assign to a local variable and, + if it seems applicable, also snoop assignment to kernel environment + variable. + +################################################################################ +# TAHCI DControl AHCI module behaviour + + $ahci_load + + The AHCI driver provides support for SATA controllers conforming to + the Advanced Host Controller Interface specification. + + The NATA driver provides support for some AHCI controllers, the AHCI + driver is used if both NATA and AHCI drivers provides support for a + controller. If AHCI driver is disabled, NATA driver will be used. + + If the ahci_load variable is set, the AHCI module will be loaded. + The AHCI driver can be disabled with: + + unset ahci_load + set hint.ahci.0.disabled=1 + + A link speed of 1.5Gb/s can be enforced with: + + set hint.ahci.force150=1 + + To refrain from attempting to send some higher level ATA commands + which some devices might not properly implement use: + + set hint.ahci.nofeatures=1 + + See ahci.4 man page (on booted system) for full description. ################################################################################ # Tautoboot DBoot after a delay @@ -36,12 +99,27 @@ ################################################################################ # Tboot DBoot immediately - boot [] [- ...] + boot [- ...] [] - Boot the system. If arguments are specified, they are added to the + Boot the system. If flags are specified, they are added to the arguments for the kernel. If is specified, and a kernel has not already been loaded, it will be booted instead of the default - kernel. + kernel. values include: + -a Same as `set boot_askname' + -C Same as `set boot_cdrom' + -c Same as `set boot_userconfig' + -d Same as `set boot_ddb' + -g Same as `set boot_gdb' + -h Same as `set boot_serial' + -m Mute the system console + -p Pause after each attached device during device probing phase + -r Use statically configured device for root file system + -s Same as `set boot_single' + -V Same as `set boot_vidcons' + -v Same as `set boot_verbose' + + s can also be set via kernel_options variable. + See also boot.8 man page (on booted system) for values. ################################################################################ # Techo DEcho arguments @@ -51,7 +129,7 @@ Emits , with no trailing newline if -n is specified. This is most useful in conjunction with scripts and the '@' line prefix. - Variables are substituted by prefixing them with $, eg. + Variables are substituted by prefixing them with $, e.g. echo Current device is $currdev @@ -62,24 +140,31 @@ $ehci_load + The EHCI driver provides support for the USB Enhanched Host Controller + Interface, which is used by USB 2.0 controllers. + If the ehci_load variable is set, the EHCI module will be loaded. - The use of EHCI can be disabled with: + The EHCI driver can be disabled with: + + unset ehci_load + set hint.ehci.0.disabled=1 - unset ehci_load - set hint.ehci.0.disabled="1" + See ehci.4 man page (on booted system) for full description. ################################################################################ # Tload DLoad a kernel or module - - load [-t ] - Loads the module contained in into memory. If no other - modules are loaded, must be a kernel or the command will - fail. + load [-t ] [ ...] + + Loads the module contained in into memory. If no other modules + are loaded, must be a kernel or the command will fail. If -t is specified, the module is loaded as raw data of , for later use by the kernel or other modules. may be any string. + Any arguments passed after the name of the file to be loaded will be + passed as arguments to that file. + ################################################################################ # Tls DList files @@ -92,26 +177,28 @@ file sizes on some media may be very slow. ################################################################################ -# Tlsdev DList devices +# Tlsdev DList all devices lsdev [-v] - List all of the devices from which it may be possible to load modules. - If -v is specified, print more details. + List all devices. Disk slices and partitions from which it may be + possible to load modules are marked with '*'. + If -v is specified, print more details, like size and position of + disk slices and partitions. ################################################################################ # Tlsmod DList modules lsmod [-v] - List loaded modules. If [-v] is specified, print more details. + List loaded modules. If -v is specified, print more details. ################################################################################ # Tmore DPage files - more [ ...] + more ... - Show contents of text files. When displaying the contents of more, + Show contents of text files. When displaying the contents of more, than one file, if the user elects to quit displaying a file, the remaining files will not be shown. @@ -128,12 +215,15 @@ be printed. ################################################################################ -# Tset DSet a variable +# Tset DSet a kernel environment variable + + set + set = - set - set = + The set command is used to set kernel environment variables. - The set command is used to set variables. + See also `=' command for distinction on local and + kernel environment variables. ################################################################################ # Tset Sautoboot_delay DSet the default autoboot delay @@ -145,12 +235,12 @@ ################################################################################ # Tset Sbootfile DSet the default boot file set - set bootfile=[;...] + set bootfile=[;...] - Sets the default set of kernel boot filename(s). It may be overridden + Sets the default set of kernel boot filename(s). It may be overridden by setting the bootfile variable to a semicolon-separated list of filenames, each of which will be searched for in the module_path - directories. The default bootfile set is "kernel". + directories. The default bootfile set is "kernel". ################################################################################ # Tset Sboot_askname DPrompt for root device @@ -160,6 +250,13 @@ Instructs the kernel to prompt the user for the name of the root device when the kernel is booted. +################################################################################ +# Tset Sboot_cdrom DBoot from CDROM + + set boot_cdrom + + Instructs the kernel to boot from CDROM when the kernel is booted. + ################################################################################ # Tset Sboot_ddb DDrop to the kernel debugger (DDB) @@ -183,28 +280,54 @@ Prevents the kernel from initiating a multi-user startup, single-user mode will be entered when the kernel has finished device probes. +################################################################################ +# Tset Sboot_serial DUse serial console after boot + + set boot_serial + + Use serial console after boot. See also `set console' command. + ################################################################################ # Tset Sboot_verbose DVerbose boot messages set boot_verbose Setting this variable causes extra debugging information to be printed - by the kernel during the boot phase. + by the kernel especially during the boot phase. + +################################################################################ +# Tset Sboot_vidcons DUse video console after boot + + set boot_vidcons + + Use video console after boot. See also `set console' command. + +################################################################################ +# Tset Skernel_options DKernel options + + set kernel_options + + Set kernel boot flags. E.g.: + + set kernel_options="-v -a" + + See also boot command; kernel_options sets default . ################################################################################ # Tset Sconsole DSet the current console set console[=] - Sets the current console. If is omitted, a list of valid - consoles will be displayed. + Sets the current console. include `vidconsole', `comconsole' + and `nullconsole'. If is omitted, a list of valid consoles + will be displayed. ################################################################################ # Tset Scurrdev DSet the current device set currdev= - Selects the default device. See lsdev for available devices. + Selects the default device. See `lsdev' for available devices. ################################################################################ # Tset Sinit_path DSet the list of init candidates @@ -221,8 +344,9 @@ set module_path=[;...] Sets the list of directories which will be searched in for modules - named in a load command or implicitly required by a dependency. The - default module_path is "/boot;/boot/modules;/;/modules". + named in a load command or implicitly required by a dependency. An + Empty specifies the current directory. The default module_path + is ";modules". ################################################################################ # Tset Sprompt DSet the command prompt @@ -230,10 +354,8 @@ set prompt= The command prompt is displayed when the loader is waiting for input. - Variable substitution is performed on the prompt. The default - prompt can be set with: - - set prompt=\${interpret} + Variable substitution is performed on the prompt. The default value + is "OK". ################################################################################ # Tset Srootdev DSet the root filesystem @@ -247,9 +369,58 @@ ################################################################################ # Tset Stunables DSet kernel tunable values - Various kernel tunable parameters can be overridden by specifying new + Various kernel tunable parameters can be overridden by specifying new values in the environment. + set hw.pci.allow_unsupported_io_range= + + Allow the PCI Bridge to pass through an unsupported + memory range assigned by the BIOS. + + value is 0 (default) or non-zero to enable. + + set hw.pci.enable_io_modes= + + Enable PCI resources which are left off by some BIOSes + or are not enabled correctly by the device driver. + + value is 1 (default), but this may cause problems with + some peripherals. Set to 0 to disable. + + set hw.physmem= MAXMEM + + Limits the amount of physical memory space available to + the system to bytes. may have a `k', `M' or + `G' suffix to indicate kilobytes, megabytes and gigabytes + respectively. Note that the current i386 architecture + limits this value to 4GB. + + On systems where memory cannot be accurately probed, + this option provides a hint as to the actual size of + system memory (which will be tested before use). + + set hw.syscons.sc_no_suspend_vtswitch= + + Disable VT switching on suspend. + + value is 0 (default) or non-zero to enable. + + set kern.emergence_intr_enable= + + Setting this to 1 enables emergency interrupt polling. All + interrupt handlers are executed periodically. This mode is + very expensive and should only be used to get a system + accessible when interrupt routing is otherwise broken. It + is primarily used by kernel developers to debug new systems. + + set kern.emergence_intr_freq= + + Set the polling rate for the emergency interrupt polling + code. The default is 10 (hz) to dissuade causual use. If + you are doing real work with emergency interrupt polling + mode enabled, it is recommended that you use a frequency + between 100hz and 300hz. + set kern.ipc.nmbclusters= NMBCLUSTERS Set the number of mbuf clusters to be allocated. The value @@ -270,66 +441,163 @@ Overrides the compile-time set value of TCBHASHSIZE or the preset default of 512. Must be a power of 2. - hw.syscons.sc_no_suspend_vtswitch= + set vfs.root.mountfrom= - Disable VT switching on suspend. + Specify root file system. is a semicolon separated + list of file systems. File system format is file system type + and disk store, separated by colon. This variable needs to be + set when using boot-only partition, which is typically mounted + on root file system as /boot. - value is 0 (default) or non-zero to enable. + One file system example: + hammer:da8se1a - set hw.physmem= MAXMEM (i386 only) + One file system HAMMER multi volume examples: + hammer:da8s1a:da9s1a - Limits the amount of physical memory space available to - the system to bytes. may have a k, M or G - suffix to indicate kilobytes, megabytes and gigabytes - respectively. Note that the current i386 architecture - limits this value to 4GB. + Several file systems, boot list, example: + ufs:da0s1a;hammer:ad1s1d - On systems where memory cannot be accurately probed, - this option provides a hint as to the actual size of - system memory (which will be tested before use). + Each file system in the list will be tried in the order + specified until the mount succeeds. If all fail, the + `mountroot>' prompt is displayed for manual entry. - set hw.pci.allow_unsupported_io_range= + You may not specify devtab labels here but you can specify + paths available to devfs such as: + hammer:serno/L41JYE0G.s1d - Allow the PCI Bridge to pass through an unsupported - memory range assigned by the BIOS. +################################################################################ +# Tshow DShow values of kernel environment variable - value is 0 (default) or non-zero to enable. + show [] - set hw.pci.enable_io_modes= + Displays the value of , or all kernel environment + variables if not specified. - Enable PCI resources which are left off by some BIOSes - or are not enabled correctly by the device driver. - - value is 1 (default), but this may cause problems with - some peripherals. Set to 0 to disable. + See also `=' command for distinction on local and + kernel environment variables. ################################################################################ -# Tshow DShow the values of variables +# Tinclude DExecute script file - show [] + include ... - Displays the value of , or all variables if not specified. - Multiple paths can be separated with a semicolon. + The entire contents of are read into memory before executing + commands, so it is safe to source a file from removable media. ################################################################################ -# Tinclude DRead commands from a script file +# Toptinclude DExecute script file; ignore exit status - include [ ...] + optinclude ... - The entire contents of are read into memory before executing + The entire contents of are read into memory before executing commands, so it is safe to source a file from removable media. + Return success and execute all commands even if some commands fail. + +################################################################################ +# Tcd DChange directory + + cd [] + + Change working directory to . Default is $base. + +################################################################################ +# Toptcd DChange directory; ignore exit status + + optcd [] + + Change working directory to . Default is $base. + Return success even if changing directory fails. + +################################################################################ +# Tpwd DPrint working directory + + pwd + + Show working directory. + +################################################################################ +# Tlocal DList local variables + + local [ ...] + + Display the value of given local variables, or all variables if not + specified. + + See also `=' command for distinction on local and + kernel environment variables. + +################################################################################ +# Tlunset DUnset local variable + + lunset + + Unset local variable: discard value and remove variable. + + See also `=' command for distinction on local and + kernel environment variables. + +################################################################################ +# Tlunsetif DUnset local variables if envvar true + + lunsetif + + Unset if is true, i.e. set to 1 or YES. + + See also `=' command for distinction on local and + kernel environment variables. + +################################################################################ +# Tloadall DLoad kernel + modules + + loadall + + Load kernel and all modules specified by MODULE_load variables. + +################################################################################ +# Tmenuclear DClear all menus + + menuclear + + Clear all menu bullets. + +################################################################################ +# Tmenuitem DAdd menu bullet + + menuitem + + Start new menu bullet, when running menu system bullet is choosen by + pressing . E.g.: + + menuitem a "Boot Backup kernel kernel.alt" + +################################################################################ +# Tmenuadd DAdd script line for menu bullet + + menuadd + + Add script line for current menu bullet. E.g.: + + menuadd lunsetif acpi_load hint.acpi.0.disabled + +################################################################################ +# Tmenu DRun menu system + + menu + + Run menu system. ################################################################################ # Tread DRead input from the terminal - read [-t ] [-p ] [] + read [-t ] [-p ] [] - The read command reads a line of input from the terminal. If the + The read command reads a line of input from the terminal. If the -t argument is specified, it will return nothing if no input has been - received after seconds. (Any keypress will cancel the + received after seconds. (Any keypress will cancel the timeout). - If -p is specified, is printed before reading input. No + If -p is specified, is printed before reading input. No newline is emitted after the prompt. If a variable name is supplied, the variable is set to the value read, @@ -343,11 +611,14 @@ This command removes any kernel and all loaded modules from memory. ################################################################################ -# Tunset DUnset a variable +# Tunset DUnset a kernel environment variable + + unset - unset + If allowed, the named kernel environment variable's value is discarded + and the variable is removed. - If allowed, the named variable's value is discarded and the variable - is removed. + See also `=' command for distinction on local and + kernel environment variables. ################################################################################ diff --git a/sys/boot/common/loader.8 b/sys/boot/common/loader.8 index 0dd9243bbe..aa1a770667 100644 --- a/sys/boot/common/loader.8 +++ b/sys/boot/common/loader.8 @@ -26,7 +26,7 @@ .\" .\" Note: The date here should be updated whenever a non-trivial .\" change is made to the manual page. -.Dd July 4, 2010 +.Dd October 6, 2010 .Dt LOADER 8 .Os .Sh NAME @@ -38,10 +38,10 @@ The program called is the final stage of .Dx Ns 's kernel bootstrapping process. -On IA32 (i386) architectures, it is a -.Pa BTX -client. -It is linked statically to +It is implemented as a +.Tn BTX +client and +is linked statically to .Xr libstand 3 and located in the .Pa /boot @@ -62,7 +62,7 @@ in either or .Pa /boot directory on the boot file system. -If boot and root are the same file systems, then files used by +If boot and root are the same file system, then files used by .Nm are located in .Pa /boot . @@ -74,21 +74,6 @@ on the boot file system, which is mounted as .Pa /boot on the root file system when the kernel is running. .Pp -.Nm -provides a scripting language that can be used to -automate tasks, do pre-configuration or assist in recovery -procedures. -This scripting language is roughly divided in -two main components. -The smaller one is a set of commands -designed for direct use by the casual user, called "builtin -commands" for historical reasons. -The main drive behind these commands is user-friendliness. -The bigger component is an -.Tn ANS -Forth compatible Forth interpreter based on FICL, by -.An John Sadler . -.Pp During initialization, .Nm will probe for a console and set the @@ -103,23 +88,8 @@ and are set, and .Va LINES is set to 24. -Next, -.Tn FICL -is initialized, the builtin words are added to its vocabulary, and -.Pa boot.4th -is processed if it exists. -No disk switching is possible while that file is being read. -The inner interpreter -.Nm -will use with -.Tn FICL -is then set to -.Ic interpret , -which is -.Tn FICL Ns 's -default. After that, -.Pa loader.rc +.Pa dloader.rc is processed if available, and, failing that, .Pa boot.conf is read for historical reasons. @@ -146,23 +116,34 @@ will engage interactive mode. In .Nm , builtin commands take parameters from the command line. -Presently, -the only way to call them from a script is by using -.Pa evaluate -on a string. -If an error condition occurs, an exception will be generated, -which can be intercepted using -.Tn ANS -Forth exception handling -words. -If not intercepted, an error message will be displayed and -the interpreter's state will be reset, emptying the stack and restoring -interpreting mode. .Pp The builtin commands available are: .Pp -.Bl -tag -width Ds -compact -.It Ic autoboot Op Ar seconds +.Bl -tag -width indent -compact +.It Ar variable Ns = Ns Ar value +Assign +.Ar value +to +.Ar variable . +Value is always assigned to local variable +.Ar variable . +If +.Ar variable +is in list of known kernel environment variables or +is a kernel tunable, +it is also assigned to the kernel environment variable of the given name. +.Ar variable +is unset if +.Ar value , +is empty. +.Pp +In other words, +the assignment described above, will assign to a local variable and +if it seems applicable, also snoop assignment to kernel environment variable. +See also +.Sx ENVIRONMENT VARIABLES AND LOCAL VARIABLES . +.Pp +.It Ic autoboot Op Ar delay Op Ar prompt Proceeds to bootstrap the system after a number of seconds, if not interrupted by the user. Displays a countdown prompt @@ -175,9 +156,7 @@ Defaults to 10 seconds. Displays statistics about disk cache usage. For depuration only. .Pp -.It Ic boot -.It Ic boot Ar kernelname Op Cm ... -.It Ic boot Fl flag Cm ... +.It Ic boot Oo Fl Ns Ar flag ... Oc Op Ar kernelname Immediately proceeds to bootstrap the system, loading the kernel if necessary. Any flags or arguments are passed to the kernel, but they @@ -185,10 +164,12 @@ must precede the kernel name, if a kernel name is provided. Flags are described in .Xr boot 8 . .Pp -.It Ic echo Xo -.Op Fl n -.Op Aq message -.Xc +.It Ic cd Op Ar directory +Change working directory to +.Ar directory . +Default is $base. +.Pp +.It Ic echo Oo Fl n Oc Op Ar message Displays text on the screen. A new line will be printed unless .Fl n @@ -198,38 +179,43 @@ is specified. Displays memory usage statistics. For debugging purposes only. .Pp -.It Ic help Op topic Op subtopic +.It Ic help Op Ar topic Op Ar subtopic Shows help messages read from .Pa loader.help . -The special topic -.Em index -will list the topics available. +The special +.Ar topic +.Cm index +will list all topics available. .Pp -.It Ic include Ar file Op Ar +.It Ic include Ar Process script files. 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 include command aborts immediately, without reading any other files, and -returns an error itself (see -.Sx ERRORS ) . +returns an error itself. .Pp -.It Ic load Xo -.Op Fl t Ar type -.Ar file Cm ... -.Xc +.It Ic load Oo Fl t Ar type Oc Ar file Op Ar argument ... Loads a kernel, kernel loadable module (kld), or file of opaque contents tagged as being of the type .Ar type . -Kernel and modules can be either in a.out or ELF format. +Kernel and modules can be either in a.out or +.Tn ELF +format. Any arguments passed after the name of the file to be loaded will be passed as arguments to that file. Currently, argument passing does not work for the kernel. .Pp -.It Ic ls Xo -.Op Fl l -.Op Ar path -.Xc +.It Ic loadall +Load kernel and all modules specified by MODULE_load variables. +.Pp +.It Ic local Op Ar local_variable ... +Displays the specified variable's value, or all local variables and their +values if +.Ar local_variable +is not specified. +.Pp +.It Ic ls Oo Fl l Oc Op Ar path Displays a listing of files in the directory .Ar path , or the root directory if @@ -240,13 +226,15 @@ If is specified, file sizes will be shown too. .Pp .It Ic lsdev Op Fl v -Lists all devices with known file systems, where a +Lists all devices. +A .Sq * -prefix indicates a device from which it may be +prefix indicates a disk slice or partition from which it may be possible to load modules. If .Fl v -is specified, more details are printed. +is specified, more details, +like disk slice or partition size and position, are printed. .Pp .It Ic lsmod Op Fl v Displays loaded modules. @@ -254,22 +242,66 @@ If .Fl v is specified, more details are shown. .Pp -.It Ic more Ar file Op Ar +.It Ic lunset Ar local_variable +Unset local variable: discard value and remove variable. +.Pp +.It Ic lunsetif Ar local_variable env_variable +Unset +.Ar local_variable +if +.Ar env_variable +is true, i.e.\& set to 1 or +.Ql YES . +.Pp +.It Ic menu +Run menu system. +.Pp +.It Ic menuadd Ar command_line +Add script line for current menu bullet. +.Pp +.It Ic menuclear +Clear all menu bullets. +.Pp +.It Ic menuitem Ar key description +Start new menu bullet. +When running menu system, a line with +.Ar key +and +.Ar description +is displayed, and bullet is choosen by pressing +.Ar key . +.Pp +.It Ic more Ar Display the files specified, with a pause at each .Va LINES displayed. .Pp +.It Ic optcd Op Ar directory +Change working directory to +.Ar directory . +Default is $base. +Ignore errors. +This command is like +.Ic cd , +but ignores errors while changing directory. +.Pp +.It Ic optinclude Ar +Process script files. +Ignore errors. +This command is like +.Ic include , +but ignores errors while executing commands in included files. +.Pp .It Ic pnpscan Op Fl v Scans for Plug-and-Play devices. This is not functional at present. .Pp -.It Ic read Xo -.Op Fl t Ar seconds -.Op Fl p Ar prompt -.Op Va variable -.Xc +.It Ic pwd +Show working directory. +.Pp +.It Ic read Oo Fl t Ar seconds Oc Oo Fl p Ar prompt Oc Op Ar env_variable Reads a line of input from the terminal, storing it in -.Va variable +.Ar env_variable if specified. A timeout can be specified with .Fl t , @@ -281,39 +313,38 @@ flag. .It Ic reboot Immediately reboots the system. .Pp -.It Ic set Ar variable -.It Ic set Ar variable Ns = Ns Ar value -Set loader's environment variables. +.It Ic set Ar env_variable +.It Ic set Ar env_variable Ns = Ns Ar value +Set +.Nm Ns 's +environment variables. .Pp -.It Ic show Op Va variable -Displays the specified variable's value, or all variables and their -values if -.Va variable +.It Ic show Op Ar env_variable +Displays the specified kernel environment variable's value, +or all variables and their values if +.Ar env_variable is not specified. .Pp .It Ic unload Remove all modules from memory. .Pp -.It Ic unset Va variable +.It Ic unset Ar env_variable Removes -.Va variable +.Ar env_variable from the environment. .Pp .It Ic \&? -Same as -.Dq help index . +List most available commands with short help. .El -.Ss BUILTIN ENVIRONMENT VARIABLES +.Ss ENVIRONMENT VARIABLES AND LOCAL VARIABLES The .Nm -has actually two different kinds of -.Sq environment -variables. -There are ANS Forth's -.Em environmental queries , -and a separate space of environment variables used by builtins, which -are not directly available to Forth words. -It is the latter type that this section covers. +has actually two different kinds of variables. +There are +kernel environment variables, which is visible to the kernel when it is run, +and a separate space of local variables used by +.Nm , +which are not available to the kernel. .Pp Environment variables can be set and unset through the .Ic set @@ -323,11 +354,10 @@ builtins, and can have their values interactively examined through the use of the .Ic show builtin. -Their values can also be accessed as described in -.Sx BUILTIN PARSER . .Pp Notice that these environment variables are not inherited by any shell -after the system has been booted. +after the system has been booted, but can be examined by +.Xr kenv 1 . .Pp A few variables are set automatically by .Nm . @@ -336,8 +366,8 @@ Others can affect the behavior of either or the kernel at boot. Some options may require a value, while others define behavior just by being set. -Both types of builtin variables are described below. -.Bl -tag -width bootfile +Both types of variables are described below. +.Bl -tag -width indent .It Va acpi_load Unset this to disable automatic loading of the ACPI module. .It Va autoboot_delay @@ -353,7 +383,7 @@ If set to no .Ic autoboot will be automatically attempted after processing -.Pa loader.rc , +.Pa dloader.rc , though explicit .Ic autoboot Ns 's will be processed normally, defaulting to 10 seconds delay. @@ -373,7 +403,7 @@ Requests that the kernel's interactive device configuration program be run when the kernel is booted. .It Va boot_verbose Setting this variable causes extra debugging information to be printed -by the kernel during the boot phase. +by the kernel especially during the boot phase. .It Va bootfile List of semicolon-separated search path for bootable kernels. The default is @@ -391,17 +421,16 @@ process. The first matching binary is used. The default list is .Dq Li /sbin/init:/sbin/oinit:/sbin/init.bak . -.It Va interpret -Has the value -.Dq Li OK -if the Forth's current state is interpreting. .It Va LINES Define the number of lines on the screen, to be used by the pager. .It Va module_path -Sets the list of directories which will be searched for modules -named in a load command or implicitly required by a dependency. +Sets the list of directories which will be searched for modules named in a +.Nm load +command or implicitly required by a dependency. The default value for this variable is -.Dq Li /boot;/boot/modules;/;/modules . +.Dq Li ;modules , +which first searches the current working directory and then +.Pa modules . .It Va num_ide_disks Sets the number of IDE disks as a workaround for some problems in finding the root disk at boot. @@ -412,11 +441,17 @@ Value of .Nm Ns 's prompt. Defaults to -.Dq Li "\e${interpret}" . +.Dq Li OK . .It Va root_disk_unit If the code which detects the disk unit number for the root disk is -confused, e.g. by a mix of SCSI and IDE disks, or IDE disks with -gaps in the sequence (e.g. no primary slave), the unit number can +confused, e.g.\& by a mix of +.Tn SCSI +and +.Tn IDE +disks, or +.Tn IDE +disks with +gaps in the sequence (e.g.\& no primary slave), the unit number can be forced by setting this variable. .It Va rootdev By default the value of @@ -432,21 +467,25 @@ of a panic. This automatically sets the .Va kern.dumpdev .Xr sysctl 3 -MIB variable. +.Tn MIB +variable. .El .Pp Other variables are used to override kernel tunable parameters. The following .Nm tunables are available: -.Bl -tag -width Va +.Bl -tag -width indent .It Va hw.irq.X.dest -Set irqX's destination to the given CPUID, +Set irqX's destination to the given +.Tn CPUID , which starts from 0. -If the specified value is larger than the last CPUID, +If the specified value is larger than the last +.Tn CPUID , then the first CPUID will be used. -This variable should not be used if IO/APIC support is not compiled -into kernel. +This variable should not be used if +.Tn IO/APIC +support is not compiled into kernel. .It Va hw.physmem Limit the amount of physical memory the system will use. By default the size is in bytes, but the @@ -462,21 +501,23 @@ kernel. The USB keyboard will sometimes not attach properly unless you set this variable to 0. .It Va kern.emergency_intr_enable -Setting this to 1 enables emergency interrupt polling. All interrupt -handlers are executed periodically. This mode is very expensive and should +Setting this to 1 enables emergency interrupt polling. +All interrupt +handlers are executed periodically. +This mode is very expensive and should only be used to get a system accessible when interrupt routing is -otherwise broken. It is primarily used by kernel developers to debug new -systems. +otherwise broken. +It is primarily used by kernel developers to debug new systems. .It Va kern.emergency_intr_freq -Set the polling rate for the emergency interrupt polling code. The -default is 10 (hz) to dissuade casual use. If you are doing real work +Set the polling rate for the emergency interrupt polling code. +The default is 10 (hz) to dissuade casual use. +If you are doing real work with emergency interrupt polling mode enabled, it is recommended that you use a frequency between 100hz and 300hz. .It Va kern.maxusers Set the size of a number of statically allocated system tables; see .Xr tuning 7 -for a description of how to select an appropriate value for this -tunable. +for a description of how to select an appropriate value for this tunable. When set, this tunable replaces the value declared in the kernel compile-time configuration file. .It Va kern.ipc.nmbclusters @@ -491,7 +532,9 @@ Toggles the mmx optimizations for the bcopy/copyin/copyout routines Sets the size of kernel memory (bytes). This overrides the value determined when the kernel was compiled. .It Va kern.maxswzone -Limits the amount of KVM to be used to hold swap +Limits the amount of +.Tn KVM +to be used to hold swap meta information, which directly governs the maximum amount of swap the system can support. This value is specified in bytes of KVA space @@ -505,7 +548,8 @@ the kernel to support a maximum of (approximately) 14GB of configured swap. Only mess around with this parameter if you need to greatly extend the -KVM reservation for other resources such as the +.Tn KVM +reservation for other resources such as the buffer cache or .Va NMBCLUSTERS . Modifies @@ -516,9 +560,12 @@ buffer cache, specified in bytes. The default maximum is 200MB. This parameter is used to prevent the buffer cache from eating too much -KVM in large-memory machine configurations. +.Tn KVM +in large-memory machine configurations. Only mess around with this parameter if you need to -greatly extend the KVM reservation for other resources +greatly extend the +.Tn KVM +reservation for other resources such as the swap zone or .Va NMBCLUSTERS . Note that @@ -526,308 +573,84 @@ the NBUF parameter will override this limit. Modifies .Va VM_BCACHE_SIZE_MAX . .It Va machdep.disable_mtrrs -Disable the use of i686 MTRRs (x86 only). +Disable the use of +.Sy i686 +.Tn MTRRs +(x86 only). .It Va net.inet.tcp.tcbhashsize Overrides the compile-time set value of .Va TCBHASHSIZE or the preset default of 512. Must be a power of 2. .It Va vfs.root.mountfrom -A semicolon separated list of partitions to try +Specify root file system. +A semicolon separated list of file systems to try as the kernel root file system. -Device format is file system type and partition, +File system format is file system type and disk store, separated by colon. -Used with boot-only partition, which is +This variable needs to be set when using boot-only partition, which is typically mounted on root file system as .Pa /boot . -.Bl -hyphen -.It -One device example: "hammer:da8s1a" -.It -Several devices example: "ufs:da0s1a;hammer:ad1s1d" -.El .Pp -Each device in the list will be tried in the order specified -until the mount succeeds. -If all fail, the -.Li mountroot> -prompt is displayed for manual entry. +One file system example: +.Dl hammer:da8s1a .Pp -You may not specify devtab labels here but you can specify paths available -to devfs such as "hammer:serno/L41JYE0G.s1d". -.El -.Ss BUILTIN PARSER -When a builtin command is executed, the rest of the line is taken -by it as arguments, and it is processed by a special parser which -is not used for regular Forth commands. -.Pp -This special parser applies the following rules to the parsed text: -.Bl -enum -.It -All backslash characters are preprocessed. -.Bl -bullet -.It -\eb , \ef , \er , \en and \et are processed as in C. -.It -\es is converted to a space. -.It -\ev is converted to -.Tn ASCII -11. -.It -\ez is just skipped. -Useful for things like -.Dq \e0xf\ez\e0xf . -.It -\e0xN and \e0xNN are replaced by the hex N or NN. -.It -\eNNN is replaced by the octal NNN -.Tn ASCII -character. -.It -\e" , \e' and \e$ will escape these characters, preventing them from -receiving special treatment in Step 2, described below. -.It -\e\e will be replaced with a single \e . -.It -In any other occurrence, backslash will just be removed. -.El -.It -Every string between non-escaped quotes or double-quotes will be treated -as a single word for the purposes of the remaining steps. -.It -Replace any -.Li $VARIABLE -or -.Li ${VARIABLE} -with the value of the environment variable -.Va VARIABLE . -.It -Space-delimited arguments are passed to the called builtin command. -Spaces can also be escaped through the use of \e\e . -.El +One file system +.Nm HAMMER +multi volume example: +.Dl hammer:da8s1a:da9s1a .Pp -An exception to this parsing rule exists, and is described in -.Sx BUILTINS AND FORTH . -.Ss BUILTINS AND FORTH -All builtin words are state-smart, immediate words. -If interpreted, they behave exactly as described previously. -If they are compiled, though, -they extract their arguments from the stack instead of the command line. -.Pp -If compiled, the builtin words expect to find, at execution time, the -following parameters on the stack: -.D1 Ar addrN lenN ... addr2 len2 addr1 len1 N -where -.Ar addrX lenX -are strings which will compose the command line that will be parsed -into the builtin's arguments. -Internally, these strings are concatenated in from 1 to N, -with a space put between each one. -.Pp -If no arguments are passed, a 0 -.Em must -be passed, even if the builtin accepts no arguments. -.Pp -While this behavior has benefits, it has its trade-offs. -If the execution token of a builtin is acquired (through -.Ic ' -or -.Ic ['] ) , -and then passed to -.Ic catch -or -.Ic execute , -the builtin behavior will depend on the system state -.Bf Em -at the time -.Ic catch -or -.Ic execute -is processed -.Ef -\&! This is particularly annoying for programs that want or need to -handle exceptions. -In this case, the use of a proxy is recommended. -For example: -.Dl : (boot) boot \&; -.Sh FICL -.Tn FICL -is a Forth interpreter written in C, in the form of a forth -virtual machine library that can be called by C functions and vice -versa. +Several file systems, boot list, example: +.Dl ufs:da0s1a;hammer:ad1s1d .Pp -In -.Nm , -each line read interactively is then fed to -.Tn FICL , -which may call -.Nm -back to execute the builtin words. -The builtin -.Ic include -will also feed -.Tn FICL , -one line at a time. +Each file system in the list will be tried in the order specified +until the mount succeeds. +If all fail, the +.Ql mountroot> +prompt is displayed for manual entry. .Pp -The words available to -.Tn FICL -can be classified into four groups. -The -.Tn ANS -Forth standard words, extra -.Tn FICL -words, extra -.Dx -words, and the builtin commands; -the latter were already described. -The -.Tn ANS -Forth standard words are listed in the -.Sx STANDARDS -section. -The words falling in the two other groups are described in the -following subsections. -.Ss FICL EXTRA WORDS -.Bl -tag -width wid-set-super -.It Ic .env -.It Ic .ver -.It Ic -roll -.It Ic 2constant -.It Ic >name -.It Ic body> -.It Ic compare -This is the STRING word set's -.Ic compare . -.It Ic compile-only -.It Ic endif -.It Ic forget-wid -.It Ic parse-word -.It Ic sliteral -This is the STRING word set's -.Ic sliteral . -.It Ic wid-set-super -.It Ic w@ -.It Ic w! -.It Ic x. -.It Ic empty -.It Ic cell- -.It Ic -rot -.El -.Ss DRAGONFLY EXTRA WORDS -.Bl -tag -width XXXXXXXX -.It Ic \&$ Pq -- -Evaluates the remainder of the input buffer, after having printed it first. -.It Ic \&% Pq -- -Evaluates the remainder of the input buffer under a -.Ic catch -exception guard. -.It Ic .# -Works like -.Ic . -but without outputting a trailing space. -.It Ic fclose Pq Ar fd -- -Closes a file. -.It Ic fkey Pq Ar fd -- char -Reads a single character from a file. -.It Ic fload Pq Ar fd -- -Processes a file -.Em fd . -.It Ic fopen Pq Ar addr len mode Li -- Ar fd -Opens a file. -Returns a file descriptor, or \-1 in case of failure. -The -.Ar mode -parameter selects whether the file is to be opened for read access, write -access, or both. -The constants -.Dv O_RDONLY , O_WRONLY , -and -.Dv O_RDWR -are defined in -.Pa support.4th , -indicating read only, write only, and read-write access, respectively. -.It Xo -.Ic fread -.Pq Ar fd addr len -- len' -.Xc -Tries to read -.Em len -bytes from file -.Em fd -into buffer -.Em addr . -Returns the actual number of bytes read, or -1 in case of error or end of -file. -.It Ic heap? Pq -- Ar cells -Return the space remaining in the dictionary heap, in cells. -This is not related to the heap used by dynamic memory allocation words. -.It Ic inb Pq Ar port -- char -Reads a byte from a port. -.It Ic key Pq -- Ar char -Reads a single character from the console. -.It Ic key? Pq -- Ar flag -Returns -.Ic true -if there is a character available to be read from the console. -.It Ic ms Pq Ar u -- -Waits -.Em u -microseconds. -.It Ic outb Pq Ar port char -- -Writes a byte to a port. -.It Ic seconds Pq -- Ar u -Returns the number of seconds since midnight. -.It Ic tib> Pq -- Ar addr len -Returns the remainder of the input buffer as a string on the stack. -.It Ic trace! Pq Ar flag -- -Activates or deactivates tracing. -Does not work with -.Ic catch . -.El -.Ss DRAGONFLY DEFINED ENVIRONMENTAL QUERIES -.Bl -tag -width Ds -.It arch-i386 -.Ic TRUE -if the architecture is IA32. -.It DragonFly_version -.Dx -version at compile time. -.It loader_version -.Nm -version. +You may not specify devtab labels here but you can specify paths available to +.Nm devfs +such as: +.Dl hammer:serno/L41JYE0G.s1d .El -.Ss SYSTEM DOCUMENTATION .Sh FILES -.Bl -tag -width /boot/defaults/loader.conf -compact -.It Pa /boot/loader -.Nm -itself. -.It Pa /boot/boot.4th -Additional -.Tn FICL -initialization. +.Bl -tag -width /boot/defaults/dloader.menu -compact .It Pa /boot/boot.conf .Nm bootstrapping script. Deprecated. +.It Pa /boot/loader +.Nm +itself. +.It Pa /boot/defaults/dloader.menu +.Nm +menu setup commands -- do not change this file. .It Pa /boot/defaults/loader.conf +.Nm +configuration file, see +.Xr loader.conf 5 +-- do not change this file. +.It Pa /boot/dloader.menu +.Nm +menu setup commands. +.It Pa /boot/dloader.rc +.Nm +bootstrapping script. .It Pa /boot/loader.conf .It Pa /boot/loader.conf.local .Nm -configuration files, as described in +configuration files, see .Xr loader.conf 5 . -.It Pa /boot/loader.rc -.Nm -bootstrapping script. .It Pa /boot/loader.help -Loaded by -.Ic help . -Contains the help messages. +help messages, used by +.Ic help +command. .El .Sh EXAMPLES Boot in single user mode: .Pp +.Dl loadall .Dl boot -s .Pp Load kernel's user configuration file. @@ -849,81 +672,32 @@ autoboot 5 .Pp Set the disk unit of the root device to 2, and then boot. This would be needed in a system with two IDE disks, -with the second IDE disk hardwired to ad2 instead of ad1. +with the second IDE disk hardwired to +.Pa ad2 +instead of +.Pa ad1 . .Bd -literal -offset indent set root_disk_unit=2 boot kernel .Ed -.Sh ERRORS -The following values are thrown by -.Nm : -.Bl -tag -width XXXXX -offset indent -.It 100 -Any type of error in the processing of a builtin. -.It -1 -.Ic Abort -executed. -.It -2 -.Ic Abort" -executed. -.It -56 -.Ic Quit -executed. -.It -256 -Out of interpreting text. -.It -257 -Need more text to succeed -- will finish on next run. -.It -258 -.Ic Bye -executed. -.It -259 -Unspecified error. -.El .Sh SEE ALSO .Xr libstand 3 , .Xr loader.conf 5 , .Xr tuning 7 , .Xr boot 8 , .Xr btxld 8 , +.Xr pxeboot 8 , +.Xr pxeboot_tftp 8 , .Xr sysctl 8 -.Sh STANDARDS -For the purposes of ANS Forth compliance, loader is an -.Bf Em -ANS Forth System with Environmental Restrictions, Providing -.Ef -.Bf Li -.No .( , -.No :noname , -.No ?do , -parse, pick, roll, refill, to, value, \e, false, true, -.No <> , -.No 0<> , -compile\&, , erase, nip, tuck -.Ef -.Em and -.Li marker -.Bf Em -from the Core Extensions word set, Providing the Exception Extensions -word set, Providing the Locals Extensions word set, Providing the -Memory-Allocation Extensions word set, Providing -.Ef -.Bf Li -\&.s, -bye, forget, see, words, -\&[if], -\&[else] -.Ef -.Em and -.Li [then] -.Bf Em -from the Programming-Tools extension word set, Providing the -Search-Order extensions word set. -.Ef .Sh HISTORY The .Nm first appeared in .Fx 3.1 . +dloader was introduced and +.Tn FORTH +removed in +.Dx 2.7 . .Sh AUTHORS .An -nosplit The @@ -931,13 +705,5 @@ The was written by .An Michael Smith Aq msmith@FreeBSD.org . .Pp -.Tn FICL -was written by -.An John Sadler Aq john_sadler@alum.mit.edu . -.Sh BUGS -The -.Ic expect -and -.Ic accept -words will read from the input buffer instead of the console. -The latter will be fixed, but the former will not. +dloader was written by +.An Matthew Dillon Aq dillon@backplane.com . diff --git a/sys/boot/common/rel_open.c b/sys/boot/common/rel_open.c index 728999c313..14df98811a 100644 --- a/sys/boot/common/rel_open.c +++ b/sys/boot/common/rel_open.c @@ -41,23 +41,35 @@ char *DirBase; COMMAND_SET(cd, "cd", "Change directory", command_chdir); -COMMAND_SET(optcd, "optcd", "Change directory", command_optchdir); +COMMAND_SET(optcd, "optcd", + "Change directory; ignore exit status", command_optchdir); int command_chdir(int ac, char **av) { - if (ac != 2) { - sprintf(command_errbuf, "Missing path"); - return(CMD_ERROR); + int result; + + if (ac == 1) { + result = chdir(getenv("base")); + } else if (ac == 2) { + result = chdir(av[1]); + } else { + sprintf(command_errbuf, "usage: cd []"); + result = CMD_ERROR; } - return(chdir(av[1])); + return result; } int command_optchdir(int ac, char **av) { - if (ac == 2) + if (ac == 1) { + chdir(getenv("base")); + } else if (ac == 2) { chdir(av[1]); + } else { + sprintf(command_errbuf, "usage: optcd []"); + } return(CMD_OK); } diff --git a/sys/boot/dloader/cmds.c b/sys/boot/dloader/cmds.c index 105a8f9122..051286222a 100644 --- a/sys/boot/dloader/cmds.c +++ b/sys/boot/dloader/cmds.c @@ -53,7 +53,7 @@ dloader_init_cmds(void) * This intercepts lines of the form 'a=b' */ COMMAND_SET(local, "local", "List local variables", command_local); -COMMAND_SET(lunset, "lunset", "Unset local variables", command_lunset); +COMMAND_SET(lunset, "lunset", "Unset local variable", command_lunset); COMMAND_SET(lunsetif, "lunsetif", "Unset local if envvar set to 1 or YES", command_lunsetif); COMMAND_SET(loadall, "loadall", "Load kernel + modules", command_loadall); COMMAND_SET(menuclear, "menuclear", "Clear all menus", command_menuclear); @@ -86,9 +86,12 @@ static char *kenv_vars[] = { }; /* - * Set local variable. Sniff "module_path" + * List or set local variable. Sniff assignment of kenv_vars[] and + * loader tunables (recognized by '.' in name). * - * format a=b (one argument) - in av[0] + * format for av[0]: + * - List: local + * - Set: var=val */ static int command_local(int ac, char **av) @@ -103,6 +106,7 @@ command_local(int ac, char **av) * local command executed directly. */ if (strcmp(av[0], "local") == 0) { + pager_open(); for (dvar = dvar_first(); dvar; dvar = dvar_next(dvar)) { for (j = 1; j < ac; ++j) { if (!strncmp(dvar->name, av[j], strlen(av[j]))) @@ -111,19 +115,23 @@ command_local(int ac, char **av) if (ac > 1 && j == ac) continue; - printf("%s=", dvar->name); + pager_output(dvar->name); + pager_output("="); for (i = 0; i < dvar->count; ++i) { if (i) - printf(","); - printf("\"%s\"", dvar->data[i]); + pager_output(","); + pager_output("\""); + pager_output(dvar->data[i]); + pager_output("\""); } - printf("\n"); + pager_output("\n"); } + pager_close(); return(CMD_OK); } /* - * local command intercept for blah=blah + * local command intercept for 'var=val' */ name = av[0]; data = strchr(name, '='); @@ -189,7 +197,7 @@ command_lunsetif(int ac, char **av) } /* - * Load the kernel + all modules specified with + * Load the kernel + all modules specified with MODULE_load="YES" */ static int command_loadall(int ac, char **av) @@ -373,6 +381,7 @@ command_menu(int ac, char **av) int c; int res; int counting = 1; + char *argv[4]; menu_display(); if ((cp = getenv("autoboot_delay")) != NULL) @@ -402,6 +411,9 @@ command_menu(int ac, char **av) } if (c == 0x1b) { setenv("autoboot_delay", "NO", 1); + argv[0] = "optcd"; + argv[1] = "kernel"; + (void)perform(2, argv); return(CMD_OK); } res = menu_execute(c); @@ -431,7 +443,7 @@ command_menu(int ac, char **av) return (res); } -#define LOGO_LINES 17 +#define LOGO_LINES 16 #define FRED_LEFT 0 #define FRED_RIGHT 1 static char *logo_blank_line = " "; @@ -440,7 +452,6 @@ static char *menu_header_right = "==================================== DragonFly static char *menu_footer = "===============================================================================\n"; static char *logo_color[LOGO_LINES] = { - " ", " ,--, | ,--, ", " | `-, ,^, ,-' | ", " `, `-, (/ \\) ,-' ,' ", @@ -459,7 +470,6 @@ static char *logo_color[LOGO_LINES] = { " " }; static char *logo_mono[LOGO_LINES] = { - " ", " ,--, | ,--, ", " | `-, ,^, ,-' | ", " `, `-, (/ \\) ,-' ,' ", @@ -493,7 +503,6 @@ static char *logo_blank[LOGO_LINES] = { " ", " ", " ", - " ", " " }; static void @@ -543,11 +552,11 @@ menu_display(void) while (dvar || i < LOGO_LINES) { if (logo_left) logo_display(logo, i, FRED_LEFT); - i++; while (dvar) { if (strncmp(dvar->name, "menu_", 5) == 0) { - printf(" %c. %-38.38s", dvar->name[5], dvar->data[0]); + printf(" %c. %-38.38s", + dvar->name[5], dvar->data[0]); dvar = dvar_next(dvar); break; } @@ -557,18 +566,17 @@ menu_display(void) * Pad when the number of menu entries is less than * LOGO_LINES. */ - if (dvar == NULL) { + if (dvar == NULL) printf(" %38.38s", " "); - } if (!logo_left) logo_display(logo, i, FRED_RIGHT); printf("\n"); + i++; } - if (logo != NULL) { + if (logo != NULL) printf(menu_footer); - } } static int diff --git a/sys/boot/dloader/loader-bootp.conf b/sys/boot/dloader/loader-bootp.conf index b04cc07539..fbb5b30ac8 100644 --- a/sys/boot/dloader/loader-bootp.conf +++ b/sys/boot/dloader/loader-bootp.conf @@ -13,8 +13,6 @@ ### Basic configuration options ############################ ############################################################## -exec=".( Loading /boot/defaults/loader-bootp.conf ) cr" - kernel="kernel.BOOTP" bootfile="kernel.BOOTP" # Kernel name (possibly absolute path) kernel_options="" @@ -23,12 +21,6 @@ userconfig_script_load="NO" userconfig_script_name="/boot/kernel-bootp.conf" userconfig_script_type="userconfig_script" -loader_conf_files="loader-bootp.conf loader-bootp.conf.local" -nextboot_conf="nextboot-bootp.conf" -nextboot_enable="NO" - -verbose_loading="NO" # Set to YES for verbose loader output - ############################################################## ### Splash screen configuration ############################ @@ -48,11 +40,12 @@ bitmap_type="splash_image_data" # and place it on the module_path #autoboot_delay="10" # Delay in seconds before autobooting #fred_disable="NO" # Turn Fred's boot menu on and off +#fred_on_left="NO" # Show Fred on left side of menu #loader_color="NO" # Set to YES for a color version of Fred #console="vidconsole" # Set the current console #currdev="disk1s1a" # Set the current device -module_path="/boot;/boot/modules;/;/modules" # Set the module search path -#prompt="\\${interpret}" # Set the command prompt +module_path=";modules" # Set the module search path +#prompt="OK" # Set the command prompt #root_disk_unit="0" # Force the root disk unit number #rootdev="disk1s1a" # Set the root filesystem diff --git a/sys/boot/dloader/loader.conf b/sys/boot/dloader/loader.conf index 253659a567..4b70117ccf 100644 --- a/sys/boot/dloader/loader.conf +++ b/sys/boot/dloader/loader.conf @@ -13,8 +13,6 @@ ### Basic configuration options ############################ ############################################################## -exec=".( Loading /boot/defaults/loader.conf ) cr" - kernel="kernel" bootfile="kernel" # Kernel name (possibly absolute path) kernel_options="" @@ -23,14 +21,6 @@ userconfig_script_load="NO" userconfig_script_name="/boot/kernel.conf" userconfig_script_type="userconfig_script" -# Must be accessible if either / or /boot is the boot directory. -# -loader_conf_files="loader.conf loader.conf.local" -nextboot_conf="nextboot.conf" -nextboot_enable="NO" - -verbose_loading="NO" # Set to YES for verbose loader output - ############################################################## ### Splash screen configuration ############################ @@ -50,11 +40,12 @@ bitmap_type="splash_image_data" # and place it on the module_path #autoboot_delay="10" # Delay in seconds before autobooting #fred_disable="NO" # Turn Fred's boot menu on and off +#fred_on_left="NO" # Show Fred on left side of menu #loader_color="NO" # Set to YES for a color version of Fred #console="vidconsole" # Set the current console #currdev="disk1s1a" # Set the current device #module_path=";modules" # Set the module search path -#prompt="\\${interpret}" # Set the command prompt +#prompt="OK" # Set the command prompt #root_disk_unit="0" # Force the root disk unit number #rootdev="disk1s1a" # Set the root filesystem diff --git a/sys/boot/dloader/subs.c b/sys/boot/dloader/subs.c index ee5fc50c38..1bbe4f5adb 100644 --- a/sys/boot/dloader/subs.c +++ b/sys/boot/dloader/subs.c @@ -143,9 +143,9 @@ dvar_istrue(dvar_t var) int retval = 0; if (var != NULL && (strcasecmp(var->data[0], "yes") == 0 || - strcasecmp(var->data[0], "true") == 0 || - strcasecmp(var->data[0], "on") == 0 || - strcasecmp(var->data[0], "1") == 0)) + strcasecmp(var->data[0], "true") == 0 || + strcasecmp(var->data[0], "on") == 0 || + strcasecmp(var->data[0], "1") == 0)) retval = 1; return (retval); diff --git a/sys/boot/pc32/loader/help.i386 b/sys/boot/pc32/loader/help.i386 index 84a61fe818..9d0ee642be 100644 --- a/sys/boot/pc32/loader/help.i386 +++ b/sys/boot/pc32/loader/help.i386 @@ -3,16 +3,21 @@ $acpi_load + The ACPI driver provides support for the Advanced Configuration and + Power Management standard. + If the acpi_load variable is set, the ACPI module will be loaded. - The use of ACPI can be disabled with: + The ACPI driver can be disabled with: - unset acpi_load - set hint.acpi.0.disabled="1" + unset acpi_load + set hint.acpi.0.disabled=1 Note that the ACPI autodetection sets a number of hints to pass information to the ACPI module. These should not be overridden, or system behaviour will be undefined. + See acpi.4 man page (on booted system) for full description. + ################################################################################ # Treboot DReboot the system @@ -20,6 +25,13 @@ Causes the system to immediately reboot. +################################################################################ +# Tbcachestat DDisplay disk block cache stats + + bcachestat + + Display disk block cache stats. For debugging use only. + ################################################################################ # Theap DDisplay memory management statistics @@ -54,8 +66,8 @@ set root_disk_unit= If the code which detects the disk unit number for the root disk is - confused, eg. by a mix of SCSI and IDE disks, or IDE disks with - gaps in the sequence (eg. no primary slave), the unit number can be + confused, e.g. by a mix of SCSI and IDE disks, or IDE disks with + gaps in the sequence (i.e. no primary slave), the unit number can be forced by setting this variable. ################################################################################ diff --git a/sys/boot/pc32/pxeldr/pxeboot.8 b/sys/boot/pc32/pxeldr/pxeboot.8 index dae74f2a54..3089621518 100644 --- a/sys/boot/pc32/pxeldr/pxeboot.8 +++ b/sys/boot/pc32/pxeldr/pxeboot.8 @@ -27,7 +27,7 @@ .\" .\" Note: The date here should be updated whenever a non-trivial .\" change is made to the manual page. -.Dd May 1, 2000 +.Dd October 6, 2010 .Dt PXEBOOT 8 .Os .Sh NAME @@ -85,20 +85,20 @@ respectively, or the server to make TFTP requests to. Note that .Nm expects to fetch -.Pa /boot/loader.rc +.Pa /boot/dloader.rc from the specified server before loading any other files. .Pp .Nm uses -.Pa /boot/kernel.BOOTP , -.Pa /boot/loader-bootp.conf , +.Pa /boot/kernel.BOOTP +and +.Pa /boot/loader-bootp.conf and .Pa nextboot-bootp.conf instead of -.Pa /boot/kernel , -.Pa /boot/loader.conf , +.Pa /boot/kernel and -.Pa nexboot.conf . +.Pa /boot/loader.conf . Note that the TFTP version .Xr pxeboot_tftp 8 uses the standard boot loader files. @@ -128,6 +128,18 @@ Check with the device's manufacturer for their latest stable release. For further information on Intel's PXE specifications and Wired for Management (WfM) systems, see .Pa http://developer.intel.com/ial/wfm/ . +.Sh FILES +.Bl -tag -width ".Pa /boot/defaults/loader-bootp.conf" -compact +.It Pa /boot/kernel.BOOTP +Default kernel for +.Nm . +.It Pa /boot/defaults/loader-bootp.conf +.Nm +configuration file -- do not change this file. +.It Pa /boot/loader-bootp.conf +.Nm +configuration file. +.El .Sh SEE ALSO .Xr dhcpd 8 Pq Pa pkgsrc/net/isc-dhcpd4 , .Xr diskless 8 , diff --git a/sys/boot/pc32/pxeldr_tftp/pxeboot_tftp.8 b/sys/boot/pc32/pxeldr_tftp/pxeboot_tftp.8 index b89650494d..19dd7bcfb1 100644 --- a/sys/boot/pc32/pxeldr_tftp/pxeboot_tftp.8 +++ b/sys/boot/pc32/pxeldr_tftp/pxeboot_tftp.8 @@ -27,7 +27,7 @@ .\" .\" Note: The date here should be updated whenever a non-trivial .\" change is made to the manual page. -.Dd May 1, 2000 +.Dd October 6, 2010 .Dt PXEBOOT_TFTP 8 .Os .Sh NAME @@ -84,7 +84,7 @@ respectively, or the server to make TFTP requests to. Note that .Nm expects to fetch -.Pa /boot/loader.rc +.Pa /boot/dloader.rc from the specified server before loading any other files. .Pp In all other respects, @@ -105,8 +105,12 @@ For further information on Intel's PXE specifications and Wired for Management (WfM) systems, see .Pa http://developer.intel.com/ial/wfm/ . .Sh SEE ALSO +.Xr dhcpd 8 Pq Pa pkgsrc/net/isc-dhcpd4 , +.Xr diskless 8 , .Xr loader 8 , -.Xr pxeboot 8 +.Xr nfsd 8 , +.Xr pxeboot 8 , +.Xr tftpd 8 .Sh HISTORY The .Nm -- 2.41.0