Commit Graph

98964 Commits

Author SHA1 Message Date
Simon Glass
2b8858b779 efi: Move loaded-image, fs and device-path GUIDs to common
Allow these to be used from the app, when EFI_LOADER is disabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-02 06:41:32 -06:00
Simon Glass
5d8c07b404 efi_loader: Drop unnecessary efi_dp_str()
This declaration already exists in efi.h so drop it from this header.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-02 06:41:32 -06:00
Simon Glass
fe127667dc efi: Set the log category throughout lib/efi_client/
All files in this directory relate to EFI, so set the log category
consistently.

Series-to: concept
Series-cc: heinrich
Cover-letter:
efi: A few minor improvements
This series mostly tidies up the efidebug command, but includes a few
other pieces as well.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:20
2025-09-02 06:41:32 -06:00
Simon Glass
a815b91b97 efi: Allow inclusion of EFI-runtime headers
Some headers use the __efi_runtime macro in their declarations. With the
app we do not have a separate runtime sections, so define this to be
empty. This allows the headers to be included from the app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-02 06:41:32 -06:00
Simon Glass
64c72bcea2 efi: doc: Mention some EFI commands in the app documentation
It is not obvious what commands can be used in the app. Add some links.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-02 06:41:32 -06:00
Simon Glass
a2759428a9 efi: Correct calculate_paths() when an image is used
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")
2025-09-02 06:41:27 -06:00
GitLab CI
1dd869d9ba chore: Bump version for release candidate 2025.09-rc1 2025.09-rc1 c2025.09-rc1 2025-09-01 10:12:06 +00:00
Simon Glass
1ec67f521c Merge branch 'apb' into 'master'
efi: App and devicetree improvements

See merge request u-boot/u-boot!165
2025-08-28 20:31:49 +00:00
Simon Glass
56dab05ff1 efi: app: Sync EFI reserved-memory to the devicetree
Obtain EFI's view of reserved memory and ensure that everything
mentioned there is present in a devicetree reserved-memory node. This
ensures that the OS doesn't try to access memory it shouldn't.

Series-to: concept
Series-cc: heinrich
Cover-letter:
efi: App and devicetree improvements

This series improves U-Boot's EFI app support and adds new functionality
for managing devicetree reserved-memory regions.

The main focus is on enhancing memory management when running as an EFI
application. A new mechanism is introduced to sync EFI reserved-memory
regions (such as runtime services and ACPI tables) with the devicetree's
/reserved-memory nodes. This ensures that Linux doesn't inadvertently use
memory regions that EFI firmware has reserved.

The main improvements are:

- New 'fdt reserved' command to display devicetree reserved-memory regions
- New 'efi memsync' command to synchronize EFI memory map with devicetree
- Enhance EFI application support with better memory region handling
- Improve EFI debugging commands and device path handling
- Better integrate EFI boot services and devicetree setup

There are a few other minor thigns:
- Enhance efidebug commands with media device and driver information
- Expose EFI device-paths in a few places in bootstd
- Improve bootflow device reporting
- ARM-specific fixes for exception level handling

This series addresses many of the issues found in booting Linux on
Qualcomm X-Elite laptops using the EFI app.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 13:21:33 -06:00
Simon Glass
6e9071ba14 efi: app: Add a simple-framebuffer node if enabled
The EFI app cannot make the EFI GOP available to Linux directly, since
it calls exit-boot-services before booting Linux. The easiest way to
provide an early console is with the simple-framebuffer feature. Add
this node to the devicetree if the feature is enabled.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 13:21:32 -06:00
Simon Glass
8132f56189 efi: fdt: Provide a command to sync the reserve-memory node
Provide a command to sync reserved-memory with EFI's version of reserved
memory.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 13:21:32 -06:00
Simon Glass
eb85d76a42 efi: Provide a way to sync EFI reserved-memory to fdt
When booting Linux with EFI the devicetree memory-map is ignored and
Linux calls through EFI to obtain the real memory map.

When booting Linux from the EFI app, without EFI, we must pass the
reserved memory onto Linux using the devicetree.

Add a function to support this. It reads the EFI memory-map and adds any
missing regions to the reserved-memory node.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 07:00:55 -06:00
Simon Glass
0dc72120b7 fdt: Add a command to show reserved-memory regions
Add a new 'fdt reserved' subcommand that displays all reserved memory
regions defined in the device tree's /reserved-memory node. This command
provides a formatted table showing the ID, name, start address, and size
of each reserved memory region.

Avoid a conflict with the existing 'fdt resize' command. Update the docs
and add a test.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 06:55:49 -06:00
Simon Glass
ecca5cc322 fdt: Add a function to show the reserved-memory nodes
Add a new helper which lists the subnodes of the reserved-memory node.
This can be helpful when checking the devicetree before booting.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 06:55:49 -06:00
Simon Glass
a945ee1098 efi: Add an efi subcommand to show the loaded image
Sometimes it is useful to see the device-path of the app itself. Add a
new 'efi image' command for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 06:55:49 -06:00
Simon Glass
27f066d157 efi: Add a command to help with shim
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>
2025-08-28 05:21:49 -06:00
Simon Glass
f73b3aaab8 efi: Use abuf when reading EFI variables
The abuf interface provides a nicer abstraction of the data and size of
EFI variables.

