diff options
Diffstat (limited to 'src/drivers')
-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); + } +} |