#
0fd98b8a |
|
15-Feb-2024 |
Warner Losh <imp@FreeBSD.org> |
loader: Move drawer.lua over to gfx table. Drawer.lua is the only bit of lua code in the base that uses any of the functons moved from the loader table to the gfx table. Move the main code to using the gfx dispatch. Add compat code for running on old loaders that creates the newer-style gfx table with the term_* functions we call in it populated. This will even work on the super old versions of the loader that don't have them (we'll still skip using them). Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D43908
|
#
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
|
#
e19d9a9b |
|
08-Sep-2021 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: allow brands to specify a shift Some brands will want to specify a shift to make sure they're properly centered; let it happen.
|
#
763bcebe |
|
08-Sep-2021 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: remove shadowed local from graphics:drawitem() for loop vars are local already and distinct from this earlier declaration; remove it.
|
#
4ba91fa0 |
|
21-Apr-2021 |
Toomas Soome <tsoome@FreeBSD.org> |
loader: do not output empty menu title As we output spaces around the menu title, we should also check, if the title is actually empty string. PR: 255299 Submitted by: Jose Luis Duran Reported by: Jose Luis Duran MFC after: 1 week
|
#
62ffcaab |
|
22-Mar-2021 |
Toomas Soome <tsoome@FreeBSD.org> |
loader: insert spaces around menu title Small visual nit, make menu title more clean MFC after: 3 days
|
#
96bef205 |
|
08-Feb-2021 |
Toomas Soome <tsoome@FreeBSD.org> |
loader: remove BORDER_PIXELS BORDER_PIXELS is left over from picking up the source from illumos port. Since FreeBSD VT does not use border in terminal size calculation, there is no reason why should loader use it. MFC after: 1 week
|
#
994e1f40 |
|
15-Jan-2021 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: use floor division to get correct type This fixes the positioning of the "Welcome to FreeBSD" heading, which was misplaced after the recent update to Lua 5.4. The issue was previously masked by a compatibility knob in Lua 5.3 that would cause float-tagged numbers to render faithfully without the decimal component. Lua 5.4 dropped that and ensures that it always prints a decimal component, even if it has to append a ".0" to the value. Standard division produces a "float", floor division (//) can be used to guarantee an integer. Floating point operations have been completely ripped out of the liblua compiled for the bootloader, so this is a nop. This is decidedly better than trying to hack out the float tag entirely. Reported-by: mjg, probably others MFC-after: 3 days
|
#
3630506b |
|
20-Dec-2020 |
Toomas Soome <tsoome@FreeBSD.org> |
loader: implement framebuffer console 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
|
#
546f18f3 |
|
04-Oct-2020 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: improve the design of the brand-/logo- mechanism In the previous world order, any brand/logo was forced to pull in the drawer and call drawer.add{Brand,Logo} with the name their brand/logo is taking and a table describing it. In the new world order, these files just need to return a table that maps out graphics types to a table of the exact same format as what was previously being passed back into the drawer. The appeal here is not needing to grab a reference back to the drawer module and having a cleaner data-driven looking format for these. The format has been renamed to 'gfx-*' prefixes and each one can provide a logo and a brand. drawer.addBrand/drawer.addLogo will remain in place until FreeBSD 13, as there's no overhead to them and it's not yet worth the break in compatibility with any pre-existing brands and logos. Reviewed by: freqlabs MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D24966
|
#
6697f577 |
|
01-Jun-2020 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: improve drawer error handling At least one user has landed in a scenario where logo files appear to be misnamed, and we failed to find them. Our fallback for missing logodefs is orb/orbbw, based on the color status. In a scenario where we can't locate the logos, though, this is not ideal. Add in one more layer of fallback to properly just don't draw any logo if the fan has been jam packed with foreign material. PR: 246046 MFC after: 3 days
|
#
90a25417 |
|
10-Sep-2019 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Revert to ASCII menu frame for serial console The box drawing characters we use aren't necessarily safe with a serial console; for instance, in the report by npn@, these were causing his xterm to send back a sequence that lua picked up as input and halted the boot. This is less than ideal. Fallback to ASCII frames for console with 'comconsole' in it. This is a partial revert r338108 by imp@ -- instead of removing the menu entirely and disabling color/cursor sequences, just reverting the default frame to ASCII is enough to not break in this setup. Reported by: npn Triaged and recommended by: tsoome
|
#
56758831 |
|
05-Sep-2019 |
Toomas Soome <tsoome@FreeBSD.org> |
loader: use teken teminal emulator for x86 and uefi Replace mini cons25 emulator with teken, this does enable us proper console terminal for loader and will make it possible to implement different back end callbacks to draw to screen. At this time we still only "draw" in text mode.
|
#
2c690e2a |
|
19-Aug-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Add drawer-exported variables for default logodefs Uncovered while writing the documentation from this, we previously explicitly fell back to orb or orbbw if an invalid or incompatible logodef was selected -- in contrast to branddefs, which have an exported variable that one can whip up a quick local.lua to override in a safe manner that works regardless of whether or not loader.conf(5) successfully loads.
|
#
a9edc01b |
|
19-Aug-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Hide the rest of the private interfaces These are less controversial than the others, thus done in a separate commit. These are all used internally and ways to override are provided via soon-to-be-documented API or loader.conf(5) variables.
|
#
12eaa305 |
|
19-Aug-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Hide most of the internal drawing functions Ideally, all of the functionality to revamp the loader screen has associated APIs that are flexible enough that third-party scripts wouldn't need to override these.
|
#
6112ee09 |
|
19-Aug-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Stop exporting drawer.draw drawer.draw is the back-end for drawlogo and drawbrand and should not be used directly.
|
#
e21e1dbe |
|
10-Jun-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Allow brand-*.lua for adding new brands dteske@, I believe, had originally pointed out that lualoader failed to allow logo-*.lua for new logos to be added. When correcting this mistake, I failed to do the same for brands. Correct the sub-mistake: creating new brands is almost identical to creating new logos, except one must use `drawer.addBrand` and 'graphic' is the only valid key for a branddef at the moment. While here, I've added `drawer.default_brand` to be set to name of brand to be used (e.g. 'fbsd', project default). Eventually this whole goolash will be documented. Reported by: kmoore, iXsystems
|
#
bbb516ae |
|
31-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Don't try to lookup a nil logo
|
#
1091c8fe |
|
31-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Split logodefs out into logo-* files This commit splits all of the logodefs/graphics out into their own own files and provides a method for these files to register their logodefs with the drawer. Graphics are now loaded on demand if they don't exist in the current set of logodefs. The drawer module becomes a little easier to navigate through without all of the graphics mixed in. It's also easy to do one-off graphics like the 9.2 Die Hard tribute by dteske@ without adding even more to our memory requirements.
|
#
9895e5d4 |
|
21-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Use printc when we expect ANSI escape sequences
|
#
2ed9eb5d |
|
03-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: logdef -> logodef typo
|
#
2d36799a |
|
03-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Shift menu+brand even for logo=none with customized pos
|
#
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.
|
#
b4353326 |
|
03-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Respect loader_menu_title_align It may be set to "left" or "right" -- any other value will cause the title to be centered. I've chosen to position these things just inside the vertical borders, rather than overlapping the corners. This is an arbitrary choice and easily amendable if this looks terrible.
|
#
953d8937 |
|
03-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Respect loader_menu_title, prepare for align
|
#
223e9874 |
|
02-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Use global printc instead of loader.printc r330282 registered loader.printc as printc, so use it instead. This makes sense for a couple reasons, the major point being that it reads a little bit easier and pairs nicely with the global 'print'. Similar cases can not really be made for other loader.* functions as most of them are either highly specific to our use-case or usually available in other modules, such as `os`. printc does not have a standard implementation in the Lua world(*), so we have a little more leeway with it, and it's kind of a special case of the globally available 'print'. (*) I've been in the Lua world for all of two weeks, so this could be wrong.
|
#
379e652e |
|
02-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Steamroll the box-drawing - Add drawer.frame_styles to map out the kinds of characters we need for the different loader_menu_frame values - Respect loader_menu_frame, default to double[*] - (imp) Use loader.printc instead of print- print adds a newline to the output, which is not the right thing we want to be doing. - (imp) Draw horizontal frames a little more efficiently- setting the cursor after every line segment is horribly inefficient, especially on serial consoles. Halve the number of characters written at the expense of an additional loop to draw the bottom frame, which is likely more efficient in the long run for some of less ideal scenarios. [*] menu.4th(8) claims that the default here was single, but unset loader_menu_frame yielded double and we didn't have any overrides in the default loader.conf(5), so double it is.
|
#
972c7fcd |
|
01-Mar-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Use string literal \xNN instead of string.char()
|
#
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.
|
#
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.
|
#
d709f254 |
|
23-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Remove unused variable; we now use the effective line number
|
#
1afbc37a |
|
22-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Track effective line number, use it for drawing Takes into account hidden entries, so that we don't draw blank lines in place of a hidden item.
|
#
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.
|
#
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.
|
#
1f6c6d86 |
|
21-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Replace 8-space indentation with a single tab
|
#
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.
|
#
dd65496a |
|
20-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
lualoader: Drop name requirement for menu separators
|
#
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.
|
#
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.
|
#
699578a6 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Insert helpful comment for drawer.branddefs
|
#
df74a61f |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Stick a copyright notice on drawer.lua
|
#
752b2d40 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Use 'graphic' instead of 'logo' for table depicting graphics This is a more sensible name that offers less redundancy when referring to it (vs. logodef.logo). Switch to it while the getting is good.
|
#
29aa5794 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Refactor brands into drawer.branddefs
|
#
bb26c57d |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Refactor logos into drawer.logodefs table This refactor makes it straightforward to add new logos for drawing and organizes logo definitions in a logical manner. The graphic to be drawn for each logo may again be modified outside of drawer, but it must be done on a case-by-case basis as a modification to the loader_logo.
|
#
02122e53 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Reduce exposure of the drawer module As part of an effort to slowly reduce our exports overall to a set of stable properties/functions, go ahead and reduce what drawer exposes to others. The graphics should generally not be modified on their own, but their position could be modified if additional grahics also need to be drawn. Export position/shift information, but leave the actual graphic local to the module. The next step will be to create a 'menudef' that gets exported instead, with each entry in the menudef table describing the graphic to be drawn along with specific positioning information.
|
#
da56fe38 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Move drawer.menu_name_handlers further up As a good candidate for modification, move this table further up in the module to improve visibility.
|
#
2413c411 |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Add and use drawer.menu_name_handlers Pull out specialized naming behavior into drawer.menu_name_handlers. This is currently only needed for the carousel entry, where naming is based on the current choice and the menu item purposefully does not store this state. The setup was designed so that every type can have a special name handler, and the default action is to simply use the result of entry.name().
|
#
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
|
#
2e716cec |
|
19-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Call menu_entries if it's a function If we've fetched menu.entries and it turns out it's a function, call it to get the actual menu entries. This will be used to swap multi-/single- user boot options if we're booting single user by default (boot_single="YES" in loader.conf(5)). It can also be used fairly easily for other non-standard situations.
|
#
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.
|
#
ddb76e07 |
|
18-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Addres style.lua(9) concern
|
#
4a4fb4f8 |
|
18-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Allow menu items to be conditionally (in)visible This will be used to conditionally show/hide the boot environment menu.
|
#
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.
|
#
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.
|
#
196ba166 |
|
15-Feb-2018 |
Kyle Evans <kevans@FreeBSD.org> |
stand/lua: Allow menu items to not have explicit aliases This will generally be used for cases like "Back to main menu" that already have global aliases installed.
|
#
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
|