Commit Graph

53 Commits

Author SHA1 Message Date
Kyle Evans
88ccfa7497 Loader consoles: Implement SGR 22, reset intensity
MFC after:	3 days
2018-03-23 03:48:45 +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
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
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
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
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
Kyle Evans
81fa17d177 stand: Fix build after r330249
One does not simply convert to SUBDIR.yes in stand without making everything
else in the affected files SUBDIR.yes -- there are better ways to do this.
2018-03-01 21:46:01 +00:00
Kyle Evans
27132543a0 stand: Makefile SUBDIR cleanup
Use SUBDIR.${MK_*} where appropriate. r330248 eliminated most of the
offenders, sweep the rest under the rug.

Differential Revision:	https://reviews.freebsd.org/D14545
2018-03-01 19:59:49 +00:00
Warner Losh
9e74797f30 Move EFI up to common makefile. There's no need for all these .if's
based on architecture.

Sponsored by: Netflix
2018-02-27 17:35:29 +00:00
Warner Losh
0c38f15ac7 Add NO_OBJ to those directories that don't make anything.
For directories that don't many anything, add NO_OBJ=t just before we
include bsd.init.mk. This prevents them from creating an OBJ
directory. In addition, prevent defs.mk from creating the machine
related links in these cases. They aren't needed and break, at least
on stable, the read-only src tree build.
2018-02-26 03:16:04 +00:00
Warner Losh
4784aef9f5 Consolidate three copies of ZFS commands into a central location.
There's no reason to have multiple copies of lszfs and
reloadbe. Consolidate them into one location. Also ldi_get_size is the
same everywhere (except sparc64). Make it the same everywhere as the
common definition is more general and will work on spar64.
2018-02-21 15:57:36 +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
Emmanuel Vadot
8b75269237 efi: Only scan the BLKIO MEDIA once
Scan only the BLOCK IO MEDIA once instead of each time for each type of
device (fd, cd and hdd).
Leave the mechanism to free and reprobe all devices if one day we want
to implement a "dev rescan" thing.

Reviewed by:	imp, tsoome
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D14334
2018-02-14 18:05:37 +00:00
Kyle Evans
003c70ff3c Remove now-unused variable after r328809
Fixed already in stable/11 by r328836 (emaste); remove now-unused variable.
2018-02-04 17:31:50 +00:00
Warner Losh
891b84a3aa Invent new LDR_INTERP for the loader interpreter to use. Use this in
preference to LIBFICL{,32}. LIBFICL{,32} are now always defined, but
LDR_INTERP{,32} is defined empty when building w/o forth (aka the
simple interpreter) and defined to LIBFICL{,32} when we are building
forth.
2018-02-02 15:40:49 +00:00
Warner Losh
b28421d5f1 These 4th words were an attempt to allow integration into the boot
loader scripts. However, that path won't be taken after all it
seems. Remove this code before it decays into uselessness. Also remove
build dependencies on forth no longer needed.
2018-02-02 15:01:44 +00:00
Warner Losh
8299b37f85 Centralize several variables.
MK_CTF, MK_SSP, MK_PROFILE, NO_PIC, and INTERNALLIB are always the
same, so set them in defs.mk. MAN= is common, so set it here too.
This removes a lot of boring repetition from the Makefiles that added
almost no value.
2018-02-02 06:32:26 +00:00
Kyle Evans
8a613444b5 stand/fdt: Consolidate overlay handling a little further
This should have been done as part of r327350, but due to lack of foresight
it came later. In the different places we apply overlays, we duplicate the
bits that check for fdt_overlays in the environment and supplement that with
any other places we need to check for overlays to load. These "other places"
will be loader specific and are not candidates for consolidation.

Provide an fdt_load_dtb_overlays to capture the common logic, allow passing
in an additional list of overlays to be loaded. This additional list of
overlays is used in practice for ubldr to pull in any fdt_overlays passed to
it from U-Boot environment, but it can be used for any other source of
overlays.

These additional overlays supplement loader.conf(5) fdt_overlays, rather
than replace, so that we're not restricted to specifying overlays in only
one place. This is a change from previous behavior where loader.conf(5)
supplied fdt_overlays would cause us to ignore U-Boot environment, and this
seems nonsensical- user should have sufficient control over both of these
aspects, or lack of control for good reasons.

