xref: /freebsd/stand/lua/core.lua.8 (revision 315ee00f)
1.\"
2.\" SPDX-License-Identifier: BSD-2-Clause
3.\"
4.\" Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.Dd March 21, 2018
28.Dt CORE.LUA 8
29.Os
30.Sh NAME
31.Nm core.lua
32.Nd FreeBSD core module
33.Sh DESCRIPTION
34.Nm
35contains core functionality that does not have a more fitting module.
36.Pp
37Before hooking into or using the functionality provided by
38.Nm ,
39it must be included with a statement such as the following:
40.Pp
41.Dl local core = require("core")
42.Ss CONSTANTS
43The following raw key code constants are defined in
44.Nm :
45.Bl -tag -width KEY_BACKSPACE -compact -offset indent
46.It Ic KEY_BACKSPACE
47The backspace code.
48Should generally be checked along with
49.Ic KEY_DELETE
50for backspace functionality.
51.It Ic KEY_ENTER
52The enter key, or hard return.
53.It Ic KEY_DELETE
54The delete code.
55Should generally be checked along with
56.Ic KEY_BACKSPACE
57for backspace functionality.
58.El
59.Pp
60The following key-string constants are defined in
61.Nm :
62.Bl -tag -width KEYSTR_ESCAPE -compact -offset indent
63.It Ic KEYSTR_ESCAPE
64The escape key.
65.It Ic KEYSTR_CSI
66The ANSI CSI sequence.
67.El
68.Pp
69The following menu entry type constants are defined in
70.Nm :
71.Bl -tag -width MENU_CAROUSEL_ENTRY -compact -offset indent
72.It Ic MENU_RETURN
73Return to the parent menu.
74.It Ic MENU_ENTRY
75A normal menu entry.
76.It Ic MENU_SEPARATOR
77A menu entry that serves as a separator.
78.It Ic MENU_SUBMENU
79A menu entry that opens a submenu when selected.
80.It Ic MENU_CAROUSEL_ENTRY
81A menu entry that rotates through items like a carousel upon selection of the
82menu entry.
83.El
84.Pp
85Please see
86.Xr menu.lua 8
87for extended descriptions and usage of the
88.Ic MENU_*
89constants.
90.Ss Exported functions
91The following functions are exported from
92.Nm :
93.Bl -tag -width core.getACPIPresent -offset indent
94.It Fn core.setVerbose verbose
95Sets or unsets
96.Ev boot_verbose .
97If
98.Fa verbose
99is omitted, toggle the current verbose setting.
100.It Fn core.setSingleUser singleUser
101Sets or unsets
102.Ev boot_single .
103If
104.Fa singleUser
105is omitted, toggle the current single user setting.
106.It Fn core.getACPIPresent checkingSystemDefaults
107Check whether ACPI is present.
108This will only be accurate for i386-compatible loaders, including non-UEFI
109loaders on amd64 systems.
110If
111.Fa checkingSystemDefaults
112is true, ignore the current value of
113.Ev hint.acpi.0.disabled .
114Otherwise, return true only if ACPI is both present and not disabled.
115.It Fn core.setACPI acpi
116Sets or unsets
117.Ev acpi_load ,
118.Ev hint.acpi.0.disabled ,
119and
120.Ev loader.acpi_disabled_by_user .
121If
122.Fa acpi
123is omitted, toggle the current ACPI setting.
124.It Fn core.setSafeMode safeMode
125Set the safe mode setting.
126Sets or unsets
127.Ev kern.smp.disabled ,
128.Ev hw.ata.ata_dma ,
129.Ev hw.ata.atapi_dma ,
130.Ev hw.ata.wc ,
131.Ev hw.eisa_slots ,
132.Ev kern.eventtimer.periodic ,
133and
134.Ev kern.geom.part.check_integrity .
135If
136.Fa safeMode
137is omitted, toggle the current safe mode setting.
138.It Fn core.clearCachedKernels
139Clears out the cache of kernels to be displayed on the boot menu.
140This function is registered as a
141.Ev config.reloaded
142hook.
143It is used to invalidate the kernel list whenever it may have changed, either
144due to a boot environment change or a potential change in either
145.Ic kernel
146or
147.Ic kernels .
148.It Fn core.kernelList
149Returns a table of kernels to display on the boot menu.
150This will combine
151.Ic kernel
152and
153.Ic kernels
154from
155.Xr loader.conf 5 .
156If
157.Ic kernels_autodetect
158is set in
159.Xr loader.conf 5 ,
160kernels will be autodetected from the current system.
161.It Fn core.bootenvDefault
162Returns the default boot environment, nil if unset.
163.It Fn core.bootenvList
164Returns a table of boot environments, or an empty table.
165These will be picked up using the
166.Ev bootenvs
167and
168.Ev bootenvs_count
169variables set by
170.Xr loader 8 .
171.It Fn core.setDefaults
172Resets ACPI, safe mode, single user, and verbose settings to their system
173defauilts.
174.It Fn core.autoboot argstr
175Loads the kernel and specified modules, then invokes the
176.Ic autoboot
177.Xr loader 8
178command with
179.Fa argstr
180as-is.
181.It Fn core.boot argstr
182Loads the kernel and specified modules, then invokes the
183.Ic boot
184.Xr loader 8
185command with
186.Fa argstr
187as-is.
188.It Fn core.isSingleUserBoot
189Returns true if
190.Ev boot_single
191is set to yes.
192.It Fn core.isZFSBoot
193Returns true if
194.Ev currdev
195is set to a
196.Xr zfs 8
197dataset.
198.It Fn core.isSerialBoot
199Returns true if we are booting over serial.
200This checks
201.Ev console ,
202.Ev boot_serial ,
203and
204.Ev boot_multicons .
205.It Fn core.isSystem386
206Returns true if this bootloader was compiled as an i386 binary.
207This generally applies to i386 loaders as well as non-UEFI loaders on amd64.
208.It Fn core.deepCopyTable tbl
209Recursively deep copies
210.Fa tbl
211and returns the result.
212.It Fn core.popFrontTable tbl
213Pops the front element off of
214.Fa tbl ,
215and returns two return values: the front element, and the rest of the table.
216If there are no elements, this returns nil and nil.
217If there is one element, this returns the front element and an empty table.
218This will not operate on truly associative tables; numeric indices are
219required.
220.El
221.Sh SEE ALSO
222.Xr loader.conf 5 ,
223.Xr loader 8 ,
224.Xr menu.lua 8
225.Sh AUTHORS
226The
227.Nm
228file was originally written by
229.An Pedro Souza Aq Mt pedrosouza@FreeBSD.org .
230Later work and this manual page was done by
231.An Kyle Evans Aq Mt kevans@FreeBSD.org .
232