--- /dev/null
+/** @file\r
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#include "UefiPayloadEntry.h"\r
+#include <UniversalPayload/AcpiTable.h>\r
+#include <UniversalPayload/SerialPortInfo.h>\r
+#include <UniversalPayload/PciRootBridges.h>\r
+#include <UniversalPayload/ExtraData.h>\r
+#include <Guid/MemoryTypeInformation.h>\r
+#include <Guid/AcpiBoardInfoGuid.h>\r
+\r
+#define ROW_LIMITER 16\r
+\r
+typedef\r
+EFI_STATUS\r
+(*HOB_PRINT_HANDLER) (\r
+ IN VOID *Hob,\r
+ IN UINT16 HobLength\r
+);\r
+\r
+typedef struct{\r
+ UINT16 Type;\r
+ CHAR8 *Name;\r
+ HOB_PRINT_HANDLER PrintHandler;\r
+} HOB_PRINT_HANDLER_TABLE;\r
+\r
+CHAR8 * mMemoryTypeStr[] = {\r
+ "EfiReservedMemoryType",\r
+ "EfiLoaderCode",\r
+ "EfiLoaderData",\r
+ "EfiBootServicesCode",\r
+ "EfiBootServicesData",\r
+ "EfiRuntimeServicesCode",\r
+ "EfiRuntimeServicesData",\r
+ "EfiConventionalMemory",\r
+ "EfiUnusableMemory",\r
+ "EfiACPIReclaimMemory",\r
+ "EfiACPIMemoryNVS",\r
+ "EfiMemoryMappedIO",\r
+ "EfiMemoryMappedIOPortSpace",\r
+ "EfiPalCode",\r
+ "EfiPersistentMemory",\r
+ "EfiMaxMemoryType"\r
+};\r
+\r
+CHAR8 * mResource_Type_List[] = {\r
+ "EFI_RESOURCE_SYSTEM_MEMORY ", //0x00000000\r
+ "EFI_RESOURCE_MEMORY_MAPPED_IO ", //0x00000001\r
+ "EFI_RESOURCE_IO ", //0x00000002\r
+ "EFI_RESOURCE_FIRMWARE_DEVICE ", //0x00000003\r
+ "EFI_RESOURCE_MEMORY_MAPPED_IO_PORT ", //0x00000004\r
+ "EFI_RESOURCE_MEMORY_RESERVED ", //0x00000005\r
+ "EFI_RESOURCE_IO_RESERVED ", //0x00000006\r
+ "EFI_RESOURCE_MAX_MEMORY_TYPE " //0x00000007\r
+};\r
+\r
+typedef\r
+EFI_STATUS\r
+(*GUID_HOB_PRINT) (\r
+ IN UINT8 *HobRaw,\r
+ IN UINT16 HobLength\r
+);\r
+\r
+typedef struct {\r
+ EFI_GUID *Guid;\r
+ GUID_HOB_PRINT PrintHandler;\r
+ CHAR8 *GuidName;\r
+} GUID_HOB_PRINT_HANDLE;\r
+\r
+typedef struct{\r
+ EFI_GUID *Guid;\r
+ CHAR8 *Type;\r
+} PRINT_MEMORY_ALLOCCATION_HOB;\r
+\r
+\r
+/**\r
+ Print the Hex value of a given range.\r
+ @param[in] DataStart A pointer to the start of data to be printed.\r
+ @param[in] DataSize The length of the data to be printed.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintHex (\r
+ IN UINT8 *DataStart,\r
+ IN UINT16 DataSize\r
+ )\r
+{\r
+ UINTN Index1;\r
+ UINTN Index2;\r
+ UINT8 *StartAddr;\r
+\r
+ StartAddr = DataStart;\r
+ for (Index1 = 0; Index1 * ROW_LIMITER < DataSize; Index1++) {\r
+ DEBUG ((DEBUG_VERBOSE, " 0x%04p:", (DataStart - StartAddr)));\r
+ for (Index2 = 0; (Index2 < ROW_LIMITER) && (Index1 * ROW_LIMITER + Index2 < DataSize); Index2++){\r
+ DEBUG ((DEBUG_VERBOSE, " %02x", *DataStart));\r
+ DataStart++;\r
+ }\r
+ DEBUG ((DEBUG_VERBOSE, "\n"));\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in HandOffHob.\r
+\r
+ @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_HANDOFF.\r
+ @param[in] HobLength The length in bytes of HOB of type EFI_HOB_TYPE_HANDOFF.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintHandOffHob(\r
+ IN VOID *HobStart,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+ Hob.Raw = (UINT8 *) HobStart;\r
+ ASSERT (HobLength >= sizeof (*Hob.HandoffInformationTable));\r
+ DEBUG ((DEBUG_INFO, " BootMode = 0x%x\n", Hob.HandoffInformationTable->BootMode));\r
+ DEBUG ((DEBUG_INFO, " EfiMemoryTop = 0x%lx\n", Hob.HandoffInformationTable->EfiMemoryTop));\r
+ DEBUG ((DEBUG_INFO, " EfiMemoryBottom = 0x%lx\n", Hob.HandoffInformationTable->EfiMemoryBottom));\r
+ DEBUG ((DEBUG_INFO, " EfiFreeMemoryTop = 0x%lx\n", Hob.HandoffInformationTable->EfiFreeMemoryTop));\r
+ DEBUG ((DEBUG_INFO, " EfiFreeMemoryBottom = 0x%lx\n", Hob.HandoffInformationTable->EfiFreeMemoryBottom));\r
+ DEBUG ((DEBUG_INFO, " EfiEndOfHobList = 0x%lx\n", Hob.HandoffInformationTable->EfiEndOfHobList));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in Memory Allocation Hob.\r
+ @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_MEMORY_ALLOCATION.\r
+ @param[in] HobLength The length in bytes of HOB of type EFI_HOB_TYPE_MEMORY_ALLOCATION.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintMemoryAllocationHob (\r
+ IN VOID *HobStart,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+\r
+ Hob.Raw = (UINT8 *) HobStart;\r
+\r
+ if(CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMemoryAllocStackGuid)) {\r
+ ASSERT (HobLength >= sizeof (*Hob.MemoryAllocationStack));\r
+ DEBUG ((DEBUG_INFO, " Type = EFI_HOB_MEMORY_ALLOCATION_STACK\n"));\r
+ } else if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMemoryAllocBspStoreGuid)) {\r
+ ASSERT (HobLength >= sizeof (*Hob.MemoryAllocationBspStore));\r
+ DEBUG ((DEBUG_INFO, " Type = EFI_HOB_MEMORY_ALLOCATION_BSP_STORE\n"));\r
+ } else if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMemoryAllocModuleGuid)) {\r
+ ASSERT (HobLength >= sizeof (*Hob.MemoryAllocationModule));\r
+ DEBUG ((DEBUG_INFO, " Type = EFI_HOB_MEMORY_ALLOCATION_MODULE\n"));\r
+ DEBUG ((DEBUG_INFO, " Module Name = %g\n", Hob.MemoryAllocationModule->ModuleName));\r
+ DEBUG ((DEBUG_INFO, " Physical Address = 0x%lx\n", Hob.MemoryAllocationModule->EntryPoint));\r
+ } else {\r
+ ASSERT (HobLength >= sizeof (*Hob.MemoryAllocation));\r
+ DEBUG ((DEBUG_INFO, " Type = EFI_HOB_TYPE_MEMORY_ALLOCATION\n"));\r
+ }\r
+ DEBUG ((DEBUG_INFO, " MemoryBaseAddress = 0x%lx\n", Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress));\r
+ DEBUG ((DEBUG_INFO, " MemoryLength = 0x%lx\n", Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength));\r
+ DEBUG ((DEBUG_INFO, " MemoryType = %a \n", mMemoryTypeStr[Hob.MemoryAllocationStack->AllocDescriptor.MemoryType]));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in Resource Discriptor Hob.\r
+ @param[in] HobStart A pointer to HOB of type EFI_HOB_TYPE_RESOURCE_DESCRIPTOR.\r
+ @param[in] HobLength The Length in bytes of HOB of type EFI_HOB_TYPE_RESOURCE_DESCRIPTOR.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintResourceDiscriptorHob (\r
+ IN VOID *HobStart,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+\r
+ Hob.Raw = (UINT8 *) HobStart;\r
+ ASSERT (HobLength >= sizeof (*Hob.ResourceDescriptor));\r
+\r
+ DEBUG ((DEBUG_INFO, " ResourceType = %a\n", mResource_Type_List[Hob.ResourceDescriptor->ResourceType]));\r
+ if(!IsZeroGuid (&Hob.ResourceDescriptor->Owner)) {\r
+ DEBUG ((DEBUG_INFO, " Owner = %g\n", Hob.ResourceDescriptor->Owner));\r
+ }\r
+ DEBUG ((DEBUG_INFO, " ResourceAttribute = 0x%x\n", Hob.ResourceDescriptor->ResourceAttribute));\r
+ DEBUG ((DEBUG_INFO, " PhysicalStart = 0x%lx\n", Hob.ResourceDescriptor->PhysicalStart));\r
+ DEBUG ((DEBUG_INFO, " ResourceLength = 0x%lx\n", Hob.ResourceDescriptor->ResourceLength));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in Acpi Guid Hob.\r
+ @param[in] HobRaw A pointer to the start of gUniversalPayloadAcpiTableGuid HOB.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintAcpiGuidHob (\r
+ IN UINT8 *HobRaw,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob;\r
+ AcpiTableHob = (UNIVERSAL_PAYLOAD_ACPI_TABLE *) GET_GUID_HOB_DATA (HobRaw);\r
+ ASSERT (HobLength >= AcpiTableHob->Header.Length);\r
+ DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpiTableHob->Header.Revision));\r
+ DEBUG ((DEBUG_INFO, " Length = 0x%x\n", AcpiTableHob->Header.Length));\r
+ DEBUG ((DEBUG_INFO, " Rsdp = 0x%p\n", (UINT64) AcpiTableHob->Rsdp));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in Serial Guid Hob.\r
+ @param[in] HobRaw A pointer to the start of gUniversalPayloadSerialPortInfoGuid HOB.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintSerialGuidHob (\r
+ IN UINT8 *HobRaw,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *SerialPortInfo;\r
+ SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *) GET_GUID_HOB_DATA (HobRaw);\r
+ ASSERT (HobLength >= SerialPortInfo->Header.Length);\r
+ DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SerialPortInfo->Header.Revision));\r
+ DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SerialPortInfo->Header.Length));\r
+ DEBUG ((DEBUG_INFO, " UseMmio = 0x%x\n", SerialPortInfo->UseMmio));\r
+ DEBUG ((DEBUG_INFO, " RegisterStride = 0x%x\n", SerialPortInfo->RegisterStride));\r
+ DEBUG ((DEBUG_INFO, " BaudRate = %d\n", SerialPortInfo->BaudRate));\r
+ DEBUG ((DEBUG_INFO, " RegisterBase = 0x%lx\n", SerialPortInfo->RegisterBase));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in Smbios Guid Hob.\r
+ @param[in] HobRaw A pointer to the start of gUniversalPayloadSmbios3TableGuid HOB.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintSmbios3GuidHob (\r
+ IN UINT8 *HobRaw,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable;\r
+ SmBiosTable = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *) GET_GUID_HOB_DATA (HobRaw);\r
+ ASSERT (HobLength >= SmBiosTable->Header.Length);\r
+ DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision));\r
+ DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SmBiosTable->Header.Length));\r
+ DEBUG ((DEBUG_INFO, " SmBiosEntryPoint = 0x%lx\n", (UINT64) SmBiosTable->SmBiosEntryPoint));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in Smbios Guid Hob.\r
+ @param[in] HobRaw A pointer to the start of gUniversalPayloadSmbiosTableGuid HOB.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintSmbiosTablGuidHob (\r
+ IN UINT8 *HobRaw,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable;\r
+ SmBiosTable = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *) GET_GUID_HOB_DATA (HobRaw);\r
+ ASSERT (HobLength >= SmBiosTable->Header.Length);\r
+ DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision));\r
+ DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SmBiosTable->Header.Length));\r
+ DEBUG ((DEBUG_INFO, " SmBiosEntryPoint = 0x%lx\n", (UINT64) SmBiosTable->SmBiosEntryPoint));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in Acpi BoardInfo Guid Hob.\r
+ @param[in] HobRaw A pointer to the start of gUefiAcpiBoardInfoGuid HOB.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintAcpiBoardInfoGuidHob (\r
+ IN UINT8 *HobRaw,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ ACPI_BOARD_INFO *AcpBoardInfo;\r
+ AcpBoardInfo = (ACPI_BOARD_INFO *) GET_GUID_HOB_DATA (HobRaw);\r
+ ASSERT (HobLength >= sizeof (*AcpBoardInfo));\r
+ DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpBoardInfo->Revision));\r
+ DEBUG ((DEBUG_INFO, " Reserved0 = 0x%x\n", AcpBoardInfo->Reserved0));\r
+ DEBUG ((DEBUG_INFO, " ResetValue = 0x%x\n", AcpBoardInfo->ResetValue));\r
+ DEBUG ((DEBUG_INFO, " PmEvtBase = 0x%lx\n", AcpBoardInfo->PmEvtBase));\r
+ DEBUG ((DEBUG_INFO, " PmGpeEnBase = 0x%lx\n", AcpBoardInfo->PmGpeEnBase));\r
+ DEBUG ((DEBUG_INFO, " PmCtrlRegBase = 0x%lx\n", AcpBoardInfo->PmCtrlRegBase));\r
+ DEBUG ((DEBUG_INFO, " PmTimerRegBase = 0x%lx\n", AcpBoardInfo->PmTimerRegBase));\r
+ DEBUG ((DEBUG_INFO, " ResetRegAddress = 0x%lx\n", AcpBoardInfo->ResetRegAddress));\r
+ DEBUG ((DEBUG_INFO, " PcieBaseAddress = 0x%lx\n", AcpBoardInfo->PcieBaseAddress));\r
+ DEBUG ((DEBUG_INFO, " PcieBaseSize = 0x%lx\n", AcpBoardInfo->PcieBaseSize));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in Pci RootBridge Info Guid Hob.\r
+ @param[in] HobRaw A pointer to the start of gUniversalPayloadPciRootBridgeInfoGuid HOB.\r
+\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintPciRootBridgeInfoGuidHob (\r
+ IN UINT8 *HobRaw,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridges;\r
+ UINTN Index;\r
+ Index = 0;\r
+ PciRootBridges = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GET_GUID_HOB_DATA (HobRaw);\r
+ ASSERT (HobLength >= sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES));\r
+ DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", PciRootBridges->Header.Revision));\r
+ DEBUG ((DEBUG_INFO, " Length = 0x%x\n", PciRootBridges->Header.Length));\r
+ DEBUG ((DEBUG_INFO, " Count = 0x%x\n", PciRootBridges->Count));\r
+ DEBUG ((DEBUG_INFO, " ResourceAssigned = %a\n", (PciRootBridges->ResourceAssigned ? "True" : "False")));\r
+\r
+ while(Index < PciRootBridges->Count) {\r
+ DEBUG ((DEBUG_INFO, " Root Bridge Index[%d]:\n", Index));\r
+ DEBUG ((DEBUG_INFO, " Segment = 0x%x\n", PciRootBridges->RootBridge[Index].Segment));\r
+ DEBUG ((DEBUG_INFO, " Supports = 0x%lx\n", PciRootBridges->RootBridge[Index].Supports));\r
+ DEBUG ((DEBUG_INFO, " Attributes = 0x%lx\n", PciRootBridges->RootBridge[Index].Attributes));\r
+ DEBUG ((DEBUG_INFO, " DmaAbove4G = 0x%x\n", PciRootBridges->RootBridge[Index].DmaAbove4G));\r
+ DEBUG ((DEBUG_INFO, " NoExtendedConfigSpace = 0x%x\n", PciRootBridges->RootBridge[Index].NoExtendedConfigSpace));\r
+ DEBUG ((DEBUG_INFO, " AllocationAttributes = 0x%lx\n", PciRootBridges->RootBridge[Index].AllocationAttributes));\r
+ DEBUG ((DEBUG_INFO, " Bus.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Base));\r
+ DEBUG ((DEBUG_INFO, " Bus.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Limit));\r
+ DEBUG ((DEBUG_INFO, " Bus.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Translation));\r
+ DEBUG ((DEBUG_INFO, " Io.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Base));\r
+ DEBUG ((DEBUG_INFO, " Io.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Limit));\r
+ DEBUG ((DEBUG_INFO, " Io.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Translation));\r
+ DEBUG ((DEBUG_INFO, " Mem.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Base));\r
+ DEBUG ((DEBUG_INFO, " Mem.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Limit));\r
+ DEBUG ((DEBUG_INFO, " Mem.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Translation));\r
+ DEBUG ((DEBUG_INFO, " MemAbove4G.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Base));\r
+ DEBUG ((DEBUG_INFO, " MemAbove4G.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Limit));\r
+ DEBUG ((DEBUG_INFO, " MemAbove4G.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Translation));\r
+ DEBUG ((DEBUG_INFO, " PMem.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Base));\r
+ DEBUG ((DEBUG_INFO, " PMem.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Limit));\r
+ DEBUG ((DEBUG_INFO, " PMem.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Translation));\r
+ DEBUG ((DEBUG_INFO, " PMemAbove4G.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Base));\r
+ DEBUG ((DEBUG_INFO, " PMemAbove4G.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Limit));\r
+ DEBUG ((DEBUG_INFO, " PMemAbove4G.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Translation));\r
+ Index+=1;\r
+ }\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in Extra Data Guid Hob.\r
+ @param[in] HobRaw A pointer to the start of gUniversalPayloadExtraDataGuid HOB.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintExtraDataGuidHob (\r
+ IN UINT8 *HobRaw,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData;\r
+ UINTN Index;\r
+\r
+ Index = 0;\r
+ ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *) GET_GUID_HOB_DATA (HobRaw);\r
+ ASSERT (HobLength >= ExtraData->Header.Length);\r
+ DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", ExtraData->Header.Revision));\r
+ DEBUG ((DEBUG_INFO, " Length = 0x%x\n", ExtraData->Header.Length));\r
+ DEBUG ((DEBUG_INFO, " Count = 0x%x\n", ExtraData->Count));\r
+\r
+ while (Index < ExtraData->Count) {\r
+ DEBUG ((DEBUG_INFO, " Id[%d] = %a\n", Index,ExtraData->Entry[Index].Identifier));\r
+ DEBUG ((DEBUG_INFO, " Base[%d] = 0x%lx\n", Index,ExtraData->Entry[Index].Base));\r
+ DEBUG ((DEBUG_INFO, " Size[%d] = 0x%lx\n", Index,ExtraData->Entry[Index].Size));\r
+ Index+=1;\r
+ }\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in MemoryTypeInfoGuidHob.\r
+ @param[in] HobRaw A pointer to the start of gEfiMemoryTypeInformationGuid HOB.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintMemoryTypeInfoGuidHob (\r
+ IN UINT8 *HobRaw,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ EFI_MEMORY_TYPE_INFORMATION *MemoryTypeInfo;\r
+\r
+ MemoryTypeInfo = (EFI_MEMORY_TYPE_INFORMATION *) GET_GUID_HOB_DATA (HobRaw);\r
+ ASSERT (HobLength >= sizeof (*MemoryTypeInfo));\r
+ DEBUG ((DEBUG_INFO, " Type = 0x%x\n", MemoryTypeInfo->Type));\r
+ DEBUG ((DEBUG_INFO, " NumberOfPages = 0x%x\n", MemoryTypeInfo->NumberOfPages));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+//\r
+// Mappint table for dump Guid Hob information.\r
+// This table can be easily extented.\r
+//\r
+GUID_HOB_PRINT_HANDLE GuidHobPrintHandleTable[] = {\r
+ {&gUniversalPayloadAcpiTableGuid, PrintAcpiGuidHob, "gUniversalPayloadAcpiTableGuid(ACPI table Guid)"},\r
+ {&gUniversalPayloadSerialPortInfoGuid, PrintSerialGuidHob, "gUniversalPayloadSerialPortInfoGuid(Serial Port Info)"},\r
+ {&gUniversalPayloadSmbios3TableGuid, PrintSmbios3GuidHob, "gUniversalPayloadSmbios3TableGuid(SmBios Guid)"},\r
+ {&gUniversalPayloadSmbiosTableGuid, PrintSmbiosTablGuidHob, "gUniversalPayloadSmbiosTableGuid(SmBios Guid)"},\r
+ {&gUefiAcpiBoardInfoGuid, PrintAcpiBoardInfoGuidHob, "gUefiAcpiBoardInfoGuid(Acpi Guid)"},\r
+ {&gUniversalPayloadPciRootBridgeInfoGuid, PrintPciRootBridgeInfoGuidHob, "gUniversalPayloadPciRootBridgeInfoGuid(Pci Guid)"},\r
+ {&gEfiMemoryTypeInformationGuid, PrintMemoryTypeInfoGuidHob, "gEfiMemoryTypeInformationGuid(Memory Type Information Guid)"},\r
+ {&gUniversalPayloadExtraDataGuid, PrintExtraDataGuidHob, "gUniversalPayloadExtraDataGuid(PayLoad Extra Data Guid)"}\r
+};\r
+\r
+/**\r
+ Print the Guid Hob using related print handle function.\r
+ @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_GUID_EXTENSION.\r
+ @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_GUID_EXTENSION.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintGuidHob (\r
+ IN VOID *HobStart,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+ UINTN Index;\r
+ EFI_STATUS Status;\r
+\r
+ Hob.Raw = (UINT8 *) HobStart;\r
+ ASSERT (HobLength >= sizeof (Hob.Guid));\r
+\r
+ for (Index = 0; Index < ARRAY_SIZE (GuidHobPrintHandleTable); Index++) {\r
+ if (CompareGuid (&Hob.Guid->Name, GuidHobPrintHandleTable[Index].Guid)) {\r
+ DEBUG ((DEBUG_INFO, " Guid = %a\n", GuidHobPrintHandleTable[Index].GuidName));\r
+ Status = GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, Hob.Header->HobLength);\r
+ return Status;\r
+ }\r
+ }\r
+ DEBUG ((DEBUG_INFO, " Name = %g\n", &Hob.Guid->Name));\r
+ PrintHex (GET_GUID_HOB_DATA (Hob.Raw), GET_GUID_HOB_DATA_SIZE (Hob.Raw));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in FV Hob.\r
+ @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV.\r
+ @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintFvHob (\r
+ IN VOID *HobStart,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+\r
+ Hob.Raw = (UINT8 *) HobStart;\r
+ ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume));\r
+\r
+ DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume->BaseAddress));\r
+ DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume->Length));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in Cpu Hob.\r
+ @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_CPU.\r
+ @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_CPU.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintCpuHob (\r
+ IN VOID *HobStart,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+\r
+ Hob.Raw = (UINT8 *) HobStart;\r
+ ASSERT (HobLength >= sizeof (*Hob.Cpu));\r
+\r
+ DEBUG ((DEBUG_INFO, " SizeOfMemorySpace = 0x%lx\n", Hob.Cpu->SizeOfMemorySpace));\r
+ DEBUG ((DEBUG_INFO, " SizeOfIoSpace = 0x%lx\n", Hob.Cpu->SizeOfIoSpace));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in MemoryPoolHob.\r
+ @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_MEMORY_POOL.\r
+ @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_MEMORY_POOL.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintMemoryPoolHob (\r
+ IN VOID *HobStart,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in Fv2Hob.\r
+ @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV2.\r
+ @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV2.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintFv2Hob (\r
+ IN VOID *HobStart,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+\r
+ Hob.Raw = (UINT8 *) HobStart;\r
+ ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume2));\r
+\r
+ DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume2->BaseAddress));\r
+ DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume2->Length));\r
+ DEBUG ((DEBUG_INFO, " FvName = %g\n", &Hob.FirmwareVolume2->FvName));\r
+ DEBUG ((DEBUG_INFO, " FileName = %g\n", &Hob.FirmwareVolume2->FileName));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in Capsule Hob.\r
+ @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_UEFI_CAPSULE.\r
+ @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_UEFI_CAPSULE.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintCapsuleHob (\r
+ IN VOID *HobStart,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+\r
+ Hob.Raw = (UINT8 *) HobStart;\r
+ ASSERT (HobLength >= sizeof (*Hob.Capsule));\r
+\r
+ DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.Capsule->BaseAddress));\r
+ DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.Capsule->Length));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Print the information in Fv3 Hob.\r
+ @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV3.\r
+ @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV3.\r
+ @retval EFI_SUCCESS If it completed successfully.\r
+**/\r
+EFI_STATUS\r
+PrintFv3Hob (\r
+ IN VOID *HobStart,\r
+ IN UINT16 HobLength\r
+ )\r
+{\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+ Hob.Raw = (UINT8 *) HobStart;\r
+ ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume3));\r
+\r
+ DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume3->BaseAddress));\r
+ DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume3->Length));\r
+ DEBUG ((DEBUG_INFO, " AuthenticationStatus = 0x%x\n", Hob.FirmwareVolume3->AuthenticationStatus));\r
+ DEBUG ((DEBUG_INFO, " ExtractedFv = %a\n", (Hob.FirmwareVolume3->ExtractedFv ? "True" : "False")));\r
+ DEBUG ((DEBUG_INFO, " FVName = %g\n", &Hob.FirmwareVolume3->FvName));\r
+ DEBUG ((DEBUG_INFO, " FileName = %g\n", &Hob.FirmwareVolume3->FileName));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+//\r
+// Mappint table from Hob type to Hob print function.\r
+//\r
+HOB_PRINT_HANDLER_TABLE mHobHandles[] = {\r
+ {EFI_HOB_TYPE_HANDOFF, "EFI_HOB_TYPE_HANDOFF", PrintHandOffHob},\r
+ {EFI_HOB_TYPE_MEMORY_ALLOCATION, "EFI_HOB_TYPE_MEMORY_ALLOCATION", PrintMemoryAllocationHob},\r
+ {EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR", PrintResourceDiscriptorHob},\r
+ {EFI_HOB_TYPE_GUID_EXTENSION, "EFI_HOB_TYPE_GUID_EXTENSION", PrintGuidHob},\r
+ {EFI_HOB_TYPE_FV, "EFI_HOB_TYPE_FV", PrintFvHob},\r
+ {EFI_HOB_TYPE_CPU, "EFI_HOB_TYPE_CPU", PrintCpuHob},\r
+ {EFI_HOB_TYPE_MEMORY_POOL, "EFI_HOB_TYPE_MEMORY_POOL", PrintMemoryPoolHob},\r
+ {EFI_HOB_TYPE_FV2, "EFI_HOB_TYPE_FV2", PrintFv2Hob},\r
+ {EFI_HOB_TYPE_UEFI_CAPSULE, "EFI_HOB_TYPE_UEFI_CAPSULE", PrintCapsuleHob},\r
+ {EFI_HOB_TYPE_FV3, "EFI_HOB_TYPE_FV3", PrintFv3Hob}\r
+};\r
+\r
+\r
+/**\r
+ Print all HOBs info from the HOB list.\r
+ @param[in] HobStart A pointer to the HOB list\r
+ @return The pointer to the HOB list.\r
+**/\r
+VOID\r
+PrintHob (\r
+ IN CONST VOID *HobStart\r
+ )\r
+{\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+ UINTN Count;\r
+ UINTN Index;\r
+ ASSERT (HobStart != NULL);\r
+\r
+ Hob.Raw = (UINT8 *) HobStart;\r
+ DEBUG ((DEBUG_INFO, "Print all Hob information from Hob 0x%p\n", Hob.Raw));\r
+\r
+ Count = 0;\r
+ //\r
+ // Parse the HOB list to see which type it is, and print the information.\r
+ //\r
+ while (!END_OF_HOB_LIST (Hob)) {\r
+ for (Index = 0; Index < ARRAY_SIZE (mHobHandles); Index++) {\r
+ if (Hob.Header->HobType == mHobHandles[Index].Type) {\r
+ 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
+ mHobHandles[Index].PrintHandler (Hob.Raw, Hob.Header->HobLength);\r
+ break;\r
+ }\r
+ }\r
+ if (Index == ARRAY_SIZE (mHobHandles)) {\r
+ 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
+ DEBUG ((DEBUG_INFO, " Unkown Hob type\n"));\r
+ PrintHex (Hob.Raw, Hob.Header->HobLength);\r
+ }\r
+ Count++;\r
+ Hob.Raw = GET_NEXT_HOB (Hob);\r
+ }\r
+ DEBUG ((DEBUG_INFO, "There are totally %d Hobs, the End Hob address is %p\n", Count, Hob.Raw));\r
+}\r