From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 13B75740035 for ; Mon, 3 Jun 2024 02:19:04 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=JNIbgRQfEcUKBQ/EQgsxKfLRF0+GOfRCdr1GaGcEXUs=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1717381144; v=1; b=wHZu5bB6VQZza9F74UlaGNG1u6JJCj7+rieiS3CRNpIo5/v6/MpnWJy+KKcY7Aa32gMZb6Ry kO/cKB+jwwCt1xSPd4N3fOCeV7etaQQer577qlUkZT/ClNBhGDla6FsDyOjF5lBxGlcw+wQX6Hb k3lQNtK55NUJBeviMhjurJ0tGDx0Jh1Gc9V/LKjey34pYxiHYUDMy2adZOi1C73egCRMneII+GY t5yIzhIW3xaCZh7x3pn2PV0KrWcL96pgU9J2YYi2N1mQSZdga8vI8yYfZK2wNBQZLay6WU44HWw xbK+N8veVsBFpaVaqsIAf7ihDveh8Av5I6XLsZkmnSsVQ== X-Received: by 127.0.0.2 with SMTP id 3yb1YY7687511xV8UHRT3Ypn; Sun, 02 Jun 2024 19:19:03 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by mx.groups.io with SMTP id smtpd.web11.73936.1717381143155655294 for ; Sun, 02 Jun 2024 19:19:03 -0700 X-CSE-ConnectionGUID: zm1k7pl9Tw27ziMl3DSV4g== X-CSE-MsgGUID: cXNxTUWXSkGnWWOlXdfEkg== X-IronPort-AV: E=McAfee;i="6600,9927,11091"; a="17688899" X-IronPort-AV: E=Sophos;i="6.08,210,1712646000"; d="scan'208";a="17688899" X-Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2024 19:19:04 -0700 X-CSE-ConnectionGUID: 3rc8ijQyRf+bpPu6OKQxog== X-CSE-MsgGUID: e6jcIyMYQvaIQNjgnksfkg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,210,1712646000"; d="scan'208";a="41667880" X-Received: from linusliu-desk1.gar.corp.intel.com ([10.225.76.64]) by orviesa005.jf.intel.com with ESMTP; 02 Jun 2024 19:19:00 -0700 From: "Linus Liu" To: devel@edk2.groups.io Cc: Benny Lin , Gua Guo , Chasel Chiu , James Lu , Dhaval Sharma Subject: [edk2-devel] [PATCH v4 5/6] UefiPayloadPkg: Add FDT Paser relative LIBs. Date: Sun, 2 Jun 2024 19:18:55 -0700 Message-Id: <20240603021855.526-1-linus.liu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Sun, 02 Jun 2024 19:19:03 -0700 Resent-From: linus.liu@intel.com Reply-To: devel@edk2.groups.io,linus.liu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 5CeMa1hrQATVZXW6vmi8OCe2x7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=wHZu5bB6; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Add FDTParser and CustomFdtNodePaser to retrive all FDT node and create the relate hobs. Cc: Benny Lin Cc: Gua Guo Cc: Chasel Chiu Cc: James Lu Cc: Dhaval Sharma Signed-off-by: Linus Liu --- UefiPayloadPkg/Library/CustomFdtNodeParserLib/CustomFdtNodeParserLib.c = | 158 +++++ UefiPayloadPkg/Library/CustomFdtNodeParserNullLib/CustomFdtNodeParserNullL= ib.c | 51 ++ UefiPayloadPkg/Library/FdtParserLib/FdtParserLib.c = | 627 ++++++++++++++++++++ UefiPayloadPkg/Library/HobParseLib/HobParseLib.c = | 408 +++++++++++++ UefiPayloadPkg/Library/CustomFdtNodeParserLib/CustomFdtNodeParserLib.inf = | 46 ++ UefiPayloadPkg/Library/CustomFdtNodeParserNullLib/CustomFdtNodeParserNullL= ib.inf | 33 ++ UefiPayloadPkg/Library/FdtParserLib/FdtParseLib.inf = | 63 ++ UefiPayloadPkg/Library/HobParseLib/HobParseLib.inf = | 40 ++ 8 files changed, 1426 insertions(+) diff --git a/UefiPayloadPkg/Library/CustomFdtNodeParserLib/CustomFdtNodePar= serLib.c b/UefiPayloadPkg/Library/CustomFdtNodeParserLib/CustomFdtNodeParse= rLib.c new file mode 100644 index 000000000000..d1376d21c5dd --- /dev/null +++ b/UefiPayloadPkg/Library/CustomFdtNodeParserLib/CustomFdtNodeParserLib.c @@ -0,0 +1,158 @@ +/** @file=0D + Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +/**=0D + Add a new HOB to the HOB List.=0D +=0D + @param HobType Type of the new HOB.=0D + @param HobLength Length of the new HOB to allocate.=0D +=0D + @return NULL if there is no space to create a hob.=0D + @return The address point to the new created hob.=0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +CreateHob (=0D + IN UINT16 HobType,=0D + IN UINT16 HobLength=0D + );=0D +=0D +/**=0D + Add HOB into HOB list=0D + @param[in] Hob The HOB to be added into the HOB list.=0D +**/=0D +VOID=0D +AddNewHob (=0D + IN EFI_PEI_HOB_POINTERS *Hob=0D + );=0D +=0D +/**=0D + Check the HOB and decide if it is need inside Payload=0D + Payload maintainer may make decision which HOB is need or needn't=0D + Then add the check logic in the function.=0D + @param[in] Hob The HOB to check=0D + @retval TRUE If HOB is need inside Payload=0D + @retval FALSE If HOB is needn't inside Payload=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +FitIsHobNeed (=0D + EFI_PEI_HOB_POINTERS Hob=0D + )=0D +{=0D + if (FixedPcdGetBool (PcdHandOffFdtEnable)) {=0D + if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_HANDOFF) {=0D + return FALSE;=0D + }=0D +=0D + if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_MEMORY_ALLOCATION) {=0D + if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gUniv= ersalPayloadDeviceTreeGuid)) {=0D + return FALSE;=0D + }=0D +=0D + if (CompareGuid (&Hob.MemoryAllocationModule->MemoryAllocationHeader= .Name, &gEfiHobMemoryAllocModuleGuid)) {=0D + return FALSE;=0D + }=0D +=0D + if ((Hob.MemoryAllocation->AllocDescriptor.MemoryType =3D=3D EfiRese= rvedMemoryType) ||=0D + (Hob.MemoryAllocation->AllocDescriptor.MemoryType =3D=3D EfiBoot= ServicesCode) ||=0D + (Hob.MemoryAllocation->AllocDescriptor.MemoryType =3D=3D EfiBoot= ServicesData) ||=0D + (Hob.MemoryAllocation->AllocDescriptor.MemoryType =3D=3D EfiRunt= imeServicesCode) ||=0D + (Hob.MemoryAllocation->AllocDescriptor.MemoryType =3D=3D EfiRunt= imeServicesData) ||=0D + (Hob.MemoryAllocation->AllocDescriptor.MemoryType =3D=3D EfiACPI= ReclaimMemory) ||=0D + (Hob.MemoryAllocation->AllocDescriptor.MemoryType =3D=3D EfiACPI= MemoryNVS))=0D + {=0D + return FALSE;=0D + }=0D + }=0D +=0D + if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_GUID_EXTENSION) {=0D + if (CompareGuid (&Hob.Guid->Name, &gUniversalPayloadSerialPortInfoGu= id)) {=0D + return FALSE;=0D + }=0D +=0D + if (CompareGuid (&Hob.Guid->Name, &gUniversalPayloadAcpiTableGuid)) = {=0D + return FALSE;=0D + }=0D +=0D + if (CompareGuid (&Hob.Guid->Name, &gUniversalPayloadPciRootBridgeInf= oGuid)) {=0D + return FALSE;=0D + }=0D + }=0D + }=0D +=0D + // Arrive here mean the HOB is need=0D + return TRUE;=0D +}=0D +=0D +/**=0D + It will Parse FDT -custom node based on information from bootloaders.=0D + @param[in] FdtBase The starting memory address of FdtBase=0D + @param[in] HobList The starting memory address of New Hob list.=0D +=0D +**/=0D +UINTN=0D +EFIAPI=0D +CustomFdtNodeParser (=0D + IN VOID *FdtBase,=0D + IN VOID *HobList=0D + )=0D +{=0D + INT32 Node, CustomNode;=0D + INT32 TempLen;=0D + UINT64 *Data64;=0D + UINTN CHobList;=0D + CONST FDT_PROPERTY *PropertyPtr;=0D + EFI_PEI_HOB_POINTERS Hob;=0D +=0D + CHobList =3D (UINTN)HobList;=0D +=0D + DEBUG ((DEBUG_INFO, "%a() #1 \n", __func__));=0D +=0D + //=0D + // Look for if exists hob list node=0D + //=0D + Node =3D FdtSubnodeOffsetNameLen (FdtBase, 0, "options", (INT32)AsciiStr= Len ("options"));=0D + if (Node > 0) {=0D + DEBUG ((DEBUG_INFO, " Found options node (%08X)", Node));=0D + CustomNode =3D FdtSubnodeOffsetNameLen (FdtBase, Node, "upl-custom", (= INT32)AsciiStrLen ("upl-custom"));=0D + if (CustomNode > 0) {=0D + DEBUG ((DEBUG_INFO, " Found upl-custom node (%08X)", CustomNode));= =0D + PropertyPtr =3D FdtGetProperty (FdtBase, CustomNode, "hoblistptr", &= TempLen);=0D + Data64 =3D (UINT64 *)(PropertyPtr->Data);=0D + CHobList =3D (UINTN)Fdt64ToCpu (*Data64);=0D + DEBUG ((DEBUG_INFO, " Found hob list node (%08X)", CustomNode));=0D + DEBUG ((DEBUG_INFO, " -pointer %016lX\n", CHobList));=0D + }=0D + }=0D +=0D + Hob.Raw =3D (UINT8 *)CHobList;=0D +=0D + //=0D + // Since payload created new Hob, move all hobs except PHIT from boot lo= ader hob list.=0D + //=0D + while (!END_OF_HOB_LIST (Hob)) {=0D + if (FitIsHobNeed (Hob)) {=0D + // Add this hob to payload HOB=0D + AddNewHob (&Hob);=0D + }=0D +=0D + Hob.Raw =3D GET_NEXT_HOB (Hob);=0D + }=0D +=0D + return CHobList;=0D +}=0D diff --git a/UefiPayloadPkg/Library/CustomFdtNodeParserNullLib/CustomFdtNod= eParserNullLib.c b/UefiPayloadPkg/Library/CustomFdtNodeParserNullLib/Custom= FdtNodeParserNullLib.c new file mode 100644 index 000000000000..0012162fa0d2 --- /dev/null +++ b/UefiPayloadPkg/Library/CustomFdtNodeParserNullLib/CustomFdtNodeParser= NullLib.c @@ -0,0 +1,51 @@ +/** @file=0D + Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#include =0D +#include =0D +=0D +/**=0D + Check the HOB and decide if it is need inside Payload=0D + Payload maintainer may make decision which HOB is need or needn't=0D + Then add the check logic in the function.=0D + @param[in] Hob The HOB to check=0D + @retval TRUE If HOB is need inside Payload=0D + @retval FALSE If HOB is needn't inside Payload=0D +**/=0D +BOOLEAN=0D +FitIsHobNeed (=0D + EFI_PEI_HOB_POINTERS Hob=0D + )=0D +{=0D + return FALSE;=0D +}=0D +=0D +/**=0D + It will Parse FDT -custom node based on information from bootloaders.=0D + @param[in] FdtBase The starting memory address of FdtBase.=0D + @param[in] HobList The starting memory address of New Hob list.=0D + @retval HobList The base address of Hoblist.=0D +=0D +**/=0D +UINTN=0D +CustomFdtNodeParser (=0D + IN VOID *Fdt,=0D + IN VOID *HobList=0D + )=0D +{=0D + UINTN CHobList;=0D +=0D + if (HobList !=3D NULL) {=0D + CHobList =3D (UINTN)HobList;=0D + }=0D +=0D + return CHobList;=0D +}=0D diff --git a/UefiPayloadPkg/Library/FdtParserLib/FdtParserLib.c b/UefiPaylo= adPkg/Library/FdtParserLib/FdtParserLib.c new file mode 100644 index 000000000000..aa944bd1e821 --- /dev/null +++ b/UefiPayloadPkg/Library/FdtParserLib/FdtParserLib.c @@ -0,0 +1,627 @@ +/** @file=0D + Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#define N_NON_RELOCATABLE BIT31=0D +#define P_NON_PREFETCHABLE BIT30=0D +#define SS_CONFIGURATION_SPACE 0=0D +#define SS_IO_SPACE BIT24=0D +#define SS_32BIT_MEMORY_SPACE BIT25=0D +#define SS_64BIT_MEMORY_SPACE BIT24+BIT25=0D +=0D +#define MEMORY_ATTRIBUTE_DEFAULT (EFI_RESOURCE_ATTRIBUTE_PRESENT = | \=0D + EFI_RESOURCE_ATTRIBUTE_INITIALIZED = | \=0D + EFI_RESOURCE_ATTRIBUTE_TESTED = | \=0D + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE = | \=0D + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEA= BLE | \=0D + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_= CACHEABLE | \=0D + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CAC= HEABLE )=0D +=0D +#define ROOT_BRIDGE_SUPPORTS_DEFAULT (EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 | \= =0D + EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 | \=0D + EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 | \=0D + EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO | \=0D + EFI_PCI_IO_ATTRIBUTE_VGA_IO | \=0D + EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | \=0D + EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO | \=0D + EFI_PCI_IO_ATTRIBUTE_ISA_IO | \=0D + EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO )=0D +=0D +extern VOID *mHobList;=0D +=0D +/**=0D + Build ACPI board info HOB using infomation from ACPI table=0D +=0D + @param AcpiTableBase ACPI table start address in memory=0D +=0D + @retval A pointer to ACPI board HOB ACPI_BOARD_INFO. Null if build HOB = failure.=0D +**/=0D +ACPI_BOARD_INFO *=0D +BuildHobFromAcpi (=0D + IN UINT64 AcpiTableBase=0D + );=0D +=0D +/**=0D + Build a Handoff Information Table HOB=0D +=0D + This function initialize a HOB region from EfiMemoryBegin to=0D + EfiMemoryTop. And EfiFreeMemoryBottom and EfiFreeMemoryTop should=0D + be inside the HOB region.=0D +=0D + @param[in] EfiMemoryBottom Total memory start address=0D + @param[in] EfiMemoryTop Total memory end address.=0D + @param[in] EfiFreeMemoryBottom Free memory start address=0D + @param[in] EfiFreeMemoryTop Free memory end address.=0D +=0D + @return The pointer to the handoff HOB table.=0D +=0D +**/=0D +EFI_HOB_HANDOFF_INFO_TABLE *=0D +EFIAPI=0D +HobConstructor (=0D + IN VOID *EfiMemoryBottom,=0D + IN VOID *EfiMemoryTop,=0D + IN VOID *EfiFreeMemoryBottom,=0D + IN VOID *EfiFreeMemoryTop=0D + );=0D +=0D +/**=0D + It will parse FDT based on DTB from bootloaders.=0D +=0D + @param[in] FdtBase Address of the Fdt data.=0D +=0D + @return The address to the new hob list=0D +**/=0D +UINTN=0D +EFIAPI=0D +ParseDtb (=0D + IN VOID *FdtBase=0D + )=0D +{=0D + VOID *Fdt;=0D + INT32 Node;=0D + INT32 Property;=0D + INT32 Depth;=0D + FDT_NODE_HEADER *NodePtr;=0D + CONST FDT_PROPERTY *PropertyPtr;=0D + CONST CHAR8 *TempStr;=0D + INT32 TempLen;=0D + UINT32 *Data32;=0D + UINT64 *Data64;=0D + UINT64 StartAddress;=0D + INT32 SubNode;=0D + UINT64 NumberOfBytes;=0D + UINT32 Attribute;=0D + UINT8 ECCAttribute;=0D + UINT32 ECCData, ECCData2;=0D + UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *Serial;=0D + UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridgeInfo;=0D + UNIVERSAL_PAYLOAD_ACPI_TABLE *PlatformAcpiTable;=0D + UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmbiosTable;=0D + UEFI_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL *DebugPrintErrorLevelInfo;=0D + UNIVERSAL_PAYLOAD_BASE *PayloadBase;=0D + EFI_PEI_GRAPHICS_INFO_HOB *GraphicsInfo;=0D + EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *GraphicsDev;=0D + UINT8 SizeOfMemorySpace;=0D + UINT64 FrameBufferBase;=0D + UINT64 FrameBufferSize;=0D + UINTN MinimalNeededSize;=0D + EFI_PHYSICAL_ADDRESS FreeMemoryBottom;=0D + EFI_PHYSICAL_ADDRESS FreeMemoryTop;=0D + EFI_PHYSICAL_ADDRESS MemoryBottom;=0D + EFI_PHYSICAL_ADDRESS MemoryTop;=0D + BOOLEAN IsHobConstructed;=0D + UINTN NewHobList;=0D + UINT8 RootBridgeCount;=0D + UINT8 index;=0D + UINTN HobDataSize;=0D +=0D + Fdt =3D FdtBase;=0D + Depth =3D 0;=0D + FrameBufferBase =3D 0;=0D + FrameBufferSize =3D 0;=0D + MinimalNeededSize =3D FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);=0D + IsHobConstructed =3D FALSE;=0D + NewHobList =3D 0;=0D + PlatformAcpiTable =3D NULL;=0D + SmbiosTable =3D NULL;=0D + PciRootBridgeInfo =3D NULL;=0D + RootBridgeCount =3D 0;=0D + index =3D 1;=0D + HobDataSize =3D 0;=0D +=0D + DEBUG ((DEBUG_INFO, "FDT =3D 0x%x %x\n", Fdt, Fdt32ToCpu (*((UINT32 *)F= dt))));=0D + DEBUG ((DEBUG_INFO, "Start parsing DTB data\n"));=0D + DEBUG ((DEBUG_INFO, "MinimalNeededSize :%x\n", MinimalNeededSize));=0D +=0D + for (Node =3D FdtNextNode (Fdt, 0, &Depth); Node >=3D 0; Node =3D FdtNex= tNode (Fdt, Node, &Depth)) {=0D + if (Depth !=3D 1) {=0D + continue;=0D + }=0D +=0D + NodePtr =3D (FDT_NODE_HEADER *)((CONST CHAR8 *)Fdt + Node + Fdt32ToCpu= (((FDT_HEADER *)Fdt)->OffsetDtStruct));=0D + DEBUG ((DEBUG_INFO, "\n Node(%08x) %a Depth %x", Node, NodePtr->N= ame, Depth));=0D + // memory node=0D + if (AsciiStrnCmp (NodePtr->Name, "memory@", AsciiStrLen ("memory@")) = =3D=3D 0) {=0D + for (Property =3D FdtFirstPropertyOffset (Fdt, Node); Property >=3D = 0; Property =3D FdtNextPropertyOffset (Fdt, Property)) {=0D + PropertyPtr =3D FdtGetPropertyByOffset (Fdt, Property, &TempLen);= =0D + TempStr =3D FdtGetString (Fdt, Fdt32ToCpu (PropertyPtr->NameOf= fset), NULL);=0D + if (AsciiStrCmp (TempStr, "reg") =3D=3D 0) {=0D + Data64 =3D (UINT64 *)(PropertyPtr->Data);=0D + StartAddress =3D Fdt64ToCpu (*Data64);=0D + NumberOfBytes =3D Fdt64ToCpu (*(Data64 + 1));=0D + DEBUG ((DEBUG_INFO, "\n Property(%08X) %a", Property, T= empStr));=0D + DEBUG ((DEBUG_INFO, " %016lX %016lX", StartAddress, NumberOfBy= tes));=0D + if (!IsHobConstructed) {=0D + if ((NumberOfBytes > MinimalNeededSize) && (StartAddress < BAS= E_4GB)) {=0D + MemoryBottom =3D StartAddress + NumberOfBytes - MinimalN= eededSize;=0D + FreeMemoryBottom =3D MemoryBottom;=0D + FreeMemoryTop =3D StartAddress + NumberOfBytes;=0D + MemoryTop =3D FreeMemoryTop;=0D +=0D + DEBUG ((DEBUG_INFO, "MemoryBottom :0x%llx\n", MemoryBottom))= ;=0D + DEBUG ((DEBUG_INFO, "FreeMemoryBottom :0x%llx\n", FreeMemory= Bottom));=0D + DEBUG ((DEBUG_INFO, "FreeMemoryTop :0x%llx\n", FreeMemoryTop= ));=0D + DEBUG ((DEBUG_INFO, "MemoryTop :0x%llx\n", MemoryTop));=0D + mHobList =3D HobConstructor ((VOID *)(UINTN)MemoryB= ottom, (VOID *)(UINTN)MemoryTop, (VOID *)(UINTN)FreeMemoryBottom, (VOID *)(= UINTN)FreeMemoryTop);=0D + IsHobConstructed =3D TRUE;=0D + NewHobList =3D (UINTN)mHobList;=0D + break;=0D + }=0D + }=0D + }=0D + }=0D + } // end of memory node=0D + else if (AsciiStrnCmp (NodePtr->Name, "pci-rb", AsciiStrLen ("pci-rb")= ) =3D=3D 0) {=0D + RootBridgeCount++;=0D + }=0D + }=0D +=0D + Depth =3D 0;=0D + for (Node =3D FdtNextNode (Fdt, 0, &Depth); Node >=3D 0; Node =3D FdtNex= tNode (Fdt, Node, &Depth)) {=0D + if (Depth !=3D 1) {=0D + continue;=0D + }=0D +=0D + NodePtr =3D (FDT_NODE_HEADER *)((CONST CHAR8 *)Fdt + Node + Fdt32ToCpu= (((FDT_HEADER *)Fdt)->OffsetDtStruct));=0D + DEBUG ((DEBUG_INFO, "\n Node(%08x) %a Depth %x", Node, NodePtr->N= ame, Depth));=0D +=0D + // memory node=0D + if (AsciiStrnCmp (NodePtr->Name, "memory@", AsciiStrLen ("memory@")) = =3D=3D 0) {=0D + Attribute =3D MEMORY_ATTRIBUTE_DEFAULT;=0D + ECCAttribute =3D 0;=0D + ECCData =3D ECCData2 =3D 0;=0D + for (Property =3D FdtFirstPropertyOffset (Fdt, Node); Property >=3D = 0; Property =3D FdtNextPropertyOffset (Fdt, Property)) {=0D + PropertyPtr =3D FdtGetPropertyByOffset (Fdt, Property, &TempLen);= =0D + TempStr =3D FdtGetString (Fdt, Fdt32ToCpu (PropertyPtr->NameOf= fset), NULL);=0D + if (AsciiStrCmp (TempStr, "reg") =3D=3D 0) {=0D + Data64 =3D (UINT64 *)(PropertyPtr->Data);=0D + StartAddress =3D Fdt64ToCpu (*Data64);=0D + NumberOfBytes =3D Fdt64ToCpu (*(Data64 + 1));=0D + } else if (AsciiStrCmp (TempStr, "ecc-detection-bits") =3D=3D 0) {= =0D + Data32 =3D (UINT32 *)(PropertyPtr->Data);=0D + ECCData =3D Fdt32ToCpu (*Data32);=0D + } else if (AsciiStrCmp (TempStr, "ecc-correction-bits") =3D=3D 0) = {=0D + Data32 =3D (UINT32 *)(PropertyPtr->Data);=0D + ECCData2 =3D Fdt32ToCpu (*Data32);=0D + }=0D + }=0D +=0D + if (ECCData =3D=3D ECCData2) {=0D + if (ECCData =3D=3D 1) {=0D + ECCAttribute =3D EFI_RESOURCE_ATTRIBUTE_SINGLE_BIT_ECC;=0D + } else if (ECCData =3D=3D 2) {=0D + ECCAttribute =3D EFI_RESOURCE_ATTRIBUTE_MULTIPLE_BIT_ECC;=0D + }=0D + }=0D +=0D + if (ECCAttribute !=3D 0) {=0D + Attribute |=3D ECCAttribute;=0D + }=0D +=0D + BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY, Attribute, S= tartAddress, NumberOfBytes);=0D + } // end of memory node=0D + // reserved-memory=0D + else if (AsciiStrCmp (NodePtr->Name, "reserved-memory") =3D=3D 0) {=0D + for (SubNode =3D FdtFirstSubnode (Fdt, Node); SubNode >=3D 0; SubNod= e =3D FdtNextSubnode (Fdt, SubNode)) {=0D + NodePtr =3D (FDT_NODE_HEADER *)((CONST CHAR8 *)Fdt + SubNode + Fdt= 32ToCpu (((FDT_HEADER *)Fdt)->OffsetDtStruct));=0D + DEBUG ((DEBUG_INFO, "\n SubNode(%08X) %a", SubNode, NodePtr-= >Name));=0D +=0D + PropertyPtr =3D FdtGetProperty (Fdt, SubNode, "reg", &TempLen);=0D + ASSERT (TempLen > 0);=0D + if (TempLen > 0) {=0D + Data64 =3D (UINT64 *)(PropertyPtr->Data);=0D + StartAddress =3D Fdt64ToCpu (*Data64);=0D + NumberOfBytes =3D Fdt64ToCpu (*(Data64 + 1));=0D + DEBUG ((DEBUG_INFO, "\n Property(%08X) %a", Property, T= empStr));=0D + DEBUG ((DEBUG_INFO, " %016lX %016lX", StartAddress, NumberOfBy= tes));=0D + }=0D +=0D + if (AsciiStrnCmp (NodePtr->Name, "mmio@", AsciiStrLen ("mmio@")) = =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, " MemoryMappedIO"));=0D + BuildMemoryAllocationHob (StartAddress, NumberOfBytes, EfiMemory= MappedIO);=0D + } else {=0D + PropertyPtr =3D FdtGetProperty (Fdt, SubNode, "compatible", &Tem= pLen);=0D + if (!(TempLen > 0)) {=0D + BuildMemoryAllocationHob (StartAddress, NumberOfBytes, EfiRese= rvedMemoryType);=0D + continue;=0D + }=0D +=0D + TempStr =3D (CHAR8 *)(PropertyPtr->Data);=0D +=0D + if (AsciiStrnCmp (TempStr, "boot-code", AsciiStrLen ("boot-code"= )) =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, " boot-code"));=0D + BuildMemoryAllocationHob (StartAddress, NumberOfBytes, EfiBoot= ServicesCode);=0D + } else if (AsciiStrnCmp (TempStr, "boot-data", AsciiStrLen ("boo= t-data")) =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, " boot-data"));=0D + BuildMemoryAllocationHob (StartAddress, NumberOfBytes, EfiBoot= ServicesData);=0D + } else if (AsciiStrnCmp (TempStr, "runtime-code", AsciiStrLen ("= runtime-code")) =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, " runtime-code"));=0D + BuildMemoryAllocationHob (StartAddress, NumberOfBytes, EfiRunt= imeServicesCode);=0D + } else if (AsciiStrnCmp (TempStr, "runtime-data", AsciiStrLen ("= runtime-data")) =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, " runtime-data"));=0D + BuildMemoryAllocationHob (StartAddress, NumberOfBytes, EfiRunt= imeServicesData);=0D + } else if (AsciiStrnCmp (TempStr, "acpi", AsciiStrLen ("acpi")) = =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, " acpi, StartAddress:%x, NumberOfBytes:%x= ", StartAddress, NumberOfBytes));=0D + BuildMemoryAllocationHob (StartAddress, NumberOfBytes, EfiBoot= ServicesData);=0D + PlatformAcpiTable =3D BuildGuidHob (&gUniversalPayloadAcpiTabl= eGuid, sizeof (UNIVERSAL_PAYLOAD_ACPI_TABLE));=0D + if (PlatformAcpiTable !=3D NULL) {=0D + DEBUG ((DEBUG_INFO, " build gUniversalPayloadAcpiTableGuid ,= NumberOfBytes:%x", NumberOfBytes));=0D + PlatformAcpiTable->Rsdp =3D (EFI_PHYSICAL_ADDRESS= )(UINTN)StartAddress;=0D + PlatformAcpiTable->Header.Revision =3D UNIVERSAL_PAYLOAD_ACP= I_TABLE_REVISION;=0D + PlatformAcpiTable->Header.Length =3D sizeof (UNIVERSAL_PAY= LOAD_ACPI_TABLE);=0D + }=0D + } else if (AsciiStrnCmp (TempStr, "acpi-nvs", AsciiStrLen ("acpi= -nvs")) =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, " acpi-nvs"));=0D + BuildMemoryAllocationHob (StartAddress, NumberOfBytes, EfiACPI= MemoryNVS);=0D + } else if (AsciiStrnCmp (TempStr, "smbios", AsciiStrLen ("smbios= ")) =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, " build smbios, NumberOfBytes:%x", NumberO= fBytes));=0D + SmbiosTable =3D BuildGuidHob (&gUniversalPayloadSmbios3TableGu= id, sizeof (UNIVERSAL_PAYLOAD_SMBIOS_TABLE) + sizeof (SMBIOS_TABLE_3_0_ENTR= Y_POINT));=0D + if (SmbiosTable !=3D NULL) {=0D + SmbiosTable->Header.Revision =3D UNIVERSAL_PAYLOAD_SMBIOS_T= ABLE_REVISION;=0D + SmbiosTable->Header.Length =3D sizeof (UNIVERSAL_PAYLOAD_= SMBIOS_TABLE);=0D + SmbiosTable->SmBiosEntryPoint =3D (EFI_PHYSICAL_ADDRESS)(UIN= TN)(&StartAddress);=0D + }=0D + }=0D + }=0D + }=0D + } // end of reserved-memory=0D +=0D + if (AsciiStrnCmp (NodePtr->Name, "serial@", AsciiStrLen ("serial@")) = =3D=3D 0) {=0D + //=0D + // Create SerialPortInfo HOB.=0D + //=0D + Serial =3D BuildGuidHob (&gUniversalPayloadSerialPortInfoGuid, sizeo= f (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO));=0D + ASSERT (Serial !=3D NULL);=0D + if (Serial =3D=3D NULL) {=0D + break;=0D + }=0D +=0D + Serial->Header.Revision =3D UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_REVIS= ION;=0D + Serial->Header.Length =3D sizeof (UNIVERSAL_PAYLOAD_SERIAL_PORT_IN= FO);=0D + Serial->RegisterStride =3D 1;=0D +=0D + for (Property =3D FdtFirstPropertyOffset (Fdt, Node); Property >=3D = 0; Property =3D FdtNextPropertyOffset (Fdt, Property)) {=0D + PropertyPtr =3D FdtGetPropertyByOffset (Fdt, Property, &TempLen);= =0D + TempStr =3D FdtGetString (Fdt, Fdt32ToCpu (PropertyPtr->NameOf= fset), NULL);=0D + if (AsciiStrCmp (TempStr, "current-speed") =3D=3D 0) {=0D + Data32 =3D (UINT32 *)(PropertyPtr->Data);=0D + DEBUG ((DEBUG_INFO, "\n Property(%08X) %a", Property, T= empStr));=0D + DEBUG ((DEBUG_INFO, " %X", Fdt32ToCpu (*Data32)));=0D +=0D + Serial->BaudRate =3D Fdt32ToCpu (*Data32);=0D + } else if (AsciiStrCmp (TempStr, "reg") =3D=3D 0) {=0D + Data32 =3D (UINT32 *)(PropertyPtr->Data);=0D + Attribute =3D Fdt32ToCpu (*(Data32 + 0));=0D + StartAddress =3D Fdt32ToCpu (*(Data32 + 2));=0D + DEBUG ((DEBUG_INFO, "\n Property(%08X) %a", Property, T= empStr));=0D + DEBUG ((DEBUG_INFO, " StartAddress %016lX\n", StartAddress));= =0D + DEBUG ((DEBUG_INFO, " Attribute %016lX\n", Attribute));=0D +=0D + Serial->RegisterBase =3D StartAddress;=0D + Serial->UseMmio =3D (Attribute&SS_32BIT_MEMORY_SPACE) =3D= =3D SS_32BIT_MEMORY_SPACE ? TRUE : FALSE;=0D + }=0D + }=0D + } else if (AsciiStrCmp (NodePtr->Name, "graphic") =3D=3D 0) {=0D + //=0D + // Create GraphicInfo HOB.=0D + //=0D + GraphicsInfo =3D BuildGuidHob (&gEfiGraphicsInfoHobGuid, sizeof (EFI= _PEI_GRAPHICS_INFO_HOB));=0D + ASSERT (GraphicsInfo !=3D NULL);=0D + if (GraphicsInfo =3D=3D NULL) {=0D + break;=0D + }=0D +=0D + GraphicsDev =3D BuildGuidHob (&gEfiGraphicsDeviceInfoHobGuid, sizeof= (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB));=0D + ASSERT (GraphicsDev !=3D NULL);=0D + if (GraphicsDev =3D=3D NULL) {=0D + break;=0D + }=0D +=0D + if (FrameBufferBase !=3D 0) {=0D + GraphicsInfo->FrameBufferBase =3D FrameBufferBase;=0D + }=0D +=0D + if (FrameBufferSize !=3D 0) {=0D + GraphicsInfo->FrameBufferSize =3D (UINT32)FrameBufferSize;=0D + }=0D +=0D + for (Property =3D FdtFirstPropertyOffset (Fdt, Node); Property >=3D = 0; Property =3D FdtNextPropertyOffset (Fdt, Property)) {=0D + PropertyPtr =3D FdtGetPropertyByOffset (Fdt, Property, &TempLen);= =0D + TempStr =3D FdtGetString (Fdt, Fdt32ToCpu (PropertyPtr->NameOf= fset), NULL);=0D + if (AsciiStrCmp (TempStr, "resolution") =3D=3D 0) {=0D + Data32 =3D (UINT32 *)(P= ropertyPtr->Data);=0D + GraphicsInfo->GraphicsMode.HorizontalResolution =3D Fdt32ToCpu (= *Data32);=0D + GraphicsInfo->GraphicsMode.VerticalResolution =3D Fdt32ToCpu (= *(Data32 + 1));=0D + } else if (AsciiStrCmp (TempStr, "pixel-format") =3D=3D 0) {=0D + Data32 =3D (UINT32 *)(PropertyPt= r->Data);=0D + GraphicsInfo->GraphicsMode.PixelFormat =3D Fdt32ToCpu (*Data32);= =0D + } else if (AsciiStrCmp (TempStr, "pixel-mask") =3D=3D 0) {=0D + Data32 =3D (UINT3= 2 *)(PropertyPtr->Data);=0D + GraphicsInfo->GraphicsMode.PixelInformation.RedMask =3D Fdt32T= oCpu (*Data32);=0D + GraphicsInfo->GraphicsMode.PixelInformation.GreenMask =3D Fdt32T= oCpu (*(Data32 + 1));=0D + GraphicsInfo->GraphicsMode.PixelInformation.BlueMask =3D Fdt32T= oCpu (*(Data32 + 2));=0D + } else if (AsciiStrCmp (TempStr, "pixe-scanline") =3D=3D 0) {=0D + Data32 =3D (UINT32 *)(Prop= ertyPtr->Data);=0D + GraphicsInfo->GraphicsMode.PixelsPerScanLine =3D Fdt32ToCpu (*Da= ta32);=0D + } else if (AsciiStrCmp (TempStr, "id") =3D=3D 0) {=0D + Data32 =3D (UINT32 *)(PropertyPtr->Data);=0D + GraphicsDev->VendorId =3D Fdt32ToCpu (*Data32) >> 16;=0D + GraphicsDev->DeviceId =3D Fdt32ToCpu (*Data32) & 0xffff;=0D + } else if (AsciiStrCmp (TempStr, "subsystem-id") =3D=3D 0) {=0D + Data32 =3D (UINT32 *)(PropertyPtr->Data)= ;=0D + GraphicsDev->SubsystemVendorId =3D Fdt32ToCpu (*Data32) >> 16;=0D + GraphicsDev->SubsystemId =3D Fdt32ToCpu (*Data32) & 0xffff= ;=0D + } else if (AsciiStrCmp (TempStr, "revision-id") =3D=3D 0) {=0D + Data32 =3D (UINT32 *)(PropertyPtr->Data);=0D + GraphicsDev->RevisionId =3D (UINT8)Fdt32ToCpu (*Data32);=0D + } else if (AsciiStrCmp (TempStr, "bar-index") =3D=3D 0) {=0D + Data32 =3D (UINT32 *)(PropertyPtr->Data);=0D + GraphicsDev->BarIndex =3D (UINT8)Fdt32ToCpu (*Data32);=0D + }=0D + }=0D + } else if (AsciiStrCmp (NodePtr->Name, "options") =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, " Found options node (%08X)", Node));=0D +=0D + for (SubNode =3D FdtFirstSubnode (Fdt, Node); SubNode >=3D 0; SubNod= e =3D FdtNextSubnode (Fdt, SubNode)) {=0D + NodePtr =3D (FDT_NODE_HEADER *)((CONST CHAR8 *)Fdt + SubNode + Fdt= 32ToCpu (((FDT_HEADER *)Fdt)->OffsetDtStruct));=0D + DEBUG ((DEBUG_INFO, "\n SubNode(%08X) %a", SubNode, NodePtr-= >Name));=0D +=0D + if (AsciiStrnCmp (NodePtr->Name, "upl-images@", AsciiStrLen ("upl-= images@")) =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, " Found image@ node \n"));=0D + //=0D + // Build PayloadBase HOB .=0D + //=0D + PayloadBase =3D BuildGuidHob (&gUniversalPayloadBaseGuid, sizeof= (UNIVERSAL_PAYLOAD_BASE));=0D + ASSERT (PayloadBase !=3D NULL);=0D + if (PayloadBase =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + PayloadBase->Header.Revision =3D UNIVERSAL_PAYLOAD_BASE_REVISION= ;=0D + PayloadBase->Header.Length =3D sizeof (UNIVERSAL_PAYLOAD_BASE)= ;=0D +=0D + PropertyPtr =3D FdtGetProperty (Fdt, SubNode, "addr", &TempLen);= =0D +=0D + ASSERT (TempLen > 0);=0D + if (TempLen > 0) {=0D + Data64 =3D (UINT64 *)(PropertyPtr->Data);=0D + StartAddress =3D Fdt64ToCpu (*Data64);=0D + DEBUG ((DEBUG_INFO, "\n Property(00000000) entry"));= =0D + DEBUG ((DEBUG_INFO, " %016lX\n", StartAddress));=0D +=0D + PayloadBase->Entry =3D (EFI_PHYSICAL_ADDRESS)StartAddress;=0D + }=0D + }=0D +=0D + if (AsciiStrnCmp (NodePtr->Name, "upl-params", AsciiStrLen ("upl-p= arams")) =3D=3D 0) {=0D + PropertyPtr =3D FdtGetProperty (Fdt, SubNode, "address_width", &= TempLen);=0D + if (TempLen > 0) {=0D + Data32 =3D (UINT32 *)(PropertyPtr->Data);=0D + DEBUG ((DEBUG_INFO, "\n Property(00000000) address_wi= dth"));=0D + DEBUG ((DEBUG_INFO, " %X", Fdt32ToCpu (*Data32)));=0D + SizeOfMemorySpace =3D (UINT8)Fdt32ToCpu (*Data32);=0D + #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)=0D + BuildCpuHob (SizeOfMemorySpace, 16);=0D + #else=0D + BuildCpuHob (SizeOfMemorySpace, 0);=0D + #endif=0D + }=0D + }=0D + }=0D + }=0D + // Optional=0D + else if (AsciiStrnCmp (NodePtr->Name, "pci-rb", AsciiStrLen ("pci-rb")= ) =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, " Found pci-rb node (%08X)", Node));=0D +=0D + HobDataSize =3D sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES) + RootBr= idgeCount *sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE);=0D + //=0D + // Create PCI Root Bridge Info Hob.=0D + //=0D + if (PciRootBridgeInfo =3D=3D NULL) {=0D + PciRootBridgeInfo =3D BuildGuidHob (&gUniversalPayloadPciRootBridg= eInfoGuid, HobDataSize);=0D + ASSERT (PciRootBridgeInfo !=3D NULL);=0D + if (PciRootBridgeInfo =3D=3D NULL) {=0D + break;=0D + }=0D +=0D + ZeroMem (PciRootBridgeInfo, HobDataSize);=0D + PciRootBridgeInfo->Header.Length =3D sizeof (UNIVERSAL_PAYLOAD_= PCI_ROOT_BRIDGES);=0D + PciRootBridgeInfo->Header.Revision =3D UNIVERSAL_PAYLOAD_PCI_ROOT= _BRIDGES_REVISION;=0D + PciRootBridgeInfo->Count =3D RootBridgeCount;=0D + PciRootBridgeInfo->ResourceAssigned =3D FALSE;=0D + }=0D +=0D + for (Property =3D FdtFirstPropertyOffset (Fdt, Node); Property >=3D = 0; Property =3D FdtNextPropertyOffset (Fdt, Property)) {=0D + PropertyPtr =3D FdtGetPropertyByOffset (Fdt, Property, &TempLen);= =0D + TempStr =3D FdtGetString (Fdt, Fdt32ToCpu (PropertyPtr->NameOf= fset), NULL);=0D +=0D + if (AsciiStrCmp (TempStr, "ranges") =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, " Found ranges Property TempLen (%08X)\n", = TempLen));=0D +=0D + PciRootBridgeInfo->RootBridge[index].AllocationAttributes =3D EF= I_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM | EFI_PCI_HOST_BRIDGE_MEM64_DECODE;=0D + PciRootBridgeInfo->RootBridge[index].Supports =3D RO= OT_BRIDGE_SUPPORTS_DEFAULT;=0D + PciRootBridgeInfo->RootBridge[index].PMemAbove4G.Base =3D Pc= dGet64 (PcdPciReservedPMemAbove4GBBase);=0D + PciRootBridgeInfo->RootBridge[index].PMemAbove4G.Limit =3D Pc= dGet64 (PcdPciReservedPMemAbove4GBLimit);=0D + PciRootBridgeInfo->RootBridge[index].PMem.Base =3D Pc= dGet32 (PcdPciReservedPMemBase);=0D + PciRootBridgeInfo->RootBridge[index].PMem.Limit =3D Pc= dGet32 (PcdPciReservedPMemLimit);=0D + PciRootBridgeInfo->RootBridge[index].UID =3D in= dex;=0D + PciRootBridgeInfo->RootBridge[index].HID =3D EI= SA_PNP_ID (0x0A03);=0D +=0D + Data32 =3D (UINT3= 2 *)(PropertyPtr->Data);=0D + PciRootBridgeInfo->RootBridge[index].Mem.Base =3D Fdt32T= oCpu (*(Data32 + 2));=0D + PciRootBridgeInfo->RootBridge[index].Mem.Limit =3D Fdt32T= oCpu (*(Data32 + 6)) + Fdt32ToCpu (*(Data32 + 2)) -1;=0D + PciRootBridgeInfo->RootBridge[index].MemAbove4G.Base =3D Fdt32T= oCpu (*(Data32 + 9)) + LShiftU64 (Fdt32ToCpu (*(Data32 + 8)), 32);=0D + PciRootBridgeInfo->RootBridge[index].MemAbove4G.Limit =3D PciRoo= tBridgeInfo->RootBridge[index].MemAbove4G.Base + LShiftU64 (Fdt32ToCpu (*(D= ata32 + 12)), 32) + Fdt32ToCpu (*(Data32 + 13)) -1;=0D + PciRootBridgeInfo->RootBridge[index].Io.Base =3D Fdt32T= oCpu (*(Data32 + 16));=0D + PciRootBridgeInfo->RootBridge[index].Io.Limit =3D PciRoo= tBridgeInfo->RootBridge[index].Io.Base + Fdt32ToCpu (*(Data32 + 20)) -1;=0D +=0D + DEBUG ((DEBUG_INFO, "RootBridgeCount %x, index :%x\n", RootBridg= eCount, index));=0D +=0D + DEBUG ((DEBUG_INFO, "PciRootBridge->Mem.Base %x, \n", PciRootBri= dgeInfo->RootBridge[index].Mem.Base));=0D + DEBUG ((DEBUG_INFO, "PciRootBridge->Mem.limit %x, \n", PciRootBr= idgeInfo->RootBridge[index].Mem.Limit));=0D +=0D + DEBUG ((DEBUG_INFO, "PciRootBridge->MemAbove4G.Base %llx, \n", P= ciRootBridgeInfo->RootBridge[index].MemAbove4G.Base));=0D + DEBUG ((DEBUG_INFO, "PciRootBridge->MemAbove4G.limit %llx, \n", = PciRootBridgeInfo->RootBridge[index].MemAbove4G.Limit));=0D +=0D + DEBUG ((DEBUG_INFO, "PciRootBridge->Io.Base %llx, \n", PciRootBr= idgeInfo->RootBridge[index].Io.Base));=0D + DEBUG ((DEBUG_INFO, "PciRootBridge->Io.limit %llx, \n", PciRootB= ridgeInfo->RootBridge[index].Io.Limit));=0D + if (index > 0) {=0D + index--;=0D + }=0D + }=0D +=0D + if (AsciiStrCmp (TempStr, "bus-range") =3D=3D 0) {=0D + UINT16 *Data16;=0D +=0D + DEBUG ((DEBUG_INFO, " Found bus-range Property TempLen (%08X)\n= ", TempLen));=0D +=0D + if (RootBridgeCount =3D=3D 1) {=0D + index =3D 0;=0D + }=0D +=0D + Data16 =3D (UINT16= *)(PropertyPtr->Data);=0D + PciRootBridgeInfo->RootBridge[index].Bus.Base =3D Fdt16To= Cpu (*Data16) & 0xFF;=0D + PciRootBridgeInfo->RootBridge[index].Bus.Limit =3D Fdt16To= Cpu (*(Data16 + 1)) & 0xFF;=0D + PciRootBridgeInfo->RootBridge[index].Bus.Translation =3D 0;=0D +=0D + DEBUG ((DEBUG_INFO, "PciRootBridge->Bus.Base %x, \n", PciRootBri= dgeInfo->RootBridge[index].Bus.Base));=0D + DEBUG ((DEBUG_INFO, "PciRootBridge->Bus.limit %x, \n", PciRootBr= idgeInfo->RootBridge[index].Bus.Limit));=0D + }=0D + }=0D + } else if (AsciiStrCmp (NodePtr->Name, "DebugPrintErrorLevel") =3D=3D = 0) {=0D + //=0D + // Create DebugPrintErrorLevel Hob.=0D + //=0D + DebugPrintErrorLevelInfo =3D BuildGuidHob (&gEdkiiDebugPrintErrorLev= elGuid, sizeof (UEFI_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL));=0D + ASSERT (DebugPrintErrorLevelInfo !=3D NULL);=0D + if (DebugPrintErrorLevelInfo =3D=3D NULL) {=0D + break;=0D + }=0D +=0D + DebugPrintErrorLevelInfo->Header.Revision =3D UEFI_PAYLOAD_DEBUG_PRI= NT_ERROR_LEVEL_REVISION;=0D + DebugPrintErrorLevelInfo->Header.Length =3D sizeof (UEFI_PAYLOAD_D= EBUG_PRINT_ERROR_LEVEL);=0D +=0D + PropertyPtr =3D FdtGetProperty (Fdt, Node, "errorlevel", &TempLen);= =0D + ASSERT (TempLen > 0);=0D + if (TempLen > 0) {=0D + Data32 =3D (UINT32 *)(PropertyPtr->Data);=0D + DEBUG ((DEBUG_INFO, "\n Property(00000000) errorlevel"));= =0D + DEBUG ((DEBUG_INFO, " %X", Fdt32ToCpu (*Data32)));=0D + DebugPrintErrorLevelInfo->ErrorLevel =3D Fdt32ToCpu (*Data32);=0D + }=0D + }=0D + }=0D +=0D + DEBUG ((DEBUG_INFO, "\n"));=0D +=0D + return NewHobList;=0D +}=0D +=0D +/**=0D + It will Parse FDT -node based on information from bootloaders.=0D + @param[in] FdtBase The starting memory address of FdtBase=0D + @retval HobList The base address of Hoblist.=0D +=0D +**/=0D +UINTN=0D +EFIAPI=0D +FdtNodeParser (=0D + IN VOID *FdtBase=0D + )=0D +{=0D + return ParseDtb (FdtBase);=0D +}=0D +=0D +/**=0D + It will build a graphic device hob.=0D +=0D + @retval EFI_SUCCESS If it completed successfully.=0D + @retval Others If it failed to parse DTB.=0D +**/=0D +EFI_STATUS=0D +BuildGraphicDevHob (=0D + VOID=0D + );=0D +=0D +/**=0D + It will initialize HOBs for UPL.=0D +=0D + @param[in] FdtBase Address of the Fdt data.=0D +=0D + @retval EFI_SUCCESS If it completed successfully.=0D + @retval Others If it failed to initialize HOBs.=0D +**/=0D +UINTN=0D +EFIAPI=0D +UplInitHob (=0D + IN VOID *FdtBase=0D + )=0D +{=0D + UINTN NHobAddress;=0D +=0D + NHobAddress =3D 0;=0D + //=0D + // Check parameter type(=0D + //=0D + if (FdtCheckHeader (FdtBase) =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, "%a() FDT blob\n", __func__));=0D + NHobAddress =3D FdtNodeParser ((VOID *)FdtBase);=0D + } else {=0D + DEBUG ((DEBUG_INFO, "%a() HOb list\n", __func__));=0D + mHobList =3D FdtBase;=0D +=0D + return (UINTN)(mHobList);=0D + }=0D +=0D + return NHobAddress;=0D +}=0D diff --git a/UefiPayloadPkg/Library/HobParseLib/HobParseLib.c b/UefiPayload= Pkg/Library/HobParseLib/HobParseLib.c new file mode 100644 index 000000000000..72da4fcaf74f --- /dev/null +++ b/UefiPayloadPkg/Library/HobParseLib/HobParseLib.c @@ -0,0 +1,408 @@ +/** @file=0D + Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT = | \=0D + EFI_RESOURCE_ATTRIBUTE_INITIALIZED = | \=0D + EFI_RESOURCE_ATTRIBUTE_TESTED = | \=0D + EFI_RESOURCE_ATTRIBUTE_READ_PROTECT= ED | \=0D + EFI_RESOURCE_ATTRIBUTE_WRITE_PROTEC= TED | \=0D + EFI_RESOURCE_ATTRIBUTE_EXECUTION_PR= OTECTED | \=0D + EFI_RESOURCE_ATTRIBUTE_READ_ONLY_PR= OTECTED | \=0D + EFI_RESOURCE_ATTRIBUTE_16_BIT_IO = | \=0D + EFI_RESOURCE_ATTRIBUTE_32_BIT_IO = | \=0D + EFI_RESOURCE_ATTRIBUTE_64_BIT_IO = | \=0D + EFI_RESOURCE_ATTRIBUTE_PERSISTENT = )=0D +=0D +#define TESTED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | = \=0D + EFI_RESOURCE_ATTRIBUTE_INITIALIZED = | \=0D + EFI_RESOURCE_ATTRIBUTE_TESTED = )=0D +=0D +extern VOID *mHobList;=0D +=0D +/**=0D + Add a new HOB to the HOB List.=0D +=0D + @param HobType Type of the new HOB.=0D + @param HobLength Length of the new HOB to allocate.=0D +=0D + @return NULL if there is no space to create a hob.=0D + @return The address point to the new created hob.=0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +CreateHob (=0D + IN UINT16 HobType,=0D + IN UINT16 HobLength=0D + );=0D +=0D +/**=0D + Build a Handoff Information Table HOB=0D +=0D + This function initialize a HOB region from EfiMemoryBegin to=0D + EfiMemoryTop. And EfiFreeMemoryBottom and EfiFreeMemoryTop should=0D + be inside the HOB region.=0D +=0D + @param[in] EfiMemoryBottom Total memory start address=0D + @param[in] EfiMemoryTop Total memory end address.=0D + @param[in] EfiFreeMemoryBottom Free memory start address=0D + @param[in] EfiFreeMemoryTop Free memory end address.=0D +=0D + @return The pointer to the handoff HOB table.=0D +=0D +**/=0D +EFI_HOB_HANDOFF_INFO_TABLE *=0D +EFIAPI=0D +HobConstructor (=0D + IN VOID *EfiMemoryBottom,=0D + IN VOID *EfiMemoryTop,=0D + IN VOID *EfiFreeMemoryBottom,=0D + IN VOID *EfiFreeMemoryTop=0D + );=0D +=0D +/**=0D + Build ACPI board info HOB using infomation from ACPI table=0D +=0D + @param AcpiTableBase ACPI table start address in memory=0D +=0D + @retval A pointer to ACPI board HOB ACPI_BOARD_INFO. Null if build HOB = failure.=0D +**/=0D +ACPI_BOARD_INFO *=0D +BuildHobFromAcpi (=0D + IN UINT64 AcpiTableBase=0D + );=0D +=0D +/**=0D + *=0D + Add HOB into HOB list=0D +=0D + @param[in] Hob The HOB to be added into the HOB list.=0D +**/=0D +VOID=0D +AddNewHob (=0D + IN EFI_PEI_HOB_POINTERS *Hob=0D + )=0D +{=0D + EFI_PEI_HOB_POINTERS NewHob;=0D +=0D + if (Hob->Raw =3D=3D NULL) {=0D + return;=0D + }=0D +=0D + NewHob.Header =3D CreateHob (Hob->Header->HobType, Hob->Header->HobLengt= h);=0D +=0D + if (NewHob.Header !=3D NULL) {=0D + CopyMem (NewHob.Header + 1, Hob->Header + 1, Hob->Header->HobLength - = sizeof (EFI_HOB_GENERIC_HEADER));=0D + }=0D +}=0D +=0D +/**=0D + Found the Resource Descriptor HOB that contains a range (Base, Top)=0D +=0D + @param[in] HobList Hob start address=0D + @param[in] Base Memory start address=0D + @param[in] Top Memory end address.=0D +=0D + @retval The pointer to the Resource Descriptor HOB.=0D +**/=0D +EFI_HOB_RESOURCE_DESCRIPTOR *=0D +FindResourceDescriptorByRange (=0D + IN VOID *HobList,=0D + IN EFI_PHYSICAL_ADDRESS Base,=0D + IN EFI_PHYSICAL_ADDRESS Top=0D + )=0D +{=0D + EFI_PEI_HOB_POINTERS Hob;=0D + EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;=0D +=0D + for (Hob.Raw =3D (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw =3D G= ET_NEXT_HOB (Hob)) {=0D + //=0D + // Skip all HOBs except Resource Descriptor HOBs=0D + //=0D + if (GET_HOB_TYPE (Hob) !=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {=0D + continue;=0D + }=0D +=0D + //=0D + // Skip Resource Descriptor HOBs that do not describe tested system me= mory=0D + //=0D + ResourceHob =3D Hob.ResourceDescriptor;=0D + if (ResourceHob->ResourceType !=3D EFI_RESOURCE_SYSTEM_MEMORY) {=0D + continue;=0D + }=0D +=0D + if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) !=3D TEST= ED_MEMORY_ATTRIBUTES) {=0D + continue;=0D + }=0D +=0D + //=0D + // Skip Resource Descriptor HOBs that do not contain the PHIT range Ef= iFreeMemoryBottom..EfiFreeMemoryTop=0D + //=0D + if (Base < ResourceHob->PhysicalStart) {=0D + continue;=0D + }=0D +=0D + if (Top > (ResourceHob->PhysicalStart + ResourceHob->ResourceLength)) = {=0D + continue;=0D + }=0D +=0D + return ResourceHob;=0D + }=0D +=0D + return NULL;=0D +}=0D +=0D +/**=0D + Find the highest below 4G memory resource descriptor, except the input R= esource Descriptor.=0D +=0D + @param[in] HobList Hob start address=0D + @param[in] MinimalNeededSize Minimal needed size.=0D + @param[in] ExceptResourceHob Ignore this Resource Descriptor.=0D +=0D + @retval The pointer to the Resource Descriptor HOB.=0D +**/=0D +EFI_HOB_RESOURCE_DESCRIPTOR *=0D +FindAnotherHighestBelow4GResourceDescriptor (=0D + IN VOID *HobList,=0D + IN UINTN MinimalNeededSize,=0D + IN EFI_HOB_RESOURCE_DESCRIPTOR *ExceptResourceHob=0D + )=0D +{=0D + EFI_PEI_HOB_POINTERS Hob;=0D + EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;=0D + EFI_HOB_RESOURCE_DESCRIPTOR *ReturnResourceHob;=0D +=0D + ReturnResourceHob =3D NULL;=0D +=0D + for (Hob.Raw =3D (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw =3D G= ET_NEXT_HOB (Hob)) {=0D + //=0D + // Skip all HOBs except Resource Descriptor HOBs=0D + //=0D + if (GET_HOB_TYPE (Hob) !=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {=0D + continue;=0D + }=0D +=0D + //=0D + // Skip Resource Descriptor HOBs that do not describe tested system me= mory=0D + //=0D + ResourceHob =3D Hob.ResourceDescriptor;=0D + if (ResourceHob->ResourceType !=3D EFI_RESOURCE_SYSTEM_MEMORY) {=0D + continue;=0D + }=0D +=0D + if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) !=3D TEST= ED_MEMORY_ATTRIBUTES) {=0D + continue;=0D + }=0D +=0D + //=0D + // Skip if the Resource Descriptor HOB equals to ExceptResourceHob=0D + //=0D + if (ResourceHob =3D=3D ExceptResourceHob) {=0D + continue;=0D + }=0D +=0D + //=0D + // Skip Resource Descriptor HOBs that are beyond 4G=0D + //=0D + if ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength) > BASE_= 4GB) {=0D + continue;=0D + }=0D +=0D + //=0D + // Skip Resource Descriptor HOBs that are too small=0D + //=0D + if (ResourceHob->ResourceLength < MinimalNeededSize) {=0D + continue;=0D + }=0D +=0D + //=0D + // Return the topest Resource Descriptor=0D + //=0D + if (ReturnResourceHob =3D=3D NULL) {=0D + ReturnResourceHob =3D ResourceHob;=0D + } else {=0D + if (ReturnResourceHob->PhysicalStart < ResourceHob->PhysicalStart) {= =0D + ReturnResourceHob =3D ResourceHob;=0D + }=0D + }=0D + }=0D +=0D + return ReturnResourceHob;=0D +}=0D +=0D +/**=0D + Check the HOB and decide if it is need inside Payload=0D +=0D + Payload maintainer may make decision which HOB is need or needn't=0D + Then add the check logic in the function.=0D +=0D + @param[in] Hob The HOB to check=0D +=0D + @retval TRUE If HOB is need inside Payload=0D + @retval FALSE If HOB is needn't inside Payload=0D +**/=0D +BOOLEAN=0D +IsHobNeed (=0D + EFI_PEI_HOB_POINTERS Hob=0D + )=0D +{=0D + if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_HANDOFF) {=0D + return FALSE;=0D + }=0D +=0D + if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_MEMORY_ALLOCATION) {=0D + if (CompareGuid (&Hob.MemoryAllocationModule->MemoryAllocationHeader.N= ame, &gEfiHobMemoryAllocModuleGuid)) {=0D + return FALSE;=0D + }=0D + }=0D +=0D + // Arrive here mean the HOB is need=0D + return TRUE;=0D +}=0D +=0D +/**=0D + It will build HOBs based on information from bootloaders.=0D +=0D + @param[in] BootloaderParameter The starting memory address of bootloa= der parameter block.=0D +=0D + @retval EFI_SUCCESS If it completed successfully.=0D + @retval Others If it failed to build required HOBs.=0D +**/=0D +EFI_STATUS=0D +BuildHobs (=0D + IN UINTN BootloaderParameter=0D + )=0D +{=0D + EFI_PEI_HOB_POINTERS Hob;=0D + UINTN MinimalNeededSize;=0D + EFI_PHYSICAL_ADDRESS FreeMemoryBottom;=0D + EFI_PHYSICAL_ADDRESS FreeMemoryTop;=0D + EFI_PHYSICAL_ADDRESS MemoryBottom;=0D + EFI_PHYSICAL_ADDRESS MemoryTop;=0D + EFI_HOB_RESOURCE_DESCRIPTOR *PhitResourceHob;=0D + EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;=0D +=0D + #if (!FixedPcdGetBool (PcdHandOffFdtEnable))=0D + UINT8 *GuidHob;=0D + UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTable;=0D + ACPI_BOARD_INFO *AcpiBoardInfo;=0D + #endif=0D + EFI_HOB_HANDOFF_INFO_TABLE *HobInfo;=0D +=0D + Hob.Raw =3D (UINT8 *)BootloaderParameter;=0D + MinimalNeededSize =3D FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);=0D +=0D + ASSERT (Hob.Raw !=3D NULL);=0D + ASSERT ((UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop =3D=3D Hob.= HandoffInformationTable->EfiFreeMemoryTop);=0D + ASSERT ((UINTN)Hob.HandoffInformationTable->EfiMemoryTop =3D=3D Hob.Hand= offInformationTable->EfiMemoryTop);=0D + ASSERT ((UINTN)Hob.HandoffInformationTable->EfiFreeMemoryBottom =3D=3D H= ob.HandoffInformationTable->EfiFreeMemoryBottom);=0D + ASSERT ((UINTN)Hob.HandoffInformationTable->EfiMemoryBottom =3D=3D Hob.H= andoffInformationTable->EfiMemoryBottom);=0D +=0D + //=0D + // Try to find Resource Descriptor HOB that contains Hob range EfiMemory= Bottom..EfiMemoryTop=0D + //=0D + PhitResourceHob =3D FindResourceDescriptorByRange (Hob.Raw, Hob.HandoffI= nformationTable->EfiMemoryBottom, Hob.HandoffInformationTable->EfiMemoryTop= );=0D + if (PhitResourceHob =3D=3D NULL) {=0D + //=0D + // Boot loader's Phit Hob is not in an available Resource Descriptor, = find another Resource Descriptor for new Phit Hob=0D + //=0D + ResourceHob =3D FindAnotherHighestBelow4GResourceDescriptor (Hob.Raw, = MinimalNeededSize, NULL);=0D + if (ResourceHob =3D=3D NULL) {=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + MemoryBottom =3D ResourceHob->PhysicalStart + ResourceHob->Resourc= eLength - MinimalNeededSize;=0D + FreeMemoryBottom =3D MemoryBottom;=0D + FreeMemoryTop =3D ResourceHob->PhysicalStart + ResourceHob->Resourc= eLength;=0D + MemoryTop =3D FreeMemoryTop;=0D + } else if (PhitResourceHob->PhysicalStart + PhitResourceHob->ResourceLen= gth - Hob.HandoffInformationTable->EfiMemoryTop >=3D MinimalNeededSize) {=0D + //=0D + // New availiable Memory range in new hob is right above memory top in= old hob.=0D + //=0D + MemoryBottom =3D Hob.HandoffInformationTable->EfiFreeMemoryTop;=0D + FreeMemoryBottom =3D Hob.HandoffInformationTable->EfiMemoryTop;=0D + FreeMemoryTop =3D FreeMemoryBottom + MinimalNeededSize;=0D + MemoryTop =3D FreeMemoryTop;=0D + } else if (Hob.HandoffInformationTable->EfiMemoryBottom - PhitResourceHo= b->PhysicalStart >=3D MinimalNeededSize) {=0D + //=0D + // New availiable Memory range in new hob is right below memory bottom= in old hob.=0D + //=0D + MemoryBottom =3D Hob.HandoffInformationTable->EfiMemoryBottom - Mi= nimalNeededSize;=0D + FreeMemoryBottom =3D MemoryBottom;=0D + FreeMemoryTop =3D Hob.HandoffInformationTable->EfiMemoryBottom;=0D + MemoryTop =3D Hob.HandoffInformationTable->EfiMemoryTop;=0D + } else {=0D + //=0D + // In the Resource Descriptor HOB contains boot loader Hob, there is n= o enough free memory size for payload hob=0D + // Find another Resource Descriptor Hob=0D + //=0D + ResourceHob =3D FindAnotherHighestBelow4GResourceDescriptor (Hob.Raw, = MinimalNeededSize, PhitResourceHob);=0D + if (ResourceHob =3D=3D NULL) {=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + MemoryBottom =3D ResourceHob->PhysicalStart + ResourceHob->Resourc= eLength - MinimalNeededSize;=0D + FreeMemoryBottom =3D MemoryBottom;=0D + FreeMemoryTop =3D ResourceHob->PhysicalStart + ResourceHob->Resourc= eLength;=0D + MemoryTop =3D FreeMemoryTop;=0D + }=0D +=0D + HobInfo =3D HobConstructor ((VOID *)(UINTN)MemoryBottom, (VOID= *)(UINTN)MemoryTop, (VOID *)(UINTN)FreeMemoryBottom, (VOID *)(UINTN)FreeMe= moryTop);=0D + HobInfo->BootMode =3D Hob.HandoffInformationTable->BootMode;=0D + //=0D + // From now on, mHobList will point to the new Hob range.=0D + //=0D +=0D + //=0D + // Create an empty FvHob for the DXE FV that contains DXE core.=0D + //=0D + BuildFvHob ((EFI_PHYSICAL_ADDRESS)0, 0);=0D + //=0D + // Since payload created new Hob, move all hobs except PHIT from boot lo= ader hob list.=0D + //=0D + Hob.Raw =3D (UINT8 *)BootloaderParameter;=0D + while (!END_OF_HOB_LIST (Hob)) {=0D + if (IsHobNeed (Hob)) {=0D + // Add this hob to payload HOB=0D + AddNewHob (&Hob);=0D + }=0D +=0D + Hob.Raw =3D GET_NEXT_HOB (Hob);=0D + }=0D +=0D + #if (!FixedPcdGetBool (PcdHandOffFdtEnable))=0D + //=0D + // Create guid hob for acpi board information=0D + //=0D + DEBUG ((DEBUG_INFO, "Create guid hob for acpi board information \n"));=0D +=0D + GuidHob =3D GetFirstGuidHob (&gUniversalPayloadAcpiTableGuid);=0D + if (GuidHob !=3D NULL) {=0D + AcpiTable =3D (UNIVERSAL_PAYLOAD_ACPI_TABLE *)GET_GUID_HOB_DATA (G= uidHob);=0D + AcpiBoardInfo =3D BuildHobFromAcpi ((UINT64)AcpiTable->Rsdp);=0D + ASSERT (AcpiBoardInfo !=3D NULL);=0D + }=0D +=0D + #endif=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/UefiPayloadPkg/Library/CustomFdtNodeParserLib/CustomFdtNodePar= serLib.inf b/UefiPayloadPkg/Library/CustomFdtNodeParserLib/CustomFdtNodePar= serLib.inf new file mode 100644 index 000000000000..036ed4315dd0 --- /dev/null +++ b/UefiPayloadPkg/Library/CustomFdtNodeParserLib/CustomFdtNodeParserLib.= inf @@ -0,0 +1,46 @@ +## @file=0D +# Custom FDT Node Parse Library.=0D +#=0D +# Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D CustomFdtNodeParserLib=0D + FILE_GUID =3D 732B2B8F-65AD-4BF8-A98F-6E0D330F7A60= =0D + MODULE_TYPE =3D BASE=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D CustomFdtNodeParserLib=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64=0D +#=0D +=0D +[Sources]=0D + CustomFdtNodeParserLib.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + UefiPayloadPkg/UefiPayloadPkg.dec=0D +=0D +[LibraryClasses]=0D + BaseMemoryLib=0D + DebugLib=0D + FdtLib=0D + HobLib=0D + PcdLib=0D +=0D +[Guids]=0D + gUniversalPayloadPciRootBridgeInfoGuid=0D + gUniversalPayloadSerialPortInfoGuid=0D + gUniversalPayloadDeviceTreeGuid=0D + gUniversalPayloadAcpiTableGuid=0D + gEfiHobMemoryAllocModuleGuid=0D +=0D +[Pcd]=0D + gUefiPayloadPkgTokenSpaceGuid.PcdHandOffFdtEnable=0D diff --git a/UefiPayloadPkg/Library/CustomFdtNodeParserNullLib/CustomFdtNod= eParserNullLib.inf b/UefiPayloadPkg/Library/CustomFdtNodeParserNullLib/Cust= omFdtNodeParserNullLib.inf new file mode 100644 index 000000000000..62916dd00848 --- /dev/null +++ b/UefiPayloadPkg/Library/CustomFdtNodeParserNullLib/CustomFdtNodeParser= NullLib.inf @@ -0,0 +1,33 @@ +## @file=0D +# Custom FDT Node Parse Library.=0D +#=0D +# Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D CustomFdtNodeParserLibNull=0D + FILE_GUID =3D 386496E4-37DB-4531-BA0C-16D126E63C55= =0D + MODULE_TYPE =3D BASE=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D CustomFdtNodeParserLib=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64=0D +#=0D +=0D +[Sources]=0D + CustomFdtNodeParserNullLib.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + UefiPayloadPkg/UefiPayloadPkg.dec=0D +=0D +[LibraryClasses]=0D + DebugLib=0D + FdtLib=0D diff --git a/UefiPayloadPkg/Library/FdtParserLib/FdtParseLib.inf b/UefiPayl= oadPkg/Library/FdtParserLib/FdtParseLib.inf new file mode 100644 index 000000000000..91be56758db5 --- /dev/null +++ b/UefiPayloadPkg/Library/FdtParserLib/FdtParseLib.inf @@ -0,0 +1,63 @@ +## @file=0D +# Coreboot Table Parse Library.=0D +#=0D +# Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D FdtParseLib=0D + FILE_GUID =3D 8956F72D-9626-4959-98B7-1BD4A3EA687E= =0D + MODULE_TYPE =3D BASE=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D FdtParseLib=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64=0D +#=0D +=0D +[Sources]=0D + FdtParserLib.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + UefiPayloadPkg/UefiPayloadPkg.dec=0D +=0D +[LibraryClasses]=0D + DebugLib=0D + PcdLib=0D + HobLib=0D + FdtLib=0D + CustomFdtNodeParserLib=0D +=0D +[Guids]=0D + gUniversalPayloadDeviceTreeGuid=0D + gEfiGraphicsInfoHobGuid=0D + gEfiGraphicsDeviceInfoHobGuid=0D + gUniversalPayloadAcpiTableGuid=0D + gUniversalPayloadSerialPortInfoGuid=0D +=0D +[Pcd.IA32,Pcd.X64]=0D + gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize=0D + gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize=0D + gUefiPayloadPkgTokenSpaceGuid.PcdHandOffFdtEnable=0D + gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemBase=0D + gUefiPayloadPkgTokenSpaceGuid.PcdPciReservedPMemBase=0D + gUefiPayloadPkgTokenSpaceGuid.PcdPciReservedPMemLimit=0D + gUefiPayloadPkgTokenSpaceGuid.PcdPciReservedPMemAbove4GBBase=0D + gUefiPayloadPkgTokenSpaceGuid.PcdPciReservedPMemAbove4GBLimit=0D +=0D +=0D +[BuildOptions]=0D + MSFT:*_*_*_CC_FLAGS =3D /wd4305=0D + GCC:*_*_IA32_CC_FLAGS =3D -Wno-error=3Dpointer-to-int-cast -Wno-error= =3Dint-to-pointer-cast=0D + GCC:*_*_X64_CC_FLAGS =3D -Wno-error=3Dpointer-to-int-cast -Wno-error= =3Dint-to-pointer-cast=0D + GCC:*_*_ARM_CC_FLAGS =3D -Wno-error=3Dpointer-to-int-cast -Wno-error= =3Dint-to-pointer-cast=0D + GCC:*_*_AARCH64_CC_FLAGS =3D -Wno-error=3Dpointer-to-int-cast -Wno-error= =3Dint-to-pointer-cast=0D + GCC:*_*_RISCV64_CC_FLAGS =3D -Wno-error=3Dpointer-to-int-cast -Wno-error= =3Dint-to-pointer-cast=0D + GCC:*_*_LOONGARCH64_CC_FLAGS =3D -Wno-error=3Dpointer-to-int-cast -Wno-e= rror=3Dint-to-pointer-cast=0D diff --git a/UefiPayloadPkg/Library/HobParseLib/HobParseLib.inf b/UefiPaylo= adPkg/Library/HobParseLib/HobParseLib.inf new file mode 100644 index 000000000000..634c7ff56746 --- /dev/null +++ b/UefiPayloadPkg/Library/HobParseLib/HobParseLib.inf @@ -0,0 +1,40 @@ +## @file=0D +# UPL Hob Parse Library.=0D +#=0D +# Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D HobParseLib=0D + FILE_GUID =3D EFB05FE7-604B-40DA-9A59-E2F998528754= =0D + MODULE_TYPE =3D DXE_DRIVER=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D HobParseLib|DXE_DRIVER DXE_RUNTIME_DR= IVER SMM_CORE DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64=0D +#=0D +=0D +[Sources]=0D + HobParseLib.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + UefiPayloadPkg/UefiPayloadPkg.dec=0D +=0D +[LibraryClasses]=0D + BaseLib=0D + BaseMemoryLib=0D + IoLib=0D + DebugLib=0D + PcdLib=0D + HobLib=0D +=0D +[Pcd.IA32,Pcd.X64]=0D + gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize=0D + gUefiPayloadPkgTokenSpaceGuid.PcdHandOffFdtEnable=0D --=20 2.39.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119420): https://edk2.groups.io/g/devel/message/119420 Mute This Topic: https://groups.io/mt/106455165/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-