#
e0f3dc82 |
|
19-Nov-2023 |
R. Christian McDonald <rcm@FreeBSD.org> |
loader: improve lua ACPI detection and handling This is a follow-up patch to https://reviews.freebsd.org/D42459 that modifies the loader lua to use the correct loader variables for determining ACPI availability. This also fixes a bug where ACPI can be inadvertently disabled when setting System Defaults at the loader menu. Reviewed by: imp, kevans Approved by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D42483
|
#
9636a145 |
|
16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
Remove $FreeBSD$: two-line lua tag Remove /^--\n--\s*\$FreeBSD\$.*$\n/
|
#
4d846d26 |
|
10-May-2023 |
Warner Losh <imp@FreeBSD.org> |
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 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
|
#
d7584aa0 |
|
15-Apr-2023 |
Cyrus Rahman <crahman@gmail.com> |
loader: lua: unload the kernel when changing BEs Usually the kernel is loaded later, but there are circumstances where it could have been loaded earlier than changing BEs. Unload anything that is already there so that we know we're using artifacts from the proper environment. PR: 265471 Reviewed by: kevans MFC after: 3 days
|
#
9b17aa27 |
|
02-Sep-2022 |
Jessica Clarke <jrtc27@FreeBSD.org> |
lualoader: Add loader_menu_multi_user_prompt config variable This allows the "Multi user" in "[B]oot Multi user" to be substituted with another string, for example with "Installer" in installer media. Note that this is lua-only at the moment, since loader.4th's menu.rc defines the alternate name as Boot [M]ulti User, unlike lualoader which leaves it as [B]oot Multi user. Ideally loader.4th would adopt the newer and simpler lualoader behaviour and then it could gain support for this option, but loader.4th is on the way out and isn't used by any official installer media so this is not a significant concern. Reviewed by: kevans, rpokala MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D36418
|
#
bb4c6912 |
|
26-Oct-2021 |
Katsuyuki Miyoshi <katsubsd@gmail.com> |
lualoader: fix the autoboot_delay countdown message When the timer drops from double to single digits, a spare 'e' is left on the end of the line as we don't overwrite it. Include an extra space at the end to account for this and overwrite the leftover character. PR: 259429 MFC after: 3 days Reviewed by: emaste
|
#
ed107537 |
|
08-Sep-2021 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: use more concise verbiage for autoboot The behavior remains the same, but lualoader now uses the more concise verbiage that forthloader used. This is particularly important because the previous line would exceed the right boundary of the menu and run straight into space that would typically be allowed for the logo. This makes it slightly easier to port logos from forthloader to lualoader.
|
#
556e66b7 |
|
31-Mar-2021 |
Warner Losh <imp@FreeBSD.org> |
luaboot: visible must be a function Visible needs to be a function. Looks like I tested the wrong thing.
|
#
e7ccd5b4 |
|
30-Mar-2021 |
Warner Losh <imp@FreeBSD.org> |
loader: create a generic vendor sub-menu place holder Add a dummy vendor menu entry on the main welcome menu. Vendors can override this in their local.lua file to create whatever sub-menu they need for their products. Also fix the adding a 'welcome' entry as well based on a suggestion from Kyle. Silly option menu code also from Kyle. They seem to work for me, but any transcription error is likely mine. Reviewed by: kevans@ (the vendor stuff)
|
#
94510c29 |
|
01-Oct-2020 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: clear up some luacheck warnings - One (1) unused argument - One (1) trailing whitespace - Two (2) "non-standard global" (curenv, rewind) tools/boot/lua-lint.sh is once again happy.
|
#
8f3b3610 |
|
28-Sep-2020 |
Warner Losh <imp@FreeBSD.org> |
Report the kernel console on the boot screen Report what console the boot loader is telling the kernel to use: o Dual (Serial Primary) o Dual (Video Primary) o Serial o Video This allows the user to interrupt the boot and tweak the cosnole, if needed, in a trivial way. Useful for installs where the default selected may not be quite what you want, or when you are running a dual setup and need to toggle over to the other console being primary. The 'c'/'C' keys will do the cycling through the consoles. Note: you'll still have to drop into the loader to set details about serial consoles. And this doesn't change the console the loader is using. Reviewed by: kevans@ MFC After: 3 days Differential Revision: https://reviews.freebsd.org/D26573
|
#
277f38ab |
|
18-Aug-2020 |
Mariusz Zaborski <oshogbo@FreeBSD.org> |
zfs: add an option to the bootloader to rewind the ZFS checkpoint The checkpoints are another way of keeping the state of ZFS. During the rewind, the pool has to be exported. This makes checkpoints unusable when using ZFS as root. Add the option to rewind the ZFS checkpoint at the boot time. If checkpoint exists, a new option for rewinding a checkpoint will appear in the bootloader menu. We fully support boot environments. If the rewind option is selected, the boot loader will show a list of boot environments that existed before the checkpoint. Reviewed by: tsoome, allanjude, kevans (ok with high-level overview) Differential Revision: https://reviews.freebsd.org/D24920
|
#
d2187b39 |
|
22-Apr-2020 |
Ryan Moeller <freqlabs@FreeBSD.org> |
menu.lua: Give names to menu entries Make menu customizations easier by naming the entries and using the names to build the table entries. Reviewed by: kevans Approved by: mav (mentor) MFC after: 1 week Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D24527
|
#
e12ff891 |
|
26-Sep-2019 |
Kyle Evans <kevans@FreeBSD.org> |
Further normalize copyright notices - s/C/c/ where I've been inconsistent about it - +SPDX tags - Remove "All rights reserved" where possible Requested by: rgrimes (all rights reserved)
|
#
6dd078df |
|
22-Sep-2019 |
Toomas Soome <tsoome@FreeBSD.org> |
loader_lua: lua color changes should end with reset The color change should have reset sequence, not switch to white.
|
#
8f7f3d08 |
|
25-Mar-2019 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Fix up some luacheck concerns - Garbage collect an unused (removed because it was useless) constant - Don't bother with vararg notation if args will not be used MFC after: 1 week
|
#
bdf12807 |
|
05-Nov-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Add chainload menu entry MFC after: 4 days
|
#
041929aa |
|
23-Oct-2018 |
Kyle Evans <kevans@FreeBSD.org> |
menu.lua: Abort autoboot sequence on failed command Currently, a timeout in the menu autoboot sequence would effectively do nothing. We would return from the autoboot handling, then begin processing the menu without redrawing it. This change makes the behavior a little more friendly. Returning the user to the menu can't have any good effects, so abort the autoboot sequence and drop to the loader prompt. MFC after: 3 days
|
#
e414851f |
|
23-Oct-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: unload upon kernel change if a kernel was previously loaded In the majority of cases, a kernel is not loaded before we hit the menu. However, if a password is set, we'll trigger autoboot and have loadelf'd beforehand. We also need to take into account one dropping to the loader prompt and twiddling with things manually; if they try to toggle through kernels, we'll assume they mean it. Reported by: trasz MFC after: 3 days
|
#
76c75816 |
|
11-Oct-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Provide a 'menu' command to redraw the menu at the loader prompt Reported by: allanjude Approved by: re (kib)
|
#
c84dbc53 |
|
05-Oct-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Don't draw loader menu with autoboot_delay=-1 This was mostly a cosmetic issue. autoboot_delay=-1 is documented to bypass the loader menu and immediately execute the boot command, but lualoader would draw the menu and immediately execute the boot command. No interaction was possible with the menu. The fix lifts autoboot_delay processing out of menu.autoboot, which now takes a delay and does nothing if no delay is specified. This lines up with my expectations of menu.autoboot's usage from a third party, which may want more control over the process than the default behavior. PR: 231610 Approved by: re (gjb)
|
#
8ce1744f |
|
21-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Clear up some possible naming confusion In the original lualoader project, 'escapef' and 'escapeb' were chosen for 'escape fg' and 'escape bg'. We've carried on this naming convention, and as our use of attributes grow the likeliness of 'escapeb'/'resetb' being confused upon glance for 'escape bold'/'reset bold' increases. Fix this by renaming these four functions to {escape,reset}{fg,bg} rather than {escape,reset}{f,b} for clarity. Reported by: dteske
|
#
3224bb3f |
|
20-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Use less atomic options for resetting colors/attributes Noted by dteske: CSI 1m ... CSI 22m CSI 2m ... CSI 22m CSI 4m ... CSI 24m CSI 5m ... CSI 25m CSI 7m ... CSI 27m CSI 8m ... CSI 28m CSI (30-37)m ... CSI 39m CSI (40-47)m ... CSI 49m - Provide resetf/resetb to match escapef/escapeb - Use CSI 22m to undo a bold This is a more reasonable approach than what was previously taken. Reported by: dteske
|
#
3244729f |
|
09-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Don't redraw the autoboot message every .05s
|
#
e9c3ceb1 |
|
07-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Use cli_execute_unparsed instead of loader.interpret loader.interpret should not be used for executing loader commands from an untrusted source (e.g. environment vars) as it will allow execution of arbitrary Lua. Replace it with a call to the recently introduced cli_execute_unparsed, which parses it out as a loader command and then dispatches it as a loader command. This effectively filters out arbitrary Lua.
|
#
1495c98f |
|
03-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Tweak positioning and fix an off-by-one - All of our default positions were offset from forth - Our menu frame size was smaller than in forth - Logo/brand drawing had an off-by-one, drawing one column lower on the screen than they should have been. - While here, switch a print() to printc() as it's expected that logos may contain color and other escpae sequences that we'll need to honor.
|
#
a76f8a5b |
|
03-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Execute menu_timeout_command at the end of menu autoboot Instead of hardcoding "boot", respect menu_timeout_command from Forth. It still defaults to 'boot', so this will not be a functional change for most.
|
#
decacd91 |
|
02-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Reset the cursor position after the menu is drawn Rather than before the menu is drawn. The drawer is going to reset the crusor position as soon as it draws anything anyways, so doing it before serves no purpose. Setting it after is needed so we don't clobber the menu when we start booting.
|
#
43f7d9d1 |
|
28-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Dedup these "Return to main menu" entries
|
#
9937e979 |
|
26-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Re-work menu skipping bits 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.
|
#
04af4229 |
|
25-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: More argument name expansion, part 2 screen also has some instances, but it also has other cleanup to go with it. Because of this, I will be committing the screen changes separately.
|
#
2a11b810 |
|
25-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: A little more general menu cleanup Instead of a single-letter parameter ('m'), use something a little more descriptive and meaningful: 'menudef' ("menu definition") -- these functions expect to be passed a menudef, so call it what it is. While here, throw an assertion in that we have a handler for the selected menu item. This is more of a debugging aide so that it's more obvious when one is testing a menudef that they've added an entry item that we don't handle. This is an improvement over the past behavior of ignoring the unknown menu entry.
|
#
beafe961 |
|
25-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Track the menu currently drawn, instead of validity This cleans up the odd approach to menu drawing. Instead of tracking validity, we track the menu that was drawn on the screen. Whenever we draw a menu, we'll set this to that menu. Anything that invalidates the screen should go ahead and trigger an explicit redraw, rather than finding a wy to set screen_invalid. The currently drawn menu is then reset in menu.run as we exit the menu system, so that dropping to the loader prompt or leaving menu.run() will just behave as expected without doing redundant work every time we leave a menu.
|
#
fe226a72 |
|
25-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Invalidate the screen from menu perspective upon mnu exit In the common case, this will effectively do nothing as the menu will get redrawn as we leave submenus regardless of whether the screen has been marked invalid or not However, upon escape to the loader prompt, one could do either of the following to re-enter the menu system: -- Method 1 require('menu').run() -- Method 2 require('menu').process(menu.default) With method 1, the menu will get redrawn anyways as we do this before autoboot checking upon entry. With method 2, however, the menu will not be redrawn without this invalidation. Both methods are acceptable for re-entering the menu system, although the latter method in the local module for processing new and interesting menus is more expected.
|
#
ca16d83f |
|
24-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Pull autoboot handling out into menu.run() There's no reason for autoboot handling to be mixed in with menu processing. It is a distinct process that should only be done once when entering the menu system. menu.process has been modified to take an initial keypress to process and to only draw the screen initially if it's been invalidated. The keypress is kind of a kludge, although it could be argued to be a potentially useful kludge if there are other processes that may need to feed a keypress into the menu system.
|
#
28384160 |
|
24-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Pull menu redrawing specifics out of menu.process In general, every menu redraw is going to require a screen clear and cursor reset. Each redraw also has the potential to invalidate the alias table, so we move the alias table being used out into a module variable. This allows third party consumers to also inspect or update the alias table if they need to. While here, stop searching the alias table once we've found a match.
|
#
da9ab827 |
|
24-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Clean up menu handling a little bit This is driven by an urge to separate out the bits that really only need to happen when the menu system starts up. Key points: - menu.process now does the bulk of menu handling. It retains autoboot handling for dubious reasons, and it no longer accepts a 'nil' menu to process as 'the default'. Its return value is insignificant. - The MENU_SUBMENU handler now returns nothing. If menu.process has exited, then we continue processing menu items on the parent menu as expected. - menu.run is now the entry point of the menu system. It checks whether the menu should be skipped, processes the default menu, then returns.
|
#
3cd5547b |
|
24-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: menu: Terminate final values in tables with a comma
|
#
322a2ddd |
|
24-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Clean up naming conventions a little bit We mostly use camel case for function names, but some local functions got mixed in using internal underscores. Doubles down on camel case.
|
#
9ed6f9ef |
|
22-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Use "local function x()" instead of "local x = function()" The latter is good, but the former is more elegant and clear about what 'x' is. Adopt it, preferably only using the latter kind of notation where needed as values for tables.
|
#
ee4e69f1 |
|
22-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: shallowCopyTable => deepCopyTable I called it a shallow copy, but it wasn't really a shallow copy at all.
|
#
72e39d71 |
|
22-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
Add SPDX tags to lua files
|
#
66964bbc |
|
22-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Attend to some 80-col issues, pointed out by luacheck Graphics have a tendency to cause 80-col issues, so make an exception to our standard indentation guidelines for these graphics. This does not hamper readability too badly. Two 40-column strings of spaces is trivially replaced with string.rep(" ", 80)
|
#
e2df27e3 |
|
21-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Address some 'luacheck' concerns 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.
|
#
4ab039b5 |
|
21-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Eliminate some unused locals
|
#
7dcffa90 |
|
21-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Don't execute menu.autoboot() for every opened menu Attempt to autoboot when we open the default menu, and only when we open the default menu. This alleviates the need for checking menu.already_autoboot, because we're not trying to autoboot every time we open a submenu. I note that escaping to loader prompt and going back to the menu (by running require('menu').run() at the loader prompt) will happily work and not re-initiate the autoboot sequence since "Escape to loader prompt" disables the autoboot_delay.
|
#
7efc058f |
|
21-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Add boot environment support This looks a little bit differently than the forth version for the time being, just to get off the ground- rather than a paging system, it's implemented as a simple carousel like the kernel selector. Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D14436
|
#
12b95c84 |
|
21-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Use the key that interrupts autoboot as a menu choice This matches forth behavior. Hitting "6" when autobooting at the welcome menu will now take you directly to the "Boot Options" menu. We likely have some slight optimizations we should make, like not checking autoboot every time we open a new menu and things of this nature. Further work will go towards this end.
|
#
4f437f9e |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Allow carousel 'items' to be a table as well as a function We don't have any in-tree users of this, but for a static set of carousel options having to define a callback is excessive.
|
#
a51f9f0c |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Simplify menu definitions a little further Allow "name" entries to be simple strings, instead of just functions. We know whether we support colors or not by the time any of this is setup, so all menu names that are basically static with colors sprinkled in are good candidates for simplification. Also simplify "func" in many cases where it's just invoking another function with no arguments. The downside to this simplification is that the functions called can no longer be trivially replaced by a local module. The upside is that it removes another layer of indirection that we likely don't need. These can be re-evaluated later if a compelling argument is raised, on a case-by-case basis, for replacement.
|
#
9a28f948 |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Directly reference submenu definition with submenu key
|
#
dd65496a |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Drop name requirement for menu separators
|
#
20a81676 |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Add "menu.default", initialized to menu.welcome The intent here is to abstract away the name of the default menu. The default menu is still the welcome menu, but this detail doesn't need to matter to things outside of the menu module. You may change the default menu, but one would need to modify a specific menu.
|
#
49550489 |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Drop explicit boolean tests; b or not b
|
#
9f71d421 |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Drop excessive parenthesizing 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.
|
#
aedd6be5 |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Drop terminating semicolons 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.
|
#
f0cb3b6b |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Intercept boot cli command This should be functional and roughly equivalent to the Forth version. Stop doing a loadelf() on menu exit now that we can DTRT with boot invocations. autoboot interception will follow not long after.
|
#
c1ab36f5 |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Ignore ACPI bits on !i386
|
#
25c4c7a5 |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Move carousel storage out into config Carousel storage doesn't need to happen in the menu module, and indeed storing it there introduces a circular reference between drawer and menu that only works because of global pollution in loader.lua. Carousel choices generally map to config entries anyways, making it as good of place as any to store these. Move {get,set}CarouselIndex functionality out into config so that drawer and menu may both use it. If we had more carousel functionality, it might make sense to create a carousel module, but this is not the case.
|
#
b5746545 |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Consistently organize modules We follow pretty closely the following structure of a module: 1. Copyright notice 2. Module requires 3. Module local declarations 4. Module local definitions 5. Module exports 6. return Re-organize the one-offs (config/drawer) and denote the start of module exports with a comment.
|
#
e15abd1f |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Consistently declare local functions at module scope Declare these adjacent to the local definitions at the top of the module, and make sure they're actually declared local to pollute global namespace a little bit less.
|
#
8d415029 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Extract menu handlers out into menu.handlers table This is a bit cleaner than our former method of an if ... else chain of handlers. Store handlers in the menu.handlers table so that they may be added to or removed dynamically. All handlers take the current menu and selected entry as parameters, and their return value indicates whether the menu processor should continue or not. An omitted return value or 'true' will indicate that we should continue, while returning 'false' will indicate that we should exit the current menu. The omitted return value behavior is due to continuing the loop being the more common situation.
|
#
4b6da14c |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Wrap tuple assignment earlier for readability
|
#
9a0904b0 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Cache swapped menu, and don't create locals for swapping Building the swapped welcome menu (first two items swapped) is kind of a sluggish, because it requires a full (recrusive) shallow copy of the welcome menu. Cache the result of that and re-use it later, instead of building it everytime. While here, don't create temporary locals just for swapping. The following is just as good: x, y = y, x; Reported by: Alexander Nasonov <alnsn@yandex.ru> (swapping)
|
#
21d5bcbe |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Add copyright notice in places I've made some not-insignificant changes to config, menu, and password bits of our lua scripts. Add a copyright notice to them to reflect.
|
#
c8518398 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Re-order locals after copyright notice; require comes first
|
#
1f5696c7 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Round up some more style.lua(9) concerns
|
#
5c1b5165 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Change boot menu items' names when swapped [Enter] should be moved to the single user menu item when we swap them. Define a non-standard menu entry function "alternate_name" to use for this purpose for ultimate flexibility if we change our minds later. When we're booting single user, make a shallow copy of the menu that we'd normally display and swap the items and their name functions to use alternate_name instead. Toggling single user in the options menu and going back to the main menu will now correctly reflect the current boot setting with the first two menu options and "[Enter]" will always be on the right one. This shallow copy technique has the chance of being quite slow since it's done on every redraw, but in my testing it does not seem to make any obvious difference. shallowCopyTable could likely belong better in a general-purpose utility module, but this (and the key constnats) are the only candidates we have at the moment so we'll drop it into our core stuff for the moment and consider re-organization at a later date.
|
#
fd2b19b3 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Re-wrap menu.lua now that I've added indentation...
|
#
303253e5 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Swap single-/multi- user boot entries as needed
|
#
d8757746 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Store menu entries in an "entries" table Instead of directly listing them in menu.welcome and menu.boot_options, store them at menu.welcome.entries and welcome.boot_options.entries. This will come into play later when we need to re-order the welcome menu if boot_single is specified.
|
#
280e990b |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Remove some unused local declarations Menus are actually defined as entries in the 'menu' table. These local declarations have not been used in the history of our in-tree lua scripts, so give them the boot.
|
#
57099121 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Menu style.lua(9) nits
|
#
b140d14b |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Rename bootserial for clarity
|
#
fa4a2394 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Defer kernel/module loading until boot or menu escape Loading the kernel and modules can be really slow. Loading before the menu draws and every time one changes kernel/boot environment is even more painful. Defer loading until we either boot, auto-boot, or escape to loader prompt. We still need to deal with configuration changes as the boot environment changes, but this is generally much quicker. This commit strips all ELF loading out of config.load/config.reload so that these are purely for configuration. config.loadelf has been created to deal with kernel/module loads. Unloading logic has been ripped out, as we won't need to deal with it in the menu anymore. Discussed in part with: allanjude
|
#
24a1bd54 |
|
16-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Style pass These are the style points that I'd like to try and maintain in our lua scripts: - Parentheses around conditionals - Trailing semicolons, except on block terminators - s:method(...) instead of string.method(s, ...) where applicable There's likely more, but that'll get hammered out as we continue.
|
#
bcf48a15 |
|
16-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Color non-default kernels blue
|
#
702b460d |
|
16-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Correct interpretation of autoboot_delay autoboot_delay=NO is documented to wait for input and *not* autoboot, which is the exact opposite of the current behavior. Additionally, autoboot_delay=-1 is documented to disallow the user from interrupting the boot (i.e. autoboot immediately), which was not previously honored. This also fixes the case insensitive comparison to be truly case insensitive. This is kind of nit-picky, but the previous version would only accept "no" and "NO".
|
#
3a0a07d0 |
|
16-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Enable menu autoboot; it seems to work
|
#
afa61e1c |
|
16-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Don't set autoboot_delay=NO in menu autoboot sequence We'll set it later if "Escape to loader prompt" is actually chosen, there's no need to be setting it here.
|
#
5d1e2f83 |
|
16-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Make CAROUSEL_ENTRY func parameters consistent with name We have no need for the index yet, but add it anyways to keep signatures consistent.
|
#
84f82e46 |
|
16-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Don't reload kernel config if we only have one kernel Don't move this into config.reload because we may want to force reloads if /boot changes out from under us later. As a caution: changing kernels in lualoader at the moment might not be loading all of your modules (in my testing, at least) from loader.conf(5). This is a known problem.
|
#
aefcaa7e |
|
16-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Don't try to divide by 0; do nothing
|
#
ef625845 |
|
16-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Allow MENU_RETURN items to have a func, fix escape to prompt
|
#
1504bce3 |
|
16-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Correct usage and acceptance of BACKSPACE/DELETE keys
|
#
a7cf0562 |
|
16-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Create/use some MENU_ constants where applicable
|
#
ada26c4a |
|
16-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Create a "carousel" menu entry type This is a pre-cursor to boot environment support in lualoader. Create a new menu item type, "carousel_entry", that generally provides a callback to get the list of items, a carousel_id for storing the current value, and the standard name/func functions that an entry has. The difference between this and a normal menu item, functionally, is that selecting a carousel item will automatically rotate through available items and wrap back at the beginning when the list is exhausted. The 'name' function takes the choice index, current choice, and the list of choices as parameters so that the menu item can decorate the name freely as desired. The 'func' function takes the current choice as a parameter, so it can act accordingly. The kernel menu item has been rewritten to use the carousel_entry type as both an example and initial test of its functionality before it is used for boot environment options.
|
#
39006570 |
|
15-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Remove a magic number/string (not a trivial literal) We'll arbitrarily use KEYSTR_ for string representations of non-trivial characters.
|
#
e9084012 |
|
15-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Say "loader prompt" instead of "lua interpreter" Noting that we're in lualoader is nice, but it's not a difference we raelly need to expose to Fred. Re-word it to match the 4th wording and reduce differences.
|
#
1666dfc0 |
|
15-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Remove explicit alias from "Back to main menu" This removes a redundant alias that has since been converted into a global alias. It was converted to a global alias before to ensure that we always have a way to go up one level in the menu.
|
#
b1b1f2b8 |
|
15-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Move kernel selection into main menu This matches the corresponding 4th behavior.
|
#
6a5a7e8a |
|
15-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Don't descend into an empty kernels submenu This submenu is likely going to go away in favor of kernel selection as it is done in forth at the moment, but for the time being don't descend into it if we have no kernels available for listing.
|
#
fe672a15 |
|
15-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Reduce magic numbers Enter/backspace values are hardcoded in both the menu and password scripts. Separate these out to core for reuse between the two.
|
#
b458bf0d |
|
15-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Always boot on 'enter' keypress in menus
|
#
abc4f7e7 |
|
14-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Exit sub-menus on backspace
|
#
088b4f5f |
|
12-Feb-2018 |
Warner Losh <imp@FreeBSD.org> |
Add the lua scripts from the lua-bootloader SoC 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
|