Commit Graph

444 Commits

Author SHA1 Message Date
Kyle Evans
64c91742f3 lualoader: Make config env-related bits private API
This pertains exclusively to the set/restore functionality that we offer,
where any changes made by loader.conf previously will be effectively removed
upon reload of the configuration. We don't currently have a need to export
these, so don't bother.
2018-03-24 04:00:01 +00:00
Kyle Evans
bc40337bb0 loader consoles: Implement SGR 24, 25
Mostly for completeness sake- implement 24 (no underline) and 25 (no blink)

MFC after:	3 days
2018-03-24 02:01:25 +00:00
Kyle Evans
1c1692795a efi loader: Choose a console mode instead if hw.vga.textmode is set
Not all systems use efifb; pull hw.vga.textmode and choose a good console
mode instead if it's set to something non-zero. This is basically a revival
of the code that used to live in boot1, but instead rebased onto this
different way of doing mode selection in loader.efi.

Interestingly enough, the regression that was previously introduced where
GOP would not reflect the console setting does not seem to exist when
console mode selection is done here. I've not done any investigation as to
why this is the case. Nevertheless, boot1.efi is still not the best place to
do mode selection.
2018-03-24 01:53:43 +00:00
Kyle Evans
bd868d67bc loader.conf(5): Convert list of values to much better looking table format
Discussed with:	jhb, rpokala
2018-03-23 23:46:59 +00:00
Kyle Evans
9ee31ef21c loader.conf(5): Document efi_max_resolution 2018-03-23 23:02:50 +00:00
Kyle Evans
05e8899d7d efi loader: Respect efi_max_resolution in loader.conf(5)
Default the max resolution to 1080p, we'll accept Width x Height
specifications along with the following presets:

- 480p
- 720p
- 1080p
- 2160p or 4k
- 5k

PR:		224825
Differential Revision:	https://reviews.freebsd.org/D14801
2018-03-23 21:02:46 +00:00
Kyle Evans
171403a3b3 Match broken style of vidconsole.c
This particular function uses a broken mix of indentation styles. Match it
for the newly added SGR 22 bits.

