]> git.proxmox.com Git - mirror_edk2.git/blob - UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
DynamicTablesPkg: Add support to specify FADT minor revision
[mirror_edk2.git] / UefiPayloadPkg / UefiPayloadEntry / PrintHob.c
1 /** @file
2 Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
3 SPDX-License-Identifier: BSD-2-Clause-Patent
4 **/
5
6 #include "UefiPayloadEntry.h"
7 #include <UniversalPayload/AcpiTable.h>
8 #include <UniversalPayload/SerialPortInfo.h>
9 #include <UniversalPayload/PciRootBridges.h>
10 #include <UniversalPayload/ExtraData.h>
11 #include <Guid/MemoryTypeInformation.h>
12 #include <Guid/AcpiBoardInfoGuid.h>
13 #include <Guid/BootManagerMenu.h>
14
15 #define ROW_LIMITER 16
16
17 typedef
18 EFI_STATUS
19 (*HOB_PRINT_HANDLER) (
20 IN VOID *Hob,
21 IN UINT16 HobLength
22 );
23
24 typedef struct {
25 UINT16 Type;
26 CHAR8 *Name;
27 HOB_PRINT_HANDLER PrintHandler;
28 } HOB_PRINT_HANDLER_TABLE;
29
30 CHAR8 *mMemoryTypeStr[] = {
31 "EfiReservedMemoryType",
32 "EfiLoaderCode",
33 "EfiLoaderData",
34 "EfiBootServicesCode",
35 "EfiBootServicesData",
36 "EfiRuntimeServicesCode",
37 "EfiRuntimeServicesData",
38 "EfiConventionalMemory",
39 "EfiUnusableMemory",
40 "EfiACPIReclaimMemory",
41 "EfiACPIMemoryNVS",
42 "EfiMemoryMappedIO",
43 "EfiMemoryMappedIOPortSpace",
44 "EfiPalCode",
45 "EfiPersistentMemory",
46 "EfiMaxMemoryType"
47 };
48
49 CHAR8 *mResource_Type_List[] = {
50 "EFI_RESOURCE_SYSTEM_MEMORY ", // 0x00000000
51 "EFI_RESOURCE_MEMORY_MAPPED_IO ", // 0x00000001
52 "EFI_RESOURCE_IO ", // 0x00000002
53 "EFI_RESOURCE_FIRMWARE_DEVICE ", // 0x00000003
54 "EFI_RESOURCE_MEMORY_MAPPED_IO_PORT ", // 0x00000004
55 "EFI_RESOURCE_MEMORY_RESERVED ", // 0x00000005
56 "EFI_RESOURCE_IO_RESERVED ", // 0x00000006
57 "EFI_RESOURCE_MAX_MEMORY_TYPE " // 0x00000007
58 };
59
60 typedef
61 EFI_STATUS
62 (*GUID_HOB_PRINT) (
63 IN UINT8 *HobRaw,
64 IN UINT16 HobLength
65 );
66
67 typedef struct {
68 EFI_GUID *Guid;
69 GUID_HOB_PRINT PrintHandler;
70 CHAR8 *GuidName;
71 } GUID_HOB_PRINT_HANDLE;
72
73 typedef struct {
74 EFI_GUID *Guid;
75 CHAR8 *Type;
76 } PRINT_MEMORY_ALLOCCATION_HOB;
77
78 /**
79 Print the Hex value of a given range.
80 @param[in] DataStart A pointer to the start of data to be printed.
81 @param[in] DataSize The length of the data to be printed.
82 @retval EFI_SUCCESS If it completed successfully.
83 **/
84 EFI_STATUS
85 PrintHex (
86 IN UINT8 *DataStart,
87 IN UINT16 DataSize
88 )
89 {
90 UINTN Index1;
91 UINTN Index2;
92 UINT8 *StartAddr;
93
94 StartAddr = DataStart;
95 for (Index1 = 0; Index1 * ROW_LIMITER < DataSize; Index1++) {
96 DEBUG ((DEBUG_VERBOSE, " 0x%04p:", (DataStart - StartAddr)));
97 for (Index2 = 0; (Index2 < ROW_LIMITER) && (Index1 * ROW_LIMITER + Index2 < DataSize); Index2++) {
98 DEBUG ((DEBUG_VERBOSE, " %02x", *DataStart));
99 DataStart++;
100 }
101
102 DEBUG ((DEBUG_VERBOSE, "\n"));
103 }
104
105 return EFI_SUCCESS;
106 }
107
108 /**
109 Print the information in HandOffHob.
110
111 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_HANDOFF.
112 @param[in] HobLength The length in bytes of HOB of type EFI_HOB_TYPE_HANDOFF.
113 @retval EFI_SUCCESS If it completed successfully.
114 **/
115 EFI_STATUS
116 PrintHandOffHob (
117 IN VOID *HobStart,
118 IN UINT16 HobLength
119 )
120 {
121 EFI_PEI_HOB_POINTERS Hob;
122
123 Hob.Raw = (UINT8 *)HobStart;
124 ASSERT (HobLength >= sizeof (*Hob.HandoffInformationTable));
125 DEBUG ((DEBUG_INFO, " BootMode = 0x%x\n", Hob.HandoffInformationTable->BootMode));
126 DEBUG ((DEBUG_INFO, " EfiMemoryTop = 0x%lx\n", Hob.HandoffInformationTable->EfiMemoryTop));
127 DEBUG ((DEBUG_INFO, " EfiMemoryBottom = 0x%lx\n", Hob.HandoffInformationTable->EfiMemoryBottom));
128 DEBUG ((DEBUG_INFO, " EfiFreeMemoryTop = 0x%lx\n", Hob.HandoffInformationTable->EfiFreeMemoryTop));
129 DEBUG ((DEBUG_INFO, " EfiFreeMemoryBottom = 0x%lx\n", Hob.HandoffInformationTable->EfiFreeMemoryBottom));
130 DEBUG ((DEBUG_INFO, " EfiEndOfHobList = 0x%lx\n", Hob.HandoffInformationTable->EfiEndOfHobList));
131 return EFI_SUCCESS;
132 }
133
134 /**
135 Print the information in Memory Allocation Hob.
136 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_MEMORY_ALLOCATION.
137 @param[in] HobLength The length in bytes of HOB of type EFI_HOB_TYPE_MEMORY_ALLOCATION.
138 @retval EFI_SUCCESS If it completed successfully.
139 **/
140 EFI_STATUS
141 PrintMemoryAllocationHob (
142 IN VOID *HobStart,
143 IN UINT16 HobLength
144 )
145 {
146 EFI_PEI_HOB_POINTERS Hob;
147
148 Hob.Raw = (UINT8 *)HobStart;
149
150 if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMemoryAllocStackGuid)) {
151 ASSERT (HobLength >= sizeof (*Hob.MemoryAllocationStack));
152 DEBUG ((DEBUG_INFO, " Type = EFI_HOB_MEMORY_ALLOCATION_STACK\n"));
153 } else if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMemoryAllocBspStoreGuid)) {
154 ASSERT (HobLength >= sizeof (*Hob.MemoryAllocationBspStore));
155 DEBUG ((DEBUG_INFO, " Type = EFI_HOB_MEMORY_ALLOCATION_BSP_STORE\n"));
156 } else if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMemoryAllocModuleGuid)) {
157 ASSERT (HobLength >= sizeof (*Hob.MemoryAllocationModule));
158 DEBUG ((DEBUG_INFO, " Type = EFI_HOB_MEMORY_ALLOCATION_MODULE\n"));
159 DEBUG ((DEBUG_INFO, " Module Name = %g\n", Hob.MemoryAllocationModule->ModuleName));
160 DEBUG ((DEBUG_INFO, " Physical Address = 0x%lx\n", Hob.MemoryAllocationModule->EntryPoint));
161 } else {
162 ASSERT (HobLength >= sizeof (*Hob.MemoryAllocation));
163 DEBUG ((DEBUG_INFO, " Type = EFI_HOB_TYPE_MEMORY_ALLOCATION\n"));
164 }
165
166 DEBUG ((DEBUG_INFO, " MemoryBaseAddress = 0x%lx\n", Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress));
167 DEBUG ((DEBUG_INFO, " MemoryLength = 0x%lx\n", Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength));
168 DEBUG ((DEBUG_INFO, " MemoryType = %a \n", mMemoryTypeStr[Hob.MemoryAllocationStack->AllocDescriptor.MemoryType]));
169 return EFI_SUCCESS;
170 }
171
172 /**
173 Print the information in Resource Discriptor Hob.
174 @param[in] HobStart A pointer to HOB of type EFI_HOB_TYPE_RESOURCE_DESCRIPTOR.
175 @param[in] HobLength The Length in bytes of HOB of type EFI_HOB_TYPE_RESOURCE_DESCRIPTOR.
176 @retval EFI_SUCCESS If it completed successfully.
177 **/
178 EFI_STATUS
179 PrintResourceDiscriptorHob (
180 IN VOID *HobStart,
181 IN UINT16 HobLength
182 )
183 {
184 EFI_PEI_HOB_POINTERS Hob;
185
186 Hob.Raw = (UINT8 *)HobStart;
187 ASSERT (HobLength >= sizeof (*Hob.ResourceDescriptor));
188
189 DEBUG ((DEBUG_INFO, " ResourceType = %a\n", mResource_Type_List[Hob.ResourceDescriptor->ResourceType]));
190 if (!IsZeroGuid (&Hob.ResourceDescriptor->Owner)) {
191 DEBUG ((DEBUG_INFO, " Owner = %g\n", Hob.ResourceDescriptor->Owner));
192 }
193
194 DEBUG ((DEBUG_INFO, " ResourceAttribute = 0x%x\n", Hob.ResourceDescriptor->ResourceAttribute));
195 DEBUG ((DEBUG_INFO, " PhysicalStart = 0x%lx\n", Hob.ResourceDescriptor->PhysicalStart));
196 DEBUG ((DEBUG_INFO, " ResourceLength = 0x%lx\n", Hob.ResourceDescriptor->ResourceLength));
197 return EFI_SUCCESS;
198 }
199
200 /**
201 Print the information in Acpi Guid Hob.
202
203 @param[in] HobRaw A pointer to the start of gUniversalPayloadAcpiTableGuid HOB.
204 @param[in] HobLength The size of the HOB data buffer.
205
206 @retval EFI_SUCCESS If it completed successfully.
207 **/
208 EFI_STATUS
209 PrintAcpiGuidHob (
210 IN UINT8 *HobRaw,
211 IN UINT16 HobLength
212 )
213 {
214 UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob;
215
216 AcpiTableHob = (UNIVERSAL_PAYLOAD_ACPI_TABLE *)GET_GUID_HOB_DATA (HobRaw);
217 ASSERT (HobLength >= AcpiTableHob->Header.Length);
218 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpiTableHob->Header.Revision));
219 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", AcpiTableHob->Header.Length));
220 DEBUG ((DEBUG_INFO, " Rsdp = 0x%p\n", (UINT64)AcpiTableHob->Rsdp));
221 return EFI_SUCCESS;
222 }
223
224 /**
225 Print the information in Serial Guid Hob.
226 @param[in] HobRaw A pointer to the start of gUniversalPayloadSerialPortInfoGuid HOB.
227 @param[in] HobLength The size of the HOB data buffer.
228
229 @retval EFI_SUCCESS If it completed successfully.
230 **/
231 EFI_STATUS
232 PrintSerialGuidHob (
233 IN UINT8 *HobRaw,
234 IN UINT16 HobLength
235 )
236 {
237 UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *SerialPortInfo;
238
239 SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *)GET_GUID_HOB_DATA (HobRaw);
240 ASSERT (HobLength >= SerialPortInfo->Header.Length);
241 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SerialPortInfo->Header.Revision));
242 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SerialPortInfo->Header.Length));
243 DEBUG ((DEBUG_INFO, " UseMmio = 0x%x\n", SerialPortInfo->UseMmio));
244 DEBUG ((DEBUG_INFO, " RegisterStride = 0x%x\n", SerialPortInfo->RegisterStride));
245 DEBUG ((DEBUG_INFO, " BaudRate = %d\n", SerialPortInfo->BaudRate));
246 DEBUG ((DEBUG_INFO, " RegisterBase = 0x%lx\n", SerialPortInfo->RegisterBase));
247 return EFI_SUCCESS;
248 }
249
250 /**
251 Print the information in Smbios Guid Hob.
252 @param[in] HobRaw A pointer to the start of gUniversalPayloadSmbios3TableGuid HOB.
253 @param[in] HobLength The size of the HOB data buffer.
254 @retval EFI_SUCCESS If it completed successfully.
255 **/
256 EFI_STATUS
257 PrintSmbios3GuidHob (
258 IN UINT8 *HobRaw,
259 IN UINT16 HobLength
260 )
261 {
262 UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable;
263
264 SmBiosTable = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *)GET_GUID_HOB_DATA (HobRaw);
265 ASSERT (HobLength >= SmBiosTable->Header.Length);
266 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision));
267 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SmBiosTable->Header.Length));
268 DEBUG ((DEBUG_INFO, " SmBiosEntryPoint = 0x%lx\n", (UINT64)SmBiosTable->SmBiosEntryPoint));
269 return EFI_SUCCESS;
270 }
271
272 /**
273 Print the information in Smbios Guid Hob.
274 @param[in] HobRaw A pointer to the start of gUniversalPayloadSmbiosTableGuid HOB.
275 @param[in] HobLength The size of the HOB data buffer.
276
277 @retval EFI_SUCCESS If it completed successfully.
278 **/
279 EFI_STATUS
280 PrintSmbiosTablGuidHob (
281 IN UINT8 *HobRaw,
282 IN UINT16 HobLength
283 )
284 {
285 UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable;
286
287 SmBiosTable = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *)GET_GUID_HOB_DATA (HobRaw);
288 ASSERT (HobLength >= SmBiosTable->Header.Length);
289 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision));
290 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SmBiosTable->Header.Length));
291 DEBUG ((DEBUG_INFO, " SmBiosEntryPoint = 0x%lx\n", (UINT64)SmBiosTable->SmBiosEntryPoint));
292 return EFI_SUCCESS;
293 }
294
295 /**
296 Print the information in Acpi BoardInfo Guid Hob.
297 @param[in] HobRaw A pointer to the start of gUefiAcpiBoardInfoGuid HOB.
298 @param[in] HobLength The size of the HOB data buffer.
299
300 @retval EFI_SUCCESS If it completed successfully.
301 **/
302 EFI_STATUS
303 PrintAcpiBoardInfoGuidHob (
304 IN UINT8 *HobRaw,
305 IN UINT16 HobLength
306 )
307 {
308 ACPI_BOARD_INFO *AcpBoardInfo;
309
310 AcpBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (HobRaw);
311 ASSERT (HobLength >= sizeof (*AcpBoardInfo));
312 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpBoardInfo->Revision));
313 DEBUG ((DEBUG_INFO, " Reserved0 = 0x%x\n", AcpBoardInfo->Reserved0));
314 DEBUG ((DEBUG_INFO, " ResetValue = 0x%x\n", AcpBoardInfo->ResetValue));
315 DEBUG ((DEBUG_INFO, " PmEvtBase = 0x%lx\n", AcpBoardInfo->PmEvtBase));
316 DEBUG ((DEBUG_INFO, " PmGpeEnBase = 0x%lx\n", AcpBoardInfo->PmGpeEnBase));
317 DEBUG ((DEBUG_INFO, " PmCtrlRegBase = 0x%lx\n", AcpBoardInfo->PmCtrlRegBase));
318 DEBUG ((DEBUG_INFO, " PmTimerRegBase = 0x%lx\n", AcpBoardInfo->PmTimerRegBase));
319 DEBUG ((DEBUG_INFO, " ResetRegAddress = 0x%lx\n", AcpBoardInfo->ResetRegAddress));
320 DEBUG ((DEBUG_INFO, " PcieBaseAddress = 0x%lx\n", AcpBoardInfo->PcieBaseAddress));
321 DEBUG ((DEBUG_INFO, " PcieBaseSize = 0x%lx\n", AcpBoardInfo->PcieBaseSize));
322 return EFI_SUCCESS;
323 }
324
325 /**
326 Print the information in Pci RootBridge Info Guid Hob.
327 @param[in] HobRaw A pointer to the start of gUniversalPayloadPciRootBridgeInfoGuid HOB.
328 @param[in] HobLength The size of the HOB data buffer.
329
330 @retval EFI_SUCCESS If it completed successfully.
331 **/
332 EFI_STATUS
333 PrintPciRootBridgeInfoGuidHob (
334 IN UINT8 *HobRaw,
335 IN UINT16 HobLength
336 )
337 {
338 UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridges;
339 UINTN Index;
340 UINTN Length;
341
342 Index = 0;
343 PciRootBridges = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *)GET_GUID_HOB_DATA (HobRaw);
344 Length = sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES) + PciRootBridges->Count * sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE);
345 ASSERT (HobLength >= Length);
346 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", PciRootBridges->Header.Revision));
347 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", PciRootBridges->Header.Length));
348 DEBUG ((DEBUG_INFO, " Count = 0x%x\n", PciRootBridges->Count));
349 DEBUG ((DEBUG_INFO, " ResourceAssigned = %a\n", (PciRootBridges->ResourceAssigned ? "True" : "False")));
350
351 while (Index < PciRootBridges->Count) {
352 DEBUG ((DEBUG_INFO, " Root Bridge Index[%d]:\n", Index));
353 DEBUG ((DEBUG_INFO, " Segment = 0x%x\n", PciRootBridges->RootBridge[Index].Segment));
354 DEBUG ((DEBUG_INFO, " Supports = 0x%lx\n", PciRootBridges->RootBridge[Index].Supports));
355 DEBUG ((DEBUG_INFO, " Attributes = 0x%lx\n", PciRootBridges->RootBridge[Index].Attributes));
356 DEBUG ((DEBUG_INFO, " DmaAbove4G = 0x%x\n", PciRootBridges->RootBridge[Index].DmaAbove4G));
357 DEBUG ((DEBUG_INFO, " NoExtendedConfigSpace = 0x%x\n", PciRootBridges->RootBridge[Index].NoExtendedConfigSpace));
358 DEBUG ((DEBUG_INFO, " AllocationAttributes = 0x%lx\n", PciRootBridges->RootBridge[Index].AllocationAttributes));
359 DEBUG ((DEBUG_INFO, " Bus.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Base));
360 DEBUG ((DEBUG_INFO, " Bus.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Limit));
361 DEBUG ((DEBUG_INFO, " Bus.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Translation));
362 DEBUG ((DEBUG_INFO, " Io.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Base));
363 DEBUG ((DEBUG_INFO, " Io.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Limit));
364 DEBUG ((DEBUG_INFO, " Io.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Translation));
365 DEBUG ((DEBUG_INFO, " Mem.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Base));
366 DEBUG ((DEBUG_INFO, " Mem.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Limit));
367 DEBUG ((DEBUG_INFO, " Mem.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Translation));
368 DEBUG ((DEBUG_INFO, " MemAbove4G.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Base));
369 DEBUG ((DEBUG_INFO, " MemAbove4G.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Limit));
370 DEBUG ((DEBUG_INFO, " MemAbove4G.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Translation));
371 DEBUG ((DEBUG_INFO, " PMem.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Base));
372 DEBUG ((DEBUG_INFO, " PMem.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Limit));
373 DEBUG ((DEBUG_INFO, " PMem.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Translation));
374 DEBUG ((DEBUG_INFO, " PMemAbove4G.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Base));
375 DEBUG ((DEBUG_INFO, " PMemAbove4G.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Limit));
376 DEBUG ((DEBUG_INFO, " PMemAbove4G.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Translation));
377 Index += 1;
378 }
379
380 return EFI_SUCCESS;
381 }
382
383 /**
384 Print the information in Extra Data Guid Hob.
385 @param[in] HobRaw A pointer to the start of gUniversalPayloadExtraDataGuid HOB.
386 @param[in] HobLength The size of the HOB data buffer.
387
388 @retval EFI_SUCCESS If it completed successfully.
389 **/
390 EFI_STATUS
391 PrintExtraDataGuidHob (
392 IN UINT8 *HobRaw,
393 IN UINT16 HobLength
394 )
395 {
396 UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData;
397 UINTN Index;
398 UINTN Length;
399
400 Index = 0;
401 ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *)GET_GUID_HOB_DATA (HobRaw);
402 Length = sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA) + ExtraData->Count * sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA_ENTRY);
403 ASSERT (HobLength >= Length);
404 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", ExtraData->Header.Revision));
405 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", ExtraData->Header.Length));
406 DEBUG ((DEBUG_INFO, " Count = 0x%x\n", ExtraData->Count));
407
408 while (Index < ExtraData->Count) {
409 DEBUG ((DEBUG_INFO, " Id[%d] = %a\n", Index, ExtraData->Entry[Index].Identifier));
410 DEBUG ((DEBUG_INFO, " Base[%d] = 0x%lx\n", Index, ExtraData->Entry[Index].Base));
411 DEBUG ((DEBUG_INFO, " Size[%d] = 0x%lx\n", Index, ExtraData->Entry[Index].Size));
412 Index += 1;
413 }
414
415 return EFI_SUCCESS;
416 }
417
418 /**
419 Print the information in MemoryTypeInfoGuidHob.
420 @param[in] HobRaw A pointer to the start of gEfiMemoryTypeInformationGuid HOB.
421 @param[in] HobLength The size of the HOB data buffer.
422
423 @retval EFI_SUCCESS If it completed successfully.
424 **/
425 EFI_STATUS
426 PrintMemoryTypeInfoGuidHob (
427 IN UINT8 *HobRaw,
428 IN UINT16 HobLength
429 )
430 {
431 EFI_MEMORY_TYPE_INFORMATION *MemoryTypeInfo;
432
433 MemoryTypeInfo = (EFI_MEMORY_TYPE_INFORMATION *)GET_GUID_HOB_DATA (HobRaw);
434 ASSERT (HobLength >= sizeof (*MemoryTypeInfo));
435 DEBUG ((DEBUG_INFO, " Type = 0x%x\n", MemoryTypeInfo->Type));
436 DEBUG ((DEBUG_INFO, " NumberOfPages = 0x%x\n", MemoryTypeInfo->NumberOfPages));
437 return EFI_SUCCESS;
438 }
439
440 /**
441 Print the information in EdkiiBootManagerMenuFileGuid.
442 @param[in] HobRaw A pointer to the start of gEdkiiBootManagerMenuFileGuid HOB.
443 @param[in] HobLength The size of the HOB data buffer.
444 @retval EFI_SUCCESS If it completed successfully.
445 **/
446 EFI_STATUS
447 PrintBootManagerMenuGuidHob (
448 IN UINT8 *HobRaw,
449 IN UINT16 HobLength
450 )
451 {
452 UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *BootManagerMenuFile;
453
454 BootManagerMenuFile = (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *)GET_GUID_HOB_DATA (HobRaw);
455 ASSERT (HobLength >= sizeof (*BootManagerMenuFile));
456 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", BootManagerMenuFile->Header.Revision));
457 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", BootManagerMenuFile->Header.Length));
458 DEBUG ((DEBUG_INFO, " FileName = %g\n", &BootManagerMenuFile->FileName));
459 return EFI_SUCCESS;
460 }
461
462 //
463 // Mappint table for dump Guid Hob information.
464 // This table can be easily extented.
465 //
466 GUID_HOB_PRINT_HANDLE GuidHobPrintHandleTable[] = {
467 { &gUniversalPayloadAcpiTableGuid, PrintAcpiGuidHob, "gUniversalPayloadAcpiTableGuid(ACPI table Guid)" },
468 { &gUniversalPayloadSerialPortInfoGuid, PrintSerialGuidHob, "gUniversalPayloadSerialPortInfoGuid(Serial Port Info)" },
469 { &gUniversalPayloadSmbios3TableGuid, PrintSmbios3GuidHob, "gUniversalPayloadSmbios3TableGuid(SmBios Guid)" },
470 { &gUniversalPayloadSmbiosTableGuid, PrintSmbiosTablGuidHob, "gUniversalPayloadSmbiosTableGuid(SmBios Guid)" },
471 { &gUefiAcpiBoardInfoGuid, PrintAcpiBoardInfoGuidHob, "gUefiAcpiBoardInfoGuid(Acpi Guid)" },
472 { &gUniversalPayloadPciRootBridgeInfoGuid, PrintPciRootBridgeInfoGuidHob, "gUniversalPayloadPciRootBridgeInfoGuid(Pci Guid)" },
473 { &gEfiMemoryTypeInformationGuid, PrintMemoryTypeInfoGuidHob, "gEfiMemoryTypeInformationGuid(Memory Type Information Guid)" },
474 { &gUniversalPayloadExtraDataGuid, PrintExtraDataGuidHob, "gUniversalPayloadExtraDataGuid(PayLoad Extra Data Guid)" },
475 { &gEdkiiBootManagerMenuFileGuid, PrintBootManagerMenuGuidHob, "gEdkiiBootManagerMenuFileGuid(Boot Manager Menu File Guid)" }
476 };
477
478 /**
479 Print the Guid Hob using related print handle function.
480 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_GUID_EXTENSION.
481 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_GUID_EXTENSION.
482 @retval EFI_SUCCESS If it completed successfully.
483 **/
484 EFI_STATUS
485 PrintGuidHob (
486 IN VOID *HobStart,
487 IN UINT16 HobLength
488 )
489 {
490 EFI_PEI_HOB_POINTERS Hob;
491 UINTN Index;
492 EFI_STATUS Status;
493
494 Hob.Raw = (UINT8 *)HobStart;
495 ASSERT (HobLength >= sizeof (Hob.Guid));
496
497 for (Index = 0; Index < ARRAY_SIZE (GuidHobPrintHandleTable); Index++) {
498 if (CompareGuid (&Hob.Guid->Name, GuidHobPrintHandleTable[Index].Guid)) {
499 DEBUG ((DEBUG_INFO, " Guid = %a\n", GuidHobPrintHandleTable[Index].GuidName));
500 Status = GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, GET_GUID_HOB_DATA_SIZE (Hob.Raw));
501 return Status;
502 }
503 }
504
505 DEBUG ((DEBUG_INFO, " Name = %g\n", &Hob.Guid->Name));
506 PrintHex (GET_GUID_HOB_DATA (Hob.Raw), GET_GUID_HOB_DATA_SIZE (Hob.Raw));
507 return EFI_SUCCESS;
508 }
509
510 /**
511 Print the information in FV Hob.
512 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV.
513 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV.
514 @retval EFI_SUCCESS If it completed successfully.
515 **/
516 EFI_STATUS
517 PrintFvHob (
518 IN VOID *HobStart,
519 IN UINT16 HobLength
520 )
521 {
522 EFI_PEI_HOB_POINTERS Hob;
523
524 Hob.Raw = (UINT8 *)HobStart;
525 ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume));
526
527 DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume->BaseAddress));
528 DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume->Length));
529 return EFI_SUCCESS;
530 }
531
532 /**
533 Print the information in Cpu Hob.
534 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_CPU.
535 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_CPU.
536 @retval EFI_SUCCESS If it completed successfully.
537 **/
538 EFI_STATUS
539 PrintCpuHob (
540 IN VOID *HobStart,
541 IN UINT16 HobLength
542 )
543 {
544 EFI_PEI_HOB_POINTERS Hob;
545
546 Hob.Raw = (UINT8 *)HobStart;
547 ASSERT (HobLength >= sizeof (*Hob.Cpu));
548
549 DEBUG ((DEBUG_INFO, " SizeOfMemorySpace = 0x%lx\n", Hob.Cpu->SizeOfMemorySpace));
550 DEBUG ((DEBUG_INFO, " SizeOfIoSpace = 0x%lx\n", Hob.Cpu->SizeOfIoSpace));
551 return EFI_SUCCESS;
552 }
553
554 /**
555 Print the information in MemoryPoolHob.
556 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_MEMORY_POOL.
557 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_MEMORY_POOL.
558 @retval EFI_SUCCESS If it completed successfully.
559 **/
560 EFI_STATUS
561 PrintMemoryPoolHob (
562 IN VOID *HobStart,
563 IN UINT16 HobLength
564 )
565 {
566 return EFI_SUCCESS;
567 }
568
569 /**
570 Print the information in Fv2Hob.
571 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV2.
572 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV2.
573 @retval EFI_SUCCESS If it completed successfully.
574 **/
575 EFI_STATUS
576 PrintFv2Hob (
577 IN VOID *HobStart,
578 IN UINT16 HobLength
579 )
580 {
581 EFI_PEI_HOB_POINTERS Hob;
582
583 Hob.Raw = (UINT8 *)HobStart;
584 ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume2));
585
586 DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume2->BaseAddress));
587 DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume2->Length));
588 DEBUG ((DEBUG_INFO, " FvName = %g\n", &Hob.FirmwareVolume2->FvName));
589 DEBUG ((DEBUG_INFO, " FileName = %g\n", &Hob.FirmwareVolume2->FileName));
590 return EFI_SUCCESS;
591 }
592
593 /**
594 Print the information in Capsule Hob.
595 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_UEFI_CAPSULE.
596 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_UEFI_CAPSULE.
597 @retval EFI_SUCCESS If it completed successfully.
598 **/
599 EFI_STATUS
600 PrintCapsuleHob (
601 IN VOID *HobStart,
602 IN UINT16 HobLength
603 )
604 {
605 EFI_PEI_HOB_POINTERS Hob;
606
607 Hob.Raw = (UINT8 *)HobStart;
608 ASSERT (HobLength >= sizeof (*Hob.Capsule));
609
610 DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.Capsule->BaseAddress));
611 DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.Capsule->Length));
612 return EFI_SUCCESS;
613 }
614
615 /**
616 Print the information in Fv3 Hob.
617 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV3.
618 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV3.
619 @retval EFI_SUCCESS If it completed successfully.
620 **/
621 EFI_STATUS
622 PrintFv3Hob (
623 IN VOID *HobStart,
624 IN UINT16 HobLength
625 )
626 {
627 EFI_PEI_HOB_POINTERS Hob;
628
629 Hob.Raw = (UINT8 *)HobStart;
630 ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume3));
631
632 DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume3->BaseAddress));
633 DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume3->Length));
634 DEBUG ((DEBUG_INFO, " AuthenticationStatus = 0x%x\n", Hob.FirmwareVolume3->AuthenticationStatus));
635 DEBUG ((DEBUG_INFO, " ExtractedFv = %a\n", (Hob.FirmwareVolume3->ExtractedFv ? "True" : "False")));
636 DEBUG ((DEBUG_INFO, " FVName = %g\n", &Hob.FirmwareVolume3->FvName));
637 DEBUG ((DEBUG_INFO, " FileName = %g\n", &Hob.FirmwareVolume3->FileName));
638 return EFI_SUCCESS;
639 }
640
641 //
642 // Mappint table from Hob type to Hob print function.
643 //
644 HOB_PRINT_HANDLER_TABLE mHobHandles[] = {
645 { EFI_HOB_TYPE_HANDOFF, "EFI_HOB_TYPE_HANDOFF", PrintHandOffHob },
646 { EFI_HOB_TYPE_MEMORY_ALLOCATION, "EFI_HOB_TYPE_MEMORY_ALLOCATION", PrintMemoryAllocationHob },
647 { EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR", PrintResourceDiscriptorHob },
648 { EFI_HOB_TYPE_GUID_EXTENSION, "EFI_HOB_TYPE_GUID_EXTENSION", PrintGuidHob },
649 { EFI_HOB_TYPE_FV, "EFI_HOB_TYPE_FV", PrintFvHob },
650 { EFI_HOB_TYPE_CPU, "EFI_HOB_TYPE_CPU", PrintCpuHob },
651 { EFI_HOB_TYPE_MEMORY_POOL, "EFI_HOB_TYPE_MEMORY_POOL", PrintMemoryPoolHob },
652 { EFI_HOB_TYPE_FV2, "EFI_HOB_TYPE_FV2", PrintFv2Hob },
653 { EFI_HOB_TYPE_UEFI_CAPSULE, "EFI_HOB_TYPE_UEFI_CAPSULE", PrintCapsuleHob },
654 { EFI_HOB_TYPE_FV3, "EFI_HOB_TYPE_FV3", PrintFv3Hob }
655 };
656
657 /**
658 Print all HOBs info from the HOB list.
659 @param[in] HobStart A pointer to the HOB list
660 @return The pointer to the HOB list.
661 **/
662 VOID
663 PrintHob (
664 IN CONST VOID *HobStart
665 )
666 {
667 EFI_PEI_HOB_POINTERS Hob;
668 UINTN Count;
669 UINTN Index;
670
671 ASSERT (HobStart != NULL);
672
673 Hob.Raw = (UINT8 *)HobStart;
674 DEBUG ((DEBUG_INFO, "Print all Hob information from Hob 0x%p\n", Hob.Raw));
675
676 Count = 0;
677 //
678 // Parse the HOB list to see which type it is, and print the information.
679 //
680 while (!END_OF_HOB_LIST (Hob)) {
681 for (Index = 0; Index < ARRAY_SIZE (mHobHandles); Index++) {
682 if (Hob.Header->HobType == mHobHandles[Index].Type) {
683 DEBUG ((DEBUG_INFO, "HOB[%d]: Type = %a, Offset = 0x%p, Length = 0x%x\n", Count, mHobHandles[Index].Name, (Hob.Raw - (UINT8 *)HobStart), Hob.Header->HobLength));
684 mHobHandles[Index].PrintHandler (Hob.Raw, Hob.Header->HobLength);
685 break;
686 }
687 }
688
689 if (Index == ARRAY_SIZE (mHobHandles)) {
690 DEBUG ((DEBUG_INFO, "HOB[%d]: Type = %d, Offset = 0x%p, Length = 0x%x\n", Count, Hob.Header->HobType, (Hob.Raw - (UINT8 *)HobStart), Hob.Header->HobLength));
691 DEBUG ((DEBUG_INFO, " Unkown Hob type\n"));
692 PrintHex (Hob.Raw, Hob.Header->HobLength);
693 }
694
695 Count++;
696 Hob.Raw = GET_NEXT_HOB (Hob);
697 }
698
699 DEBUG ((DEBUG_INFO, "There are totally %d Hobs, the End Hob address is %p\n", Count, Hob.Raw));
700 }