When running as an EFI app we should set the ulib flag early so as to
avoid printing unwanted output on start. Add a parameter to
efi_startup() to control whether ulib is used.
Drop the starting message in this case.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a 'verbose' argument to efi_init() so that the init messages can be
suppressed if desired.
For now, keep them as they are.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a 'verbose' argument to setup_memory() so that the memory messages
can be suppressed if desired.
For now, keep them as they are.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Use the EVT_RESERVE_BOARD event handler to allocate the efi_priv struct
in the normal memory area. This avoids the caller needing to keep it on
the stack.
Copy the struct to the new place and start using it there.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
In some cases this function may be provided outside the library, e.g. by
a Rust main program. Add a Kconfig to control this and refactor the code
so that it is optional.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
When the app is running under QEMU we may wish to do some things
differently. Add a flag for this and use the SMBIOS tables to detect it.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Check for both GUIDs when looking for the SMBIOS tables. This allows
both table versions to be detected when running from OVMF.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
It is common for the main program to be at the bottom, but with recent
changes it has crept up a bit. Move it back to the bottom.
Signed-off-by: Simon Glass <sjg@chromium.org>
Add support for reset -c flag to explicitly request cold reset.
This provides symmetry with -w (warm) and -u (firmware UI) flags.
For EFI apps, this performs EFI_RESET_COLD which does a full system
reboot without going to firmware setup interface.
Series-to: concept
Series-cc: heinrich
Cover-letter:
efi: Improve integration of the app with a Shim environment
This series collects together various small fixes and improvements which
make it easier to use the U-Boot EFI app in a bootflow which includes
Shim:
- 'Reset' back to the caller (e.g. EDK2)
- Machine reset using cold and warm reset
- Reset and enter the firmware UI
- Shim command now supports persistent debug
- Bootmenu shows the real media for each bootflow rather than just 'efi'
END
Signed-off-by: Simon Glass <sjg@chromium.org>
Add new SYSRESET_TO_FIRMWARE_UI reset type to allow resetting directly
to firmware UI. This is implemented via the reset command's new -u flag.
For the EFI app, this sets the EFI_OS_INDICATIONS_BOOT_TO_FW_UI bit in
the OsIndications variable before performing a warm reset, causing the
firmware to boot to its setup interface.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
At present reset just exits the U-Boot app and returns to the caller.
Add support for proper warm and cold resets, with 'hot' reset preserving
the current behaviour.
Signed-off-by: Simon Glass <sjg@chromium.org>
It is handy to have the pager in the app, since some output can be quite
long. Enable the console mux since the pager feature depends on it.
Signed-off-by: Simon Glass <sjg@chromium.org>
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
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>
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>
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>
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>
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>
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>
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>
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>
Use simplefb on ARM devices so that we see a console earlier, assuming
that 'console=tty0' is passed to Linux.
Signed-off-by: Simon Glass <sjg@chromium.org>
This is quite a long dump and is only useful when debugging. Show it
only if LOG_DEBUG is defined in this file.
Signed-off-by: Simon Glass <sjg@chromium.org>
The new global_data is set up by the app but it never uses it. Switch to
the new value after board_init_f(), so that the output of the 'meminfo'
command is more contiguous.
Signed-off-by: Simon Glass <sjg@chromium.org>
Printing may make use of tables which could go away when freed, so do
the free as the last thing before exiting the app.
Signed-off-by: Simon Glass <sjg@chromium.org>
If an SMBIOS table is available, pick it up so that it can be parsed, or
examined with the 'smbios' command.
Signed-off-by: Simon Glass <sjg@chromium.org>
Rather than immediately falling back to the pool allocator when we
cannot get enough memory below 4GB, try the page allocator first. This
provides 4K-aligned memory, which is nicer to look at when debugging.
Signed-off-by: Simon Glass <sjg@chromium.org>
A few comments are out of date. Drop the one about global_data_ptr and
reword the one about memory above 4GB.
Signed-off-by: Simon Glass <sjg@chromium.org>
The EFI app shows a list of every disk and partition it can find. On
Qualcomm x1e laptops this can fill the screen. The information is not
that useful, so just show a summary.
Signed-off-by: Simon Glass <sjg@chromium.org>
Before booting using extlinux we must add the memory map to the FDT.
Provide a ft_system_setup() function to handle this.
To determine the memory size, scan the memory map looking for entries
that look like real memory.
Signed-off-by: Simon Glass <sjg@chromium.org>
The conversion to using an event was not done correctly, with the
result that it has no effect. Fix it, by passing in the length and
actually using the returned address.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 207bf34de7 ("boot: efi: Use an event to relocate the OS")
When the app is booting a kernel without using EFI, it must first exit
the boot services provided by EFI. Add a hook for this, using
bootm_final()
Signed-off-by: Simon Glass <sjg@chromium.org>
This function is not called from the app at present. Even if it were, it
would be called later, after stdio is working, so there is no need to
use printhex2() and the like.
Move the function into the stub.
Signed-off-by: Simon Glass <sjg@chromium.org>
The device-path code requires memory allocation. Provide an
implementation of these for use by the client.
Note that this will not work for the stub, since in that case it needs
to use U-Boot's memory allocation. This was a subject of a long argument
on the mailing list about U-Boot using its own malloc() where possible,
so it seems best to just leave this broken.
Signed-off-by: Simon Glass <sjg@chromium.org>
A 'removing flags -mregparm=3' message appears when building sometimes.
It isn't very useful and does not indicate a problem, so remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Now that the stub code is unified, switch over to it, dropping the
individual efi_main() functions.
Series-to: concept
Cover-letter:
efi: Unify the scripts and start-up code
We have two scripts which run QEMU, one for EFI and one for bare metal.
They have similar options so it seems reasonable to try to unify them a
bit. This series creates a common file and adjusts arguments so they are
consistent across both scripts.
The EFI app for ARM and x86 have different start-up code but in fact
the code is quiet similar. This series creates a new common main
program, called efi_main_common() which is used for both architectures.
The small number of differences are handled in arch-specific code.
END
Fill in the required helper functions and call efi_main_common() to
do everything else.
Delete the old efi_main() function.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fill in the required helper functions and call efi_main_common() to
do everything else.
Delete the old efi_main() function.
Signed-off-by: Simon Glass <sjg@chromium.org>
At present x86 and ARM have different implementations, but they are
similar enough that it is not too hard to unify them.
Create a new common function, with arch-specific pieces at the start
(setting up the address to which to copy U-Boot) and end (to jump to
U-Boot).
For now, nothing uses this code.
Signed-off-by: Simon Glass <sjg@chromium.org>
The x86 and ARM implementations use a different variable for the same
thing, just inverted.
Invent a third name for this, adjust both files to use it and store it
in the common stub.c file.
Signed-off-by: Simon Glass <sjg@chromium.org>