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 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 31 | /* |
| 32 | * Reads a 64-bit value from memory that may be unaligned. |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 33 | * |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 34 | * This function returns the 64-bit value pointed to by buffer. The |
| 35 | * function guarantees that the read operation does not produce an |
| 36 | * alignment fault. |
| 37 | * |
| 38 | * If buffer is NULL, then ASSERT(). |
| 39 | * |
| 40 | * buffer: Pointer to a 64-bit value that may be unaligned. |
| 41 | * |
| 42 | * Returns the 64-bit value read from buffer. |
| 43 | * |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 44 | */ |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 45 | static |
| 46 | uint64_t |
| 47 | read_unaligned_64( |
| 48 | const uint64_t *buffer |
| 49 | ) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 50 | { |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 51 | ASSERT(buffer != NULL); |
| 52 | |
| 53 | return *buffer; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 56 | /* |
| 57 | * Compares two GUIDs. |
| 58 | * |
| 59 | * This function compares guid1 to guid2. If the GUIDs are identical then |
| 60 | * TRUE is returned. If there are any bit differences in the two GUIDs, |
| 61 | * then FALSE is returned. |
| 62 | * |
| 63 | * If guid1 is NULL, then ASSERT(). |
| 64 | * If guid2 is NULL, then ASSERT(). |
| 65 | * |
| 66 | * guid1: A pointer to a 128 bit GUID. |
| 67 | * guid2: A pointer to a 128 bit GUID. |
| 68 | * |
| 69 | * Returns non-zero if guid1 and guid2 are identical, otherwise returns 0. |
| 70 | * |
| 71 | */ |
| 72 | static |
| 73 | long |
| 74 | compare_guid( |
| 75 | const EFI_GUID * guid1, |
| 76 | const EFI_GUID * guid2 |
| 77 | ) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 78 | { |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 79 | uint64_t low_part_of_guid1; |
| 80 | uint64_t low_part_of_guid2; |
| 81 | uint64_t high_part_of_guid1; |
| 82 | uint64_t high_part_of_guid2; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 83 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 84 | low_part_of_guid1 = read_unaligned_64((const uint64_t *) guid1); |
| 85 | low_part_of_guid2 = read_unaligned_64((const uint64_t *) guid2); |
| 86 | high_part_of_guid1 = read_unaligned_64((const uint64_t *) guid1 + 1); |
| 87 | high_part_of_guid2 = read_unaligned_64((const uint64_t *) guid2 + 1); |
| 88 | |
| 89 | return ((low_part_of_guid1 == low_part_of_guid2) |
| 90 | && (high_part_of_guid1 == high_part_of_guid2)); |
| 91 | } |
| 92 | |
| 93 | /* Returns the pointer to the HOB list. */ |
| 94 | VOID * |
| 95 | EFIAPI |
| 96 | get_hob_list( |
| 97 | VOID |
| 98 | ) |
| 99 | { |
| 100 | void *hob_list; |
| 101 | |
| 102 | hob_list = fsp_get_hob_list(); |
| 103 | if (hob_list == NULL) |
| 104 | die("Call fsp_set_runtime() before this call!\n"); |
| 105 | return hob_list; |
| 106 | } |
| 107 | |
| 108 | /* Returns the next instance of a HOB type from the starting HOB. */ |
| 109 | VOID * |
| 110 | EFIAPI |
| 111 | get_next_hob( |
| 112 | UINT16 type, |
| 113 | CONST VOID *hob_start |
| 114 | ) |
| 115 | { |
| 116 | EFI_PEI_HOB_POINTERS hob; |
| 117 | |
| 118 | ASSERT(hob_start != NULL); |
| 119 | |
| 120 | hob.Raw = (UINT8 *)hob_start; |
| 121 | |
| 122 | /* Parse the HOB list until end of list or matching type is found. */ |
| 123 | while (!END_OF_HOB_LIST(hob.Raw)) { |
| 124 | if (hob.Header->HobType == type) |
| 125 | return hob.Raw; |
| 126 | if (GET_HOB_LENGTH(hob.Raw) < sizeof(*hob.Header)) |
| 127 | break; |
| 128 | hob.Raw = GET_NEXT_HOB(hob.Raw); |
| 129 | } |
| 130 | return NULL; |
| 131 | } |
| 132 | |
| 133 | /* Returns the first instance of a HOB type among the whole HOB list. */ |
| 134 | VOID * |
| 135 | EFIAPI |
| 136 | get_first_hob( |
| 137 | UINT16 type |
| 138 | ) |
| 139 | { |
| 140 | VOID *hob_list; |
| 141 | |
| 142 | hob_list = get_hob_list(); |
| 143 | return get_next_hob(type, hob_list); |
| 144 | } |
| 145 | |
| 146 | /* Returns the next instance of the matched GUID HOB from the starting HOB. */ |
| 147 | VOID * |
| 148 | EFIAPI |
| 149 | get_next_guid_hob( |
| 150 | CONST EFI_GUID * guid, |
| 151 | CONST VOID *hob_start |
| 152 | ) |
| 153 | { |
| 154 | EFI_PEI_HOB_POINTERS hob; |
| 155 | |
| 156 | hob.Raw = (UINT8 *)hob_start; |
| 157 | while ((hob.Raw = get_next_hob(EFI_HOB_TYPE_GUID_EXTENSION, hob.Raw)) |
| 158 | != NULL) { |
| 159 | if (compare_guid(guid, &hob.Guid->Name)) |
| 160 | break; |
| 161 | hob.Raw = GET_NEXT_HOB(hob.Raw); |
| 162 | } |
| 163 | return hob.Raw; |
| 164 | } |
| 165 | |
| 166 | /* |
| 167 | * Returns the first instance of the matched GUID HOB among the whole HOB list. |
| 168 | */ |
| 169 | VOID * |
| 170 | EFIAPI |
| 171 | get_first_guid_hob( |
| 172 | CONST EFI_GUID * guid |
| 173 | ) |
| 174 | { |
| 175 | return get_next_guid_hob(guid, get_hob_list()); |
| 176 | } |
| 177 | |
| 178 | /* |
| 179 | * Returns the next instance of the matching resource HOB from the starting HOB. |
| 180 | */ |
| 181 | void *get_next_resource_hob(const EFI_GUID *guid, const void *hob_start) |
| 182 | { |
| 183 | EFI_PEI_HOB_POINTERS hob; |
| 184 | |
| 185 | hob.Raw = (UINT8 *)hob_start; |
| 186 | while ((hob.Raw = get_next_hob(EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, |
| 187 | hob.Raw)) != NULL) { |
| 188 | if (compare_guid(guid, &hob.ResourceDescriptor->Owner)) |
| 189 | break; |
| 190 | hob.Raw = GET_NEXT_HOB(hob.Raw); |
| 191 | } |
| 192 | return hob.Raw; |
| 193 | } |
| 194 | |
| 195 | /* |
| 196 | * Returns the first instance of the matching resource HOB among the whole HOB |
| 197 | * list. |
| 198 | */ |
| 199 | void *get_first_resource_hob(const EFI_GUID *guid) |
| 200 | { |
| 201 | return get_next_resource_hob(guid, get_hob_list()); |
| 202 | } |
| 203 | |
| 204 | static void print_hob_mem_attributes(void *hob_ptr) |
| 205 | { |
| 206 | EFI_HOB_MEMORY_ALLOCATION *hob_memory_ptr = |
| 207 | (EFI_HOB_MEMORY_ALLOCATION *)hob_ptr; |
| 208 | EFI_MEMORY_TYPE hob_mem_type = |
| 209 | hob_memory_ptr->AllocDescriptor.MemoryType; |
| 210 | u64 hob_mem_addr = hob_memory_ptr->AllocDescriptor.MemoryBaseAddress; |
| 211 | u64 hob_mem_length = hob_memory_ptr->AllocDescriptor.MemoryLength; |
| 212 | const char *hob_mem_type_names[15]; |
| 213 | |
| 214 | hob_mem_type_names[0] = "EfiReservedMemoryType"; |
| 215 | hob_mem_type_names[1] = "EfiLoaderCode"; |
| 216 | hob_mem_type_names[2] = "EfiLoaderData"; |
| 217 | hob_mem_type_names[3] = "EfiBootServicesCode"; |
| 218 | hob_mem_type_names[4] = "EfiBootServicesData"; |
| 219 | hob_mem_type_names[5] = "EfiRuntimeServicesCode"; |
| 220 | hob_mem_type_names[6] = "EfiRuntimeServicesData"; |
| 221 | hob_mem_type_names[7] = "EfiConventionalMemory"; |
| 222 | hob_mem_type_names[8] = "EfiUnusableMemory"; |
| 223 | hob_mem_type_names[9] = "EfiACPIReclaimMemory"; |
| 224 | hob_mem_type_names[10] = "EfiACPIMemoryNVS"; |
| 225 | hob_mem_type_names[11] = "EfiMemoryMappedIO"; |
| 226 | hob_mem_type_names[12] = "EfiMemoryMappedIOPortSpace"; |
| 227 | hob_mem_type_names[13] = "EfiPalCode"; |
| 228 | hob_mem_type_names[14] = "EfiMaxMemoryType"; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 229 | |
| 230 | printk(BIOS_SPEW, " Memory type %s (0x%x)\n", |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 231 | hob_mem_type_names[(u32)hob_mem_type], |
| 232 | (u32)hob_mem_type); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 233 | printk(BIOS_SPEW, " at location 0x%0lx with length 0x%0lx\n", |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 234 | (unsigned long)hob_mem_addr, |
| 235 | (unsigned long)hob_mem_length); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 236 | } |
| 237 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 238 | static void print_hob_resource_attributes(void *hob_ptr) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 239 | { |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 240 | EFI_HOB_RESOURCE_DESCRIPTOR *hob_resource_ptr = |
| 241 | (EFI_HOB_RESOURCE_DESCRIPTOR *)hob_ptr; |
| 242 | u32 hob_res_type = hob_resource_ptr->ResourceType; |
| 243 | u32 hob_res_attr = hob_resource_ptr->ResourceAttribute; |
| 244 | u64 hob_res_addr = hob_resource_ptr->PhysicalStart; |
| 245 | u64 hob_res_length = hob_resource_ptr->ResourceLength; |
| 246 | const char *hob_res_type_str = NULL; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 247 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 248 | /* HOB Resource Types */ |
| 249 | switch (hob_res_type) { |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 250 | case EFI_RESOURCE_SYSTEM_MEMORY: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 251 | hob_res_type_str = "EFI_RESOURCE_SYSTEM_MEMORY"; |
| 252 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 253 | case EFI_RESOURCE_MEMORY_MAPPED_IO: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 254 | hob_res_type_str = "EFI_RESOURCE_MEMORY_MAPPED_IO"; |
| 255 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 256 | case EFI_RESOURCE_IO: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 257 | hob_res_type_str = "EFI_RESOURCE_IO"; |
| 258 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 259 | case EFI_RESOURCE_FIRMWARE_DEVICE: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 260 | hob_res_type_str = "EFI_RESOURCE_FIRMWARE_DEVICE"; |
| 261 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 262 | case EFI_RESOURCE_MEMORY_MAPPED_IO_PORT: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 263 | hob_res_type_str = "EFI_RESOURCE_MEMORY_MAPPED_IO_PORT"; |
| 264 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 265 | case EFI_RESOURCE_MEMORY_RESERVED: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 266 | hob_res_type_str = "EFI_RESOURCE_MEMORY_RESERVED"; |
| 267 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 268 | case EFI_RESOURCE_IO_RESERVED: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 269 | hob_res_type_str = "EFI_RESOURCE_IO_RESERVED"; |
| 270 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 271 | case EFI_RESOURCE_MAX_MEMORY_TYPE: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 272 | hob_res_type_str = "EFI_RESOURCE_MAX_MEMORY_TYPE"; |
| 273 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 274 | default: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 275 | hob_res_type_str = "EFI_RESOURCE_UNKNOWN"; |
| 276 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | printk(BIOS_SPEW, " Resource %s (0x%0x) has attributes 0x%0x\n", |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 280 | hob_res_type_str, hob_res_type, hob_res_attr); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 281 | printk(BIOS_SPEW, " at location 0x%0lx with length 0x%0lx\n", |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 282 | (unsigned long)hob_res_addr, |
| 283 | (unsigned long)hob_res_length); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 284 | } |
| 285 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 286 | static const char *get_hob_type_string(void *hob_ptr) |
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 | EFI_PEI_HOB_POINTERS hob; |
| 289 | const char *hob_type_string = NULL; |
| 290 | const EFI_GUID fsp_reserved_guid = |
| 291 | FSP_RESERVED_MEMORY_RESOURCE_HOB_GUID; |
| 292 | const EFI_GUID mrc_guid = FSP_NON_VOLATILE_STORAGE_HOB_GUID; |
| 293 | const EFI_GUID bootldr_tmp_mem_guid = |
| 294 | FSP_BOOTLOADER_TEMP_MEMORY_HOB_GUID; |
| 295 | const EFI_GUID bootldr_tolum_guid = FSP_BOOTLOADER_TOLUM_HOB_GUID; |
| 296 | const EFI_GUID graphics_info_guid = EFI_PEI_GRAPHICS_INFO_HOB_GUID; |
Lee Leahy | 4a8c19c | 2015-06-16 14:33:30 -0700 | [diff] [blame] | 297 | const EFI_GUID memory_info_hob_guid = FSP_SMBIOS_MEMORY_INFO_GUID; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 298 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 299 | hob.Header = (EFI_HOB_GENERIC_HEADER *)hob_ptr; |
| 300 | switch (hob.Header->HobType) { |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 301 | case EFI_HOB_TYPE_HANDOFF: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 302 | hob_type_string = "EFI_HOB_TYPE_HANDOFF"; |
| 303 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 304 | case EFI_HOB_TYPE_MEMORY_ALLOCATION: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 305 | hob_type_string = "EFI_HOB_TYPE_MEMORY_ALLOCATION"; |
| 306 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 307 | case EFI_HOB_TYPE_RESOURCE_DESCRIPTOR: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 308 | hob_type_string = "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR"; |
Lee Leahy | 4a8c19c | 2015-06-16 14:33:30 -0700 | [diff] [blame] | 309 | if (compare_guid(&fsp_reserved_guid, &hob.Guid->Name)) |
| 310 | hob_type_string = "FSP_RESERVED_MEMORY_RESOURCE_HOB"; |
| 311 | else if (compare_guid(&bootldr_tolum_guid, &hob.Guid->Name)) |
| 312 | hob_type_string = "FSP_BOOTLOADER_TOLUM_HOB_GUID"; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 313 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 314 | case EFI_HOB_TYPE_GUID_EXTENSION: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 315 | hob_type_string = "EFI_HOB_TYPE_GUID_EXTENSION"; |
| 316 | if (compare_guid(&bootldr_tmp_mem_guid, &hob.Guid->Name)) |
| 317 | hob_type_string = "FSP_BOOTLOADER_TEMP_MEMORY_HOB"; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 318 | else if (compare_guid(&mrc_guid, &hob.Guid->Name)) |
| 319 | hob_type_string = "FSP_NON_VOLATILE_STORAGE_HOB"; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 320 | else if (compare_guid(&graphics_info_guid, &hob.Guid->Name)) |
| 321 | hob_type_string = "EFI_PEI_GRAPHICS_INFO_HOB_GUID"; |
Lee Leahy | 4a8c19c | 2015-06-16 14:33:30 -0700 | [diff] [blame] | 322 | else if (compare_guid(&memory_info_hob_guid, &hob.Guid->Name)) |
| 323 | hob_type_string = "FSP_SMBIOS_MEMORY_INFO_GUID"; |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 324 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 325 | case EFI_HOB_TYPE_MEMORY_POOL: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 326 | hob_type_string = "EFI_HOB_TYPE_MEMORY_POOL"; |
| 327 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 328 | case EFI_HOB_TYPE_UNUSED: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 329 | hob_type_string = "EFI_HOB_TYPE_UNUSED"; |
| 330 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 331 | case EFI_HOB_TYPE_END_OF_HOB_LIST: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 332 | hob_type_string = "EFI_HOB_TYPE_END_OF_HOB_LIST"; |
| 333 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 334 | default: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 335 | hob_type_string = "EFI_HOB_TYPE_UNRECOGNIZED"; |
| 336 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 337 | } |
| 338 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 339 | return hob_type_string; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 340 | } |
| 341 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 342 | /* |
| 343 | * Print out a structure of all the HOBs |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 344 | * that match a certain type: |
| 345 | * Print all types (0x0000) |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 346 | * EFI_HOB_TYPE_HANDOFF (0x0001) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 347 | * EFI_HOB_TYPE_MEMORY_ALLOCATION (0x0002) |
| 348 | * EFI_HOB_TYPE_RESOURCE_DESCRIPTOR (0x0003) |
| 349 | * EFI_HOB_TYPE_GUID_EXTENSION (0x0004) |
| 350 | * EFI_HOB_TYPE_MEMORY_POOL (0x0007) |
| 351 | * EFI_HOB_TYPE_UNUSED (0xFFFE) |
| 352 | * EFI_HOB_TYPE_END_OF_HOB_LIST (0xFFFF) |
| 353 | */ |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 354 | void print_hob_type_structure(u16 hob_type, void *hob_list_ptr) |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 355 | { |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 356 | u32 *current_hob; |
| 357 | u32 *next_hob = 0; |
| 358 | u8 last_hob = 0; |
| 359 | u32 current_type; |
| 360 | const char *current_type_str; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 361 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 362 | current_hob = hob_list_ptr; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 363 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 364 | /* |
| 365 | * Print out HOBs of our desired type until |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 366 | * the end of the HOB list |
| 367 | */ |
| 368 | printk(BIOS_DEBUG, "\n=== FSP HOB Data Structure ===\n"); |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 369 | printk(BIOS_DEBUG, "0x%p: hob_list_ptr\n", hob_list_ptr); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 370 | do { |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 371 | EFI_HOB_GENERIC_HEADER *current_header_ptr = |
| 372 | (EFI_HOB_GENERIC_HEADER *)current_hob; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 373 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 374 | /* Get the type of this HOB */ |
| 375 | current_type = current_header_ptr->HobType; |
| 376 | current_type_str = get_hob_type_string(current_hob); |
| 377 | |
| 378 | if (current_type == hob_type || hob_type == 0x0000) { |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 379 | printk(BIOS_DEBUG, "HOB 0x%0x is an %s (type 0x%0x)\n", |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 380 | (u32)current_hob, current_type_str, |
| 381 | current_type); |
| 382 | switch (current_type) { |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 383 | case EFI_HOB_TYPE_MEMORY_ALLOCATION: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 384 | print_hob_mem_attributes(current_hob); |
| 385 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 386 | case EFI_HOB_TYPE_RESOURCE_DESCRIPTOR: |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 387 | print_hob_resource_attributes(current_hob); |
| 388 | break; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 389 | } |
| 390 | } |
| 391 | |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 392 | /* Check for end of HOB list */ |
| 393 | last_hob = END_OF_HOB_LIST(current_hob); |
| 394 | if (!last_hob) { |
| 395 | /* Get next HOB pointer */ |
| 396 | next_hob = GET_NEXT_HOB(current_hob); |
| 397 | |
| 398 | /* Start on next HOB */ |
| 399 | current_hob = next_hob; |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 400 | } |
Lee Leahy | b5ad827 | 2015-04-20 15:29:16 -0700 | [diff] [blame] | 401 | } while (!last_hob); |
Lee Leahy | 3dad489 | 2015-05-05 11:14:02 -0700 | [diff] [blame] | 402 | printk(BIOS_DEBUG, "=== End of FSP HOB Data Structure ===\n\n"); |
| 403 | } |