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