diff options
author | Michał Żygowski <michal.zygowski@3mdeb.com> | 2022-05-24 13:26:55 +0200 |
---|---|---|
committer | Michał Żygowski <michal.zygowski@3mdeb.com> | 2022-10-11 08:36:06 +0000 |
commit | a3bd8e96185b064cce6bbe2aa9b6e81b59efa486 (patch) | |
tree | 820b618d5518aacd42f67ae2ff1c0110a7af9076 /src/drivers/generic | |
parent | 0c14c0c585108b03d1d1d5d520c7fde94637c4bb (diff) |
drivers/generic/cbfs-uuid: Add driver to include UUID from CBFS
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 <michal.zygowski@3mdeb.com>
Change-Id: I22f22f4e8742716283d2fcaba4894c06cef3a4bf
Reviewed-on: https://review.coreboot.org/c/coreboot/+/64639
Reviewed-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/drivers/generic')
-rw-r--r-- | src/drivers/generic/cbfs-uuid/Kconfig | 6 | ||||
-rw-r--r-- | src/drivers/generic/cbfs-uuid/Makefile.inc | 1 | ||||
-rw-r--r-- | src/drivers/generic/cbfs-uuid/cbfs-uuid.c | 23 |
3 files changed, 30 insertions, 0 deletions
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 <cbfs.h> +#include <device/device.h> +#include <smbios.h> +#include <string.h> +#include <uuid.h> + +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); + } +} |