Name of user not set #1002789 has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/44005 )
Change subject: drivers/generic/cbfs-serial: Update driver to read UUID from CBFS ......................................................................
drivers/generic/cbfs-serial: Update driver to read UUID from CBFS
Modify the existing cbfs-serial driver to also read the UUID from a text file in CBFS, just as a serial number is done today. When driver is selected and a system_uuid exists in the CBFS the UUID is read from the file and populated in the SMBIOS table. Note that in order to work there must be no newline character at the end of the file, this is also true of the serial_number.
Tested on a Google Tricky (Dell 3010 Chromebox).
Change-Id: I140a61670cec1318c095e18815c6bc7c1bf78cd6 Signed-off-by: Chris Morgan macromorgan@hotmail.com --- M src/drivers/generic/cbfs-serial/Kconfig M src/drivers/generic/cbfs-serial/cbfs-serial.c 2 files changed, 34 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/05/44005/1
diff --git a/src/drivers/generic/cbfs-serial/Kconfig b/src/drivers/generic/cbfs-serial/Kconfig index 209c242..d0cce14 100644 --- a/src/drivers/generic/cbfs-serial/Kconfig +++ b/src/drivers/generic/cbfs-serial/Kconfig @@ -2,5 +2,8 @@ bool "Serial number in CBFS" default n help - Enable this option to read the board serial number from a - text file located in CBFS. + Enable this option to read the board serial number or + system UUID from a text file located in CBFS. The text + file should be named serial_number or system_uuid + respectively and include only the serial number or + UUID (with dashes) with no newline characters. diff --git a/src/drivers/generic/cbfs-serial/cbfs-serial.c b/src/drivers/generic/cbfs-serial/cbfs-serial.c index 2e3e37d..6ee3c26 100644 --- a/src/drivers/generic/cbfs-serial/cbfs-serial.c +++ b/src/drivers/generic/cbfs-serial/cbfs-serial.c @@ -4,9 +4,10 @@ #include <device/device.h> #include <smbios.h> #include <string.h> - +#include <uuid.h>
#define MAX_SERIAL_LENGTH 0x100 +#define UUID_LENGTH 0x128
const char *smbios_mainboard_serial_number(void) { @@ -37,3 +38,30 @@
return serial_number; } + +void smbios_system_set_uuid(u8 *uuid) +{ + static char system_uuid[UUID_LENGTH + 1] = {0}; + struct cbfsf file; + + if (system_uuid[0] != 0) + parse_uuid(uuid, system_uuid); + + if (cbfs_boot_locate(&file, "system_uuid", NULL) == 0) { + struct region_device cbfs_region; + size_t uuid_len; + + cbfs_file_data(&cbfs_region, &file); + + uuid_len = region_device_sz(&cbfs_region); + if (uuid_len <= UUID_LENGTH) { + if (rdev_readat(&cbfs_region, system_uuid, 0, + uuid_len) == uuid_len) { + system_uuid[uuid_len] = 0; + parse_uuid(uuid, system_uuid); + } + } + } + + parse_uuid(uuid, system_uuid); +}