A knob could be considered in the future to ignore U-Boot supplied overlays,
but the supplemental treatment seems like a good start.

Reviewed by:	imp (earlier version), gonzo (earlier version)
Differential Revision:	https://reviews.freebsd.org/D13993
2018-01-28 01:22:15 +00:00
Ed Maste
9b2ff7db9d loader.efi: add missing EFI GUIDs
These were found during bring-up on a new arm64 platform and in an
amd64 VM.

Submitted by:	Arshan Khanifar <arshankhanifar_gmail.com>
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D14036
2018-01-25 20:09:51 +00:00
Warner Losh
cec2b30645 Remove extra copy of bootinfo.c. It's a bit rotted copy of the one in
efi/loader.

Differential Review: https://reviews.freebsd.org/D13986
2018-01-19 19:09:17 +00:00
Kyle Evans
62821e5720 stand: Move sections around to fix stand/ build with ld.lld on armv7
When building loader bits, lld fails with the following error:
"ld: error: section: .dynamic is not contiguous with other relro sections"
on both ubldr and EFI loader.

Move .dynamic up to make ld.lld happy, adjust .got as necessary for ubldr.

Tested on:	OrangePi One (ld.lld, ubldr)
Tested on:	Banana Pi-M3 (ld.lld, ubldr)
Tested on:	qemu-armv7 (ld.lld, EFI)
Tested on:	qemu-armv7 (ld.bfd, EFI)
Tested on:	Raspberry Pi 2 (ld.bfd, ubldr) [manu]
Tested on:	Banana Pi-M2 (ld.bfd, ubldr) [manu]
Reviewed by:	andrew, emaste, imp
Differential Revision:	https://reviews.freebsd.org/D13942
2018-01-18 22:46:47 +00:00
Toomas Soome
981887b970 utf8_to_ucs2() should check for malloc failure
utf8_to_ucs2() is calling malloc() without checking the result.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D13933
2018-01-16 20:35:54 +00:00
Warner Losh
082f2fb1a6 Need to free uv after we're done using it.
Reported by: andrew@
Sponsored by: Netflix
2018-01-15 22:17:39 +00:00
Warner Losh
96c4f2c537 Check the return value from utf8_to_ucs2 instead of whether or not uv
is NULL. That's more correct and doesn't depend on the error behavior
of utf8_to_ucs2. In practice, we'll never see this though since we
pass utf8_to_ucs2 a well formed string.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13918
2018-01-15 22:17:34 +00:00
Warner Losh
27d95c1a03 When returning an error and freeing allocated memory from ucs2_to_utf8
and utf8_to_ucs2, be sure to NULL out the return pointer too, rather
than return a pointer to free memory.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13917
2018-01-15 22:17:15 +00:00
Andrew Turner
2c18ede691 Fix booting on some arm64 systems after r327879 by fixing the call to
utf8_to_ucs2 in boot1.efi. We need to initialise the ucs2 output string
so it will allocate space, and use the return value to determine if the
call was successful.

Reviewed by:	imp
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D13915
2018-01-15 16:58:07 +00:00
Warner Losh
1d28802f0c Allow this file to be included
Use simple "foo" rather than "${.CURDIR}/foo" to include Makefile.fat
since the former works when including this Makefile from else
where. Also, use full path from ${BOOTSRC} to the FAT templates for
similar reasons. It doesn't change anything in base FreeBSD, but
allows us to have a custom boot1.efi more easily (though that will be
short-lived for us, it may also be helpful for others).

Sponsored by: Netflix
2018-01-12 17:21:48 +00:00
Warner Losh
8d578b39fd Report the boot order and where we are in that boot order. Add
ability to create a boot1.efi that always fails for testing purposes
and failover scenarios.

Sponsored by: Netflix
2018-01-12 15:30:56 +00:00
Warner Losh
1e13416bb9 Add GUID for UEFI boot manager variables.
Sponsoered by: Netflix
2018-01-12 15:30:52 +00:00
Kyle Evans
06d6750e0d stand/fdt: Consistently apply fdt_overlays
Overlays were previously not applied when U-Boot provides FDT or EFI
provides FDT, only when we load FDT from /boot/dtb given name from U-Boot.

Make all three paths lead to loading fdt_overlays and applying them, so that
fdt_overlays can be expected to Just Work.

