Commit Graph

98891 Commits

Author SHA1 Message Date
Simon Glass
31bd3547bb cmd: Add -s flag to printenv -e for sorted output
Add support for sorting EFI variables by name when using printenv -e.
The -s flag sorts variables alphabetically before display, useful when
dealing with large numbers of variables.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

Series-to: concept
Series-cc: heinrich
Cover-letter:
efi: Improvements to env print -e
Printing EFI variables can be quite verbose, with many hundreds of lines
of text. Part of this is because GUIDs and hex dumps are included. It
can also be hard to find a few variables visually in an unsorted list.

This series makes the feature more user-friendly:
- Puts verbose output behind a -v flag, so that 'env print -e' behaves
  more like 'env print'
- Adds a -s option to sort the list
END
Series-links: 1:15
2025-08-22 08:23:17 -06:00
Simon Glass
ba43199ce9 efi: nvedit: Place variables in an alist before printing them
Rather than printing as we go, add variables to an alist so they can be
printed when all variables are present.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-22 08:23:17 -06:00
Simon Glass
ceb8cb140e efi: Refactor error handling in efi_dump_var_all()
Rather than freeing the variable in several places, put it at the end.
Assume failure by default, returning success only if all steps passed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-22 08:23:17 -06:00
Simon Glass
5247ae8219 efi: Rename var_name64 to name in efi_dump_var_all()
This variable name is quite long. There is only one 'name' (the variable
name) and it has to be u16 as it is an EFI variable. So rename it to
'name'.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-22 08:23:17 -06:00
Simon Glass
b60fd4dae9 efi: Change env print -e to show only names by default
Change the default behavior of 'printenv -e' to show only EFI variable
names. The previous verbose output is now available with the -v flag.
This makes the command more user-friendly for quick variable listing.

Update documentation to reflect the new behavior and provide examples
of all three output modes: default (names only), -n (details without
hex dump), and -v (full verbose output).

It might be nicer to use -d to enable the dump, rather than have it on
by default.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-22 08:23:17 -06:00
Simon Glass
b6c3c5ec6a efi: Enable access to efi variables from the app
Enable the 'setenv -e' feature.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-22 08:23:17 -06:00
Simon Glass
b0341ef417 efi: Move guid used for variables to common files
Move efi_guid_image_security_database to a common file so that it can be
used by the app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-22 08:23:17 -06:00
Simon Glass
a815f55022 Merge branch 'loadr' into 'master'
efi: app: Support booting an OS

See merge request u-boot/u-boot!160
2025-08-22 14:13:19 +00:00
Simon Glass
96d39714e4 test: efi: Add a test for the app booting Ubuntu via EFI
Now that the EFI app supports booting Ubuntu via the EFI bootmeth, add
a test for this, for ARM. This uses the sjg lab.

Series-to: concept
Series-cc: heinrich
Cover-letter:
efi: app: Support booting an OS
This series completes the work to get the EFI app booting an EFI
application (e.g. Ubuntu):

- efidebug dh now works, and is slightly enhanced
- device paths which refer to the underlying EFI layer can now be
  requested by the app
- a test is provided, for EFI on ARM booting into Ubuntu using the sjg
  lab
END

Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:12
2025-08-20 10:07:17 -06:00
Simon Glass
2e0fab9f72 efi: app: Allow booting an EFI app
Enable booting an app from the U-Boot app, since many distros package
their bootloader as an EFI app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
49d762e7ef efi: Add a little debugging to calculate_paths()
Provide some debugging for when things go wrong.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
cea7a888bf efi: Add device-path support for EFI media devices
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>
2025-08-20 10:07:17 -06:00
Simon Glass
9a7c744421 efi: Show component names and other info with efidebug dh
If a component name is available, show it, along with the supported
languages.

Also indicate at the top if the handle is a driver, rather than listing
that protocol at the end.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
2d2b8cff43 efi: Add the component-name2 protocol to efidebug dh
Add the GUID and API for this protocol so that we can use it in the
'efidebug dh' command.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
27893c8309 efi: Update efidebug dh to work with the app
Make use of the boot-time services rather than internal functions, so
that the app can implement this command.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
3637e38ab8 efi: Show the device name only with the EFI loader
The 'efidebug dh' command dereferences a handle to obtain the device
name.

The format of an EFI handle is not defined by the spec, so when running
in the app we cannot assume that the handle can be dereferenced. Even if
the EFI provider happens to be U-Boot it might be a different version.

So don't try display the device name with the app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
c029c38ad0 efi: Use a local var for a handle with efidebug dh
Rather than repeating handles[i], put it in a variable.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
ed609a9439 efi: Use a function to obtain boot services in efi debug
Rather than accessing the EFI loader's structure, create an
efi_get_boot() function to match that used by the app, so that the
call to protocols_per_handle() can operate in the app as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
e82779fb09 efi: Drop the BS macro with efi debug
Even if this is a subtle dig at EFI, it is only used once and there is
not much benefit in retaining it. Access the system-table directly,
instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
f06ec4fbcd efi: Move driver-binding guid to a common file
Move efi_guid_driver_binding_protocol to lib/efi so that it can be used
from the app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
4f95b262c8 efi: Drop EFI_CALL() from efidebug command
The intend of this macro is to debug calls from an app. But the efidebug
command is not an app, so it really doesn't make a lot of sense to call
via that macro. Remove EFI_CALL() from do_efi_show_handles() so that the
app can use this code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
a7117cda66 test/py: Support a timing report when max_count is 0
If only a single test runs, it does not set the max_count variable, so
it remains as zero. Handle this situation as a special case.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
c96e0fc2d9 Merge branch 'pate' into 'master'
patman: Various small tweaks

