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