LOADER.LUA(8) FreeBSD System Manager's Manual LOADER.LUA(8)

loader.luaFx Lua loader module

The built-in Lua bindings for the FreeBSD boot loaders using the Lua interpreter are available via the loader table.

The loader table is always available in Lua scripts. There is no need to require it like other loader-specific modules.

The following variables are exported from in the loader table:

The target's hw.machine sysctl(8) value.
The target's hw.machine_arch sysctl(8) value. Some boot loaders are 32-bit applications that then load a 64-bit kernel. In these cases, machine_arch represents the 32-bit architecture, not the 64-bit architecture.
The current lua loading path.
The version of the boot program.

The following functions are exported in the loader table.

(usec)
Delay for usec microseconds.
()
Returns the error string from the last command to fail.
(argc, argv)
Like () but the arguments are already parsed onto the stack.
(str)
Execute the loader builtin command str as if it were typed by the user. This will first try to execute str as Lua. If that fails, it will attempt to execute it as a cli command, including those defined by the cli.lua(8) mechanism. If that fails, it will attempt to execute it as a builtin command and return the same values as perform().
(str)
Parses the command str into its words and return those words on the stack.
(name)
Obtains the value of the environment variable name.
(cmd)
returns true if commmand is present in the interpreter as a builtin. Otherwise it returns nil and an error string. It does not check the “cli” table to see if a user defined command has been created.
(feature)
returns true if the feature is enabled. Otherwise it returns nil and an error string.
perform(str)
Execute the loader builtin command str. Returns the result of the command, one of the following values:
loader.CMD_OK
The command completed successfully.
loader.CMD_WARN
The command was successful, but the user stopped its output prematurely.
loader.CMD_ERROR
The command did not complete successfully. Use command_error to retrieve the error.
loader.CMD_CRIT
The command returned a critical error that was already printed.
loader.CMD_FATAL
The command determined continuation was not possible and the loader panicked. In practice, though () does not return.
(str)
Outputs the string using the loader's () function. This function is also available globally as printc().
(name, value)
Insert or reset the environment variable name into the loader's environment list. If no environment variable with this name exists, one is created. If one exists, its value is replaced and any change callback function registers at creation is called.
()
Returns the loader's notion of time, in seconds since 1970. The value of loader's notion varies somewhat between different loading environments.
(name)
Removes the environment variable name from the loader's environment list.
(x0, y0, x1, y1, x2, y2, width)
Draw a bezier curve through the points (x0, y0), (x1, y1), and (x1, y1) of width width.
(x0, y0, x1, y1, fill)
Fill in a rectangle with the pixel fill with the corners (x0, y0) and (x1, y1).
(x0, y0, x1, y1, width)
Draw a line from (x0, y0) to (x1, y1) with a width of width.
(name, x1, y1, x2, y2, f)
Load the PNG file name and place it in the rectangle with the corners (x1, y1) and (x2, y2) and fill with pixel f.
(x, y)
Sets the pixel at (x, y).
(x0, y0, x1, y1)
Draw the outline of a rectangle with the text coordinate corners of (x0, y0) and (x1, y1).
(name, x1, y1, x2, y2, f)
Load the PNG file name and place it in the rectangle with the text coordinate corners (x1, y1) and (x2, y2) and fill with pixel f.

The functions starting with () and () are optional. They should only be used if they are non-nil and if () is true.

In addition, the Lua interpreters start with the file /boot/lua/loader.lua when they start to boot the system. The default one will fixup the screen, load the configuration files, check for a password, and then load the menu or load the kernel file and then return. If autoboot is enabled, the loaded files will boot.

loader.conf(5), core.lua(8), loader(8), sysctl(8)

The loader.lua man page was written by Warner Losh <imp@FreeBSD.org>.

command() and perform() should return a tuple when there's CMD_ERROR or worse..

February 1, 2024 FreeBSD 15.0-CURRENT