Angel Pons | 8a3453f | 2020-04-02 23:48:19 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 2 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 3 | #include <arch/hlt.h> |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 4 | #include <console/console.h> |
Aaron Durbin | 789f2b6 | 2015-09-09 17:05:06 -0500 | [diff] [blame] | 5 | #include <fsp/util.h> |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 6 | #include <ip_checksum.h> |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 7 | #include <string.h> |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 8 | |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 9 | /* Compares two EFI GUIDs. Returns true of the GUIDs match, false otherwise. */ |
| 10 | static bool compare_guid(const EFI_GUID *guid1, const EFI_GUID *guid2) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 11 | { |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 12 | return !memcmp(guid1, guid2, sizeof(EFI_GUID)); |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | /* Returns the pointer to the HOB list. */ |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 16 | void *get_hob_list(void) |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 17 | { |
| 18 | void *hob_list; |
| 19 | |
| 20 | hob_list = fsp_get_hob_list(); |
| 21 | if (hob_list == NULL) |
| 22 | die("Call fsp_set_runtime() before this call!\n"); |
| 23 | return hob_list; |
| 24 | } |
| 25 | |
| 26 | /* Returns the next instance of a HOB type from the starting HOB. */ |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 27 | void *get_next_hob(uint16_t type, const void *hob_start) |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 28 | { |
| 29 | EFI_PEI_HOB_POINTERS hob; |
| 30 | |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 31 | if (!hob_start) |
| 32 | return NULL; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 33 | |
| 34 | hob.Raw = (UINT8 *)hob_start; |
| 35 | |
| 36 | /* Parse the HOB list until end of list or matching type is found. */ |
| 37 | while (!END_OF_HOB_LIST(hob.Raw)) { |
| 38 | if (hob.Header->HobType == type) |
| 39 | return hob.Raw; |
| 40 | if (GET_HOB_LENGTH(hob.Raw) < sizeof(*hob.Header)) |
| 41 | break; |
| 42 | hob.Raw = GET_NEXT_HOB(hob.Raw); |
| 43 | } |
| 44 | return NULL; |
| 45 | } |
| 46 | |
| 47 | /* Returns the first instance of a HOB type among the whole HOB list. */ |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 48 | void *get_first_hob(uint16_t type) |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 49 | { |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 50 | return get_next_hob(type, get_hob_list()); |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /* Returns the next instance of the matched GUID HOB from the starting HOB. */ |
Lee Leahy | 216712a | 2017-03-17 11:23:32 -0700 | [diff] [blame] | 54 | void *get_next_guid_hob(const EFI_GUID *guid, const void *hob_start) |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 55 | { |
| 56 | EFI_PEI_HOB_POINTERS hob; |
| 57 | |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 58 | hob.Raw = (uint8_t *)hob_start; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 59 | while ((hob.Raw = get_next_hob(EFI_HOB_TYPE_GUID_EXTENSION, hob.Raw)) |
| 60 | != NULL) { |
| 61 | if (compare_guid(guid, &hob.Guid->Name)) |
| 62 | break; |
| 63 | hob.Raw = GET_NEXT_HOB(hob.Raw); |
| 64 | } |
| 65 | return hob.Raw; |
| 66 | } |
| 67 | |
| 68 | /* |
| 69 | * Returns the first instance of the matched GUID HOB among the whole HOB list. |
| 70 | */ |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 71 | void *get_first_guid_hob(const EFI_GUID *guid) |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 72 | { |
| 73 | return get_next_guid_hob(guid, get_hob_list()); |
| 74 | } |
| 75 | |
| 76 | /* |
| 77 | * Returns the next instance of the matching resource HOB from the starting HOB. |
| 78 | */ |
| 79 | void *get_next_resource_hob(const EFI_GUID *guid, const void *hob_start) |
| 80 | { |
| 81 | EFI_PEI_HOB_POINTERS hob; |
| 82 | |
| 83 | hob.Raw = (UINT8 *)hob_start; |
| 84 | while ((hob.Raw = get_next_hob(EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, |
| 85 | hob.Raw)) != NULL) { |
| 86 | if (compare_guid(guid, &hob.ResourceDescriptor->Owner)) |
| 87 | break; |
| 88 | hob.Raw = GET_NEXT_HOB(hob.Raw); |
| 89 | } |
| 90 | return hob.Raw; |
| 91 | } |
| 92 | |
| 93 | /* |
| 94 | * Returns the first instance of the matching resource HOB among the whole HOB |
| 95 | * list. |
| 96 | */ |
| 97 | void *get_first_resource_hob(const EFI_GUID *guid) |
| 98 | { |
| 99 | return get_next_resource_hob(guid, get_hob_list()); |
| 100 | } |
| 101 | |
| 102 | static void print_hob_mem_attributes(void *hob_ptr) |
| 103 | { |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 104 | EFI_MEMORY_TYPE hob_mem_type; |
| 105 | EFI_HOB_MEMORY_ALLOCATION *hob_memory_ptr = hob_ptr; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 106 | u64 hob_mem_addr = hob_memory_ptr->AllocDescriptor.MemoryBaseAddress; |
| 107 | u64 hob_mem_length = hob_memory_ptr->AllocDescriptor.MemoryLength; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 108 | |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 109 | hob_mem_type = hob_memory_ptr->AllocDescriptor.MemoryType; |
| 110 | |
| 111 | static const char *hob_mem_type_names[15] = { |
| 112 | [EfiReservedMemoryType] = "EfiReservedMemoryType", |
| 113 | [EfiLoaderCode] = "EfiLoaderCode", |
| 114 | [EfiLoaderData] = "EfiLoaderData", |
| 115 | [EfiBootServicesCode] = "EfiBootServicesCode", |
| 116 | [EfiBootServicesData] = "EfiBootServicesData", |
| 117 | [EfiRuntimeServicesCode] = "EfiRuntimeServicesCode", |
| 118 | [EfiRuntimeServicesData] = "EfiRuntimeServicesData", |
| 119 | [EfiConventionalMemory] = "EfiConventionalMemory", |
| 120 | [EfiUnusableMemory] = "EfiUnusableMemory", |
| 121 | [EfiACPIReclaimMemory] = "EfiACPIReclaimMemory", |
| 122 | [EfiACPIMemoryNVS] = "EfiACPIMemoryNVS", |
| 123 | [EfiMemoryMappedIO] = "EfiMemoryMappedIO", |
| 124 | [EfiMemoryMappedIOPortSpace] = "EfiMemoryMappedIOPortSpace", |
| 125 | [EfiPalCode] = "EfiPalCode", |
| 126 | [EfiMaxMemoryType] = "EfiMaxMemoryType", |
| 127 | }; |
| 128 | |
| 129 | if (hob_mem_type >= ARRAY_SIZE(hob_mem_type_names)) |
| 130 | hob_mem_type = EfiReservedMemoryType; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 131 | |
| 132 | printk(BIOS_SPEW, " Memory type %s (0x%x)\n", |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 133 | hob_mem_type_names[hob_mem_type], |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 134 | (u32)hob_mem_type); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 135 | printk(BIOS_SPEW, " at location 0x%0lx with length 0x%0lx\n", |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 136 | (unsigned long)hob_mem_addr, |
| 137 | (unsigned long)hob_mem_length); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 138 | } |
| 139 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 140 | static void print_hob_resource_attributes(void *hob_ptr) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 141 | { |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 142 | EFI_HOB_RESOURCE_DESCRIPTOR *hob_resource_ptr = |
| 143 | (EFI_HOB_RESOURCE_DESCRIPTOR *)hob_ptr; |
| 144 | u32 hob_res_type = hob_resource_ptr->ResourceType; |
| 145 | u32 hob_res_attr = hob_resource_ptr->ResourceAttribute; |
| 146 | u64 hob_res_addr = hob_resource_ptr->PhysicalStart; |
| 147 | u64 hob_res_length = hob_resource_ptr->ResourceLength; |
| 148 | const char *hob_res_type_str = NULL; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 149 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 150 | /* HOB Resource Types */ |
| 151 | switch (hob_res_type) { |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 152 | case EFI_RESOURCE_SYSTEM_MEMORY: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 153 | hob_res_type_str = "EFI_RESOURCE_SYSTEM_MEMORY"; |
| 154 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 155 | case EFI_RESOURCE_MEMORY_MAPPED_IO: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 156 | hob_res_type_str = "EFI_RESOURCE_MEMORY_MAPPED_IO"; |
| 157 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 158 | case EFI_RESOURCE_IO: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 159 | hob_res_type_str = "EFI_RESOURCE_IO"; |
| 160 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 161 | case EFI_RESOURCE_FIRMWARE_DEVICE: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 162 | hob_res_type_str = "EFI_RESOURCE_FIRMWARE_DEVICE"; |
| 163 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 164 | case EFI_RESOURCE_MEMORY_MAPPED_IO_PORT: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 165 | hob_res_type_str = "EFI_RESOURCE_MEMORY_MAPPED_IO_PORT"; |
| 166 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 167 | case EFI_RESOURCE_MEMORY_RESERVED: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 168 | hob_res_type_str = "EFI_RESOURCE_MEMORY_RESERVED"; |
| 169 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 170 | case EFI_RESOURCE_IO_RESERVED: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 171 | hob_res_type_str = "EFI_RESOURCE_IO_RESERVED"; |
| 172 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 173 | case EFI_RESOURCE_MAX_MEMORY_TYPE: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 174 | hob_res_type_str = "EFI_RESOURCE_MAX_MEMORY_TYPE"; |
| 175 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 176 | default: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 177 | hob_res_type_str = "EFI_RESOURCE_UNKNOWN"; |
| 178 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | printk(BIOS_SPEW, " Resource %s (0x%0x) has attributes 0x%0x\n", |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 182 | hob_res_type_str, hob_res_type, hob_res_attr); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 183 | printk(BIOS_SPEW, " at location 0x%0lx with length 0x%0lx\n", |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 184 | (unsigned long)hob_res_addr, |
| 185 | (unsigned long)hob_res_length); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 186 | } |
| 187 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 188 | static const char *get_hob_type_string(void *hob_ptr) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 189 | { |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 190 | EFI_PEI_HOB_POINTERS hob; |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 191 | const char *hob_type_string; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 192 | const EFI_GUID fsp_reserved_guid = |
| 193 | FSP_RESERVED_MEMORY_RESOURCE_HOB_GUID; |
| 194 | const EFI_GUID mrc_guid = FSP_NON_VOLATILE_STORAGE_HOB_GUID; |
| 195 | const EFI_GUID bootldr_tmp_mem_guid = |
| 196 | FSP_BOOTLOADER_TEMP_MEMORY_HOB_GUID; |
| 197 | const EFI_GUID bootldr_tolum_guid = FSP_BOOTLOADER_TOLUM_HOB_GUID; |
| 198 | const EFI_GUID graphics_info_guid = EFI_PEI_GRAPHICS_INFO_HOB_GUID; |
Lee Leahy | 4a8c19c | 2015-06-16 14:33:30 -0700 | [diff] [blame] | 199 | const EFI_GUID memory_info_hob_guid = FSP_SMBIOS_MEMORY_INFO_GUID; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 200 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 201 | hob.Header = (EFI_HOB_GENERIC_HEADER *)hob_ptr; |
| 202 | switch (hob.Header->HobType) { |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 203 | case EFI_HOB_TYPE_HANDOFF: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 204 | hob_type_string = "EFI_HOB_TYPE_HANDOFF"; |
| 205 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 206 | case EFI_HOB_TYPE_MEMORY_ALLOCATION: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 207 | hob_type_string = "EFI_HOB_TYPE_MEMORY_ALLOCATION"; |
| 208 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 209 | case EFI_HOB_TYPE_RESOURCE_DESCRIPTOR: |
Lee Leahy | 4a8c19c | 2015-06-16 14:33:30 -0700 | [diff] [blame] | 210 | if (compare_guid(&fsp_reserved_guid, &hob.Guid->Name)) |
| 211 | hob_type_string = "FSP_RESERVED_MEMORY_RESOURCE_HOB"; |
| 212 | else if (compare_guid(&bootldr_tolum_guid, &hob.Guid->Name)) |
| 213 | hob_type_string = "FSP_BOOTLOADER_TOLUM_HOB_GUID"; |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 214 | else |
| 215 | hob_type_string = "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR"; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 216 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 217 | case EFI_HOB_TYPE_GUID_EXTENSION: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 218 | if (compare_guid(&bootldr_tmp_mem_guid, &hob.Guid->Name)) |
| 219 | hob_type_string = "FSP_BOOTLOADER_TEMP_MEMORY_HOB"; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 220 | else if (compare_guid(&mrc_guid, &hob.Guid->Name)) |
| 221 | hob_type_string = "FSP_NON_VOLATILE_STORAGE_HOB"; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 222 | else if (compare_guid(&graphics_info_guid, &hob.Guid->Name)) |
| 223 | hob_type_string = "EFI_PEI_GRAPHICS_INFO_HOB_GUID"; |
Lee Leahy | 4a8c19c | 2015-06-16 14:33:30 -0700 | [diff] [blame] | 224 | else if (compare_guid(&memory_info_hob_guid, &hob.Guid->Name)) |
| 225 | hob_type_string = "FSP_SMBIOS_MEMORY_INFO_GUID"; |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 226 | else |
| 227 | hob_type_string = "EFI_HOB_TYPE_GUID_EXTENSION"; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 228 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 229 | case EFI_HOB_TYPE_MEMORY_POOL: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 230 | hob_type_string = "EFI_HOB_TYPE_MEMORY_POOL"; |
| 231 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 232 | case EFI_HOB_TYPE_UNUSED: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 233 | hob_type_string = "EFI_HOB_TYPE_UNUSED"; |
| 234 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 235 | case EFI_HOB_TYPE_END_OF_HOB_LIST: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 236 | hob_type_string = "EFI_HOB_TYPE_END_OF_HOB_LIST"; |
| 237 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 238 | default: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 239 | hob_type_string = "EFI_HOB_TYPE_UNRECOGNIZED"; |
| 240 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 241 | } |
| 242 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 243 | return hob_type_string; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 244 | } |
| 245 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 246 | /* |
| 247 | * Print out a structure of all the HOBs |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 248 | * that match a certain type: |
| 249 | * Print all types (0x0000) |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 250 | * EFI_HOB_TYPE_HANDOFF (0x0001) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 251 | * EFI_HOB_TYPE_MEMORY_ALLOCATION (0x0002) |
| 252 | * EFI_HOB_TYPE_RESOURCE_DESCRIPTOR (0x0003) |
| 253 | * EFI_HOB_TYPE_GUID_EXTENSION (0x0004) |
| 254 | * EFI_HOB_TYPE_MEMORY_POOL (0x0007) |
| 255 | * EFI_HOB_TYPE_UNUSED (0xFFFE) |
| 256 | * EFI_HOB_TYPE_END_OF_HOB_LIST (0xFFFF) |
| 257 | */ |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 258 | void print_hob_type_structure(u16 hob_type, void *hob_list_ptr) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 259 | { |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 260 | u32 *current_hob; |
| 261 | u32 *next_hob = 0; |
| 262 | u8 last_hob = 0; |
| 263 | u32 current_type; |
| 264 | const char *current_type_str; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 265 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 266 | current_hob = hob_list_ptr; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 267 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 268 | /* |
| 269 | * Print out HOBs of our desired type until |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 270 | * the end of the HOB list |
| 271 | */ |
| 272 | printk(BIOS_DEBUG, "\n=== FSP HOB Data Structure ===\n"); |
Julius Werner | 540a980 | 2019-12-09 13:03:29 -0800 | [diff] [blame] | 273 | printk(BIOS_DEBUG, "%p: hob_list_ptr\n", hob_list_ptr); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 274 | do { |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 275 | EFI_HOB_GENERIC_HEADER *current_header_ptr = |
| 276 | (EFI_HOB_GENERIC_HEADER *)current_hob; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 277 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 278 | /* Get the type of this HOB */ |
| 279 | current_type = current_header_ptr->HobType; |
| 280 | current_type_str = get_hob_type_string(current_hob); |
| 281 | |
| 282 | if (current_type == hob_type || hob_type == 0x0000) { |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 283 | printk(BIOS_DEBUG, "HOB %p is an %s (type 0x%0x)\n", |
| 284 | current_hob, current_type_str, |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 285 | current_type); |
| 286 | switch (current_type) { |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 287 | case EFI_HOB_TYPE_MEMORY_ALLOCATION: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 288 | print_hob_mem_attributes(current_hob); |
| 289 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 290 | case EFI_HOB_TYPE_RESOURCE_DESCRIPTOR: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 291 | print_hob_resource_attributes(current_hob); |
| 292 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 293 | } |
| 294 | } |
| 295 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 296 | /* Check for end of HOB list */ |
| 297 | last_hob = END_OF_HOB_LIST(current_hob); |
| 298 | if (!last_hob) { |
| 299 | /* Get next HOB pointer */ |
| 300 | next_hob = GET_NEXT_HOB(current_hob); |
| 301 | |
| 302 | /* Start on next HOB */ |
| 303 | current_hob = next_hob; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 304 | } |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 305 | } while (!last_hob); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 306 | printk(BIOS_DEBUG, "=== End of FSP HOB Data Structure ===\n\n"); |
| 307 | } |