[coreboot-gerrit] New patch to review for coreboot: drivers/intel/fsp2_0: Add display HOB support

Lee Leahy (leroy.p.leahy@intel.com) gerrit at coreboot.org
Mon Jul 25 21:39:32 CEST 2016


Lee Leahy (leroy.p.leahy at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15851

-gerrit

commit f9faafae57d08108f58263acf4d01291320cbaa2
Author: Lee Leahy <leroy.p.leahy at intel.com>
Date:   Sun Jul 24 17:18:32 2016 -0700

    drivers/intel/fsp2_0: Add display HOB support
    
    Add support to display the HOBs returned by FSP:
    * Add Kconfig value to enable HOB display
    * Move hob_header and hob_resource structures into api.h
    * Add HOB type name table
    * Add more GUID values
    * Extend UUID name table
    * Add fsp_ prefix to print_guid and remove static
    * Add routine to convert EDK-II GUID into a name
    * Add SOC specific routine to handle unknown GUID types
    * Add routine to convert HOB type into a name
    * Add SOC specific routine to handle unknown HOB types
    * Add routine to display the hobs
    
    TEST=Build and run on Galileo Gen2
    
    Change-Id: I10606d752859fff0f4f08a5ac03ab129b2c96d1f
    Signed-off-by: Lee Leahy <leroy.p.leahy at intel.com>
---
 src/drivers/intel/fsp2_0/Kconfig            |   6 ++
 src/drivers/intel/fsp2_0/hand_off_block.c   | 160 ++++++++++++++++++++++++----
 src/drivers/intel/fsp2_0/include/fsp/api.h  |  18 ++++
 src/drivers/intel/fsp2_0/include/fsp/util.h |   5 +
 src/drivers/intel/fsp2_0/memory_init.c      |  14 +++
 src/drivers/intel/fsp2_0/silicon_init.c     |   4 +
 6 files changed, 187 insertions(+), 20 deletions(-)

diff --git a/src/drivers/intel/fsp2_0/Kconfig b/src/drivers/intel/fsp2_0/Kconfig
index 10c7cac..01846e3 100644
--- a/src/drivers/intel/fsp2_0/Kconfig
+++ b/src/drivers/intel/fsp2_0/Kconfig
@@ -27,6 +27,12 @@ config ADD_FSP_BINARIES
 	  Add the FSP-M and FSP-S binaries to CBFS. Currently coreboot does not
 	  use the FSP-T binary and it is not added.
 
+config DISPLAY_HOBS
+	bool "Display the hand-off-blocks"
+	default n
+	help
+	  Display the FSP HOBs which are provided for coreboot.
+
 config DISPLAY_UPD_DATA
 	bool "Display UPD data"
 	default n
diff --git a/src/drivers/intel/fsp2_0/hand_off_block.c b/src/drivers/intel/fsp2_0/hand_off_block.c
index 276e49d..ff3a70b 100644
--- a/src/drivers/intel/fsp2_0/hand_off_block.c
+++ b/src/drivers/intel/fsp2_0/hand_off_block.c
@@ -21,17 +21,9 @@
 
 #define HOB_HEADER_LEN		8
 
-struct hob_header {
+struct hob_type_name {
 	uint16_t type;
-	uint16_t length;
-} __attribute__((packed));
-
-struct hob_resource {
-	uint8_t owner_guid[16];
-	uint32_t type;
-	uint32_t attribute_type;
-	uint64_t addr;
-	uint64_t length;
+	const char *name;
 } __attribute__((packed));
 
 enum resource_type {
@@ -70,6 +62,21 @@ enum hob_type {
 	HOB_TYPE_END_OF_HOB_LIST		= 0xFFFF,
 };
 
+static const struct hob_type_name hob_type_names [] = {
+	{HOB_TYPE_HANDOFF, "HOB_TYPE_HANDOFF"},
+	{HOB_TYPE_MEMORY_ALLOCATION, "HOB_TYPE_MEMORY_ALLOCATION"},
+	{HOB_TYPE_RESOURCE_DESCRIPTOR, "HOB_TYPE_RESOURCE_DESCRIPTOR"},
+	{HOB_TYPE_GUID_EXTENSION, "HOB_TYPE_GUID_EXTENSION"},
+	{HOB_TYPE_FV, "HOB_TYPE_FV"},
+	{HOB_TYPE_CPU, "HOB_TYPE_CPU"},
+	{HOB_TYPE_MEMORY_POOL, "HOB_TYPE_MEMORY_POOL"},
+	{HOB_TYPE_FV2, "HOB_TYPE_FV2"},
+	{HOB_TYPE_LOAD_PEIM_UNUSED, "HOB_TYPE_LOAD_PEIM_UNUSED"},
+	{HOB_TYPE_UCAPSULE, "HOB_TYPE_UCAPSULE"},
+	{HOB_TYPE_UNUSED, "HOB_TYPE_UNUSED"},
+	{HOB_TYPE_END_OF_HOB_LIST, "HOB_TYPE_END_OF_HOB_LIST"}
+};
+
 /* UUIDs (GUIDs) in little-endian, so they can be used with memcmp() */
 static const uint8_t uuid_owner_bootloader_tolum[16] = {
 	0x56, 0x4f, 0xff, 0x73, 0x8e, 0xaa, 0x51, 0x44,
@@ -87,8 +94,28 @@ static const uint8_t uuid_owner_tseg[16] = {
 };
 
 static const uint8_t uuid_fsp_nv_storage[16] = {
-       0x02, 0xcf, 0x1a, 0x72, 0x77, 0x4d, 0x2a, 0x4c,
-       0xb3, 0xdc, 0x27, 0x0b, 0x7b, 0xa9, 0xe4, 0xb0
+	0x02, 0xcf, 0x1a, 0x72, 0x77, 0x4d, 0x2a, 0x4c,
+	0xb3, 0xdc, 0x27, 0x0b, 0x7b, 0xa9, 0xe4, 0xb0
+};
+
+static const uint8_t uuid_graphics_info[16] = {
+	0xce, 0x2c, 0xf6, 0x39, 0x25, 0x68, 0x69, 0x46,
+	0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07
+};
+
+static const uint8_t uuid_smbios_memory_info[16] = {
+	0x8c, 0x10, 0xa1, 0x01, 0xee, 0x9d, 0x84, 0x49,
+	0x88, 0xc3, 0xee, 0xe8, 0xc4, 0x9e, 0xfb, 0x89
+};
+
+static const uint8_t uuid_bootloader_temp_memory[16] = {
+	0x6c, 0xf4, 0xcf, 0xbb, 0xd3, 0xc8, 0x13, 0x41,
+	0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e
+};
+
+static const uint8_t uuid_fsp_info_header[16] = {
+	0xbe, 0x40, 0x27, 0x91, 0x84, 0x22, 0x34, 0x47,
+	0xb9, 0x71, 0x84, 0xb0, 0x27, 0x35, 0x3f, 0x0c
 };
 
 static const uint8_t empty_uuid[16] = {
@@ -99,10 +126,14 @@ static const struct uuid_name_map {
 	const void *uuid;
 	const char *name;
 } uuid_names[] = {
-	{ uuid_owner_bootloader_tolum,	"BOOTLOADER_TOLUM" },
-	{ uuid_owner_fsp,		"FSP_RESERVED_MEMORY" },
-	{ uuid_owner_tseg,		"TSEG" },
-	{ uuid_fsp_nv_storage,		"FSP_NV_STORAGE" },
+	{uuid_owner_bootloader_tolum,	"BOOTLOADER_TOLUM"},
+	{uuid_owner_fsp,		"FSP_RESERVED_MEMORY"},
+	{uuid_owner_tseg,		"TSEG"},
+	{uuid_fsp_nv_storage,		"FSP_NV_STORAGE"},
+	{uuid_graphics_info,		"GRAPHICS INFO"},
+	{uuid_smbios_memory_info,	"FSP_SMBIOS_MEMORY_INFO_GUID"},
+	{uuid_bootloader_temp_memory,	"FSP_BOOTLOADER_TEMP_MEMORY_HOB_GUID"},
+	{uuid_fsp_info_header,		"FSP_INFO_HEADER_GUID"},
 };
 
 static const char *resource_name(enum resource_type type)
@@ -244,7 +275,7 @@ void fsp_find_reserved_memory(struct range_entry *re, const void *hob_list)
  * Utilities for printing HOB information
  */
 
-static void print_guid(const void *base)
+void fsp_print_guid(const void *base)
 {
 	uint32_t big;
 	uint16_t mid[2];
@@ -270,12 +301,11 @@ static void print_resource_descriptor(const void *base)
 	printk(BIOS_DEBUG, "\t0x%08llx + 0x%08llx\n", res->addr, res->length);
 	if (!uuid_compare(res->owner_guid, empty_uuid)) {
 		printk(BIOS_DEBUG, "\tOwner GUID: ");
-		print_guid(res->owner_guid);
+		fsp_print_guid(res->owner_guid);
 		printk(BIOS_DEBUG, " (%s)\n", uuid_name(res->owner_guid));
 	}
 }
 
-
 void fsp_print_memory_resource_hobs(const void *hob_list)
 {
 	const struct hob_header *hob = hob_list;
@@ -309,8 +339,98 @@ const void *fsp_find_extension_hob_by_uuid(const uint8_t *uuid, size_t *size)
 	return NULL;
 }
 
-
 const void *fsp_find_nv_storage_data(size_t *size)
 {
 	return fsp_find_extension_hob_by_uuid(uuid_fsp_nv_storage, size);
 }
+
+const char *fsp_get_hob_type_name(const struct hob_header *hob)
+{
+	uint32_t index;
+	const char *name;
+
+	for (index = 0; index < ARRAY_SIZE(hob_type_names); index++)
+		if (hob->type == hob_type_names[index].type)
+			return hob_type_names[index].name;
+
+	/* Get name for SOC specific hob */
+	name = soc_hob_type_name(hob);
+	if (name != NULL)
+		return name;
+	return "Unknown HOB type";
+}
+
+const char *fsp_get_guid_name(const uint8_t *guid)
+{
+	uint32_t index;
+	const char *name;
+
+	for (index = 0; index < ARRAY_SIZE(uuid_names); index++)
+		if (uuid_compare(guid, uuid_names[index].uuid))
+			return uuid_names[index].name;
+
+	/* Get name for SOC specific uuid */
+	name = soc_guid_name(guid);
+	if (name != NULL)
+		return name;
+	return "Unknown GUID";
+}
+
+__attribute__((weak)) const char *soc_hob_type_name(
+	const struct hob_header *hob)
+{
+	return NULL;
+}
+
+void fsp_print_guid_extension_hob(const struct hob_header *hob)
+{
+	const struct hob_resource *res;
+
+	res = hob_header_to_resource(hob);
+	printk(BIOS_DEBUG, "\t");
+	fsp_print_guid(res->owner_guid);
+	printk(BIOS_DEBUG, ": %s\n", fsp_get_guid_name(res->owner_guid));
+}
+
+__attribute__((weak)) const char *soc_guid_name(const uint8_t *guid)
+{
+	return NULL;
+}
+
+void fsp_display_hobs(const struct hob_header *hob_list_ptr)
+{
+	const struct hob_header *hob = hob_list_ptr;
+
+	/* Display the HOB list pointer */
+	printk(BIOS_DEBUG, "\n=== FSP HOBs ===\n");
+	printk(BIOS_DEBUG, "0x%p: hob_list_ptr\n", hob);
+
+	/* Walk the list of HOBs */
+	while (1) {
+		/* Display the HOB header */
+		printk(BIOS_DEBUG, "0x%p, 0x%08x bytes: %s\n", hob, hob->length,
+			fsp_get_hob_type_name(hob));
+		switch(hob->type) {
+		default:
+			soc_display_hob(hob);
+			break;
+
+		case HOB_TYPE_END_OF_HOB_LIST:
+			printk(BIOS_DEBUG, "=== End of FSP HOBs ===\n\n");
+			return;
+
+		case HOB_TYPE_RESOURCE_DESCRIPTOR:
+			print_resource_descriptor(hob);
+			break;
+
+		case HOB_TYPE_GUID_EXTENSION:
+			fsp_print_guid_extension_hob(hob);
+			break;
+		}
+		hob = next_hob(hob);
+	}
+}
+
+__attribute__((weak)) void soc_display_hob(const struct hob_header *hob)
+{
+}
diff --git a/src/drivers/intel/fsp2_0/include/fsp/api.h b/src/drivers/intel/fsp2_0/include/fsp/api.h
index 6026559..09d3f81 100644
--- a/src/drivers/intel/fsp2_0/include/fsp/api.h
+++ b/src/drivers/intel/fsp2_0/include/fsp/api.h
@@ -76,6 +76,24 @@ void fspm_display_upd_params(const struct FSPM_UPD *fspm_old_upd,
 void fsps_display_upd_params(const struct FSPS_UPD *fsps_old_upd,
 	const struct FSPS_UPD *fsps_new_upd);
 
+struct hob_header {
+	uint16_t type;
+	uint16_t length;
+} __attribute__((packed));
+
+struct hob_resource {
+	uint8_t owner_guid[16];
+	uint32_t type;
+	uint32_t attribute_type;
+	uint64_t addr;
+	uint64_t length;
+} __attribute__((packed));
+
+/* Callbacks for displaying HOBs */
+const char *soc_hob_type_name(const struct hob_header *hob);
+const char *soc_guid_name(const uint8_t *guid);
+void soc_display_hob(const struct hob_header *hob);
+
 /*
  * # DOCUMENTATION:
  *
diff --git a/src/drivers/intel/fsp2_0/include/fsp/util.h b/src/drivers/intel/fsp2_0/include/fsp/util.h
index 03cea09..231a546 100644
--- a/src/drivers/intel/fsp2_0/include/fsp/util.h
+++ b/src/drivers/intel/fsp2_0/include/fsp/util.h
@@ -37,6 +37,11 @@ void fsp_find_range_hob(struct range_entry *re, const void *hob_list,
 void fsp_find_bootloader_tolum(struct range_entry *re, const void *hob_list);
 void fsp_find_reserved_memory(struct range_entry *re, const void *hob_list);
 void fsp_print_memory_resource_hobs(const void *hob_list);
+void fsp_print_guid(const void *guid);
+const char *fsp_get_hob_type_name(const struct hob_header *hob);
+const char *fsp_get_guid_name(const uint8_t *guid);
+void fsp_print_guid_extension_hob(const struct hob_header *hob);
+void fsp_display_hobs(const struct hob_header *hob_list_ptr);
 
 /* Fill in header and validate sanity of component within region device. */
 enum cb_err fsp_validate_component(struct fsp_header *hdr,
diff --git a/src/drivers/intel/fsp2_0/memory_init.c b/src/drivers/intel/fsp2_0/memory_init.c
index 6950038..973967d 100644
--- a/src/drivers/intel/fsp2_0/memory_init.c
+++ b/src/drivers/intel/fsp2_0/memory_init.c
@@ -64,10 +64,17 @@ static void verify_hobs(struct range_entry *fsp_mem,
 {
 	struct range_entry tolum;
 
+	/* Display the HOB list pointer */
+	if (IS_ENABLED(CONFIG_DISPLAY_HOBS))
+		printk(BIOS_ERR, "0x%p: HOB list pointer\n", hob_list_ptr);
+
 	/* Lookup the FSP_BOOTLOADER_TOLUM_HOB */
 	fsp_find_bootloader_tolum(&tolum, hob_list_ptr);
 	if ((tolum.begin == 0) && (tolum.begin == (tolum.end + 1)))
 		die("9.3: FSP_BOOTLOADER_TOLUM_HOB missing!\n");
+	if (IS_ENABLED(CONFIG_DISPLAY_HOBS))
+		printk(BIOS_ERR, "0x%08llx - 0x%08llx: BootLoaderTolum\n",
+			tolum.begin, tolum.end + 1);
 	if (range_entry_size(&tolum) < cbmem_overhead_size()) {
 		printk(BIOS_ERR, "FSP_BOOTLOADER_TOLUM_SIZE: 0x%08llx < 0x%08lx\n",
 			range_entry_size(&tolum), cbmem_overhead_size());
@@ -78,6 +85,9 @@ static void verify_hobs(struct range_entry *fsp_mem,
 	fsp_find_reserved_memory(fsp_mem, hob_list_ptr);
 	if ((fsp_mem->begin == 0) && (fsp_mem->begin == (fsp_mem->end + 1)))
 		die("9.1: FSP_RESERVED_MEMORY_RESOURCE_HOB missing!\n");
+	if (IS_ENABLED(CONFIG_DISPLAY_HOBS))
+		printk(BIOS_SPEW, "0x%08llx - 0x%08llx: FSP reserved memory\n",
+			fsp_mem->begin, fsp_mem->end + 1);
 
 	/* Verify the the bootloader tolum is above the FSP reserved area */
 	if (tolum.end <= fsp_mem->begin)
@@ -97,6 +107,10 @@ static enum fsp_status do_fsp_post_memory_init(void *hob_list_ptr, bool s3wake,
 	/* Verify that the HOB list pointer was set */
 	if (hob_list_ptr == NULL)
 		die("ERROR - HOB list pointer was not returned!\n");
+
+	/* Display and verify the HOBs */
+	if (IS_ENABLED(CONFIG_DISPLAY_HOBS))
+		fsp_display_hobs(hob_list_ptr);
 	verify_hobs(&fsp_mem, hob_list_ptr);
 
 	/* initialize cbmem by adding FSP reserved memory first thing */
diff --git a/src/drivers/intel/fsp2_0/silicon_init.c b/src/drivers/intel/fsp2_0/silicon_init.c
index 6f2f229..93ab5c9 100644
--- a/src/drivers/intel/fsp2_0/silicon_init.c
+++ b/src/drivers/intel/fsp2_0/silicon_init.c
@@ -64,6 +64,10 @@ static enum fsp_status do_silicon_init(struct fsp_header *hdr)
 	/* Handle any resets requested by FSPS. */
 	fsp_handle_reset(status);
 
+	/* Display the HOBs */
+	if (IS_ENABLED(CONFIG_DISPLAY_HOBS))
+		fsp_display_hobs(fsp_get_hob_list());
+
 	/* Display the MTRRs */
 	soc_display_mtrrs();
 



More information about the coreboot-gerrit mailing list