diff options
Diffstat (limited to 'src/drivers/intel')
-rw-r--r-- | src/drivers/intel/fsp2_0/Kconfig | 6 | ||||
-rw-r--r-- | src/drivers/intel/fsp2_0/Makefile.inc | 2 | ||||
-rw-r--r-- | src/drivers/intel/fsp2_0/debug.c | 19 | ||||
-rw-r--r-- | src/drivers/intel/fsp2_0/graphics.c | 4 | ||||
-rw-r--r-- | src/drivers/intel/fsp2_0/hand_off_block.c | 190 | ||||
-rw-r--r-- | src/drivers/intel/fsp2_0/hob_display.c | 231 | ||||
-rw-r--r-- | src/drivers/intel/fsp2_0/include/fsp/debug.h | 19 | ||||
-rw-r--r-- | src/drivers/intel/fsp2_0/include/fsp/util.h | 52 | ||||
-rw-r--r-- | src/drivers/intel/fsp2_0/memory_init.c | 21 |
9 files changed, 358 insertions, 186 deletions
diff --git a/src/drivers/intel/fsp2_0/Kconfig b/src/drivers/intel/fsp2_0/Kconfig index 32dbb59906..06f1a7c331 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 cc496eedec..2b1754ef1a 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 b34910b6fe..ffc9d4fc24 100644 --- a/src/drivers/intel/fsp2_0/debug.c +++ b/src/drivers/intel/fsp2_0/debug.c @@ -19,7 +19,7 @@ */ void fsp_debug_before_memory_init(fsp_memory_init_fn memory_init, const struct FSPM_UPD *fspm_old_upd, - const struct FSPM_UPD *fspm_new_upd, void **hob_list_ptr) + const struct FSPM_UPD *fspm_new_upd) { /* Display the MTRRs */ if (IS_ENABLED(CONFIG_DISPLAY_MTRRS)) @@ -34,15 +34,18 @@ void fsp_debug_before_memory_init(fsp_memory_init_fn memory_init, return; printk(BIOS_DEBUG, "Calling FspMemoryInit: 0x%p\n", memory_init); printk(BIOS_SPEW, "\t0x%p: raminit_upd\n", fspm_new_upd); - printk(BIOS_SPEW, "\t0x%p: &hob_list_ptr\n", hob_list_ptr); + printk(BIOS_SPEW, "\t0x%p: &hob_list_ptr\n", fsp_get_hob_list_ptr()); } -void fsp_debug_after_memory_init(enum fsp_status status, - const struct hob_header *hob_list_ptr) +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(); + /* Display the MTRRs */ if (IS_ENABLED(CONFIG_DISPLAY_MTRRS)) soc_display_mtrrs(); @@ -76,6 +79,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(); + /* Display the MTRRs */ if (IS_ENABLED(CONFIG_DISPLAY_MTRRS)) soc_display_mtrrs(); @@ -102,6 +109,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(); + /* 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 f4ba40220f..039202faa4 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 ce06a8283b..a979ac6cff 100644 --- a/src/drivers/intel/fsp2_0/hand_off_block.c +++ b/src/drivers/intel/fsp2_0/hand_off_block.c @@ -10,6 +10,7 @@ * (at your option) any later version. */ +#include <arch/early_variables.h> #include <arch/io.h> #include <cbmem.h> #include <commonlib/helpers.h> @@ -21,14 +22,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 +33,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]) -{ - return !memcmp(uuid1, uuid2, 16); -} - -static const char *uuid_name(const uint8_t uuid[16]) +bool fsp_guid_compare(const uint8_t guid1[16], const uint8_t guid2[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"; + return !memcmp(guid1, guid2, 16); } -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 +87,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); } @@ -177,45 +101,59 @@ struct hob_resource *hob_header_to_resource(const struct hob_header *hob) * Utilities for locating and identifying HOBs */ -void fsp_save_hob_list(void *hob_list_ptr) +static void *fsp_hob_list_ptr CAR_GLOBAL; + +static void save_hob_list(int is_recovery) { uint32_t *cbmem_loc; cbmem_loc = cbmem_add(CBMEM_ID_FSP_RUNTIME, sizeof(*cbmem_loc)); - *cbmem_loc = (uintptr_t)hob_list_ptr; + *cbmem_loc = (uintptr_t)fsp_get_hob_list(); } +ROMSTAGE_CBMEM_INIT_HOOK(save_hob_list); + const void *fsp_get_hob_list(void) { - uint32_t *list_loc = cbmem_find(CBMEM_ID_FSP_RUNTIME); + uint32_t *list_loc; + if (ENV_ROMSTAGE) + return (void *)car_get_var(fsp_hob_list_ptr); + list_loc = cbmem_find(CBMEM_ID_FSP_RUNTIME); return (list_loc) ? (void *)(uintptr_t)(*list_loc) : NULL; } +void *fsp_get_hob_list_ptr(void) +{ + return car_get_var_ptr(&fsp_hob_list_ptr); +} + 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; } -void fsp_find_reserved_memory(struct range_entry *re, const void *hob_list) +void fsp_find_reserved_memory(struct range_entry *re) { const struct hob_resource *fsp_mem; + const void *hob_list = fsp_get_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 +162,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 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 void *fsp_find_extension_hob_by_guid(const uint8_t *guid, 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 +186,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 0000000000..048d8606e4 --- /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_SPEW, "%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_SPEW, "Resource %s, attribute %x\n", + resource_name(res->type), res->attribute_type); + printk(BIOS_SPEW, "\t0x%08llx + 0x%08llx\n", res->addr, res->length); + if (!fsp_guid_compare(res->owner_guid, empty_guid)) { + printk(BIOS_SPEW, "\tOwner GUID: "); + fsp_print_guid(res->owner_guid); + printk(BIOS_SPEW, " (%s)\n", + fsp_get_guid_name(res->owner_guid)); + } +} + +void fsp_print_memory_resource_hobs(void) +{ + const struct hob_header *hob = fsp_get_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(void) +{ + const struct hob_header *hob = fsp_get_hob_list(); + + /* 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_SPEW, "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_SPEW, "=== 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 21e175478f..ca433e2ea2 100644 --- a/src/drivers/intel/fsp2_0/include/fsp/debug.h +++ b/src/drivers/intel/fsp2_0/include/fsp/debug.h @@ -17,9 +17,8 @@ /* FSP debug API */ void fsp_debug_before_memory_init(fsp_memory_init_fn memory_init, const struct FSPM_UPD *fspm_old_upd, - const struct FSPM_UPD *fspm_new_upd, void **hob_list_ptr); -void fsp_debug_after_memory_init(enum fsp_status status, - const struct hob_header *hob_list_ptr); + const struct FSPM_UPD *fspm_new_upd); +void fsp_debug_after_memory_init(enum fsp_status status); void fsp_debug_before_silicon_init(fsp_silicon_init_fn silicon_init, const struct FSPS_UPD *fsps_old_upd, const struct FSPS_UPD *fsps_new_upd); @@ -29,6 +28,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(void); /* Callbacks for displaying UPD parameters - place in a separate file * that is conditionally build with CONFIG_DISPLAY_UPD_DATA. @@ -38,8 +38,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, size_t size, uint64_t old, uint64_t new); +void fsp_print_guid(const void *guid); +void fsp_print_memory_resource_hobs(void); +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 b16a6ec964..36bb7b0af9 100644 --- a/src/drivers/intel/fsp2_0/include/fsp/util.h +++ b/src/drivers/intel/fsp2_0/include/fsp/util.h @@ -29,21 +29,43 @@ struct fsp_notify_params { enum fsp_notify_phase phase; }; -/* - * 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); +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]; + const void *fsp_get_hob_list(void); -const void *fsp_find_extension_hob_by_uuid(const uint8_t *uuid, size_t *size); +void *fsp_get_hob_list_ptr(void); +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); -/* - * Hand-off-block utilities which do not depend on CBMEM, but need to be passed - * 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); +void fsp_find_reserved_memory(struct range_entry *re); +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, @@ -65,10 +87,8 @@ void chipset_handle_reset(enum fsp_status status); typedef asmlinkage enum fsp_status (*fsp_memory_init_fn) (void *raminit_upd, void **hob_list); -typedef asmlinkage enum fsp_status (*fsp_silicon_init_fn) - (void *silicon_upd); -typedef asmlinkage enum fsp_status (*fsp_notify_fn) - (struct fsp_notify_params *); +typedef asmlinkage enum fsp_status (*fsp_silicon_init_fn)(void *silicon_upd); +typedef asmlinkage enum fsp_status (*fsp_notify_fn)(struct fsp_notify_params *); #include <fsp/debug.h> #endif /* _FSP2_0_UTIL_H_ */ diff --git a/src/drivers/intel/fsp2_0/memory_init.c b/src/drivers/intel/fsp2_0/memory_init.c index 7aaed3c20f..e55b9e5e0b 100644 --- a/src/drivers/intel/fsp2_0/memory_init.c +++ b/src/drivers/intel/fsp2_0/memory_init.c @@ -62,13 +62,13 @@ static void save_memory_training_data(bool s3wake, uint32_t fsp_version) */ #define MRC_DEAD_VERSION (0xdeaddead) -static enum fsp_status do_fsp_post_memory_init(void *hob_list_ptr, bool s3wake, - uint32_t fsp_version) +static enum fsp_status do_fsp_post_memory_init(bool s3wake, + uint32_t fsp_version) { struct range_entry fsp_mem; struct romstage_handoff *handoff; - fsp_find_reserved_memory(&fsp_mem, hob_list_ptr); + fsp_find_reserved_memory(&fsp_mem); /* initialize cbmem by adding FSP reserved memory first thing */ if (!s3wake) { @@ -77,7 +77,8 @@ static enum fsp_status do_fsp_post_memory_init(void *hob_list_ptr, bool s3wake, } else if (cbmem_initialize_id_size(CBMEM_ID_FSP_RESERVED_MEMORY, range_entry_size(&fsp_mem))) { if (IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)) { - printk(BIOS_DEBUG, "Failed to recover CBMEM in S3 resume.\n"); + printk(BIOS_DEBUG, + "Failed to recover CBMEM in S3 resume.\n"); /* Failed S3 resume, reset to come up cleanly */ hard_reset(); } @@ -89,8 +90,6 @@ static enum fsp_status do_fsp_post_memory_init(void *hob_list_ptr, bool s3wake, die("Failed to accommodate FSP reserved memory request"); /* Now that CBMEM is up, save the list so ramstage can use it */ - fsp_save_hob_list(hob_list_ptr); - if (vboot_recovery_mode_enabled()) fsp_version = MRC_DEAD_VERSION; @@ -189,7 +188,6 @@ static enum fsp_status do_fsp_memory_init(struct fsp_header *hdr, bool s3wake, enum fsp_status status; fsp_memory_init_fn fsp_raminit; struct FSPM_UPD fspm_upd, *upd; - void *hob_list_ptr; struct FSPM_ARCH_UPD *arch_upd; post_code(0x34); @@ -219,16 +217,15 @@ static enum fsp_status do_fsp_memory_init(struct fsp_header *hdr, bool s3wake, /* Call FspMemoryInit */ fsp_raminit = (void *)(hdr->image_base + hdr->memory_init_entry_offset); - fsp_debug_before_memory_init(fsp_raminit, upd, &fspm_upd, - &hob_list_ptr); + fsp_debug_before_memory_init(fsp_raminit, upd, &fspm_upd); post_code(POST_FSP_MEMORY_INIT); timestamp_add_now(TS_FSP_MEMORY_INIT_START); - status = fsp_raminit(&fspm_upd, &hob_list_ptr); + status = fsp_raminit(&fspm_upd, fsp_get_hob_list_ptr()); post_code(POST_FSP_MEMORY_INIT); timestamp_add_now(TS_FSP_MEMORY_INIT_END); - fsp_debug_after_memory_init(status, hob_list_ptr); + fsp_debug_after_memory_init(status); /* Handle any resets requested by FSPM. */ fsp_handle_reset(status); @@ -236,7 +233,7 @@ static enum fsp_status do_fsp_memory_init(struct fsp_header *hdr, bool s3wake, if (status != FSP_SUCCESS) return status; - return do_fsp_post_memory_init(hob_list_ptr, s3wake, hdr->fsp_revision); + return do_fsp_post_memory_init(s3wake, hdr->fsp_revision); } /* Load the binary into the memory specified by the info header. */ |