See merge request u-boot/u-boot!159
2025-08-20 16:05:02 +00:00
Simon Glass
c3b2c14731 patman: Support autolink when some series are archived
Archived series currently cause an error when autolink is attempted. Add
a check to avoid this.

Series-to: u-boot
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:458284
2025-08-20 09:54:41 -06:00
Simon Glass
12a20d3122 patman: Correct parsing of branch names
The name 'x86a' must be parsed as a branch name, not as versio 86 of
branch 'x'. Correct the regex and add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
a9ea16e399 patman: Allow using the first commit as series description
Sometimes series don't have a cover letter. Add a --use-commit option to
easily use the first commit's subject instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
e26ea124fb patman: Allow showing progress on archived series
Sometimes it is useful to include archived series in the progress report
so you can see all the work completed. Add a flag for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
16667556bd patman: Allow listing archived series
Sometimes it is useful to include archived series in the listing so you
can see which series could potentially be unarchived. Add a flag for
this.

Add a --include-archived option to the 'series ls' command for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
da1cdaf278 patman: Move split_name_version to patchstream
This function is needed by 'patman status', meaning that it must import
cser_helper which needs pygit2

Move it to patchstream so that pygit2 is not needed for the
'patman status' command.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
abb8470f86 patman: Avoid needing pygit2 for all subcommands
If pygit2 does not exist, patman refuses to work at all, but most
subcommands don't need it. Move the imports to resolve this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
822223cf91 Merge branch 'loadq2' into 'master'
efi: Move towards the EFI app booting EFI applications

See merge request u-boot/u-boot!158
2025-08-20 15:54:27 +00:00
Simon Glass
a3f84444ba efi: doc: Add documentation for efidebug command in the app
Mention the efidebug command specifically the EFI-app documentaion, to
highlight its usefulness.

Series-to: concept
Series-cc: heinrich
Cover-letter:
efi: Move towards the EFI app booting EFI applications
This series adds various new features to the EFI app, mostly by moving
code over from the EFI loader implementation.

In particular it adds support for the efidebug command (with only a
subset of subcommands so far).

The main approach is to make use of the system table (for both the app
and the loader) instead of directly calling EFI-loader code.

It also includes a few fixes, which likely have no effect but will help
to avoid confusion in future.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
Series-version: 2
Series-changes: 2
- Mention the 'dh' subcommand
- Mention that 'order' allows the boot order to be changed
- Mention the eficonfig command and the underlying UEFI firmware
Series-links: 2:10
2025-08-20 09:05:49 -06:00
Simon Glass
acff53b00d efi: app: Support efidebug boot add, rm and order
Enable these commands in the app, since the requires pieces are now in
place.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
fc274ee3d0 efi: Move efi_load_option_dp_join() to a common file
This function is useful in the app so move it to the common helper.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
c8c34fba1c efi: app: Use the same efi_free_pool() signature as loader
The app has a function of this name, but it does not return any value.
Return success (always) so that we can use the same signature.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
c43c1681ee efi: Move efi_string utilities to the common directory
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>
2025-08-20 09:05:49 -06:00
Simon Glass
fe33f0fbfb efi: app: Implement %pD in the app
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>
2025-08-20 09:05:49 -06:00
Simon Glass
16ed1a82ab efi: app: Find the device-path-to-text protocol on startup
Some protocols are generally useful for the app and it makes sense to
store these in the priv struct rather than requesting them each time
they are needed.

Add a new function which locates the device-path-to-text protocol and
stores it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
59f797f922 efi: app: Implement efidebug boot dump
Seeing the boot order is useful in the app. Everything we need is
present except an implementation of efi_query_variable_info_int(), so
add that and enable 'efidebug boot dump'.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
712bd388ef efi: Move FDT and global-variable GUIDs to common files
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>
2025-08-20 09:05:49 -06:00
Simon Glass
4500ade27f efi: Move some load-options handling into the common dir
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>
2025-08-20 09:05:49 -06:00
Simon Glass
eeaec57199 efi: Move a few helper functions into the common efi/ dir
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>
2025-08-20 09:05:49 -06:00
Simon Glass
7cc4e9b062 efi: app: Provide easy access to runtime services
Add a function which allows the app to obtain the runtime services
without first obtaining the priv data.

Make use of this in efi_vars.c

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
9a94bdebbf efi: app: Support efidebug show tables
It is useful to be able to see the available tables in the app, so
enable this subcommand. Provide an implementation of efi_get_sys_table()
that works for the EFI loader.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
7a46391c44 efi: app: Support efidebug memmap
It is helpful to see the memory map in some cases, so enable this
subcommand in the app.

Unfortunately we cannot assume that desc_size is the same in the
underlying EFI implementation, so use a variable for that.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
04062f0cbf efi: app: Support the efidebug command
This command is useful for the app, so enable it. For now most of the
subcommands don't work, so provide a message in that case. This seems
better than silently pretending that the subcommand doesn't exist.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
8bc5cf50ff efi: Update path_uefi() to avoid allowed_unaligned()
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>
2025-08-20 09:05:49 -06:00
Simon Glass
ddb6d94b03 efi: Add missing break to dp_fill()
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")
2025-08-20 09:05:49 -06:00
Simon Glass
6a54b56015 efi: Add missing break statements in dp_size()
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()")
2025-08-20 09:05:49 -06:00
Simon Glass
d33a7d75c2 Merge branch 'makee' into 'master'
test: Improvements to make check et al

See merge request u-boot/u-boot!157
2025-08-20 15:05:32 +00:00