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. */ |
Arthur Heymans | 56ed0be | 2022-03-30 13:34:38 +0200 | [diff] [blame] | 27 | static 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 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 47 | /* Returns the next instance of the matched GUID HOB from the starting HOB. */ |
Arthur Heymans | ca74d7e | 2022-03-30 14:41:16 +0200 | [diff] [blame] | 48 | void *get_guid_hob(const EFI_GUID *guid, const void *hob_start) |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 49 | { |
| 50 | EFI_PEI_HOB_POINTERS hob; |
| 51 | |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 52 | hob.Raw = (uint8_t *)hob_start; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 53 | while ((hob.Raw = get_next_hob(EFI_HOB_TYPE_GUID_EXTENSION, hob.Raw)) |
| 54 | != NULL) { |
| 55 | if (compare_guid(guid, &hob.Guid->Name)) |
| 56 | break; |
| 57 | hob.Raw = GET_NEXT_HOB(hob.Raw); |
| 58 | } |
| 59 | return hob.Raw; |
| 60 | } |
| 61 | |
| 62 | /* |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 63 | * Returns the next instance of the matching resource HOB from the starting HOB. |
| 64 | */ |
Arthur Heymans | ca74d7e | 2022-03-30 14:41:16 +0200 | [diff] [blame] | 65 | void *get_resource_hob(const EFI_GUID *guid, const void *hob_start) |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 66 | { |
| 67 | EFI_PEI_HOB_POINTERS hob; |
| 68 | |
| 69 | hob.Raw = (UINT8 *)hob_start; |
| 70 | while ((hob.Raw = get_next_hob(EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, |
| 71 | hob.Raw)) != NULL) { |
| 72 | if (compare_guid(guid, &hob.ResourceDescriptor->Owner)) |
| 73 | break; |
| 74 | hob.Raw = GET_NEXT_HOB(hob.Raw); |
| 75 | } |
| 76 | return hob.Raw; |
| 77 | } |
| 78 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 79 | static void print_hob_mem_attributes(void *hob_ptr) |
| 80 | { |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 81 | EFI_MEMORY_TYPE hob_mem_type; |
| 82 | EFI_HOB_MEMORY_ALLOCATION *hob_memory_ptr = hob_ptr; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 83 | u64 hob_mem_addr = hob_memory_ptr->AllocDescriptor.MemoryBaseAddress; |
| 84 | u64 hob_mem_length = hob_memory_ptr->AllocDescriptor.MemoryLength; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 85 | |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 86 | hob_mem_type = hob_memory_ptr->AllocDescriptor.MemoryType; |
| 87 | |
| 88 | static const char *hob_mem_type_names[15] = { |
| 89 | [EfiReservedMemoryType] = "EfiReservedMemoryType", |
| 90 | [EfiLoaderCode] = "EfiLoaderCode", |
| 91 | [EfiLoaderData] = "EfiLoaderData", |
| 92 | [EfiBootServicesCode] = "EfiBootServicesCode", |
| 93 | [EfiBootServicesData] = "EfiBootServicesData", |
| 94 | [EfiRuntimeServicesCode] = "EfiRuntimeServicesCode", |
| 95 | [EfiRuntimeServicesData] = "EfiRuntimeServicesData", |
| 96 | [EfiConventionalMemory] = "EfiConventionalMemory", |
| 97 | [EfiUnusableMemory] = "EfiUnusableMemory", |
| 98 | [EfiACPIReclaimMemory] = "EfiACPIReclaimMemory", |
| 99 | [EfiACPIMemoryNVS] = "EfiACPIMemoryNVS", |
| 100 | [EfiMemoryMappedIO] = "EfiMemoryMappedIO", |
| 101 | [EfiMemoryMappedIOPortSpace] = "EfiMemoryMappedIOPortSpace", |
| 102 | [EfiPalCode] = "EfiPalCode", |
| 103 | [EfiMaxMemoryType] = "EfiMaxMemoryType", |
| 104 | }; |
| 105 | |
| 106 | if (hob_mem_type >= ARRAY_SIZE(hob_mem_type_names)) |
| 107 | hob_mem_type = EfiReservedMemoryType; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 108 | |
| 109 | printk(BIOS_SPEW, " Memory type %s (0x%x)\n", |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 110 | hob_mem_type_names[hob_mem_type], |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 111 | (u32)hob_mem_type); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 112 | printk(BIOS_SPEW, " at location 0x%0lx with length 0x%0lx\n", |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 113 | (unsigned long)hob_mem_addr, |
| 114 | (unsigned long)hob_mem_length); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 115 | } |
| 116 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 117 | static void print_hob_resource_attributes(void *hob_ptr) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 118 | { |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 119 | EFI_HOB_RESOURCE_DESCRIPTOR *hob_resource_ptr = |
| 120 | (EFI_HOB_RESOURCE_DESCRIPTOR *)hob_ptr; |
| 121 | u32 hob_res_type = hob_resource_ptr->ResourceType; |
| 122 | u32 hob_res_attr = hob_resource_ptr->ResourceAttribute; |
| 123 | u64 hob_res_addr = hob_resource_ptr->PhysicalStart; |
| 124 | u64 hob_res_length = hob_resource_ptr->ResourceLength; |
| 125 | const char *hob_res_type_str = NULL; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 126 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 127 | /* HOB Resource Types */ |
| 128 | switch (hob_res_type) { |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 129 | case EFI_RESOURCE_SYSTEM_MEMORY: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 130 | hob_res_type_str = "EFI_RESOURCE_SYSTEM_MEMORY"; |
| 131 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 132 | case EFI_RESOURCE_MEMORY_MAPPED_IO: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 133 | hob_res_type_str = "EFI_RESOURCE_MEMORY_MAPPED_IO"; |
| 134 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 135 | case EFI_RESOURCE_IO: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 136 | hob_res_type_str = "EFI_RESOURCE_IO"; |
| 137 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 138 | case EFI_RESOURCE_FIRMWARE_DEVICE: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 139 | hob_res_type_str = "EFI_RESOURCE_FIRMWARE_DEVICE"; |
| 140 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 141 | case EFI_RESOURCE_MEMORY_MAPPED_IO_PORT: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 142 | hob_res_type_str = "EFI_RESOURCE_MEMORY_MAPPED_IO_PORT"; |
| 143 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 144 | case EFI_RESOURCE_MEMORY_RESERVED: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 145 | hob_res_type_str = "EFI_RESOURCE_MEMORY_RESERVED"; |
| 146 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 147 | case EFI_RESOURCE_IO_RESERVED: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 148 | hob_res_type_str = "EFI_RESOURCE_IO_RESERVED"; |
| 149 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 150 | case EFI_RESOURCE_MAX_MEMORY_TYPE: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 151 | hob_res_type_str = "EFI_RESOURCE_MAX_MEMORY_TYPE"; |
| 152 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 153 | default: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 154 | hob_res_type_str = "EFI_RESOURCE_UNKNOWN"; |
| 155 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | printk(BIOS_SPEW, " Resource %s (0x%0x) has attributes 0x%0x\n", |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 159 | hob_res_type_str, hob_res_type, hob_res_attr); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 160 | printk(BIOS_SPEW, " at location 0x%0lx with length 0x%0lx\n", |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 161 | (unsigned long)hob_res_addr, |
| 162 | (unsigned long)hob_res_length); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 163 | } |
| 164 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 165 | static const char *get_hob_type_string(void *hob_ptr) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 166 | { |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 167 | EFI_PEI_HOB_POINTERS hob; |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 168 | const char *hob_type_string; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 169 | const EFI_GUID fsp_reserved_guid = |
| 170 | FSP_RESERVED_MEMORY_RESOURCE_HOB_GUID; |
| 171 | const EFI_GUID mrc_guid = FSP_NON_VOLATILE_STORAGE_HOB_GUID; |
| 172 | const EFI_GUID bootldr_tmp_mem_guid = |
| 173 | FSP_BOOTLOADER_TEMP_MEMORY_HOB_GUID; |
| 174 | const EFI_GUID bootldr_tolum_guid = FSP_BOOTLOADER_TOLUM_HOB_GUID; |
| 175 | const EFI_GUID graphics_info_guid = EFI_PEI_GRAPHICS_INFO_HOB_GUID; |
Lee Leahy | 4a8c19c | 2015-06-16 14:33:30 -0700 | [diff] [blame] | 176 | const EFI_GUID memory_info_hob_guid = FSP_SMBIOS_MEMORY_INFO_GUID; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 177 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 178 | hob.Header = (EFI_HOB_GENERIC_HEADER *)hob_ptr; |
| 179 | switch (hob.Header->HobType) { |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 180 | case EFI_HOB_TYPE_HANDOFF: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 181 | hob_type_string = "EFI_HOB_TYPE_HANDOFF"; |
| 182 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 183 | case EFI_HOB_TYPE_MEMORY_ALLOCATION: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 184 | hob_type_string = "EFI_HOB_TYPE_MEMORY_ALLOCATION"; |
| 185 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 186 | case EFI_HOB_TYPE_RESOURCE_DESCRIPTOR: |
Lee Leahy | 4a8c19c | 2015-06-16 14:33:30 -0700 | [diff] [blame] | 187 | if (compare_guid(&fsp_reserved_guid, &hob.Guid->Name)) |
| 188 | hob_type_string = "FSP_RESERVED_MEMORY_RESOURCE_HOB"; |
| 189 | else if (compare_guid(&bootldr_tolum_guid, &hob.Guid->Name)) |
| 190 | hob_type_string = "FSP_BOOTLOADER_TOLUM_HOB_GUID"; |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 191 | else |
| 192 | hob_type_string = "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR"; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 193 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 194 | case EFI_HOB_TYPE_GUID_EXTENSION: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 195 | if (compare_guid(&bootldr_tmp_mem_guid, &hob.Guid->Name)) |
| 196 | hob_type_string = "FSP_BOOTLOADER_TEMP_MEMORY_HOB"; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 197 | else if (compare_guid(&mrc_guid, &hob.Guid->Name)) |
| 198 | hob_type_string = "FSP_NON_VOLATILE_STORAGE_HOB"; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 199 | else if (compare_guid(&graphics_info_guid, &hob.Guid->Name)) |
| 200 | hob_type_string = "EFI_PEI_GRAPHICS_INFO_HOB_GUID"; |
Lee Leahy | 4a8c19c | 2015-06-16 14:33:30 -0700 | [diff] [blame] | 201 | else if (compare_guid(&memory_info_hob_guid, &hob.Guid->Name)) |
| 202 | hob_type_string = "FSP_SMBIOS_MEMORY_INFO_GUID"; |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 203 | else |
| 204 | hob_type_string = "EFI_HOB_TYPE_GUID_EXTENSION"; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 205 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 206 | case EFI_HOB_TYPE_MEMORY_POOL: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 207 | hob_type_string = "EFI_HOB_TYPE_MEMORY_POOL"; |
| 208 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 209 | case EFI_HOB_TYPE_UNUSED: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 210 | hob_type_string = "EFI_HOB_TYPE_UNUSED"; |
| 211 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 212 | case EFI_HOB_TYPE_END_OF_HOB_LIST: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 213 | hob_type_string = "EFI_HOB_TYPE_END_OF_HOB_LIST"; |
| 214 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 215 | default: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 216 | hob_type_string = "EFI_HOB_TYPE_UNRECOGNIZED"; |
| 217 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 218 | } |
| 219 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 220 | return hob_type_string; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 221 | } |
| 222 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 223 | /* |
| 224 | * Print out a structure of all the HOBs |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 225 | * that match a certain type: |
| 226 | * Print all types (0x0000) |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 227 | * EFI_HOB_TYPE_HANDOFF (0x0001) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 228 | * EFI_HOB_TYPE_MEMORY_ALLOCATION (0x0002) |
| 229 | * EFI_HOB_TYPE_RESOURCE_DESCRIPTOR (0x0003) |
| 230 | * EFI_HOB_TYPE_GUID_EXTENSION (0x0004) |
| 231 | * EFI_HOB_TYPE_MEMORY_POOL (0x0007) |
| 232 | * EFI_HOB_TYPE_UNUSED (0xFFFE) |
| 233 | * EFI_HOB_TYPE_END_OF_HOB_LIST (0xFFFF) |
| 234 | */ |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 235 | void print_hob_type_structure(u16 hob_type, void *hob_list_ptr) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 236 | { |
Patrick Rudolph | ac49aaf | 2022-03-22 12:17:48 +0100 | [diff] [blame] | 237 | void *current_hob; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 238 | u32 current_type; |
| 239 | const char *current_type_str; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 240 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 241 | /* |
| 242 | * Print out HOBs of our desired type until |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 243 | * the end of the HOB list |
| 244 | */ |
| 245 | printk(BIOS_DEBUG, "\n=== FSP HOB Data Structure ===\n"); |
Julius Werner | 540a980 | 2019-12-09 13:03:29 -0800 | [diff] [blame] | 246 | printk(BIOS_DEBUG, "%p: hob_list_ptr\n", hob_list_ptr); |
Patrick Rudolph | ac49aaf | 2022-03-22 12:17:48 +0100 | [diff] [blame] | 247 | for (current_hob = hob_list_ptr; !END_OF_HOB_LIST(current_hob); |
| 248 | current_hob = GET_NEXT_HOB(current_hob)) { |
| 249 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 250 | EFI_HOB_GENERIC_HEADER *current_header_ptr = |
| 251 | (EFI_HOB_GENERIC_HEADER *)current_hob; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 252 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 253 | /* Get the type of this HOB */ |
| 254 | current_type = current_header_ptr->HobType; |
| 255 | current_type_str = get_hob_type_string(current_hob); |
| 256 | |
| 257 | if (current_type == hob_type || hob_type == 0x0000) { |
Alexandru Gagniuc | 5c9a71e | 2015-08-28 18:49:40 -0400 | [diff] [blame] | 258 | printk(BIOS_DEBUG, "HOB %p is an %s (type 0x%0x)\n", |
| 259 | current_hob, current_type_str, |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 260 | current_type); |
| 261 | switch (current_type) { |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 262 | case EFI_HOB_TYPE_MEMORY_ALLOCATION: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 263 | print_hob_mem_attributes(current_hob); |
| 264 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 265 | case EFI_HOB_TYPE_RESOURCE_DESCRIPTOR: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 266 | print_hob_resource_attributes(current_hob); |
| 267 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 268 | } |
| 269 | } |
Patrick Rudolph | ac49aaf | 2022-03-22 12:17:48 +0100 | [diff] [blame] | 270 | } |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 271 | printk(BIOS_DEBUG, "=== End of FSP HOB Data Structure ===\n\n"); |
| 272 | } |