xref: /freebsd/stand/man/loader_4th.8 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
19e1dc7beSWarner Losh.\" Copyright (c) 1999 Daniel C. Sobral
29e1dc7beSWarner Losh.\" All rights reserved.
39e1dc7beSWarner Losh.\"
49e1dc7beSWarner Losh.\" Redistribution and use in source and binary forms, with or without
59e1dc7beSWarner Losh.\" modification, are permitted provided that the following conditions
69e1dc7beSWarner Losh.\" are met:
79e1dc7beSWarner Losh.\" 1. Redistributions of source code must retain the above copyright
89e1dc7beSWarner Losh.\"    notice, this list of conditions and the following disclaimer.
99e1dc7beSWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright
109e1dc7beSWarner Losh.\"    notice, this list of conditions and the following disclaimer in the
119e1dc7beSWarner Losh.\"    documentation and/or other materials provided with the distribution.
129e1dc7beSWarner Losh.\"
139e1dc7beSWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
149e1dc7beSWarner Losh.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
159e1dc7beSWarner Losh.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
169e1dc7beSWarner Losh.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
179e1dc7beSWarner Losh.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
189e1dc7beSWarner Losh.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199e1dc7beSWarner Losh.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
209e1dc7beSWarner Losh.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
219e1dc7beSWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
229e1dc7beSWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
239e1dc7beSWarner Losh.\" SUCH DAMAGE.
249e1dc7beSWarner Losh.\"
259e1dc7beSWarner Losh.Dd September 29, 2021
269e1dc7beSWarner Losh.Dt LOADER_4TH 8
279e1dc7beSWarner Losh.Os
289e1dc7beSWarner Losh.Sh NAME
299e1dc7beSWarner Losh.Nm loader_4th
309e1dc7beSWarner Losh.Nd kernel bootstrapping final stage
319e1dc7beSWarner Losh.Sh DESCRIPTION
329e1dc7beSWarner LoshThe program called
339e1dc7beSWarner Losh.Nm
349e1dc7beSWarner Loshis the final stage of
359e1dc7beSWarner Losh.Fx Ns 's
369e1dc7beSWarner Loshkernel bootstrapping process.
379e1dc7beSWarner LoshOn IA32 (i386) architectures, it is a
389e1dc7beSWarner Losh.Pa BTX
399e1dc7beSWarner Loshclient.
409e1dc7beSWarner LoshIt is linked statically to
41*11f49259SWarner Losh.Xr libsa 3
429e1dc7beSWarner Loshand usually located in the directory
439e1dc7beSWarner Losh.Pa /boot .
449e1dc7beSWarner Losh.Pp
459e1dc7beSWarner LoshIt provides a scripting language that can be used to
469e1dc7beSWarner Loshautomate tasks, do pre-configuration or assist in recovery
479e1dc7beSWarner Loshprocedures.
489e1dc7beSWarner LoshThis scripting language is roughly divided in
499e1dc7beSWarner Loshtwo main components.
509e1dc7beSWarner LoshThe smaller one is a set of commands
519e1dc7beSWarner Loshdesigned for direct use by the casual user, called "builtin
529e1dc7beSWarner Loshcommands" for historical reasons.
539e1dc7beSWarner LoshThe main drive behind these commands is user-friendliness.
549e1dc7beSWarner LoshThe bigger component is an
559e1dc7beSWarner Losh.Tn ANS
569e1dc7beSWarner LoshForth compatible Forth interpreter based on FICL, by
579e1dc7beSWarner Losh.An John Sadler .
589e1dc7beSWarner Losh.Pp
599e1dc7beSWarner LoshDuring initialization,
609e1dc7beSWarner Losh.Nm
619e1dc7beSWarner Loshwill probe for a console and set the
629e1dc7beSWarner Losh.Va console
639e1dc7beSWarner Loshvariable, or set it to serial console
649e1dc7beSWarner Losh.Pq Dq Li comconsole
659e1dc7beSWarner Loshif the previous boot stage used that.
669e1dc7beSWarner LoshIf multiple consoles are selected, they will be listed separated by spaces.
679e1dc7beSWarner LoshThen, devices are probed,
689e1dc7beSWarner Losh.Va currdev
699e1dc7beSWarner Loshand
709e1dc7beSWarner Losh.Va loaddev
719e1dc7beSWarner Loshare set, and
729e1dc7beSWarner Losh.Va LINES
739e1dc7beSWarner Loshis set to 24.
749e1dc7beSWarner LoshNext,
759e1dc7beSWarner Losh.Tn FICL
769e1dc7beSWarner Loshis initialized, the builtin words are added to its vocabulary, and
779e1dc7beSWarner Losh.Pa /boot/boot.4th
789e1dc7beSWarner Loshis processed if it exists.
799e1dc7beSWarner LoshNo disk switching is possible while that file is being read.
809e1dc7beSWarner LoshThe inner interpreter
819e1dc7beSWarner Losh.Nm
829e1dc7beSWarner Loshwill use with
839e1dc7beSWarner Losh.Tn FICL
849e1dc7beSWarner Loshis then set to
859e1dc7beSWarner Losh.Ic interpret ,
869e1dc7beSWarner Loshwhich is
879e1dc7beSWarner Losh.Tn FICL Ns 's
889e1dc7beSWarner Loshdefault.
899e1dc7beSWarner LoshAfter that,
909e1dc7beSWarner Losh.Pa /boot/loader.rc
919e1dc7beSWarner Loshis processed if available.
929e1dc7beSWarner LoshThese files are processed through the
939e1dc7beSWarner Losh.Ic include
949e1dc7beSWarner Loshcommand, which reads all of them into memory before processing them,
959e1dc7beSWarner Loshmaking disk changes possible.
969e1dc7beSWarner Losh.Pp
979e1dc7beSWarner LoshAt this point, if an
989e1dc7beSWarner Losh.Ic autoboot
999e1dc7beSWarner Loshhas not been tried, and if
1009e1dc7beSWarner Losh.Va autoboot_delay
1019e1dc7beSWarner Loshis not set to
1029e1dc7beSWarner Losh.Dq Li NO
1039e1dc7beSWarner Losh(not case sensitive), then an
1049e1dc7beSWarner Losh.Ic autoboot
1059e1dc7beSWarner Loshwill be tried.
1069e1dc7beSWarner LoshIf the system gets past this point,
1079e1dc7beSWarner Losh.Va prompt
1089e1dc7beSWarner Loshwill be set and
1099e1dc7beSWarner Losh.Nm
1109e1dc7beSWarner Loshwill engage interactive mode.
1119e1dc7beSWarner LoshPlease note that historically even when
1129e1dc7beSWarner Losh.Va autoboot_delay
1139e1dc7beSWarner Loshis set to
1149e1dc7beSWarner Losh.Dq Li 0
1159e1dc7beSWarner Loshuser will be able to interrupt autoboot process by pressing some key
1169e1dc7beSWarner Loshon the console while kernel and modules are being loaded.
1179e1dc7beSWarner LoshIn some
1189e1dc7beSWarner Loshcases such behaviour may be undesirable, to prevent it set
1199e1dc7beSWarner Losh.Va autoboot_delay
1209e1dc7beSWarner Loshto
1219e1dc7beSWarner Losh.Dq Li -1 ,
1229e1dc7beSWarner Loshin this case
1239e1dc7beSWarner Losh.Nm
1249e1dc7beSWarner Loshwill engage interactive mode only if
1259e1dc7beSWarner Losh.Ic autoboot
1269e1dc7beSWarner Loshhas failed.
1279e1dc7beSWarner Losh.Sh BUILTIN COMMANDS
1289e1dc7beSWarner LoshIn
1299e1dc7beSWarner Losh.Nm ,
1309e1dc7beSWarner Loshbuiltin commands take parameters from the command line.
1319e1dc7beSWarner LoshPresently,
1329e1dc7beSWarner Loshthe only way to call them from a script is by using
1339e1dc7beSWarner Losh.Pa evaluate
1349e1dc7beSWarner Loshon a string.
1359e1dc7beSWarner LoshIf an error condition occurs, an exception will be generated,
1369e1dc7beSWarner Loshwhich can be intercepted using
1379e1dc7beSWarner Losh.Tn ANS
1389e1dc7beSWarner LoshForth exception handling
1399e1dc7beSWarner Loshwords.
1409e1dc7beSWarner LoshIf not intercepted, an error message will be displayed and
1419e1dc7beSWarner Loshthe interpreter's state will be reset, emptying the stack and restoring
1429e1dc7beSWarner Loshinterpreting mode.
1439e1dc7beSWarner LoshThe commands are described in the
1449e1dc7beSWarner Losh.Xr loader_simp 8
1459e1dc7beSWarner Losh.Dq BUILTIN COMMANDS
1469e1dc7beSWarner Loshsection.
1479e1dc7beSWarner Losh.Ss BUILTIN ENVIRONMENT VARIABLES
1489e1dc7beSWarner LoshThe environment variables common to all interpreters are described in the
1499e1dc7beSWarner Losh.Xr loader_simp 8
1509e1dc7beSWarner Losh.Dq BUILTIN ENVIRONMENT VARIABLES
1519e1dc7beSWarner Loshsection.
1529e1dc7beSWarner Losh.Ss BUILTIN PARSER
1539e1dc7beSWarner LoshWhen a builtin command is executed, the rest of the line is taken
1549e1dc7beSWarner Loshby it as arguments, and it is processed by a special parser which
1559e1dc7beSWarner Loshis not used for regular Forth commands.
1569e1dc7beSWarner Losh.Pp
1579e1dc7beSWarner LoshThis special parser applies the following rules to the parsed text:
1589e1dc7beSWarner Losh.Bl -enum
1599e1dc7beSWarner Losh.It
1609e1dc7beSWarner LoshAll backslash characters are preprocessed.
1619e1dc7beSWarner Losh.Bl -bullet
1629e1dc7beSWarner Losh.It
1639e1dc7beSWarner Losh\eb , \ef , \er , \en and \et are processed as in C.
1649e1dc7beSWarner Losh.It
1659e1dc7beSWarner Losh\es is converted to a space.
1669e1dc7beSWarner Losh.It
1679e1dc7beSWarner Losh\ev is converted to
1689e1dc7beSWarner Losh.Tn ASCII
1699e1dc7beSWarner Losh11.
1709e1dc7beSWarner Losh.It
1719e1dc7beSWarner Losh\ez is just skipped.
1729e1dc7beSWarner LoshUseful for things like
1739e1dc7beSWarner Losh.Dq \e0xf\ez\e0xf .
1749e1dc7beSWarner Losh.It
1759e1dc7beSWarner Losh\e0xN and \e0xNN are replaced by the hex N or NN.
1769e1dc7beSWarner Losh.It
1779e1dc7beSWarner Losh\eNNN is replaced by the octal NNN
1789e1dc7beSWarner Losh.Tn ASCII
1799e1dc7beSWarner Loshcharacter.
1809e1dc7beSWarner Losh.It
1819e1dc7beSWarner Losh\e" , \e' and \e$ will escape these characters, preventing them from
1829e1dc7beSWarner Loshreceiving special treatment in Step 2, described below.
1839e1dc7beSWarner Losh.It
1849e1dc7beSWarner Losh\e\e will be replaced with a single \e .
1859e1dc7beSWarner Losh.It
1869e1dc7beSWarner LoshIn any other occurrence, backslash will just be removed.
1879e1dc7beSWarner Losh.El
1889e1dc7beSWarner Losh.It
1899e1dc7beSWarner LoshEvery string between non-escaped quotes or double-quotes will be treated
1909e1dc7beSWarner Loshas a single word for the purposes of the remaining steps.
1919e1dc7beSWarner Losh.It
1929e1dc7beSWarner LoshReplace any
1939e1dc7beSWarner Losh.Li $VARIABLE
1949e1dc7beSWarner Loshor
1959e1dc7beSWarner Losh.Li ${VARIABLE}
1969e1dc7beSWarner Loshwith the value of the environment variable
1979e1dc7beSWarner Losh.Va VARIABLE .
1989e1dc7beSWarner Losh.It
1999e1dc7beSWarner LoshSpace-delimited arguments are passed to the called builtin command.
2009e1dc7beSWarner LoshSpaces can also be escaped through the use of \e\e .
2019e1dc7beSWarner Losh.El
2029e1dc7beSWarner Losh.Pp
2039e1dc7beSWarner LoshAn exception to this parsing rule exists, and is described in
2049e1dc7beSWarner Losh.Sx BUILTINS AND FORTH .
2059e1dc7beSWarner Losh.Ss BUILTINS AND FORTH
2069e1dc7beSWarner LoshAll builtin words are state-smart, immediate words.
2079e1dc7beSWarner LoshIf interpreted, they behave exactly as described previously.
2089e1dc7beSWarner LoshIf they are compiled, though,
2099e1dc7beSWarner Loshthey extract their arguments from the stack instead of the command line.
2109e1dc7beSWarner Losh.Pp
2119e1dc7beSWarner LoshIf compiled, the builtin words expect to find, at execution time, the
2129e1dc7beSWarner Loshfollowing parameters on the stack:
2139e1dc7beSWarner Losh.D1 Ar addrN lenN ... addr2 len2 addr1 len1 N
2149e1dc7beSWarner Loshwhere
2159e1dc7beSWarner Losh.Ar addrX lenX
2169e1dc7beSWarner Loshare strings which will compose the command line that will be parsed
2179e1dc7beSWarner Loshinto the builtin's arguments.
2189e1dc7beSWarner LoshInternally, these strings are concatenated in from 1 to N,
2199e1dc7beSWarner Loshwith a space put between each one.
2209e1dc7beSWarner Losh.Pp
2219e1dc7beSWarner LoshIf no arguments are passed, a 0
2229e1dc7beSWarner Losh.Em must
2239e1dc7beSWarner Loshbe passed, even if the builtin accepts no arguments.
2249e1dc7beSWarner Losh.Pp
2259e1dc7beSWarner LoshWhile this behavior has benefits, it has its trade-offs.
2269e1dc7beSWarner LoshIf the execution token of a builtin is acquired (through
2279e1dc7beSWarner Losh.Ic '
2289e1dc7beSWarner Loshor
2299e1dc7beSWarner Losh.Ic ['] ) ,
2309e1dc7beSWarner Loshand then passed to
2319e1dc7beSWarner Losh.Ic catch
2329e1dc7beSWarner Loshor
2339e1dc7beSWarner Losh.Ic execute ,
2349e1dc7beSWarner Loshthe builtin behavior will depend on the system state
2359e1dc7beSWarner Losh.Bf Em
2369e1dc7beSWarner Loshat the time
2379e1dc7beSWarner Losh.Ic catch
2389e1dc7beSWarner Loshor
2399e1dc7beSWarner Losh.Ic execute
2409e1dc7beSWarner Loshis processed!
2419e1dc7beSWarner Losh.Ef
2429e1dc7beSWarner LoshThis is particularly annoying for programs that want or need to
2439e1dc7beSWarner Loshhandle exceptions.
2449e1dc7beSWarner LoshIn this case, the use of a proxy is recommended.
2459e1dc7beSWarner LoshFor example:
2469e1dc7beSWarner Losh.Dl : (boot) boot ;
2479e1dc7beSWarner Losh.Sh FICL
2489e1dc7beSWarner Losh.Tn FICL
2499e1dc7beSWarner Loshis a Forth interpreter written in C, in the form of a forth
2509e1dc7beSWarner Loshvirtual machine library that can be called by C functions and vice
2519e1dc7beSWarner Loshversa.
2529e1dc7beSWarner Losh.Pp
2539e1dc7beSWarner LoshIn
2549e1dc7beSWarner Losh.Nm ,
2559e1dc7beSWarner Losheach line read interactively is then fed to
2569e1dc7beSWarner Losh.Tn FICL ,
2579e1dc7beSWarner Loshwhich may call
2589e1dc7beSWarner Losh.Nm
2599e1dc7beSWarner Loshback to execute the builtin words.
2609e1dc7beSWarner LoshThe builtin
2619e1dc7beSWarner Losh.Ic include
2629e1dc7beSWarner Loshwill also feed
2639e1dc7beSWarner Losh.Tn FICL ,
2649e1dc7beSWarner Loshone line at a time.
2659e1dc7beSWarner Losh.Pp
2669e1dc7beSWarner LoshThe words available to
2679e1dc7beSWarner Losh.Tn FICL
2689e1dc7beSWarner Loshcan be classified into four groups.
2699e1dc7beSWarner LoshThe
2709e1dc7beSWarner Losh.Tn ANS
2719e1dc7beSWarner LoshForth standard words, extra
2729e1dc7beSWarner Losh.Tn FICL
2739e1dc7beSWarner Loshwords, extra
2749e1dc7beSWarner Losh.Fx
2759e1dc7beSWarner Loshwords, and the builtin commands;
2769e1dc7beSWarner Loshthe latter were already described.
2779e1dc7beSWarner LoshThe
2789e1dc7beSWarner Losh.Tn ANS
2799e1dc7beSWarner LoshForth standard words are listed in the
2809e1dc7beSWarner Losh.Sx STANDARDS
2819e1dc7beSWarner Loshsection.
2829e1dc7beSWarner LoshThe words falling in the two other groups are described in the
2839e1dc7beSWarner Loshfollowing subsections.
2849e1dc7beSWarner Losh.Ss FICL EXTRA WORDS
2859e1dc7beSWarner Losh.Bl -tag -width wid-set-super
2869e1dc7beSWarner Losh.It Ic .env
2879e1dc7beSWarner Losh.It Ic .ver
2889e1dc7beSWarner Losh.It Ic -roll
2899e1dc7beSWarner Losh.It Ic 2constant
2909e1dc7beSWarner Losh.It Ic >name
2919e1dc7beSWarner Losh.It Ic body>
2929e1dc7beSWarner Losh.It Ic compare
2939e1dc7beSWarner LoshThis is the STRING word set's
2949e1dc7beSWarner Losh.Ic compare .
2959e1dc7beSWarner Losh.It Ic compile-only
2969e1dc7beSWarner Losh.It Ic endif
2979e1dc7beSWarner Losh.It Ic forget-wid
2989e1dc7beSWarner Losh.It Ic parse-word
2999e1dc7beSWarner Losh.It Ic sliteral
3009e1dc7beSWarner LoshThis is the STRING word set's
3019e1dc7beSWarner Losh.Ic sliteral .
3029e1dc7beSWarner Losh.It Ic wid-set-super
3039e1dc7beSWarner Losh.It Ic w@
3049e1dc7beSWarner Losh.It Ic w!
3059e1dc7beSWarner Losh.It Ic x.
3069e1dc7beSWarner Losh.It Ic empty
3079e1dc7beSWarner Losh.It Ic cell-
3089e1dc7beSWarner Losh.It Ic -rot
3099e1dc7beSWarner Losh.El
3109e1dc7beSWarner Losh.Ss FREEBSD EXTRA WORDS
3119e1dc7beSWarner Losh.Bl -tag -width XXXXXXXX
3129e1dc7beSWarner Losh.It Ic \&$ Pq --
3139e1dc7beSWarner LoshEvaluates the remainder of the input buffer, after having printed it first.
3149e1dc7beSWarner Losh.It Ic \&% Pq --
3159e1dc7beSWarner LoshEvaluates the remainder of the input buffer under a
3169e1dc7beSWarner Losh.Ic catch
3179e1dc7beSWarner Loshexception guard.
3189e1dc7beSWarner Losh.It Ic .#
3199e1dc7beSWarner LoshWorks like
3209e1dc7beSWarner Losh.Ic "."
3219e1dc7beSWarner Loshbut without outputting a trailing space.
3229e1dc7beSWarner Losh.It Ic fclose Pq Ar fd --
3239e1dc7beSWarner LoshCloses a file.
3249e1dc7beSWarner Losh.It Ic fkey Pq Ar fd -- char
3259e1dc7beSWarner LoshReads a single character from a file.
3269e1dc7beSWarner Losh.It Ic fload Pq Ar fd --
3279e1dc7beSWarner LoshProcesses a file
3289e1dc7beSWarner Losh.Em fd .
3299e1dc7beSWarner Losh.It Ic fopen Pq Ar addr len mode Li -- Ar fd
3309e1dc7beSWarner LoshOpens a file.
3319e1dc7beSWarner LoshReturns a file descriptor, or \-1 in case of failure.
3329e1dc7beSWarner LoshThe
3339e1dc7beSWarner Losh.Ar mode
3349e1dc7beSWarner Loshparameter selects whether the file is to be opened for read access, write
3359e1dc7beSWarner Loshaccess, or both.
3369e1dc7beSWarner LoshThe constants
3379e1dc7beSWarner Losh.Dv O_RDONLY , O_WRONLY ,
3389e1dc7beSWarner Loshand
3399e1dc7beSWarner Losh.Dv O_RDWR
3409e1dc7beSWarner Loshare defined in
3419e1dc7beSWarner Losh.Pa /boot/support.4th ,
3429e1dc7beSWarner Loshindicating read only, write only, and read-write access, respectively.
3439e1dc7beSWarner Losh.It Xo
3449e1dc7beSWarner Losh.Ic fread
3459e1dc7beSWarner Losh.Pq Ar fd addr len -- len'
3469e1dc7beSWarner Losh.Xc
3479e1dc7beSWarner LoshTries to read
3489e1dc7beSWarner Losh.Em len
3499e1dc7beSWarner Loshbytes from file
3509e1dc7beSWarner Losh.Em fd
3519e1dc7beSWarner Loshinto buffer
3529e1dc7beSWarner Losh.Em addr .
3539e1dc7beSWarner LoshReturns the actual number of bytes read, or -1 in case of error or end of
3549e1dc7beSWarner Loshfile.
3559e1dc7beSWarner Losh.It Ic heap? Pq -- Ar cells
3569e1dc7beSWarner LoshReturn the space remaining in the dictionary heap, in cells.
3579e1dc7beSWarner LoshThis is not related to the heap used by dynamic memory allocation words.
3589e1dc7beSWarner Losh.It Ic inb Pq Ar port -- char
3599e1dc7beSWarner LoshReads a byte from a port.
3609e1dc7beSWarner Losh.It Ic key Pq -- Ar char
3619e1dc7beSWarner LoshReads a single character from the console.
3629e1dc7beSWarner Losh.It Ic key? Pq -- Ar flag
3639e1dc7beSWarner LoshReturns
3649e1dc7beSWarner Losh.Ic true
3659e1dc7beSWarner Loshif there is a character available to be read from the console.
3669e1dc7beSWarner Losh.It Ic ms Pq Ar u --
3679e1dc7beSWarner LoshWaits
3689e1dc7beSWarner Losh.Em u
3699e1dc7beSWarner Loshmicroseconds.
3709e1dc7beSWarner Losh.It Ic outb Pq Ar port char --
3719e1dc7beSWarner LoshWrites a byte to a port.
3729e1dc7beSWarner Losh.It Ic seconds Pq -- Ar u
3739e1dc7beSWarner LoshReturns the number of seconds since midnight.
3749e1dc7beSWarner Losh.It Ic tib> Pq -- Ar addr len
3759e1dc7beSWarner LoshReturns the remainder of the input buffer as a string on the stack.
3769e1dc7beSWarner Losh.It Ic trace! Pq Ar flag --
3779e1dc7beSWarner LoshActivates or deactivates tracing.
3789e1dc7beSWarner LoshDoes not work with
3799e1dc7beSWarner Losh.Ic catch .
3809e1dc7beSWarner Losh.El
3819e1dc7beSWarner Losh.Ss FREEBSD DEFINED ENVIRONMENTAL QUERIES
3829e1dc7beSWarner Losh.Bl -tag -width Ds
3839e1dc7beSWarner Losh.It arch-i386
3849e1dc7beSWarner Losh.Ic TRUE
3859e1dc7beSWarner Loshif the architecture is IA32.
3869e1dc7beSWarner Losh.It FreeBSD_version
3879e1dc7beSWarner Losh.Fx
3889e1dc7beSWarner Loshversion at compile time.
3899e1dc7beSWarner Losh.It loader_version
3909e1dc7beSWarner Losh.Nm
3919e1dc7beSWarner Loshversion.
3929e1dc7beSWarner Losh.El
3939e1dc7beSWarner Losh.Sh SECURITY
3949e1dc7beSWarner LoshAccess to the
3959e1dc7beSWarner Losh.Nm
3969e1dc7beSWarner Loshcommand line provides several ways of compromising system security,
3979e1dc7beSWarner Loshincluding, but not limited to:
3989e1dc7beSWarner Losh.Pp
3999e1dc7beSWarner Losh.Bl -bullet
4009e1dc7beSWarner Losh.It
4019e1dc7beSWarner LoshBooting from removable storage, by setting the
4029e1dc7beSWarner Losh.Va currdev
4039e1dc7beSWarner Loshor
4049e1dc7beSWarner Losh.Va loaddev
4059e1dc7beSWarner Loshvariables
4069e1dc7beSWarner Losh.It
4079e1dc7beSWarner LoshExecuting binary of choice, by setting the
4089e1dc7beSWarner Losh.Va init_path
4099e1dc7beSWarner Loshor
4109e1dc7beSWarner Losh.Va init_script
4119e1dc7beSWarner Loshvariables
4129e1dc7beSWarner Losh.It
4139e1dc7beSWarner LoshOverriding ACPI DSDT to inject arbitrary code into the ACPI subsystem
4149e1dc7beSWarner Losh.El
4159e1dc7beSWarner Losh.Pp
4169e1dc7beSWarner LoshOne can prevent unauthorized access
4179e1dc7beSWarner Loshto the
4189e1dc7beSWarner Losh.Nm
4199e1dc7beSWarner Loshcommand line by setting the
4209e1dc7beSWarner Losh.Va password ,
4219e1dc7beSWarner Loshor setting
4229e1dc7beSWarner Losh.Va autoboot_delay
4239e1dc7beSWarner Loshto -1.
4249e1dc7beSWarner LoshSee
4259e1dc7beSWarner Losh.Xr loader.conf 5
4269e1dc7beSWarner Loshfor details.
4279e1dc7beSWarner LoshIn order for this to be effective, one should also configure the firmware
4289e1dc7beSWarner Losh(BIOS or UEFI) to prevent booting from unauthorized devices.
4299e1dc7beSWarner Losh.Sh MD
4309e1dc7beSWarner LoshMemory disk (MD) can be used when the
4319e1dc7beSWarner Losh.Nm
4329e1dc7beSWarner Loshwas compiled with
4339e1dc7beSWarner Losh.Va MD_IMAGE_SIZE .
4349e1dc7beSWarner LoshThe size of the memory disk is determined by
4359e1dc7beSWarner Losh.Va MD_IMAGE_SIZE .
4369e1dc7beSWarner LoshIf MD available, a file system can be embedded into the
4379e1dc7beSWarner Losh.Nm
4389e1dc7beSWarner Loshwith
4399e1dc7beSWarner Losh.Pa /sys/tools/embed_mfs.sh .
4409e1dc7beSWarner LoshThen, MD will be probed and be set to
4419e1dc7beSWarner Losh.Va currdev
4429e1dc7beSWarner Loshduring initialization.
4439e1dc7beSWarner Losh.Pp
4449e1dc7beSWarner LoshCurrently, MD is only supported in
4459e1dc7beSWarner Losh.Xr loader.efi 8 .
4469e1dc7beSWarner Losh.Sh FILES
4479e1dc7beSWarner Losh.Bl -tag -width /usr/share/examples/bootforth/ -compact
4489e1dc7beSWarner Losh.It Pa /boot/loader
4499e1dc7beSWarner Losh.Nm
4509e1dc7beSWarner Loshitself.
4519e1dc7beSWarner Losh.It Pa /boot/boot.4th
4529e1dc7beSWarner LoshAdditional
4539e1dc7beSWarner Losh.Tn FICL
4549e1dc7beSWarner Loshinitialization.
4559e1dc7beSWarner Losh.It Pa /boot/defaults/loader.conf
4569e1dc7beSWarner Losh.It Pa /boot/loader.4th
4579e1dc7beSWarner LoshExtra builtin-like words.
4589e1dc7beSWarner Losh.It Pa /boot/loader.conf
4599e1dc7beSWarner Losh.It Pa /boot/loader.conf.local
4609e1dc7beSWarner Losh.Nm
4619e1dc7beSWarner Loshconfiguration files, as described in
4629e1dc7beSWarner Losh.Xr loader.conf 5 .
4639e1dc7beSWarner Losh.It Pa /boot/loader.rc
4649e1dc7beSWarner Losh.Nm
4659e1dc7beSWarner Loshbootstrapping script.
4669e1dc7beSWarner Losh.It Pa /boot/loader.help
4679e1dc7beSWarner LoshLoaded by
4689e1dc7beSWarner Losh.Ic help .
4699e1dc7beSWarner LoshContains the help messages.
4709e1dc7beSWarner Losh.It Pa /boot/support.4th
4719e1dc7beSWarner Losh.Pa loader.conf
4729e1dc7beSWarner Loshprocessing words.
4739e1dc7beSWarner Losh.It Pa /usr/share/examples/bootforth/
4749e1dc7beSWarner LoshAssorted examples.
4759e1dc7beSWarner Losh.El
4769e1dc7beSWarner Losh.Sh EXAMPLES
4779e1dc7beSWarner LoshBoot in single user mode:
4789e1dc7beSWarner Losh.Pp
4799e1dc7beSWarner Losh.Dl boot -s
4809e1dc7beSWarner Losh.Pp
4819e1dc7beSWarner LoshLoad the kernel, a splash screen, and then autoboot in five seconds.
4829e1dc7beSWarner LoshNotice that a kernel must be loaded before any other
4839e1dc7beSWarner Losh.Ic load
4849e1dc7beSWarner Loshcommand is attempted.
4859e1dc7beSWarner Losh.Bd -literal -offset indent
4869e1dc7beSWarner Loshload kernel
4879e1dc7beSWarner Loshload splash_bmp
4889e1dc7beSWarner Loshload -t splash_image_data /boot/chuckrulez.bmp
4899e1dc7beSWarner Loshautoboot 5
4909e1dc7beSWarner Losh.Ed
4919e1dc7beSWarner Losh.Pp
4929e1dc7beSWarner LoshSet the disk unit of the root device to 2, and then boot.
4939e1dc7beSWarner LoshThis would be needed in a system with two IDE disks,
4949e1dc7beSWarner Loshwith the second IDE disk hardwired to ada2 instead of ada1.
4959e1dc7beSWarner Losh.Bd -literal -offset indent
4969e1dc7beSWarner Loshset root_disk_unit=2
4979e1dc7beSWarner Loshboot /boot/kernel/kernel
4989e1dc7beSWarner Losh.Ed
4999e1dc7beSWarner Losh.Pp
5009e1dc7beSWarner LoshSet the default device used for loading a kernel from a ZFS filesystem:
5019e1dc7beSWarner Losh.Bd -literal -offset indent
5029e1dc7beSWarner Loshset currdev=zfs:tank/ROOT/knowngood:
5039e1dc7beSWarner Losh.Ed
5049e1dc7beSWarner Losh.Pp
5059e1dc7beSWarner Losh.Sh ERRORS
5069e1dc7beSWarner LoshThe following values are thrown by
5079e1dc7beSWarner Losh.Nm :
5089e1dc7beSWarner Losh.Bl -tag -width XXXXX -offset indent
5099e1dc7beSWarner Losh.It 100
5109e1dc7beSWarner LoshAny type of error in the processing of a builtin.
5119e1dc7beSWarner Losh.It -1
5129e1dc7beSWarner Losh.Ic Abort
5139e1dc7beSWarner Loshexecuted.
5149e1dc7beSWarner Losh.It -2
5159e1dc7beSWarner Losh.Ic Abort"
5169e1dc7beSWarner Loshexecuted.
5179e1dc7beSWarner Losh.It -56
5189e1dc7beSWarner Losh.Ic Quit
5199e1dc7beSWarner Loshexecuted.
5209e1dc7beSWarner Losh.It -256
5219e1dc7beSWarner LoshOut of interpreting text.
5229e1dc7beSWarner Losh.It -257
5239e1dc7beSWarner LoshNeed more text to succeed -- will finish on next run.
5249e1dc7beSWarner Losh.It -258
5259e1dc7beSWarner Losh.Ic Bye
5269e1dc7beSWarner Loshexecuted.
5279e1dc7beSWarner Losh.It -259
5289e1dc7beSWarner LoshUnspecified error.
5299e1dc7beSWarner Losh.El
5309e1dc7beSWarner Losh.Sh SEE ALSO
531*11f49259SWarner Losh.Xr libsa 3 ,
5329e1dc7beSWarner Losh.Xr loader.conf 5 ,
5339e1dc7beSWarner Losh.Xr tuning 7 ,
5349e1dc7beSWarner Losh.Xr boot 8 ,
5359e1dc7beSWarner Losh.Xr btxld 8
5369e1dc7beSWarner Losh.Sh STANDARDS
5379e1dc7beSWarner LoshFor the purposes of ANS Forth compliance, loader is an
5389e1dc7beSWarner Losh.Bf Em
5399e1dc7beSWarner LoshANS Forth System with Environmental Restrictions, Providing
5409e1dc7beSWarner Losh.Ef
5419e1dc7beSWarner Losh.Bf Li
5429e1dc7beSWarner Losh.No .( ,
5439e1dc7beSWarner Losh.No :noname ,
5449e1dc7beSWarner Losh.No ?do ,
5459e1dc7beSWarner Loshparse, pick, roll, refill, to, value, \e, false, true,
5469e1dc7beSWarner Losh.No <> ,
5479e1dc7beSWarner Losh.No 0<> ,
5489e1dc7beSWarner Loshcompile\&, , erase, nip, tuck
5499e1dc7beSWarner Losh.Ef
5509e1dc7beSWarner Losh.Em and
5519e1dc7beSWarner Losh.Li marker
5529e1dc7beSWarner Losh.Bf Em
5539e1dc7beSWarner Loshfrom the Core Extensions word set, Providing the Exception Extensions
5549e1dc7beSWarner Loshword set, Providing the Locals Extensions word set, Providing the
5559e1dc7beSWarner LoshMemory-Allocation Extensions word set, Providing
5569e1dc7beSWarner Losh.Ef
5579e1dc7beSWarner Losh.Bf Li
5589e1dc7beSWarner Losh\&.s,
5599e1dc7beSWarner Loshbye, forget, see, words,
5609e1dc7beSWarner Losh\&[if],
5619e1dc7beSWarner Losh\&[else]
5629e1dc7beSWarner Losh.Ef
5639e1dc7beSWarner Losh.Em and
5649e1dc7beSWarner Losh.Li [then]
5659e1dc7beSWarner Losh.Bf Em
5669e1dc7beSWarner Loshfrom the Programming-Tools extension word set, Providing the
5679e1dc7beSWarner LoshSearch-Order extensions word set.
5689e1dc7beSWarner Losh.Ef
5699e1dc7beSWarner Losh.Sh HISTORY
5709e1dc7beSWarner LoshThe
5719e1dc7beSWarner Losh.Nm
5729e1dc7beSWarner Loshfirst appeared in
5739e1dc7beSWarner Losh.Fx 3.1 .
5749e1dc7beSWarner Losh.Sh AUTHORS
5759e1dc7beSWarner Losh.An -nosplit
5769e1dc7beSWarner LoshThe
5779e1dc7beSWarner Losh.Nm
5789e1dc7beSWarner Loshwas written by
5799e1dc7beSWarner Losh.An Michael Smith Aq msmith@FreeBSD.org .
5809e1dc7beSWarner Losh.Pp
5819e1dc7beSWarner Losh.Tn FICL
5829e1dc7beSWarner Loshwas written by
5839e1dc7beSWarner Losh.An John Sadler Aq john_sadler@alum.mit.edu .
584