summaryrefslogtreecommitdiff
path: root/stand/liblua
AgeCommit message (Collapse)Author
2025-10-03flua: kick out the remaining builtin modulesKyle Evans
Bootstrap flua has some magic now to handle modules by building them in and discovering them via linker sets. This is slightly cleaner than always building them in and baking them into loadedlibs for both bootstrap and system flua. Adjust the stand build now that these three libs have their own new homes. Reviewed by: bapt, emaste Differential Revision: https://reviews.freebsd.org/D51891
2025-10-03Revert "flua: kick out the remaining builtin modules"Kyle Evans
This reverts commit 80ada959004c4386880e47b11618f8abfc2d80e1, because bootstrap flua is about to get backed out.
2025-10-03flua: kick out the remaining builtin modulesKyle Evans
Bootstrap flua has some magic now to handle modules by building them in and discovering them via linker sets. This is slightly cleaner than always building them in and baking them into loadedlibs for both bootstrap and system flua. Adjust the stand build now that these three libs have their own new homes. Reviewed by: bapt, emaste Differential Revision: https://reviews.freebsd.org/D51891
2025-06-11machine/stdarg.h -> sys/stdarg.hBrooks Davis
Switch to using sys/stdarg.h for va_list type and va_* builtins. Make an attempt to insert the include in a sensible place. Where style(9) was followed this is easy, where it was ignored, aim for the first block of sys/*.h headers and don't get too fussy or try to fix other style bugs. Reviewed by: imp Exp-run by: antoine (PR 286274) Pull Request: https://github.com/freebsd/freebsd-src/pull/1595
2024-07-15Remove residual blank line at start of MakefileWarner Losh
This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
2024-05-11stand: Spell LUA_COMPILE_SET correctly.Warner Losh
MFC After: 2 days Sponsored by: Netflix
2024-02-26loader: Add loader.exitWarner Losh
Add loader.exit(status). While one can get alomst this behavior with loader.perform("quit"), quit doesn't allow a value to be returned to the firmware. The interpretation of 'status' is firmware specific. This can be used when autobooting doesn't work in scripts, for example, to allow the firmware to try something else... Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44094
2024-02-24loader/efi: Use unique linker set for luaWarner Losh
After the linker set cleanup in ldscripts, there's now only one place we need to know the linkerset name, so go ahead and change the lua interpreter augmentation linker set to be uniquely named. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D44062
2024-02-23loader: rename gfx_interp_md to gfx_interp_refWarner Losh
We have the call to gfx_interp_ref to bring in the .o so that we get the linker set item to add the language bindings at the right time. Where we call it is not the right time... So the _ref name is better. Change it before we have too many others like it. Sponsored by: Netflix
2024-02-22libsa: Remove redundant sys/cdefs.hWarner Losh
Sponsored by: Netflix
2024-02-20loader: For the mini-stdio we have for lua, #define them to something elseWarner Losh
To make it easier to port lua and some of the lua modules, we have a series of routines to implement the stdio routines, even though we don't normally implement them in the boot loader. Add a comment to this effect. Also, some tools, like sanitizers and static analysis tools, make unwarranted assumptions about these, so #define them to a different name so they stop. Sponsored by: Netflix
2024-02-15kboot: Add our own lua bindingsWarner Losh
Create a small wrapper around the new flua hash module so we can use it here too. There's no 4th bindings, nor will they be created. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43874
2024-02-15loader: Move to using linker sets to bring in optional bitsWarner Losh
The graphics stuff is optional. When it is pulled into the system, we use a linker set to initialize the lua bindings for it now. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D43906
2024-02-15loader: Add prototype for gfx_interp_mdWarner Losh
This function will be used to draw in the graphics bindings when the loader is compiled with graphics (gfx) support. Provide definitions for lua and the simple interpreter. 4th support is forthcoming. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D43903
2024-02-15loader: Create new gfx tableWarner Losh
Create a new gfx global table. Put into it all the graphics bindings that we have in loader today. For now, have compatability binding for loader. Remove them from loader. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D43902
2024-02-15loader: Separate gfx to a new file.Warner Losh
Move gfx lua hook registration to a new file. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D43901
2024-02-15loader: Register the gfx stuff separately.Warner Losh
Move registration of the gfx stuff to separate function. However, no change in functionality is intended. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D43900
2024-02-15loader: Simplify the loader.has_commandWarner Losh
luaL_checkstring already checks for the right number of arguments. There's no need to do that by hand here. Now an exception will be thrown like any other function with the wrong args. Also, push a boolean instead of an int. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43820
2024-02-14loader: export the CMD_ constants in loader tableWarner Losh
Export the CMD_OK, etc constants in the loader table. They are the return values of loader.perform, etc. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43821
2023-12-08loader: provide a features table for binary compatibility advertisementKyle Evans
liblua now provides a loader.has_feature() function to probe the loader binary for features advertised. name => desc mappings are provided in loader.features to get a list of all of the features loader *can* support. core.hasFeature is provided as a shim to loader.has_feature so that individual consumers don't need to think about the logic of the loader module not providing has_feature; we know that means the feature isn't enabled. The first consumer of this will be EARLY_ACPI to advertise that the loader binary probes for ACPI presence before the interpreter has started, so that we know whether we can trust the presence of acpi.rsdp as relatively authoritative. In general, it's intended to be used to avoid breaking new scripts on older loaders within reason. This will be used in lua as `core.hasFeature("EARLY_ACPI")`, while the C bits of loader will `feature_enable(FEATURE_EARLY_ACPI)`. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D42695
2023-11-26stand: Automated cleanup of cdefs and other formattingWarner Losh
Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
2023-10-29dirdeps: Add missing dependency filesStephen J. Kiernan
Some leaf directories were missing Makefile.depend files or needed architecture-specific Makefile.depend.* files.
2023-08-16Remove $FreeBSD$: one-line sh patternWarner Losh
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16Remove $FreeBSD$: one-line .c patternWarner Losh
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16Remove $FreeBSD$: two-line .h patternWarner Losh
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-04-19loader: Change version calculation to be more consistent.Stephen J. Kiernan
Use 1000 * major + minor when calculating the version number that gets set in the Ficl environment or lua loader property. This allows for more room if the minor number needs to go above 9. Add loader.version property to lua loader. Reviewed by: imp Obtained from: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D39631
2023-02-08lua: Update to 5.4.4Warner Losh
Merge commit '755d9301ca89f02956fd17858b9d4d821ab5c972' from the vendor branch. This updates us from lua 5.4.2 to 5.4.4. In addition, it switches around how we flavor liblua for the boot loader and flua. This is done to reduce diffs with upstream and make it easier to import new versions (the current method has too many conflicts to resolve by hand): we include luaconf.local.h from luaconf.h (the only change to this file is now that #include at the end). We then define what we need to: for flua (which does very little) and one for stand (which creates the new FLOAT type out of int64). Sponsored by: Netflix
2023-01-26lua: reduce diffs between luaconf.h copiesEd Maste
Upstream luaconf.h is contrib/lua/src/luaconf.h.dist, while userland lua and loader lua have copies in lib/liblua/luaconf.h and stand/liblua/luaconf.h. Adjust whitespace, VCS tags, etc. to match upstream's version, for ease of comparison. Reviewed By: imp Sponsored By: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38206
2022-09-01stand: Add lua binding loader.has_commandWarner Losh
Give scripts the ability to determine if the currently running loader has provided a command. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D36365
2021-04-30EFI secure boot VECTX related changesEric van Gyzen
When VECTX is enabled as a kernel option and non-EFI loaders are built, many reads will fail due to the mis-match of whether LOADER_VERIEXEC_VECTX or not in readin.h. Source that includes bootstrap.h must ensure the kernel option agrees with the compile time CFLAGS in the various make related files. Submitted by: bret_ketchum@dell.com (original revision) Reviewed by: sjg, bdrewery, dab, bret_ketchum@dell.com MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D29993
2021-01-13contrib/lua: update to 5.4.2Kyle Evans
Merge commit '0ea45b9cd43ce1247eb3eee9bfd5cee3d19068e7' into main
2021-01-02loader: implement framebuffer consoleToomas Soome
Draw console on efi. Add vbe framebuffer for BIOS loader (vbe off, vbe on, vbe list, vbe set xxx). autoload font (/boot/fonts) based on resolution and font size. Add command loadfont (set font by file) and variable screen.font (set font by size). Pass loaded font to kernel. Export variables: screen.height screen.width screen.depth Add gfx primitives to draw the screen and put png image on the screen. Rework menu draw to iterate list of consoles to enamble device specific output. Probably something else I forgot... Relnotes: yes Differential Revision: https://reviews.freebsd.org/D27420
2020-12-12stand: liblua: add a pager moduleKyle Evans
This is nearly a 1:1 mapping of the pager API from libsa. The only real difference is that pager.output() will accept any number of arguments and coerce all of them to strings for output using luaL_tolstring (i.e. the __tostring metamethod will be used). The only consumer planned at this time is the upcoming "show-module-options" implementation. MFC after: 1 week Notes: svn path=/head/; revision=368591
2020-09-11Only set WARNS if not definedKyle Evans
This would allow interested parties to do experimental runs with an environment set appropriately to raise all the warnings throughout the build; e.g. env WARNS=6 NO_WERROR=yes buildworld. Not currently touching the numerous instances in ^/tools. MFC after: 1 week Notes: svn path=/head/; revision=365631
2020-03-09veloader use vectx API for kernel and modulesSimon J. Gerraty
The vectx API, computes the hash for verifying a file as it is read. This avoids the overhead of reading files twice - once to verify, then again to load. For doing an install via loader, avoiding the need to rewind large files is critical. This API is only used for modules, kernel and mdimage as these are the biggest files read by the loader. The reduction in boot time depends on how expensive the I/O is on any given platform. On a fast VM we see 6% improvement. For install via loader the first file to be verified is likely to be the kernel, so some of the prep work (finding manifest etc) done by verify_file() needs to be factored so it can be reused for vectx_open(). For missing or unrecognized fingerprint entries, we fail in vectx_open() unless verifying is disabled. Otherwise fingerprint check happens in vectx_close() and since this API is only used for files which must be verified (VE_MUST) we panic if we get an incorrect hash. Reviewed by: imp,tsoome MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org//D23827 Notes: svn path=/head/; revision=358811
2019-12-12stand: liblua: drop default buffer size to 128Kyle Evans
Lua allocates LUAL_BUFFERSIZE buffers on the stack for various string functions (string.format, string.gsub) -- this works out to be somewhat significant and not necessary, based on how we use string operations. Dropping it risks having to allocate per call to format/gsub, but this is not the case for our usage. This simply stops allocating 8K buffers on the stack when luaL_Buffer is used. Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D22500 Notes: svn path=/head/; revision=355640
2019-12-04Regularize my copyright noticeWarner Losh
o Remove All Rights Reserved from my notices o imp@FreeBSD.org everywhere o regularize punctiation, eliminate date ranges o Make sure that it's clear that I don't claim All Rights reserved by listing All Rights Reserved on same line as other copyright holders (but not me). Other such holders are also listed last where it's clear. Notes: svn path=/head/; revision=355394
2019-11-18Add flua to the base system, install to /usr/libexecKyle Evans
FreeBSDlua ("flua") is a FreeBSD-private lua, flavored with whatever extensions we need for base system operations. We currently support a subset of lfs and lposix that are used in the rewrite of makesyscall.sh into lua, added in r354786. flua is intentionally written such that one can install standard lua and some set of lua modules from ports and achieve the same effect. linit_flua is a copy of linit.c from contrib/lua with lfs and lposix added in. This is similar to what we do in stand/. linit.c has been renamed to make it clear that this has flua-specific bits. luaconf has been slightly obfuscated to make extensions more difficult. Part of the problem is that flua is already hard enough to use as a bootstrap tool because it's not in PATH- attempting to do extension loading would require a special bootstrap version of flua with paths changed to protect the innocent. src.lua.mk has been added to make it easy for in-tree stuff to find flua, whether it's bootstrap-flua or relying on PATH frobbing by Makefile.inc1. Reviewed by: brooks, emaste (both earlier version), imp Differential Revision: https://reviews.freebsd.org/D21893 Notes: svn path=/head/; revision=354833
2019-11-02liblua: add loader.lua_pathKyle Evans
As described previously, loader.lua_path is absolute path where scripts are installed. A future commit will use this to build paths for dofile in try_include, rather than the current pcall/require setup that makes it more difficult to coordinate loader aborts from local.lua -- we do not need the flexibility of require(), and local.lua is in-fact not a 'module-like' file as we will not be referencing anything from it. Notes: svn path=/head/; revision=354246
2019-11-02stand: consolidate knowledge of lua pathKyle Evans
Multiple places coordinate to 'know' where lua scripts are installed. Knock this down to being formally defined (and overridable) in exactly one spot, defs.mk, and spread the knowledge to loaders and liblua alike. A future commit will expose this to lua as loader.lua_path, so it can build absolute paths to lua scripts as needed. MFC after: 1 week Notes: svn path=/head/; revision=354245
2019-02-26Enable veriexec for loaderSimon J. Gerraty
This relies on libbearssl and libsecureboot to verify files read by loader in a maner equivalent to how mac_veriexec Note: disabled by default. Use is initially expected to be by embeded vendors Reviewed by: emaste, imp Sponsored by: Juniper Networks Differential Revision: D16336 Notes: svn path=/head/; revision=344568
2019-01-17Create new EINTEGRITY error with message "Integrity check failed".Kirk McKusick
An integrity check such as a check-hash or a cross-correlation failed. The integrity error falls between EINVAL that identifies errors in parameters to a system call and EIO that identifies errors with the underlying storage media. EINTEGRITY is typically raised by intermediate kernel layers such as a filesystem or an in-kernel GEOM subsystem when they detect inconsistencies. Uses include allowing the mount(8) command to return a different exit value to automate the running of fsck(8) during a system boot. These changes make no use of the new error, they just add it. Later commits will be made for the use of the new error number and it will be added to additional manual pages as appropriate. Reviewed by: gnn, dim, brueffer, imp Discussed with: kib, cem, emaste, ed, jilles Differential Revision: https://reviews.freebsd.org/D18765 Notes: svn path=/head/; revision=343111
2018-10-28Move LUA_ROOT to /boot/luaWarner Losh
While this is mostly unused today, this is a better place than /usr/local/lua. Notes: svn path=/head/; revision=339831
2018-10-25lualoader: Improve module loading diagnosticsKyle Evans
Some fixes: - Maintain historical behavior more accurately w.r.t verbose_loading; verbose_loading strictly prints "${module_name...}" and later "failed!" or "ok" based on load success - With or without verbose_loading, dump command_errbuf on load failure. This usually happens prior to ok/failed if we're verbose_loading Reviewed by: imp MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D17694 Notes: svn path=/head/; revision=339702
2018-08-14MFV r337586: lua: Update to 5.3.5Kyle Evans
Bugfix release, nothing too major. Tested with: lualoader via userboot, lualoader live Differential Revision: https://reviews.freebsd.org/D16665 Notes: svn path=/head/; revision=337810
2018-08-14For our INT64 implementation, we can compare integers and numbersWarner Losh
directly because they are the same thing. Reviewed by: kevans@ Notes: svn path=/head/; revision=337809
2018-05-01Use M. Warner Losh everywhere on my copyrights.Warner Losh
Remove 'All Rights Reserved' where I can. Notes: svn path=/head/; revision=333143
2018-03-07lualoader: Expose loader.parse and add cli_execute_unparsedKyle Evans
This will be used for scenarios where the command to execute is coming in via the environment (from, for example, loader.conf(5)) and is thus not necessarily trusted. cli_execute_unparsed will immediately be used for handling module_{before,after,error} as well as menu_timeout_command. We still want to offer these variables the ability to execute Lua-intercepted loader commands, but we don't want them to be able to execute arbitrary Lua. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D14580 Notes: svn path=/head/; revision=330616
2018-03-03liblua: Add loader.interpretKyle Evans
This allows lua to pass back a command string to be executed as if it were typed at the loader prompt- loader tries to execute the string first as pure lua, then parses it and gives lua a chance to intercept before it tries to execute it itself. This will be used to implement menu_timeout_command, among other things, which *should* be used to execute basic loader commands independent of the chosen interpreter. Notes: svn path=/head/; revision=330339
2018-03-02liblua: Use putc instead of printf for printcKyle Evans
printc does not need the features or the overhead of printf. It does not take formatting strings, and it pipes the single string argument through an "%s" format. Instead, use putc directly. This pipes the string through in its entirety as a series of 'unsigned char's, generally straight to the console emulator. Discussed with: tsoome Notes: svn path=/head/; revision=330284