Reviewed by:	gonzo, imp, manu
Differential Revision:	https://reviews.freebsd.org/D13664
2017-12-29 18:08:30 +00:00
Michael Zhilin
5e6e2d38c1 [boot/efi] scan all display modes rather than sequential try-fail way
This patch allows to scan all display modes in boot1 as loader does.

Before system tried to select optimal display mode by sequential scan of
modes and if error then stop scanning. This way is not good, because
if mode N is not present, mode N+1 may exist.

In loader we use conout->Mode->MaxMode to identify maximum number of modes.
This commit is to use same way in boot1 as in loader.

Reported by:	Andrey Pustovetov <andrey.pustovetov@gmail.com>
Reviewed by:	tsoome
Differential Revision:	https://reviews.freebsd.org/D13541
2017-12-21 12:21:35 +00:00
Warner Losh
6bc860372d Interact is always called with NULL. Simplify code a little by
removing this argument, and expanding when rc is NULL. This
effectively completes the back out of custom scripts for tftp booted
loaders from r269153 that was started in r292344 with the new path
tricks that obsoleted it.

Submitted by: Netflix
2017-12-19 04:05:55 +00:00
Warner Losh
25c2f4cb95 Move loader help file definitions to being 100% inside of loader.mk.
HELP_FILES is a loader only thing, so move it to loader.mk. Only
generate the help file if HELP_FILES is defined. Adjust Makefiles to
new convention. Fix a few cases where ${.CURDIR}/ was missing
resulting in missing bits from the help files.

Sponsored by: Netflix
2017-12-18 04:51:34 +00:00
Toomas Soome
9f9b430b19 libefi: make efichar.h more usable in stand code
Use _STANDALONE for guard expression in efichar.[ch] and add efi_char typedef.
clean up boot1.c, and replace for loop in efipart.c with ucs2len().

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D13488
2017-12-14 16:41:52 +00:00
Warner Losh
ba25195ebf Revert r326792, r326784, r326772, r326712
Something subtle is creating problems for disk access on ubldr. Back
it out unti that can be sorted out.

Sponsored by: Netflix
2017-12-12 22:06:22 +00:00
Warner Losh
c83457486b Fix regression with lua import
Don't print when we can't find a file. Copy it instead to the error
buffer. Higher level routines determine if it's appropriate to print
the error message.

Also, remove dead code (labeled bogusly lost functionality) since we
never used that functionality. Remove unused arg from interact() too.

Sponsored by: Netflix
2017-12-11 16:18:05 +00:00
Warner Losh
f0408ed054 boot1.c needs EFI_ZFS_BOOT too, so add it globally. Otherwise we'll
not be able to actually read ZFS partitions.

Submitted by: kevans@
2017-12-08 19:57:26 +00:00
Warner Losh
f38658e140 Prefer stdint.h to inttypes.h since the added prototypes form the
latter aren't used. Prefer sys/link_elf.h to link.h so we're only
dependent on the kernel tree. The default installation of link.h just
includes this file, and any benefit from that is outweighed by the
hassle it causes. This reduces the footprint of files needed from the
system includes (or sysroot in buildworld).

Sponsored by: Netflix
2017-12-05 21:38:04 +00:00
Warner Losh
6fd96c93c1 Make sure we include the right path for skein.h, as well only include
the ZFS flags for zfs_modules.c. This keeps us from pulling from the
system or sysroot during buildworld.
2017-12-05 21:37:59 +00:00
Toomas Soome
61da91207d loader.efi: add note about iPXE into the efipart.c
Commant update.
2017-12-04 08:50:00 +00:00
Warner Losh
4291beb51b Remove stale dependency on ufsread.c
Remove the now-useless dependency on ufsread.c. In some cases, it was
on the wrong file. But in all cases, we now automatically generate
.depend files, so we don't need it explicitly.

Sponsored by: Netflix
2017-12-02 00:06:52 +00:00
Toomas Soome
e4f6a1bfa3 loader.efi: efipart should exclude iPXE stub block protocol
iPXE does insert stub  BLOCK IO protocol handle to rework other issues,
this handle is not usable as it does not provide actual implementation.

We can detect this situation by checking and validating the BlockSize
property, so this update does make sure we have BlockSize at least 512B
and its value is power of 2.

PR:		223969
Reported by:	Jeff Pieper
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D13297
2017-12-01 06:37:12 +00:00