Matt DeVillier has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/49050 )
Change subject: drivers/vpd: Add support to read device serial from VPD ......................................................................
drivers/vpd: Add support to read device serial from VPD
Add functions to read the system and mainboard serial numbers from VPD tables stored in flash.
Test: build/boot google/akemi with RO_VPD region persisted from stock Google firmware, verify system/mainboard serial numbers present via dmidecode.
Change-Id: I14ae07cd8b764e1e22d58577c7cc697ca1496bd5 Signed-off-by: Matt DeVillier matt.devillier@gmail.com --- M src/drivers/vpd/Kconfig M src/drivers/vpd/vpd.c 2 files changed, 28 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/50/49050/1
diff --git a/src/drivers/vpd/Kconfig b/src/drivers/vpd/Kconfig index 0b16058..6bfbf4f 100644 --- a/src/drivers/vpd/Kconfig +++ b/src/drivers/vpd/Kconfig @@ -19,3 +19,8 @@ default 0x4000 help Size in bytes of the FMAP region created to store VPD tables. + +config SMBIOS_SERIAL_FROM_VPD + bool "Load device serial from VPD" + depends on VPD && GENERATE_SMBIOS_TABLES + default y diff --git a/src/drivers/vpd/vpd.c b/src/drivers/vpd/vpd.c index d3ff370..14dad8a 100644 --- a/src/drivers/vpd/vpd.c +++ b/src/drivers/vpd/vpd.c @@ -6,6 +6,7 @@ #include <ctype.h> #include <fmap.h> #include <program_loading.h> +#include <smbios.h> #include <string.h> #include <timestamp.h> #include <types.h> @@ -297,4 +298,26 @@ return true; }
+#if CONFIG(SMBIOS_SERIAL_FROM_VPD) +#define VPD_KEY_SYSTEM_SERIAL "serial_number" +#define VPD_KEY_MAINBOARD_SERIAL "mlb_serial_number" +#define VPD_SERIAL_LEN 64 + +const char *smbios_system_serial_number(void) +{ + static char serial[VPD_SERIAL_LEN]; + if (vpd_gets(VPD_KEY_SYSTEM_SERIAL, serial, VPD_SERIAL_LEN, VPD_RO)) + return serial; + return ""; +} + +const char *smbios_mainboard_serial_number(void) +{ + static char serial[VPD_SERIAL_LEN]; + if (vpd_gets(VPD_KEY_MAINBOARD_SERIAL, serial, VPD_SERIAL_LEN, VPD_RO)) + return serial; + return ""; +} +#endif + ROMSTAGE_CBMEM_INIT_HOOK(cbmem_add_cros_vpd)