[coreboot-gerrit] Patch set updated for coreboot: drivers/intel/fsp2_0: Add display HOB support

Lee Leahy (leroy.p.leahy@intel.com) gerrit at coreboot.org
Tue Aug 2 02:31:12 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 4b9b6615cb58eded46070a4ae401b6a41702fcdd
Author: Lee Leahy <leroy.p.leahy at intel.com>
Date:   Wed Jul 27 07:40:25 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, hob_resource and uuid_name structures into util.h
    * Move hob_type enum into util.h
    * Remove static from the debug utility functions
    * Add fsp_ prefix to the debug utility functions
    * Declare the debug utility functions in debug.h
    * Add HOB type name table
    * Add more GUID values
    * Add new GUID name table for additional GUIDs
    * 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/Makefile.inc        |   2 +
 src/drivers/intel/fsp2_0/debug.c             |  12 ++
 src/drivers/intel/fsp2_0/graphics.c          |   4 +-
 src/drivers/intel/fsp2_0/hand_off_block.c    | 168 +++----------------
 src/drivers/intel/fsp2_0/hob_display.c       | 231 +++++++++++++++++++++++++++
 src/drivers/intel/fsp2_0/include/fsp/debug.h |  14 ++
 src/drivers/intel/fsp2_0/include/fsp/util.h  |  34 +++-
 8 files changed, 322 insertions(+), 149 deletions(-)

diff --git a/src/drivers/intel/fsp2_0/Kconfig b/src/drivers/intel/fsp2_0/Kconfig
index 32dbb59..06f1a7c 100644
--- a/src/drivers/intel/fsp2_0/Kconfig
+++ b/src/drivers/intel/fsp2_0/Kconfig
@@ -34,6 +34,12 @@ config DISPLAY_FSP_CALLS_AND_STATUS
 	  Display the FSP call entry point and parameters prior to calling FSP
 	  and display the status upon return from FSP.
 
+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/Makefile.inc b/src/drivers/intel/fsp2_0/Makefile.inc
index cc496ee..2b1754e 100644
--- a/src/drivers/intel/fsp2_0/Makefile.inc
+++ b/src/drivers/intel/fsp2_0/Makefile.inc
@@ -17,6 +17,7 @@ ifeq ($(CONFIG_PLATFORM_USES_FSP2_0),y)
 
 romstage-y += debug.c
 romstage-y += hand_off_block.c
+romstage-$(CONFIG_DISPLAY_HOBS) += hob_display.c
 romstage-$(CONFIG_DISPLAY_UPD_DATA) += upd_display.c
 romstage-y += util.c
 romstage-y += memory_init.c
@@ -24,6 +25,7 @@ romstage-y += memory_init.c
 ramstage-y += debug.c
 ramstage-y += graphics.c
 ramstage-y += hand_off_block.c
+ramstage-$(CONFIG_DISPLAY_HOBS) += hob_display.c
 ramstage-y += notify.c
 ramstage-y += silicon_init.c
 ramstage-$(CONFIG_DISPLAY_UPD_DATA) += upd_display.c
