Lee Leahy (leroy.p.leahy@intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15851
-gerrit
commit 68971e08a410c2a0289317b3ae106ad339089330 Author: Lee Leahy leroy.p.leahy@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 debug.h * Move hob_type enum into debug.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@intel.com --- src/drivers/intel/fsp2_0/Kconfig | 6 + src/drivers/intel/fsp2_0/Makefile.inc | 2 + src/drivers/intel/fsp2_0/hand_off_block.c | 68 ++++-------- src/drivers/intel/fsp2_0/hob_display.c | 157 +++++++++++++++++++++++++++ src/drivers/intel/fsp2_0/include/fsp/debug.h | 69 ++++++++++++ src/drivers/intel/fsp2_0/include/fsp/util.h | 7 +- 6 files changed, 262 insertions(+), 47 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 91e86b5..5b8c663 100644 --- a/src/drivers/intel/fsp2_0/Makefile.inc +++ b/src/drivers/intel/fsp2_0/Makefile.inc @@ -16,12 +16,14 @@ ifeq ($(CONFIG_PLATFORM_USES_FSP2_0),y)
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
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/hand_off_block.c b/src/drivers/intel/fsp2_0/hand_off_block.c index ce06a82..d3392cd 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, @@ -50,21 +42,6 @@ static const char *resource_names[] = { [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, @@ -90,15 +67,13 @@ 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[] = { +const struct uuid_name_map 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" }, }; +const size_t uuid_names_entries = ARRAY_SIZE(uuid_names);
static const char *resource_name(enum resource_type type) { @@ -111,7 +86,7 @@ static const char *resource_name(enum resource_type type) * Utilities for walking HOBs */
-static bool uuid_compare(const uint8_t uuid1[16], const uint8_t uuid2[16]) +bool fsp_uuid_compare(const uint8_t uuid1[16], const uint8_t uuid2[16]) { return !memcmp(uuid1, uuid2, 16); } @@ -123,13 +98,13 @@ static const char *uuid_name(const uint8_t uuid[16])
for (i = 0; i < ARRAY_SIZE(uuid_names); i++) { owner_entry = uuid_names + i; - if (uuid_compare(uuid, owner_entry->uuid)) + if (fsp_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; @@ -167,8 +142,8 @@ static const void *hob_header_to_extension_hob(const struct hob_header *hob) 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); } @@ -197,13 +172,14 @@ struct hob_resource *find_resource_hob_by_uuid(const struct hob_header *hob, { 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_uuid_compare(res->owner_guid, uuid)) return res; } return NULL; @@ -228,7 +204,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]; @@ -243,30 +219,30 @@ static void print_guid(const void *base) id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15]); }
-static void print_resource_descriptor(const void *base) +void fsp_print_resource_descriptor(const void *base) { const struct hob_resource *res;
- res = hob_header_to_resource(base); + 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 (!uuid_compare(res->owner_guid, empty_uuid)) { + if (!fsp_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;
- 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) - print_resource_descriptor(hob); + fsp_print_resource_descriptor(hob); } }
@@ -278,13 +254,14 @@ const void *fsp_find_extension_hob_by_uuid(const uint8_t *uuid, size_t *size) 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)) { + if (fsp_uuid_compare(hob_uuid, uuid)) { *size = hob->length - (HOB_HEADER_LEN + 16); return hob_header_to_extension_hob(hob); } @@ -293,7 +270,6 @@ 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); 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..1b10ed4 --- /dev/null +++ b/src/drivers/intel/fsp2_0/hob_display.c @@ -0,0 +1,157 @@ +/* + * 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 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 struct uuid_name_map guid_names[] = { + { 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" }, +}; + +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 hand_off_block.c */ + for (index = 0; index < uuid_names_entries; index++) + if (fsp_uuid_compare(guid, uuid_names[index].uuid)) + return uuid_names[index].name; + + /* Compare the GUID values in this module */ + for (index = 0; index < ARRAY_SIZE(guid_names); index++) + if (fsp_uuid_compare(guid, guid_names[index].uuid)) + 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_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_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_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: + 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 7c48886..8935ce1 100644 --- a/src/drivers/intel/fsp2_0/include/fsp/debug.h +++ b/src/drivers/intel/fsp2_0/include/fsp/debug.h @@ -28,6 +28,66 @@ struct hob_header { 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)); + +struct uuid_name_map { + const void *uuid; + const char *name; +}; + +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 struct uuid_name_map uuid_names[]; +extern const size_t uuid_names_entries; + +/* + * Hand-off-block handling functions that depend on CBMEM, and thus can only + * be used after cbmem_initialize(). + */ +const void *fsp_get_hob_list(void); + +#if IS_ENABLED(CONFIG_DISPLAY_HOBS) +/* Display HOBs API */ +void fsp_display_hobs(const struct hob_header *hob_list_ptr); + +/* 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); + +/* Display HOBs utility functions */ +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); +#else /* CONFIG_DISPLAY_HOBS */ +/* Remove HOB display code from the image */ +static inline __attribute__((always_inline)) void fsp_display_hobs( + const struct hob_header *hob_list_ptr) +{ +} +#endif /* CONFIG_DISPLAY_HOBS */ + /*----------- * MTRRs *----------- @@ -113,6 +173,9 @@ static inline __attribute__((always_inline)) void fsp_debug_memory_init( if (IS_ENABLED(CONFIG_DISPLAY_FSP_CALLS_AND_STATUS)) printk(BIOS_DEBUG, "FspMemoryInit returned 0x%08x\n", status);
+ /* Display the HOBs */ + fsp_display_hobs(hob_list_ptr); + /* Display the MTRRs */ fsp_display_mtrrs(); } @@ -144,6 +207,9 @@ static inline __attribute__((always_inline)) void fsp_debug_silicon_init( if (IS_ENABLED(CONFIG_DISPLAY_FSP_CALLS_AND_STATUS)) printk(BIOS_SPEW, "FspSiliconInit returned 0x%08x\n", status);
+ /* Display the HOBs */ + fsp_display_hobs((const struct hob_header *)fsp_get_hob_list()); + /* Display the MTRRs */ fsp_display_mtrrs(); } @@ -177,6 +243,9 @@ static inline __attribute__((always_inline)) void fsp_debug_notify( if (IS_ENABLED(CONFIG_DISPLAY_FSP_CALLS_AND_STATUS)) printk(BIOS_SPEW, "FspNotify returned 0x%08x\n", status);
+ /* Display the HOBs */ + fsp_display_hobs((const struct hob_header *)fsp_get_hob_list()); + /* Display the MTRRs */ fsp_display_mtrrs(); } diff --git a/src/drivers/intel/fsp2_0/include/fsp/util.h b/src/drivers/intel/fsp2_0/include/fsp/util.h index cc70cc1..c84a017 100644 --- a/src/drivers/intel/fsp2_0/include/fsp/util.h +++ b/src/drivers/intel/fsp2_0/include/fsp/util.h @@ -25,7 +25,6 @@ * 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_nv_storage_data(size_t *size); enum cb_err fsp_fill_lb_framebuffer(struct lb_framebuffer *framebuffer); @@ -34,7 +33,13 @@ 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); +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); +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); +bool fsp_uuid_compare(const uint8_t uuid1[16], const uint8_t uuid2[16]);
/* Fill in header and validate sanity of component within region device. */ enum cb_err fsp_validate_component(struct fsp_header *hdr,