| LOADER(7) | Standards, Environments, and Macros | LOADER(7) | 
loader — kernel
    bootstrapping final stage
The loader is the final stage of
    illumos's kernel bootstrapping process. The actual
    name for the stage depends on the platform. On IA32 (i386) architectures
    with BIOS firmware, it is a BTX client and named
    loader. It is linked statically to libstand and
    usually located in the directory /boot.
loader supports booting from
    ZFS, UFS,
    PCFS, HSFS and
    NFS file systems. Additionally,
    loader can load files from the
    TFTP file service. The NFS and TFTP based boot is
    enabled via pxeboot(7). The
    loader also does support uncompressing gzip files
    while reading. The uncompression will happen automatically if the compressed
    file is stored without .gz suffix or if the file is accessed by leaving out
    the .gz suffix from the name. If the file is referred by full name,
    including .gz suffix, then the file content is read as is and the
    uncompression is not performed.
loader 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 ANS Forth compatible Forth interpreter based on FICL, by
    John Sadler.
During initialization, loader will probe
    for a console and set the console variable, or set it
    to serial console (“ttya” -
    “ttyd”) if the previous boot stage
    used that. If multiple consoles are selected, they will be listed separated
    by commas. Then, devices are probed, currdev and
    loaddev are set, and
    screen-#cols, screen-#rows, and
    ISADIR are set. Next, FICL is initialized, the builtin
    words are added to its vocabulary. The inner interpreter
    loader will use with FICL is then set to
    interpret, which is FICL's default. After that,
    /boot/loader.rc is processed if available. These
    files are processed through the include command,
    which reads all of them into memory before processing them, making disk
    changes possible.
At this point, if an autoboot has not been
    tried, and if autoboot_delay is not set to
    “NO” (not case sensitive), then an
    autoboot will be tried. If the system gets past this
    point, prompt will be set and
    loader will engage interactive mode. Please note
    that historically even when autoboot_delay is set to
    “0” user will be able to interrupt
    autoboot process by pressing some key on the console while kernel and
    modules are being loaded. In some cases such behaviour may be undesirable,
    to prevent it set autoboot_delay to
    “-1”, in this case
    loader will engage interactive mode only if
    autoboot has failed.
In loader, builtin commands take
    parameters from the command line. If an error condition occurs, an exception
    will be generated, which can be intercepted using 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.
The builtin commands available are:
autoboot
    [seconds [prompt]]bcachestatbootboot
    kernelname [...]boot
    -flag ...WARNING: The behavior of this builtin is changed if loader.4th(7) is loaded.
chain
    deviceecho
    [-n] [⟨message⟩]-n is specified.
    
  heaphelp
    [topic [subtopic]]include
    file [file ...]load
    [-t type]
    file ...ls
    [-l] [path]-l is specified, file sizes will be shown too.
    
  lsdev
    [-v]-v is specified, more details are printed. For ZFS
      pools the output resembles zpool
      status output.
    
  lsmod
    [-v]-v is specified, more
      details are shown.
    
  lszfs
    filesystemmore
    file [file ...]read
    [-t seconds]
    [-p prompt]
    [variable]-t, though it will be canceled at the first
      key pressed. A prompt may also be displayed through the
      -p flag.
    
  reboot
    [-f]-f flag is set, or the
      BOOT_TO_FW_UI environment variable exists, and the
      firmware supports this feature, the system will automatically enter the
      firmware setup after reboot.
    
  set
    variableset
    variable=valueshow
    [variable]unloadunset
    variable?loader supports the following format for
    specifying ZFS filesystems which can be used wherever
    loader refers to a device specification:
zfs:pool/filesystem:
where pool/filesystem is a ZFS filesystem name as described in zfs(8).
The loader has actually two different
    kinds of ‘environment’ variables. There are ANS Forth's
    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.
Environment variables can be set and unset through the
    set and unset builtins, and
    can have their values interactively examined through the use of the
    show builtin. Their values can also be accessed as
    described in BUILTIN PARSER.
Notice that these environment variables are not inherited by any shell after the system has been booted.
A few variables are set automatically by
    loader. Others can affect the behavior of either
    loader 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.
autoboot will wait before
      booting. If this variable is not defined, autoboot
      will default to 10 seconds.
    If set to “NO”, no
        autoboot will be automatically attempted after
        processing /boot/loader.rc, though explicit
        autoboot's will be processed normally,
        defaulting to 10 seconds delay.
If set to “0”, no delay
        will be inserted, but user still will be able to interrupt
        autoboot process and escape into the interactive
        mode by pressing some key on the console while kernel and modules are
        being loaded.