diff --git a/src/drivers/intel/fsp2_0/debug.c b/src/drivers/intel/fsp2_0/debug.c
index c01810a..c345c92 100644
--- a/src/drivers/intel/fsp2_0/debug.c
+++ b/src/drivers/intel/fsp2_0/debug.c
@@ -43,6 +43,10 @@ void fsp_debug_after_memory_init(enum fsp_status status,
 	if (IS_ENABLED(CONFIG_DISPLAY_FSP_CALLS_AND_STATUS))
 		printk(BIOS_DEBUG, "FspMemoryInit returned 0x%08x\n", status);
 
+	/* Display the HOBs */
+	if (IS_ENABLED(CONFIG_DISPLAY_HOBS))
+		fsp_display_hobs(hob_list_ptr);
+
 	/* Display the MTRRs */
 	if (IS_ENABLED(CONFIG_DISPLAY_MTRRS))
 		soc_display_mtrrs();
@@ -72,6 +76,10 @@ void fsp_debug_after_silicon_init(enum fsp_status status)
 	if (IS_ENABLED(CONFIG_DISPLAY_FSP_CALLS_AND_STATUS))
 		printk(BIOS_SPEW, "FspSiliconInit returned 0x%08x\n", status);
 
+	/* Display the HOBs */
+	if (IS_ENABLED(CONFIG_DISPLAY_HOBS))
+		fsp_display_hobs((const struct hob_header *)fsp_get_hob_list());
+
 	/* Display the MTRRs */
 	if (IS_ENABLED(CONFIG_DISPLAY_MTRRS))
 		soc_display_mtrrs();
@@ -98,6 +106,10 @@ void fsp_debug_after_notify(enum fsp_status status)
 	if (IS_ENABLED(CONFIG_DISPLAY_FSP_CALLS_AND_STATUS))
 		printk(BIOS_SPEW, "FspNotify returned 0x%08x\n", status);
 
+	/* Display the HOBs */
+	if (IS_ENABLED(CONFIG_DISPLAY_HOBS))
+		fsp_display_hobs((const struct hob_header *)fsp_get_hob_list());
+
 	/* Display the MTRRs */
 	if (IS_ENABLED(CONFIG_DISPLAY_MTRRS))
 		soc_display_mtrrs();
diff --git a/src/drivers/intel/fsp2_0/graphics.c b/src/drivers/intel/fsp2_0/graphics.c
index f4ba402..039202f 100644
--- a/src/drivers/intel/fsp2_0/graphics.c
+++ b/src/drivers/intel/fsp2_0/graphics.c
@@ -20,7 +20,7 @@ enum pixel_format {
 	pixel_bitmask = 2,		/* defined by <rgb>_mask values */
 };
 
-static const uint8_t uuid_graphics_info[16] = {
+const uint8_t fsp_graphics_info_guid[16] = {
 	0xce, 0x2c, 0xf6, 0x39, 0x25, 0x68, 0x69, 0x46,
 	0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07
 };
@@ -60,7 +60,7 @@ enum cb_err fsp_fill_lb_framebuffer(struct lb_framebuffer *framebuffer)
 	const struct hob_graphics_info *ginfo;
 	const struct fsp_framebuffer *fbinfo;
 
-	ginfo = fsp_find_extension_hob_by_uuid(uuid_graphics_info, &size);
+	ginfo = fsp_find_extension_hob_by_guid(fsp_graphics_info_guid, &size);
 
 	if (!ginfo) {
 		printk(BIOS_ALERT, "Graphics hand-off block not found\n");
diff --git a/src/drivers/intel/fsp2_0/hand_off_block.c b/src/drivers/intel/fsp2_0/hand_off_block.c
index ce06a82..eca742b 100644
--- a/src/drivers/intel/fsp2_0/hand_off_block.c
+++ b/src/drivers/intel/fsp2_0/hand_off_block.c
@@ -21,14 +21,6 @@
 
 #define HOB_HEADER_LEN		8
 
-struct hob_resource {
-	uint8_t owner_guid[16];
-	uint32_t type;
-	uint32_t attribute_type;
-	uint64_t addr;
-	uint64_t length;
-} __attribute__((packed));
-
 enum resource_type {
 	EFI_RESOURCE_SYSTEM_MEMORY		= 0,
 	EFI_RESOURCE_MEMORY_MAPPED_IO		= 1,
@@ -40,96 +32,27 @@ enum resource_type {
 	EFI_RESOURCE_MAX_MEMORY_TYPE		= 7,
 };
 
-static const char *resource_names[] = {
-	[EFI_RESOURCE_SYSTEM_MEMORY]		= "SYSTEM_MEMORY",
-	[EFI_RESOURCE_MEMORY_MAPPED_IO]		= "MMIO",
-	[EFI_RESOURCE_IO]			= "IO",
-	[EFI_RESOURCE_FIRMWARE_DEVICE]		= "FIRMWARE_DEVICE",
-	[EFI_RESOURCE_MEMORY_MAPPED_IO_PORT]	= "MMIO_PORT",
-	[EFI_RESOURCE_MEMORY_RESERVED]		= "MEMORY_RESERVED",
-	[EFI_RESOURCE_IO_RESERVED]		= "IO_RESERVED",
-};
-
-enum hob_type {
-	HOB_TYPE_HANDOFF			= 0x0001,
-	HOB_TYPE_MEMORY_ALLOCATION		= 0x0002,
-	HOB_TYPE_RESOURCE_DESCRIPTOR		= 0x0003,
-	HOB_TYPE_GUID_EXTENSION			= 0x0004,
-	HOB_TYPE_FV				= 0x0005,
-	HOB_TYPE_CPU				= 0x0006,
-	HOB_TYPE_MEMORY_POOL			= 0x0007,
-	HOB_TYPE_FV2				= 0x0009,
-	HOB_TYPE_LOAD_PEIM_UNUSED		= 0x000A,
-	HOB_TYPE_UCAPSULE			= 0x000B,
-	HOB_TYPE_UNUSED				= 0xFFFE,
-	HOB_TYPE_END_OF_HOB_LIST		= 0xFFFF,
-};
-
-/* 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,
-	0xb3, 0x16, 0x36, 0x35, 0x36, 0x67, 0xad, 0x44,
-};
-
-static const uint8_t uuid_owner_fsp[16] = {
+/* GUIDs in little-endian, so they can be used with memcmp() */
+const uint8_t fsp_reserved_memory_guid[16] = {
 	0x59, 0x97, 0xa7, 0x69, 0x73, 0x13, 0x67, 0x43,
 	0xa6, 0xc4, 0xc7, 0xf5, 0x9e, 0xfd, 0x98, 0x6e,
 };
 
-static const uint8_t uuid_owner_tseg[16] = {
-	0x7c, 0x74, 0x38, 0xd0, 0x0c, 0xd0, 0x80, 0x49,
-	0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55
-};
-
-static const uint8_t uuid_fsp_nv_storage[16] = {
+const uint8_t fsp_nv_storage_guid[16] = {
        0x02, 0xcf, 0x1a, 0x72, 0x77, 0x4d, 0x2a, 0x4c,
        0xb3, 0xdc, 0x27, 0x0b, 0x7b, 0xa9, 0xe4, 0xb0
 };
 
-static const uint8_t empty_uuid[16] = {
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-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" },
-};
-
-static const char *resource_name(enum resource_type type)
-{
-	if (type >= ARRAY_SIZE(resource_names))
-		return "UNKNOWN";
-	return resource_names[type];
-}
-
 /*
  * Utilities for walking HOBs
  */
 
-static bool uuid_compare(const uint8_t uuid1[16], const uint8_t uuid2[16])
+bool fsp_guid_compare(const uint8_t guid1[16], const uint8_t guid2[16])
 {
-	return !memcmp(uuid1, uuid2, 16);
+	return !memcmp(guid1, guid2, 16);
 }
 
-static const char *uuid_name(const uint8_t uuid[16])
-{
-	size_t i;
-	const struct uuid_name_map *owner_entry;
-
-	for (i = 0; i < ARRAY_SIZE(uuid_names); i++) {
-		owner_entry = uuid_names + i;
-		if (uuid_compare(uuid, owner_entry->uuid))
-			return owner_entry->name;
-	}
-	return "UNKNOWN";
-}
-
-static const struct hob_header *next_hob(const struct hob_header *parent)
+const struct hob_header *fsp_next_hob(const struct hob_header *parent)
 {
 	union {
 		const struct hob_header *hob;
@@ -163,12 +86,12 @@ static const void *hob_header_to_extension_hob(const struct hob_header *hob)
 	} hob_walker;
 
 	hob_walker.hob_hdr = hob;
-	hob_walker.addr += HOB_HEADER_LEN + 16; /* header and 16-byte UUID */
+	hob_walker.addr += HOB_HEADER_LEN + 16; /* header and 16-byte GUID */
 	return hob_walker.hob_descr;
 }
 
-static const
-struct hob_resource *hob_header_to_resource(const struct hob_header *hob)
+const
+struct hob_resource *fsp_hob_header_to_resource(const struct hob_header *hob)
 {
 	return hob_header_to_struct(hob);
 }
@@ -192,18 +115,19 @@ const void *fsp_get_hob_list(void)
 }
 
 static const
-struct hob_resource *find_resource_hob_by_uuid(const struct hob_header *hob,
-					       const uint8_t uuid[16])
+struct hob_resource *find_resource_hob_by_guid(const struct hob_header *hob,
+					       const uint8_t guid[16])
 {
 	const struct hob_resource *res;
 
-	for ( ; hob->type != HOB_TYPE_END_OF_HOB_LIST; hob = next_hob(hob)) {
+	for ( ; hob->type != HOB_TYPE_END_OF_HOB_LIST;
+		hob = fsp_next_hob(hob)) {
 
 		if (hob->type != HOB_TYPE_RESOURCE_DESCRIPTOR)
 			continue;
 
-		res = hob_header_to_resource(hob);
-		if (uuid_compare(res->owner_guid, uuid))
+		res = fsp_hob_header_to_resource(hob);
+		if (fsp_guid_compare(res->owner_guid, guid))
 			return res;
 	}
 	return NULL;
@@ -215,7 +139,7 @@ void fsp_find_reserved_memory(struct range_entry *re, const void *hob_list)
 
 	range_entry_init(re, 0, 0, 0);
 
-	fsp_mem = find_resource_hob_by_uuid(hob_list, uuid_owner_fsp);
+	fsp_mem = find_resource_hob_by_guid(hob_list, fsp_reserved_memory_guid);
 
 	if (!fsp_mem) {
 		return;
@@ -224,67 +148,22 @@ void fsp_find_reserved_memory(struct range_entry *re, const void *hob_list)
 	range_entry_init(re, fsp_mem->addr, fsp_mem->addr + fsp_mem->length, 0);
 }
 
-/*
- * Utilities for printing HOB information
- */
-
-static void print_guid(const void *base)
-{
-	uint32_t big;
-	uint16_t mid[2];
-
-	const uint8_t *id = base;
-	big = read32(id + 0);
-	mid[0] = read16(id + 4);
-	mid[1] = read16(id + 6);
-
-	printk(BIOS_DEBUG, "%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x",
-	       big, mid[0], mid[1],
-	       id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15]);
-}
-
-static void print_resource_descriptor(const void *base)
-{
-	const struct hob_resource *res;
-
-	res = hob_header_to_resource(base);
-
-	printk(BIOS_DEBUG, "Resource %s, attribute %x\n",
-			   resource_name(res->type), res->attribute_type);
-	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);
-		printk(BIOS_DEBUG, " (%s)\n", uuid_name(res->owner_guid));
-	}
-}
-
-
-void fsp_print_memory_resource_hobs(const void *hob_list)
+const void *fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size)
 {
-	const struct hob_header *hob = hob_list;
-
-	for ( ; hob->type != HOB_TYPE_END_OF_HOB_LIST; hob = next_hob(hob)) {
-		if (hob->type == HOB_TYPE_RESOURCE_DESCRIPTOR)
-			print_resource_descriptor(hob);
-	}
-}
-
-const void *fsp_find_extension_hob_by_uuid(const uint8_t *uuid, size_t *size)
-{
-	const uint8_t *hob_uuid;
+	const uint8_t *hob_guid;
 	const struct hob_header *hob = fsp_get_hob_list();
 
 	if (!hob)
 		return NULL;
 
-	for ( ; hob->type != HOB_TYPE_END_OF_HOB_LIST; hob = next_hob(hob)) {
+	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 (uuid_compare(hob_uuid, uuid)) {
+		hob_guid = hob_header_to_struct(hob);
+		if (fsp_guid_compare(hob_guid, guid)) {
 			*size = hob->length - (HOB_HEADER_LEN + 16);
 			return hob_header_to_extension_hob(hob);
 		}
@@ -293,8 +172,7 @@ 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);
+	return fsp_find_extension_hob_by_guid(fsp_nv_storage_guid, size);
 }
diff --git a/src/drivers/intel/fsp2_0/hob_display.c b/src/drivers/intel/fsp2_0/hob_display.c
new file mode 100644
index 0000000..f151d90
--- /dev/null
+++ b/src/drivers/intel/fsp2_0/hob_display.c
@@ -0,0 +1,231 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 Intel Corp.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <console/console.h>
+#include <fsp/util.h>
+
+struct hob_type_name {
+	uint16_t type;
+	const char *name;
+} __attribute__((packed));
+
+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" }
+};
+
+static const char *resource_names[] = {
+	[EFI_RESOURCE_SYSTEM_MEMORY]		= "SYSTEM_MEMORY",
+	[EFI_RESOURCE_MEMORY_MAPPED_IO]		= "MMIO",
+	[EFI_RESOURCE_IO]			= "IO",
+	[EFI_RESOURCE_FIRMWARE_DEVICE]		= "FIRMWARE_DEVICE",
+	[EFI_RESOURCE_MEMORY_MAPPED_IO_PORT]	= "MMIO_PORT",
+	[EFI_RESOURCE_MEMORY_RESERVED]		= "MEMORY_RESERVED",
+	[EFI_RESOURCE_IO_RESERVED]		= "IO_RESERVED",
+};
+
+static const uint8_t bootloader_temp_memory_guid[16] = {
+	0x6c, 0xf4, 0xcf, 0xbb, 0xd3, 0xc8, 0x13, 0x41,
+	0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e
+};
+
+static const uint8_t bootloader_tolum_guid[16] = {
+	0x56, 0x4f, 0xff, 0x73, 0x8e, 0xaa, 0x51, 0x44,
+	0xb3, 0x16, 0x36, 0x35, 0x36, 0x67, 0xad, 0x44,
+};
+
+static const uint8_t empty_guid[16] = {
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+static const uint8_t fsp_info_header_guid[16] = {
+	0xbe, 0x40, 0x27, 0x91, 0x84, 0x22, 0x34, 0x47,
+	0xb9, 0x71, 0x84, 0xb0, 0x27, 0x35, 0x3f, 0x0c
+};
+
+static const uint8_t smbios_memory_info_guid[16] = {
+	0x8c, 0x10, 0xa1, 0x01, 0xee, 0x9d, 0x84, 0x49,
+	0x88, 0xc3, 0xee, 0xe8, 0xc4, 0x9e, 0xfb, 0x89
+};
+
+static const uint8_t tseg_guid[16] = {
+	0x7c, 0x74, 0x38, 0xd0, 0x0c, 0xd0, 0x80, 0x49,
+	0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55
+};
+
+struct guid_name_map {
+	const void *guid;
+	const char *name;
+};
+
+static const struct guid_name_map  guid_names[] = {
+	{ bootloader_temp_memory_guid,	"FSP_BOOTLOADER_TEMP_MEMORY_HOB_GUID" },
+	{ bootloader_tolum_guid,	"BOOTLOADER_TOLUM" },
+	{ empty_guid,			"No GUID specified" },
+	{ fsp_info_header_guid,		"FSP_INFO_HEADER_GUID" },
+	{ fsp_reserved_memory_guid,	"FSP_RESERVED_MEMORY" },
+	{ fsp_nv_storage_guid,		"FSP_NV_STORAGE" },
+	{ graphics_info_guid,		"GRAPHICS INFO" },
+	{ smbios_memory_info_guid,	"FSP_SMBIOS_MEMORY_INFO_GUID" },
+	{ tseg_guid,			"TSEG" },
+};
+
+void fsp_print_guid(const void *base)
+{
+	uint32_t big;
+	uint16_t mid[2];
+
+	const uint8_t *id = base;
+	big = read32(id + 0);
+	mid[0] = read16(id + 4);
+	mid[1] = read16(id + 6);
+
+	printk(BIOS_DEBUG, "%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x",
+	       big, mid[0], mid[1],
+	       id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15]);
+}
+
+static const char *resource_name(enum resource_type type)
+{
+	if (type >= ARRAY_SIZE(resource_names))
+		return "UNKNOWN";
+	return resource_names[type];
+}
+
+void fsp_print_resource_descriptor(const void *base)
+{
+	const struct hob_resource *res;
+
+	res = fsp_hob_header_to_resource(base);
+
+	printk(BIOS_DEBUG, "Resource %s, attribute %x\n",
+			   resource_name(res->type), res->attribute_type);
+	printk(BIOS_DEBUG, "\t0x%08llx + 0x%08llx\n", res->addr, res->length);
+	if (!fsp_guid_compare(res->owner_guid, empty_guid)) {
+		printk(BIOS_DEBUG, "\tOwner GUID: ");
+		fsp_print_guid(res->owner_guid);
+		printk(BIOS_DEBUG, " (%s)\n",
+			fsp_get_guid_name(res->owner_guid));
+	}
+}
+
+void fsp_print_memory_resource_hobs(const void *hob_list)
+{
+	const struct hob_header *hob = hob_list;
+
+	for ( ; hob->type != HOB_TYPE_END_OF_HOB_LIST;
+		hob = fsp_next_hob(hob)) {
+		if (hob->type == HOB_TYPE_RESOURCE_DESCRIPTOR)
+			fsp_print_resource_descriptor(hob);
+	}
+}
+
+const char *fsp_get_hob_type_name(const struct hob_header *hob)
+{
+	size_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_get_hob_type_name(hob);
+	if (name != NULL)
+		return name;
+	return "Unknown HOB type";
+}
+
+const char *fsp_get_guid_name(const uint8_t *guid)
+{
+	size_t index;
+	const char *name;
+
+	/* Compare the GUID values in this module */
+	for (index = 0; index < ARRAY_SIZE(guid_names); index++)
+		if (fsp_guid_compare(guid, guid_names[index].guid))
+			return guid_names[index].name;
+
+	/* Get GUID name from SOC */
+	name = soc_get_guid_name(guid);
+	if (name != NULL)
+		return name;
+	return "Unknown GUID";
+}
+
+__attribute__((weak)) const char *soc_get_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 = fsp_hob_header_to_resource(hob);
+	printk(BIOS_SPEW, "\t");
+	fsp_print_guid(res->owner_guid);
+	printk(BIOS_SPEW, ": %s\n", fsp_get_guid_name(res->owner_guid));
+}
+
+__attribute__((weak)) const char *soc_get_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_SPEW, "\n=== FSP HOBs ===\n");
+	printk(BIOS_SPEW, "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:
+			fsp_print_resource_descriptor(hob);
+			break;
+
+		case HOB_TYPE_GUID_EXTENSION:
+			fsp_print_guid_extension_hob(hob);
+			break;
+		}
+		hob = fsp_next_hob(hob);
+	}
+}
+
+__attribute__((weak)) void soc_display_hob(const struct hob_header *hob)
+{
+}
diff --git a/src/drivers/intel/fsp2_0/include/fsp/debug.h b/src/drivers/intel/fsp2_0/include/fsp/debug.h
index 21fc1b7..1c2685c 100644
--- a/src/drivers/intel/fsp2_0/include/fsp/debug.h
+++ b/src/drivers/intel/fsp2_0/include/fsp/debug.h
@@ -29,6 +29,7 @@ void fsp_before_debug_notify(fsp_notify_fn notify,
 void fsp_debug_after_notify(enum fsp_status status);
 void fspm_display_upd_values(const struct FSPM_UPD *old,
 	const struct FSPM_UPD *new);
+void fsp_display_hobs(const struct hob_header *hob_list_ptr);
 
 /* Callbacks for displaying UPD parameters - place in a separate file
  * that is conditionally build with CONFIG_DISPLAY_UPD_DATA.
@@ -38,8 +39,21 @@ void soc_display_fspm_upd_params(const struct FSPM_UPD *fspm_old_upd,
 void soc_display_fsps_upd_params(const struct FSPS_UPD *fsps_old_upd,
 	const struct FSPS_UPD *fsps_new_upd);
 
+/* Callbacks for displaying HOBs - place in a separate file that is
+ * conditionally build with CONFIG_DISPLAY_HOBS.
+ */
+const char *soc_get_hob_type_name(const struct hob_header *hob);
+const char *soc_get_guid_name(const uint8_t *guid);
+void soc_display_hob(const struct hob_header *hob);
+
 /* FSP debug utility functions */
 void fsp_display_upd_value(const char *name, uint32_t size, uint64_t old,
 	uint64_t new);
+void fsp_print_guid(const void *guid);
+void fsp_print_memory_resource_hobs(const void *hob_list);
+void fsp_print_resource_descriptor(const void *base);
+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);
 
 #endif /* _FSP2_0_DEBUG_H_ */
