]> git.proxmox.com Git - mirror_edk2.git/blame - UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
UefiPayloadPkg: Dump hob information from boot loader
[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
320 Index = 0;\r
321 PciRootBridges = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GET_GUID_HOB_DATA (HobRaw);\r
322 ASSERT (HobLength >= sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES));\r
323 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", PciRootBridges->Header.Revision));\r
324 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", PciRootBridges->Header.Length));\r
325 DEBUG ((DEBUG_INFO, " Count = 0x%x\n", PciRootBridges->Count));\r
326 DEBUG ((DEBUG_INFO, " ResourceAssigned = %a\n", (PciRootBridges->ResourceAssigned ? "True" : "False")));\r
327\r
328 while(Index < PciRootBridges->Count) {\r
329 DEBUG ((DEBUG_INFO, " Root Bridge Index[%d]:\n", Index));\r
330 DEBUG ((DEBUG_INFO, " Segment = 0x%x\n", PciRootBridges->RootBridge[Index].Segment));\r
331 DEBUG ((DEBUG_INFO, " Supports = 0x%lx\n", PciRootBridges->RootBridge[Index].Supports));\r
332 DEBUG ((DEBUG_INFO, " Attributes = 0x%lx\n", PciRootBridges->RootBridge[Index].Attributes));\r
333 DEBUG ((DEBUG_INFO, " DmaAbove4G = 0x%x\n", PciRootBridges->RootBridge[Index].DmaAbove4G));\r
334 DEBUG ((DEBUG_INFO, " NoExtendedConfigSpace = 0x%x\n", PciRootBridges->RootBridge[Index].NoExtendedConfigSpace));\r
335 DEBUG ((DEBUG_INFO, " AllocationAttributes = 0x%lx\n", PciRootBridges->RootBridge[Index].AllocationAttributes));\r
336 DEBUG ((DEBUG_INFO, " Bus.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Base));\r
337 DEBUG ((DEBUG_INFO, " Bus.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Limit));\r
338 DEBUG ((DEBUG_INFO, " Bus.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Translation));\r
339 DEBUG ((DEBUG_INFO, " Io.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Base));\r
340 DEBUG ((DEBUG_INFO, " Io.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Limit));\r
341 DEBUG ((DEBUG_INFO, " Io.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Translation));\r
342 DEBUG ((DEBUG_INFO, " Mem.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Base));\r
343 DEBUG ((DEBUG_INFO, " Mem.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Limit));\r
344 DEBUG ((DEBUG_INFO, " Mem.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Translation));\r
345 DEBUG ((DEBUG_INFO, " MemAbove4G.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Base));\r
346 DEBUG ((DEBUG_INFO, " MemAbove4G.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Limit));\r
347 DEBUG ((DEBUG_INFO, " MemAbove4G.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Translation));\r
348 DEBUG ((DEBUG_INFO, " PMem.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Base));\r
349 DEBUG ((DEBUG_INFO, " PMem.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Limit));\r
350 DEBUG ((DEBUG_INFO, " PMem.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Translation));\r
351 DEBUG ((DEBUG_INFO, " PMemAbove4G.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Base));\r
352 DEBUG ((DEBUG_INFO, " PMemAbove4G.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Limit));\r
353 DEBUG ((DEBUG_INFO, " PMemAbove4G.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Translation));\r
354 Index+=1;\r
355 }\r
356 return EFI_SUCCESS;\r
357}\r
358\r
359/**\r
360 Print the information in Extra Data Guid Hob.\r
361 @param[in] HobRaw A pointer to the start of gUniversalPayloadExtraDataGuid HOB.\r
362 @retval EFI_SUCCESS If it completed successfully.\r
363**/\r
364EFI_STATUS\r
365PrintExtraDataGuidHob (\r
366 IN UINT8 *HobRaw,\r
367 IN UINT16 HobLength\r
368 )\r
369{\r
370 UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData;\r
371 UINTN Index;\r
372\r
373 Index = 0;\r
374 ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *) GET_GUID_HOB_DATA (HobRaw);\r
375 ASSERT (HobLength >= ExtraData->Header.Length);\r
376 DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", ExtraData->Header.Revision));\r
377 DEBUG ((DEBUG_INFO, " Length = 0x%x\n", ExtraData->Header.Length));\r
378 DEBUG ((DEBUG_INFO, " Count = 0x%x\n", ExtraData->Count));\r
379\r
380 while (Index < ExtraData->Count) {\r
381 DEBUG ((DEBUG_INFO, " Id[%d] = %a\n", Index,ExtraData->Entry[Index].Identifier));\r
382 DEBUG ((DEBUG_INFO, " Base[%d] = 0x%lx\n", Index,ExtraData->Entry[Index].Base));\r
383 DEBUG ((DEBUG_INFO, " Size[%d] = 0x%lx\n", Index,ExtraData->Entry[Index].Size));\r
384 Index+=1;\r
385 }\r
386 return EFI_SUCCESS;\r
387}\r
388\r
389/**\r
390 Print the information in MemoryTypeInfoGuidHob.\r
391 @param[in] HobRaw A pointer to the start of gEfiMemoryTypeInformationGuid HOB.\r
392 @retval EFI_SUCCESS If it completed successfully.\r
393**/\r
394EFI_STATUS\r
395PrintMemoryTypeInfoGuidHob (\r
396 IN UINT8 *HobRaw,\r
397 IN UINT16 HobLength\r
398 )\r
399{\r
400 EFI_MEMORY_TYPE_INFORMATION *MemoryTypeInfo;\r
401\r
402 MemoryTypeInfo = (EFI_MEMORY_TYPE_INFORMATION *) GET_GUID_HOB_DATA (HobRaw);\r
403 ASSERT (HobLength >= sizeof (*MemoryTypeInfo));\r
404 DEBUG ((DEBUG_INFO, " Type = 0x%x\n", MemoryTypeInfo->Type));\r
405 DEBUG ((DEBUG_INFO, " NumberOfPages = 0x%x\n", MemoryTypeInfo->NumberOfPages));\r
406 return EFI_SUCCESS;\r
407}\r
408\r
409//\r
410// Mappint table for dump Guid Hob information.\r
411// This table can be easily extented.\r
412//\r
413GUID_HOB_PRINT_HANDLE GuidHobPrintHandleTable[] = {\r
414 {&gUniversalPayloadAcpiTableGuid, PrintAcpiGuidHob, "gUniversalPayloadAcpiTableGuid(ACPI table Guid)"},\r
415 {&gUniversalPayloadSerialPortInfoGuid, PrintSerialGuidHob, "gUniversalPayloadSerialPortInfoGuid(Serial Port Info)"},\r
416 {&gUniversalPayloadSmbios3TableGuid, PrintSmbios3GuidHob, "gUniversalPayloadSmbios3TableGuid(SmBios Guid)"},\r
417 {&gUniversalPayloadSmbiosTableGuid, PrintSmbiosTablGuidHob, "gUniversalPayloadSmbiosTableGuid(SmBios Guid)"},\r
418 {&gUefiAcpiBoardInfoGuid, PrintAcpiBoardInfoGuidHob, "gUefiAcpiBoardInfoGuid(Acpi Guid)"},\r
419 {&gUniversalPayloadPciRootBridgeInfoGuid, PrintPciRootBridgeInfoGuidHob, "gUniversalPayloadPciRootBridgeInfoGuid(Pci Guid)"},\r
420 {&gEfiMemoryTypeInformationGuid, PrintMemoryTypeInfoGuidHob, "gEfiMemoryTypeInformationGuid(Memory Type Information Guid)"},\r
421 {&gUniversalPayloadExtraDataGuid, PrintExtraDataGuidHob, "gUniversalPayloadExtraDataGuid(PayLoad Extra Data Guid)"}\r
422};\r
423\r
424/**\r
425 Print the Guid Hob using related print handle function.\r
426 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_GUID_EXTENSION.\r
427 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_GUID_EXTENSION.\r
428 @retval EFI_SUCCESS If it completed successfully.\r
429**/\r
430EFI_STATUS\r
431PrintGuidHob (\r
432 IN VOID *HobStart,\r
433 IN UINT16 HobLength\r
434 )\r
435{\r
436 EFI_PEI_HOB_POINTERS Hob;\r
437 UINTN Index;\r
438 EFI_STATUS Status;\r
439\r
440 Hob.Raw = (UINT8 *) HobStart;\r
441 ASSERT (HobLength >= sizeof (Hob.Guid));\r
442\r
443 for (Index = 0; Index < ARRAY_SIZE (GuidHobPrintHandleTable); Index++) {\r
444 if (CompareGuid (&Hob.Guid->Name, GuidHobPrintHandleTable[Index].Guid)) {\r
445 DEBUG ((DEBUG_INFO, " Guid = %a\n", GuidHobPrintHandleTable[Index].GuidName));\r
446 Status = GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, Hob.Header->HobLength);\r
447 return Status;\r
448 }\r
449 }\r
450 DEBUG ((DEBUG_INFO, " Name = %g\n", &Hob.Guid->Name));\r
451 PrintHex (GET_GUID_HOB_DATA (Hob.Raw), GET_GUID_HOB_DATA_SIZE (Hob.Raw));\r
452 return EFI_SUCCESS;\r
453}\r
454\r
455/**\r
456 Print the information in FV Hob.\r
457 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV.\r
458 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV.\r
459 @retval EFI_SUCCESS If it completed successfully.\r
460**/\r
461EFI_STATUS\r
462PrintFvHob (\r
463 IN VOID *HobStart,\r
464 IN UINT16 HobLength\r
465 )\r
466{\r
467 EFI_PEI_HOB_POINTERS Hob;\r
468\r
469 Hob.Raw = (UINT8 *) HobStart;\r
470 ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume));\r
471\r
472 DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume->BaseAddress));\r
473 DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume->Length));\r
474 return EFI_SUCCESS;\r
475}\r
476\r
477/**\r
478 Print the information in Cpu Hob.\r
479 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_CPU.\r
480 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_CPU.\r
481 @retval EFI_SUCCESS If it completed successfully.\r
482**/\r
483EFI_STATUS\r
484PrintCpuHob (\r
485 IN VOID *HobStart,\r
486 IN UINT16 HobLength\r
487 )\r
488{\r
489 EFI_PEI_HOB_POINTERS Hob;\r
490\r
491 Hob.Raw = (UINT8 *) HobStart;\r
492 ASSERT (HobLength >= sizeof (*Hob.Cpu));\r
493\r
494 DEBUG ((DEBUG_INFO, " SizeOfMemorySpace = 0x%lx\n", Hob.Cpu->SizeOfMemorySpace));\r
495 DEBUG ((DEBUG_INFO, " SizeOfIoSpace = 0x%lx\n", Hob.Cpu->SizeOfIoSpace));\r
496 return EFI_SUCCESS;\r
497}\r
498\r
499/**\r
500 Print the information in MemoryPoolHob.\r
501 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_MEMORY_POOL.\r
502 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_MEMORY_POOL.\r
503 @retval EFI_SUCCESS If it completed successfully.\r
504**/\r
505EFI_STATUS\r
506PrintMemoryPoolHob (\r
507 IN VOID *HobStart,\r
508 IN UINT16 HobLength\r
509 )\r
510{\r
511 return EFI_SUCCESS;\r
512}\r
513\r
514/**\r
515 Print the information in Fv2Hob.\r
516 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV2.\r
517 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV2.\r
518 @retval EFI_SUCCESS If it completed successfully.\r
519**/\r
520EFI_STATUS\r
521PrintFv2Hob (\r
522 IN VOID *HobStart,\r
523 IN UINT16 HobLength\r
524 )\r
525{\r
526 EFI_PEI_HOB_POINTERS Hob;\r
527\r
528 Hob.Raw = (UINT8 *) HobStart;\r
529 ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume2));\r
530\r
531 DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume2->BaseAddress));\r
532 DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume2->Length));\r
533 DEBUG ((DEBUG_INFO, " FvName = %g\n", &Hob.FirmwareVolume2->FvName));\r
534 DEBUG ((DEBUG_INFO, " FileName = %g\n", &Hob.FirmwareVolume2->FileName));\r
535 return EFI_SUCCESS;\r
536}\r
537\r
538/**\r
539 Print the information in Capsule Hob.\r
540 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_UEFI_CAPSULE.\r
541 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_UEFI_CAPSULE.\r
542 @retval EFI_SUCCESS If it completed successfully.\r
543**/\r
544EFI_STATUS\r
545PrintCapsuleHob (\r
546 IN VOID *HobStart,\r
547 IN UINT16 HobLength\r
548 )\r
549{\r
550 EFI_PEI_HOB_POINTERS Hob;\r
551\r
552 Hob.Raw = (UINT8 *) HobStart;\r
553 ASSERT (HobLength >= sizeof (*Hob.Capsule));\r
554\r
555 DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.Capsule->BaseAddress));\r
556 DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.Capsule->Length));\r
557 return EFI_SUCCESS;\r
558}\r
559\r
560/**\r
561 Print the information in Fv3 Hob.\r
562 @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV3.\r
563 @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV3.\r
564 @retval EFI_SUCCESS If it completed successfully.\r
565**/\r
566EFI_STATUS\r
567PrintFv3Hob (\r
568 IN VOID *HobStart,\r
569 IN UINT16 HobLength\r
570 )\r
571{\r
572 EFI_PEI_HOB_POINTERS Hob;\r
573 Hob.Raw = (UINT8 *) HobStart;\r
574 ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume3));\r
575\r
576 DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume3->BaseAddress));\r
577 DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume3->Length));\r
578 DEBUG ((DEBUG_INFO, " AuthenticationStatus = 0x%x\n", Hob.FirmwareVolume3->AuthenticationStatus));\r
579 DEBUG ((DEBUG_INFO, " ExtractedFv = %a\n", (Hob.FirmwareVolume3->ExtractedFv ? "True" : "False")));\r
580 DEBUG ((DEBUG_INFO, " FVName = %g\n", &Hob.FirmwareVolume3->FvName));\r
581 DEBUG ((DEBUG_INFO, " FileName = %g\n", &Hob.FirmwareVolume3->FileName));\r
582 return EFI_SUCCESS;\r
583}\r
584\r
585//\r
586// Mappint table from Hob type to Hob print function.\r
587//\r
588HOB_PRINT_HANDLER_TABLE mHobHandles[] = {\r
589 {EFI_HOB_TYPE_HANDOFF, "EFI_HOB_TYPE_HANDOFF", PrintHandOffHob},\r
590 {EFI_HOB_TYPE_MEMORY_ALLOCATION, "EFI_HOB_TYPE_MEMORY_ALLOCATION", PrintMemoryAllocationHob},\r
591 {EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR", PrintResourceDiscriptorHob},\r
592 {EFI_HOB_TYPE_GUID_EXTENSION, "EFI_HOB_TYPE_GUID_EXTENSION", PrintGuidHob},\r
593 {EFI_HOB_TYPE_FV, "EFI_HOB_TYPE_FV", PrintFvHob},\r
594 {EFI_HOB_TYPE_CPU, "EFI_HOB_TYPE_CPU", PrintCpuHob},\r
595 {EFI_HOB_TYPE_MEMORY_POOL, "EFI_HOB_TYPE_MEMORY_POOL", PrintMemoryPoolHob},\r
596 {EFI_HOB_TYPE_FV2, "EFI_HOB_TYPE_FV2", PrintFv2Hob},\r
597 {EFI_HOB_TYPE_UEFI_CAPSULE, "EFI_HOB_TYPE_UEFI_CAPSULE", PrintCapsuleHob},\r
598 {EFI_HOB_TYPE_FV3, "EFI_HOB_TYPE_FV3", PrintFv3Hob}\r
599};\r
600\r
601\r
602/**\r
603 Print all HOBs info from the HOB list.\r
604 @param[in] HobStart A pointer to the HOB list\r
605 @return The pointer to the HOB list.\r
606**/\r
607VOID\r
608PrintHob (\r
609 IN CONST VOID *HobStart\r
610 )\r
611{\r
612 EFI_PEI_HOB_POINTERS Hob;\r
613 UINTN Count;\r
614 UINTN Index;\r
615 ASSERT (HobStart != NULL);\r
616\r
617 Hob.Raw = (UINT8 *) HobStart;\r
618 DEBUG ((DEBUG_INFO, "Print all Hob information from Hob 0x%p\n", Hob.Raw));\r
619\r
620 Count = 0;\r
621 //\r
622 // Parse the HOB list to see which type it is, and print the information.\r
623 //\r
624 while (!END_OF_HOB_LIST (Hob)) {\r
625 for (Index = 0; Index < ARRAY_SIZE (mHobHandles); Index++) {\r
626 if (Hob.Header->HobType == mHobHandles[Index].Type) {\r
627 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
628 mHobHandles[Index].PrintHandler (Hob.Raw, Hob.Header->HobLength);\r
629 break;\r
630 }\r
631 }\r
632 if (Index == ARRAY_SIZE (mHobHandles)) {\r
633 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
634 DEBUG ((DEBUG_INFO, " Unkown Hob type\n"));\r
635 PrintHex (Hob.Raw, Hob.Header->HobLength);\r
636 }\r
637 Count++;\r
638 Hob.Raw = GET_NEXT_HOB (Hob);\r
639 }\r
640 DEBUG ((DEBUG_INFO, "There are totally %d Hobs, the End Hob address is %p\n", Count, Hob.Raw));\r
641}\r