
The debug version of the UEFI shell on x86 requires a HOB list. This implementation allows to generate an empty HOB list.
Generate the HOB list on the sandbox and on x86 by default.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- include/efi_hob.h | 32 ++++++++++++++++++++++++++++++++ include/efi_loader.h | 9 +++++++++ lib/efi_loader/Kconfig | 8 ++++++++ lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_hob.c | 33 +++++++++++++++++++++++++++++++++ lib/efi_loader/efi_setup.c | 7 +++++++ 6 files changed, 90 insertions(+) create mode 100644 include/efi_hob.h create mode 100644 lib/efi_loader/efi_hob.c
diff --git a/include/efi_hob.h b/include/efi_hob.h new file mode 100644 index 00000000000..b401e6c2fa1 --- /dev/null +++ b/include/efi_hob.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * HOB list + * + * Copyright (c) 2025 Heinrich Schuchardt + */ + +#ifndef _EFI_HOB_H +#define _EFI_HOB_H 1 + +#include <efi.h> + +/** + * define EFI_HOB_TYPE_END_OF_HOB_LIST - end of hob list + */ +#define EFI_HOB_TYPE_END_OF_HOB_LIST 0xFFFF + +/** + * struct efi_hob_header - EFI_HOB_GENERIC_HEADER + */ +struct efi_hob_header { + /** @hob_type: type of HOB data structure */ + u16 hob_type; + /** @hob_length: HOB length including header in bytes */ + u16 hob_length; + /** @reserved: always 0 */ + u32 reserved; +}; + +extern const efi_guid_t efi_guid_hob_list; + +#endif /* _EFI_HOB_H */ diff --git a/include/efi_loader.h b/include/efi_loader.h index 9afbec35ebf..c1258098217 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -654,6 +654,15 @@ efi_status_t efi_acpi_register(void); */ efi_status_t efi_smbios_register(void);
+/** + * efi_hob_list_register() - install HOB list + * + * The EFI shell on X86 requires a HOB list + * + * Return: status code + */ +efi_status_t efi_hob_list_register(void); + struct efi_simple_file_system_protocol * efi_fs_from_path(struct efi_device_path *fp);
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index c46ffe3a9d8..ec38a0ea352 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -395,6 +395,14 @@ config EFI_LOADER_HII U-Boot implements enough of its features to be able to run the UEFI Shell, but not more than that.
+config EFI_HOB + bool 'HOB list' + default y if SANDBOX || X86 + help + Install a HOB list. The UEFI shell on x86 requires a HOB list + to be present. Our list is empty as we don't implement the + UEFI Platform Initialization Specification. + config EFI_UNICODE_COLLATION_PROTOCOL2 bool "Unicode collation protocol" default y diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 2a0b4172bd7..7d1f04e9fbd 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -37,6 +37,7 @@ obj-y += efi_dt_fixup.o obj-y += efi_fdt.o obj-y += efi_file.o obj-$(CONFIG_EFI_LOADER_HII) += efi_hii.o +obj-$(CONFIG_EFI_HOB) += efi_hob.o obj-y += efi_image_loader.o obj-y += efi_load_options.o obj-y += efi_memory.o diff --git a/lib/efi_loader/efi_hob.c b/lib/efi_loader/efi_hob.c new file mode 100644 index 00000000000..6a1365bd817 --- /dev/null +++ b/lib/efi_loader/efi_hob.c @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Provide HOB list + * + * Copyright (c) 2025 Heinrich Schuchardt + */ + +#include <efi_hob.h> +#include <efi_loader.h> + +const efi_guid_t efi_guid_hob_list = EFI_HOB_LIST; + +/** + * efi_hob_list_register() - install HOB list + * + * The EFI shell on X86 requires a HOB list + * + * Return: status code + */ +efi_status_t efi_hob_list_register(void) +{ + struct efi_hob_header *hob; + + hob = efi_alloc(sizeof(struct efi_hob_header)); + if (!hob) + return EFI_OUT_OF_RESOURCES; + + hob->hob_type = EFI_HOB_TYPE_END_OF_HOB_LIST; + hob->hob_length = sizeof(struct efi_hob_header); + hob->reserved = 0; + + return efi_install_configuration_table(&efi_guid_hob_list, hob); +} diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index aa59bc7779d..393b690c3ee 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -7,6 +7,7 @@
#define LOG_CATEGORY LOGC_EFI
+#include <efi_hob.h> #include <efi_loader.h> #include <efi_variable.h> #include <log.h> @@ -271,6 +272,12 @@ efi_status_t efi_init_obj_list(void) goto out; }
+ if (IS_ENABLED(CONFIG_EFI_HOB)) { + ret = efi_hob_list_register(); + if (ret != EFI_SUCCESS) + goto out; + } + if (IS_ENABLED(CONFIG_EFI_TCG2_PROTOCOL)) { ret = efi_tcg2_register(); if (ret != EFI_SUCCESS)