[coreboot-gerrit] Change in coreboot[master]: mainboard/google/kahlee: allow oem.bin file to update smbios

Martin Roth (Code Review) gerrit at coreboot.org
Mon Sep 17 22:49:05 CEST 2018


Martin Roth has uploaded this change for review. ( https://review.coreboot.org/28651


Change subject: mainboard/google/kahlee: allow oem.bin file to update smbios
......................................................................

mainboard/google/kahlee: allow oem.bin file to update smbios

Grunt variants need a way to customize the mainboard vendor based on the
platform.  For future boards, this can probably be done via CBI, but
grunt doesn't support that method.

BUG=b:79874904
TEST=Build, see updated mainboard vendor

Change-Id: I997dc39c7f36f70cf4320ef335831245889eb475
Signed-off-by: Martin Roth <martinroth at chromium.org>
---
M src/mainboard/google/kahlee/Kconfig
M src/mainboard/google/kahlee/variants/baseboard/Makefile.inc
M src/mainboard/google/kahlee/variants/baseboard/mainboard.c
3 files changed, 69 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/51/28651/1

diff --git a/src/mainboard/google/kahlee/Kconfig b/src/mainboard/google/kahlee/Kconfig
index 9180906..5ea904c 100644
--- a/src/mainboard/google/kahlee/Kconfig
+++ b/src/mainboard/google/kahlee/Kconfig
@@ -128,4 +128,15 @@
 	hex
 	default 0x50
 
+config USE_OEM_BIN
+	bool "Add an oem.bin file"
+	help
+	  Add an oem.bin file to identify the manufacturer in smbios, overriding the
+	  CONFIG_MAINBOARD_SMBIOS_MANUFACTURER value.
+
+config OEM_BIN_FILE
+	string "OEM ID table"
+	depends on USE_OEM_BIN
+	default ""
+
 endif # BOARD_GOOGLE_BASEBOARD_KAHLEE
diff --git a/src/mainboard/google/kahlee/variants/baseboard/Makefile.inc b/src/mainboard/google/kahlee/variants/baseboard/Makefile.inc
index 1f6d8ce..6ffbf53 100644
--- a/src/mainboard/google/kahlee/variants/baseboard/Makefile.inc
+++ b/src/mainboard/google/kahlee/variants/baseboard/Makefile.inc
@@ -25,3 +25,10 @@
 
 ramstage-y += gpio.c
 ramstage-y += tpm_tis.c
+
+# Add OEM ID table
+ifeq ($(CONFIG_USE_OEM_BIN),y)
+cbfs-files-y += oem.bin
+oem.bin-file := $(call strip_quotes,$(CONFIG_OEM_BIN_FILE))
+oem.bin-type := raw
+endif #($(CONFIG_USE_OEM_BIN),y)
diff --git a/src/mainboard/google/kahlee/variants/baseboard/mainboard.c b/src/mainboard/google/kahlee/variants/baseboard/mainboard.c
index 3edcd65..657fef9 100644
--- a/src/mainboard/google/kahlee/variants/baseboard/mainboard.c
+++ b/src/mainboard/google/kahlee/variants/baseboard/mainboard.c
@@ -15,7 +15,9 @@
 
 #include <ec/google/chromeec/ec.h>
 #include <baseboard/variants.h>
+#include <cbfs.h>
 #include <gpio.h>
+#include <smbios.h>
 #include <variant/gpio.h>
 #include <device/pci.h>
 #include <drivers/generic/bayhub/bh720.h>
@@ -73,3 +75,52 @@
 	write32((void *)(sdbar + BH720_MEM_RW_ADR), 0x800000D0);
 	write32((void *)(sdbar + BH720_MEM_ACCESS_EN), 0x80000000);
 }
+
+static uint8_t calc_oem_id(void)
+{
+	return variant_board_sku() / 0x10;
+}
+
+/* "oem.bin" in cbfs contains an array of records using the following structure. */
+struct oem_mapping {
+	uint8_t oem_id;
+	char oem_name[10];
+} __packed;
+
+/* Local buffer to read "oem.bin" */
+static char oem_bin_data[200];
+
+const char *smbios_mainboard_manufacturer(void)
+{
+	uint8_t oem_id;
+	const struct oem_mapping *oem_entry = (void *)&oem_bin_data;
+	size_t oem_data_size;
+	size_t curr;
+	static const char *manuf;
+
+	if (! IS_ENABLED(CONFIG_USE_OEM_BIN))
+		return CONFIG_MAINBOARD_SMBIOS_MANUFACTURER;
+
+	if (manuf)
+		return manuf;
+
+	oem_data_size = cbfs_boot_load_file("oem.bin", oem_bin_data,
+					    sizeof(oem_bin_data),
+					    CBFS_TYPE_RAW);
+	oem_id = calc_oem_id();
+	curr = 0;
+	while ((curr < oem_data_size) &&
+	       ((oem_data_size - curr) >= sizeof(*oem_entry))) {
+		if (oem_id == oem_entry->oem_id) {
+			manuf = oem_entry->oem_name;
+			break;
+		}
+		curr += sizeof(*oem_entry);
+		oem_entry++;
+	}
+
+	if (manuf == NULL)
+		manuf = CONFIG_MAINBOARD_SMBIOS_MANUFACTURER;
+
+	return manuf;
+}

-- 
To view, visit https://review.coreboot.org/28651
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I997dc39c7f36f70cf4320ef335831245889eb475
Gerrit-Change-Number: 28651
Gerrit-PatchSet: 1
Gerrit-Owner: Martin Roth <martinroth at google.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180917/9d999032/attachment-0001.html>


More information about the coreboot-gerrit mailing list