Create a new efi_read_var() function and export it so it can be used
elsewhere. Adjust the existing efi_dump_single_var() to use it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 05:21:49 -06:00
Simon Glass
b0025aa2b0 boot: Show the underlying bootflow device in the app
Within the app all media devices are 'efi' so it isn't useful to show
that as the media. Look up the media-type of the underlying device, e.g.
'usb' or 'nvme'. This is a lot more helpful, and can make it easy to see
which bootflows relates to internal media and which to external, for
example.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 05:21:49 -06:00
Simon Glass
e6f9a0ae58 boot: Show the device path for EFI bootflows
If the bootflow relates to the EFI bootmeth, show the device path along
with the other info.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 05:21:49 -06:00
Simon Glass
ead588c067 boot: Correct filename in bootmeth_common_read_file()
This should add the filename provided to the image, not the original
bootflow filename. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 114dd14e38 ("bootmeth: Update the read_file() method to...")
2025-08-28 05:21:49 -06:00
Simon Glass
14e35376ab efi: Implement efidebug show drivers in the app
Adjust the code slightly to support the final subcommand in efidebug
that is currently unavailable in the app: 'efidebug drivers'.

Drop the now-unused app_not_supported() function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 05:21:49 -06:00
Simon Glass
9390344c35 efi: Add a uclass column to efidebug media command
Add a new column to the 'efidebug media' command that shows the likely
uclass for each EFI media device based on its device path.

This uses the new efi_dp_guess_uclass() function which looks through an
EFI device-path to determine the corresponding uclass.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 05:21:48 -06:00
Simon Glass
af0299b9de efi: Convert a device-path to a uclass and name
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>
2025-08-27 17:08:45 -06:00
Simon Glass
e395c41d59 efi: Add all messaging types for device paths
Fill out the rest of these values from the spec, so that we can (later)
provide a more useful summary for the user.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-27 17:08:38 -06:00
Simon Glass
c9c937170f efi: Add a way to show media devices
Add a new 'efidebug media' subcommand to show media devices and their
device-paths.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-27 16:51:47 -06:00
Simon Glass
cd8d6ccaef efi: app: Avoid freeing memory on exit
The private data is used to perform the exit, so freeing anything used
by the app may cause a hang or crash. The underlying EFI system should
be able to free any memory allocated by the app, so just skip the call
to free_memory()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-27 16:51:47 -06:00
Simon Glass
a7cc8de618 efi: app: Avoid switching exception levels on ARM
The EFI app runs under the environment provided to it and is not allowed
to change the exception level. Remove this call for the app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-27 16:51:47 -06:00
Simon Glass
dea4ea00a7 efi: Set the efi_media device name when binding
Binding a new efi_media device uses a placeholder name which is then
changed after the device is bound. But binding the device immediately
causes a child block device to be bound, which uses this placeholder
name as its base, rather than the eventual name of the efi_media device.

To fix, decide on the name earlier (based on the number of existing
devices), then pass that name to device_bind()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-27 16:51:47 -06:00
Simon Glass
88123cd086 Merge branch 'apa' into 'master'
Allow printing fdt nodes from outside the 'fdt' command

See merge request u-boot/u-boot!164
2025-08-27 22:11:12 +00:00
Simon Glass
a52a0036bc lib: Add fdt_print() to print a node
Extract the core device tree printing logic from fdt_print_path() into
a new fdt_print() function that takes a node offset parameter. This
allows printing from any node offset rather than requiring a path string.

Pass in the fdt, for more flexibility.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-27 12:46:48 -06:00
Simon Glass
c70aa53c2a lib: Rename fdt_print() to fdt_print_path()
Rename the function to better indicate that it prints from a specific path
in the device tree.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-developed-by: Claude <noreply@anthropic.com>
2025-08-27 12:44:42 -06:00
Simon Glass
dd6f8cfbcb lib: Split fdt_print() into separate library file
Move fdt_print() function from cmd/fdt.c to a new lib/fdt_print.c file
to make it available as a library function for other code to use.

Move and rename is_printable_string(), making it available as well.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-27 12:44:42 -06:00
Simon Glass
2b03d6f39c Merge branch 'clib2' into 'master'
Introduce a pager for the console

See merge request u-boot/u-boot!163
2025-08-27 16:02:50 +00:00
Simon Glass
10a0dec8bc pager: doc: Add mention of the pager feature
Add a note about the pager to the console documentation, with some more
information in the developer section. Also include the pager API.

Series-to: concept
Cover-letter:
Introduce a pager for the console
Some U-Boot commands can produce a lot of output and this can run off
top of the display. This series introduces a simple pager feature, to
allow the output to be read, before pressing SPACE to continue.

