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