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>
This commit is contained in:
parent
0c14c0c585
commit
a3bd8e9618
5 changed files with 96 additions and 0 deletions
6
src/drivers/generic/cbfs-uuid/Kconfig
Normal file
6
src/drivers/generic/cbfs-uuid/Kconfig
Normal file
|
|
@ -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.
|
||||
1
src/drivers/generic/cbfs-uuid/Makefile.inc
Normal file
1
src/drivers/generic/cbfs-uuid/Makefile.inc
Normal file
|
|
@ -0,0 +1 @@
|
|||
ramstage-$(CONFIG_DRIVERS_GENERIC_CBFS_UUID) += cbfs-uuid.c
|
||||
23
src/drivers/generic/cbfs-uuid/cbfs-uuid.c
Normal file
23
src/drivers/generic/cbfs-uuid/cbfs-uuid.c
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue