From 8bdb006db54dfecb1cbf132dbe627aad46a4e656 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Sun, 31 May 2020 12:31:15 -0500 Subject: drivers/vpd: Add support to read device serial from VPD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add functions to read the system and mainboard serial numbers from VPD tables stored in flash. Remove board-specific implementations for google/drallion and google/sarien and select the new Kconfig instead. 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/49050 Reviewed-by: Angel Pons Reviewed-by: Michael Niewöhner Tested-by: build bot (Jenkins) --- src/drivers/vpd/Kconfig | 5 +++++ src/drivers/vpd/Makefile.inc | 1 + src/drivers/vpd/vpd_serial.c | 26 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 src/drivers/vpd/vpd_serial.c (limited to 'src/drivers') diff --git a/src/drivers/vpd/Kconfig b/src/drivers/vpd/Kconfig index 0b16058006..7d45eb6a85 100644 --- a/src/drivers/vpd/Kconfig +++ b/src/drivers/vpd/Kconfig @@ -19,3 +19,8 @@ config VPD_FMAP_SIZE 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 n diff --git a/src/drivers/vpd/Makefile.inc b/src/drivers/vpd/Makefile.inc index f54c4d0dd9..615e48a18e 100644 --- a/src/drivers/vpd/Makefile.inc +++ b/src/drivers/vpd/Makefile.inc @@ -5,3 +5,4 @@ verstage-$(CONFIG_VPD) += vpd_decode.c vpd.c romstage-$(CONFIG_VPD) += vpd_decode.c vpd.c postcar-$(CONFIG_VPD) += vpd_decode.c vpd.c ramstage-$(CONFIG_VPD) += vpd_decode.c vpd.c +ramstage-$(CONFIG_SMBIOS_SERIAL_FROM_VPD) += vpd_serial.c diff --git a/src/drivers/vpd/vpd_serial.c b/src/drivers/vpd/vpd_serial.c new file mode 100644 index 0000000000..528dcbb368 --- /dev/null +++ b/src/drivers/vpd/vpd_serial.c @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#include + +#include "vpd.h" +#include "vpd_tables.h" + +#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 ""; +} -- cgit v1.2.3