[coreboot-gerrit] Change in coreboot[master]: drivers/intel/fsp2_0: Add support to display FSP version info Hob

Subrata Banik (Code Review) gerrit at coreboot.org
Tue Jan 23 12:32:27 CET 2018


Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/23386


Change subject: drivers/intel/fsp2_0: Add support to display FSP version info Hob
......................................................................

drivers/intel/fsp2_0: Add support to display FSP version info Hob

This patch locates FSP FVI hob in order to extract all firmware
ingredient version information.

So far this feature is only supported for CannonLake SoC onwards.

Change-Id: Ib749e49a9f263d85947b60d4c445faf8c37f5931
Signed-off-by: Subrata Banik <subrata.banik at intel.com>
---
M src/drivers/intel/fsp2_0/Kconfig
M src/drivers/intel/fsp2_0/hand_off_block.c
M src/drivers/intel/fsp2_0/include/fsp/soc_binding.h
M src/drivers/intel/fsp2_0/include/fsp/util.h
4 files changed, 119 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/23386/1

diff --git a/src/drivers/intel/fsp2_0/Kconfig b/src/drivers/intel/fsp2_0/Kconfig
index 864b3a1..e2c784d 100644
--- a/src/drivers/intel/fsp2_0/Kconfig
+++ b/src/drivers/intel/fsp2_0/Kconfig
@@ -112,6 +112,11 @@
 	bool "Reset the system on S3 wake when ramstage cache invalid."
 	default n
 
+config DISPLAY_FSP_VERSION_INFO
+	bool "Display Firmware Ingredient Version Information"
+	help
+	  Select this option to display Firmware version information.
+
 config FSP2_0_USES_TPM_MRC_HASH
 	bool
 	default y if HAS_RECOVERY_MRC_CACHE
diff --git a/src/drivers/intel/fsp2_0/hand_off_block.c b/src/drivers/intel/fsp2_0/hand_off_block.c
index 2d7e209..a4453e2 100644
--- a/src/drivers/intel/fsp2_0/hand_off_block.c
+++ b/src/drivers/intel/fsp2_0/hand_off_block.c
@@ -15,12 +15,14 @@
 #include <cbmem.h>
 #include <commonlib/helpers.h>
 #include <console/console.h>
+#include <fsp/api.h>
 #include <fsp/util.h>
 #include <inttypes.h>
 #include <lib.h>
 #include <string.h>
 
 #define HOB_HEADER_LEN		8
+#define SMBUS_HEADER_LEN	4
 
 /* GUIDs in little-endian, so they can be used with memcmp() */
 const uint8_t fsp_bootloader_tolum_guid[16] = {
@@ -43,6 +45,11 @@
 	0x88, 0xc3, 0xee, 0xe8, 0xc4, 0x9e, 0xfb, 0x89
 };
 
+const uint8_t uuid_fv_info[16] = {
+	0x2e, 0x72, 0x8e, 0x79, 0xb2, 0x15, 0x13, 0x4e,
+	0x8a, 0xe9, 0x6b, 0xa3, 0x0f, 0xf7, 0xf1, 0x67
+};
+
 /*
  * Utilities for walking HOBs
  */
@@ -217,6 +224,109 @@
 	return NULL;
 }
 
