1.\" 2.\" SPDX-License-Identifier: BSD-2-Clause 3.\" 4.\" Copyright (c) 1999 Daniel C. Sobral 5.\" All rights reserved. 6.\" Copyright (c) 2021 Warner Losh <imp@FreeBSD.org> 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" SUCH DAMAGE. 28.\" 29.Dd September 29, 2021 30.Dt LOADER 8 31.Os 32.Sh NAME 33.Nm loader 34.Nd kernel bootstrapping final stage 35.Sh DESCRIPTION 36The program called 37.Nm 38is the final stage of 39.Fx Ns 's 40kernel bootstrapping process. 41It is responsible for bringing the kernel, kernel modules and other files into 42memory. 43It creates a set of 44.Xr sh 1 45like environment variables that are passed to the kernel. 46It executes boot scripts written in one of several interpreters. 47Together with the scripts, it controls the booting process and 48interaction with the user. 49.Pp 50It provides a scripting language that can be used to 51automate tasks, do pre-configuration or assist in recovery 52procedures. 53This scripting language is roughly divided in 54two main components. 55The smaller one is a set of commands 56designed for direct use by the casual user, called "builtin 57commands" for historical reasons. 58The main drive behind these commands is user-friendliness. 59The larger component is the scripting language built into 60the boot loader. 61.Fx 62provides three different interpreters: Forth, Lua and Simple. 63The Forth loader is based on an ANS Forth compatible 64Forth interpreter based on FICL, by 65.An John Sadler . 66The Lua loader is a full Lua interpreter from 67.Pa https://www.lua.org/ . 68The Simple loader only interprets a list of builtin commands 69without any control structure. 70.Pp 71During initialization, 72.Nm 73will probe for a console and set the 74.Va console 75variable, or set it to serial console 76.Pq Dq Li comconsole 77if the previous boot stage used that. 78If multiple consoles are selected, they will be listed separated by spaces. 79Then, devices are probed, 80.Va currdev 81and 82.Va loaddev 83are set, and 84.Va LINES 85is set to 24. 86Finally, an interpreter specific file will be executed. 87.Sh BUILTIN COMMANDS 88The commands common to all interpreters are described in the 89.Xr loader_simp 8 90.Dq BUILTIN COMMANDS 91section. 92.Ss BUILTIN ENVIRONMENT VARIABLES 93The environment variables common to all interpreters are described in the 94.Xr loader_simp 8 95.Dq BUILTIN ENVIRONMENT VARIABLES 96section. 97.Sh SEE ALSO 98.Xr libsa 3 , 99.Xr loader.conf 5 , 100.Xr tuning 7 , 101.Xr boot 8 , 102.Xr btxld 8 , 103.Xr loader.efi 8 , 104.Xr loader_4th 8 , 105.Xr loader_lua 8 , 106.Xr loader_simp 8 107.Sh HISTORY 108The 109.Nm 110first appeared in 111.Fx 3.1 . 112The 113.Nm 114scripting language changed to Lua by default in 115.Fx 12.0 . 116.Sh AUTHORS 117.An -nosplit 118The 119.Nm 120was written by 121.An Michael Smith Aq Mt msmith@FreeBSD.org . 122.Pp 123FICL was written by 124.An John Sadler Aq Mt john_sadler@alum.mit.edu . 125.Pp 126.An Warner Losh Aq Mt imp@FreeBSD.org 127integrated Lua into the tree based on initial work done by Pedro Souza 128for the 2014 Google Summer of Code. 129