1913bd098SKyle Evans.\" 24d846d26SWarner Losh.\" SPDX-License-Identifier: BSD-2-Clause 3913bd098SKyle Evans.\" 4913bd098SKyle Evans.\" Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org> 5913bd098SKyle Evans.\" 6913bd098SKyle Evans.\" Redistribution and use in source and binary forms, with or without 7913bd098SKyle Evans.\" modification, are permitted provided that the following conditions 8913bd098SKyle Evans.\" are met: 9913bd098SKyle Evans.\" 1. Redistributions of source code must retain the above copyright 10913bd098SKyle Evans.\" notice, this list of conditions and the following disclaimer. 11913bd098SKyle Evans.\" 2. Redistributions in binary form must reproduce the above copyright 12913bd098SKyle Evans.\" notice, this list of conditions and the following disclaimer in the 13913bd098SKyle Evans.\" documentation and/or other materials provided with the distribution. 14913bd098SKyle Evans.\" 15913bd098SKyle Evans.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16913bd098SKyle Evans.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17913bd098SKyle Evans.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18913bd098SKyle Evans.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19913bd098SKyle Evans.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20913bd098SKyle Evans.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21913bd098SKyle Evans.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22913bd098SKyle Evans.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23913bd098SKyle Evans.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24913bd098SKyle Evans.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25913bd098SKyle Evans.\" SUCH DAMAGE. 26913bd098SKyle Evans.\" 271631382cSKyle Evans.Dd December 8, 2023 28913bd098SKyle Evans.Dt CORE.LUA 8 29913bd098SKyle Evans.Os 30913bd098SKyle Evans.Sh NAME 31913bd098SKyle Evans.Nm core.lua 32913bd098SKyle Evans.Nd FreeBSD core module 33913bd098SKyle Evans.Sh DESCRIPTION 34913bd098SKyle Evans.Nm 35913bd098SKyle Evanscontains core functionality that does not have a more fitting module. 36913bd098SKyle Evans.Pp 37913bd098SKyle EvansBefore hooking into or using the functionality provided by 38913bd098SKyle Evans.Nm , 39913bd098SKyle Evansit must be included with a statement such as the following: 40913bd098SKyle Evans.Pp 41913bd098SKyle Evans.Dl local core = require("core") 42913bd098SKyle Evans.Ss CONSTANTS 43913bd098SKyle EvansThe following raw key code constants are defined in 44913bd098SKyle Evans.Nm : 45913bd098SKyle Evans.Bl -tag -width KEY_BACKSPACE -compact -offset indent 46913bd098SKyle Evans.It Ic KEY_BACKSPACE 47913bd098SKyle EvansThe backspace code. 48913bd098SKyle EvansShould generally be checked along with 49913bd098SKyle Evans.Ic KEY_DELETE 50913bd098SKyle Evansfor backspace functionality. 51913bd098SKyle Evans.It Ic KEY_ENTER 52913bd098SKyle EvansThe enter key, or hard return. 53913bd098SKyle Evans.It Ic KEY_DELETE 54913bd098SKyle EvansThe delete code. 55913bd098SKyle EvansShould generally be checked along with 56913bd098SKyle Evans.Ic KEY_BACKSPACE 57913bd098SKyle Evansfor backspace functionality. 58913bd098SKyle Evans.El 59913bd098SKyle Evans.Pp 60913bd098SKyle EvansThe following key-string constants are defined in 61913bd098SKyle Evans.Nm : 62913bd098SKyle Evans.Bl -tag -width KEYSTR_ESCAPE -compact -offset indent 63913bd098SKyle Evans.It Ic KEYSTR_ESCAPE 64913bd098SKyle EvansThe escape key. 659eded7f4SKyle Evans.It Ic KEYSTR_CSI 669eded7f4SKyle EvansThe ANSI CSI sequence. 67913bd098SKyle Evans.El 68913bd098SKyle Evans.Pp 69913bd098SKyle EvansThe following menu entry type constants are defined in 70913bd098SKyle Evans.Nm : 71913bd098SKyle Evans.Bl -tag -width MENU_CAROUSEL_ENTRY -compact -offset indent 72913bd098SKyle Evans.It Ic MENU_RETURN 73913bd098SKyle EvansReturn to the parent menu. 74913bd098SKyle Evans.It Ic MENU_ENTRY 75913bd098SKyle EvansA normal menu entry. 76913bd098SKyle Evans.It Ic MENU_SEPARATOR 77913bd098SKyle EvansA menu entry that serves as a separator. 78913bd098SKyle Evans.It Ic MENU_SUBMENU 79913bd098SKyle EvansA menu entry that opens a submenu when selected. 80913bd098SKyle Evans.It Ic MENU_CAROUSEL_ENTRY 81913bd098SKyle EvansA menu entry that rotates through items like a carousel upon selection of the 82913bd098SKyle Evansmenu entry. 83913bd098SKyle Evans.El 84913bd098SKyle Evans.Pp 85913bd098SKyle EvansPlease see 86913bd098SKyle Evans.Xr menu.lua 8 87913bd098SKyle Evansfor extended descriptions and usage of the 88913bd098SKyle Evans.Ic MENU_* 89913bd098SKyle Evansconstants. 90913bd098SKyle Evans.Ss Exported functions 91913bd098SKyle EvansThe following functions are exported from 92913bd098SKyle Evans.Nm : 93e0f3dc82SR. Christian McDonald.Bl -tag -width core.setSingleUser -offset indent 94913bd098SKyle Evans.It Fn core.setVerbose verbose 95913bd098SKyle EvansSets or unsets 96913bd098SKyle Evans.Ev boot_verbose . 97913bd098SKyle EvansIf 98913bd098SKyle Evans.Fa verbose 99913bd098SKyle Evansis omitted, toggle the current verbose setting. 100913bd098SKyle Evans.It Fn core.setSingleUser singleUser 101913bd098SKyle EvansSets or unsets 102913bd098SKyle Evans.Ev boot_single . 103913bd098SKyle EvansIf 104913bd098SKyle Evans.Fa singleUser 105913bd098SKyle Evansis omitted, toggle the current single user setting. 106e0f3dc82SR. Christian McDonald.It Fn core.getACPI 107e0f3dc82SR. Christian McDonaldReturn true if ACPI is both present and not explicitly disabled by 108e0f3dc82SR. Christian McDonald.Ev hints.acpi.0.disabled . 109e0f3dc82SR. Christian McDonald.It Fn core.hasACPI 110e0f3dc82SR. Christian McDonaldChecks whether ACPI support is present. 111e0f3dc82SR. Christian McDonaldThis requires the loader to probe the system and set 112e0f3dc82SR. Christian McDonald.Ev acpi.rsdp 113e0f3dc82SR. Christian McDonaldearly before starting the interpreter. 114913bd098SKyle Evans.It Fn core.setACPI acpi 115913bd098SKyle EvansSets or unsets 116913bd098SKyle Evans.Ev acpi_load , 117913bd098SKyle Evans.Ev hint.acpi.0.disabled , 118913bd098SKyle Evansand 119913bd098SKyle Evans.Ev loader.acpi_disabled_by_user . 120913bd098SKyle EvansIf 121913bd098SKyle Evans.Fa acpi 122913bd098SKyle Evansis omitted, toggle the current ACPI setting. 123913bd098SKyle Evans.It Fn core.setSafeMode safeMode 124913bd098SKyle EvansSet the safe mode setting. 125913bd098SKyle EvansSets or unsets 126913bd098SKyle Evans.Ev kern.smp.disabled , 127913bd098SKyle Evans.Ev hw.ata.ata_dma , 128913bd098SKyle Evans.Ev hw.ata.atapi_dma , 129913bd098SKyle Evans.Ev kern.eventtimer.periodic , 130913bd098SKyle Evansand 131913bd098SKyle Evans.Ev kern.geom.part.check_integrity . 132913bd098SKyle EvansIf 133913bd098SKyle Evans.Fa safeMode 134913bd098SKyle Evansis omitted, toggle the current safe mode setting. 1355a79ea48SKyle Evans.It Fn core.clearCachedKernels 1365a79ea48SKyle EvansClears out the cache of kernels to be displayed on the boot menu. 1375a79ea48SKyle EvansThis function is registered as a 1385a79ea48SKyle Evans.Ev config.reloaded 1395a79ea48SKyle Evanshook. 1405a79ea48SKyle EvansIt is used to invalidate the kernel list whenever it may have changed, either 1415a79ea48SKyle Evansdue to a boot environment change or a potential change in either 1425a79ea48SKyle Evans.Ic kernel 1435a79ea48SKyle Evansor 1445a79ea48SKyle Evans.Ic kernels . 1451631382cSKyle Evans.It Fn core.hasFeature featureName 1461631382cSKyle EvansChecks whether the named 1471631382cSKyle Evans.Fa featureName 1481631382cSKyle Evansis enabled in the current loader. 1491631382cSKyle EvansThis is specifically used for detecting capabilities of the loaded loader 1501631382cSKyle Evansbinary, so that one can reasonably implement backwards compatibility shims if 1511631382cSKyle Evansneeded. 152913bd098SKyle Evans.It Fn core.kernelList 153913bd098SKyle EvansReturns a table of kernels to display on the boot menu. 154913bd098SKyle EvansThis will combine 155913bd098SKyle Evans.Ic kernel 156913bd098SKyle Evansand 157913bd098SKyle Evans.Ic kernels 158913bd098SKyle Evansfrom 159913bd098SKyle Evans.Xr loader.conf 5 . 160913bd098SKyle EvansIf 161913bd098SKyle Evans.Ic kernels_autodetect 162913bd098SKyle Evansis set in 163913bd098SKyle Evans.Xr loader.conf 5 , 164913bd098SKyle Evanskernels will be autodetected from the current system. 165913bd098SKyle Evans.It Fn core.bootenvDefault 166913bd098SKyle EvansReturns the default boot environment, nil if unset. 167913bd098SKyle Evans.It Fn core.bootenvList 168913bd098SKyle EvansReturns a table of boot environments, or an empty table. 169913bd098SKyle EvansThese will be picked up using the 170913bd098SKyle Evans.Ev bootenvs 171913bd098SKyle Evansand 172913bd098SKyle Evans.Ev bootenvs_count 173913bd098SKyle Evansvariables set by 1741a14a0bfSWarner Losh.Xr loader 8 . 175913bd098SKyle Evans.It Fn core.setDefaults 176913bd098SKyle EvansResets ACPI, safe mode, single user, and verbose settings to their system 177913bd098SKyle Evansdefauilts. 178913bd098SKyle Evans.It Fn core.autoboot argstr 179913bd098SKyle EvansLoads the kernel and specified modules, then invokes the 180913bd098SKyle Evans.Ic autoboot 181913bd098SKyle Evans.Xr loader 8 182913bd098SKyle Evanscommand with 183913bd098SKyle Evans.Fa argstr 184913bd098SKyle Evansas-is. 185913bd098SKyle Evans.It Fn core.boot argstr 186913bd098SKyle EvansLoads the kernel and specified modules, then invokes the 187913bd098SKyle Evans.Ic boot 188913bd098SKyle Evans.Xr loader 8 189913bd098SKyle Evanscommand with 190913bd098SKyle Evans.Fa argstr 191913bd098SKyle Evansas-is. 192913bd098SKyle Evans.It Fn core.isSingleUserBoot 193913bd098SKyle EvansReturns true if 194913bd098SKyle Evans.Ev boot_single 195913bd098SKyle Evansis set to yes. 196913bd098SKyle Evans.It Fn core.isZFSBoot 197913bd098SKyle EvansReturns true if 198913bd098SKyle Evans.Ev currdev 199913bd098SKyle Evansis set to a 200913bd098SKyle Evans.Xr zfs 8 201913bd098SKyle Evansdataset. 202913bd098SKyle Evans.It Fn core.isSerialBoot 203913bd098SKyle EvansReturns true if we are booting over serial. 204913bd098SKyle EvansThis checks 205913bd098SKyle Evans.Ev console , 206913bd098SKyle Evans.Ev boot_serial , 207913bd098SKyle Evansand 208913bd098SKyle Evans.Ev boot_multicons . 209913bd098SKyle Evans.It Fn core.deepCopyTable tbl 210913bd098SKyle EvansRecursively deep copies 211913bd098SKyle Evans.Fa tbl 212913bd098SKyle Evansand returns the result. 213913bd098SKyle Evans.It Fn core.popFrontTable tbl 214913bd098SKyle EvansPops the front element off of 215913bd098SKyle Evans.Fa tbl , 216913bd098SKyle Evansand returns two return values: the front element, and the rest of the table. 217913bd098SKyle EvansIf there are no elements, this returns nil and nil. 218913bd098SKyle EvansIf there is one element, this returns the front element and an empty table. 219913bd098SKyle EvansThis will not operate on truly associative tables; numeric indices are 220913bd098SKyle Evansrequired. 221*a2fd7ae8SWarner Losh.It Fn core.loaderTooOld 222*a2fd7ae8SWarner LoshReturns true if the loader is too old. 223*a2fd7ae8SWarner LoshSpecifically, this means, is the loader old enough to require one or more 224*a2fd7ae8SWarner Loshworkarounds in the current lua base modules. 225913bd098SKyle Evans.El 226913bd098SKyle Evans.Sh SEE ALSO 227913bd098SKyle Evans.Xr loader.conf 5 , 228913bd098SKyle Evans.Xr loader 8 , 229913bd098SKyle Evans.Xr menu.lua 8 230913bd098SKyle Evans.Sh AUTHORS 231913bd098SKyle EvansThe 232913bd098SKyle Evans.Nm 233913bd098SKyle Evansfile was originally written by 234913bd098SKyle Evans.An Pedro Souza Aq Mt pedrosouza@FreeBSD.org . 235913bd098SKyle EvansLater work and this manual page was done by 236913bd098SKyle Evans.An Kyle Evans Aq Mt kevans@FreeBSD.org . 237