If set to “-1”, no delay
        will be inserted and loader will engage
        interactive mode only if autoboot has failed for
        some reason.
-a option.-d option.-k option.-r option.-s option.-v option.loader configuration, the
      loader startup will parse the
      boot-args value to set boot prefixed variables
      listed above, any unrecognized options are added to kernel command line
      verbatim.chain command and will cause chain command menu
      entry to appear on loader main menu. The alternate
      method to use chain loader is to add menu entries into
      menu.lst(5) file.ok” if the Forth's
      current state is interpreting./platform/i86pc/${ISADIR}”loader's prompt. Defaults to
      “${interpret}”. If variable
      prompt is unset, the default prompt is
      ‘>’.Other variables are used for loader or to set kernel properties or for informational purposes.
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.
This special parser applies the following rules to the parsed text:
$VARIABLE or
      ${VARIABLE} with the value of the environment
      variable VARIABLE.An exception to this parsing rule exists, and is described in 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.
If compiled, the builtin words expect to find, at execution time, the following parameters on the stack:
If no arguments are passed, a 0 must be passed, even if the builtin accepts no arguments.
While this behavior has benefits, it has its trade-offs. If the
    execution token of a builtin is acquired (through '
    or [']), and then passed to
    catch or execute, the
    builtin behavior will depend on the system state
catch or
  execute is processed!: (boot) bootFICL 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.
In loader, each line read interactively is
    then fed to FICL, which may call loader back to
    execute the builtin words. The builtin include will
    also feed FICL, one line at a time.
The words available to FICL can be classified into four groups. The ANS Forth standard words, extra FICL words, extra FreeBSD words, and the builtin commands; the latter were already described. The ANS Forth standard words are listed in the STANDARDS section. The words falling in the two other groups are described in the following subsections.
.env.ver-roll2constant>namebody>comparecompare.compile-onlyendifforget-widparse-wordsliteralsliteral.wid-set-superw@w!x.emptycell--rot$
    (--)%
    (--)catch exception guard..#. but without outputting a trailing
      space.fclose
    (fd --)fkey
    (fd -- char)fload
    (fd --)fopen
    (addr len mode --
    fd)O_RDONLY, O_WRONLY, and
      O_RDWR are defined in
      /boot/forth/support.4th, indicating read only,
      write only, and read-write access, respectively.fread
    (fd addr len -- len')heap?
    (-- cells)inb
    (port -- char)isvirtualized?
    (-- addr len flag | flag)true and string with virtualization engine
      name or false.key
    (-- char)key?
    (-- flag)true if there is a character available to
      be read from the console.ms
    (u --)outb
    (port char --)seconds
    (-- u)tib>
    (-- addr len)fb-bezier
    (x1 y1 x2 y2 x3 y3 width --)fb-drawrect
    (x1 y1 x2 y2 fill --)true then the rectangle will be filled in.fb-line
    (x1 y1 x2 y2 width --)fb-putimage
    (flags x1 y1 x2 y2 addr len -- flag)true if
      the image was able to be written and false
      otherwise. Only truecolor PNG images are supported and the path to the
      file must be provided through the addr and
      len arguments on the stack. The image will be displayed
      in the rectangular screen region with the top left at
      (x1,y1) and the bottom right at
      (x2,y2)
    Either x2 or y2 can be set to "0" which causes it to be calculated to maintain the aspect ratio of the image. If both are "0" then the native resolution of the image will be used.
If x1 is "0", then the image will be placed as far over to the right of the screen as possible. Similarly, if y1 is "0", then the image will be placed as far down the screen as possible.
Flags is a bitfield; the following bits are defined:
fb-setpixel
    (x y --)term-drawrect
    (x1 y1 x2 y2 --)TRUE if the
      architecture is IA32.loader version.The following values are thrown by
  loader:
loader configuration files, as described in
      loader.conf(5).help. Contains the help messages.loader bootstrapping script.loader itself.Boot in single user mode:
boot -sLoad the kernel, a boot_archive, and then autoboot in five
    seconds. Notice that a kernel must be loaded before any other
    load command is attempted.
load /platform/i86pc/kernel/amd64/unix load -t rootfs /platform/i86pc/amd64/boot_archive autoboot 5
Set the default device used for loading a kernel from a ZFS filesystem:
set currdev=zfs:rpool/ROOT/knowngood:
Although setting the currdev as shown in the example above is supported, it is advisable to use loader beadm command or boot environment menu instead. The reason is, the beadm or menu selection will also instruct loader to clean up the currently set configuration and load configuration from the new boot environment.
For the purposes of ANS Forth compliance, loader is an
marker
[then]
| March 30, 2023 | OmniOS |