The MMC and network subsystems must be present to use device paths for
them. Add the missing checks.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Create a new file in lib/efi to handle conversion of keys from EFI
format to characters, so we can use it from multiple places. Update the
serial_efi driver accordingly.
Signed-off-by: Simon Glass <sjg@chromium.org>
The device path is updated if an image is used, so move the setting of
*device_pathp lower, to take account of this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 73ad2d9909 ("efi: Move efi_bootflow_run() to a common file")
Shim is a program which normally comes before U-Boot in the boot
process. But when the app runs first, it can sometimes chain Shim since
that is what is contained within the bootaa64.efi file, for example.
Add a simple command for dealing with shim. For now it only supports
enabling verbosity.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a function which looks through a device path and tries to figure out
the corresponding name (e.g. 'nvme' and uclass ID. This can be useful
for showing a short summary of the device path.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add proper device-path handling for UCLASS_EFI_MEDIA devices in both
dp_size() and dp_fill() functions. This enables EFI applications to use
firmware device-paths for media devices accessed through the EFI block
I/O protocol.
Add some debugging while we are here.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
This file contains some useful utility functions which are not specific
to the EFI loader. Move them to lib/efi so they can be used by the app.
Signed-off-by: Simon Glass <sjg@chromium.org>
This printf() extension is useful for the app. Add an implementation of
efi_dp_str() so that it works as expected.
Signed-off-by: Simon Glass <sjg@chromium.org>
The global-variable GUID is already set in the common device_path.c file
but its declaration is only in the efi_loader header.
Move it and also move over the FDT GUIDs.
Signed-off-by: Simon Glass <sjg@chromium.org>
These functions are useful for the app as well as the loader.
For now, efi_set_load_options() calls efi_search_protocol() which is
still in the loader, but we can provide an 'app' version when needed. It
doesn't seem worth keeping that one function in a separate file.
Signed-off-by: Simon Glass <sjg@chromium.org>
Checking if a variable is a load option is useful for the app, so move
efi_varname_is_load_option() and u16_tohex() into a new helper.c file.
Signed-off-by: Simon Glass <sjg@chromium.org>
This call seems to have been added in an unrelated commit, likely to fix
a bug:
046fe7b507 ("efi_loader: efi_dp_from_file() expect UTF-8 path")
With standard boot we don't need to call efi_set_bootdev(). Also this
function is not available in the EFI app.
So for now, add a condition, to avoid a build error in the x86 app when
CONFIG_EFI_BINARY_EXEC is enabled.
Signed-off-by: Simon Glass <sjg@chromium.org>
While this doesn't really affect anything in practice, it is better to
deal with an incorrect use of this function (calling it with a UCLASS
which is not enabled).
Add a break after the UCLASS_BLK case, to help this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: a48a8929de ("efi: Move most of efi_device_path into lib/efi")
The conversion to using a size variable was missing a break statement
for the BLK case. Fix it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: ffde1a3922 ("efi: Use variables in dp_size()")
It is sometimes useful to display the memory type in logs, etc. Add a
function to convert it to a string, which is more user-friendly than a
number.
Signed-off-by: Simon Glass <sjg@chromium.org>
The 'efi mem' command dumps out the memory map. This is useful within
the app, even if commands are not enabled, so move it to a common file.
Rename it from 'print' to 'dump' since most things that dump information
use that word.
Signed-off-by: Simon Glass <sjg@chromium.org>
The EFI app will eventually execute binaries, but it does not enable
the CONFIG_EFI_LOADER option. So move the option to a common directory.
Signed-off-by: Simon Glass <sjg@chromium.org>
Move this function and some dependencies into the lib/efi directory so
that it can be used by the app, which does not enable CONFIG_EFI_LOADER
Since the networking has an #ifdef add CONFIG_EFI_LOADER to it, since
the definitions are in efi_loader.h for now.
Signed-off-by: Simon Glass <sjg@chromium.org>
Most of these utility functions are useful for the app, so move them
into the common directory.
Move the GUIDs used by this file from their various other location, so
they are available to the app, even if it doesn't enabled EFI_LOADER
Fix the rather large number of checkpath warnings in this file, except
for the lwip one, best left to the maintainer to sort out.
One noteable change is adding a return value to dp_fill() for the case
where an option is not enabled but its uclass is referenced. This
presuambly never happens during execution, since if the uclass is not
supported there can be no device in that uclass and therefore nothing
will ever request its path. So just handle this like an invalid device.
Signed-off-by: Simon Glass <sjg@chromium.org>
While the file where the basename.c code came from is marked as Linaro
from 2020, commit [1] was based on Heinrich's email. Also, [2] and [3]
were my patches. Linaro is not the copyright holder and none of the code
is from 2020.
Update the file accordingly.
Link: https://lore.kernel.org/u-boot/2175cecb-a392-5107-b932-b099ec21d62c@gmx.de
[1] 4e65ca00f3 ("efi_loader: bootmgr: add booting from removable media")
[2] 3e18860e3f ("bootstd: Allow reading an EFI file from the network")
[3] 7506c15669 ("sandbox: Report host default-filename in native mode")
Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Create a Kconfig which indicates that EFI functionality is in use,
either as a client (EFI app / stub) or provider (EFI loader). This will
make it easier to share code between these two parts of U-Boot
Signed-off-by: Simon Glass <sjg@chromium.org>
This directory was created when U-Boot gained the ability to run as an
EFI app in 2015. Since then the EFI-loader feature has been added.
The code in lib/efi is not actually used by the loader, so the name is
confusing.
Rename the directory to efi_client to indicate that it includes files
just for U-Boot being a client of EFI, i.e. the EFI app and stub.
Signed-off-by: Simon Glass <sjg@chromium.org>
Introduce an EFI app for arm64 and update the documentation.
Provide a value for LOAD_ADDR to avoid a link error.
Signed-off-by: Simon Glass <sjg@chromium.org>
Use the available functions for setting and getting the global_data
pointer so that EFI-startup can operate on 64-bit ARM as well as x86.
Signed-off-by: Simon Glass <sjg@chromium.org>
This code is not actually x86-specific, so move it into the lib/efi dir
where other archs can use it.
Drop inclusion of the unnecessary x86-specific header.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
When running U-Boot as an EFI payload with CONFIG_EFI_STUB, the reserved
regions from the previous stage EFI bootloader should be carried over
since they may not fully align with the reserved-memory regions in
devicetree.
Implement a helper to map these pages when the EFI subsystem starts up.
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Add a debug log for these since its often useful to inspect the memory
map from the EFI we're jumping from.
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
U-Boot itself might be mapped as LOADER_CODE, there's also no reason not
to make additional pages accessible to the OS. This fixes an issue where
U-Boot can't run EFI apps because it gets relocated somewhere outside of
its own memory map.
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Introduce two new helpers dram_init_banksize_from_efi() and
of_populate_from_efi(). These populate the DRAM bank info and simplefb
framebuffer OF node respectively using the EFI table populated by the
EFI stub.
dram_init_banksize_from_efi() is directly moved from the x86 payload
code to make it available for other boards.
Populating the simplefb node allows for an easy way to bring up video
without the full heft of VIDEO_EFI which is not particularly well-suited
to ARM.
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Avoid changing the devicetree with the EFI app; fix build error on x86:
Signed-off-by: Simon Glass <sjg@chromium.org>
Implement support for launching U-Boot via an EFI stub app on ARM64.
This is more or less a straight port of the x86 implementation, but due
to the highly x86/qemu specific nature of that implementation I decided
to just split it out to its own file.
Unlike the x86 implementation, there is no debug UART here since ARM
platforms don't have a standard UART interface. However it is usually
possible to port over the debug uart implementation for you platform for
bringup purposes.
Currently this implementation doesn't provide a DTB to U-Boot and
expects U-Boot to use a built-in one, however this ought to be a fairly
trivial addition in the future.
The other significant difference to the x86 version is that rather than
copying U-Boot to CONFIG_TEXT_OFFSET, we require that U-Boot is built
position independent and copy it to EFI allocated memory.
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
efi_bind_block had two issues.
1. A pointer to a the stack was inserted as plat structure and thus used
beyond its life time.
2. Only the first segment of the device path was copied into the
platfom data structure resulting in an unterminated device path.
Signed-off-by: Janis Danisevskis <jdanisevskis@aurora.tech>
Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
The UEFI app is an actual executable with things like section headers,
so just gluing the DTB onto the end of it won't work. Add an additional
section to contain this and allocate some space, and then during build
copy the DTB into that section.
Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
Add support for driving a TPM via UEFI firmware provided drivers, and
bind those devices from the UEFI app.
Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
Add a driver that makes use of the UEFI Simple Network Protocol to
support network access when using the UEFI app implementation, and hook
up the app code to instantiate it for probed devices.
Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
Add include of linux/ctype in epautoconf.c and conditional net.h:
Signed-off-by: Simon Glass <sjg@chromium.org>
Add simple support for accessing EFI variables when in EFI app mode
Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
We want to jump into the EFI stub in the kernel so it can perform
appropriate init and call ExitBootServices. Add support for doing that,
including ensuring that we copy the kernel to somewhere that's not
currently being used by the firmware.
Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
Drop use of image_info_t:
Signed-off-by: Simon Glass <sjg@chromium.org>