xref: /freebsd/stand/man/loader.8 (revision ca987d4641cdcd7f27e153db17c5bf064934faf5)
1*ca987d46SWarner Losh.\" Copyright (c) 1999 Daniel C. Sobral
2*ca987d46SWarner Losh.\" All rights reserved.
3*ca987d46SWarner Losh.\"
4*ca987d46SWarner Losh.\" Redistribution and use in source and binary forms, with or without
5*ca987d46SWarner Losh.\" modification, are permitted provided that the following conditions
6*ca987d46SWarner Losh.\" are met:
7*ca987d46SWarner Losh.\" 1. Redistributions of source code must retain the above copyright
8*ca987d46SWarner Losh.\"    notice, this list of conditions and the following disclaimer.
9*ca987d46SWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright
10*ca987d46SWarner Losh.\"    notice, this list of conditions and the following disclaimer in the
11*ca987d46SWarner Losh.\"    documentation and/or other materials provided with the distribution.
12*ca987d46SWarner Losh.\"
13*ca987d46SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14*ca987d46SWarner Losh.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15*ca987d46SWarner Losh.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16*ca987d46SWarner Losh.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17*ca987d46SWarner Losh.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18*ca987d46SWarner Losh.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19*ca987d46SWarner Losh.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20*ca987d46SWarner Losh.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21*ca987d46SWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22*ca987d46SWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23*ca987d46SWarner Losh.\" SUCH DAMAGE.
24*ca987d46SWarner Losh.\"
25*ca987d46SWarner Losh.\" $FreeBSD$
26*ca987d46SWarner Losh.\"
27*ca987d46SWarner Losh.Dd November 18, 2015
28*ca987d46SWarner Losh.Dt LOADER 8
29*ca987d46SWarner Losh.Os
30*ca987d46SWarner Losh.Sh NAME
31*ca987d46SWarner Losh.Nm loader
32*ca987d46SWarner Losh.Nd kernel bootstrapping final stage
33*ca987d46SWarner Losh.Sh DESCRIPTION
34*ca987d46SWarner LoshThe program called
35*ca987d46SWarner Losh.Nm
36*ca987d46SWarner Loshis the final stage of
37*ca987d46SWarner Losh.Fx Ns 's
38*ca987d46SWarner Loshkernel bootstrapping process.
39*ca987d46SWarner LoshOn IA32 (i386) architectures, it is a
40*ca987d46SWarner Losh.Pa BTX
41*ca987d46SWarner Loshclient.
42*ca987d46SWarner LoshIt is linked statically to
43*ca987d46SWarner Losh.Xr libstand 3
44*ca987d46SWarner Loshand usually located in the directory
45*ca987d46SWarner Losh.Pa /boot .
46*ca987d46SWarner Losh.Pp
47*ca987d46SWarner LoshIt provides a scripting language that can be used to
48*ca987d46SWarner Loshautomate tasks, do pre-configuration or assist in recovery
49*ca987d46SWarner Loshprocedures.
50*ca987d46SWarner LoshThis scripting language is roughly divided in
51*ca987d46SWarner Loshtwo main components.
52*ca987d46SWarner LoshThe smaller one is a set of commands
53*ca987d46SWarner Loshdesigned for direct use by the casual user, called "builtin
54*ca987d46SWarner Loshcommands" for historical reasons.
55*ca987d46SWarner LoshThe main drive behind these commands is user-friendliness.
56*ca987d46SWarner LoshThe bigger component is an
57*ca987d46SWarner Losh.Tn ANS
58*ca987d46SWarner LoshForth compatible Forth interpreter based on FICL, by
59*ca987d46SWarner Losh.An John Sadler .
60*ca987d46SWarner Losh.Pp
61*ca987d46SWarner LoshDuring initialization,
62*ca987d46SWarner Losh.Nm
63*ca987d46SWarner Loshwill probe for a console and set the
64*ca987d46SWarner Losh.Va console
65*ca987d46SWarner Loshvariable, or set it to serial console
66*ca987d46SWarner Losh.Pq Dq Li comconsole
67*ca987d46SWarner Loshif the previous boot stage used that.
68*ca987d46SWarner LoshIf multiple consoles are selected, they will be listed separated by spaces.
69*ca987d46SWarner LoshThen, devices are probed,
70*ca987d46SWarner Losh.Va currdev
71*ca987d46SWarner Loshand
72*ca987d46SWarner Losh.Va loaddev
73*ca987d46SWarner Loshare set, and
74*ca987d46SWarner Losh.Va LINES
75*ca987d46SWarner Loshis set to 24.
76*ca987d46SWarner LoshNext,
77*ca987d46SWarner Losh.Tn FICL
78*ca987d46SWarner Loshis initialized, the builtin words are added to its vocabulary, and
79*ca987d46SWarner Losh.Pa /boot/boot.4th
80*ca987d46SWarner Loshis processed if it exists.
81*ca987d46SWarner LoshNo disk switching is possible while that file is being read.
82*ca987d46SWarner LoshThe inner interpreter
83*ca987d46SWarner Losh.Nm
84*ca987d46SWarner Loshwill use with
85*ca987d46SWarner Losh.Tn FICL
86*ca987d46SWarner Loshis then set to
87*ca987d46SWarner Losh.Ic interpret ,
88*ca987d46SWarner Loshwhich is
89*ca987d46SWarner Losh.Tn FICL Ns 's
90*ca987d46SWarner Loshdefault.
91*ca987d46SWarner LoshAfter that,
92*ca987d46SWarner Losh.Pa /boot/loader.rc
93*ca987d46SWarner Loshis processed if available.
94*ca987d46SWarner LoshThese files are processed through the
95*ca987d46SWarner Losh.Ic include
96*ca987d46SWarner Loshcommand, which reads all of them into memory before processing them,
97*ca987d46SWarner Loshmaking disk changes possible.
98*ca987d46SWarner Losh.Pp
99*ca987d46SWarner LoshAt this point, if an
100*ca987d46SWarner Losh.Ic autoboot
101*ca987d46SWarner Loshhas not been tried, and if
102*ca987d46SWarner Losh.Va autoboot_delay
103*ca987d46SWarner Loshis not set to
104*ca987d46SWarner Losh.Dq Li NO
105*ca987d46SWarner Losh(not case sensitive), then an
106*ca987d46SWarner Losh.Ic autoboot
107*ca987d46SWarner Loshwill be tried.
108*ca987d46SWarner LoshIf the system gets past this point,
109*ca987d46SWarner Losh.Va prompt
110*ca987d46SWarner Loshwill be set and
111*ca987d46SWarner Losh.Nm
112*ca987d46SWarner Loshwill engage interactive mode.
113*ca987d46SWarner LoshPlease note that historically even when
114*ca987d46SWarner Losh.Va autoboot_delay
115*ca987d46SWarner Loshis set to
116*ca987d46SWarner Losh.Dq Li 0
117*ca987d46SWarner Loshuser will be able to interrupt autoboot process by pressing some key
118*ca987d46SWarner Loshon the console while kernel and modules are being loaded.
119*ca987d46SWarner LoshIn some
120*ca987d46SWarner Loshcases such behaviour may be undesirable, to prevent it set
121*ca987d46SWarner Losh.Va autoboot_delay
122*ca987d46SWarner Loshto
123*ca987d46SWarner Losh.Dq Li -1 ,
124*ca987d46SWarner Loshin this case
125*ca987d46SWarner Losh.Nm
126*ca987d46SWarner Loshwill engage interactive mode only if
127*ca987d46SWarner Losh.Ic autoboot
128*ca987d46SWarner Loshhas failed.
129*ca987d46SWarner Losh.Sh BUILTIN COMMANDS
130*ca987d46SWarner LoshIn
131*ca987d46SWarner Losh.Nm ,
132*ca987d46SWarner Loshbuiltin commands take parameters from the command line.
133*ca987d46SWarner LoshPresently,
134*ca987d46SWarner Loshthe only way to call them from a script is by using
135*ca987d46SWarner Losh.Pa evaluate
136*ca987d46SWarner Loshon a string.
137*ca987d46SWarner LoshIf an error condition occurs, an exception will be generated,
138*ca987d46SWarner Loshwhich can be intercepted using
139*ca987d46SWarner Losh.Tn ANS
140*ca987d46SWarner LoshForth exception handling
141*ca987d46SWarner Loshwords.
142*ca987d46SWarner LoshIf not intercepted, an error message will be displayed and
143*ca987d46SWarner Loshthe interpreter's state will be reset, emptying the stack and restoring
144*ca987d46SWarner Loshinterpreting mode.
145*ca987d46SWarner Losh.Pp
146*ca987d46SWarner LoshThe builtin commands available are:
147*ca987d46SWarner Losh.Pp
148*ca987d46SWarner Losh.Bl -tag -width Ds -compact
149*ca987d46SWarner Losh.It Ic autoboot Op Ar seconds Op Ar prompt
150*ca987d46SWarner LoshProceeds to bootstrap the system after a number of seconds, if not
151*ca987d46SWarner Loshinterrupted by the user.
152*ca987d46SWarner LoshDisplays a countdown prompt
153*ca987d46SWarner Loshwarning the user the system is about to be booted,
154*ca987d46SWarner Loshunless interrupted by a key press.
155*ca987d46SWarner LoshThe kernel will be loaded first if necessary.
156*ca987d46SWarner LoshDefaults to 10 seconds.
157*ca987d46SWarner Losh.Pp
158*ca987d46SWarner Losh.It Ic bcachestat
159*ca987d46SWarner LoshDisplays statistics about disk cache usage.
160*ca987d46SWarner LoshFor debugging only.
161*ca987d46SWarner Losh.Pp
162*ca987d46SWarner Losh.It Ic boot
163*ca987d46SWarner Losh.It Ic boot Ar kernelname Op Cm ...
164*ca987d46SWarner Losh.It Ic boot Fl flag Cm ...
165*ca987d46SWarner LoshImmediately proceeds to bootstrap the system, loading the kernel
166*ca987d46SWarner Loshif necessary.
167*ca987d46SWarner LoshAny flags or arguments are passed to the kernel, but they
168*ca987d46SWarner Loshmust precede the kernel name, if a kernel name is provided.
169*ca987d46SWarner Losh.Pp
170*ca987d46SWarner Losh.Em WARNING :
171*ca987d46SWarner LoshThe behavior of this builtin is changed if
172*ca987d46SWarner Losh.Xr loader.4th 8
173*ca987d46SWarner Loshis loaded.
174*ca987d46SWarner Losh.Pp
175*ca987d46SWarner Losh.It Ic echo Xo
176*ca987d46SWarner Losh.Op Fl n
177*ca987d46SWarner Losh.Op Aq message
178*ca987d46SWarner Losh.Xc
179*ca987d46SWarner LoshDisplays text on the screen.
180*ca987d46SWarner LoshA new line will be printed unless
181*ca987d46SWarner Losh.Fl n
182*ca987d46SWarner Loshis specified.
183*ca987d46SWarner Losh.Pp
184*ca987d46SWarner Losh.It Ic heap
185*ca987d46SWarner LoshDisplays memory usage statistics.
186*ca987d46SWarner LoshFor debugging purposes only.
187*ca987d46SWarner Losh.Pp
188*ca987d46SWarner Losh.It Ic help Op topic Op subtopic
189*ca987d46SWarner LoshShows help messages read from
190*ca987d46SWarner Losh.Pa /boot/loader.help .
191*ca987d46SWarner LoshThe special topic
192*ca987d46SWarner Losh.Em index
193*ca987d46SWarner Loshwill list the topics available.
194*ca987d46SWarner Losh.Pp
195*ca987d46SWarner Losh.It Ic include Ar file Op Ar
196*ca987d46SWarner LoshProcess script files.
197*ca987d46SWarner LoshEach file, in turn, is completely read into memory,
198*ca987d46SWarner Loshand then each of its lines is passed to the command line interpreter.
199*ca987d46SWarner LoshIf any error is returned by the interpreter, the include
200*ca987d46SWarner Loshcommand aborts immediately, without reading any other files, and
201*ca987d46SWarner Loshreturns an error itself (see
202*ca987d46SWarner Losh.Sx ERRORS ) .
203*ca987d46SWarner Losh.Pp
204*ca987d46SWarner Losh.It Ic load Xo
205*ca987d46SWarner Losh.Op Fl t Ar type
206*ca987d46SWarner Losh.Ar file Cm ...
207*ca987d46SWarner Losh.Xc
208*ca987d46SWarner LoshLoads a kernel, kernel loadable module (kld), disk image,
209*ca987d46SWarner Loshor file of opaque contents tagged as being of the type
210*ca987d46SWarner Losh.Ar type .
211*ca987d46SWarner LoshKernel and modules can be either in a.out or ELF format.
212*ca987d46SWarner LoshAny arguments passed after the name of the file to be loaded
213*ca987d46SWarner Loshwill be passed as arguments to that file.
214*ca987d46SWarner LoshUse the
215*ca987d46SWarner Losh.Li md_image
216*ca987d46SWarner Loshtype to make the kernel create a file-backed
217*ca987d46SWarner Losh.Xr md 4
218*ca987d46SWarner Loshdisk.
219*ca987d46SWarner LoshThis is useful for booting from a temporary rootfs.
220*ca987d46SWarner LoshCurrently, argument passing does not work for the kernel.
221*ca987d46SWarner Losh.Pp
222*ca987d46SWarner Losh.It Ic load_geli Xo
223*ca987d46SWarner Losh.Op Fl n Ar keyno
224*ca987d46SWarner Losh.Ar prov Ar file
225*ca987d46SWarner Losh.Xc
226*ca987d46SWarner LoshLoads a
227*ca987d46SWarner Losh.Xr geli 8
228*ca987d46SWarner Loshencryption keyfile for the given provider name.
229*ca987d46SWarner LoshThe key index can be specified via
230*ca987d46SWarner Losh.Ar keyno
231*ca987d46SWarner Loshor will default to zero.
232*ca987d46SWarner Losh.Pp
233*ca987d46SWarner Losh.It Ic ls Xo
234*ca987d46SWarner Losh.Op Fl l
235*ca987d46SWarner Losh.Op Ar path
236*ca987d46SWarner Losh.Xc
237*ca987d46SWarner LoshDisplays a listing of files in the directory
238*ca987d46SWarner Losh.Ar path ,
239*ca987d46SWarner Loshor the root directory if
240*ca987d46SWarner Losh.Ar path
241*ca987d46SWarner Loshis not specified.
242*ca987d46SWarner LoshIf
243*ca987d46SWarner Losh.Fl l
244*ca987d46SWarner Loshis specified, file sizes will be shown too.
245*ca987d46SWarner Losh.Pp
246*ca987d46SWarner Losh.It Ic lsdev Op Fl v
247*ca987d46SWarner LoshLists all of the devices from which it may be possible to load modules.
248*ca987d46SWarner LoshIf
249*ca987d46SWarner Losh.Fl v
250*ca987d46SWarner Loshis specified, more details are printed.
251*ca987d46SWarner Losh.Pp
252*ca987d46SWarner Losh.It Ic lsmod Op Fl v
253*ca987d46SWarner LoshDisplays loaded modules.
254*ca987d46SWarner LoshIf
255*ca987d46SWarner Losh.Fl v
256*ca987d46SWarner Loshis specified, more details are shown.
257*ca987d46SWarner Losh.Pp
258*ca987d46SWarner Losh.It Ic more Ar file Op Ar
259*ca987d46SWarner LoshDisplay the files specified, with a pause at each
260*ca987d46SWarner Losh.Va LINES
261*ca987d46SWarner Loshdisplayed.
262*ca987d46SWarner Losh.Pp
263*ca987d46SWarner Losh.It Ic pnpscan Op Fl v
264*ca987d46SWarner LoshScans for Plug-and-Play devices.
265*ca987d46SWarner LoshThis is not functional at present.
266*ca987d46SWarner Losh.Pp
267*ca987d46SWarner Losh.It Ic read Xo
268*ca987d46SWarner Losh.Op Fl t Ar seconds
269*ca987d46SWarner Losh.Op Fl p Ar prompt
270*ca987d46SWarner Losh.Op Va variable
271*ca987d46SWarner Losh.Xc
272*ca987d46SWarner LoshReads a line of input from the terminal, storing it in
273*ca987d46SWarner Losh.Va variable
274*ca987d46SWarner Loshif specified.
275*ca987d46SWarner LoshA timeout can be specified with
276*ca987d46SWarner Losh.Fl t ,
277*ca987d46SWarner Loshthough it will be canceled at the first key pressed.
278*ca987d46SWarner LoshA prompt may also be displayed through the
279*ca987d46SWarner Losh.Fl p
280*ca987d46SWarner Loshflag.
281*ca987d46SWarner Losh.Pp
282*ca987d46SWarner Losh.It Ic reboot
283*ca987d46SWarner LoshImmediately reboots the system.
284*ca987d46SWarner Losh.Pp
285*ca987d46SWarner Losh.It Ic set Ar variable
286*ca987d46SWarner Losh.It Ic set Ar variable Ns = Ns Ar value
287*ca987d46SWarner LoshSet loader's environment variables.
288*ca987d46SWarner Losh.Pp
289*ca987d46SWarner Losh.It Ic show Op Va variable
290*ca987d46SWarner LoshDisplays the specified variable's value, or all variables and their
291*ca987d46SWarner Loshvalues if
292*ca987d46SWarner Losh.Va variable
293*ca987d46SWarner Loshis not specified.
294*ca987d46SWarner Losh.Pp
295*ca987d46SWarner Losh.It Ic unload
296*ca987d46SWarner LoshRemove all modules from memory.
297*ca987d46SWarner Losh.Pp
298*ca987d46SWarner Losh.It Ic unset Va variable
299*ca987d46SWarner LoshRemoves
300*ca987d46SWarner Losh.Va variable
301*ca987d46SWarner Loshfrom the environment.
302*ca987d46SWarner Losh.Pp
303*ca987d46SWarner Losh.It Ic \&?
304*ca987d46SWarner LoshLists available commands.
305*ca987d46SWarner Losh.El
306*ca987d46SWarner Losh.Ss BUILTIN ENVIRONMENT VARIABLES
307*ca987d46SWarner LoshThe
308*ca987d46SWarner Losh.Nm
309*ca987d46SWarner Loshhas actually two different kinds of
310*ca987d46SWarner Losh.Sq environment
311*ca987d46SWarner Loshvariables.
312*ca987d46SWarner LoshThere are ANS Forth's
313*ca987d46SWarner Losh.Em environmental queries ,
314*ca987d46SWarner Loshand a separate space of environment variables used by builtins, which
315*ca987d46SWarner Loshare not directly available to Forth words.
316*ca987d46SWarner LoshIt is the latter type that this section covers.
317*ca987d46SWarner Losh.Pp
318*ca987d46SWarner LoshEnvironment variables can be set and unset through the
319*ca987d46SWarner Losh.Ic set
320*ca987d46SWarner Loshand
321*ca987d46SWarner Losh.Ic unset
322*ca987d46SWarner Loshbuiltins, and can have their values interactively examined through the
323*ca987d46SWarner Loshuse of the
324*ca987d46SWarner Losh.Ic show
325*ca987d46SWarner Loshbuiltin.
326*ca987d46SWarner LoshTheir values can also be accessed as described in
327*ca987d46SWarner Losh.Sx BUILTIN PARSER .
328*ca987d46SWarner Losh.Pp
329*ca987d46SWarner LoshNotice that these environment variables are not inherited by any shell
330*ca987d46SWarner Loshafter the system has been booted.
331*ca987d46SWarner Losh.Pp
332*ca987d46SWarner LoshA few variables are set automatically by
333*ca987d46SWarner Losh.Nm .
334*ca987d46SWarner LoshOthers can affect the behavior of either
335*ca987d46SWarner Losh.Nm
336*ca987d46SWarner Loshor the kernel at boot.
337*ca987d46SWarner LoshSome options may require a value,
338*ca987d46SWarner Loshwhile others define behavior just by being set.
339*ca987d46SWarner LoshBoth types of builtin variables are described below.
340*ca987d46SWarner Losh.Bl -tag -width bootfile
341*ca987d46SWarner Losh.It Va autoboot_delay
342*ca987d46SWarner LoshNumber of seconds
343*ca987d46SWarner Losh.Ic autoboot
344*ca987d46SWarner Loshwill wait before booting.
345*ca987d46SWarner LoshIf this variable is not defined,
346*ca987d46SWarner Losh.Ic autoboot
347*ca987d46SWarner Loshwill default to 10 seconds.
348*ca987d46SWarner Losh.Pp
349*ca987d46SWarner LoshIf set to
350*ca987d46SWarner Losh.Dq Li NO ,
351*ca987d46SWarner Loshno
352*ca987d46SWarner Losh.Ic autoboot
353*ca987d46SWarner Loshwill be automatically attempted after processing
354*ca987d46SWarner Losh.Pa /boot/loader.rc ,
355*ca987d46SWarner Loshthough explicit
356*ca987d46SWarner Losh.Ic autoboot Ns 's
357*ca987d46SWarner Loshwill be processed normally, defaulting to 10 seconds delay.
358*ca987d46SWarner Losh.Pp
359*ca987d46SWarner LoshIf set to
360*ca987d46SWarner Losh.Dq Li 0 ,
361*ca987d46SWarner Loshno delay will be inserted, but user still will be able to interrupt
362*ca987d46SWarner Losh.Ic autoboot
363*ca987d46SWarner Loshprocess and escape into the interactive mode by pressing some key
364*ca987d46SWarner Loshon the console while kernel and
365*ca987d46SWarner Loshmodules are being loaded.
366*ca987d46SWarner Losh.Pp
367*ca987d46SWarner LoshIf set to
368*ca987d46SWarner Losh.Dq Li -1 ,
369*ca987d46SWarner Loshno delay will be inserted and
370*ca987d46SWarner Losh.Nm
371*ca987d46SWarner Loshwill engage interactive mode only if
372*ca987d46SWarner Losh.Ic autoboot
373*ca987d46SWarner Loshhas failed for some reason.
374*ca987d46SWarner Losh.It Va boot_askname
375*ca987d46SWarner LoshInstructs the kernel to prompt the user for the name of the root device
376*ca987d46SWarner Loshwhen the kernel is booted.
377*ca987d46SWarner Losh.It Va boot_cdrom
378*ca987d46SWarner LoshInstructs the kernel to try to mount the root file system from CD-ROM.
379*ca987d46SWarner Losh.It Va boot_ddb
380*ca987d46SWarner LoshInstructs the kernel to start in the DDB debugger, rather than
381*ca987d46SWarner Loshproceeding to initialize when booted.
382*ca987d46SWarner Losh.It Va boot_dfltroot
383*ca987d46SWarner LoshInstructs the kernel to mount the statically compiled-in root file system.
384*ca987d46SWarner Losh.It Va boot_gdb
385*ca987d46SWarner LoshSelects gdb-remote mode for the kernel debugger by default.
386*ca987d46SWarner Losh.It Va boot_multicons
387*ca987d46SWarner LoshEnables multiple console support in the kernel early on boot.
388*ca987d46SWarner LoshIn a running system, console configuration can be manipulated
389*ca987d46SWarner Loshby the
390*ca987d46SWarner Losh.Xr conscontrol 8
391*ca987d46SWarner Loshutility.
392*ca987d46SWarner Losh.It Va boot_mute
393*ca987d46SWarner LoshAll console output is suppressed when console is muted.
394*ca987d46SWarner LoshIn a running system, the state of console muting can be manipulated by the
395*ca987d46SWarner Losh.Xr conscontrol 8
396*ca987d46SWarner Loshutility.
397*ca987d46SWarner Losh.It Va boot_pause
398*ca987d46SWarner LoshDuring the device probe, pause after each line is printed.
399*ca987d46SWarner Losh.It Va boot_serial
400*ca987d46SWarner LoshForce the use of a serial console even when an internal console
401*ca987d46SWarner Loshis present.
402*ca987d46SWarner Losh.It Va boot_single
403*ca987d46SWarner LoshPrevents the kernel from initiating a multi-user startup; instead,
404*ca987d46SWarner Losha single-user mode will be entered when the kernel has finished
405*ca987d46SWarner Loshdevice probing.
406*ca987d46SWarner Losh.It Va boot_verbose
407*ca987d46SWarner LoshSetting this variable causes extra debugging information to be printed
408*ca987d46SWarner Loshby the kernel during the boot phase.
409*ca987d46SWarner Losh.It Va bootfile
410*ca987d46SWarner LoshList of semicolon-separated search path for bootable kernels.
411*ca987d46SWarner LoshThe default is
412*ca987d46SWarner Losh.Dq Li kernel .
413*ca987d46SWarner Losh.It Va comconsole_speed
414*ca987d46SWarner LoshDefines the speed of the serial console (i386 and amd64 only).
415*ca987d46SWarner LoshIf the previous boot stage indicated that a serial console is in use
416*ca987d46SWarner Loshthen this variable is initialized to the current speed of the console
417*ca987d46SWarner Loshserial port.
418*ca987d46SWarner LoshOtherwise it is set to 9600 unless this was overridden using the
419*ca987d46SWarner Losh.Va BOOT_COMCONSOLE_SPEED
420*ca987d46SWarner Loshvariable when
421*ca987d46SWarner Losh.Nm
422*ca987d46SWarner Loshwas compiled.
423*ca987d46SWarner LoshChanges to the
424*ca987d46SWarner Losh.Va comconsole_speed
425*ca987d46SWarner Loshvariable take effect immediately.
426*ca987d46SWarner Losh.It Va comconsole_port
427*ca987d46SWarner LoshDefines the base i/o port used to access console UART
428*ca987d46SWarner Losh(i386 and amd64 only).
429*ca987d46SWarner LoshIf the variable is not set, its assumed value is 0x3F8, which
430*ca987d46SWarner Loshcorresponds to PC port COM1, unless overridden by
431*ca987d46SWarner Losh.Va BOOT_COMCONSOLE_PORT
432*ca987d46SWarner Loshvariable during the compilation of
433*ca987d46SWarner Losh.Nm .
434*ca987d46SWarner LoshSetting the
435*ca987d46SWarner Losh.Va comconsole_port
436*ca987d46SWarner Loshvariable automatically set
437*ca987d46SWarner Losh.Va hw.uart.console
438*ca987d46SWarner Loshenvironment variable to provide a hint to kernel for location of the console.
439*ca987d46SWarner LoshLoader console is changed immediately after variable
440*ca987d46SWarner Losh.Va comconsole_port
441*ca987d46SWarner Loshis set.
442*ca987d46SWarner Losh.It Va comconsole_pcidev
443*ca987d46SWarner LoshDefines the location of a PCI device of the 'simple communication'
444*ca987d46SWarner Loshclass to be used as the serial console UART (i386 and amd64 only).
445*ca987d46SWarner LoshThe syntax of the variable is
446*ca987d46SWarner Losh.Li 'bus:device:function[:bar]' ,
447*ca987d46SWarner Loshwhere all members must be numeric, with possible
448*ca987d46SWarner Losh.Li 0x
449*ca987d46SWarner Loshprefix to indicate a hexadecimal value.
450*ca987d46SWarner LoshThe
451*ca987d46SWarner Losh.Va bar
452*ca987d46SWarner Loshmember is optional and assumed to be 0x10 if omitted.
453*ca987d46SWarner LoshThe bar must decode i/o space.
454*ca987d46SWarner LoshSetting the variable
455*ca987d46SWarner Losh.Va comconsole_pcidev
456*ca987d46SWarner Loshautomatically sets the variable
457*ca987d46SWarner Losh.Va comconsole_port
458*ca987d46SWarner Loshto the base of the selected bar, and hint
459*ca987d46SWarner Losh.Va hw.uart.console .
460*ca987d46SWarner LoshLoader console is changed immediately after variable
461*ca987d46SWarner Losh.Va comconsole_pcidev
462*ca987d46SWarner Loshis set.
463*ca987d46SWarner Losh.It Va console
464*ca987d46SWarner LoshDefines the current console or consoles.
465*ca987d46SWarner LoshMultiple consoles may be specified.
466*ca987d46SWarner LoshIn that case, the first listed console will become the default console for
467*ca987d46SWarner Loshuserland output (e.g.\& from
468*ca987d46SWarner Losh.Xr init 8 ) .
469*ca987d46SWarner Losh.It Va currdev
470*ca987d46SWarner LoshSelects the default device.
471*ca987d46SWarner LoshSyntax for devices is odd.
472*ca987d46SWarner Losh.It Va dumpdev
473*ca987d46SWarner LoshSets the device for kernel dumps.
474*ca987d46SWarner LoshThis can be used to ensure that a device is configured before the corresponding
475*ca987d46SWarner Losh.Va dumpdev
476*ca987d46SWarner Loshdirective from
477*ca987d46SWarner Losh.Xr rc.conf 5
478*ca987d46SWarner Loshhas been processed, allowing kernel panics that happen during the early stages
479*ca987d46SWarner Loshof boot to be captured.
480*ca987d46SWarner Losh.It Va init_chroot
481*ca987d46SWarner LoshIf set to a valid directory in the root file system, it causes
482*ca987d46SWarner Losh.Xr init 8
483*ca987d46SWarner Loshto perform a
484*ca987d46SWarner Losh.Xr chroot 2
485*ca987d46SWarner Loshoperation on that directory, making it the new root directory.
486*ca987d46SWarner LoshThat happens before entering single-user mode or multi-user
487*ca987d46SWarner Loshmode (but after executing the
488*ca987d46SWarner Losh.Va init_script
489*ca987d46SWarner Loshif enabled).
490*ca987d46SWarner LoshThis functionality has generally been eclipsed by rerooting.
491*ca987d46SWarner LoshSee
492*ca987d46SWarner Losh.Xr reboot 8
493*ca987d46SWarner Losh.Fl r
494*ca987d46SWarner Loshfor details.
495*ca987d46SWarner Losh.It Va init_path
496*ca987d46SWarner LoshSets the list of binaries which the kernel will try to run as the initial
497*ca987d46SWarner Loshprocess.
498*ca987d46SWarner LoshThe first matching binary is used.
499*ca987d46SWarner LoshThe default list is
500*ca987d46SWarner Losh.Dq Li /sbin/init:/sbin/oinit:/sbin/init.bak:\:/rescue/init .
501*ca987d46SWarner Losh.It Va init_script
502*ca987d46SWarner LoshIf set to a valid file name in the root file system,
503*ca987d46SWarner Loshinstructs
504*ca987d46SWarner Losh.Xr init 8
505*ca987d46SWarner Loshto run that script as the very first action,
506*ca987d46SWarner Loshbefore doing anything else.
507*ca987d46SWarner LoshSignal handling and exit code interpretation is similar to
508*ca987d46SWarner Loshrunning the
509*ca987d46SWarner Losh.Pa /etc/rc
510*ca987d46SWarner Loshscript.
511*ca987d46SWarner LoshIn particular, single-user operation is enforced
512*ca987d46SWarner Loshif the script terminates with a non-zero exit code,
513*ca987d46SWarner Loshor if a SIGTERM is delivered to the
514*ca987d46SWarner Losh.Xr init 8
515*ca987d46SWarner Loshprocess (PID 1).
516*ca987d46SWarner LoshThis functionality has generally been eclipsed by rerooting.
517*ca987d46SWarner LoshSee
518*ca987d46SWarner Losh.Xr reboot 8
519*ca987d46SWarner Losh.Fl r
520*ca987d46SWarner Loshfor details.
521*ca987d46SWarner Losh.It Va init_shell
522*ca987d46SWarner LoshDefines the shell binary to be used for executing the various shell scripts.
523*ca987d46SWarner LoshThe default is
524*ca987d46SWarner Losh.Dq Li /bin/sh .
525*ca987d46SWarner LoshIt is used for running the
526*ca987d46SWarner Losh.Va init_script
527*ca987d46SWarner Loshif set, as well as for the
528*ca987d46SWarner Losh.Pa /etc/rc
529*ca987d46SWarner Loshand
530*ca987d46SWarner Losh.Pa /etc/rc.shutdown
531*ca987d46SWarner Loshscripts.
532*ca987d46SWarner LoshThe value of the corresponding
533*ca987d46SWarner Losh.Xr kenv 2
534*ca987d46SWarner Loshvariable is evaluated every time
535*ca987d46SWarner Losh.Xr init 8
536*ca987d46SWarner Loshcalls a shell script, so it can be changed later on using the
537*ca987d46SWarner Losh.Xr kenv 1
538*ca987d46SWarner Loshutility.
539*ca987d46SWarner LoshIn particular, if a non-default shell is used for running an
540*ca987d46SWarner Losh.Va init_script ,
541*ca987d46SWarner Loshit might be desirable to have that script reset the value of
542*ca987d46SWarner Losh.Va init_shell
543*ca987d46SWarner Loshback to the default, so that the
544*ca987d46SWarner Losh.Pa /etc/rc
545*ca987d46SWarner Loshscript is executed with the standard shell
546*ca987d46SWarner Losh.Pa /bin/sh .
547*ca987d46SWarner Losh.It Va interpret
548*ca987d46SWarner LoshHas the value
549*ca987d46SWarner Losh.Dq Li OK
550*ca987d46SWarner Loshif the Forth's current state is interpreting.
551*ca987d46SWarner Losh.It Va LINES
552*ca987d46SWarner LoshDefine the number of lines on the screen, to be used by the pager.
553*ca987d46SWarner Losh.It Va module_path
554*ca987d46SWarner LoshSets the list of directories which will be searched for modules
555*ca987d46SWarner Loshnamed in a load command or implicitly required by a dependency.
556*ca987d46SWarner LoshThe default value for this variable is
557*ca987d46SWarner Losh.Dq Li /boot/kernel;/boot/modules .
558*ca987d46SWarner Losh.It Va num_ide_disks
559*ca987d46SWarner LoshSets the number of IDE disks as a workaround for some problems in
560*ca987d46SWarner Loshfinding the root disk at boot.
561*ca987d46SWarner LoshThis has been deprecated in favor of
562*ca987d46SWarner Losh.Va root_disk_unit .
563*ca987d46SWarner Losh.It Va prompt
564*ca987d46SWarner LoshValue of
565*ca987d46SWarner Losh.Nm Ns 's
566*ca987d46SWarner Loshprompt.
567*ca987d46SWarner LoshDefaults to
568*ca987d46SWarner Losh.Dq Li "${interpret}" .
569*ca987d46SWarner LoshIf variable
570*ca987d46SWarner Losh.Va prompt
571*ca987d46SWarner Loshis unset, the default prompt is
572*ca987d46SWarner Losh.Ql > .
573*ca987d46SWarner Losh.It Va root_disk_unit
574*ca987d46SWarner LoshIf the code which detects the disk unit number for the root disk is
575*ca987d46SWarner Loshconfused, e.g.\& by a mix of SCSI and IDE disks, or IDE disks with
576*ca987d46SWarner Loshgaps in the sequence (e.g.\& no primary slave), the unit number can
577*ca987d46SWarner Loshbe forced by setting this variable.
578*ca987d46SWarner Losh.It Va rootdev
579*ca987d46SWarner LoshBy default the value of
580*ca987d46SWarner Losh.Va currdev
581*ca987d46SWarner Loshis used to set the root file system
582*ca987d46SWarner Loshwhen the kernel is booted.
583*ca987d46SWarner LoshThis can be overridden by setting
584*ca987d46SWarner Losh.Va rootdev
585*ca987d46SWarner Loshexplicitly.
586*ca987d46SWarner Losh.El
587*ca987d46SWarner Losh.Pp
588*ca987d46SWarner LoshOther variables are used to override kernel tunable parameters.
589*ca987d46SWarner LoshThe following tunables are available:
590*ca987d46SWarner Losh.Bl -tag -width Va
591*ca987d46SWarner Losh.It Va hw.physmem
592*ca987d46SWarner LoshLimit the amount of physical memory the system will use.
593*ca987d46SWarner LoshBy default the size is in bytes, but the
594*ca987d46SWarner Losh.Cm k , K , m , M , g
595*ca987d46SWarner Loshand
596*ca987d46SWarner Losh.Cm G
597*ca987d46SWarner Loshsuffixes
598*ca987d46SWarner Loshare also accepted and indicate kilobytes, megabytes and gigabytes
599*ca987d46SWarner Loshrespectively.
600*ca987d46SWarner LoshAn invalid suffix will result in the variable being ignored by the
601*ca987d46SWarner Loshkernel.
602*ca987d46SWarner Losh.It Va hw.pci.host_start_mem , hw.acpi.host_start_mem
603*ca987d46SWarner LoshWhen not otherwise constrained, this limits the memory start
604*ca987d46SWarner Loshaddress.
605*ca987d46SWarner LoshThe default is 0x80000000 and should be set to at least size of the
606*ca987d46SWarner Loshmemory and not conflict with other resources.
607*ca987d46SWarner LoshTypically, only systems without PCI bridges need to set this variable
608*ca987d46SWarner Loshsince PCI bridges typically constrain the memory starting address
609*ca987d46SWarner Losh(and the variable is only used when bridges do not constrain this
610*ca987d46SWarner Loshaddress).
611*ca987d46SWarner Losh.It Va hw.pci.enable_io_modes
612*ca987d46SWarner LoshEnable PCI resources which are left off by some BIOSes or are not
613*ca987d46SWarner Loshenabled correctly by the device driver.
614*ca987d46SWarner LoshTunable value set to ON (1) by default, but this may cause problems
615*ca987d46SWarner Loshwith some peripherals.
616*ca987d46SWarner Losh.It Va kern.maxusers
617*ca987d46SWarner LoshSet the size of a number of statically allocated system tables; see
618*ca987d46SWarner Losh.Xr tuning 7
619*ca987d46SWarner Loshfor a description of how to select an appropriate value for this
620*ca987d46SWarner Loshtunable.
621*ca987d46SWarner LoshWhen set, this tunable replaces the value declared in the kernel
622*ca987d46SWarner Loshcompile-time configuration file.
623*ca987d46SWarner Losh.It Va kern.ipc.nmbclusters
624*ca987d46SWarner LoshSet the number of mbuf clusters to be allocated.
625*ca987d46SWarner LoshThe value cannot be set below the default
626*ca987d46SWarner Loshdetermined when the kernel was compiled.
627*ca987d46SWarner Losh.It Va kern.ipc.nsfbufs
628*ca987d46SWarner LoshSet the number of
629*ca987d46SWarner Losh.Xr sendfile 2
630*ca987d46SWarner Loshbuffers to be allocated.
631*ca987d46SWarner LoshOverrides
632*ca987d46SWarner Losh.Dv NSFBUFS .
633*ca987d46SWarner LoshNot all architectures use such buffers; see
634*ca987d46SWarner Losh.Xr sendfile 2
635*ca987d46SWarner Loshfor details.
636*ca987d46SWarner Losh.It Va kern.maxswzone
637*ca987d46SWarner LoshLimits the amount of KVM to be used to hold swap
638*ca987d46SWarner Loshmetadata, which directly governs the
639*ca987d46SWarner Loshmaximum amount of swap the system can support,
640*ca987d46SWarner Loshat the rate of approximately 200 MB of swap space
641*ca987d46SWarner Loshper 1 MB of metadata.
642*ca987d46SWarner LoshThis value is specified in bytes of KVA space.
643*ca987d46SWarner LoshIf no value is provided, the system allocates
644*ca987d46SWarner Loshenough memory to handle an amount of swap
645*ca987d46SWarner Loshthat corresponds to eight times the amount of
646*ca987d46SWarner Loshphysical memory present in the system.
647*ca987d46SWarner Losh.Pp
648*ca987d46SWarner LoshNote that swap metadata can be fragmented,
649*ca987d46SWarner Loshwhich means that the system can run out of
650*ca987d46SWarner Loshspace before it reaches the theoretical limit.
651*ca987d46SWarner LoshTherefore, care should be taken to not configure
652*ca987d46SWarner Loshmore swap than approximately half of the
653*ca987d46SWarner Loshtheoretical maximum.
654*ca987d46SWarner Losh.Pp
655*ca987d46SWarner LoshRunning out of space for swap metadata can leave
656*ca987d46SWarner Loshthe system in an unrecoverable state.
657*ca987d46SWarner LoshTherefore, you should only change
658*ca987d46SWarner Loshthis parameter if you need to greatly extend the
659*ca987d46SWarner LoshKVM reservation for other resources such as the
660*ca987d46SWarner Loshbuffer cache or
661*ca987d46SWarner Losh.Va kern.ipc.nmbclusters .
662*ca987d46SWarner LoshModifies kernel option
663*ca987d46SWarner Losh.Dv VM_SWZONE_SIZE_MAX .
664*ca987d46SWarner Losh.It Va kern.maxbcache
665*ca987d46SWarner LoshLimits the amount of KVM reserved for use by the
666*ca987d46SWarner Loshbuffer cache, specified in bytes.
667*ca987d46SWarner LoshThe default maximum is 200MB on i386,
668*ca987d46SWarner Loshand 400MB on amd64 and sparc64.
669*ca987d46SWarner LoshThis parameter is used to
670*ca987d46SWarner Loshprevent the buffer cache from eating too much
671*ca987d46SWarner LoshKVM in large-memory machine configurations.
672*ca987d46SWarner LoshOnly mess around with this parameter if you need to
673*ca987d46SWarner Loshgreatly extend the KVM reservation for other resources
674*ca987d46SWarner Loshsuch as the swap zone or
675*ca987d46SWarner Losh.Va kern.ipc.nmbclusters .
676*ca987d46SWarner LoshNote that
677*ca987d46SWarner Loshthe NBUF parameter will override this limit.
678*ca987d46SWarner LoshModifies
679*ca987d46SWarner Losh.Dv VM_BCACHE_SIZE_MAX .
680*ca987d46SWarner Losh.It Va kern.msgbufsize
681*ca987d46SWarner LoshSets the size of the kernel message buffer.
682*ca987d46SWarner LoshThe default limit of 64KB is usually sufficient unless
683*ca987d46SWarner Loshlarge amounts of trace data need to be collected
684*ca987d46SWarner Loshbetween opportunities to examine the buffer or
685*ca987d46SWarner Loshdump it to a file.
686*ca987d46SWarner LoshOverrides kernel option
687*ca987d46SWarner Losh.Dv MSGBUF_SIZE .
688*ca987d46SWarner Losh.It Va machdep.disable_mtrrs
689*ca987d46SWarner LoshDisable the use of i686 MTRRs (x86 only).
690*ca987d46SWarner Losh.It Va net.inet.tcp.tcbhashsize
691*ca987d46SWarner LoshOverrides the compile-time set value of
692*ca987d46SWarner Losh.Dv TCBHASHSIZE
693*ca987d46SWarner Loshor the preset default of 512.
694*ca987d46SWarner LoshMust be a power of 2.
695*ca987d46SWarner Losh.It Va twiddle_divisor
696*ca987d46SWarner LoshThrottles the output of the
697*ca987d46SWarner Losh.Sq twiddle
698*ca987d46SWarner LoshI/O progress indicator displayed while loading the kernel and modules.
699*ca987d46SWarner LoshThis is useful on slow serial consoles where the time spent waiting for
700*ca987d46SWarner Loshthese characters to be written can add up to many seconds.
701*ca987d46SWarner LoshThe default is 1 (full speed); a value of 2 spins half as fast, and so on.
702*ca987d46SWarner Losh.It Va vm.kmem_size
703*ca987d46SWarner LoshSets the size of kernel memory (bytes).
704*ca987d46SWarner LoshThis overrides the value determined when the kernel was compiled.
705*ca987d46SWarner LoshModifies
706*ca987d46SWarner Losh.Dv VM_KMEM_SIZE .
707*ca987d46SWarner Losh.It Va vm.kmem_size_min
708*ca987d46SWarner Losh.It Va vm.kmem_size_max
709*ca987d46SWarner LoshSets the minimum and maximum (respectively) amount of kernel memory
710*ca987d46SWarner Loshthat will be automatically allocated by the kernel.
711*ca987d46SWarner LoshThese override the values determined when the kernel was compiled.
712*ca987d46SWarner LoshModifies
713*ca987d46SWarner Losh.Dv VM_KMEM_SIZE_MIN
714*ca987d46SWarner Loshand
715*ca987d46SWarner Losh.Dv VM_KMEM_SIZE_MAX .
716*ca987d46SWarner Losh.El
717*ca987d46SWarner Losh.Ss BUILTIN PARSER
718*ca987d46SWarner LoshWhen a builtin command is executed, the rest of the line is taken
719*ca987d46SWarner Loshby it as arguments, and it is processed by a special parser which
720*ca987d46SWarner Loshis not used for regular Forth commands.
721*ca987d46SWarner Losh.Pp
722*ca987d46SWarner LoshThis special parser applies the following rules to the parsed text:
723*ca987d46SWarner Losh.Bl -enum
724*ca987d46SWarner Losh.It
725*ca987d46SWarner LoshAll backslash characters are preprocessed.
726*ca987d46SWarner Losh.Bl -bullet
727*ca987d46SWarner Losh.It
728*ca987d46SWarner Losh\eb , \ef , \er , \en and \et are processed as in C.
729*ca987d46SWarner Losh.It
730*ca987d46SWarner Losh\es is converted to a space.
731*ca987d46SWarner Losh.It
732*ca987d46SWarner Losh\ev is converted to
733*ca987d46SWarner Losh.Tn ASCII
734*ca987d46SWarner Losh11.
735*ca987d46SWarner Losh.It
736*ca987d46SWarner Losh\ez is just skipped.
737*ca987d46SWarner LoshUseful for things like
738*ca987d46SWarner Losh.Dq \e0xf\ez\e0xf .
739*ca987d46SWarner Losh.It
740*ca987d46SWarner Losh\e0xN and \e0xNN are replaced by the hex N or NN.
741*ca987d46SWarner Losh.It
742*ca987d46SWarner Losh\eNNN is replaced by the octal NNN
743*ca987d46SWarner Losh.Tn ASCII
744*ca987d46SWarner Loshcharacter.
745*ca987d46SWarner Losh.It
746*ca987d46SWarner Losh\e" , \e' and \e$ will escape these characters, preventing them from
747*ca987d46SWarner Loshreceiving special treatment in Step 2, described below.
748*ca987d46SWarner Losh.It
749*ca987d46SWarner Losh\e\e will be replaced with a single \e .
750*ca987d46SWarner Losh.It
751*ca987d46SWarner LoshIn any other occurrence, backslash will just be removed.
752*ca987d46SWarner Losh.El
753*ca987d46SWarner Losh.It
754*ca987d46SWarner LoshEvery string between non-escaped quotes or double-quotes will be treated
755*ca987d46SWarner Loshas a single word for the purposes of the remaining steps.
756*ca987d46SWarner Losh.It
757*ca987d46SWarner LoshReplace any
758*ca987d46SWarner Losh.Li $VARIABLE
759*ca987d46SWarner Loshor
760*ca987d46SWarner Losh.Li ${VARIABLE}
761*ca987d46SWarner Loshwith the value of the environment variable
762*ca987d46SWarner Losh.Va VARIABLE .
763*ca987d46SWarner Losh.It
764*ca987d46SWarner LoshSpace-delimited arguments are passed to the called builtin command.
765*ca987d46SWarner LoshSpaces can also be escaped through the use of \e\e .
766*ca987d46SWarner Losh.El
767*ca987d46SWarner Losh.Pp
768*ca987d46SWarner LoshAn exception to this parsing rule exists, and is described in
769*ca987d46SWarner Losh.Sx BUILTINS AND FORTH .
770*ca987d46SWarner Losh.Ss BUILTINS AND FORTH
771*ca987d46SWarner LoshAll builtin words are state-smart, immediate words.
772*ca987d46SWarner LoshIf interpreted, they behave exactly as described previously.
773*ca987d46SWarner LoshIf they are compiled, though,
774*ca987d46SWarner Loshthey extract their arguments from the stack instead of the command line.
775*ca987d46SWarner Losh.Pp
776*ca987d46SWarner LoshIf compiled, the builtin words expect to find, at execution time, the
777*ca987d46SWarner Loshfollowing parameters on the stack:
778*ca987d46SWarner Losh.D1 Ar addrN lenN ... addr2 len2 addr1 len1 N
779*ca987d46SWarner Loshwhere
780*ca987d46SWarner Losh.Ar addrX lenX
781*ca987d46SWarner Loshare strings which will compose the command line that will be parsed
782*ca987d46SWarner Loshinto the builtin's arguments.
783*ca987d46SWarner LoshInternally, these strings are concatenated in from 1 to N,
784*ca987d46SWarner Loshwith a space put between each one.
785*ca987d46SWarner Losh.Pp
786*ca987d46SWarner LoshIf no arguments are passed, a 0
787*ca987d46SWarner Losh.Em must
788*ca987d46SWarner Loshbe passed, even if the builtin accepts no arguments.
789*ca987d46SWarner Losh.Pp
790*ca987d46SWarner LoshWhile this behavior has benefits, it has its trade-offs.
791*ca987d46SWarner LoshIf the execution token of a builtin is acquired (through
792*ca987d46SWarner Losh.Ic '
793*ca987d46SWarner Loshor
794*ca987d46SWarner Losh.Ic ['] ) ,
795*ca987d46SWarner Loshand then passed to
796*ca987d46SWarner Losh.Ic catch
797*ca987d46SWarner Loshor
798*ca987d46SWarner Losh.Ic execute ,
799*ca987d46SWarner Loshthe builtin behavior will depend on the system state
800*ca987d46SWarner Losh.Bf Em
801*ca987d46SWarner Loshat the time
802*ca987d46SWarner Losh.Ic catch
803*ca987d46SWarner Loshor
804*ca987d46SWarner Losh.Ic execute
805*ca987d46SWarner Loshis processed!
806*ca987d46SWarner Losh.Ef
807*ca987d46SWarner LoshThis is particularly annoying for programs that want or need to
808*ca987d46SWarner Loshhandle exceptions.
809*ca987d46SWarner LoshIn this case, the use of a proxy is recommended.
810*ca987d46SWarner LoshFor example:
811*ca987d46SWarner Losh.Dl : (boot) boot ;
812*ca987d46SWarner Losh.Sh FICL
813*ca987d46SWarner Losh.Tn FICL
814*ca987d46SWarner Loshis a Forth interpreter written in C, in the form of a forth
815*ca987d46SWarner Loshvirtual machine library that can be called by C functions and vice
816*ca987d46SWarner Loshversa.
817*ca987d46SWarner Losh.Pp
818*ca987d46SWarner LoshIn
819*ca987d46SWarner Losh.Nm ,
820*ca987d46SWarner Losheach line read interactively is then fed to
821*ca987d46SWarner Losh.Tn FICL ,
822*ca987d46SWarner Loshwhich may call
823*ca987d46SWarner Losh.Nm
824*ca987d46SWarner Loshback to execute the builtin words.
825*ca987d46SWarner LoshThe builtin
826*ca987d46SWarner Losh.Ic include
827*ca987d46SWarner Loshwill also feed
828*ca987d46SWarner Losh.Tn FICL ,
829*ca987d46SWarner Loshone line at a time.
830*ca987d46SWarner Losh.Pp
831*ca987d46SWarner LoshThe words available to
832*ca987d46SWarner Losh.Tn FICL
833*ca987d46SWarner Loshcan be classified into four groups.
834*ca987d46SWarner LoshThe
835*ca987d46SWarner Losh.Tn ANS
836*ca987d46SWarner LoshForth standard words, extra
837*ca987d46SWarner Losh.Tn FICL
838*ca987d46SWarner Loshwords, extra
839*ca987d46SWarner Losh.Fx
840*ca987d46SWarner Loshwords, and the builtin commands;
841*ca987d46SWarner Loshthe latter were already described.
842*ca987d46SWarner LoshThe
843*ca987d46SWarner Losh.Tn ANS
844*ca987d46SWarner LoshForth standard words are listed in the
845*ca987d46SWarner Losh.Sx STANDARDS
846*ca987d46SWarner Loshsection.
847*ca987d46SWarner LoshThe words falling in the two other groups are described in the
848*ca987d46SWarner Loshfollowing subsections.
849*ca987d46SWarner Losh.Ss FICL EXTRA WORDS
850*ca987d46SWarner Losh.Bl -tag -width wid-set-super
851*ca987d46SWarner Losh.It Ic .env
852*ca987d46SWarner Losh.It Ic .ver
853*ca987d46SWarner Losh.It Ic -roll
854*ca987d46SWarner Losh.It Ic 2constant
855*ca987d46SWarner Losh.It Ic >name
856*ca987d46SWarner Losh.It Ic body>
857*ca987d46SWarner Losh.It Ic compare
858*ca987d46SWarner LoshThis is the STRING word set's
859*ca987d46SWarner Losh.Ic compare .
860*ca987d46SWarner Losh.It Ic compile-only
861*ca987d46SWarner Losh.It Ic endif
862*ca987d46SWarner Losh.It Ic forget-wid
863*ca987d46SWarner Losh.It Ic parse-word
864*ca987d46SWarner Losh.It Ic sliteral
865*ca987d46SWarner LoshThis is the STRING word set's
866*ca987d46SWarner Losh.Ic sliteral .
867*ca987d46SWarner Losh.It Ic wid-set-super
868*ca987d46SWarner Losh.It Ic w@
869*ca987d46SWarner Losh.It Ic w!
870*ca987d46SWarner Losh.It Ic x.
871*ca987d46SWarner Losh.It Ic empty
872*ca987d46SWarner Losh.It Ic cell-
873*ca987d46SWarner Losh.It Ic -rot
874*ca987d46SWarner Losh.El
875*ca987d46SWarner Losh.Ss FREEBSD EXTRA WORDS
876*ca987d46SWarner Losh.Bl -tag -width XXXXXXXX
877*ca987d46SWarner Losh.It Ic \&$ Pq --
878*ca987d46SWarner LoshEvaluates the remainder of the input buffer, after having printed it first.
879*ca987d46SWarner Losh.It Ic \&% Pq --
880*ca987d46SWarner LoshEvaluates the remainder of the input buffer under a
881*ca987d46SWarner Losh.Ic catch
882*ca987d46SWarner Loshexception guard.
883*ca987d46SWarner Losh.It Ic .#
884*ca987d46SWarner LoshWorks like
885*ca987d46SWarner Losh.Ic "."
886*ca987d46SWarner Loshbut without outputting a trailing space.
887*ca987d46SWarner Losh.It Ic fclose Pq Ar fd --
888*ca987d46SWarner LoshCloses a file.
889*ca987d46SWarner Losh.It Ic fkey Pq Ar fd -- char
890*ca987d46SWarner LoshReads a single character from a file.
891*ca987d46SWarner Losh.It Ic fload Pq Ar fd --
892*ca987d46SWarner LoshProcesses a file
893*ca987d46SWarner Losh.Em fd .
894*ca987d46SWarner Losh.It Ic fopen Pq Ar addr len mode Li -- Ar fd
895*ca987d46SWarner LoshOpens a file.
896*ca987d46SWarner LoshReturns a file descriptor, or \-1 in case of failure.
897*ca987d46SWarner LoshThe
898*ca987d46SWarner Losh.Ar mode
899*ca987d46SWarner Loshparameter selects whether the file is to be opened for read access, write
900*ca987d46SWarner Loshaccess, or both.
901*ca987d46SWarner LoshThe constants
902*ca987d46SWarner Losh.Dv O_RDONLY , O_WRONLY ,
903*ca987d46SWarner Loshand
904*ca987d46SWarner Losh.Dv O_RDWR
905*ca987d46SWarner Loshare defined in
906*ca987d46SWarner Losh.Pa /boot/support.4th ,
907*ca987d46SWarner Loshindicating read only, write only, and read-write access, respectively.
908*ca987d46SWarner Losh.It Xo
909*ca987d46SWarner Losh.Ic fread
910*ca987d46SWarner Losh.Pq Ar fd addr len -- len'
911*ca987d46SWarner Losh.Xc
912*ca987d46SWarner LoshTries to read
913*ca987d46SWarner Losh.Em len
914*ca987d46SWarner Loshbytes from file
915*ca987d46SWarner Losh.Em fd
916*ca987d46SWarner Loshinto buffer
917*ca987d46SWarner Losh.Em addr .
918*ca987d46SWarner LoshReturns the actual number of bytes read, or -1 in case of error or end of
919*ca987d46SWarner Loshfile.
920*ca987d46SWarner Losh.It Ic heap? Pq -- Ar cells
921*ca987d46SWarner LoshReturn the space remaining in the dictionary heap, in cells.
922*ca987d46SWarner LoshThis is not related to the heap used by dynamic memory allocation words.
923*ca987d46SWarner Losh.It Ic inb Pq Ar port -- char
924*ca987d46SWarner LoshReads a byte from a port.
925*ca987d46SWarner Losh.It Ic key Pq -- Ar char
926*ca987d46SWarner LoshReads a single character from the console.
927*ca987d46SWarner Losh.It Ic key? Pq -- Ar flag
928*ca987d46SWarner LoshReturns
929*ca987d46SWarner Losh.Ic true
930*ca987d46SWarner Loshif there is a character available to be read from the console.
931*ca987d46SWarner Losh.It Ic ms Pq Ar u --
932*ca987d46SWarner LoshWaits
933*ca987d46SWarner Losh.Em u
934*ca987d46SWarner Loshmicroseconds.
935*ca987d46SWarner Losh.It Ic outb Pq Ar port char --
936*ca987d46SWarner LoshWrites a byte to a port.
937*ca987d46SWarner Losh.It Ic seconds Pq -- Ar u
938*ca987d46SWarner LoshReturns the number of seconds since midnight.
939*ca987d46SWarner Losh.It Ic tib> Pq -- Ar addr len
940*ca987d46SWarner LoshReturns the remainder of the input buffer as a string on the stack.
941*ca987d46SWarner Losh.It Ic trace! Pq Ar flag --
942*ca987d46SWarner LoshActivates or deactivates tracing.
943*ca987d46SWarner LoshDoes not work with
944*ca987d46SWarner Losh.Ic catch .
945*ca987d46SWarner Losh.El
946*ca987d46SWarner Losh.Ss FREEBSD DEFINED ENVIRONMENTAL QUERIES
947*ca987d46SWarner Losh.Bl -tag -width Ds
948*ca987d46SWarner Losh.It arch-i386
949*ca987d46SWarner Losh.Ic TRUE
950*ca987d46SWarner Loshif the architecture is IA32.
951*ca987d46SWarner Losh.It FreeBSD_version
952*ca987d46SWarner Losh.Fx
953*ca987d46SWarner Loshversion at compile time.
954*ca987d46SWarner Losh.It loader_version
955*ca987d46SWarner Losh.Nm
956*ca987d46SWarner Loshversion.
957*ca987d46SWarner Losh.El
958*ca987d46SWarner Losh.Ss SYSTEM DOCUMENTATION
959*ca987d46SWarner Losh.Sh FILES
960*ca987d46SWarner Losh.Bl -tag -width /boot/defaults/loader.conf -compact
961*ca987d46SWarner Losh.It Pa /boot/loader
962*ca987d46SWarner Losh.Nm
963*ca987d46SWarner Loshitself.
964*ca987d46SWarner Losh.It Pa /boot/boot.4th
965*ca987d46SWarner LoshAdditional
966*ca987d46SWarner Losh.Tn FICL
967*ca987d46SWarner Loshinitialization.
968*ca987d46SWarner Losh.It Pa /boot/defaults/loader.conf
969*ca987d46SWarner Losh.It Pa /boot/loader.conf
970*ca987d46SWarner Losh.It Pa /boot/loader.conf.local
971*ca987d46SWarner Losh.Nm
972*ca987d46SWarner Loshconfiguration files, as described in
973*ca987d46SWarner Losh.Xr loader.conf 5 .
974*ca987d46SWarner Losh.It Pa /boot/loader.rc
975*ca987d46SWarner Losh.Nm
976*ca987d46SWarner Loshbootstrapping script.
977*ca987d46SWarner Losh.It Pa /boot/loader.help
978*ca987d46SWarner LoshLoaded by
979*ca987d46SWarner Losh.Ic help .
980*ca987d46SWarner LoshContains the help messages.
981*ca987d46SWarner Losh.El
982*ca987d46SWarner Losh.Sh EXAMPLES
983*ca987d46SWarner LoshBoot in single user mode:
984*ca987d46SWarner Losh.Pp
985*ca987d46SWarner Losh.Dl boot -s
986*ca987d46SWarner Losh.Pp
987*ca987d46SWarner LoshLoad the kernel, a splash screen, and then autoboot in five seconds.
988*ca987d46SWarner LoshNotice that a kernel must be loaded before any other
989*ca987d46SWarner Losh.Ic load
990*ca987d46SWarner Loshcommand is attempted.
991*ca987d46SWarner Losh.Bd -literal -offset indent
992*ca987d46SWarner Loshload kernel
993*ca987d46SWarner Loshload splash_bmp
994*ca987d46SWarner Loshload -t splash_image_data /boot/chuckrulez.bmp
995*ca987d46SWarner Loshautoboot 5
996*ca987d46SWarner Losh.Ed
997*ca987d46SWarner Losh.Pp
998*ca987d46SWarner LoshSet the disk unit of the root device to 2, and then boot.
999*ca987d46SWarner LoshThis would be needed in a system with two IDE disks,
1000*ca987d46SWarner Loshwith the second IDE disk hardwired to ada2 instead of ada1.
1001*ca987d46SWarner Losh.Bd -literal -offset indent
1002*ca987d46SWarner Loshset root_disk_unit=2
1003*ca987d46SWarner Loshboot /boot/kernel/kernel
1004*ca987d46SWarner Losh.Ed
1005*ca987d46SWarner Losh.Pp
1006*ca987d46SWarner LoshSee also:
1007*ca987d46SWarner Losh.Bl -tag -width /usr/share/examples/bootforth/X
1008*ca987d46SWarner Losh.It Pa /boot/loader.4th
1009*ca987d46SWarner LoshExtra builtin-like words.
1010*ca987d46SWarner Losh.It Pa /boot/support.4th
1011*ca987d46SWarner Losh.Pa loader.conf
1012*ca987d46SWarner Loshprocessing words.
1013*ca987d46SWarner Losh.It Pa /usr/share/examples/bootforth/
1014*ca987d46SWarner LoshAssorted examples.
1015*ca987d46SWarner Losh.El
1016*ca987d46SWarner Losh.Sh ERRORS
1017*ca987d46SWarner LoshThe following values are thrown by
1018*ca987d46SWarner Losh.Nm :
1019*ca987d46SWarner Losh.Bl -tag -width XXXXX -offset indent
1020*ca987d46SWarner Losh.It 100
1021*ca987d46SWarner LoshAny type of error in the processing of a builtin.
1022*ca987d46SWarner Losh.It -1
1023*ca987d46SWarner Losh.Ic Abort
1024*ca987d46SWarner Loshexecuted.
1025*ca987d46SWarner Losh.It -2
1026*ca987d46SWarner Losh.Ic Abort"
1027*ca987d46SWarner Loshexecuted.
1028*ca987d46SWarner Losh.It -56
1029*ca987d46SWarner Losh.Ic Quit
1030*ca987d46SWarner Loshexecuted.
1031*ca987d46SWarner Losh.It -256
1032*ca987d46SWarner LoshOut of interpreting text.
1033*ca987d46SWarner Losh.It -257
1034*ca987d46SWarner LoshNeed more text to succeed -- will finish on next run.
1035*ca987d46SWarner Losh.It -258
1036*ca987d46SWarner Losh.Ic Bye
1037*ca987d46SWarner Loshexecuted.
1038*ca987d46SWarner Losh.It -259
1039*ca987d46SWarner LoshUnspecified error.
1040*ca987d46SWarner Losh.El
1041*ca987d46SWarner Losh.Sh SEE ALSO
1042*ca987d46SWarner Losh.Xr libstand 3 ,
1043*ca987d46SWarner Losh.Xr loader.conf 5 ,
1044*ca987d46SWarner Losh.Xr tuning 7 ,
1045*ca987d46SWarner Losh.Xr boot 8 ,
1046*ca987d46SWarner Losh.Xr btxld 8
1047*ca987d46SWarner Losh.Sh STANDARDS
1048*ca987d46SWarner LoshFor the purposes of ANS Forth compliance, loader is an
1049*ca987d46SWarner Losh.Bf Em
1050*ca987d46SWarner LoshANS Forth System with Environmental Restrictions, Providing
1051*ca987d46SWarner Losh.Ef
1052*ca987d46SWarner Losh.Bf Li
1053*ca987d46SWarner Losh.No .( ,
1054*ca987d46SWarner Losh.No :noname ,
1055*ca987d46SWarner Losh.No ?do ,
1056*ca987d46SWarner Loshparse, pick, roll, refill, to, value, \e, false, true,
1057*ca987d46SWarner Losh.No <> ,
1058*ca987d46SWarner Losh.No 0<> ,
1059*ca987d46SWarner Loshcompile\&, , erase, nip, tuck
1060*ca987d46SWarner Losh.Ef
1061*ca987d46SWarner Losh.Em and
1062*ca987d46SWarner Losh.Li marker
1063*ca987d46SWarner Losh.Bf Em
1064*ca987d46SWarner Loshfrom the Core Extensions word set, Providing the Exception Extensions
1065*ca987d46SWarner Loshword set, Providing the Locals Extensions word set, Providing the
1066*ca987d46SWarner LoshMemory-Allocation Extensions word set, Providing
1067*ca987d46SWarner Losh.Ef
1068*ca987d46SWarner Losh.Bf Li
1069*ca987d46SWarner Losh\&.s,
1070*ca987d46SWarner Loshbye, forget, see, words,
1071*ca987d46SWarner Losh\&[if],
1072*ca987d46SWarner Losh\&[else]
1073*ca987d46SWarner Losh.Ef
1074*ca987d46SWarner Losh.Em and
1075*ca987d46SWarner Losh.Li [then]
1076*ca987d46SWarner Losh.Bf Em
1077*ca987d46SWarner Loshfrom the Programming-Tools extension word set, Providing the
1078*ca987d46SWarner LoshSearch-Order extensions word set.
1079*ca987d46SWarner Losh.Ef
1080*ca987d46SWarner Losh.Sh HISTORY
1081*ca987d46SWarner LoshThe
1082*ca987d46SWarner Losh.Nm
1083*ca987d46SWarner Loshfirst appeared in
1084*ca987d46SWarner Losh.Fx 3.1 .
1085*ca987d46SWarner Losh.Sh AUTHORS
1086*ca987d46SWarner Losh.An -nosplit
1087*ca987d46SWarner LoshThe
1088*ca987d46SWarner Losh.Nm
1089*ca987d46SWarner Loshwas written by
1090*ca987d46SWarner Losh.An Michael Smith Aq msmith@FreeBSD.org .
1091*ca987d46SWarner Losh.Pp
1092*ca987d46SWarner Losh.Tn FICL
1093*ca987d46SWarner Loshwas written by
1094*ca987d46SWarner Losh.An John Sadler Aq john_sadler@alum.mit.edu .
1095*ca987d46SWarner Losh.Sh BUGS
1096*ca987d46SWarner LoshThe
1097*ca987d46SWarner Losh.Ic expect
1098*ca987d46SWarner Loshand
1099*ca987d46SWarner Losh.Ic accept
1100*ca987d46SWarner Loshwords will read from the input buffer instead of the console.
1101*ca987d46SWarner LoshThe latter will be fixed, but the former will not.
1102