Reported by:	jkim
X-MFC-With:	r331416
2018-03-23 17:22:28 +00:00
Kyle Evans
88ccfa7497 Loader consoles: Implement SGR 22, reset intensity
MFC after:	3 days
2018-03-23 03:48:45 +00:00
Kyle Evans
9afece1e2f forthloader: Don't break BIOS boots...
I thought I tested this scenario, but clearly I failed to. =(

BIOS boots won't have efi-autoresizecons, so trying to use it as a forth
word fails during include. Use evaluate on "efi-autoresizecons" as a string
instead to move any potential errors to runtime- safely after we've already
checked that we're booting UEFI.

Pointy hat to:	me
Reported by:	cy
2018-03-22 04:16:14 +00:00
Conrad Meyer
70be5ca734 Apply r228478 (CTASSERT => _Static_assert()) to stand bootstrap.h
Reported by:	GCC (it doesn't like the unused array)
Sponsored by:	Dell EMC Isilon
2018-03-21 23:46:26 +00:00
Kyle Evans
5ef2174a50 Forth version of EFI autoresizing
r331321 delegated autoresizing to an efi-autoresizecons command that
currently is expected to be done in forth/lua prior to drawing anything
useful.

Add the Forth version of the lua addition in r331321, hook efi.4th up to be
installed.

efiboot? was written by dteske@; anything outside of that may be blamed on
me.
2018-03-21 22:01:51 +00:00
Kyle Evans
5f8cfbe134 UEFI: Ditch console mode setting, choose optimal GOP mode later in boot
boot1 is too early to be deciding a good resolution. Console modes don't map
cleanly/predictably to actual screen resolutions, and GOP does not reflect
the actual screen resolution after a console mode change. Rip it out.

Add an efi-autoresizecons command to loader to choose an optimal screen
resolution based on the current environment. We'll explicitly execute this
later, preferably before we draw anything of value but after we load config
and pick up any tunables we may need to decide where we're going.

This method also allows us to actually pass the correct framebuffer
information on to the kernel.

UGA autoresizing is not implemented because it doesn't have the kind of mode
enumeration that GOP does. If an interested person with relevant hardware
could get in contact, we can take a look at implementing UGA autoresize.

This effectively "fixes" the breakage caused by r327058, but doesn't
actually set the resolution correctly until the interpreter calls
efi-autoresizcons. The lualoader version of this has been included for
reference; the forth equivalent will follow.

Reviewed by:	imp (with some hestitation), manu
Differential Revision:	https://reviews.freebsd.org/D14788
2018-03-21 20:36:57 +00:00
Kyle Evans
9895e5d41b lualoader: Use printc when we expect ANSI escape sequences 2018-03-21 18:02:56 +00:00
Kyle Evans
8ce1744f82 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
2018-03-21 15:09:47 +00:00
Kyle Evans
5a79ea480e core.lua(8): Update to reflect recently added function clearCachedKernels 2018-03-21 03:16:14 +00:00
Kyle Evans
aea262bfc4 lualoader: Add primitive hook module, use it to untangle bogus reference
See: comments in the hook module about intended usage, as well as the
introduced use for config.reloaded.

Use the newly introduced hook module to define a "config.reloaded" hook.
This is currently used to register core's clearKernelCache as a reload hook
to avoid a circular dependency and fix this functionality- it didn't
actually work out, and it isn't immediately obvious how it slipped into src.

Other hook types will be introduced into the core lualoader as useful hook
points are identified.
2018-03-21 03:07:16 +00:00
Kyle Evans
3224bb3f77 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
2018-03-20 20:26:24 +00:00
Kyle Evans
4a034bad21 lualoader: Reset attributes and color scheme with color.highlight()
Previously, we sent a CSI 0m sequence to reset attributes, which also reset
the color scheme if the terminal defaults didn't match what we're expecting.
Go all-in and reset the color scheme, too, just in case.

Reported by:	emaste
2018-03-20 20:05:11 +00:00
Kyle Evans
2c58a19393 Amend missed reference to /boot/overlays, moved to /boot/dtb/overlays 2018-03-19 16:17:10 +00:00
Kyle Evans
d5a390e6c7 Move /boot/overlays to /boot/dtb/overlays
The former is fairly vague; these are FDT overlays to be applied to the
running system, so /boot/dtb is a sensible location to put it without
cluttering up /boot/dtb even further if desired.
2018-03-19 16:16:12 +00:00
Kyle Evans
85efc91a3c lualoader: Setup default color scheme if we're using colors
The console may have been set for different colors before lualoader kicks
in; notably, a black-on-white color scheme is not necessarily what we're
expecting.

While here, make color.default() a composition of color.escape() instead of
rewriting the escape sequence to make it more obvious what it's achieving: a
white-on-black color scheme with no attributes set.

Reported by:	emaste, whose eyes may rest easily
2018-03-19 15:48:31 +00:00
Ed Maste
c69defc269 loader.conf: remove obsolete non-x86 beastie menu statement
As of r330005 the same loader.conf defaults are used on all platforms.

Sponsored by:	The FreeBSD Foundation
2018-03-19 15:07:15 +00:00
Warner Losh
a0139c462a Don't add links or cleanfiles for NO_OBJ case, in addition to not
creating them. Move them under the if after the all: target.  They are
just defines, so it doesn't really matter where we have them.

MFC After: 3 days
2018-03-18 18:50:48 +00:00
Ed Maste
d8ba45e213 Revert r313780 (UFS_ prefix) 2018-03-17 12:59:55 +00:00
Ed Maste
1e2b9afca9 Prefix UFS symbols with UFS_ to reduce namespace pollution
Followup to r313780.  Also prefix ext2's and nandfs's versions with
EXT2_ and NANDFS_.

Reported by:	kib
Reviewed by:	kib, mckusick
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D9623
2018-03-17 01:48:27 +00:00
Warner Losh
1ce0264e67 Only print boot order / boot current if we can get the variables from
the loader. Some UEFI implementations don't return all of them.

Sponsored by: Netflix
2018-03-16 18:12:50 +00:00
Toomas Soome
255b83725c libefi: UEFI_BOOT_VAR_GUID duplicates EFI_GLOBAL_VARIABLE
Drop UEFI_BOOT_VAR_GUID and use EFI_GLOBAL_VARIABLE.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D14696
2018-03-15 05:58:35 +00:00
Kyle Evans
0cb59ea75a ubldr: Bump heap size from 512K to 1M
lualoader in itself only uses another ~200K, but there seems to be no reason
not to bump it a little higher to give us some more wiggle room.

With this, I can boot using a menu-enabled lualoader, no problem and
reasonably fast. Some heap usage datapoints from the review:

forthloader, no menus, kernel loaded:
heap base at 0x1203d5b0, top at 0x1208e000, used 330320

lualoader, no menus, kernel loaded:
heap base at 0x42050028, top at 0x420ab000, used 372696

lualoader, menus, kernel loaded:
heap base at 0x42050028, top at 0x420d5000, used 544728

Since then, the no menu case for lualoader should have decreased slightly as
I've made some changes to make sure that it no longer loads any of th emenu
bits with beastie disabled.

While here, split heap size out into a HEAP_SIZE macro.

Reviewed by:	ian, imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D14471
2018-03-14 02:35:49 +00:00
Gleb Smirnoff
695f33df8a Fix typo that misteriously passes compilation. 2018-03-13 22:54:29 +00:00
Kyle Evans
63ee68c220 EFIRT: SetVirtualAddressMap with 1:1 mapping after exiting boot services
This fixes a problem encountered on the Lenovo Thinkpad X220/Yoga 11e where
runtime services would try to inexplicably jump to other parts of memory
where it shouldn't be when attempting to enumerate EFI vars, causing a
panic.

The virtual mapping is enabled by default and can be disabled by setting
efi_disable_vmap in loader.conf(5).

Reviewed by:	kib (earlier version)
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D14677
2018-03-13 17:10:52 +00:00
Warner Losh
56e53cb8ef Prefer uintXX_t to u_intXX_t
A foolish consistency is the hobgoblin of little minds, adored by
little statesmen and philosophers and divines. With consistency a
great soul has simply nothing to do. -- Ralph Waldo Emerson
2018-03-13 16:33:00 +00:00
Toomas Soome
3ee1f2803b biosdisk.c should not set d_opendata.
Same as 330807, d_opendata is owned by open_disk and we should not
set it.

M    stand/i386/libi386/biosdisk.c
2018-03-13 09:58:29 +00:00
Kyle Evans
f0b03262c0 lualoader: Sprinkle some verbose_loading salt
Our module loading messages should be hidden without verbose_loading -- go
ahead and do that as a first step.
2018-03-13 02:59:13 +00:00
Warner Losh
ac15bcde8a Print the load and device path as well as BootCurrent and BootOrder
Sponsored by: Netflix
2018-03-12 21:40:24 +00:00
Warner Losh
c25acd4518 Star BootCurrent entry when booting.
Sponsored by: Netflix
2018-03-12 21:40:19 +00:00
Warner Losh
5722dd8394 Move the env convenience routines out of boot1.c.
These routines are more generally useful. Even though boot1 is on its
way out, it's better to make these common during the transition than
copy them.
2018-03-12 21:40:14 +00:00
Warner Losh
f7b26b765b Use the one-line-per-file pattern here, and sort the file names.
Sponsored by: Netflix
2018-03-12 21:40:09 +00:00
Warner Losh
2472d92505 GC unused routines.
Sponsored by: Netflix
2018-03-12 21:40:05 +00:00
Warner Losh
ad00892f4c Remove d_type from devdesc. It's not needed as we can fetch it from
d_dev->dv_type when we need it.
2018-03-12 21:39:59 +00:00
Warner Losh
de04d704a9 Use the actual struct devdesc at the start of all *_devdesc structs
The current system is fragile and requires very careful layout of all
*_devdesc structures. It also makes it hard to change the base
devdesc. Take a page from CAM and put the 'header' in all the derived
classes and adjust the code to match.

For OFW, move the iHandle h_handle out of a slot conflicting with
d_opendata. Due to quirks in the alignment rules, this worked.
However changing the code to use d_opendata storage now that it's a
pointer is hard, so just have a separate field for it.

All other cleanups were to make the *_devdesc structures match where
they'd taken some liberties that were none-the-less compatible enough
to work.
2018-03-12 21:39:49 +00:00
Warner Losh
f264386b32 Make struct libi386_devdesc match the struct devdesc better
Move data to top and call it d_opendata.
2018-03-12 21:39:42 +00:00
Warner Losh
49898aa2ff We can't use d_opendata for blkio storage.
open_disk uses d_opendata for it's own purpse. We can't store blkio
there. Fortunately, blkio is stored elsewhere and we never actually
retrieve blkio from d_opendata. Eliminate it as a source of confusion.
Eliminate all stores of d_opendata in efi since this layer doesn't own
that field.
2018-03-12 21:39:38 +00:00
Warner Losh
b3a2aad11e Minor cosmetic changes.
Make sure { on the same line as struct for all struct *devdesc.  Move
some type definitions to next to the dv_type define, since that's what
sets the d_type.
2018-03-12 21:39:27 +00:00
Kyle Evans
054564747d beri loader: Replace getc/putc with beri_ prefixed versions
This matches a convention that we use, at least in ubldr, to prefix
getc/putc with a loader-specific prefix to avoid collisions. This was
encountered while trying to build the beri loader with MK_LOADER_LUA=yes.

No objection from:	brooks
Reported by:	emaste
2018-03-12 03:54:38 +00:00
Kyle Evans
bef6cd493c stand/interp_lua: correct errorr => error 2018-03-11 04:10:18 +00:00
Kyle Evans
35b0c718d3 lualoader: Cache kernel list
With autodetection turned on, hitting the filesystem everytime we need to
calculate choices for the kernel carousel is kind of slow. Cache once on the
first listing and reload it anytime the config is reloaded in case any of
the loader.conf(5) changes that affect this (kernel, kernels,
kernels_autodetect) have changed. This also picks up the case where we've
changed currdev and the autodetected kernels could change.
2018-03-09 19:04:06 +00:00
Kyle Evans
3244729fbb lualoader: Don't redraw the autoboot message every .05s 2018-03-09 18:45:13 +00:00
Kyle Evans
cc8ea7cf7c stand: Fix copy-paste-o, unbreaks libi386 lualoader build
The 32-bit version of liblua is, in fact, NOT libficl. =)

Reported by:	emaste
2018-03-09 14:16:33 +00:00
Kyle Evans
f6e00525db lualoader: Return status in cli_execute_unparsed properly
cli_execute was changed to return the status, cascade that to
cli_execute_unparsed.

This fixes a lot of false "Failed to execute" errors following r330620; no
failures actually occurred, but [module]_error would've then promptly
executed (and also "failed")
2018-03-07 22:05:23 +00:00
Kyle Evans
dec08e67e4 loader.conf(5): Document some other settings
These tend to have less coverage in other places and they don't have
defaults as of yet, so mention them here:
- fdt_overlays
- kernels_autodetect (lualoader only)
2018-03-07 18:45:24 +00:00