Commit Graph

217 Commits

Author SHA1 Message Date
Kyle Evans
ddb76e073e stand/lua: Addres style.lua(9) concern 2018-02-19 02:01:49 +00:00
Kyle Evans
4a4fb4f8d6 stand/lua: Allow menu items to be conditionally (in)visible
This will be used to conditionally show/hide the boot environment menu.
2018-02-19 01:59:41 +00:00
Emmanuel Vadot
ff727b9a1d efi: Do not pad the efi devpath structure
This solve problem when booting with efi on armv7
Reviewed by:	imp, tsoome
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D14415
2018-02-18 11:17:39 +00:00
Kyle Evans
e402cd1307 stand/lua: More style nits, config.lua
Some other points I think we need to be consistent on:
- Spacing around string concatenation (always)
- Test against 'nil' explicitly rather than relying on 'not' for things that
  reasonably won't be returning a boolean. e.g. loader.getenv

Eventually this will all get formalized somewhere.
2018-02-18 01:35:46 +00:00
Kyle Evans
929c9bd077 liblua: Fix missing '}' in lutil.c after r329499 2018-02-18 01:31:18 +00:00
Conrad Meyer
a108046f58 lua loader: Auto detect eligible list of kernels to boot
Reviewed by:	imp, kevans
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D14419
2018-02-18 01:16:37 +00:00
Conrad Meyer
77d4be50c9 Lua loader: Add barebones "lfs" module
Add a Lua FileSystem module, an emulation of a subset of the permissively
licensed (MIT) Lua library of the same name[0], to our loader's Lua
environment.

[0]: https://github.com/keplerproject/luafilesystem/

Reviewed by:	kevans
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D14418
2018-02-18 01:15:25 +00:00
Conrad Meyer
6771d4a815 interp_lua: Register io/loader with regular Lua module system
Reviewed by:	kevans
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D14421
2018-02-18 01:13:58 +00:00
Kyle Evans
faf2ee299c stand/lua: Remove some debugging bits that snuck in... gr... 2018-02-18 01:01:15 +00:00
Kyle Evans
15d8e03c32 stand/lua: Fix module_path handling with multiple kernels
Once we've successfully loaded a kernel, we add its directory to
module_path. If we switch kernels with the kernel selector, we again prepend
the kernel directory to the current module_path and end up with multiple
kernel paths, potentially with mismatched kernel/modules, added to
module_path.

Fix it by caching module_path at load() time and using the cached version
whenever we load a new kernel.
2018-02-18 00:56:12 +00:00
Kyle Evans
7fc96e380a stand/lua: Fix verbiage and some typos
"other_kernel" is decidedly not spelled "other_kern"
2018-02-18 00:44:09 +00:00
Conrad Meyer
b216e997af liblua: Emulate DIR, opendir, fdopendir, closedir
In a similar fashion to FILE, provide thin shims for the standard directory
manipulation functions.

Reviewed by:	imp
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D14417
2018-02-17 22:18:39 +00:00
Conrad Meyer
f276951a4d liblua: Clean up io/loader C module registration
Utilize registration APIs Lua provides to make module definition a little
cleaner.

Discussed with:	imp
Sponsored by:	Dell EMC Isilon
2018-02-17 22:17:21 +00:00
Kyle Evans
4afa0076c5 stand/lua: dumpModules => lsModules
rgrimes@ notes that this behavior is more befitting of the latter name than
the former, and I'm inclined to agree.

Reported by:	rgrimes
2018-02-17 14:30:39 +00:00
Kyle Evans
32a5a33ec5 stand/lua: Debugging string snuck in... 2018-02-17 05:53:41 +00:00
Kyle Evans
24a1bd54dc 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.
2018-02-17 05:52:25 +00:00
Kyle Evans
c959454232 stand/lua: Check for nil (GELI prompt) 2018-02-17 05:28:06 +00:00
Kyle Evans
11cac43197 stand/lua: Add optional GELI passphrase prompt
Prompt for GELI passphrase when geom_eli_passphrase_prompt has been set to
"YES" in loader.conf(5).

This entailed breaking out the password prompt into its own function that
can be reused between the password compare bits and this prompt that simply
takes the entered password and passes it along in the environment as
kern.geom.eli.passphrase.

I've also added a TODO to re-evaluate later if we want the "password
masking" -- it is currently not functional, so one still can't observe the
length of the password typed at the prompt.
2018-02-17 05:26:28 +00:00
Kyle Evans
18c286a0ac stand/lua: Try to load alternate kernels as directories first
This is the procedure that config.loadkernel tries to go through, but
reloading kernel config didn't use this function. Amend config.loadkernel to
take an optional other_kernel.

While here, be a little more verbose ("Trying to load kernel") so that it's
easy to follow where we've gone wrong.
2018-02-17 05:02:38 +00:00
Kyle Evans
4d290ffb2d stand/lua: Correct test sense, this should have been 'not nil' 2018-02-17 04:46:06 +00:00
Kyle Evans
7104917375 stand/lua: Address some nits
1.) Instead of string.function(s, ...), use s:function(...)
2.) Don't try to concatenate `res`, it was just tested to be nil
3.) Note that "Loading configuration" is configured modules, and be a little
more precise in mentioning what failed ("loading of one or more modules")
2018-02-17 04:43:41 +00:00
Kyle Evans
41e77b5399 stand/lua: Add debug method to dump modules 2018-02-17 04:33:37 +00:00
Kyle Evans
c990f0a990 stand/lua: Correct some trivial errors in config
An empty module_path to start with isn't ideal, but if all modules are
contained within a kernel directory (which is what we just tested) then it
isn't strictly an error. Don't assume that module_path has a value already.

