Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 2 | |
| 3 | #include <console/console.h> |
| 4 | #include <fsp/util.h> |
| 5 | |
| 6 | struct hob_type_name { |
| 7 | uint16_t type; |
| 8 | const char *name; |
Stefan Reinauer | 6a00113 | 2017-07-13 02:20:27 +0200 | [diff] [blame] | 9 | } __packed; |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 10 | |
Lee Leahy | b2b97a5 | 2017-03-10 08:40:18 -0800 | [diff] [blame] | 11 | static const struct hob_type_name hob_type_names[] = { |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 12 | { HOB_TYPE_HANDOFF, "HOB_TYPE_HANDOFF" }, |
| 13 | { HOB_TYPE_MEMORY_ALLOCATION, "HOB_TYPE_MEMORY_ALLOCATION" }, |
| 14 | { HOB_TYPE_RESOURCE_DESCRIPTOR, "HOB_TYPE_RESOURCE_DESCRIPTOR" }, |
| 15 | { HOB_TYPE_GUID_EXTENSION, "HOB_TYPE_GUID_EXTENSION" }, |
| 16 | { HOB_TYPE_FV, "HOB_TYPE_FV" }, |
| 17 | { HOB_TYPE_CPU, "HOB_TYPE_CPU" }, |
| 18 | { HOB_TYPE_MEMORY_POOL, "HOB_TYPE_MEMORY_POOL" }, |
| 19 | { HOB_TYPE_FV2, "HOB_TYPE_FV2" }, |
| 20 | { HOB_TYPE_LOAD_PEIM_UNUSED, "HOB_TYPE_LOAD_PEIM_UNUSED" }, |
| 21 | { HOB_TYPE_UCAPSULE, "HOB_TYPE_UCAPSULE" }, |
| 22 | { HOB_TYPE_UNUSED, "HOB_TYPE_UNUSED" }, |
| 23 | { HOB_TYPE_END_OF_HOB_LIST, "HOB_TYPE_END_OF_HOB_LIST" } |
| 24 | }; |
| 25 | |
| 26 | static const char *resource_names[] = { |
| 27 | [EFI_RESOURCE_SYSTEM_MEMORY] = "SYSTEM_MEMORY", |
| 28 | [EFI_RESOURCE_MEMORY_MAPPED_IO] = "MMIO", |
| 29 | [EFI_RESOURCE_IO] = "IO", |
| 30 | [EFI_RESOURCE_FIRMWARE_DEVICE] = "FIRMWARE_DEVICE", |
| 31 | [EFI_RESOURCE_MEMORY_MAPPED_IO_PORT] = "MMIO_PORT", |
| 32 | [EFI_RESOURCE_MEMORY_RESERVED] = "MEMORY_RESERVED", |
| 33 | [EFI_RESOURCE_IO_RESERVED] = "IO_RESERVED", |
| 34 | }; |
| 35 | |
| 36 | static const uint8_t bootloader_temp_memory_guid[16] = { |
| 37 | 0x6c, 0xf4, 0xcf, 0xbb, 0xd3, 0xc8, 0x13, 0x41, |
| 38 | 0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e |
| 39 | }; |
| 40 | |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 41 | static const uint8_t empty_guid[16] = { |
| 42 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 43 | }; |
| 44 | |
Lee Leahy | 5a9ca4d | 2016-09-28 17:15:00 -0700 | [diff] [blame] | 45 | static const uint8_t fsp_graphics_info_guid[16] = { |
| 46 | 0xce, 0x2c, 0xf6, 0x39, 0x25, 0x68, 0x69, 0x46, |
| 47 | 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07 |
| 48 | }; |
| 49 | |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 50 | static const uint8_t fsp_info_header_guid[16] = { |
| 51 | 0xbe, 0x40, 0x27, 0x91, 0x84, 0x22, 0x34, 0x47, |
| 52 | 0xb9, 0x71, 0x84, 0xb0, 0x27, 0x35, 0x3f, 0x0c |
| 53 | }; |
| 54 | |
| 55 | static const uint8_t smbios_memory_info_guid[16] = { |
| 56 | 0x8c, 0x10, 0xa1, 0x01, 0xee, 0x9d, 0x84, 0x49, |
| 57 | 0x88, 0xc3, 0xee, 0xe8, 0xc4, 0x9e, 0xfb, 0x89 |
| 58 | }; |
| 59 | |
| 60 | static const uint8_t tseg_guid[16] = { |
| 61 | 0x7c, 0x74, 0x38, 0xd0, 0x0c, 0xd0, 0x80, 0x49, |
| 62 | 0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55 |
| 63 | }; |
| 64 | |
| 65 | struct guid_name_map { |
| 66 | const void *guid; |
| 67 | const char *name; |
| 68 | }; |
| 69 | |
| 70 | static const struct guid_name_map guid_names[] = { |
| 71 | { bootloader_temp_memory_guid, "FSP_BOOTLOADER_TEMP_MEMORY_HOB_GUID" }, |
Lee Leahy | 52d0c68 | 2016-08-01 15:47:42 -0700 | [diff] [blame] | 72 | { fsp_bootloader_tolum_guid, "BOOTLOADER_TOLUM" }, |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 73 | { empty_guid, "No GUID specified" }, |
| 74 | { fsp_info_header_guid, "FSP_INFO_HEADER_GUID" }, |
| 75 | { fsp_reserved_memory_guid, "FSP_RESERVED_MEMORY" }, |
| 76 | { fsp_nv_storage_guid, "FSP_NV_STORAGE" }, |
Lee Leahy | 5a9ca4d | 2016-09-28 17:15:00 -0700 | [diff] [blame] | 77 | { fsp_graphics_info_guid, "GRAPHICS INFO" }, |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 78 | { smbios_memory_info_guid, "FSP_SMBIOS_MEMORY_INFO_GUID" }, |
| 79 | { tseg_guid, "TSEG" }, |
| 80 | }; |
| 81 | |
Subrata Banik | a3af8eb | 2018-02-26 17:16:26 +0530 | [diff] [blame] | 82 | static const char *resource_name(uint32_t type) |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 83 | { |
| 84 | if (type >= ARRAY_SIZE(resource_names)) |
| 85 | return "UNKNOWN"; |
| 86 | return resource_names[type]; |
| 87 | } |
| 88 | |
| 89 | void fsp_print_resource_descriptor(const void *base) |
| 90 | { |
| 91 | const struct hob_resource *res; |
| 92 | |
| 93 | res = fsp_hob_header_to_resource(base); |
| 94 | |
| 95 | printk(BIOS_SPEW, "Resource %s, attribute %x\n", |
| 96 | resource_name(res->type), res->attribute_type); |
| 97 | printk(BIOS_SPEW, "\t0x%08llx + 0x%08llx\n", res->addr, res->length); |
| 98 | if (!fsp_guid_compare(res->owner_guid, empty_guid)) { |
| 99 | printk(BIOS_SPEW, "\tOwner GUID: "); |
Felix Held | 50c0a6d | 2022-11-14 22:11:56 +0100 | [diff] [blame] | 100 | fsp_print_guid(BIOS_SPEW, res->owner_guid); |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 101 | printk(BIOS_SPEW, " (%s)\n", |
| 102 | fsp_get_guid_name(res->owner_guid)); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | void fsp_print_memory_resource_hobs(void) |
| 107 | { |
| 108 | const struct hob_header *hob = fsp_get_hob_list(); |
| 109 | |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 110 | for (; hob->type != HOB_TYPE_END_OF_HOB_LIST; |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 111 | hob = fsp_next_hob(hob)) { |
| 112 | if (hob->type == HOB_TYPE_RESOURCE_DESCRIPTOR) |
| 113 | fsp_print_resource_descriptor(hob); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | const char *fsp_get_hob_type_name(const struct hob_header *hob) |
| 118 | { |
| 119 | size_t index; |
| 120 | const char *name; |
| 121 | |
| 122 | for (index = 0; index < ARRAY_SIZE(hob_type_names); index++) |
| 123 | if (hob->type == hob_type_names[index].type) |
| 124 | return hob_type_names[index].name; |
| 125 | |
| 126 | /* Get name for SOC specific hob */ |
| 127 | name = soc_get_hob_type_name(hob); |
| 128 | if (name != NULL) |
| 129 | return name; |
| 130 | return "Unknown HOB type"; |
| 131 | } |
| 132 | |
| 133 | const char *fsp_get_guid_name(const uint8_t *guid) |
| 134 | { |
| 135 | size_t index; |
| 136 | const char *name; |
| 137 | |
| 138 | /* Compare the GUID values in this module */ |
| 139 | for (index = 0; index < ARRAY_SIZE(guid_names); index++) |
| 140 | if (fsp_guid_compare(guid, guid_names[index].guid)) |
| 141 | return guid_names[index].name; |
| 142 | |
| 143 | /* Get GUID name from SOC */ |
| 144 | name = soc_get_guid_name(guid); |
| 145 | if (name != NULL) |
| 146 | return name; |
| 147 | return "Unknown GUID"; |
| 148 | } |
| 149 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 150 | __weak const char *soc_get_hob_type_name( |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 151 | const struct hob_header *hob) |
| 152 | { |
| 153 | return NULL; |
| 154 | } |
| 155 | |
| 156 | void fsp_print_guid_extension_hob(const struct hob_header *hob) |
| 157 | { |
| 158 | const struct hob_resource *res; |
| 159 | |
| 160 | res = fsp_hob_header_to_resource(hob); |
| 161 | printk(BIOS_SPEW, "\t"); |
Felix Held | 50c0a6d | 2022-11-14 22:11:56 +0100 | [diff] [blame] | 162 | fsp_print_guid(BIOS_SPEW, res->owner_guid); |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 163 | printk(BIOS_SPEW, ": %s\n", fsp_get_guid_name(res->owner_guid)); |
Jonathan Zhang | f381d97 | 2020-05-20 10:13:12 -0700 | [diff] [blame] | 164 | |
| 165 | /* Some of the SoC FSP specific hobs are of type HOB_TYPE_GUID_EXTENSION */ |
| 166 | soc_display_hob(hob); |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 167 | } |
| 168 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 169 | __weak const char *soc_get_guid_name(const uint8_t *guid) |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 170 | { |
| 171 | return NULL; |
| 172 | } |
| 173 | |
| 174 | void fsp_display_hobs(void) |
| 175 | { |
| 176 | const struct hob_header *hob = fsp_get_hob_list(); |
| 177 | |
| 178 | /* Display the HOB list pointer */ |
| 179 | printk(BIOS_SPEW, "\n=== FSP HOBs ===\n"); |
Julius Werner | 540a980 | 2019-12-09 13:03:29 -0800 | [diff] [blame] | 180 | printk(BIOS_SPEW, "%p: hob_list_ptr\n", hob); |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 181 | |
| 182 | /* Walk the list of HOBs */ |
| 183 | while (1) { |
| 184 | /* Display the HOB header */ |
Julius Werner | 540a980 | 2019-12-09 13:03:29 -0800 | [diff] [blame] | 185 | printk(BIOS_SPEW, "%p, 0x%08x bytes: %s\n", hob, hob->length, |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 186 | fsp_get_hob_type_name(hob)); |
Lee Leahy | b2b97a5 | 2017-03-10 08:40:18 -0800 | [diff] [blame] | 187 | switch (hob->type) { |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 188 | default: |
| 189 | soc_display_hob(hob); |
| 190 | break; |
| 191 | |
| 192 | case HOB_TYPE_END_OF_HOB_LIST: |
| 193 | printk(BIOS_SPEW, "=== End of FSP HOBs ===\n\n"); |
| 194 | return; |
| 195 | |
| 196 | case HOB_TYPE_RESOURCE_DESCRIPTOR: |
| 197 | fsp_print_resource_descriptor(hob); |
| 198 | break; |
| 199 | |
| 200 | case HOB_TYPE_GUID_EXTENSION: |
| 201 | fsp_print_guid_extension_hob(hob); |
| 202 | break; |
| 203 | } |
| 204 | hob = fsp_next_hob(hob); |
| 205 | } |
| 206 | } |
| 207 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 208 | __weak void soc_display_hob(const struct hob_header *hob) |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 209 | { |
| 210 | } |