PC-BSD/trueos 346d905stand/efi/boot1 boot1.c Makefile, stand/efi/include efilib.h

MFC r346702-r346704, r346879-r346881, r347023, r347059-r347062,
r347193-r347194, r347201

r346702:
Add efi_freebsd_delenv

Add a wrapper around efi_delenv akin to efi_freebsd_getenv and
efi_getenv.

r346703:
Move initialization of the block device handles earlier (we're just
snagging them from UEFI BIOS). Call the device type init routines
earlier as well, as they don't depend on how the console is
setup. This will allow us to read files earlier in boot, so any rare
error messages that this might move only to the EFI console will be an
acceptable price to pay. Also tweak the order of has_kbd so it resides
next to the rest of the console code. It needs to be after we initialize
the buffer cache.

r346704:
Add the proper range of years for Netflix's copyright on this
file. Note that I wrote it.

r346879:
Read in and parse /efi/freebsd/loader.env from the boot device's
partition as if it were on the command line.

Fetch FreeBSD-LoaderEnv UEFI enviornment variable. If set, read in
loader environment variables from it. Otherwise read in
/efi/freebsd/loader.env. Both are read relative to the device
loader.efi loaded from (they aren't full UEFI device paths)

Next fetch FreeBSD-NextLoaderEnv UEFI environment variable. If
present, read the file it points to in as above and delete the UEFI
environment variable so it only happens once.

This lets one set environment variables in the bootloader.
Unfortunately, we don't have all the mechanisms in place to parse the
file, nor do we have the magic pattern matching in place that
loader.conf has. Variables are of the form foo=bar. No quotes are
supported, so spaces aren't allowed, for example. Also, variables like
foo_load=yes are intercepted when we parse the loader.conf file and
things are done based on that. Since those aren't done here, variables
that cause an action to happen won't work.

r346880:
Implement uefi_rootdev

If uefi_rootdev is set in the environment, then treat it like a device
path. Convert the string to a device path and see if we can find a
device that matches. If so, use that device at our root dev no matter
what. If it's bad in any way, the boot will fail.

r346881:
Implement uefi_ignore_boot_mgr env variable.

When set, we ignore all the hints that the UEFI boot manager has set
for us. We also always fail back to the OK prompt when we can't find
the right thing to boot rather than failing back to the UEFI boot
manager. This has the side effect of also expanding the cases where we
fail back to the OK prompt to include when we're booted under UEFI,
but UEFI::BootCurrent isn't set in the environment and we can't find a
proper place to boot from.

r347023:
stand: correct mis-merge from r346879

Small mis-merge from multiple WIP resulted in block io media handles getting
double-initialized. This resulted in some installations oddly landing at the
mountroot prompt.

r347059:
Remove stray '*'

We're storing an EFI_HANDLE, not an pointer to a handle. Since
EFI_HANDLE is a void * anyway, this has little practical effect since
the conversion to / from void * and void ** is silent.

r347060:
When we can't get memory, trying again right away is going to
fail. Rather than print N failure messages, bail on the first one.

r347061:
Substitute boot1 with ${BOOT1}

Allow for other names to be built, so parameterize this makefile to
avoid hard coding boot1.

r347062:
Use SRC+= rather than SRC=

To allow boot1/Makefile to be included, use SRC+= rathern than SRC=
so the including Makefile can add additional sources to the build.

r347193:
Reach over and pull in devpath.c from libefi

This allows us to remove three nearly identical functions because the
differences don't matter, and the size difference is trivial.

r347194:
We only ever need one devinfo per handle. So allocate it outside of
looping over the filesystem modules rather than doing a malloc + free
each time through the loop. In addition, nothing changes from loop to
loop, so setup the new devinfo outside the loop as well.

r347201:
Simplify boot1 allocation of handles.

There's no need to pre-malloc the number of handles. Instead call
LocateHandles twice, once to get the size, and once to get the
data.
DeltaFile
+171-50stand/efi/loader/main.c
+23-100stand/efi/boot1/boot1.c
+9-7stand/efi/boot1/Makefile
+7-1stand/efi/libefi/efienv.c
+1-1stand/efi/boot1/boot_module.h
+1-0stand/efi/include/efilib.h
+212-1596 files

UnifiedSplitRaw