A fixed buffer size (4K) is used, which sets a limit on the permmited
output before paging fails and the output is simply written all in one
lot. In most cases this is plenty, but 'env print' does print the whole
environment as one string, so if the legacy distro-boot scripts are used
it could happen.

The default number of visible lines is set with a Kconfig option. Where
a video terminal is being used, the page size is set to match that. In
general U-Boot cannot guess the number of visible lines, since a serial
terminal may be in use.

There is also a 'pager' environment variable which can override any
detected value.

This initial series only counts newlines. It has no support for counting
characters so the result will be sub-optimal if very long lines are
written. This could be addressed in a future patch.

Some effort is made to handle common cases correctly. For example, if
stdout is changed to a serial or vidconsole device, that is used to
determine the page length. When redirecting sandbox to a file, no
attempt is made.

Future work may detect the terminal size by sending an ANSI sequence.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
Series-version: 2
2025-08-26 14:36:07 -06:00
Simon Glass
480be6d905 efi: Enable the console pager for the app
The app can produce quite a bit of output, so enable the pager feature.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
f3d27f9841 console: Add tests for calc_check_console_lines()
Add tests for checking:
- environment variable override with hex values
- invalid environment variable handling
- Kconfig-default behavior with device detection
- precedence rules (environment overrides device detection)
- serial terminal detection by manipulating sandbox state

Also expose calc_check_console_lines() in console.h for testing
and update pager functionality to use bypass mode when serial
is not connected to a terminal.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
4aefafb381 console: Recheck the page length when stdout device changes
It is annoying to have the pager use the line count from the display
when console output is actually using serial. Check this when stdio
changes and recaculate as needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
ca37f12368 console: Get the pager lines from the serial console
If there is a serial console, use that to set the number of lines for the
pager.

This is controlled by CONFIG_SERIAL_TERM_PRESENT

Enable SERIAL_TERM_PRESENT by default if the pager is being used, since
people generally have a serial console enabled.

Make the serial a lower priority than the vidconsole.

We don't want to use the pager when the output of sandbox is being
redirected. So in that case, put the pager in bypass mode.

Series-changes: 2
- Only use the vidconsole if we believe it is visible

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
2f6efe5832 console: Get the pager lines from the vidconsole
If there is a video console, use that to set the number of lines for the
pager.

For sandbox, only do this if the -l flag was provided, i.e. the emulated
LCD is visible.

Series-changes: 2
- Only use the vidconsole if we believe it is visible

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
4412d9c3cf bdinfo: Show the pager page_len value
Show the actual value being used by the pager, if enabled.

Series-changes: 2
- Add new patch to show the pager page_len value

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
731ee5ebfb console: Implement an environment var to control the pager
The 'pager' environment variable can be used to set the number of lines
on the display. Provide a callback for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
5d26e9dc1c console: Reset the pager when entering a new command
We don't want the pager appearing when entering commands, so add a way
to bypass it. Reset the line count to zero before executing the command.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
5c8817090b console: Add a few more paging tests
Provide a test that the prompt is displayed and another that paging
happens but does not appear in the recorded console-output.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
28311413de console: Support paging with single characters
A single character may result in a stall waiting for user input, which
means that it may request that a string be output. So when the pager is
active we never actually use the devices' putc() methods. Add a special
case so they don't go to wrack and ruin.

As before, the pager is only supported with CONFIG_CONSOLE_MUX enabled.

Series-changes: 2
- Drop unnecessary '!= NULL'

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
3b30dd23bd console: Support a bypass state
Allow the pager to be put in a bypass state, e.g. if not connected to
a terminal.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
cad364dd79 console: test: Allow tests to bypass the pager
We generally don't want the pager to be active when running tests,
since U-Boot appears to hang forever. Perhaps we could detect when the
tests are being run interactively and use the pager in that case. But
for now, just bypass it.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
d3d493c8a3 console: Plumb in the pager
Send all console output via the pager. If it is disabled, it will do
nothing.

The pager is only supported if CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are
enabled. This is the common case for more richly featured boards, i.e.
those that can cope with the extra code size of this feature.

Series-changes: 2
- Drop an unnecessary direct call to the pager
- Repeat the old code in console_puts_pager() to avoid 16-byte growth

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
149fe34151 test/py: Disable terminal detection with sandbox tests
Detecting the terminal size results in unwanted output in tests. Use the
-A option to disable this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
c0f36f2d00 sandbox: Add -A option to assume no terminal present
Add a new -A sandbox command-line option that sets a flag to assume no
terminal is present. This causes serial_query_size() to return -ENOENT
immediately, similar to when CONFIG_SERIAL_TERM_PRESENT is disabled.

This option is useful for testing pager behavior in non-interactive
environments without needing to modify configuration options.

Co-developed-by: Claude <noreply@anthropic.com>
2025-08-26 14:36:07 -06:00
Simon Glass
03fde8e2bf test/py: Disable the pager when running sandbox tests
The pager gets in the way of most tests, since it kicks in (by default)
when a command results in more than 25 lines of output. Use the -P flag
to bypass it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00