summaryrefslogtreecommitdiff
path: root/stand/lua/menu.lua
AgeCommit message (Collapse)Author
2025-04-17loader: Add loader_autoboot_showEmmanuel Vadot
It's used to control if the autoboot part of loader is displayed or not. Differential Revision: https://reviews.freebsd.org/D49819 Reviewed by: imp Sponsored by: Beckhoff Automation GmbH & Co. KG
2025-01-09loader: Rework kernel menu sectionEmmanuel Vadot
With pkgbase we can have long kernel name, so create a new section for the kernel name. Do not show the "default" text, we already show the "1 of X" part at the end of the line and the default kernel is always number 1 so it's a bit redundant. Differential Revision: https://reviews.freebsd.org/D48354 Reviewed by: imp, tsoome Sponsored by: Beckhoff Automation GmbH & Co. KG
2024-10-11loader: Use Cyan instead of Blue for some menu itemsWarner Losh
BLUE often translates to DARK BLUE. On BLACK this is hard to read. Instead, use CYAN which looks good on both black and white backgrounds. Discussed with: kevans Sponsored by: Netflix
2024-09-24loader: Fix 0 vs 1 confusion for column numbersWarner Losh
In two places we use '0' for a column number. However, the upper left hand corner of the screen is 1, 1. Fix those two confusions. Also, fix a comment that flipped the coordinates in a comment (I'm used to the vt100 convention where it's row, column (eg y, x)) and didn't notice the rest of the code uses x, y. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D46777
2024-09-24loader: Use printc instead of print to fit in 24,80Warner Losh
print automatically adds a newline, while printc does not. Use printc in preference to print for managing the autoboot message. This means we can use line 24 safely on a 24x80 terminal, restoring some functionality that was lost in 101afbc6ee2f0. Note: we still set the default curosor position to 25,1 in screen.lua, but real VT100s (and successors) will treat any row larger than the pnumber of rows in a cursor motion command to be the last physical row (this is so you can move to 9999,9999 and do a cursor location query to get the size of the screen). Keeping that as is looks better on a typical VGA console. Fixes: 101afbc6ee2f0 Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D46771
2024-08-22loader/menu: tweak for added lineWarner Losh
I added a line to the menu, but didn't adjust so things were a line off. Make the necessary adjustments. Fixes: 7cb65be96d47 Sponsored by: Netflix MFC After: 3 days
2024-07-29stand: Use correct loader needs to be updated codeWarner Losh
Use the correct loader code that adds an inactive highlighted menu item indicating that an update is needed. My laptop is the only machine that I have a boot menu. I'd debugged the menu part there, but had all the other changes, including my original menu code, on my server and hadn't copied it back before pushing. Fixes: 0eac99f76ec3 Sponsored by: Netflix
2024-07-29stand: Add "Loader needs updating" to the first menu item"Warner Losh
When the boot loader version is too old, add a warning to the boot menu to maybe catch people's attention. Sponsored by: Netflix Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D45890
2023-11-20loader: improve lua ACPI detection and handlingR. Christian McDonald
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
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
2023-04-15loader: lua: unload the kernel when changing BEsCyrus Rahman
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
2022-09-02lualoader: Add loader_menu_multi_user_prompt config variableJessica Clarke
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
2021-10-26lualoader: fix the autoboot_delay countdown messageKatsuyuki Miyoshi
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
2021-09-09lualoader: use more concise verbiage for autobootKyle Evans
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.
2021-03-31luaboot: visible must be a functionWarner Losh
Visible needs to be a function. Looks like I tested the wrong thing.
2021-03-31loader: create a generic vendor sub-menu place holderWarner Losh
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)
2020-10-01lualoader: clear up some luacheck warningsKyle Evans
- One (1) unused argument - One (1) trailing whitespace - Two (2) "non-standard global" (curenv, rewind) tools/boot/lua-lint.sh is once again happy. Notes: svn path=/head/; revision=366314
2020-09-28Report the kernel console on the boot screenWarner Losh
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 Notes: svn path=/head/; revision=366228
2020-08-18zfs: add an option to the bootloader to rewind the ZFS checkpointMariusz Zaborski
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 Notes: svn path=/head/; revision=364355
2020-04-22menu.lua: Give names to menu entriesRyan Moeller
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 Notes: svn path=/head/; revision=360199
2019-09-26Further normalize copyright noticesKyle Evans
- s/C/c/ where I've been inconsistent about it - +SPDX tags - Remove "All rights reserved" where possible Requested by: rgrimes (all rights reserved) Notes: svn path=/head/; revision=352757
2019-09-22loader_lua: lua color changes should end with resetToomas Soome
The color change should have reset sequence, not switch to white. Notes: svn path=/head/; revision=352601
2019-03-26lualoader: Fix up some luacheck concernsKyle Evans
- 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 Notes: svn path=/head/; revision=345518
2018-11-05lualoader: Add chainload menu entryKyle Evans
MFC after: 4 days Notes: svn path=/head/; revision=340152
2018-10-24menu.lua: Abort autoboot sequence on failed commandKyle Evans
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 Notes: svn path=/head/; revision=339678
2018-10-24lualoader: unload upon kernel change if a kernel was previously loadedKyle Evans
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 Notes: svn path=/head/; revision=339677
2018-10-11lualoader: Provide a 'menu' command to redraw the menu at the loader promptKyle Evans
Reported by: allanjude Approved by: re (kib) Notes: svn path=/head/; revision=339307
2018-10-05lualoader: Don't draw loader menu with autoboot_delay=-1Kyle Evans
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) Notes: svn path=/head/; revision=339200
2018-03-21lualoader: Clear up some possible naming confusionKyle Evans
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 Notes: svn path=/head/; revision=331304
2018-03-20lualoader: Use less atomic options for resetting colors/attributesKyle Evans
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 Notes: svn path=/head/; revision=331259
2018-03-09lualoader: Don't redraw the autoboot message every .05sKyle Evans
Notes: svn path=/head/; revision=330701
2018-03-07lualoader: Use cli_execute_unparsed instead of loader.interpretKyle Evans
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. Notes: svn path=/head/; revision=330618
2018-03-03lualoader: Tweak positioning and fix an off-by-oneKyle Evans
- 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. Notes: svn path=/head/; revision=330345
2018-03-03lualoader: Execute menu_timeout_command at the end of menu autobootKyle Evans
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. Notes: svn path=/head/; revision=330340
2018-03-02lualoader: Reset the cursor position after the menu is drawnKyle Evans
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. Notes: svn path=/head/; revision=330287
2018-03-01lualoader: Dedup these "Return to main menu" entriesKyle Evans
Notes: svn path=/head/; revision=330138
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-26lualoader: More argument name expansion, part 2Kyle Evans
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. Notes: svn path=/head/; revision=330009
2018-02-26lualoader: A little more general menu cleanupKyle Evans
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. Notes: svn path=/head/; revision=330008
2018-02-25lualoader: Track the menu currently drawn, instead of validityKyle Evans
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. Notes: svn path=/head/; revision=329987
2018-02-25lualoader: Invalidate the screen from menu perspective upon mnu exitKyle Evans
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. Notes: svn path=/head/; revision=329986
2018-02-25lualoader: Pull autoboot handling out into menu.run()Kyle Evans
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. Notes: svn path=/head/; revision=329948
2018-02-25lualoader: Pull menu redrawing specifics out of menu.processKyle Evans
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. Notes: svn path=/head/; revision=329947
2018-02-25lualoader: Clean up menu handling a little bitKyle Evans
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. Notes: svn path=/head/; revision=329946
2018-02-25lualoader: menu: Terminate final values in tables with a commaKyle Evans
Notes: svn path=/head/; revision=329945
2018-02-24lualoader: Clean up naming conventions a little bitKyle Evans
We mostly use camel case for function names, but some local functions got mixed in using internal underscores. Doubles down on camel case. Notes: svn path=/head/; revision=329927
2018-02-23lualoader: Use "local function x()" instead of "local x = function()"Kyle Evans
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. Notes: svn path=/head/; revision=329856
2018-02-23lualoader: shallowCopyTable => deepCopyTableKyle Evans
I called it a shallow copy, but it wasn't really a shallow copy at all. Notes: svn path=/head/; revision=329854
2018-02-23Add SPDX tags to lua filesKyle Evans
Notes: svn path=/head/; revision=329851