When we fail to load the kernel, printing the result (which is guaranteed to
be nil) is not intended; print the name of the kernel.
2018-02-17 04:22:36 +00:00
Kyle Evans
bcf48a159e stand/lua: Color non-default kernels blue 2018-02-17 04:07:16 +00:00
Kyle Evans
702b460d41 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".
2018-02-17 03:39:55 +00:00
Kyle Evans
3a0a07d0ea stand/lua: Enable menu autoboot; it seems to work 2018-02-17 03:13:05 +00:00
Kyle Evans
afa61e1c77 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.
2018-02-17 03:12:35 +00:00
Benno Rice
5857eb21be Revert r329269.
I tried to rework a section to fit inside 80 columns but the change ended
up being functional. Back this out so I can readdress.
2018-02-17 00:12:30 +00:00
Kyle Evans
5d1e2f83d0 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.
2018-02-16 23:59:50 +00:00
Kyle Evans
84f82e468c 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.
2018-02-16 22:57:52 +00:00
Kyle Evans
aefcaa7e85 stand/lua: Don't try to divide by 0; do nothing 2018-02-16 22:51:08 +00:00
Kyle Evans
ef62584580 stand/lua: Allow MENU_RETURN items to have a func, fix escape to prompt 2018-02-16 22:17:30 +00:00
Kyle Evans
5f9d54f4da stand/lua: Use escaped dot instead of single character class 2018-02-16 18:50:06 +00:00
Kyle Evans
901d96e3fb stand/lua: Chop off the decimal for numbers passed to setcursor
Decimals screw up the escape sequence and the cursor will not get set. Right
now this only affects setting the cursor for drawing "Welcome to FreeBSD" --
the resulting number after our (x+(w/2)-9) calculation gets output as
"14.0."

This should be fixed at the interpreter level, rather than here, but this is
not a widespread problem at the moment so we'll fix it up in further work.

Reported by:	David Wolfskill <david@catwhisker.org>
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D14375
2018-02-16 17:46:07 +00:00
Kyle Evans
1504bce32d stand/lua: Correct usage and acceptance of BACKSPACE/DELETE keys 2018-02-16 17:42:38 +00:00
Mark Johnston
16759360d4 Fix a memory leak introduced in r328426.
ffs_sbget() may return a superblock buffer even if it fails, so the
caller must be prepared to free it in this case. Moreover, when tasting
alternate superblock locations in a loop, ffs_sbget()'s readfunc
callback must free the previously allocated buffer.

Reported and tested by:	pho
Reviewed by:		kib (previous version)
Differential Revision:	https://reviews.freebsd.org/D14390
2018-02-16 15:41:03 +00:00
Kyle Evans
f35b4e7e97 stand/lua: Remove sneaky kernel assignment 2018-02-16 14:59:11 +00:00
Kyle Evans
a7cf056239 stand/lua: Create/use some MENU_ constants where applicable 2018-02-16 14:57:42 +00:00
Kyle Evans
ada26c4a88 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.
2018-02-16 14:39:41 +00:00
Kyle Evans
ecdc734299 stand/lua: Set ACPI's default the proper way (setACPI) 2018-02-16 13:57:43 +00:00
Kyle Evans
39006570a4 stand/lua: Remove a magic number/string (not a trivial literal)
We'll arbitrarily use KEYSTR_ for string representations of non-trivial
characters.
2018-02-16 04:59:21 +00:00
Kyle Evans
e908401285 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.
2018-02-16 04:50:14 +00:00
Kyle Evans
1666dfc03e 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.
2018-02-16 04:45:53 +00:00
Kyle Evans
196ba16663 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.
2018-02-16 04:44:47 +00:00
Kyle Evans
b1b1f2b8fd stand/lua: Move kernel selection into main menu
This matches the corresponding 4th behavior.
2018-02-16 04:31:09 +00:00
Kyle Evans
27fac8ff4c stand/lua: Consistently use semicolons for line endings 2018-02-16 04:10:10 +00:00
Kyle Evans
6401094f62 stand/lua: Set reasonable ACPI default based on presence
Set it based on hint.acpi.0.rsdp. Initially, hint.acpi.0.disabled will be
respected. "Using System Defaults" will override whether it's explicitly
disabled by hint and re-load it based on whether it's present on the system.

Unlike the 4th version, this is not restricted to x86. I have no strong
reasoning for this, so this is definitely open to change.
2018-02-16 04:03:15 +00:00
Kyle Evans
6a5a7e8a53 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.
2018-02-16 03:14:23 +00:00
Kyle Evans
fe672a15db 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.
2018-02-16 03:12:24 +00:00
Warner Losh
fcdb1f0317 Eliminate bsd.stand.mk and -fPIC 32-bit intel builds
OK. We don't really need a bsd.stand.mk, and it was causing a -fPIC
for the toolchain to be added (bogusly) when building on amd64. Pull
all relevant defs back into defs.mk and delete bsd.stand.mk.

This saves about 15-20k on i386 loader and zfsloader which when
combined with Lua give us a lot more stack space in those constrained
environments.
2018-02-16 00:17:32 +00:00