diff options
author | Sergii Dmytruk <sergii.dmytruk@3mdeb.com> | 2024-06-24 16:23:32 +0300 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2024-08-19 14:30:20 +0000 |
commit | 1a8b9c20f8de41a8f027ff54a614b8c1ac9bcff8 (patch) | |
tree | 1b05711f3b861d761ad48bb59bb023944ac94b68 /src/drivers | |
parent | 2355aa7d3ba490512483925b6362ec45064a8c0f (diff) |
drivers/efi: add optional ESRT-friendly coreboot table tag
EFI System Resource Table (ESRT) is an informational structure that
reports basic details about current system or device firmware. This is
chiefly used to perform firmware updates.
New CONFIG_DRIVERS_EFI_FW_INFO is off by default, enabling it adds
DRIVERS_EFI_FW_{GUID,VERSION,LSV} to be used to specify firmware
version/update information.
Existing forms of versions wouldn't be sufficient because there is no
universal way of converting string versions to 32-bit unsigned integers
and there are no GUIDs or lowest supported versions.
Change-Id: Ic1b768d7bed43edf7ca8e41552087734054de033
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83421
Reviewed-by: Christian Walter <christian.walter@9elements.com>
Reviewed-by: coreboot org <coreboot.org@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/drivers')
-rw-r--r-- | src/drivers/efi/Kconfig | 32 | ||||
-rw-r--r-- | src/drivers/efi/Makefile.mk | 2 | ||||
-rw-r--r-- | src/drivers/efi/info.c | 28 |
3 files changed, 62 insertions, 0 deletions
diff --git a/src/drivers/efi/Kconfig b/src/drivers/efi/Kconfig index ad27d68b39..399443bdaa 100644 --- a/src/drivers/efi/Kconfig +++ b/src/drivers/efi/Kconfig @@ -6,3 +6,35 @@ config DRIVERS_EFI_VARIABLE_STORE help Adds a driver that is able to read and write an EFI formatted VariableStore as used by tianocore. + +config DRIVERS_EFI_FW_INFO + bool "Expose firmware version in a EFI-friendly form" + depends on UDK_BASE + help + Adds firmware version information to coreboot table in a form similar to + EFI System Resource Table (ESRT) that can be used for firmware updates. + +config DRIVERS_EFI_MAIN_FW_GUID + string "GUID of the firmware" + default "00112233-4455-6677-8899-aabbccddeeff" + depends on DRIVERS_EFI_FW_INFO + help + GUID used to identify firmware kind for the purposes of updates. + +config DRIVERS_EFI_MAIN_FW_VERSION + hex "Version of the firmware" + range 0x00000000 0xFFFFFFFF + default 0x00000000 + depends on DRIVERS_EFI_FW_INFO + help + 32-bit unsigned integer representing current firmware's version. + +config DRIVERS_EFI_MAIN_FW_LSV + hex "Lowest supported firmware version" + range 0x00000000 0xFFFFFFFF + default 0x00000000 + depends on DRIVERS_EFI_FW_INFO + help + 32-bit unsigned integer representing lowest firmware version number + that is allowed to replace the current one. Can be used to forbid + bugged versions. diff --git a/src/drivers/efi/Makefile.mk b/src/drivers/efi/Makefile.mk index 2597c09bff..47f0e82990 100644 --- a/src/drivers/efi/Makefile.mk +++ b/src/drivers/efi/Makefile.mk @@ -5,3 +5,5 @@ smm-$(CONFIG_DRIVERS_EFI_VARIABLE_STORE) += efivars.c all-$(CONFIG_USE_UEFI_VARIABLE_STORE) += option.c smm-$(CONFIG_USE_UEFI_VARIABLE_STORE) += option.c + +ramstage-$(CONFIG_DRIVERS_EFI_FW_INFO) += info.c diff --git a/src/drivers/efi/info.c b/src/drivers/efi/info.c new file mode 100644 index 0000000000..fc1cfea573 --- /dev/null +++ b/src/drivers/efi/info.c @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <boot/coreboot_tables.h> +#include <console/console.h> +#include <stdint.h> +#include <string.h> +#include <uuid.h> + +void lb_efi_fw_info(struct lb_header *header) +{ + uint8_t guid[16]; + struct lb_efi_fw_info *fw_info; + + if (parse_uuid(guid, CONFIG_DRIVERS_EFI_MAIN_FW_GUID)) { + printk(BIOS_ERR, "%s(): failed to parse firmware's GUID: '%s'\n", __func__, + CONFIG_DRIVERS_EFI_MAIN_FW_GUID); + return; + } + + fw_info = (struct lb_efi_fw_info *)lb_new_record(header); + fw_info->tag = LB_TAG_EFI_FW_INFO; + fw_info->size = sizeof(*fw_info); + + memcpy(fw_info->guid, guid, sizeof(guid)); + fw_info->version = CONFIG_DRIVERS_EFI_MAIN_FW_VERSION; + fw_info->lowest_supported_version = CONFIG_DRIVERS_EFI_MAIN_FW_LSV; + fw_info->fw_size = CONFIG_ROM_SIZE; +} |