From nobody Sat May 4 05:20:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+77732+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+77732+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1626160308; cv=none; d=zohomail.com; s=zohoarc; b=mApdQXFiIjaeDNTVFA5KTh624bdk1PJrb4/rEKC9Ps9MoGJ72MyISD0OB/jz8UYtPEFfcjebVU0pxqzqwIx7KSEOfJQKstn/7LPAP2mZ/zgYw2dbqF5/56sZ7k8c88VhQU2TySpPNxT+df/DcENxEMtH+piUl57A1tHEjsp1vtg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626160308; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=MG6iNxYMhWil7vKPqFRN+nh2+bl3Uh+tPrfERrR9Scc=; b=S2eBex6AvuzqmgF8f0q7DRz21MGca7T9q3J196Gj1y1SovwKBarta28aLdMnzYwyWuxZs7dWduLzvj8UwWzJxyUyoOuXpd+jTw55RdYqijAGWr91Fxnx+JDG9He3eKudGB+R9CvREypjxzgGPNtM1FIQVwc2LeCvRaNt709uELE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+77732+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1626160308601567.1910542286333; Tue, 13 Jul 2021 00:11:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id cEmxYY1788612xe7R3Z209Nj; Tue, 13 Jul 2021 00:11:48 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web12.1221.1626160301443150839 for ; Tue, 13 Jul 2021 00:11:42 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10043"; a="210087646" X-IronPort-AV: E=Sophos;i="5.84,235,1620716400"; d="scan'208";a="210087646" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2021 00:11:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,235,1620716400"; d="scan'208";a="502865903" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by fmsmga002.fm.intel.com with ESMTP; 13 Jul 2021 00:11:35 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Maurice Ma , Guo Dong , Ray Ni , Benjamin You , Thiyagu Kesavan Balakrishnan Subject: [edk2-devel] [Patch V3] UefiPayloadPkg: Dump hob information from boot loader Date: Tue, 13 Jul 2021 15:10:42 +0800 Message-Id: <20210713071042.2007-1-zhiguang.liu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhiguang.liu@intel.com X-Gm-Message-State: 5CR9Pqjf2kqV4FUpqhjzZyQOx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1626160308; bh=dFGMEAY0oPfzutP5Rnp+w1kaTSNkjtwUXWtpdExdFmU=; h=Cc:Date:From:Reply-To:Subject:To; b=vDt50xFI20+uuNnMu/bukhOnodWu8lOtD2ecSBIbmR3kBOyQcxqhbAYGBzRgaMVvKzi pas2xVKEC3/RuG+izXD8yUhcV1XYcf1QDgUubU69i8aMHa2s04aFrJ/DmFaK7i6zFYdYs dTpCWuTut9snflCtrNKFAO5mYuEWd0Td/FM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1626160310553100001 Content-Type: text/plain; charset="utf-8" V1: Universal Payload will consume Hobs from boot loader. Dump all hobs in the Universal Payload entry. V2: Add function comments V3: minor change, for example Hobsize -> HobLength, SMBiosTable -> SmBiosTable Cc: Maurice Ma Cc: Guo Dong Cc: Ray Ni Cc: Benjamin You Signed-off-by: Thiyagu Kesavan Balakrishnan Signed-off-by: Zhiguang Liu --- UefiPayloadPkg/UefiPayloadEntry/PrintHob.c | 641 ++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++ UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 17 ++++++++++= +++++++ UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf | 6 ++++++ 3 files changed, 664 insertions(+) diff --git a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c b/UefiPayloadPkg/Ue= fiPayloadEntry/PrintHob.c new file mode 100644 index 0000000000..5fb638d4a4 --- /dev/null +++ b/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c @@ -0,0 +1,641 @@ +/** @file + Copyright (c) 2021, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "UefiPayloadEntry.h" +#include +#include +#include +#include +#include +#include + +#define ROW_LIMITER 16 + +typedef +EFI_STATUS +(*HOB_PRINT_HANDLER) ( + IN VOID *Hob, + IN UINT16 HobLength +); + +typedef struct{ + UINT16 Type; + CHAR8 *Name; + HOB_PRINT_HANDLER PrintHandler; +} HOB_PRINT_HANDLER_TABLE; + +CHAR8 * mMemoryTypeStr[] =3D { + "EfiReservedMemoryType", + "EfiLoaderCode", + "EfiLoaderData", + "EfiBootServicesCode", + "EfiBootServicesData", + "EfiRuntimeServicesCode", + "EfiRuntimeServicesData", + "EfiConventionalMemory", + "EfiUnusableMemory", + "EfiACPIReclaimMemory", + "EfiACPIMemoryNVS", + "EfiMemoryMappedIO", + "EfiMemoryMappedIOPortSpace", + "EfiPalCode", + "EfiPersistentMemory", + "EfiMaxMemoryType" +}; + +CHAR8 * mResource_Type_List[] =3D { + "EFI_RESOURCE_SYSTEM_MEMORY ", //0x00000000 + "EFI_RESOURCE_MEMORY_MAPPED_IO ", //0x00000001 + "EFI_RESOURCE_IO ", //0x00000002 + "EFI_RESOURCE_FIRMWARE_DEVICE ", //0x00000003 + "EFI_RESOURCE_MEMORY_MAPPED_IO_PORT ", //0x00000004 + "EFI_RESOURCE_MEMORY_RESERVED ", //0x00000005 + "EFI_RESOURCE_IO_RESERVED ", //0x00000006 + "EFI_RESOURCE_MAX_MEMORY_TYPE " //0x00000007 +}; + +typedef +EFI_STATUS +(*GUID_HOB_PRINT) ( + IN UINT8 *HobRaw, + IN UINT16 HobLength +); + +typedef struct { + EFI_GUID *Guid; + GUID_HOB_PRINT PrintHandler; + CHAR8 *GuidName; +} GUID_HOB_PRINT_HANDLE; + +typedef struct{ + EFI_GUID *Guid; + CHAR8 *Type; +} PRINT_MEMORY_ALLOCCATION_HOB; + + +/** + Print the Hex value of a given range. + @param[in] DataStart A pointer to the start of data to be printed. + @param[in] DataSize The length of the data to be printed. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintHex ( + IN UINT8 *DataStart, + IN UINT16 DataSize + ) +{ + UINTN Index1; + UINTN Index2; + UINT8 *StartAddr; + + StartAddr =3D DataStart; + for (Index1 =3D 0; Index1 * ROW_LIMITER < DataSize; Index1++) { + DEBUG ((DEBUG_VERBOSE, " 0x%04p:", (DataStart - StartAddr))); + for (Index2 =3D 0; (Index2 < ROW_LIMITER) && (Index1 * ROW_LIMITER + I= ndex2 < DataSize); Index2++){ + DEBUG ((DEBUG_VERBOSE, " %02x", *DataStart)); + DataStart++; + } + DEBUG ((DEBUG_VERBOSE, "\n")); + } + + return EFI_SUCCESS; +} + +/** + Print the information in HandOffHob. + + @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_HAN= DOFF. + @param[in] HobLength The length in bytes of HOB of type EFI_HOB_TY= PE_HANDOFF. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintHandOffHob( + IN VOID *HobStart, + IN UINT16 HobLength + ) +{ + EFI_PEI_HOB_POINTERS Hob; + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (HobLength >=3D sizeof (*Hob.HandoffInformationTable)); + DEBUG ((DEBUG_INFO, " BootMode =3D 0x%x\n", Hob.HandoffInf= ormationTable->BootMode)); + DEBUG ((DEBUG_INFO, " EfiMemoryTop =3D 0x%lx\n", Hob.HandoffInf= ormationTable->EfiMemoryTop)); + DEBUG ((DEBUG_INFO, " EfiMemoryBottom =3D 0x%lx\n", Hob.HandoffInf= ormationTable->EfiMemoryBottom)); + DEBUG ((DEBUG_INFO, " EfiFreeMemoryTop =3D 0x%lx\n", Hob.HandoffInf= ormationTable->EfiFreeMemoryTop)); + DEBUG ((DEBUG_INFO, " EfiFreeMemoryBottom =3D 0x%lx\n", Hob.HandoffInf= ormationTable->EfiFreeMemoryBottom)); + DEBUG ((DEBUG_INFO, " EfiEndOfHobList =3D 0x%lx\n", Hob.HandoffInf= ormationTable->EfiEndOfHobList)); + return EFI_SUCCESS; +} + +/** + Print the information in Memory Allocation Hob. + @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_MEM= ORY_ALLOCATION. + @param[in] HobLength The length in bytes of HOB of type EFI_HOB_TY= PE_MEMORY_ALLOCATION. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintMemoryAllocationHob ( + IN VOID *HobStart, + IN UINT16 HobLength + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw =3D (UINT8 *) HobStart; + + if(CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMem= oryAllocStackGuid)) { + ASSERT (HobLength >=3D sizeof (*Hob.MemoryAllocationStack)); + DEBUG ((DEBUG_INFO, " Type =3D EFI_HOB_MEMORY_ALLOCATIO= N_STACK\n")); + } else if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gE= fiHobMemoryAllocBspStoreGuid)) { + ASSERT (HobLength >=3D sizeof (*Hob.MemoryAllocationBspStore)); + DEBUG ((DEBUG_INFO, " Type =3D EFI_HOB_MEMORY_ALLOCATIO= N_BSP_STORE\n")); + } else if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gE= fiHobMemoryAllocModuleGuid)) { + ASSERT (HobLength >=3D sizeof (*Hob.MemoryAllocationModule)); + DEBUG ((DEBUG_INFO, " Type =3D EFI_HOB_MEMORY_ALLOCATIO= N_MODULE\n")); + DEBUG ((DEBUG_INFO, " Module Name =3D %g\n", Hob.MemoryAllocat= ionModule->ModuleName)); + DEBUG ((DEBUG_INFO, " Physical Address =3D 0x%lx\n", Hob.MemoryAllo= cationModule->EntryPoint)); + } else { + ASSERT (HobLength >=3D sizeof (*Hob.MemoryAllocation)); + DEBUG ((DEBUG_INFO, " Type =3D EFI_HOB_TYPE_MEMORY_ALLO= CATION\n")); + } + DEBUG ((DEBUG_INFO, " MemoryBaseAddress =3D 0x%lx\n", Hob.MemoryAlloca= tionStack->AllocDescriptor.MemoryBaseAddress)); + DEBUG ((DEBUG_INFO, " MemoryLength =3D 0x%lx\n", Hob.MemoryAlloca= tionStack->AllocDescriptor.MemoryLength)); + DEBUG ((DEBUG_INFO, " MemoryType =3D %a \n", mMemoryTypeStr[H= ob.MemoryAllocationStack->AllocDescriptor.MemoryType])); + return EFI_SUCCESS; +} + +/** + Print the information in Resource Discriptor Hob. + @param[in] HobStart A pointer to HOB of type EFI_HOB_TYPE_RESOURC= E_DESCRIPTOR. + @param[in] HobLength The Length in bytes of HOB of type EFI_HOB_TY= PE_RESOURCE_DESCRIPTOR. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintResourceDiscriptorHob ( + IN VOID *HobStart, + IN UINT16 HobLength + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (HobLength >=3D sizeof (*Hob.ResourceDescriptor)); + + DEBUG ((DEBUG_INFO, " ResourceType =3D %a\n", mResource_Type_List= [Hob.ResourceDescriptor->ResourceType])); + if(!IsZeroGuid (&Hob.ResourceDescriptor->Owner)) { + DEBUG ((DEBUG_INFO, " Owner =3D %g\n", Hob.ResourceDescrip= tor->Owner)); + } + DEBUG ((DEBUG_INFO, " ResourceAttribute =3D 0x%x\n", Hob.ResourceDesc= riptor->ResourceAttribute)); + DEBUG ((DEBUG_INFO, " PhysicalStart =3D 0x%lx\n", Hob.ResourceDesc= riptor->PhysicalStart)); + DEBUG ((DEBUG_INFO, " ResourceLength =3D 0x%lx\n", Hob.ResourceDesc= riptor->ResourceLength)); + return EFI_SUCCESS; +} + +/** + Print the information in Acpi Guid Hob. + @param[in] HobRaw A pointer to the start of gUniversalPayloadAc= piTableGuid HOB. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintAcpiGuidHob ( + IN UINT8 *HobRaw, + IN UINT16 HobLength + ) +{ + UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob; + AcpiTableHob =3D (UNIVERSAL_PAYLOAD_ACPI_TABLE *) GET_GUID_HOB_DATA (Hob= Raw); + ASSERT (HobLength >=3D AcpiTableHob->Header.Length); + DEBUG ((DEBUG_INFO, " Revision =3D 0x%x\n", AcpiTableHob->Header.Rev= ision)); + DEBUG ((DEBUG_INFO, " Length =3D 0x%x\n", AcpiTableHob->Header.Len= gth)); + DEBUG ((DEBUG_INFO, " Rsdp =3D 0x%p\n", (UINT64) AcpiTableHob->R= sdp)); + return EFI_SUCCESS; +} + +/** + Print the information in Serial Guid Hob. + @param[in] HobRaw A pointer to the start of gUniversalPayloadSe= rialPortInfoGuid HOB. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintSerialGuidHob ( + IN UINT8 *HobRaw, + IN UINT16 HobLength + ) +{ + UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *SerialPortInfo; + SerialPortInfo =3D (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *) GET_GUID_HOB_D= ATA (HobRaw); + ASSERT (HobLength >=3D SerialPortInfo->Header.Length); + DEBUG ((DEBUG_INFO, " Revision =3D 0x%x\n", SerialPortInfo->Hea= der.Revision)); + DEBUG ((DEBUG_INFO, " Length =3D 0x%x\n", SerialPortInfo->Hea= der.Length)); + DEBUG ((DEBUG_INFO, " UseMmio =3D 0x%x\n", SerialPortInfo->Use= Mmio)); + DEBUG ((DEBUG_INFO, " RegisterStride =3D 0x%x\n", SerialPortInfo->Reg= isterStride)); + DEBUG ((DEBUG_INFO, " BaudRate =3D %d\n", SerialPortInfo->Bau= dRate)); + DEBUG ((DEBUG_INFO, " RegisterBase =3D 0x%lx\n", SerialPortInfo->Reg= isterBase)); + return EFI_SUCCESS; +} + +/** + Print the information in Smbios Guid Hob. + @param[in] HobRaw A pointer to the start of gUniversalPayloadSm= bios3TableGuid HOB. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintSmbios3GuidHob ( + IN UINT8 *HobRaw, + IN UINT16 HobLength + ) +{ + UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable; + SmBiosTable =3D (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *) GET_GUID_HOB_DATA (Ho= bRaw); + ASSERT (HobLength >=3D SmBiosTable->Header.Length); + DEBUG ((DEBUG_INFO, " Revision =3D 0x%x\n", SmBiosTable->Head= er.Revision)); + DEBUG ((DEBUG_INFO, " Length =3D 0x%x\n", SmBiosTable->Head= er.Length)); + DEBUG ((DEBUG_INFO, " SmBiosEntryPoint =3D 0x%lx\n", (UINT64) SmBiosTa= ble->SmBiosEntryPoint)); + return EFI_SUCCESS; +} + +/** + Print the information in Smbios Guid Hob. + @param[in] HobRaw A pointer to the start of gUniversalPayloadSm= biosTableGuid HOB. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintSmbiosTablGuidHob ( + IN UINT8 *HobRaw, + IN UINT16 HobLength + ) +{ + UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable; + SmBiosTable =3D (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *) GET_GUID_HOB_DATA (Ho= bRaw); + ASSERT (HobLength >=3D SmBiosTable->Header.Length); + DEBUG ((DEBUG_INFO, " Revision =3D 0x%x\n", SmBiosTable->Head= er.Revision)); + DEBUG ((DEBUG_INFO, " Length =3D 0x%x\n", SmBiosTable->Head= er.Length)); + DEBUG ((DEBUG_INFO, " SmBiosEntryPoint =3D 0x%lx\n", (UINT64) SmBiosTa= ble->SmBiosEntryPoint)); + return EFI_SUCCESS; +} + +/** + Print the information in Acpi BoardInfo Guid Hob. + @param[in] HobRaw A pointer to the start of gUefiAcpiBoardInfoG= uid HOB. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintAcpiBoardInfoGuidHob ( + IN UINT8 *HobRaw, + IN UINT16 HobLength + ) +{ + ACPI_BOARD_INFO *AcpBoardInfo; + AcpBoardInfo =3D (ACPI_BOARD_INFO *) GET_GUID_HOB_DATA (HobRaw); + ASSERT (HobLength >=3D sizeof (*AcpBoardInfo)); + DEBUG ((DEBUG_INFO, " Revision =3D 0x%x\n", AcpBoardInfo->Revi= sion)); + DEBUG ((DEBUG_INFO, " Reserved0 =3D 0x%x\n", AcpBoardInfo->Rese= rved0)); + DEBUG ((DEBUG_INFO, " ResetValue =3D 0x%x\n", AcpBoardInfo->Rese= tValue)); + DEBUG ((DEBUG_INFO, " PmEvtBase =3D 0x%lx\n", AcpBoardInfo->PmEv= tBase)); + DEBUG ((DEBUG_INFO, " PmGpeEnBase =3D 0x%lx\n", AcpBoardInfo->PmGp= eEnBase)); + DEBUG ((DEBUG_INFO, " PmCtrlRegBase =3D 0x%lx\n", AcpBoardInfo->PmCt= rlRegBase)); + DEBUG ((DEBUG_INFO, " PmTimerRegBase =3D 0x%lx\n", AcpBoardInfo->PmTi= merRegBase)); + DEBUG ((DEBUG_INFO, " ResetRegAddress =3D 0x%lx\n", AcpBoardInfo->Rese= tRegAddress)); + DEBUG ((DEBUG_INFO, " PcieBaseAddress =3D 0x%lx\n", AcpBoardInfo->Pcie= BaseAddress)); + DEBUG ((DEBUG_INFO, " PcieBaseSize =3D 0x%lx\n", AcpBoardInfo->Pcie= BaseSize)); + return EFI_SUCCESS; +} + +/** + Print the information in Pci RootBridge Info Guid Hob. + @param[in] HobRaw A pointer to the start of gUniversalPayloadPc= iRootBridgeInfoGuid HOB. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintPciRootBridgeInfoGuidHob ( + IN UINT8 *HobRaw, + IN UINT16 HobLength + ) +{ + UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridges; + UINTN Index; + Index =3D 0; + PciRootBridges =3D (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GET_GUID_HOB_D= ATA (HobRaw); + ASSERT (HobLength >=3D sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES)); + DEBUG ((DEBUG_INFO, " Revision =3D 0x%x\n", PciRootBridges->He= ader.Revision)); + DEBUG ((DEBUG_INFO, " Length =3D 0x%x\n", PciRootBridges->He= ader.Length)); + DEBUG ((DEBUG_INFO, " Count =3D 0x%x\n", PciRootBridges->Co= unt)); + DEBUG ((DEBUG_INFO, " ResourceAssigned =3D %a\n", (PciRootBridges->R= esourceAssigned ? "True" : "False"))); + + while(Index < PciRootBridges->Count) { + DEBUG ((DEBUG_INFO, " Root Bridge Index[%d]:\n", Index)); + DEBUG ((DEBUG_INFO, " Segment =3D 0x%x\n", PciRootB= ridges->RootBridge[Index].Segment)); + DEBUG ((DEBUG_INFO, " Supports =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].Supports)); + DEBUG ((DEBUG_INFO, " Attributes =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].Attributes)); + DEBUG ((DEBUG_INFO, " DmaAbove4G =3D 0x%x\n", PciRootB= ridges->RootBridge[Index].DmaAbove4G)); + DEBUG ((DEBUG_INFO, " NoExtendedConfigSpace =3D 0x%x\n", PciRootB= ridges->RootBridge[Index].NoExtendedConfigSpace)); + DEBUG ((DEBUG_INFO, " AllocationAttributes =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].AllocationAttributes)); + DEBUG ((DEBUG_INFO, " Bus.Base =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].Bus.Base)); + DEBUG ((DEBUG_INFO, " Bus.Limit =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].Bus.Limit)); + DEBUG ((DEBUG_INFO, " Bus.Translation =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].Bus.Translation)); + DEBUG ((DEBUG_INFO, " Io.Base =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].Io.Base)); + DEBUG ((DEBUG_INFO, " Io.Limit =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].Io.Limit)); + DEBUG ((DEBUG_INFO, " Io.Translation =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].Io.Translation)); + DEBUG ((DEBUG_INFO, " Mem.Base =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].Mem.Base)); + DEBUG ((DEBUG_INFO, " Mem.Limit =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].Mem.Limit)); + DEBUG ((DEBUG_INFO, " Mem.Translation =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].Mem.Translation)); + DEBUG ((DEBUG_INFO, " MemAbove4G.Base =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].MemAbove4G.Base)); + DEBUG ((DEBUG_INFO, " MemAbove4G.Limit =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].MemAbove4G.Limit)); + DEBUG ((DEBUG_INFO, " MemAbove4G.Translation =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].MemAbove4G.Translation)); + DEBUG ((DEBUG_INFO, " PMem.Base =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].PMem.Base)); + DEBUG ((DEBUG_INFO, " PMem.Limit =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].PMem.Limit)); + DEBUG ((DEBUG_INFO, " PMem.Translation =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].PMem.Translation)); + DEBUG ((DEBUG_INFO, " PMemAbove4G.Base =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].PMemAbove4G.Base)); + DEBUG ((DEBUG_INFO, " PMemAbove4G.Limit =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].PMemAbove4G.Limit)); + DEBUG ((DEBUG_INFO, " PMemAbove4G.Translation =3D 0x%lx\n", PciRootB= ridges->RootBridge[Index].PMemAbove4G.Translation)); + Index+=3D1; + } + return EFI_SUCCESS; +} + +/** + Print the information in Extra Data Guid Hob. + @param[in] HobRaw A pointer to the start of gUniversalPayloadEx= traDataGuid HOB. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintExtraDataGuidHob ( + IN UINT8 *HobRaw, + IN UINT16 HobLength + ) +{ + UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData; + UINTN Index; + + Index =3D 0; + ExtraData =3D (UNIVERSAL_PAYLOAD_EXTRA_DATA *) GET_GUID_HOB_DATA (HobRaw= ); + ASSERT (HobLength >=3D ExtraData->Header.Length); + DEBUG ((DEBUG_INFO, " Revision =3D 0x%x\n", ExtraData->Header.Revisio= n)); + DEBUG ((DEBUG_INFO, " Length =3D 0x%x\n", ExtraData->Header.Length)= ); + DEBUG ((DEBUG_INFO, " Count =3D 0x%x\n", ExtraData->Count)); + + while (Index < ExtraData->Count) { + DEBUG ((DEBUG_INFO, " Id[%d] =3D %a\n", Index,ExtraData->Entr= y[Index].Identifier)); + DEBUG ((DEBUG_INFO, " Base[%d] =3D 0x%lx\n", Index,ExtraData->Entr= y[Index].Base)); + DEBUG ((DEBUG_INFO, " Size[%d] =3D 0x%lx\n", Index,ExtraData->Entr= y[Index].Size)); + Index+=3D1; + } + return EFI_SUCCESS; +} + +/** + Print the information in MemoryTypeInfoGuidHob. + @param[in] HobRaw A pointer to the start of gEfiMemoryTypeInfor= mationGuid HOB. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintMemoryTypeInfoGuidHob ( + IN UINT8 *HobRaw, + IN UINT16 HobLength + ) +{ + EFI_MEMORY_TYPE_INFORMATION *MemoryTypeInfo; + + MemoryTypeInfo =3D (EFI_MEMORY_TYPE_INFORMATION *) GET_GUID_HOB_DATA (Ho= bRaw); + ASSERT (HobLength >=3D sizeof (*MemoryTypeInfo)); + DEBUG ((DEBUG_INFO, " Type =3D 0x%x\n", MemoryTypeInfo->Typ= e)); + DEBUG ((DEBUG_INFO, " NumberOfPages =3D 0x%x\n", MemoryTypeInfo->Num= berOfPages)); + return EFI_SUCCESS; +} + +// +// Mappint table for dump Guid Hob information. +// This table can be easily extented. +// +GUID_HOB_PRINT_HANDLE GuidHobPrintHandleTable[] =3D { + {&gUniversalPayloadAcpiTableGuid, PrintAcpiGuidHob, = "gUniversalPayloadAcpiTableGuid(ACPI table Guid)"}, + {&gUniversalPayloadSerialPortInfoGuid, PrintSerialGuidHob, = "gUniversalPayloadSerialPortInfoGuid(Serial Port Info)"}, + {&gUniversalPayloadSmbios3TableGuid, PrintSmbios3GuidHob, = "gUniversalPayloadSmbios3TableGuid(SmBios Guid)"}, + {&gUniversalPayloadSmbiosTableGuid, PrintSmbiosTablGuidHob, = "gUniversalPayloadSmbiosTableGuid(SmBios Guid)"}, + {&gUefiAcpiBoardInfoGuid, PrintAcpiBoardInfoGuidHob, = "gUefiAcpiBoardInfoGuid(Acpi Guid)"}, + {&gUniversalPayloadPciRootBridgeInfoGuid, PrintPciRootBridgeInfoGuidHob,= "gUniversalPayloadPciRootBridgeInfoGuid(Pci Guid)"}, + {&gEfiMemoryTypeInformationGuid, PrintMemoryTypeInfoGuidHob, = "gEfiMemoryTypeInformationGuid(Memory Type Information Guid)"}, + {&gUniversalPayloadExtraDataGuid, PrintExtraDataGuidHob, = "gUniversalPayloadExtraDataGuid(PayLoad Extra Data Guid)"} +}; + +/** + Print the Guid Hob using related print handle function. + @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_GUI= D_EXTENSION. + @param[in] HobLength The length in bytes of the HOB of type EFI_HO= B_TYPE_GUID_EXTENSION. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintGuidHob ( + IN VOID *HobStart, + IN UINT16 HobLength + ) +{ + EFI_PEI_HOB_POINTERS Hob; + UINTN Index; + EFI_STATUS Status; + + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (HobLength >=3D sizeof (Hob.Guid)); + + for (Index =3D 0; Index < ARRAY_SIZE (GuidHobPrintHandleTable); Index++)= { + if (CompareGuid (&Hob.Guid->Name, GuidHobPrintHandleTable[Index].Guid)= ) { + DEBUG ((DEBUG_INFO, " Guid =3D %a\n", GuidHobPrintHandleTable[In= dex].GuidName)); + Status =3D GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, Hob= .Header->HobLength); + return Status; + } + } + DEBUG ((DEBUG_INFO, " Name =3D %g\n", &Hob.Guid->Name)); + PrintHex (GET_GUID_HOB_DATA (Hob.Raw), GET_GUID_HOB_DATA_SIZE (Hob.Raw)); + return EFI_SUCCESS; +} + +/** + Print the information in FV Hob. + @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV. + @param[in] HobLength The length in bytes of the HOB of type EFI_HO= B_TYPE_FV. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintFvHob ( + IN VOID *HobStart, + IN UINT16 HobLength + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (HobLength >=3D sizeof (*Hob.FirmwareVolume)); + + DEBUG ((DEBUG_INFO, " BaseAddress =3D 0x%lx\n", Hob.FirmwareVolume->Ba= seAddress)); + DEBUG ((DEBUG_INFO, " Length =3D 0x%lx\n", Hob.FirmwareVolume->Le= ngth)); + return EFI_SUCCESS; +} + +/** + Print the information in Cpu Hob. + @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_CPU. + @param[in] HobLength The length in bytes of the HOB of type EFI_HO= B_TYPE_CPU. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintCpuHob ( + IN VOID *HobStart, + IN UINT16 HobLength + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (HobLength >=3D sizeof (*Hob.Cpu)); + + DEBUG ((DEBUG_INFO, " SizeOfMemorySpace =3D 0x%lx\n", Hob.Cpu->SizeOfM= emorySpace)); + DEBUG ((DEBUG_INFO, " SizeOfIoSpace =3D 0x%lx\n", Hob.Cpu->SizeOfI= oSpace)); + return EFI_SUCCESS; +} + +/** + Print the information in MemoryPoolHob. + @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_MEM= ORY_POOL. + @param[in] HobLength The length in bytes of the HOB of type EFI_HO= B_TYPE_MEMORY_POOL. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintMemoryPoolHob ( + IN VOID *HobStart, + IN UINT16 HobLength + ) +{ + return EFI_SUCCESS; +} + +/** + Print the information in Fv2Hob. + @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV2. + @param[in] HobLength The length in bytes of the HOB of type EFI_HO= B_TYPE_FV2. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintFv2Hob ( + IN VOID *HobStart, + IN UINT16 HobLength + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (HobLength >=3D sizeof (*Hob.FirmwareVolume2)); + + DEBUG ((DEBUG_INFO, " BaseAddress =3D 0x%lx\n", Hob.FirmwareVolume2->B= aseAddress)); + DEBUG ((DEBUG_INFO, " Length =3D 0x%lx\n", Hob.FirmwareVolume2->L= ength)); + DEBUG ((DEBUG_INFO, " FvName =3D %g\n", &Hob.FirmwareVolume2->= FvName)); + DEBUG ((DEBUG_INFO, " FileName =3D %g\n", &Hob.FirmwareVolume2->= FileName)); + return EFI_SUCCESS; +} + +/** + Print the information in Capsule Hob. + @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_UEF= I_CAPSULE. + @param[in] HobLength The length in bytes of the HOB of type EFI_HO= B_TYPE_UEFI_CAPSULE. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintCapsuleHob ( + IN VOID *HobStart, + IN UINT16 HobLength + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (HobLength >=3D sizeof (*Hob.Capsule)); + + DEBUG ((DEBUG_INFO, " BaseAddress =3D 0x%lx\n", Hob.Capsule->BaseAddre= ss)); + DEBUG ((DEBUG_INFO, " Length =3D 0x%lx\n", Hob.Capsule->Length)); + return EFI_SUCCESS; +} + +/** + Print the information in Fv3 Hob. + @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV3. + @param[in] HobLength The length in bytes of the HOB of type EFI_HO= B_TYPE_FV3. + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintFv3Hob ( + IN VOID *HobStart, + IN UINT16 HobLength + ) +{ + EFI_PEI_HOB_POINTERS Hob; + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (HobLength >=3D sizeof (*Hob.FirmwareVolume3)); + + DEBUG ((DEBUG_INFO, " BaseAddress =3D 0x%lx\n", Hob.FirmwareV= olume3->BaseAddress)); + DEBUG ((DEBUG_INFO, " Length =3D 0x%lx\n", Hob.FirmwareV= olume3->Length)); + DEBUG ((DEBUG_INFO, " AuthenticationStatus =3D 0x%x\n", Hob.FirmwareV= olume3->AuthenticationStatus)); + DEBUG ((DEBUG_INFO, " ExtractedFv =3D %a\n", (Hob.Firmware= Volume3->ExtractedFv ? "True" : "False"))); + DEBUG ((DEBUG_INFO, " FVName =3D %g\n", &Hob.Firmware= Volume3->FvName)); + DEBUG ((DEBUG_INFO, " FileName =3D %g\n", &Hob.Firmware= Volume3->FileName)); + return EFI_SUCCESS; +} + +// +// Mappint table from Hob type to Hob print function. +// +HOB_PRINT_HANDLER_TABLE mHobHandles[] =3D { + {EFI_HOB_TYPE_HANDOFF, "EFI_HOB_TYPE_HANDOFF", P= rintHandOffHob}, + {EFI_HOB_TYPE_MEMORY_ALLOCATION, "EFI_HOB_TYPE_MEMORY_ALLOCATION", P= rintMemoryAllocationHob}, + {EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR", P= rintResourceDiscriptorHob}, + {EFI_HOB_TYPE_GUID_EXTENSION, "EFI_HOB_TYPE_GUID_EXTENSION", P= rintGuidHob}, + {EFI_HOB_TYPE_FV, "EFI_HOB_TYPE_FV", P= rintFvHob}, + {EFI_HOB_TYPE_CPU, "EFI_HOB_TYPE_CPU", P= rintCpuHob}, + {EFI_HOB_TYPE_MEMORY_POOL, "EFI_HOB_TYPE_MEMORY_POOL", P= rintMemoryPoolHob}, + {EFI_HOB_TYPE_FV2, "EFI_HOB_TYPE_FV2", P= rintFv2Hob}, + {EFI_HOB_TYPE_UEFI_CAPSULE, "EFI_HOB_TYPE_UEFI_CAPSULE", P= rintCapsuleHob}, + {EFI_HOB_TYPE_FV3, "EFI_HOB_TYPE_FV3", P= rintFv3Hob} +}; + + +/** + Print all HOBs info from the HOB list. + @param[in] HobStart A pointer to the HOB list + @return The pointer to the HOB list. +**/ +VOID +PrintHob ( + IN CONST VOID *HobStart + ) +{ + EFI_PEI_HOB_POINTERS Hob; + UINTN Count; + UINTN Index; + ASSERT (HobStart !=3D NULL); + + Hob.Raw =3D (UINT8 *) HobStart; + DEBUG ((DEBUG_INFO, "Print all Hob information from Hob 0x%p\n", Hob.Raw= )); + + Count =3D 0; + // + // Parse the HOB list to see which type it is, and print the information. + // + while (!END_OF_HOB_LIST (Hob)) { + for (Index =3D 0; Index < ARRAY_SIZE (mHobHandles); Index++) { + if (Hob.Header->HobType =3D=3D mHobHandles[Index].Type) { + DEBUG ((DEBUG_INFO, "HOB[%d]: Type =3D %a, Offset =3D 0x%p, Length= =3D 0x%x\n", Count, mHobHandles[Index].Name, (Hob.Raw - (UINT8 *) HobStart= ), Hob.Header->HobLength)); + mHobHandles[Index].PrintHandler (Hob.Raw, Hob.Header->HobLength); + break; + } + } + if (Index =3D=3D ARRAY_SIZE (mHobHandles)) { + DEBUG ((DEBUG_INFO, "HOB[%d]: Type =3D %d, Offset =3D 0x%p, Length = =3D 0x%x\n", Count, Hob.Header->HobType, (Hob.Raw - (UINT8 *)HobStart), Hob= .Header->HobLength)); + DEBUG ((DEBUG_INFO, " Unkown Hob type\n")); + PrintHex (Hob.Raw, Hob.Header->HobLength); + } + Count++; + Hob.Raw =3D GET_NEXT_HOB (Hob); + } + DEBUG ((DEBUG_INFO, "There are totally %d Hobs, the End Hob address is %= p\n", Count, Hob.Raw)); +} diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c b/Uefi= PayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c index 7a00a56ab9..09dd1e8378 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c @@ -25,6 +25,16 @@ =20 extern VOID *mHobList; =20 +/** + Print all HOBs info from the HOB list. + + @return The pointer to the HOB list. +**/ +VOID +PrintHob ( + IN CONST VOID *HobStart + ); + /** Some bootloader may pass a pcd database, and UPL also contain a PCD data= base. Dxe PCD driver has the assumption that the two PCD database can be caten= ated and @@ -375,6 +385,13 @@ _ModuleEntryPoint ( DEBUG ((DEBUG_INFO, "Entering Universal Payload...\n")); DEBUG ((DEBUG_INFO, "sizeof(UINTN) =3D 0x%x\n", sizeof(UINTN))); =20 + DEBUG_CODE ( + // + // Dump the Hobs from boot loader + // + PrintHob (mHobList); + ); + // Initialize floating point operating environment to be compliant with = UEFI spec. InitializeFloatingPointUnits (); =20 diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf b/Ue= fiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf index 76d7e4791c..416a620598 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf @@ -24,6 +24,7 @@ UniversalPayloadEntry.c LoadDxeCore.c MemoryAllocation.c + PrintHob.c =20 [Sources.Ia32] X64/VirtualMemory.h @@ -64,6 +65,11 @@ gUefiSerialPortInfoGuid gUniversalPayloadExtraDataGuid gPcdDataBaseHobGuid + gUniversalPayloadSmbiosTableGuid + gEfiHobMemoryAllocBspStoreGuid + gUniversalPayloadAcpiTableGuid + gUniversalPayloadPciRootBridgeInfoGuid + gUniversalPayloadSmbios3TableGuid =20 [FeaturePcd.IA32] gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES --=20 2.30.0.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#77732): https://edk2.groups.io/g/devel/message/77732 Mute This Topic: https://groups.io/mt/84173456/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-