This allows e.g. dmidecode in Linux to query the information that barebox has collected.
Signed-off-by: Ahmad Fatoum <[email protected]> --- common/Kconfig | 13 +++++++++++ efi/loader/Makefile | 1 + efi/loader/smbios.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 efi/loader/smbios.c diff --git a/common/Kconfig b/common/Kconfig index b61a5bc40a1f..d4d9d930a996 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -755,6 +755,19 @@ config MMCBLKDEV_ROOTARG [1] fa2d0aa96941 ("mmc: core: Allow setting slot index via device tree alias") +config GENERATE_SMBIOS_TABLE + bool "Generate an SMBIOS (System Management BIOS) table" + depends on EFI_LOADER && OF + select SMBIOS + default y + help + The System Management BIOS (SMBIOS) specification addresses how + motherboard and system vendors present management information about + their products in a standard format by extending the BIOS interface + on Intel architecture systems. + + Check http://www.dmtf.org/standards/smbios for details. + config BAREBOX_UPDATE bool "In-system barebox update infrastructure" diff --git a/efi/loader/Makefile b/efi/loader/Makefile index c06d1f7c8c35..7992a4f5caa0 100644 --- a/efi/loader/Makefile +++ b/efi/loader/Makefile @@ -15,6 +15,7 @@ obj-y += loadopts.o obj-$(CONFIG_BOOT) += bootesp.o obj-$(CONFIG_EFI_LOADER_BOOTMGR) += efibootmgr.o obj-$(CONFIG_BOOTM) += bootm.o +obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o obj-y += efi_var_common.o obj-y += efi_variable.o obj-y += efi_var_mem.o diff --git a/efi/loader/smbios.c b/efi/loader/smbios.c new file mode 100644 index 000000000000..81ba77c24017 --- /dev/null +++ b/efi/loader/smbios.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0+ +// SPDX-FileCopyrightText: 2016 Alexander Graf +// SPDX-Comment: Origin-URL: https://github.com/u-boot/u-boot/blob/1c5aab803c0b0f07be1d3b0029f4031463497acf/lib/efi_loader/efi_smbios.c + +#define pr_fmt(fmt) "efi-loader: smbios: " fmt + +#include <efi/loader.h> +#include <efi/guid.h> +#include <efi/error.h> +#include <efi/memory.h> +#include <efi/loader/table.h> +#include <linux/printk.h> +#include <malloc.h> +#include <smbios.h> +#include <init.h> +#include <linux/sizes.h> + +#define TABLE_SIZE SZ_4K + +/* + * Install the SMBIOS table as a configuration table. + * + * Return: status code + */ +static efi_status_t efi_smbios_register(void *data) +{ + efi_status_t ret; + u64 memory; + void *buf; + + /* Align the table to a 4KB boundary to keep EFI happy */ + ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, + EFI_RUNTIME_SERVICES_DATA, + efi_size_in_pages(TABLE_SIZE), + &memory, "smbios"); + if (ret != EFI_SUCCESS) + return ret; + + buf = efi_phys_to_virt(memory); + + if (!write_smbios_table(buf)) { + pr_err("Failed to write SMBIOS table\n"); + return -EINVAL; + } + + /* Install SMBIOS information as configuration table */ + return efi_install_configuration_table(&efi_smbios3_guid, buf); +} + +static int efi_smbios_init(void) +{ + efi_register_deferred_init(efi_smbios_register, NULL); + return 0; +} +postenvironment_initcall(efi_smbios_init); -- 2.47.3
