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