]> git.proxmox.com Git - mirror_edk2.git/blame - UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
UefiPayloadPkg: Replace MEMROY_ENTRY by MEMORY_ENTRY
[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
199 @param[in] HobRaw A pointer to the start of gUniversalPayloadAcpiTableGuid HOB.\r
200 @retval EFI_SUCCESS If it completed successfully.\r
201**/\r
202EFI_STATUS\r
203PrintAcpiGuidHob (\r
204 IN UINT8 *HobRaw,\r
205 IN UINT16 HobLength\r
206 )\r
207{\r
208 UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob;\r
209 AcpiTableHob = (UNIVERSAL_PAYLOAD_ACPI_TABLE *) GET_GUID_HOB_DATA (HobRaw);\r
210 ASSERT (HobLength >= AcpiTableHob->Header.Length);\r
211 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpiTableHob->Header.Revision));\r
212 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", AcpiTableHob->Header.Length));\r
213 DEBUG ((DEBUG_INFO, " Rsdp = 0x%p\n", (UINT64) AcpiTableHob->Rsdp));\r
214 return EFI_SUCCESS;\r
215}\r
216\r
217/**\r
218 Print the information in Serial Guid Hob.\r
219 @param[in] HobRaw A pointer to the start of gUniversalPayloadSerialPortInfoGuid HOB.\r
220 @retval EFI_SUCCESS If it completed successfully.\r
221**/\r
222EFI_STATUS\r
223PrintSerialGuidHob (\r
224 IN UINT8 *HobRaw,\r
225 IN UINT16 HobLength\r
226 )\r
227{\r
228 UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *SerialPortInfo;\r
229 SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *) GET_GUID_HOB_DATA (HobRaw);\r
230 ASSERT (HobLength >= SerialPortInfo->Header.Length);\r
231 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SerialPortInfo->Header.Revision));\r
232 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SerialPortInfo->Header.Length));\r
233 DEBUG ((DEBUG_INFO, " UseMmio = 0x%x\n", SerialPortInfo->UseMmio));\r
234 DEBUG ((DEBUG_INFO, " RegisterStride = 0x%x\n", SerialPortInfo->RegisterStride));\r
235 DEBUG ((DEBUG_INFO, " BaudRate = %d\n", SerialPortInfo->BaudRate));\r
236 DEBUG ((DEBUG_INFO, " RegisterBase = 0x%lx\n", SerialPortInfo->RegisterBase));\r
237 return EFI_SUCCESS;\r
238}\r
239\r
240/**\r
241 Print the information in Smbios Guid Hob.\r
242 @param[in] HobRaw A pointer to the start of gUniversalPayloadSmbios3TableGuid HOB.\r
243 @retval EFI_SUCCESS If it completed successfully.\r
244**/\r
245EFI_STATUS\r
246PrintSmbios3GuidHob (\r
247 IN UINT8 *HobRaw,\r
248 IN UINT16 HobLength\r
249 )\r
250{\r
251 UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable;\r
252 SmBiosTable = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *) GET_GUID_HOB_DATA (HobRaw);\r
253 ASSERT (HobLength >= SmBiosTable->Header.Length);\r
254 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision));\r
255 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SmBiosTable->Header.Length));\r
256 DEBUG ((DEBUG_INFO, " SmBiosEntryPoint = 0x%lx\n", (UINT64) SmBiosTable->SmBiosEntryPoint));\r
257 return EFI_SUCCESS;\r
258}\r
259\r
260/**\r
261 Print the information in Smbios Guid Hob.\r
262 @param[in] HobRaw A pointer to the start of gUniversalPayloadSmbiosTableGuid HOB.\r
263 @retval EFI_SUCCESS If it completed successfully.\r
264**/\r
265EFI_STATUS\r
266PrintSmbiosTablGuidHob (\r
267 IN UINT8 *HobRaw,\r
268 IN UINT16 HobLength\r
269 )\r
270{\r
271 UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable;\r
272 SmBiosTable = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *) GET_GUID_HOB_DATA (HobRaw);\r
273 ASSERT (HobLength >= SmBiosTable->Header.Length);\r
274 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision));\r
275 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SmBiosTable->Header.Length));\r
276 DEBUG ((DEBUG_INFO, " SmBiosEntryPoint = 0x%lx\n", (UINT64) SmBiosTable->SmBiosEntryPoint));\r
277 return EFI_SUCCESS;\r
278}\r
279\r
280/**\r
281 Print the information in Acpi BoardInfo Guid Hob.\r
282 @param[in] HobRaw A pointer to the start of gUefiAcpiBoardInfoGuid HOB.\r
283 @retval EFI_SUCCESS If it completed successfully.\r
284**/\r
285EFI_STATUS\r
286PrintAcpiBoardInfoGuidHob (\r
287 IN UINT8 *HobRaw,\r
288 IN UINT16 HobLength\r
289 )\r
290{\r
291 ACPI_BOARD_INFO *AcpBoardInfo;\r
292 AcpBoardInfo = (ACPI_BOARD_INFO *) GET_GUID_HOB_DATA (HobRaw);\r
293 ASSERT (HobLength >= sizeof (*AcpBoardInfo));\r
294 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpBoardInfo->Revision));\r
295 DEBUG ((DEBUG_INFO, " Reserved0 = 0x%x\n", AcpBoardInfo->Reserved0));\r
296 DEBUG ((DEBUG_INFO, " ResetValue = 0x%x\n", AcpBoardInfo->ResetValue));\r
297 DEBUG ((DEBUG_INFO, " PmEvtBase = 0x%lx\n", AcpBoardInfo->PmEvtBase));\r
298 DEBUG ((DEBUG_INFO, " PmGpeEnBase = 0x%lx\n", AcpBoardInfo->PmGpeEnBase));\r
299 DEBUG ((DEBUG_INFO, " PmCtrlRegBase = 0x%lx\n", AcpBoardInfo->PmCtrlRegBase));\r
300 DEBUG ((DEBUG_INFO, " PmTimerRegBase = 0x%lx\n", AcpBoardInfo->PmTimerRegBase));\r
301 DEBUG ((DEBUG_INFO, " ResetRegAddress = 0x%lx\n", AcpBoardInfo->ResetRegAddress));\r
302 DEBUG ((DEBUG_INFO, " PcieBaseAddress = 0x%lx\n", AcpBoardInfo->PcieBaseAddress));\r
303 DEBUG ((DEBUG_INFO, " PcieBaseSize = 0x%lx\n", AcpBoardInfo->PcieBaseSize));\r
304 return EFI_SUCCESS;\r
305}\r
306\r
307/**\r
308 Print the information in Pci RootBridge Info Guid Hob.\r
309 @param[in] HobRaw A pointer to the start of gUniversalPayloadPciRootBridgeInfoGuid HOB.\r
310\r
311 @retval EFI_SUCCESS If it completed successfully.\r
312**/\r
313EFI_STATUS\r
314PrintPciRootBridgeInfoGuidHob (\r
315 IN UINT8 *HobRaw,\r
316 IN UINT16 HobLength\r
317 )\r
318{\r
319 UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridges;\r
320 UINTN Index;\r
d96df7e9 321 UINTN Length;\r
fda5226a
ZL
322 Index = 0;\r
323 PciRootBridges = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GET_GUID_HOB_DATA (HobRaw);\r
d96df7e9 324 Length = sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES) + PciRootBridges->Count * sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE);\r
325 ASSERT (HobLength >= Length);\r
fda5226a
ZL
326 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", PciRootBridges->Header.Revision));\r
327 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", PciRootBridges->Header.Length));\r
328 DEBUG ((DEBUG_INFO, " Count = 0x%x\n", PciRootBridges->Count));\r
329 DEBUG ((DEBUG_INFO, " ResourceAssigned = %a\n", (PciRootBridges->ResourceAssigned ? "True" : "False")));\r
330\r
331 while(Index < PciRootBridges->Count) {\r
332 DEBUG ((DEBUG_INFO, " Root Bridge Index[%d]:\n", Index));\r
333 DEBUG ((DEBUG_INFO, " Segment = 0x%x\n", PciRootBridges->RootBridge[Index].Segment));\r
334 DEBUG ((DEBUG_INFO, " Supports = 0x%lx\n", PciRootBridges->RootBridge[Index].Supports));\r
335 DEBUG ((DEBUG_INFO, " Attributes = 0x%lx\n", PciRootBridges->RootBridge[Index].Attributes));\r
336 DEBUG ((DEBUG_INFO, " DmaAbove4G = 0x%x\n", PciRootBridges->RootBridge[Index].DmaAbove4G));\r
337 DEBUG ((DEBUG_INFO, " NoExtendedConfigSpace = 0x%x\n", PciRootBridges->RootBridge[Index].NoExtendedConfigSpace));\r
338 DEBUG ((DEBUG_INFO, " AllocationAttributes = 0x%lx\n", PciRootBridges->RootBridge[Index].AllocationAttributes));\r
339 DEBUG ((DEBUG_INFO, " Bus.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Base));\r
340 DEBUG ((DEBUG_INFO, " Bus.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Limit));\r
341 DEBUG ((DEBUG_INFO, " Bus.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Translation));\r
342 DEBUG ((DEBUG_INFO, " Io.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Base));\r
343 DEBUG ((DEBUG_INFO, " Io.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Limit));\r
344 DEBUG ((DEBUG_INFO, " Io.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Translation));\r
345 DEBUG ((DEBUG_INFO, " Mem.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Base));\r
346 DEBUG ((DEBUG_INFO, " Mem.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Limit));\r
347 DEBUG ((DEBUG_INFO, " Mem.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Translation));\r
348 DEBUG ((DEBUG_INFO, " MemAbove4G.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Base));\r
349 DEBUG ((DEBUG_INFO, " MemAbove4G.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Limit));\r
350 DEBUG ((DEBUG_INFO, " MemAbove4G.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Translation));\r
351 DEBUG ((DEBUG_INFO, " PMem.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Base));\r
352 DEBUG ((DEBUG_INFO, " PMem.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Limit));\r
353 DEBUG ((DEBUG_INFO, " PMem.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Translation));\r
354 DEBUG ((DEBUG_INFO, " PMemAbove4G.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Base));\r
355 DEBUG ((DEBUG_INFO, " PMemAbove4G.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Limit));\r
356 DEBUG ((DEBUG_INFO, " PMemAbove4G.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Translation));\r
357 Index+=1;\r
358 }\r
359 return EFI_SUCCESS;\r
360}\r
361\r
362/**\r
363 Print the information in Extra Data Guid Hob.\r
364 @param[in] HobRaw A pointer to the start of gUniversalPayloadExtraDataGuid HOB.\r
365 @retval EFI_SUCCESS If it completed successfully.\r
366**/\r
367EFI_STATUS\r
368PrintExtraDataGuidHob (\r
369 IN UINT8 *HobRaw,\r
370 IN UINT16 HobLength\r
371 )\r
372{\r
373 UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData;\r
374 UINTN Index;\r
d96df7e9 375 UINTN Length;\r
fda5226a
ZL
376\r
377 Index = 0;\r
378 ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *) GET_GUID_HOB_DATA (HobRaw);\r
d96df7e9 379 Length = sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA) + ExtraData->Count * sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA_ENTRY);\r
380 ASSERT (HobLength >= Length);\r
fda5226a
ZL
381 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", ExtraData->Header.Revision));\r
382 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", ExtraData->Header.Length));\r
383 DEBUG ((DEBUG_INFO, " Count = 0x%x\n", ExtraData->Count));\r
384\r
385 while (Index < ExtraData->Count) {\r
386 DEBUG ((DEBUG_INFO, " Id[%d] = %a\n", Index,ExtraData->Entry[Index].Identifier));\r
387 DEBUG ((DEBUG_INFO, " Base[%d] = 0x%lx\n", Index,ExtraData->Entry[Index].Base));\r
388 DEBUG ((DEBUG_INFO, " Size[%d] = 0x%lx\n", Index,ExtraData->Entry[Index].Size));\r
389 Index+=1;\r
390 }\r
391 return EFI_SUCCESS;\r
392}\r
393\r
394/**\r
395 Print the information in MemoryTypeInfoGuidHob.\r
396 @param[in] HobRaw A pointer to the start of gEfiMemoryTypeInformationGuid HOB.\r
397 @retval EFI_SUCCESS If it completed successfully.\r
398**/\r
399EFI_STATUS\r
400PrintMemoryTypeInfoGuidHob (\r
401 IN UINT8 *HobRaw,\r
402 IN UINT16 HobLength\r
403 )\r
404{\r
405 EFI_MEMORY_TYPE_INFORMATION *MemoryTypeInfo;\r
406\r
407 MemoryTypeInfo = (EFI_MEMORY_TYPE_INFORMATION *) GET_GUID_HOB_DATA (HobRaw);\r
408 ASSERT (HobLength >= sizeof (*MemoryTypeInfo));\r
409 DEBUG ((DEBUG_INFO, " Type = 0x%x\n", MemoryTypeInfo->Type));\r
410 DEBUG ((DEBUG_INFO, " NumberOfPages = 0x%x\n", MemoryTypeInfo->NumberOfPages));\r
411 return EFI_SUCCESS;\r
412}\r
413\r
dcd3d63f 414/**\r
415 Print the information in EdkiiBootManagerMenuFileGuid.\r
416 @param[in] HobRaw A pointer to the start of gEdkiiBootManagerMenuFileGuid HOB.\r
417 @param[in] HobLength The size of the data buffer.\r
418 @retval EFI_SUCCESS If it completed successfully.\r
419**/\r
420EFI_STATUS\r
421PrintBootManagerMenuGuidHob (\r
422 IN UINT8 *HobRaw,\r
423 IN UINT16 HobLength\r
424 )\r
425{\r
426 UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *BootManagerMenuFile;\r
427\r
428 BootManagerMenuFile = (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *) GET_GUID_HOB_DATA (HobRaw);\r
429 ASSERT (HobLength >= sizeof (*BootManagerMenuFile));\r
430 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", BootManagerMenuFile->Header.Revision));\r
431 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", BootManagerMenuFile->Header.Length));\r
432 DEBUG ((DEBUG_INFO, " FileName = %g\n", &BootManagerMenuFile->FileName));\r
433 return EFI_SUCCESS;\r
434}\r
435\r
fda5226a
ZL
436//\r
437// Mappint table for dump Guid Hob information.\r
438// This table can be easily extented.\r
439//\r
440GUID_HOB_PRINT_HANDLE GuidHobPrintHandleTable[] = {\r
441 {&gUniversalPayloadAcpiTableGuid, PrintAcpiGuidHob, "gUniversalPayloadAcpiTableGuid(ACPI table Guid)"},\r
442 {&gUniversalPayloadSerialPortInfoGuid, PrintSerialGuidHob, "gUniversalPayloadSerialPortInfoGuid(Serial Port Info)"},\r
443 {&gUniversalPayloadSmbios3TableGuid, PrintSmbios3GuidHob, "gUniversalPayloadSmbios3TableGuid(SmBios Guid)"},\r
444 {&gUniversalPayloadSmbiosTableGuid, PrintSmbiosTablGuidHob, "gUniversalPayloadSmbiosTableGuid(SmBios Guid)"},\r
445 {&gUefiAcpiBoardInfoGuid, PrintAcpiBoardInfoGuidHob, "gUefiAcpiBoardInfoGuid(Acpi Guid)"},\r
446 {&gUniversalPayloadPciRootBridgeInfoGuid, PrintPciRootBridgeInfoGuidHob, "gUniversalPayloadPciRootBridgeInfoGuid(Pci Guid)"},\r
447 {&gEfiMemoryTypeInformationGuid, PrintMemoryTypeInfoGuidHob, "gEfiMemoryTypeInformationGuid(Memory Type Information Guid)"},\r
dcd3d63f 448 {&gUniversalPayloadExtraDataGuid, PrintExtraDataGuidHob, "gUniversalPayloadExtraDataGuid(PayLoad Extra Data Guid)"},\r
449 {&gEdkiiBootManagerMenuFileGuid, PrintBootManagerMenuGuidHob, "gEdkiiBootManagerMenuFileGuid(Boot Manager Menu File Guid)"}\r
fda5226a
ZL
450};\r
451\r
452/**\r
453 Print the Guid Hob using related print handle function.\r
454 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_GUID_EXTENSION.\r
455 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_GUID_EXTENSION.\r
456 @retval EFI_SUCCESS If it completed successfully.\r
457**/\r
458EFI_STATUS\r
459PrintGuidHob (\r
460 IN VOID *HobStart,\r
461 IN UINT16 HobLength\r
462 )\r
463{\r
464 EFI_PEI_HOB_POINTERS Hob;\r
465 UINTN Index;\r
466 EFI_STATUS Status;\r
467\r
468 Hob.Raw = (UINT8 *) HobStart;\r
469 ASSERT (HobLength >= sizeof (Hob.Guid));\r
470\r
471 for (Index = 0; Index < ARRAY_SIZE (GuidHobPrintHandleTable); Index++) {\r
472 if (CompareGuid (&Hob.Guid->Name, GuidHobPrintHandleTable[Index].Guid)) {\r
473 DEBUG ((DEBUG_INFO, " Guid = %a\n", GuidHobPrintHandleTable[Index].GuidName));\r
d96df7e9 474 Status = GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, GET_GUID_HOB_DATA_SIZE (Hob.Raw));\r
fda5226a
ZL
475 return Status;\r
476 }\r
477 }\r
478 DEBUG ((DEBUG_INFO, " Name = %g\n", &Hob.Guid->Name));\r
479 PrintHex (GET_GUID_HOB_DATA (Hob.Raw), GET_GUID_HOB_DATA_SIZE (Hob.Raw));\r
480 return EFI_SUCCESS;\r
481}\r
482\r
483/**\r
484 Print the information in FV Hob.\r
485 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV.\r
486 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV.\r
487 @retval EFI_SUCCESS If it completed successfully.\r
488**/\r
489EFI_STATUS\r
490PrintFvHob (\r
491 IN VOID *HobStart,\r
492 IN UINT16 HobLength\r
493 )\r
494{\r
495 EFI_PEI_HOB_POINTERS Hob;\r
496\r
497 Hob.Raw = (UINT8 *) HobStart;\r
498 ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume));\r
499\r
500 DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume->BaseAddress));\r
501 DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume->Length));\r
502 return EFI_SUCCESS;\r
503}\r
504\r
505/**\r
506 Print the information in Cpu Hob.\r
507 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_CPU.\r
508 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_CPU.\r
509 @retval EFI_SUCCESS If it completed successfully.\r
510**/\r
511EFI_STATUS\r
512PrintCpuHob (\r
513 IN VOID *HobStart,\r
514 IN UINT16 HobLength\r
515 )\r
516{\r
517 EFI_PEI_HOB_POINTERS Hob;\r
518\r
519 Hob.Raw = (UINT8 *) HobStart;\r
520 ASSERT (HobLength >= sizeof (*Hob.Cpu));\r
521\r
522 DEBUG ((DEBUG_INFO, " SizeOfMemorySpace = 0x%lx\n", Hob.Cpu->SizeOfMemorySpace));\r
523 DEBUG ((DEBUG_INFO, " SizeOfIoSpace = 0x%lx\n", Hob.Cpu->SizeOfIoSpace));\r
524 return EFI_SUCCESS;\r
525}\r
526\r
527/**\r
528 Print the information in MemoryPoolHob.\r
529 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_MEMORY_POOL.\r
530 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_MEMORY_POOL.\r
531 @retval EFI_SUCCESS If it completed successfully.\r
532**/\r
533EFI_STATUS\r
534PrintMemoryPoolHob (\r
535 IN VOID *HobStart,\r
536 IN UINT16 HobLength\r
537 )\r
538{\r
539 return EFI_SUCCESS;\r
540}\r
541\r
542/**\r
543 Print the information in Fv2Hob.\r
544 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV2.\r
545 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV2.\r
546 @retval EFI_SUCCESS If it completed successfully.\r
547**/\r
548EFI_STATUS\r
549PrintFv2Hob (\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.FirmwareVolume2));\r
558\r
559 DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume2->BaseAddress));\r
560 DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume2->Length));\r
561 DEBUG ((DEBUG_INFO, " FvName = %g\n", &Hob.FirmwareVolume2->FvName));\r
562 DEBUG ((DEBUG_INFO, " FileName = %g\n", &Hob.FirmwareVolume2->FileName));\r
563 return EFI_SUCCESS;\r
564}\r
565\r
566/**\r
567 Print the information in Capsule Hob.\r
568 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_UEFI_CAPSULE.\r
569 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_UEFI_CAPSULE.\r
570 @retval EFI_SUCCESS If it completed successfully.\r
571**/\r
572EFI_STATUS\r
573PrintCapsuleHob (\r
574 IN VOID *HobStart,\r
575 IN UINT16 HobLength\r
576 )\r
577{\r
578 EFI_PEI_HOB_POINTERS Hob;\r
579\r
580 Hob.Raw = (UINT8 *) HobStart;\r
581 ASSERT (HobLength >= sizeof (*Hob.Capsule));\r
582\r
583 DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.Capsule->BaseAddress));\r
584 DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.Capsule->Length));\r
585 return EFI_SUCCESS;\r
586}\r
587\r
588/**\r
589 Print the information in Fv3 Hob.\r
590 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV3.\r
591 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV3.\r
592 @retval EFI_SUCCESS If it completed successfully.\r
593**/\r
594EFI_STATUS\r
595PrintFv3Hob (\r
596 IN VOID *HobStart,\r
597 IN UINT16 HobLength\r
598 )\r
599{\r
600 EFI_PEI_HOB_POINTERS Hob;\r
601 Hob.Raw = (UINT8 *) HobStart;\r
602 ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume3));\r
603\r
604 DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume3->BaseAddress));\r
605 DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume3->Length));\r
606 DEBUG ((DEBUG_INFO, " AuthenticationStatus = 0x%x\n", Hob.FirmwareVolume3->AuthenticationStatus));\r
607 DEBUG ((DEBUG_INFO, " ExtractedFv = %a\n", (Hob.FirmwareVolume3->ExtractedFv ? "True" : "False")));\r
608 DEBUG ((DEBUG_INFO, " FVName = %g\n", &Hob.FirmwareVolume3->FvName));\r
609 DEBUG ((DEBUG_INFO, " FileName = %g\n", &Hob.FirmwareVolume3->FileName));\r
610 return EFI_SUCCESS;\r
611}\r
612\r
613//\r
614// Mappint table from Hob type to Hob print function.\r
615//\r
616HOB_PRINT_HANDLER_TABLE mHobHandles[] = {\r
617 {EFI_HOB_TYPE_HANDOFF, "EFI_HOB_TYPE_HANDOFF", PrintHandOffHob},\r
618 {EFI_HOB_TYPE_MEMORY_ALLOCATION, "EFI_HOB_TYPE_MEMORY_ALLOCATION", PrintMemoryAllocationHob},\r
619 {EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR", PrintResourceDiscriptorHob},\r
620 {EFI_HOB_TYPE_GUID_EXTENSION, "EFI_HOB_TYPE_GUID_EXTENSION", PrintGuidHob},\r
621 {EFI_HOB_TYPE_FV, "EFI_HOB_TYPE_FV", PrintFvHob},\r
622 {EFI_HOB_TYPE_CPU, "EFI_HOB_TYPE_CPU", PrintCpuHob},\r
623 {EFI_HOB_TYPE_MEMORY_POOL, "EFI_HOB_TYPE_MEMORY_POOL", PrintMemoryPoolHob},\r
624 {EFI_HOB_TYPE_FV2, "EFI_HOB_TYPE_FV2", PrintFv2Hob},\r
625 {EFI_HOB_TYPE_UEFI_CAPSULE, "EFI_HOB_TYPE_UEFI_CAPSULE", PrintCapsuleHob},\r
626 {EFI_HOB_TYPE_FV3, "EFI_HOB_TYPE_FV3", PrintFv3Hob}\r
627};\r
628\r
629\r
630/**\r
631 Print all HOBs info from the HOB list.\r
632 @param[in] HobStart A pointer to the HOB list\r
633 @return The pointer to the HOB list.\r
634**/\r
635VOID\r
636PrintHob (\r
637 IN CONST VOID *HobStart\r
638 )\r
639{\r
640 EFI_PEI_HOB_POINTERS Hob;\r
641 UINTN Count;\r
642 UINTN Index;\r
643 ASSERT (HobStart != NULL);\r
644\r
645 Hob.Raw = (UINT8 *) HobStart;\r
646 DEBUG ((DEBUG_INFO, "Print all Hob information from Hob 0x%p\n", Hob.Raw));\r
647\r
648 Count = 0;\r
649 //\r
650 // Parse the HOB list to see which type it is, and print the information.\r
651 //\r
652 while (!END_OF_HOB_LIST (Hob)) {\r
653 for (Index = 0; Index < ARRAY_SIZE (mHobHandles); Index++) {\r
654 if (Hob.Header->HobType == mHobHandles[Index].Type) {\r
655 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
656 mHobHandles[Index].PrintHandler (Hob.Raw, Hob.Header->HobLength);\r
657 break;\r
658 }\r
659 }\r
660 if (Index == ARRAY_SIZE (mHobHandles)) {\r
661 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
662 DEBUG ((DEBUG_INFO, " Unkown Hob type\n"));\r
663 PrintHex (Hob.Raw, Hob.Header->HobLength);\r
664 }\r
665 Count++;\r
666 Hob.Raw = GET_NEXT_HOB (Hob);\r
667 }\r
668 DEBUG ((DEBUG_INFO, "There are totally %d Hobs, the End Hob address is %p\n", Count, Hob.Raw));\r
669}\r