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
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>
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")
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>
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>
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>
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>
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>
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>
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>
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>
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>
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...")
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>