From a3bd8e96185b064cce6bbe2aa9b6e81b59efa486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=BBygowski?= Date: Tue, 24 May 2022 13:26:55 +0200 Subject: drivers/generic/cbfs-uuid: Add driver to include UUID from CBFS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When system_uuid CBFS file is present and contains the UUID in a string format, the driver will parse it and convert to binary format to populate the SMBIOS type 1 UUID field. TEST=Add UUID file and boot MSI PRO Z690-A DDR4 WIFI and check with dmidecode if the UUID is populated correctly. Signed-off-by: Michał Żygowski Change-Id: I22f22f4e8742716283d2fcaba4894c06cef3a4bf Reviewed-on: https://review.coreboot.org/c/coreboot/+/64639 Reviewed-by: Krystian Hebel Tested-by: build bot (Jenkins) --- src/drivers/generic/cbfs-uuid/Kconfig | 6 ++++++ src/drivers/generic/cbfs-uuid/Makefile.inc | 1 + src/drivers/generic/cbfs-uuid/cbfs-uuid.c | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 src/drivers/generic/cbfs-uuid/Kconfig create mode 100644 src/drivers/generic/cbfs-uuid/Makefile.inc create mode 100644 src/drivers/generic/cbfs-uuid/cbfs-uuid.c (limited to 'src/drivers/generic') diff --git a/src/drivers/generic/cbfs-uuid/Kconfig b/src/drivers/generic/cbfs-uuid/Kconfig new file mode 100644 index 0000000000..136c6011b3 --- /dev/null +++ b/src/drivers/generic/cbfs-uuid/Kconfig @@ -0,0 +1,6 @@ +config DRIVERS_GENERIC_CBFS_UUID + bool "System UUID in CBFS" + default n + help + Enable this option to read the SMBIOS system UUID from a + text file located in CBFS. diff --git a/src/drivers/generic/cbfs-uuid/Makefile.inc b/src/drivers/generic/cbfs-uuid/Makefile.inc new file mode 100644 index 0000000000..b1344076dd --- /dev/null +++ b/src/drivers/generic/cbfs-uuid/Makefile.inc @@ -0,0 +1 @@ +ramstage-$(CONFIG_DRIVERS_GENERIC_CBFS_UUID) += cbfs-uuid.c diff --git a/src/drivers/generic/cbfs-uuid/cbfs-uuid.c b/src/drivers/generic/cbfs-uuid/cbfs-uuid.c new file mode 100644 index 0000000000..e657bdd922 --- /dev/null +++ b/src/drivers/generic/cbfs-uuid/cbfs-uuid.c @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include +#include + +void smbios_system_set_uuid(u8 *uuid) +{ + /* Add 3 more bytes: 2 for possible CRLF and third for NULL char */ + char uuid_str[UUID_STRLEN + 3] = {0}; + uint8_t system_uuid[UUID_LEN]; + + size_t uuid_len = cbfs_load("system_uuid", uuid_str, UUID_STRLEN); + + if (uuid_len >= UUID_STRLEN && uuid_len <= UUID_STRLEN + 3) { + /* Cut off any trailing whitespace like CR or LF */ + uuid_str[UUID_STRLEN] = '\0'; + if (!parse_uuid(system_uuid, uuid_str)) + memcpy(uuid, system_uuid, UUID_LEN); + } +} -- cgit v1.2.3