From nobody Sun May 5 04:12:33 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+77366+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+77366+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1625059610; cv=none; d=zohomail.com; s=zohoarc; b=HqL1V6RU4WdxbAXGMPSD/dAD1TtqHfLbohOD37c4yJQj2cWWjblgE0fkOlhhM5AgYieOhMMQo2jkrbV7VsEadhDdPoe3LCyLyei4hMYSqklEwCzDUXktVELN8rS3lA9/MKHpiG25Uwe7+Qtt+0NEebpjKUOp9nN72VyA1ePDWPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625059610; 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=qnoEIa55KEzMv2Tsmx8C9qtqkr2L935RXNUlrzAZ64s=; b=cYGwrqyT30S9N8SVwnzzfSbMAYQ4ofQ0XGfjdkBd35aEo9ICpPbt98JOkwMD7fqZ0YxWV/nCSUDVWUfqrqputzkJzOv1zElTvfKd2+hmlMvw6EFHeEh2R3kD06PDq02XXYCZxmLu7dJDih/K3RG/jR6i5IyWgk7ZNdmgaLvqTWc= 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+77366+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 1625059610834170.04401968766558; Wed, 30 Jun 2021 06:26:50 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id LBfBYY1788612xYo7g9z6cjj; Wed, 30 Jun 2021 06:26:50 -0700 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web08.5800.1625059609444377182 for ; Wed, 30 Jun 2021 06:26:49 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10030"; a="269480065" X-IronPort-AV: E=Sophos;i="5.83,312,1616482800"; d="scan'208";a="269480065" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2021 06:26:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,312,1616482800"; d="scan'208";a="447464542" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga007.jf.intel.com with ESMTP; 30 Jun 2021 06:26:45 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Maurice Ma , Guo Dong , Benjamin You , Thiyagu Kesavan Balakrishnan Subject: [edk2-devel] [PATCH] UefiPayloadPkg: Dump hob information from boot loader Date: Wed, 30 Jun 2021 21:26:26 +0800 Message-Id: <20210630132626.1061-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: B1Ot5ocnBUEziPkeegjF58HQx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1625059610; bh=PvxGKTLfI9myKzQSAaEp4UL9pknc/Z64cJocKsyIOaQ=; h=Cc:Date:From:Reply-To:Subject:To; b=r3pPvkTgptn0+Dp3ig6GSRAeWb/v2/AxhSQeAE1B4vIYlLxyuQXWdHA9ZVGVuzw9Cnh YDtgufguwnXtcnKZ++/g8O7I5dPzbZdMJ5BmazjkfNy6sU8gka8JfA3BvhomHW16exklk xZmKXKX15qXCj91V92wU3kfiyRD+mvtEIiQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Universal Payload will consume Hobs from boot loader. Dump all hobs in the Universal Payload entry. Cc: Maurice Ma Cc: Guo Dong Cc: Benjamin You Signed-off-by: Thiyagu Kesavan Balakrishnan Signed-off-by: Zhiguang Liu --- UefiPayloadPkg/UefiPayloadEntry/PrintHob.c | 613 ++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++ UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 15 ++++++++++= +++++ UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf | 8 ++++++++ 3 files changed, 636 insertions(+) diff --git a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c b/UefiPayloadPkg/Ue= fiPayloadEntry/PrintHob.c new file mode 100644 index 0000000000..09f37720b4 --- /dev/null +++ b/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c @@ -0,0 +1,613 @@ +/** @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 + +typedef +EFI_STATUS +(*HOB_PRINT_HANDLER) ( + IN VOID *Hob, + IN UINTN Hobsize +); + +typedef struct{ + UINT16 Type; + CHAR8 *Name; + HOB_PRINT_HANDLER Function; +} 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 +); + +typedef struct { + EFI_GUID *Guid; + GUID_HOB_PRINT Function; + 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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintHex ( + IN UINT8 *DataStart, + IN UINTN DataSize + ) +{ + UINTN Index1; + UINTN Index2; + UINT8 *StartAddr; + + StartAddr =3D DataStart; + for (Index1 =3D 0; Index1 * 16 < DataSize; Index1++) { + DEBUG ((DEBUG_INFO, " 0x%04p:",(DataStart - StartAddr))); + for (Index2 =3D 0; (Index2 < 16) && (Index1 * 16 + Index2 < DataSize);= Index2++){ + DEBUG ((DEBUG_INFO, " %02x", *DataStart)); + DataStart++; + } + DEBUG ((DEBUG_INFO, "\n")); + } + + return EFI_SUCCESS; +} + +/** + Print the information in HandOffHob. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintHandOffHob( + IN VOID *HobStart, + IN UINTN Hobsize + ) +{ + EFI_PEI_HOB_POINTERS Hob; + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (Hobsize >=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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintMemoryAllocationHob ( + IN VOID *HobStart, + IN UINTN Hobsize + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw =3D (UINT8 *) HobStart; + + if(CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMem= oryAllocStackGuid)) { + ASSERT (Hobsize >=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 (Hobsize >=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 (Hobsize >=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 (Hobsize >=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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintResourceDiscriptorHob ( + IN VOID *HobStart, + IN UINTN Hobsize + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (Hobsize >=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.ResourceDescr= iptor->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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintAcpiGuidHob ( + IN UINT8 *HobRaw + ) +{ + UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob; + AcpiTableHob =3D (UNIVERSAL_PAYLOAD_ACPI_TABLE *) GET_GUID_HOB_DATA (Hob= Raw); + 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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintSerialGuidHob ( + IN UINT8 *HobRaw + ) +{ + UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *SerialPortInfo; + SerialPortInfo =3D (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *) GET_GUID_HOB_D= ATA (HobRaw); + 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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintSmbios3GuidHob ( + IN UINT8 *HobRaw + ) +{ + UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SMBiosTable; + SMBiosTable =3D (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *) GET_GUID_HOB_DATA (Ho= bRaw); + 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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintSmbiosTablGuidHob ( + IN UINT8 *HobRaw + ) +{ + UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SMBiosTable; + SMBiosTable =3D (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *) GET_GUID_HOB_DATA (Ho= bRaw); + 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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintAcpiBoardInfoGuidHob ( + IN UINT8 *HobRaw + ) +{ + ACPI_BOARD_INFO *AcpBoardInfo; + AcpBoardInfo =3D (ACPI_BOARD_INFO *) GET_GUID_HOB_DATA (HobRaw); + 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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintPciRootBridgeInfoGuidHob ( + IN UINT8 *HobRaw + ) +{ + UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridges; + UINTN Index; + Index =3D 0; + PciRootBridges =3D (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GET_GUID_HOB_D= ATA (HobRaw); + 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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintExtraDataGuidHob ( + IN UINT8 *HobRaw + ) +{ + UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData; + UINTN Index; + + Index =3D 0; + ExtraData =3D (UNIVERSAL_PAYLOAD_EXTRA_DATA *) GET_GUID_HOB_DATA (HobRaw= ); + + DEBUG ((DEBUG_INFO, " Revision =3D 0x%x\n", ExtraData->PldHeader.Revi= sion)); + DEBUG ((DEBUG_INFO, " Length =3D 0x%x\n", ExtraData->PldHeader.Leng= th)); + 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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintMemoryTypeInfoGuidHob ( + IN UINT8 *HobRaw + ) +{ + EFI_MEMORY_TYPE_INFORMATION *MemoryTypeInfo; + + MemoryTypeInfo =3D (EFI_MEMORY_TYPE_INFORMATION *) GET_GUID_HOB_DATA (Ho= bRaw); + + 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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintGuidHob ( + IN VOID *HobStart, + IN UINTN Hobsize + ) +{ + EFI_PEI_HOB_POINTERS Hob; + UINTN Index; + EFI_STATUS Status; + + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (Hobsize >=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].Function (Hob.Raw); + 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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintFvHob ( + IN VOID *HobStart, + IN UINTN Hobsize + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (Hobsize >=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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintCpuHob ( + IN VOID *HobStart, + IN UINTN Hobsize + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (Hobsize >=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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintMemoryPoolHob ( + IN VOID *HobStart, + IN UINTN Hobsize + ) +{ + return EFI_SUCCESS; +} + +/** + Print the information in Fv2Hob. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintFv2Hob ( + IN VOID *HobStart, + IN UINTN Hobsize + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (Hobsize >=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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintCapsuleHob ( + IN VOID *HobStart, + IN UINTN Hobsize + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (Hobsize >=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. + + @retval EFI_SUCCESS If it completed successfully. +**/ +EFI_STATUS +PrintFv3Hob ( + IN VOID *HobStart, + IN UINTN Hobsize + ) +{ + EFI_PEI_HOB_POINTERS Hob; + Hob.Raw =3D (UINT8 *) HobStart; + ASSERT (Hobsize >=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}, //0x0001 + {EFI_HOB_TYPE_MEMORY_ALLOCATION, "EFI_HOB_TYPE_MEMORY_ALLOCATION", P= rintMemoryAllocationHob}, //0x0002 + {EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR", P= rintResourceDiscriptorHob}, //0x0003 + {EFI_HOB_TYPE_GUID_EXTENSION, "EFI_HOB_TYPE_GUID_EXTENSION", P= rintGuidHob}, //0x0004 + {EFI_HOB_TYPE_FV, "EFI_HOB_TYPE_FV", P= rintFvHob}, //0x0005 + {EFI_HOB_TYPE_CPU, "EFI_HOB_TYPE_CPU", P= rintCpuHob}, //0x0006 + {EFI_HOB_TYPE_MEMORY_POOL, "EFI_HOB_TYPE_MEMORY_POOL", P= rintMemoryPoolHob}, //0x0007 + {EFI_HOB_TYPE_FV2, "EFI_HOB_TYPE_FV2", P= rintFv2Hob}, //0x0009 + {EFI_HOB_TYPE_UEFI_CAPSULE, "EFI_HOB_TYPE_UEFI_CAPSULE", P= rintCapsuleHob}, //0x000B + {EFI_HOB_TYPE_FV3, "EFI_HOB_TYPE_FV3", P= rintFv3Hob} //0x000C +}; + + +/** + Print all HOBs info from 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].Function (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 a67653eb11..5b61ed06f8 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 @@ -376,6 +386,11 @@ _ModuleEntryPoint ( DEBUG ((DEBUG_INFO, "Entering Universal Payload...\n")); DEBUG ((DEBUG_INFO, "sizeof(UINTN) =3D 0x%x\n", sizeof(UINTN))); =20 + // + // 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..ae7c22676b 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,13 @@ gUefiSerialPortInfoGuid gUniversalPayloadExtraDataGuid gPcdDataBaseHobGuid + gUniversalPayloadSmbiosTableGuid + gUniversalPayloadAcpiTableGuid + gUniversalPayloadPciRootBridgeInfoGuid + gUniversalPayloadSmbios3TableGuid + gEfiHobMemoryAllocBspStoreGuid + gEfiHobMemoryAllocModuleGuid + gEfiHobMemoryAllocStackGuid =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 (#77366): https://edk2.groups.io/g/devel/message/77366 Mute This Topic: https://groups.io/mt/83892156/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-