Commit Graph

228 Commits

Author SHA1 Message Date
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
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
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
Kyle Evans
b458bf0da1 stand/lua: Always boot on 'enter' keypress in menus 2018-02-15 18:16:16 +00:00
Kyle Evans
abc4f7e735 stand/lua: Exit sub-menus on backspace 2018-02-14 20:18:23 +00:00
Warner Losh
088b4f5f32 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
2018-02-12 15:32:00 +00:00