diff --git a/src/drivers/intel/fsp2_0/include/fsp/util.h b/src/drivers/intel/fsp2_0/include/fsp/util.h
index b16a6ec..1774dc8 100644
--- a/src/drivers/intel/fsp2_0/include/fsp/util.h
+++ b/src/drivers/intel/fsp2_0/include/fsp/util.h
@@ -29,13 +29,40 @@ struct fsp_notify_params {
 	enum fsp_notify_phase phase;
 };
 
+struct hob_resource {
+	uint8_t owner_guid[16];
+	uint32_t type;
+	uint32_t attribute_type;
+	uint64_t addr;
+	uint64_t length;
+} __attribute__((packed));
+
+enum hob_type {
+	HOB_TYPE_HANDOFF			= 0x0001,
+	HOB_TYPE_MEMORY_ALLOCATION		= 0x0002,
+	HOB_TYPE_RESOURCE_DESCRIPTOR		= 0x0003,
+	HOB_TYPE_GUID_EXTENSION			= 0x0004,
+	HOB_TYPE_FV				= 0x0005,
+	HOB_TYPE_CPU				= 0x0006,
+	HOB_TYPE_MEMORY_POOL			= 0x0007,
+	HOB_TYPE_FV2				= 0x0009,
+	HOB_TYPE_LOAD_PEIM_UNUSED		= 0x000A,
+	HOB_TYPE_UCAPSULE			= 0x000B,
+	HOB_TYPE_UNUSED				= 0xFFFE,
+	HOB_TYPE_END_OF_HOB_LIST		= 0xFFFF,
+};
+
+extern const uint8_t fsp_graphics_info_guid[16];
+extern const uint8_t fsp_nv_storage_guid[16];
+extern const uint8_t fsp_reserved_memory_guid[16];
+
 /*
  * Hand-off-block handling functions that depend on CBMEM, and thus can only
  * be used after cbmem_initialize().
  */
 void fsp_save_hob_list(void *hob_list_ptr);
 const void *fsp_get_hob_list(void);
-const void *fsp_find_extension_hob_by_uuid(const uint8_t *uuid, size_t *size);
+const void *fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size);
 const void *fsp_find_nv_storage_data(size_t *size);
 enum cb_err fsp_fill_lb_framebuffer(struct lb_framebuffer *framebuffer);
 /*
@@ -43,7 +70,10 @@ enum cb_err fsp_fill_lb_framebuffer(struct lb_framebuffer *framebuffer);
  * the HOB list explicitly.
  */
 void fsp_find_reserved_memory(struct range_entry *re, const void *hob_list);
-void fsp_print_memory_resource_hobs(const void *hob_list);
+const struct hob_resource *fsp_hob_header_to_resource(
+	const struct hob_header *hob);
+const struct hob_header *fsp_next_hob(const struct hob_header *parent);
+bool fsp_guid_compare(const uint8_t guid1[16], const uint8_t guid2[16]);
 
 /* Fill in header and validate sanity of component within region device. */
 enum cb_err fsp_validate_component(struct fsp_header *hdr,



More information about the coreboot-gerrit mailing list