4059 Commits

Author SHA1 Message Date
Simon Glass
92aad5b59e efi: Move EFI_BINARY_EXEC to lib/efi
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>
2025-08-08 16:59:11 -06:00
Simon Glass
28b512bad3 efi_client: Support running an app
Add support for running another app from with the EFI app. This can be
used to boot an OS, for example.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:11 -06:00
Simon Glass
75bf1ee3c5 efi_client: Allow access to the parent image
This value is useful when running a binary, so provide a function to
obtain it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:11 -06:00
Simon Glass
3d81bf9ac0 efi_loader: Split out efi_binary_run_dp() et all
efi_binary_run_dp() calls efi_init_obj_list() which is specific to the
EFI loader. Move this into a new file within lib/efi_loader

Similarly, move efi_run_image() since the app will need a different
implementation.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:10 -06:00
Simon Glass
73ad2d9909 efi: Move efi_bootflow_run() to a common file
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>
2025-08-08 16:59:10 -06:00
Simon Glass
a48a8929de efi: Move most of efi_device_path into lib/efi
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>
2025-08-08 16:59:10 -06:00
Simon Glass
ffde1a3922 efi: Use variables in dp_size()
This function calculates the parent size in many places and does the
same addition in most cases. Create a variable for the parent_size and
another for the size, so we can do the addition once at the end.

The uclass array is too sparse to consider an array.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:56:46 -06:00
Simon Glass
ca57421d07 efi_client: Provide generic malloc() and free() functions
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>
2025-08-08 16:53:16 -06:00
Simon Glass
61844e4076 efi: Drop information about removing C flags
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>
2025-07-23 20:19:42 -06:00
Simon Glass
6da757f538 bootm: Move bootm_disable_interrupts() to bootm_final()
Move disabling of interrupts to bootm_final() so it is done for bootm
and EFI boot paths. Drop the now-duplicate calls.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 16:22:33 -06:00
Simon Glass
ec4efd7f0f bootm: Move board_quiesce_devices(void) to bootm_final()
This function is called just before boot, so move it from EFI into the
common bootm_final() function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 16:18:52 -06:00
Simon Glass
490dbf1968 bootm: Call cleanup_before_linux() from bootm_final()
Add this call to the bootm_final() function, dropping it from RISC-V

Add a flag to ensure that cleanup_before_linux() is not called when
booting an EFI app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 16:18:52 -06:00
Simon Glass
898b951842 efi: Drop EFI_GRUB_ARM32_WORKAROUND
This work-around dates from 2019 and grub 2.04 which is quite old. New
builds of grub don't have the problem and old boards presumably use an
older U-Boot, so don't need this.

Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 16:16:50 -06:00
Simon Glass
a1ae8de12c riscv: Call bootm_final()
Make use of this function, adding some pieces needed by RISC-V

Drop the udc_disconnect() from EFI_LOADER since it is now done in
bootm_final()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 16:14:47 -06:00
Simon Glass
148240871e efi: Make use of bootm_final()
Call this function from the EFI code. Add the required call to
dm_remove_devices_active() there.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 15:59:38 +02:00
Simon Glass
3be860fe74 acpi: Support a boot logo (BGRT)
Add support for creating a BGRT so that Linux will show a logo on
startup and shutdown.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:11 +02:00
Simon Glass
a4a1a69412 acpi: Provide a way to build in a boot logo
EFI has a Boot Graphics Record Table which can be used to show a logo
when booting up and shutting down.

Add support for adding this to the image, using a U-Boot logo which
includes the name, since many people will be unfamiliar with the logo.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:11 +02:00
Simon Glass
3354f95e7e acpi: Provide a way to locate the end of the ACPI tables
For QEMU we want to add new tables to the end of what QEMU provides. Add
a function to find the correct place for a new table.

Add a function to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:11 +02:00
Simon Glass
34203312d0 acpi: Allow finding the RSDT or XSDT
At present acpi_find_table() support locating most of the tables, but
not these two, since they are the pointers to the rest.

When adding new tables, these tables need to be located and updated, so
update acpi_find_table() to allow searching for them.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:11 +02:00
Simon Glass
e593cc86be acpi: Move code table-writing code to lib/acpi/acpi.c
The acpi_table.c file includes ACPI_WRITER() declarations and is only
included in the build if CONFIG_ACPIGEN is enabled.

For QEMU we want to augment the tables provided via qfw, but
CONFIG_ACPIGEN is not enabled.

Move the core functions out to the acpi.c file which is included in all
x86 builds. This allows the QEMU build to make use of these functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:11 +02:00
Simon Glass
2d72a90152 acpi: Pull out setup code from acpi_find_table()
The start of this function determines whether xdst or rdsp is used for
locating tables. Move it into a separate function so that we can use
this logic elsewhere.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:11 +02:00
Simon Glass
9d4aa656de acpi: Update acpi_find_table() to verify checksums
The RSP is not valid unless the checksums are corrrect, so add a test
for this.

Add a few blank lines for readability while here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:11 +02:00
Simon Glass
d0b607221f acpi: Move calculation of RSDP checksum into a function
Create a function for this checksumming, since it is not trivial. This
will allow the code to be shared with tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:11 +02:00
Simon Glass
37e7aec2d2 efi_loader: Use the first random-number-generator device
There is no guarantee that the RNG device has a sequence number of zero.
Use the first available device instead, by default.

This resolved a failure to find the device with qemu-x86_64 when the
virtio device is used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:10 +02:00
Simon Glass
8ed299f3be display_options: Support printing a 32-bit value
On 64-bit machines we don't always want to show 16 hex digits,
particularly if the value is 32-bit. Add a new function to show a 32-bit
value.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:26:02 +02:00
Simon Glass
0f640f96c8 Make the bdinfo printing-functions more generic
The bdinfo command makes use of quite a few functions which show a label
followed by a value, on a single line.

