summaryrefslogtreecommitdiff
path: root/stand/lua/loader.lua
AgeCommit message (Collapse)Author
2024-09-22loader: Load platform entropy even without menuColin Percival
In 5c73b3e0a3db calls to core.loadEntropy were added to core.boot and core.autoboot; but neither of those is invoked if we disable the "beastie" menu. Add a core.loadEntropy call to the no-menu path. Reviewed by: imp MFC after: 1 week Sponsored by: Amazon Fixes: 5c73b3e0a3db ("Add support for getting early entropy from UEFI") Differential Revision: https://reviews.freebsd.org/D46637
2023-08-16Remove $FreeBSD$: two-line lua tagWarner Losh
Remove /^--\n--\s*\$FreeBSD\$.*$\n/
2023-05-12spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
2020-03-27loader: Fully reset terminal settings, not just colorsRyan Moeller
Reviewed by: kevans Reviewed by: tsoome Approved by: mav (mentor) MFC after: 1 week Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D21733 Notes: svn path=/head/; revision=359371
2020-01-25loader.lua: re-arrange to load local.lua *after* config loadingKyle Evans
The major problem with the current ordering is that loader.conf may contain all of the magic we need to actually setup the console, so loading local.lua prior to that can make it excessively difficult and annoying to debug (whoops, sorry Ravi & Warner). The new ordering has some implications, but I suspect they are a non-issue. The first is that it's no longer possible for the local module to inject any logic prior to loading config -- I suspect no one has relied on this. The second implication is that the config.loaded hook is now useless, as the local module will always be included after that hook would have fired. For config.loaded, I will opt to leave it in, just in case we add an early point for local lua to get injected or in case one wants to schedule some deferred logic in a custom loader.lua. The overhead of having it if no hooks will be invoked is relatively minimal. Diagnosed by: imp Reported by: imp, rpokala (most likely) MFC after: 3 days Notes: svn path=/head/; revision=357103
2018-08-30lualoader: fix color usageKyle Evans
Resetting to the default color scheme was done prior to reading the config. This is bogus; colors may only be declined by the user with the loader.conf(5) variable "loader_color", so such a request for no color will not be completely honored as we reset to the default color scheme unconditionally. Approved by: re (rgrimes) Notes: svn path=/head/; revision=338394
2018-06-12lualoader: More black-on-white fixesKyle Evans
To recap the problem: with a black-on-white xterm, the menu draws terribly. Ideally, we would try our best for a white-on-black context for the menu since graphics and whatnot might not be tested for other setups and there's no reasonable way to sample the terminal at this point for the used color scheme. This commit attempts to address that further in two ways: - Instead of issuing CSI bg/fg resets (CSI 39m and CSI 49m respectively for "default"), issue CSI bg/fg escape sequences for our expected color scheme - Reset to *our* default color scheme before we even attempt to load the local module, so that we personally don't have any earlier text with the console default color scheme. Reported by: emaste (again) Notes: svn path=/head/; revision=334986
2018-04-06lualoader: Fix menu skipping with loader.conf(5) varsKyle Evans
Earlier efforts to stop loading the menu broke the ability to skip the menu with, e.g., beastie_disable in loader.conf(5) as it was decided before configuration was read. Defer bringing in the menu module until we've loaded configuration so that we can make a more informed decision on whether the menu should be skipped or not. Notes: svn path=/head/; revision=332106
2018-03-26lualoader: Implement try_include and use it for including the local moduleKyle Evans
This provides a way to optionally include a module without having to wrap it in filesystem checks. try_include is a little more robust, using the lua search path instead of forcing us to explicitly consider all of the places we could want to include a module. Errors are still generally raised from trying to load the module, but ENOENT will not get raised unless we're doing a verbose load. This will also be used to split out logo/brand graphics into their own files so that we can safely scale up the number of graphics included without worrying about the extra memory consumption- opting to lazily load graphics instead. Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D14658 Notes: svn path=/head/; revision=331563
2018-03-21UEFI: Ditch console mode setting, choose optimal GOP mode later in bootKyle Evans
boot1 is too early to be deciding a good resolution. Console modes don't map cleanly/predictably to actual screen resolutions, and GOP does not reflect the actual screen resolution after a console mode change. Rip it out. Add an efi-autoresizecons command to loader to choose an optimal screen resolution based on the current environment. We'll explicitly execute this later, preferably before we draw anything of value but after we load config and pick up any tunables we may need to decide where we're going. This method also allows us to actually pass the correct framebuffer information on to the kernel. UGA autoresizing is not implemented because it doesn't have the kind of mode enumeration that GOP does. If an interested person with relevant hardware could get in contact, we can take a look at implementing UGA autoresize. This effectively "fixes" the breakage caused by r327058, but doesn't actually set the resolution correctly until the interpreter calls efi-autoresizcons. The lualoader version of this has been included for reference; the forth equivalent will follow. Reviewed by: imp (with some hestitation), manu Differential Revision: https://reviews.freebsd.org/D14788 Notes: svn path=/head/; revision=331321
2018-03-19lualoader: Setup default color scheme if we're using colorsKyle Evans
The console may have been set for different colors before lualoader kicks in; notably, a black-on-white color scheme is not necessarily what we're expecting. While here, make color.default() a composition of color.escape() instead of rewriting the escape sequence to make it more obvious what it's achieving: a white-on-black color scheme with no attributes set. Reported by: emaste, whose eyes may rest easily Notes: svn path=/head/; revision=331211
2018-03-05lualoader: Add note about importance of including the cli module earlyKyle Evans
Notes: svn path=/head/; revision=330434
2018-02-26lualoader: Re-work menu skipping bitsKyle Evans
This is motivated by a want to reduce heap usage if the menu is being skipped. Currently, the menu module must be loaded regardless of whether it's being skipped or not, which adds a cool ~50-100KB worth of memory usage. Move the menu skip logic out to core (and remove a debug print), then check in loader.lua if we should be skipping the menu and avoid loading the menu module entirely if so. This keeps our memory usage below ~115KB for a boot with the menu stripped. Also worth noting: with this change, we no longer explicitly invoke autoboot if we're skipping the menu. Instead, we let the standard loader behavior apply: try to autoboot if we need to, then drop to a loader prompt if not or if the autoboot sequence is interrupted. The only thing we still handle before dropping to the loader autoboot sequence is loadelf(), so that we can still apply any of our kernel loading behavior. Notes: svn path=/head/; revision=330020
2018-02-23Add SPDX tags to lua filesKyle Evans
Notes: svn path=/head/; revision=329851
2018-02-23lualoader: Drop unused return values; we'll only use the firstKyle Evans
Notes: svn path=/head/; revision=329850
2018-02-22lualoader: Address some 'luacheck' concernsKyle Evans
luacheck pointed out an assortment of issues, ranging from non-standard globals being created as well as unused parameters, variables, and redundant assignments. Using '_' as a placeholder for values unused (whether it be parameters unused or return values unused, assuming multiple return values) feels clean and gets the point across, so I've adopted it. It also helps flag candidates for cleanup later in some of the lambdas I've created, giving me an easy way to re-evaluate later if we're still not using some of these features. Notes: svn path=/head/; revision=329809
2018-02-22lualoader: Split cli bits out into a cli moduleKyle Evans
This module will, in the not-so-distant future, grow functionality for reducing boilerplate in functions that implement cli commands. It will likely also house most in-tree cli commands. Notes: svn path=/head/; revision=329779
2018-02-21lualoader: Bring in local.lua module if it existsKyle Evans
Provide a way for out-of-tree users of lualoader to patch into the loader system without having to modify our distributed scripts. Do note that we can't really offer any API compatibility guarantees at this time due to the evolving nature of lualoader right now. This still has some utility as local modules may add commands at the loader prompt without relying heavily on lualoader features- this specific functionality is less likely to change without more careful consideration. Reviewed by: cem (earlier version) Differential Revision: https://reviews.freebsd.org/D14439 Notes: svn path=/head/; revision=329692
2018-02-21lualoader: Drop excessive parenthesizingKyle Evans
This was also a convenience convention (for me) that is not very lua-tic. Drop it. I've maintained some parentheses where I'd prefer them, for example, 'if x or y or (z and w) then', but these situations are far and few between. Notes: svn path=/head/; revision=329685
2018-02-21lualoader: Drop terminating semicolonsKyle Evans
This was previously chosen out of convenience, as we had a mixed style and needed to be consistent. I started learning Lua on Friday, so I switched everything over. It is not a very lua-nic convention, though, so drop it. Excessive parenthesizing around conditionals is next on the chopping block. Notes: svn path=/head/; revision=329684
2018-02-20lualoader: Replace invalid construct with valid constructKyle Evans
It only worked by coincidence, but it did work. Store varargs in a table instead and work off of that. Notes: svn path=/head/; revision=329662
2018-02-20lualoader: Eliminate global namespace pollution in loader.luaKyle Evans
Notes: svn path=/head/; revision=329646
2018-02-20lualoader: Add ability to intercept cli commandsKyle Evans
If we failed to execute the input line as pure lua, run the command through parse for consistent argument parsing. Pass the parsed arguments through to a global "cli_execute" written in Lua, which is expected to either handle it or pass it back through to interp_builtin_cmd (via loader.command). lua-handled cli commands will then exist as globals in whatever module they most belong in, and invocations at the loader prompt will magically dispatch to them if they exist. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D14450 Notes: svn path=/head/; revision=329644
2018-02-12Add the lua scripts from the lua-bootloader SoCWarner Losh
These are the .lua files from from Pedro Souza's 2014 Summer of Code project. Rui Paulo, Pedro Arthur and Wojciech A. Koszek also contributed. Obtained from: https://wiki.freebsd.org/SummerOfCode2014/LuaLoader Sponsored by: Google Summer of Code Improve the SoC lua menu code to bring it in line with forth menu functionality Submitted by: Zakary Nafziger Sponsored by: FreeBSD Foundation Use loader.setenv and loader.unsetenv instead of loader.perform Convert from include("/boot/foo.lua") to foo = require("foo"); to bring in line with latest lua module conventions. Enforce a uniform style for the new .lua files: o hard tab indenation for 8 spaces o don't have if foo then bar; else bas; end on one line MFC After: 1 month Relnotes: yes Differential Review: https://reviews.freebsd.org/D14295 Notes: svn path=/head/; revision=329167