+#if IS_ENABLED(CONFIG_DISPLAY_FSP_VERSION_INFO)
+
+static int get_fw_ingredient_info(char *comp_name)
+{
+	int count = 0;
+
+	while(comp_name[count] != '\0')
+		count++;
+
+	return count;
+}
+
+static char *get_next_ingredient(char *comp_name, int size)
+{
+	comp_name = (char *)((uint32_t)comp_name + size +
+			sizeof(uint8_t));
+
+	return comp_name;
+}
+
+static void display_fsp_version_info_hob(const FIRMWARE_VERSION_INFO_HOB *fvih,
+		size_t size)
+{
+	FIRMWARE_VERSION_INFO *fvi;
+	int index, cnt;
+	char *str_ptr;
+	struct firmware_version_string{
+		char *component_name;
+		char *version_string;
+	} __attribute__((packed));
+	struct firmware_version_string *fvi_ver_str;
+
+	fvi = (FIRMWARE_VERSION_INFO *)(&(fvih->Count) +1);
+
+	str_ptr = (char *)((uint32_t)fvi +
+			 (fvih->Count * sizeof (FIRMWARE_VERSION_INFO)));
+	fvi_ver_str = malloc(size - sizeof(fvih->Count) - (fvih->Count *
+				sizeof (FIRMWARE_VERSION_INFO)));
+
+	for (index = 0; index < fvih->Count; index++) {
+		cnt = get_fw_ingredient_info(str_ptr);
+
+		/*  Don't show ingredient name and version if its all 0xFF */
+		if (fvi[index].Version.MajorVersion == 0xFF &&
+			fvi[index].Version.MajorVersion == 0xFF &&
+			fvi[index].Version.MajorVersion == 0xFF &&
+			fvi[index].Version.MajorVersion == 0xFF &&
+			fvi[index].VersionStringIndex == 0) {
+			str_ptr = get_next_ingredient(str_ptr, cnt);
+			continue;
+;		}
+
+		memcpy((char *)(&(fvi_ver_str)[index].component_name),
+				str_ptr, cnt+1);
+		printk(BIOS_DEBUG, "%s = ",
+				(char *)(&(fvi_ver_str)[index].component_name));
+
+		if (!fvi[index].VersionStringIndex)
+			printk(BIOS_DEBUG, "%x.%x.%x.%x\n",
+					fvi[index].Version.MajorVersion,
+					fvi[index].Version.MinorVersion,
+					fvi[index].Version.Revision,
+					fvi[index].Version.BuildNumber);
+		else {
+			str_ptr = get_next_ingredient(str_ptr, cnt);
+			cnt = get_fw_ingredient_info(str_ptr);
+			memcpy((char *)(&(fvi_ver_str)[index].version_string),
+				str_ptr, cnt+1);
+
+			printk(BIOS_DEBUG, "%s\n",
+				(char *)(&(fvi_ver_str)[index].version_string));
+		}
+		str_ptr = get_next_ingredient(str_ptr, cnt);
+	}
+	free(fvi_ver_str);
+}
+
+void fsp_find_fvi_version_hob(void)
+{
+	const uint8_t *hob_uuid;
+	const struct hob_header *hob = fsp_get_hob_list();
+	size_t size;
+
+	if (!hob)
+		return;
+
+	for ( ; hob->type != HOB_TYPE_END_OF_HOB_LIST;
+			hob = fsp_next_hob(hob)) {
+		if (hob->type != HOB_TYPE_GUID_EXTENSION)
+			continue;
+
+		hob_uuid = hob_header_to_struct(hob);
+
+		if (fsp_guid_compare(hob_uuid, uuid_fv_info)) {
+			size = hob->length - (HOB_HEADER_LEN + 16 +
+					SMBUS_HEADER_LEN);
+			display_fsp_version_info_hob(
+				(FIRMWARE_VERSION_INFO_HOB *)hob, size);
+		}
+	}
+}
+#endif
+
 const void *fsp_find_nv_storage_data(size_t *size)
 {
 	return fsp_find_extension_hob_by_guid(fsp_nv_storage_guid, size);
diff --git a/src/drivers/intel/fsp2_0/include/fsp/soc_binding.h b/src/drivers/intel/fsp2_0/include/fsp/soc_binding.h
index 5c8b441..94abe78 100644
--- a/src/drivers/intel/fsp2_0/include/fsp/soc_binding.h
+++ b/src/drivers/intel/fsp2_0/include/fsp/soc_binding.h
@@ -26,6 +26,9 @@
 #include <Base.h>
 #include <FspmUpd.h>
 #include <FspsUpd.h>
+#if IS_ENABLED(CONFIG_DISPLAY_FSP_VERSION_INFO)
+#include <FirmwareVersionInfoHob.h>
+#endif
 
 #pragma pack(pop)
 
diff --git a/src/drivers/intel/fsp2_0/include/fsp/util.h b/src/drivers/intel/fsp2_0/include/fsp/util.h
index 43e3569..34466b8 100644
--- a/src/drivers/intel/fsp2_0/include/fsp/util.h
+++ b/src/drivers/intel/fsp2_0/include/fsp/util.h
@@ -77,6 +77,7 @@
 const void *fsp_find_smbios_memory_info(size_t *size);
 enum cb_err fsp_fill_lb_framebuffer(struct lb_framebuffer *framebuffer);
 int fsp_find_range_hob(struct range_entry *re, const uint8_t guid[16]);
+void fsp_find_fvi_version_hob(void);
 int fsp_find_reserved_memory(struct range_entry *re);
 const struct hob_resource *fsp_hob_header_to_resource(
 	const struct hob_header *hob);

-- 
To view, visit https://review.coreboot.org/23386
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: Ib749e49a9f263d85947b60d4c445faf8c37f5931
Gerrit-Change-Number: 23386
Gerrit-PatchSet: 1
Gerrit-Owner: Subrata Banik <subrata.banik at intel.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180123/7e1e40fa/attachment-0001.html>


More information about the coreboot-gerrit mailing list