This sort of thing is generally useful outside of bdinfo, so move it to
a generic place. Use 'l' (for label) as the prefix.

The margin is still hard-coded to 12, which seems a reasonable limit for
a label.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:26:02 +02:00
Simon Glass
537e97237e x86: Rename QEMU to ARCH_QEMU_X86
CONFIG_QEMU is too generic for an x86-specific option. Rename it to
ARCH_QEMU_X86

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-05 05:48:28 -06:00
Simon Glass
50d0aeeeff emulation: efi_loader: Set MACH_QEMU with ARCH_QEMU_ARM
Define MACH_QEMU whenever ARCH_QEMU_ARM is used.

Some of the uses of ARCH_QEMU_ARM with efi_loader should clearly apply
to all QEMU variables, so update these.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-05 05:48:28 -06:00
Simon Glass
ab3b9d1d88 emulation: Rename ARCH_QEMU to ARCH_QEMU_ARM
This option looks generic but in fact is specific to ARM. Rename it to
reflect this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-05 05:48:28 -06:00
Simon Glass
5209eaf9e5 efi: Switch x86 and ARM to use the unified stub
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
2025-06-30 14:28:08 -06:00
Simon Glass
c3c7d368a0 efi: Move ARM over to use the common efi_main() function
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>
2025-06-30 14:28:08 -06:00
Simon Glass
cf92622d07 efi: Move x86 over to use the common efi_main() function
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>
2025-06-30 14:28:08 -06:00
Simon Glass
c0c2b1237e efi: Create a common efi_main() implementation for the stub
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>
2025-06-30 14:27:53 -06:00
Simon Glass
4df2a3f4a1 efi: Unify the names for use_uart and ebs_called
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>
2025-06-30 14:26:34 -06:00
Simon Glass
baee46f95b efi: Move more common stub code into the common file
Pull in several functions which are identical in the ARM and x86 files.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-30 14:26:34 -06:00
Simon Glass
d43aab19fb efi: Create a common file for the stub
There is some duplicated code across x86 and ARM even though they have
slightly different implementations.

They both call efi_stub_exit_boot_services() and this function does not
relate to the app, so belongs better outside the general-purpose efi.c
file.

Create a new efi_stub C file containing this function. Leave out the
efi_ prefix since this is obvious from the directory name.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-30 14:26:34 -06:00
Simon Glass
0b00c34e7c efi: Drop the efi_ prefix on the arch-specific stub files
These are already in the lib/efi/ directory so the extra efi_ prefix is
redundant and makes files harder to find. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-30 14:26:34 -06:00
Simon Glass
cf4fc6dd9a efi: Rename efi_stub.o Makefile variable
This variable is a bit confusing as it looks like a filename. Use
stub_obj instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-30 14:26:34 -06:00
Simon Glass
d50a7577e1 efi: x86: Show app banner on startup
Print a line that indicates if this is the app, to match the line shown
for the payload, i.e.:

   Model: EFI x86 Application

or:

   Model: EFI x86 Payload

or:

   Model: EFI ARM Application

Drop CONFIG_DISPLAY_BOARDINFO_LATE as it is not needed.

Note that there is no (generic) stub for ARM.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-30 14:26:16 -06:00
Simon Glass
8630e568b2 fs: Rename fs_read() to fs_legacy_read()
This existing function does not have any context associated with it.
Rename it so that fs_read() can be used for the new FS uclass.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 12:30:56 -06:00
Simon Glass
8a698cf850 fs: Rename fs.h to fs_legacy.h
A new filesystem interface is coming, so rename the current header to
indicate that it is the old one.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 07:53:25 -06:00
Simon Glass
b1936206e2 alist: Allow inclusion from OS headers
Sandbox needs to include system headers in some files, but also wants
to use alist. Adjust the headers to permit this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-27 07:50:11 -06:00
Simon Glass
7452a49d13 mbed: Remove check_files.py
This script has conflict markers in it so comes up as an unwanted match
when searching them. Remove the file since it is not used in U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-27 05:48:01 -06:00
Simon Glass
8fd296aae9 abuf: Add a way to set up an abuf with a given address
In some cases it is convenient to provide an address when initing an
abuf, instead of a pointer. Add a function for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
207bf34de7 boot: efi: Use an event to relocate the OS
Rather than a weak function, use the recently added event to adjust the
OS load-address. Tidy up the code a little while here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-05 14:42:47 -06:00
Simon Glass
dce9be4dda tpm: Export the function to set up the TPM log
In some cases, we may wish to set up the TPM log under full control of
a driver in U-Boot. Export the required function to make this possible.

This avoids calling the weak function tcg2_platform_get_log() when the
caller already knows where the log is.

Series-to: u-boot
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:458273
2025-06-04 15:07:08 -06:00
Jerome Forissier
c97dcfb24d initcall: remove initcall_run_list()
Now that all initcalls have been converted to static calls, remove
initcall_run_list().

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-06-02 12:54:50 -06:00
Simon Glass
2762f777b8 x86: efi: Add a few dummy functions
Although GD_FLG_SKIP_RELOC is enabled for the app, the code for
relocation is still present in the image. Add a few dummy functions
needed on x86.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-02 08:25:41 -06:00
Simon Glass
21ae2207d5 efi: Provide an easy way to debug with gdb
Add a Kconfig option to easily enable debugging of the app using the
recommended method. Provide some docs too.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-02 08:25:41 -06:00
Simon Glass
0af4a0a5ad efi: Allow disabling the TPM in the app
When the TPM is disabled, avoid trying to use it in the app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-02 08:25:41 -06:00