aboutsummaryrefslogtreecommitdiff
path: root/stand/liblua/lutils.c
Commit message (Collapse)AuthorAgeFilesLines
* loader: Add loader.exitWarner Losh2024-02-271-4/+12
| | | | | | | | | | | | | 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
* loader: Create new gfx tableWarner Losh2024-02-161-1/+0
| | | | | | | | | | 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
* loader: Separate gfx to a new file.Warner Losh2024-02-161-202/+0
| | | | | | | | Move gfx lua hook registration to a new file. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D43901
* loader: Register the gfx stuff separately.Warner Losh2024-02-161-0/+11
| | | | | | | | | 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
* loader: Simplify the loader.has_commandWarner Losh2024-02-161-5/+6
| | | | | | | | | | 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
* loader: export the CMD_ constants in loader tableWarner Losh2024-02-141-0/+10
| | | | | | | | 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
* loader: provide a features table for binary compatibility advertisementKyle Evans2023-12-081-0/+48
| | | | | | | | | | | | | | | | | | | | | | 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
* stand: Automated cleanup of cdefs and other formattingWarner Losh2023-11-271-1/+0
| | | | | | | | | | | | | | | | 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
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* loader: Change version calculation to be more consistent.Stephen J. Kiernan2023-04-191-0/+2
| | | | | | | | | | | | 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
* stand: Add lua binding loader.has_commandWarner Losh2022-09-011-2/+17
| | | | | | | | 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
* loader: implement framebuffer consoleToomas Soome2021-01-021-0/+192
| | | | | | | | | | | | | | | | | | | | | | | 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
* liblua: add loader.lua_pathKyle Evans2019-11-021-0/+2
| | | | | | | | | | | | 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
* lualoader: Improve module loading diagnosticsKyle Evans2018-10-251-0/+9
| | | | | | | | | | | | | | | | | 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
* lualoader: Expose loader.parse and add cli_execute_unparsedKyle Evans2018-03-071-0/+19
| | | | | | | | | | | | | | | | | 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
* liblua: Add loader.interpretKyle Evans2018-03-031-0/+20
| | | | | | | | | | | | | | 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
* liblua: Use putc instead of printf for printcKyle Evans2018-03-021-4/+4
| | | | | | | | | | | | | | 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
* lualoader: Register loader.printc as global printcKyle Evans2018-03-021-0/+3
| | | | Notes: svn path=/head/; revision=330282
* liblua: Implement write supportKyle Evans2018-02-241-4/+69
| | | | | | | | | | | Write support (even if it only works on UFS) will be needed for nextboot functionality. Reviewed by: cem, imp Differential Revision: https://reviews.freebsd.org/D14478 Notes: svn path=/head/; revision=329895
* liblua: Add loader.machine and loader.machine_arch propertiesKyle Evans2018-02-201-0/+7
| | | | | | | | | | | | | Provisioned from MACHINE/MACHINE_ARCH on the system, expose loader.machine and loader.machine_arch respectively. These may be used to hide ACPI option on non-applicable archs. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D14446 Notes: svn path=/head/; revision=329650
* Implement loader.commandWarner Losh2018-02-201-0/+26
| | | | | | | | | This is just like loader.perform, except it takes pre-parsed arguments. Review: https://reviews.freebsd.org/D14448 Notes: svn path=/head/; revision=329643
* liblua: Fix missing '}' in lutil.c after r329499Kyle Evans2018-02-181-0/+1
| | | | Notes: svn path=/head/; revision=329503
* interp_lua: Register io/loader with regular Lua module systemConrad Meyer2018-02-181-5/+9
| | | | | | | | | Reviewed by: kevans Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D14421 Notes: svn path=/head/; revision=329499
* liblua: Clean up io/loader C module registrationConrad Meyer2018-02-171-50/+25
| | | | | | | | | | | Utilize registration APIs Lua provides to make module definition a little cleaner. Discussed with: imp Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=329473
* Add Lua as a scripting langauge to /boot/loaderWarner Losh2018-02-121-0/+268
liblua glues the lua run time into the boot loader. It implements all the runtime routines that lua expects. In addition, it has a few standard 'C' headers that nueter various aspects of the LUA build that are too specific to lua to be in libsa. Many refinements from the original code to improve implementation and the number of included lua libraries. Use int64_t for lua_Number. Have "/boot/lua" be the default module path. Numerous cleanups from the original GSoC project, including hacking libsa to allow lua to be built with only one change outside luaconf.h. Add the final bit of lua glue to bring in liblua and plug into the multiple interpreter framework, previously committed. Add LOADER_LUA option, currently off by default. Presently, this is an experimental option. One must opt-in to using this by defining WITH_LOADER_LUA and WITHOUT_FORTH. It's been lightly tested, so keep a backup copy of your old loader handy. The menu code, coming in the next commit, hasn't been exhaustively tested. A LUA boot loader is 60k larger than a FORTH one, which is 80k larger than a no-interpreter one. Subtle changes in size may tip things past some subtle limit (the binary is ~430k now when built with LUA). A future version may offer coexistance. Bump FreeBSD version to 1200058 to mark the milestone. Pedro Souza's 2014 Summer of Code project. Rui Paulo, Pedro Arthur, Zakary Nafziger and Wojciech A. Koszek also contributed. Warner Losh reworked it extensively into its current form. Obtained from: https://wiki.freebsd.org/SummerOfCode2014/LuaLoader Sponsored by: Google Summer of Code Relnotes: Yes MFC After: 1 month Differential Review: https://reviews.freebsd.org/D14295 Notes: svn path=/head/; revision=329166