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