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 0C7D9D80A38 for ; Tue, 4 Jun 2024 17:18:31 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=YpXock3AvevStzf3Ixvi2yLgH6Gqxkdqn6e/gOdg99w=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240206; t=1717521511; v=1; b=odVuDfA8PXLEQFLMC7HGSMpR479p5bDXFNyWj7vex7hUL67NeX5zIF6jXGTKjFrhrfPdrOo4 KKRk/BaY8AAdXhJJP40L6gwp95Ig/ToTU3GEY4vFWhOUIENh4i4WNJ8YwCqtHspDCReOWSbZXOr titL1xGTII3GeLfCjENkcQbrKgsy+HF8oM4cY/LlrHX8UeBHz98Mc3zkrmDdgDrELevqVpzWRTM pm1ZRZdiCL9s4o9j3BVnD6WZuK/3igVtiJrByRGk9TZSGW2QvxEsWZ3oFN5lTTIo+sY1kKDF+9q craDXLl00jeszuTUSSszgeeXnVlGGtbyyzy4LDxYuN6ug== X-Received: by 127.0.0.2 with SMTP id RWNLYY7687511xmhnj0JGYzu; Tue, 04 Jun 2024 10:18:30 -0700 X-Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) by mx.groups.io with SMTP id smtpd.web10.1923.1717521508794094489 for ; Tue, 04 Jun 2024 10:18:29 -0700 X-Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-57a50ac2ca1so4004526a12.0 for ; Tue, 04 Jun 2024 10:18:28 -0700 (PDT) X-Gm-Message-State: Z2waddY3y0NT0KxFaYHmiVqlx7686176AA= X-Google-Smtp-Source: AGHT+IEVppL/2MC/hWTtQLieIndmC2Dl5Ahs/P8QH1Dz0S8mL/Yl8Ro49+N3zFXcjUqR3YVLkxUlIY3pn3jPX+coniA= X-Received: by 2002:a50:d009:0:b0:57a:2e8d:c308 with SMTP id 4fb4d7f45d1cf-57a8bccb48dmr124284a12.40.1717521506877; Tue, 04 Jun 2024 10:18:26 -0700 (PDT) MIME-Version: 1.0 References: <20240603021923.1356-1-linus.liu@intel.com> In-Reply-To: From: "Dhaval Sharma" Date: Tue, 4 Jun 2024 22:48:15 +0530 Message-ID: Subject: Re: [edk2-devel] [PATCH v4 6/6] UefiPayloadPkg: Update UefiPayload driver for FDT support. To: Linus Liu Cc: devel@edk2.groups.io, Benny Lin , Gua Guo , Chasel Chiu , James Lu 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: Tue, 04 Jun 2024 10:18:29 -0700 Resent-From: dhaval@rivosinc.com Reply-To: devel@edk2.groups.io,dhaval@rivosinc.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: multipart/alternative; boundary="0000000000004fe06a061a13a364" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=odVuDfA8; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none --0000000000004fe06a061a13a364 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I also believe this code needs to go through crustify etc to ensure it follows all edk2 standards? On Mon, Jun 3, 2024 at 4:57=E2=80=AFPM Dhaval Sharma = wrote: > BuildFitLoadablesFvHob: > > - Fdt variable is not initialized. > - It ONLY gets initialized if GuidHob is found. What if it is not > found? > - FdtCheckHeader still evaluating it? > > > On Mon, Jun 3, 2024 at 7:49=E2=80=AFAM Linus Liu wr= ote: > >> Add FDT detection and comsume FDT when needed. >> Move some x86 specific function in the x86 folder. >> Create HandOffHob via FDT memory node. >> >> Cc: Benny Lin >> Cc: Gua Guo >> Cc: Chasel Chiu >> Cc: James Lu >> Cc: Dhaval Sharma >> >> Signed-off-by: Linus Liu >> --- >> UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c >> | 428 +++++++++----------- >> UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c >> | 12 + >> UefiPayloadPkg/UefiPayloadEntry/Ia32/{DxeLoadFunc.c =3D> DxeLoadFuncFit= .c} >> | 32 +- >> UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c >> | 50 +++ >> UefiPayloadPkg/UefiPayloadEntry/PrintHob.c >> | 6 +- >> UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c >> | 6 - >> UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c >> | 12 + >> UefiPayloadPkg/UefiPayloadEntry/X64/{DxeLoadFunc.c =3D> DxeLoadFuncFit.= c} >> | 31 +- >> UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf >> | 20 +- >> UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h >> | 68 ++++ >> UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf >> | 16 +- >> UefiPayloadPkg/UefiPayloadPkg.dsc >> | 29 +- >> 12 files changed, 443 insertions(+), 267 deletions(-) >> >> diff --git a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c >> b/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c >> index eb0b325369a0..813d656950d1 100644 >> --- a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c >> +++ b/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c >> @@ -6,6 +6,8 @@ >> #include "UefiPayloadEntry.h" >> #include >> #include >> +#include >> +#include >> >> #define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT >> | \ >> >> EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \ >> @@ -23,6 +25,15 @@ >> >> EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \ >> EFI_RESOURCE_ATTRIBUTE_TESTED >> ) >> >> +EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] =3D { >> + { EfiACPIReclaimMemory, FixedPcdGet32 >> (PcdMemoryTypeEfiACPIReclaimMemory) }, >> + { EfiACPIMemoryNVS, FixedPcdGet32 >> (PcdMemoryTypeEfiACPIMemoryNVS) }, >> + { EfiReservedMemoryType, FixedPcdGet32 >> (PcdMemoryTypeEfiReservedMemoryType) }, >> + { EfiRuntimeServicesData, FixedPcdGet32 >> (PcdMemoryTypeEfiRuntimeServicesData) }, >> + { EfiRuntimeServicesCode, FixedPcdGet32 >> (PcdMemoryTypeEfiRuntimeServicesCode) }, >> + { EfiMaxMemoryType, 0 >> } >> +}; >> + >> extern VOID *mHobList; >> >> CHAR8 *mLineBuffer =3D NULL; >> @@ -36,6 +47,78 @@ PrintHob ( >> IN CONST VOID *HobStart >> ); >> >> +/** >> + Add HOB into HOB list >> + @param[in] Hob The HOB to be added into the HOB list. >> +**/ >> +VOID >> +AddNewHob ( >> + IN EFI_PEI_HOB_POINTERS *Hob >> + ); >> + >> +/** >> + Found the Resource Descriptor HOB that contains a range (Base, Top) >> + @param[in] HobList Hob start address >> + @param[in] Base Memory start address >> + @param[in] Top Memory end address. >> + @retval The pointer to the Resource Descriptor HOB. >> +**/ >> +EFI_HOB_RESOURCE_DESCRIPTOR * >> +FindResourceDescriptorByRange ( >> + IN VOID *HobList, >> + IN EFI_PHYSICAL_ADDRESS Base, >> + IN EFI_PHYSICAL_ADDRESS Top >> + ); >> + >> +/** >> + Find the highest below 4G memory resource descriptor, except the inpu= t >> Resource Descriptor. >> + @param[in] HobList Hob start address >> + @param[in] MinimalNeededSize Minimal needed size. >> + @param[in] ExceptResourceHob Ignore this Resource Descriptor. >> + @retval The pointer to the Resource Descriptor HOB. >> +**/ >> +EFI_HOB_RESOURCE_DESCRIPTOR * >> +FindAnotherHighestBelow4GResourceDescriptor ( >> + IN VOID *HobList, >> + IN UINTN MinimalNeededSize, >> + IN EFI_HOB_RESOURCE_DESCRIPTOR *ExceptResourceHob >> + ); >> + >> +/** >> + Check the HOB and decide if it is need inside Payload >> + Payload maintainer may make decision which HOB is need or needn't >> + Then add the check logic in the function. >> + @param[in] Hob The HOB to check >> + @retval TRUE If HOB is need inside Payload >> + @retval FALSE If HOB is needn't inside Payload >> +**/ >> +BOOLEAN >> +FitIsHobNeed ( >> + EFI_PEI_HOB_POINTERS Hob >> + ); >> + >> +/** >> + Check the HOB and decide if it is need inside Payload >> + >> + Payload maintainer may make decision which HOB is need or needn't >> + Then add the check logic in the function. >> + >> + @param[in] Hob The HOB to check >> + >> + @retval TRUE If HOB is need inside Payload >> + @retval FALSE If HOB is needn't inside Payload >> +**/ >> +BOOLEAN >> +IsHobNeed ( >> + EFI_PEI_HOB_POINTERS Hob >> + ); >> + >> +VOID >> +EFIAPI >> +ProcessLibraryConstructorList ( >> + VOID >> + ); >> + >> /** >> Find the first substring. >> @param String Point to the string where to find the substring. >> @@ -191,187 +274,6 @@ FixUpPcdDatabase ( >> return EFI_SUCCESS; >> } >> >> -/** >> - Add HOB into HOB list >> - @param[in] Hob The HOB to be added into the HOB list. >> -**/ >> -VOID >> -AddNewHob ( >> - IN EFI_PEI_HOB_POINTERS *Hob >> - ) >> -{ >> - EFI_PEI_HOB_POINTERS NewHob; >> - >> - if (Hob->Raw =3D=3D NULL) { >> - return; >> - } >> - >> - NewHob.Header =3D CreateHob (Hob->Header->HobType, >> Hob->Header->HobLength); >> - ASSERT (NewHob.Header !=3D NULL); >> - if (NewHob.Header =3D=3D NULL) { >> - return; >> - } >> - >> - CopyMem (NewHob.Header + 1, Hob->Header + 1, Hob->Header->HobLength - >> sizeof (EFI_HOB_GENERIC_HEADER)); >> -} >> - >> -/** >> - Found the Resource Descriptor HOB that contains a range (Base, Top) >> - @param[in] HobList Hob start address >> - @param[in] Base Memory start address >> - @param[in] Top Memory end address. >> - @retval The pointer to the Resource Descriptor HOB. >> -**/ >> -EFI_HOB_RESOURCE_DESCRIPTOR * >> -FindResourceDescriptorByRange ( >> - IN VOID *HobList, >> - IN EFI_PHYSICAL_ADDRESS Base, >> - IN EFI_PHYSICAL_ADDRESS Top >> - ) >> -{ >> - EFI_PEI_HOB_POINTERS Hob; >> - EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob; >> - >> - for (Hob.Raw =3D (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = =3D >> GET_NEXT_HOB (Hob)) { >> - // >> - // Skip all HOBs except Resource Descriptor HOBs >> - // >> - if (GET_HOB_TYPE (Hob) !=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { >> - continue; >> - } >> - >> - // >> - // Skip Resource Descriptor HOBs that do not describe tested system >> memory >> - // >> - ResourceHob =3D Hob.ResourceDescriptor; >> - if (ResourceHob->ResourceType !=3D EFI_RESOURCE_SYSTEM_MEMORY) { >> - continue; >> - } >> - >> - if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) !=3D >> TESTED_MEMORY_ATTRIBUTES) { >> - continue; >> - } >> - >> - // >> - // Skip Resource Descriptor HOBs that do not contain the PHIT range >> EfiFreeMemoryBottom..EfiFreeMemoryTop >> - // >> - if (Base < ResourceHob->PhysicalStart) { >> - continue; >> - } >> - >> - if (Top > (ResourceHob->PhysicalStart + >> ResourceHob->ResourceLength)) { >> - continue; >> - } >> - >> - return ResourceHob; >> - } >> - >> - return NULL; >> -} >> - >> -/** >> - Find the highest below 4G memory resource descriptor, except the inpu= t >> Resource Descriptor. >> - @param[in] HobList Hob start address >> - @param[in] MinimalNeededSize Minimal needed size. >> - @param[in] ExceptResourceHob Ignore this Resource Descriptor. >> - @retval The pointer to the Resource Descriptor HOB. >> -**/ >> -EFI_HOB_RESOURCE_DESCRIPTOR * >> -FindAnotherHighestBelow4GResourceDescriptor ( >> - IN VOID *HobList, >> - IN UINTN MinimalNeededSize, >> - IN EFI_HOB_RESOURCE_DESCRIPTOR *ExceptResourceHob >> - ) >> -{ >> - EFI_PEI_HOB_POINTERS Hob; >> - EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob; >> - EFI_HOB_RESOURCE_DESCRIPTOR *ReturnResourceHob; >> - >> - ReturnResourceHob =3D NULL; >> - >> - for (Hob.Raw =3D (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = =3D >> GET_NEXT_HOB (Hob)) { >> - // >> - // Skip all HOBs except Resource Descriptor HOBs >> - // >> - if (GET_HOB_TYPE (Hob) !=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { >> - continue; >> - } >> - >> - // >> - // Skip Resource Descriptor HOBs that do not describe tested system >> memory >> - // >> - ResourceHob =3D Hob.ResourceDescriptor; >> - if (ResourceHob->ResourceType !=3D EFI_RESOURCE_SYSTEM_MEMORY) { >> - continue; >> - } >> - >> - if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) !=3D >> TESTED_MEMORY_ATTRIBUTES) { >> - continue; >> - } >> - >> - // >> - // Skip if the Resource Descriptor HOB equals to ExceptResourceHob >> - // >> - if (ResourceHob =3D=3D ExceptResourceHob) { >> - continue; >> - } >> - >> - // >> - // Skip Resource Descriptor HOBs that are beyond 4G >> - // >> - if ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength) > >> BASE_4GB) { >> - continue; >> - } >> - >> - // >> - // Skip Resource Descriptor HOBs that are too small >> - // >> - if (ResourceHob->ResourceLength < MinimalNeededSize) { >> - continue; >> - } >> - >> - // >> - // Return the topest Resource Descriptor >> - // >> - if (ReturnResourceHob =3D=3D NULL) { >> - ReturnResourceHob =3D ResourceHob; >> - } else { >> - if (ReturnResourceHob->PhysicalStart < ResourceHob->PhysicalStart= ) >> { >> - ReturnResourceHob =3D ResourceHob; >> - } >> - } >> - } >> - >> - return ReturnResourceHob; >> -} >> - >> -/** >> - Check the HOB and decide if it is need inside Payload >> - Payload maintainer may make decision which HOB is need or needn't >> - Then add the check logic in the function. >> - @param[in] Hob The HOB to check >> - @retval TRUE If HOB is need inside Payload >> - @retval FALSE If HOB is needn't inside Payload >> -**/ >> -BOOLEAN >> -IsHobNeed ( >> - EFI_PEI_HOB_POINTERS Hob >> - ) >> -{ >> - if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_HANDOFF) { >> - return FALSE; >> - } >> - >> - if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_MEMORY_ALLOCATION) { >> - if (CompareGuid >> (&Hob.MemoryAllocationModule->MemoryAllocationHeader.Name, >> &gEfiHobMemoryAllocModuleGuid)) { >> - return FALSE; >> - } >> - } >> - >> - // Arrive here mean the HOB is need >> - return TRUE; >> -} >> - >> /** >> It will build Fv HOBs based on information from bootloaders. >> @param[out] DxeFv The pointer to the DXE FV in memory. >> @@ -409,21 +311,25 @@ BuildFitLoadablesFvHob ( >> >> Status =3D FdtCheckHeader (Fdt); >> if (EFI_ERROR (Status)) { >> + DEBUG ((DEBUG_INFO, "FdtCheckHeader UPSUPPORTED\n")); >> return EFI_UNSUPPORTED; >> } >> >> ConfigNode =3D FdtSubnodeOffsetNameLen (Fdt, 0, "configurations", >> (INT32)AsciiStrLen ("configurations")); >> if (ConfigNode <=3D 0) { >> + DEBUG ((DEBUG_INFO, "BuildFitLoadablesFvHob configurations >> EFI_NOT_FOUND\n")); >> return EFI_NOT_FOUND; >> } >> >> Config1Node =3D FdtSubnodeOffsetNameLen (Fdt, ConfigNode, "conf-1", >> (INT32)AsciiStrLen ("conf-1")); >> if (Config1Node <=3D 0) { >> + DEBUG ((DEBUG_INFO, "BuildFitLoadablesFvHob conf-1 >> EFI_NOT_FOUND\n")); >> return EFI_NOT_FOUND; >> } >> >> ImageNode =3D FdtSubnodeOffsetNameLen (Fdt, 0, "images", >> (INT32)AsciiStrLen ("images")); >> if (ImageNode <=3D 0) { >> + DEBUG ((DEBUG_INFO, "BuildFitLoadablesFvHob images >> EFI_NOT_FOUND\n")); >> return EFI_NOT_FOUND; >> } >> >> @@ -467,31 +373,25 @@ BuildFitLoadablesFvHob ( >> } >> >> /** >> - It will build HOBs based on information from bootloaders. >> - @param[in] BootloaderParameter The starting memory address of >> bootloader parameter block. >> - @param[out] DxeFv The pointer to the DXE FV in memory= . >> - @retval EFI_SUCCESS If it completed successfully. >> - @retval Others If it failed to build required HOBs. >> + * >> + Create new HOB for new HOB list >> + >> + @param[in] BootloaderParameter The HOB to be added into the HOB lis= t. >> **/ >> -EFI_STATUS >> -BuildHobs ( >> - IN UINTN BootloaderParameter, >> - OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv >> +VOID >> +CreatNewHobForHoblist ( >> + IN UINTN BootloaderParameter >> ) >> { >> - EFI_PEI_HOB_POINTERS Hob; >> - UINTN MinimalNeededSize; >> - EFI_PHYSICAL_ADDRESS FreeMemoryBottom; >> - EFI_PHYSICAL_ADDRESS FreeMemoryTop; >> - EFI_PHYSICAL_ADDRESS MemoryBottom; >> - EFI_PHYSICAL_ADDRESS MemoryTop; >> - EFI_HOB_RESOURCE_DESCRIPTOR *PhitResourceHob; >> - EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob; >> - UINT8 *GuidHob; >> - EFI_HOB_FIRMWARE_VOLUME *FvHob; >> - UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTable; >> - ACPI_BOARD_INFO *AcpiBoardInfo; >> - EFI_HOB_HANDOFF_INFO_TABLE *HobInfo; >> + EFI_PEI_HOB_POINTERS Hob; >> + UINTN MinimalNeededSize; >> + EFI_PHYSICAL_ADDRESS FreeMemoryBottom; >> + EFI_PHYSICAL_ADDRESS FreeMemoryTop; >> + EFI_PHYSICAL_ADDRESS MemoryBottom; >> + EFI_PHYSICAL_ADDRESS MemoryTop; >> + EFI_HOB_RESOURCE_DESCRIPTOR *PhitResourceHob; >> + EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob; >> + EFI_HOB_HANDOFF_INFO_TABLE *HobInfo; >> >> Hob.Raw =3D (UINT8 *)BootloaderParameter; >> MinimalNeededSize =3D FixedPcdGet32 (PcdSystemMemoryUefiRegionSize); >> @@ -512,7 +412,7 @@ BuildHobs ( >> // >> ResourceHob =3D FindAnotherHighestBelow4GResourceDescriptor (Hob.Ra= w, >> MinimalNeededSize, NULL); >> if (ResourceHob =3D=3D NULL) { >> - return EFI_NOT_FOUND; >> + return; >> } >> >> MemoryBottom =3D ResourceHob->PhysicalStart + >> ResourceHob->ResourceLength - MinimalNeededSize; >> @@ -542,7 +442,7 @@ BuildHobs ( >> // >> ResourceHob =3D FindAnotherHighestBelow4GResourceDescriptor (Hob.Ra= w, >> MinimalNeededSize, PhitResourceHob); >> if (ResourceHob =3D=3D NULL) { >> - return EFI_NOT_FOUND; >> + return; >> } >> >> MemoryBottom =3D ResourceHob->PhysicalStart + >> ResourceHob->ResourceLength - MinimalNeededSize; >> @@ -553,14 +453,7 @@ BuildHobs ( >> >> HobInfo =3D HobConstructor ((VOID *)(UINTN)MemoryBottom, (V= OID >> *)(UINTN)MemoryTop, (VOID *)(UINTN)FreeMemoryBottom, (VOID >> *)(UINTN)FreeMemoryTop); >> HobInfo->BootMode =3D Hob.HandoffInformationTable->BootMode; >> - // >> - // From now on, mHobList will point to the new Hob range. >> - // >> >> - // >> - // Create an empty FvHob for the DXE FV that contains DXE core. >> - // >> - BuildFvHob ((EFI_PHYSICAL_ADDRESS)0, 0); >> // >> // Since payload created new Hob, move all hobs except PHIT from boot >> loader hob list. >> // >> @@ -573,7 +466,57 @@ BuildHobs ( >> Hob.Raw =3D GET_NEXT_HOB (Hob); >> } >> >> - BuildFitLoadablesFvHob (DxeFv); >> + return; >> +} >> + >> +/** >> + It will build HOBs based on information from bootloaders. >> + @param[in] NewFdtBase The pointer to New FdtBase. >> + @param[out] DxeFv The pointer to the DXE FV in memory. >> + @retval EFI_SUCCESS If it completed successfully. >> + @retval Others If it failed to build required HOBs. >> +**/ >> +EFI_STATUS >> +FitBuildHobs ( >> + IN UINTN NewFdtBase, >> + OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv >> + ) >> +{ >> + UINT8 *GuidHob; >> + UINT32 FdtSize; >> + EFI_HOB_FIRMWARE_VOLUME *FvHob; >> + UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTable; >> + ACPI_BOARD_INFO *AcpiBoardInfo; >> + UNIVERSAL_PAYLOAD_DEVICE_TREE *Fdt; >> + >> + if (FixedPcdGetBool (PcdHandOffFdtEnable)) { >> + // >> + // Back up FDT in Reserved memory region >> + // >> + >> + GuidHob =3D GetFirstGuidHob (&gUniversalPayloadDeviceTreeGuid); >> + if (GuidHob !=3D NULL) { >> + Fdt =3D (UNIVERSAL_PAYLOAD_DEVICE_TREE *)GET_GUID_HOB_DATA >> (GuidHob); >> + if (Fdt !=3D NULL) { >> + DEBUG ((DEBUG_INFO, "Update FDT base to reserved memory\n")); >> + FdtSize =3D 4 * EFI_PAGE_SIZE; >> + CopyMem ((VOID *)NewFdtBase, (VOID *)(Fdt->DeviceTreeAddress), >> FdtSize); >> + Fdt->DeviceTreeAddress =3D NewFdtBase; >> + } >> + } >> + } >> + >> + // >> + // To create Memory Type Information HOB >> + // >> + GuidHob =3D GetFirstGuidHob (&gEfiMemoryTypeInformationGuid); >> + if (GuidHob =3D=3D NULL) { >> + BuildGuidDataHob ( >> + &gEfiMemoryTypeInformationGuid, >> + mDefaultMemoryTypeInformation, >> + sizeof (mDefaultMemoryTypeInformation) >> + ); >> + } >> >> // >> // Create guid hob for acpi board information >> @@ -588,6 +531,12 @@ BuildHobs ( >> } >> } >> >> + // >> + // Create an empty FvHob for the DXE FV that contains DXE core. >> + // >> + BuildFvHob ((EFI_PHYSICAL_ADDRESS)0, 0); >> + >> + BuildFitLoadablesFvHob (DxeFv); >> // >> // Update DXE FV information to first fv hob in the hob list, which >> // is the empty FvHob created before. >> @@ -600,12 +549,12 @@ BuildHobs ( >> >> /** >> Entry point to the C language phase of UEFI payload. >> - @param[in] BootloaderParameter The starting address of bootloade= r >> parameter block. >> + @param[in] BootloaderParameter The starting address of FDT . >> @retval It will not return if SUCCESS, and return error when >> passing bootloader parameter. >> **/ >> EFI_STATUS >> EFIAPI >> -_ModuleEntryPoint ( >> +FitUplEntryPoint ( >> IN UINTN BootloaderParameter >> ) >> { >> @@ -613,14 +562,46 @@ _ModuleEntryPoint ( >> PHYSICAL_ADDRESS DxeCoreEntryPoint; >> EFI_PEI_HOB_POINTERS Hob; >> EFI_FIRMWARE_VOLUME_HEADER *DxeFv; >> + PHYSICAL_ADDRESS HobListPtr; >> + VOID *FdtBase; >> + VOID *FdtBaseResvd; >> >> - mHobList =3D (VOID *)BootloaderParameter; >> - DxeFv =3D NULL; >> + if (FixedPcdGetBool (PcdHandOffFdtEnable)) { >> + mHobList =3D (VOID *)NULL; >> + } else { >> + mHobList =3D (VOID *)BootloaderParameter; >> + } >> + >> + DxeFv =3D NULL; >> // Call constructor for all libraries >> ProcessLibraryConstructorList (); >> >> DEBUG ((DEBUG_INFO, "Entering Universal Payload...\n")); >> DEBUG ((DEBUG_INFO, "sizeof(UINTN) =3D 0x%x\n", sizeof (UINTN))); >> + DEBUG ((DEBUG_INFO, "BootloaderParameter =3D 0x%x\n", >> BootloaderParameter)); >> + >> + DEBUG ((DEBUG_INFO, "Start init Hobs...\n")); >> + HobListPtr =3D UplInitHob ((VOID *)BootloaderParameter); >> + >> + // >> + // Found hob list node >> + // >> + if (HobListPtr !=3D 0) { >> + FdtBase =3D (VOID *)BootloaderParameter; >> + if (FdtCheckHeader (FdtBase) =3D=3D 0) { >> + CustomFdtNodeParser ((VOID *)FdtBase, (VOID *)HobListPtr); >> + } else { >> + CreatNewHobForHoblist (BootloaderParameter); >> + } >> + >> + FdtBaseResvd =3D PayloadAllocatePages (4, EfiReservedMemoryType); >> + >> + // Build HOB based on information from Bootloader >> + Status =3D FitBuildHobs ((UINTN)FdtBaseResvd, &DxeFv); >> + } >> + >> + // Call constructor for all libraries again since hobs were built >> + ProcessLibraryConstructorList (); >> >> DEBUG_CODE ( >> // >> @@ -629,23 +610,10 @@ _ModuleEntryPoint ( >> PrintHob (mHobList); >> ); >> >> - // Initialize floating point operating environment to be compliant >> with UEFI spec. >> - InitializeFloatingPointUnits (); >> - >> - // Build HOB based on information from Bootloader >> - Status =3D BuildHobs (BootloaderParameter, &DxeFv); >> - ASSERT_EFI_ERROR (Status); >> - >> FixUpPcdDatabase (DxeFv); >> Status =3D UniversalLoadDxeCore (DxeFv, &DxeCoreEntryPoint); >> ASSERT_EFI_ERROR (Status); >> >> - // >> - // Mask off all legacy 8259 interrupt sources >> - // >> - IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF); >> - IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF); >> - >> Hob.HandoffInformationTable =3D (EFI_HOB_HANDOFF_INFO_TABLE >> *)GetFirstHob (EFI_HOB_TYPE_HANDOFF); >> HandOffToDxeCore (DxeCoreEntryPoint, Hob); >> >> diff --git a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c >> b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c >> index 61a9f01ec9e7..cf9c03a9a8e9 100644 >> --- a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c >> +++ b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c >> @@ -15,12 +15,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent >> #include >> #include >> #include >> +#include >> #include "VirtualMemory.h" >> #include "UefiPayloadEntry.h" >> >> #define STACK_SIZE 0x20000 >> #define IDT_ENTRY_COUNT 32 >> >> +extern VOID *mHobList; >> + >> typedef struct _X64_IDT_TABLE { >> // >> // Reserved 4 bytes preceding PeiService and IdtTable, >> @@ -268,6 +271,15 @@ HandOffToDxeCore ( >> UINT32 Index; >> X64_IDT_TABLE *IdtTableForX64; >> >> + // Initialize floating point operating environment to be compliant >> with UEFI spec. >> + InitializeFloatingPointUnits (); >> + >> + // >> + // Mask off all legacy 8259 interrupt sources >> + // >> + IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF); >> + IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF); >> + >> // >> // Clear page 0 and mark it as allocated if NULL pointer detection is >> enabled. >> // >> diff --git a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c >> b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFuncFit.c >> similarity index 90% >> copy from UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c >> copy to UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFuncFit.c >> index 61a9f01ec9e7..439d5bee0b8c 100644 >> --- a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c >> +++ b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFuncFit.c >> @@ -1,10 +1,8 @@ >> /** @file >> Ia32-specific functionality for DxeLoad. >> >> -Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
>> -Copyright (c) 2017, AMD Incorporated. All rights reserved.
>> - >> -SPDX-License-Identifier: BSD-2-Clause-Patent >> + Copyright (c) 2024, Intel Corporation. All rights reserved.
>> + SPDX-License-Identifier: BSD-2-Clause-Patent >> >> **/ >> >> @@ -15,12 +13,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent >> #include >> #include >> #include >> +#include >> #include "VirtualMemory.h" >> #include "UefiPayloadEntry.h" >> >> #define STACK_SIZE 0x20000 >> #define IDT_ENTRY_COUNT 32 >> >> +extern VOID *mHobList; >> + >> typedef struct _X64_IDT_TABLE { >> // >> // Reserved 4 bytes preceding PeiService and IdtTable, >> @@ -268,6 +269,15 @@ HandOffToDxeCore ( >> UINT32 Index; >> X64_IDT_TABLE *IdtTableForX64; >> >> + // Initialize floating point operating environment to be compliant >> with UEFI spec. >> + InitializeFloatingPointUnits (); >> + >> + // >> + // Mask off all legacy 8259 interrupt sources >> + // >> + IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF); >> + IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF); >> + >> // >> // Clear page 0 and mark it as allocated if NULL pointer detection is >> enabled. >> // >> @@ -379,3 +389,17 @@ HandOffToDxeCore ( >> CpuDeadLoop (); >> } >> } >> + >> +/** >> + Entry point to the C language phase of UEFI payload. >> + @param[in] BootloaderParameter The starting address of bootloade= r >> parameter block. >> + @retval It will not return if SUCCESS, and return error when >> passing bootloader parameter. >> +**/ >> +EFI_STATUS >> +EFIAPI >> +_ModuleEntryPoint ( >> + IN UINTN BootloaderParameter >> + ) >> +{ >> + return FitUplEntryPoint (BootloaderParameter); >> +} >> diff --git a/UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c >> b/UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c >> index 83936ae26e68..36edca81f997 100644 >> --- a/UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c >> +++ b/UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c >> @@ -10,6 +10,56 @@ >> >> #include "UefiPayloadEntry.h" >> >> +/** >> + Allocates one or more pages of type EfiBootServicesData. >> + >> + Allocates the number of pages of MemoryType and returns a pointer to >> the >> + allocated buffer. The buffer returned is aligned on a 4KB boundary. >> + If Pages is 0, then NULL is returned. >> + If there is not enough memory availble to satisfy the request, then >> NULL >> + is returned. >> + >> + @param Pages The number of 4 KB pages to allocate. >> + @param MemoryType The MemoryType >> + @return A pointer to the allocated buffer or NULL if allocation fail= s. >> +**/ >> +VOID * >> +EFIAPI >> +PayloadAllocatePages ( >> + IN UINTN Pages, >> + IN EFI_MEMORY_TYPE MemoryType >> + ) >> +{ >> + EFI_PEI_HOB_POINTERS Hob; >> + EFI_PHYSICAL_ADDRESS Offset; >> + EFI_HOB_HANDOFF_INFO_TABLE *HobTable; >> + >> + Hob.Raw =3D GetHobList (); >> + HobTable =3D Hob.HandoffInformationTable; >> + >> + if (Pages =3D=3D 0) { >> + return NULL; >> + } >> + >> + // Make sure allocation address is page alligned. >> + Offset =3D HobTable->EfiFreeMemoryTop & EFI_PAGE_MASK; >> + if (Offset !=3D 0) { >> + HobTable->EfiFreeMemoryTop -=3D Offset; >> + } >> + >> + // >> + // Check available memory for the allocation >> + // >> + if (HobTable->EfiFreeMemoryTop - ((Pages * EFI_PAGE_SIZE) + sizeof >> (EFI_HOB_MEMORY_ALLOCATION)) < HobTable->EfiFreeMemoryBottom) { >> + return NULL; >> + } >> + >> + HobTable->EfiFreeMemoryTop -=3D Pages * EFI_PAGE_SIZE; >> + BuildMemoryAllocationHob (HobTable->EfiFreeMemoryTop, Pages * >> EFI_PAGE_SIZE, MemoryType); >> + >> + return (VOID *)(UINTN)HobTable->EfiFreeMemoryTop; >> +} >> + >> /** >> Allocates one or more pages of type EfiBootServicesData. >> >> diff --git a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c >> b/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c >> index b63e93c07ec2..153d1b00f637 100644 >> --- a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c >> +++ b/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c >> @@ -169,13 +169,13 @@ PrintMemoryAllocationHob ( >> } >> >> /** >> - Print the information in Resource Discriptor Hob. >> + Print the information in Resource Descriptor Hob. >> @param[in] HobStart A pointer to HOB of type >> EFI_HOB_TYPE_RESOURCE_DESCRIPTOR. >> @param[in] HobLength The Length in bytes of HOB of type >> EFI_HOB_TYPE_RESOURCE_DESCRIPTOR. >> @retval EFI_SUCCESS If it completed successfully. >> **/ >> EFI_STATUS >> -PrintResourceDiscriptorHob ( >> +PrintResourceDescriptorHob ( >> IN VOID *HobStart, >> IN UINT16 HobLength >> ) >> @@ -620,7 +620,7 @@ PrintFv3Hob ( >> HOB_PRINT_HANDLER_TABLE mHobHandles[] =3D { >> { EFI_HOB_TYPE_HANDOFF, "EFI_HOB_TYPE_HANDOFF", >> PrintHandOffHob }, >> { EFI_HOB_TYPE_MEMORY_ALLOCATION, "EFI_HOB_TYPE_MEMORY_ALLOCATION", >> PrintMemoryAllocationHob }, >> - { EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, >> "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR", PrintResourceDiscriptorHob }, >> + { EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, >> "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR", PrintResourceDescriptorHob }, >> { EFI_HOB_TYPE_GUID_EXTENSION, "EFI_HOB_TYPE_GUID_EXTENSION", >> PrintGuidHob }, >> { EFI_HOB_TYPE_FV, "EFI_HOB_TYPE_FV", >> PrintFvHob }, >> { EFI_HOB_TYPE_CPU, "EFI_HOB_TYPE_CPU", >> PrintCpuHob }, >> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c >> b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c >> index f37c00fad774..5b864eeefe10 100644 >> --- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c >> +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c >> @@ -486,12 +486,6 @@ _ModuleEntryPoint ( >> Status =3D UniversalLoadDxeCore (DxeFv, &DxeCoreEntryPoint); >> ASSERT_EFI_ERROR (Status); >> >> - // >> - // Mask off all legacy 8259 interrupt sources >> - // >> - IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF); >> - IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF); >> - >> Hob.HandoffInformationTable =3D (EFI_HOB_HANDOFF_INFO_TABLE >> *)GetFirstHob (EFI_HOB_TYPE_HANDOFF); >> HandOffToDxeCore (DxeCoreEntryPoint, Hob); >> >> diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c >> b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c >> index 346e3feb0459..6c3603f12098 100644 >> --- a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c >> +++ b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c >> @@ -13,10 +13,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent >> #include >> #include >> #include >> +#include >> #include "X64/VirtualMemory.h" >> #include "UefiPayloadEntry.h" >> #define STACK_SIZE 0x20000 >> >> +extern VOID *mHobList; >> + >> /** >> Transfers control to DxeCore. >> >> @@ -40,6 +43,15 @@ HandOffToDxeCore ( >> VOID *GhcbBase; >> UINTN GhcbSize; >> >> + // Initialize floating point operating environment to be compliant >> with UEFI spec. >> + InitializeFloatingPointUnits (); >> + >> + // >> + // Mask off all legacy 8259 interrupt sources >> + // >> + IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF); >> + IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF); >> + >> // >> // Clear page 0 and mark it as allocated if NULL pointer detection is >> enabled. >> // >> diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c >> b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFuncFit.c >> similarity index 74% >> copy from UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c >> copy to UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFuncFit.c >> index 346e3feb0459..35b52a911df3 100644 >> --- a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c >> +++ b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFuncFit.c >> @@ -1,8 +1,8 @@ >> /** @file >> x64-specifc functionality for DxeLoad. >> >> -Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
>> -SPDX-License-Identifier: BSD-2-Clause-Patent >> + Copyright (c) 2024, Intel Corporation. All rights reserved.
>> + SPDX-License-Identifier: BSD-2-Clause-Patent >> >> **/ >> >> @@ -13,10 +13,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent >> #include >> #include >> #include >> +#include >> +#include >> #include "X64/VirtualMemory.h" >> #include "UefiPayloadEntry.h" >> #define STACK_SIZE 0x20000 >> >> +extern VOID *mHobList; >> + >> /** >> Transfers control to DxeCore. >> >> @@ -40,6 +44,15 @@ HandOffToDxeCore ( >> VOID *GhcbBase; >> UINTN GhcbSize; >> >> + // Initialize floating point operating environment to be compliant >> with UEFI spec. >> + InitializeFloatingPointUnits (); >> + >> + // >> + // Mask off all legacy 8259 interrupt sources >> + // >> + IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF); >> + IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF); >> + >> // >> // Clear page 0 and mark it as allocated if NULL pointer detection is >> enabled. >> // >> @@ -106,3 +119,17 @@ HandOffToDxeCore ( >> TopOfStack >> ); >> } >> + >> +/** >> + Entry point to the C language phase of UEFI payload. >> + @param[in] BootloaderParameter The starting address of bootloade= r >> parameter block. >> + @retval It will not return if SUCCESS, and return error when >> passing bootloader parameter. >> +**/ >> +EFI_STATUS >> +EFIAPI >> +_ModuleEntryPoint ( >> + IN UINTN BootloaderParameter >> + ) >> +{ >> + return FitUplEntryPoint (BootloaderParameter); >> +} >> diff --git a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.in= f >> b/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf >> index b87a0989eee3..c87e674f7cbd 100644 >> --- a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf >> +++ b/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf >> @@ -30,13 +30,13 @@ >> [Sources.Ia32] >> X64/VirtualMemory.h >> X64/VirtualMemory.c >> - Ia32/DxeLoadFunc.c >> + Ia32/DxeLoadFuncFit.c >> Ia32/IdtVectorAsm.nasm >> >> [Sources.X64] >> X64/VirtualMemory.h >> X64/VirtualMemory.c >> - X64/DxeLoadFunc.c >> + X64/DxeLoadFuncFit.c >> >> [Packages] >> MdePkg/MdePkg.dec >> @@ -54,6 +54,8 @@ >> PeCoffLib >> CpuLib >> FdtLib >> + CustomFdtNodeParserLib >> + PcdLib >> >> [Guids] >> gEfiMemoryTypeInformationGuid >> @@ -71,6 +73,7 @@ >> gUniversalPayloadAcpiTableGuid >> gUniversalPayloadPciRootBridgeInfoGuid >> gUniversalPayloadSmbios3TableGuid >> + gUniversalPayloadDeviceTreeGuid >> >> [FeaturePcd.IA32] >> gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## >> CONSUMES >> @@ -78,7 +81,6 @@ >> [FeaturePcd.X64] >> gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables ## >> CONSUMES >> >> - >> [Pcd.IA32,Pcd.X64] >> gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile >> gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable >> ## SOMETIMES_CONSUMES >> @@ -88,11 +90,19 @@ >> gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard >> ## CONSUMES >> gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase >> ## CONSUMES >> gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize >> ## CONSUMES >> - >> gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemBase >> gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize >> gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize >> - >> gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## >> SOMETIMES_CONSUMES >> gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## >> SOMETIMES_CONSUMES >> gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## >> SOMETIMES_CONSUMES >> + gUefiPayloadPkgTokenSpaceGuid.PcdHandOffFdtEnable >> + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS >> + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory >> + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType >> + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData >> + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode >> + >> +[BuildOptions] >> + MSFT:*_*_*_CC_FLAGS =3D /wd4244 /wd4305 >> + GCC:*_*_*_CC_FLAGS =3D -Wno-error=3Dpointer-to-int-cast >> -Wno-error=3Dint-to-pointer-cast >> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h >> b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h >> index 80ccc5072c55..09fce8dbcf35 100644 >> --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h >> +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h >> @@ -35,6 +35,7 @@ >> #include >> #include >> #include >> +#include >> #include >> >> #define LEGACY_8259_MASK_REGISTER_MASTER 0x21 >> @@ -134,6 +135,31 @@ UniversalLoadDxeCore ( >> OUT PHYSICAL_ADDRESS *DxeCoreEntryPoint >> ); >> >> +/** >> + It will Parse FDT -node based on information. >> + @param[in] FdtBase The starting memory address of FdtBase >> + @retval HobList The base address of Hoblist. >> + >> +**/ >> +UINT64 >> +EFIAPI >> +FdtNodeParser ( >> + IN VOID *FdtBase >> + ); >> + >> +/** >> + It will Parse FDT -custom node based on information. >> + @param[in] FdtBase The starting memory address of FdtBase >> + @param[in] HostList The starting memory address of New Hob list. >> + >> +**/ >> +UINTN >> +EFIAPI >> +CustomFdtNodeParser ( >> + IN VOID *FdtBase, >> + IN VOID *HostList >> + ); >> + >> /** >> Transfers control to DxeCore. >> >> @@ -206,4 +232,46 @@ BuildHobFromAcpi ( >> IN UINT64 AcpiTableBase >> ); >> >> +/** >> + Allocates one or more pages . >> + >> + Allocates the number of pages of MemoryType and returns a pointer to >> the >> + allocated buffer. The buffer returned is aligned on a 4KB boundary. >> + If Pages is 0, then NULL is returned. >> + If there is not enough memory availble to satisfy the request, then >> NULL >> + is returned. >> + >> + @param Pages The number of 4 KB pages to allocate. >> + @param MemoryType The Memorytype >> + @return A pointer to the allocated buffer or NULL if allocation fail= s. >> +**/ >> +VOID * >> +EFIAPI >> +PayloadAllocatePages ( >> + IN UINTN Pages, >> + IN EFI_MEMORY_TYPE MemoryType >> + ); >> + >> +/** >> + Entry point to the C language phase of UEFI payload. >> + @param[in] FdtPrt The starting address of FDT . >> + @retval It will not return if SUCCESS, and return error when >> passing bootloader parameter. >> +**/ >> +EFI_STATUS >> +EFIAPI >> +FitUplEntryPoint ( >> + IN UINTN BootloaderParameter >> + ); >> + >> +/** >> + Entry point to the C language phase of UEFI payload. >> + @param[in] BootloaderParameter The starting address of bootloade= r >> parameter block. >> + @retval It will not return if SUCCESS, and return error when >> passing bootloader parameter. >> +**/ >> +EFI_STATUS >> +EFIAPI >> +UplEntryPoint ( >> + IN UINTN BootloaderParameter >> + ); >> + >> #endif >> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf >> b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf >> index a62da5c7059d..be91f7be2819 100644 >> --- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf >> +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf >> @@ -6,44 +6,37 @@ >> # SPDX-License-Identifier: BSD-2-Clause-Patent >> # >> ## >> - >> [Defines] >> INF_VERSION =3D 1.30 >> BASE_NAME =3D UniversalPayloadEntry >> FILE_GUID =3D D4F0F269-1209-4A66-8039-C4D5A700EA= 4E >> MODULE_TYPE =3D SEC >> VERSION_STRING =3D 1.0 >> - >> # >> # The following information is for reference only and not required by >> the build tools. >> # >> # VALID_ARCHITECTURES =3D IA32 X64 >> # >> - >> [Sources] >> UniversalPayloadEntry.c >> LoadDxeCore.c >> MemoryAllocation.c >> PrintHob.c >> AcpiTable.c >> - >> [Sources.Ia32] >> X64/VirtualMemory.h >> X64/VirtualMemory.c >> Ia32/DxeLoadFunc.c >> Ia32/IdtVectorAsm.nasm >> - >> [Sources.X64] >> X64/VirtualMemory.h >> X64/VirtualMemory.c >> X64/DxeLoadFunc.c >> - >> [Packages] >> MdePkg/MdePkg.dec >> MdeModulePkg/MdeModulePkg.dec >> UefiCpuPkg/UefiCpuPkg.dec >> UefiPayloadPkg/UefiPayloadPkg.dec >> - >> [LibraryClasses] >> BaseMemoryLib >> DebugLib >> @@ -69,14 +62,12 @@ >> gUniversalPayloadAcpiTableGuid >> gUniversalPayloadPciRootBridgeInfoGuid >> gUniversalPayloadSmbios3TableGuid >> - >> + gUniversalPayloadBaseGuid >> + gUniversalPayloadDeviceTreeGuid >> [FeaturePcd.IA32] >> gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## >> CONSUMES >> - >> [FeaturePcd.X64] >> gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables ## >> CONSUMES >> - >> - >> [Pcd.IA32,Pcd.X64] >> gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile >> gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable >> ## SOMETIMES_CONSUMES >> @@ -86,12 +77,9 @@ >> gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard >> ## CONSUMES >> gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase >> ## CONSUMES >> gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize >> ## CONSUMES >> - >> gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemBase >> gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize >> gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize >> - >> gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## >> SOMETIMES_CONSUMES >> gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## >> SOMETIMES_CONSUMES >> gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## >> SOMETIMES_CONSUMES >> - >> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc >> b/UefiPayloadPkg/UefiPayloadPkg.dsc >> index 2860a659f6a7..779f74da7171 100644 >> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc >> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc >> @@ -55,7 +55,7 @@ >> # ELF: Build UniversalPayload file as UniversalPayload.elf >> # FIT: Build UniversalPayload file as UniversalPayload.fit >> # >> - DEFINE UNIVERSAL_PAYLOAD =3D FALSE >> + DEFINE UNIVERSAL_PAYLOAD =3D TRUE >> DEFINE UNIVERSAL_PAYLOAD_FORMAT =3D ELF >> >> # >> @@ -226,6 +226,7 @@ >> OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf >> RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf >> HobLib|UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf >> + >> CustomFdtNodeParserLib|UefiPayloadPkg/Library/CustomFdtNodeParserNullLib= /CustomFdtNodeParserNullLib.inf >> >> # >> # UEFI & PI >> @@ -470,6 +471,8 @@ >> gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0 >> gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE >> gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE >> + gUefiPayloadPkgTokenSpaceGuid.PcdHandOffFdtEnable|TRUE >> + >> >> gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, >> 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, >> 0x23, 0x31 } >> gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, >> 0x80, 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, >> 0x41 } >> @@ -513,7 +516,15 @@ >> !endif >> !endif >> >> + >> [PcdsPatchableInModule.X64] >> + # >> + # The following parameters are set by Library/PlatformHookLib >> + # >> + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|FALSE >> + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x3F8 >> + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate|$(BAUD_RATE) >> + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|1 >> !if $(NETWORK_DRIVER_ENABLE) =3D=3D TRUE >> gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE >> !endif >> @@ -635,7 +646,13 @@ >> !if $(UNIVERSAL_PAYLOAD_FORMAT) =3D=3D "ELF" >> UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf >> !elseif $(UNIVERSAL_PAYLOAD_FORMAT) =3D=3D "FIT" >> - UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf >> + UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf { >> + >> + FdtLib|MdePkg/Library/BaseFdtLib/BaseFdtLib.inf >> + >> CustomFdtNodeParserLib|UefiPayloadPkg/Library/CustomFdtNodeParserLib/Cus= tomFdtNodeParserLib.inf >> + NULL|UefiPayloadPkg/Library/FdtParserLib/FdtParseLib.inf >> + NULL|UefiPayloadPkg/Library/HobParseLib/HobParseLib.inf >> + } >> !else >> UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf >> !endif >> @@ -648,7 +665,13 @@ >> !if $(UNIVERSAL_PAYLOAD_FORMAT) =3D=3D "ELF" >> UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf >> !elseif $(UNIVERSAL_PAYLOAD_FORMAT) =3D=3D "FIT" >> - UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf >> + UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf { >> + >> + FdtLib|MdePkg/Library/BaseFdtLib/BaseFdtLib.inf >> + >> CustomFdtNodeParserLib|UefiPayloadPkg/Library/CustomFdtNodeParserLib/Cus= tomFdtNodeParserLib.inf >> + NULL|UefiPayloadPkg/Library/FdtParserLib/FdtParseLib.inf >> + NULL|UefiPayloadPkg/Library/HobParseLib/HobParseLib.inf >> + } >> !else >> UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf >> !endif >> -- >> 2.39.2.windows.1 >> >> > > -- > Thanks! > =3DD > --=20 Thanks! =3DD -=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 (#119451): https://edk2.groups.io/g/devel/message/119451 Mute This Topic: https://groups.io/mt/106455168/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --0000000000004fe06a061a13a364 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I also believe=C2=A0this code needs to go through crustify= etc to ensure it follows all edk2 standards?

On Mon, Jun 3, 2024 at 4:57=E2= =80=AFPM Dhaval Sharma <dhaval@ri= vosinc.com> wrote:
BuildFitLoadablesFvHob:
  • Fdt var= iable is not initialized.
  • It ONLY gets initialized=C2=A0if Guid= Hob is found. What if it is not found?
  • FdtCheckHeader still evaluat= ing it?

On Mon, Jun 3, 2024 at 7:49=E2=80=AFAM Linus Liu <= ;linus.liu@intel.c= om> wrote:
= benny.lin@intel.com>
Cc: Gua Guo <gua.= guo@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: James Lu <ja= mes.lu@intel.com>
Cc: Dhaval Sharma <dhaval@rivosinc.com>

Signed-off-by: Linus Liu <linus.liu@intel.com>
---
=C2=A0UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 428 +++++++++-----------
=C2=A0UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 1= 2 +
=C2=A0UefiPayloadPkg/UefiPayloadEntry/Ia32/{DxeLoadFunc.c =3D> DxeLoadFu= ncFit.c} |=C2=A0 32 +-
=C2=A0UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 5= 0 +++
=C2=A0UefiPayloadPkg/UefiPayloadEntry/PrintHob.c=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0|=C2=A0 =C2=A06 +-
=C2=A0UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A06 -
=C2=A0UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 12 = +
=C2=A0UefiPayloadPkg/UefiPayloadEntry/X64/{DxeLoadFunc.c =3D> DxeLoadFun= cFit.c}=C2=A0 |=C2=A0 31 +-
=C2=A0UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 20 +-
=C2=A0UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 6= 8 ++++
=C2=A0UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 16 +-
=C2=A0UefiPayloadPkg/UefiPayloadPkg.dsc=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 29 +-
=C2=A012 files changed, 443 insertions(+), 267 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c b/U= efiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c
index eb0b325369a0..813d656950d1 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c
@@ -6,6 +6,8 @@
=C2=A0#include "UefiPayloadEntry.h"
=C2=A0#include <Library/FdtLib.h>
=C2=A0#include <Guid/UniversalPayloadBase.h>
+#include <Guid/MemoryTypeInformation.h>
+#include <Library/FdtParserLib.h>

=C2=A0#define MEMORY_ATTRIBUTE_MASK=C2=A0 (EFI_RESOURCE_ATTRIBUTE_PRESENT= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0 =C2= =A0 \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 EFI_RESO= URCE_ATTRIBUTE_INITIALIZED=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| \
@@ -23,6 +25,15 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 EFI_RESO= URCE_ATTRIBUTE_INITIALIZED | \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 EFI_RESO= URCE_ATTRIBUTE_TESTED=C2=A0 =C2=A0 =C2=A0 )

+EFI_MEMORY_TYPE_INFORMATION=C2=A0 mDefaultMemoryTypeInformation[] =3D { +=C2=A0 { EfiACPIReclaimMemory,=C2=A0 =C2=A0FixedPcdGet32 (PcdMemoryTypeEfi= ACPIReclaimMemory)=C2=A0 =C2=A0},
+=C2=A0 { EfiACPIMemoryNVS,=C2=A0 =C2=A0 =C2=A0 =C2=A0FixedPcdGet32 (PcdMem= oryTypeEfiACPIMemoryNVS)=C2=A0 =C2=A0 =C2=A0 =C2=A0},
+=C2=A0 { EfiReservedMemoryType,=C2=A0 FixedPcdGet32 (PcdMemoryTypeEfiReser= vedMemoryType)=C2=A0 },
+=C2=A0 { EfiRuntimeServicesData, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeSer= vicesData) },
+=C2=A0 { EfiRuntimeServicesCode, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeSer= vicesCode) },
+=C2=A0 { EfiMaxMemoryType,=C2=A0 =C2=A0 =C2=A0 =C2=A00=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0}
+};
+
=C2=A0extern VOID=C2=A0 *mHobList;

=C2=A0CHAR8=C2=A0 *mLineBuffer =3D NULL;
@@ -36,6 +47,78 @@ PrintHob (
=C2=A0 =C2=A0IN CONST VOID=C2=A0 *HobStart
=C2=A0 =C2=A0);

+/**
+=C2=A0 Add HOB into HOB list
+=C2=A0 @param[in]=C2=A0 Hob=C2=A0 =C2=A0 The HOB to be added into the HOB = list.
+**/
+VOID
+AddNewHob (
+=C2=A0 IN EFI_PEI_HOB_POINTERS=C2=A0 *Hob
+=C2=A0 );
+
+/**
+=C2=A0 Found the Resource Descriptor HOB that contains a range (Base, Top)=
+=C2=A0 @param[in] HobList=C2=A0 =C2=A0 Hob start address
+=C2=A0 @param[in] Base=C2=A0 =C2=A0 =C2=A0 =C2=A0Memory start address
+=C2=A0 @param[in] Top=C2=A0 =C2=A0 =C2=A0 =C2=A0 Memory end address.
+=C2=A0 @retval=C2=A0 =C2=A0 =C2=A0The pointer to the Resource Descriptor H= OB.
+**/
+EFI_HOB_RESOURCE_DESCRIPTOR *
+FindResourceDescriptorByRange (
+=C2=A0 IN VOID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 *HobList,
+=C2=A0 IN EFI_PHYSICAL_ADDRESS=C2=A0 Base,
+=C2=A0 IN EFI_PHYSICAL_ADDRESS=C2=A0 Top
+=C2=A0 );
+
+/**
+=C2=A0 Find the highest below 4G memory resource descriptor, except the in= put Resource Descriptor.
+=C2=A0 @param[in] HobList=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0Hob start address
+=C2=A0 @param[in] MinimalNeededSize=C2=A0 =C2=A0 =C2=A0 =C2=A0Minimal need= ed size.
+=C2=A0 @param[in] ExceptResourceHob=C2=A0 =C2=A0 =C2=A0 =C2=A0Ignore this = Resource Descriptor.
+=C2=A0 @retval=C2=A0 =C2=A0 =C2=A0The pointer to the Resource Descriptor H= OB.
+**/
+EFI_HOB_RESOURCE_DESCRIPTOR *
+FindAnotherHighestBelow4GResourceDescriptor (
+=C2=A0 IN VOID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*HobList,
+=C2=A0 IN UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 MinimalNeededSize,
+=C2=A0 IN EFI_HOB_RESOURCE_DESCRIPTOR=C2=A0 *ExceptResourceHob
+=C2=A0 );
+
+/**
+=C2=A0 Check the HOB and decide if it is need inside Payload
+=C2=A0 Payload maintainer may make decision which HOB is need or needn'= ;t
+=C2=A0 Then add the check logic in the function.
+=C2=A0 @param[in] Hob The HOB to check
+=C2=A0 @retval TRUE=C2=A0 If HOB is need inside Payload
+=C2=A0 @retval FALSE If HOB is needn't inside Payload
+**/
+BOOLEAN
+FitIsHobNeed (
+=C2=A0 EFI_PEI_HOB_POINTERS=C2=A0 Hob
+=C2=A0 );
+
+/**
+=C2=A0 Check the HOB and decide if it is need inside Payload
+
+=C2=A0 Payload maintainer may make decision which HOB is need or needn'= ;t
+=C2=A0 Then add the check logic in the function.
+
+=C2=A0 @param[in] Hob The HOB to check
+
+=C2=A0 @retval TRUE=C2=A0 If HOB is need inside Payload
+=C2=A0 @retval FALSE If HOB is needn't inside Payload
+**/
+BOOLEAN
+IsHobNeed (
+=C2=A0 EFI_PEI_HOB_POINTERS=C2=A0 Hob
+=C2=A0 );
+
+VOID
+EFIAPI
+ProcessLibraryConstructorList (
+=C2=A0 VOID
+=C2=A0 );
+
=C2=A0/**
=C2=A0 =C2=A0Find the first substring.
=C2=A0 =C2=A0@param=C2=A0 String=C2=A0 =C2=A0 Point to the string where to = find the substring.
@@ -191,187 +274,6 @@ FixUpPcdDatabase (
=C2=A0 =C2=A0return EFI_SUCCESS;
=C2=A0}

-/**
-=C2=A0 Add HOB into HOB list
-=C2=A0 @param[in]=C2=A0 Hob=C2=A0 =C2=A0 The HOB to be added into the HOB = list.
-**/
-VOID
-AddNewHob (
-=C2=A0 IN EFI_PEI_HOB_POINTERS=C2=A0 *Hob
-=C2=A0 )
-{
-=C2=A0 EFI_PEI_HOB_POINTERS=C2=A0 NewHob;
-
-=C2=A0 if (Hob->Raw =3D=3D NULL) {
-=C2=A0 =C2=A0 return;
-=C2=A0 }
-
-=C2=A0 NewHob.Header =3D CreateHob (Hob->Header->HobType, Hob->He= ader->HobLength);
-=C2=A0 ASSERT (NewHob.Header !=3D NULL);
-=C2=A0 if (NewHob.Header =3D=3D NULL) {
-=C2=A0 =C2=A0 return;
-=C2=A0 }
-
-=C2=A0 CopyMem (NewHob.Header + 1, Hob->Header + 1, Hob->Header->= HobLength - sizeof (EFI_HOB_GENERIC_HEADER));
-}
-
-/**
-=C2=A0 Found the Resource Descriptor HOB that contains a range (Base, Top)=
-=C2=A0 @param[in] HobList=C2=A0 =C2=A0 Hob start address
-=C2=A0 @param[in] Base=C2=A0 =C2=A0 =C2=A0 =C2=A0Memory start address
-=C2=A0 @param[in] Top=C2=A0 =C2=A0 =C2=A0 =C2=A0 Memory end address.
-=C2=A0 @retval=C2=A0 =C2=A0 =C2=A0The pointer to the Resource Descriptor H= OB.
-**/
-EFI_HOB_RESOURCE_DESCRIPTOR *
-FindResourceDescriptorByRange (
-=C2=A0 IN VOID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 *HobList,
-=C2=A0 IN EFI_PHYSICAL_ADDRESS=C2=A0 Base,
-=C2=A0 IN EFI_PHYSICAL_ADDRESS=C2=A0 Top
-=C2=A0 )
-{
-=C2=A0 EFI_PEI_HOB_POINTERS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Hob;
-=C2=A0 EFI_HOB_RESOURCE_DESCRIPTOR=C2=A0 *ResourceHob;
-
-=C2=A0 for (Hob.Raw =3D (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = =3D GET_NEXT_HOB (Hob)) {
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 // Skip all HOBs except Resource Descriptor HOBs
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 if (GET_HOB_TYPE (Hob) !=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR= ) {
-=C2=A0 =C2=A0 =C2=A0 continue;
-=C2=A0 =C2=A0 }
-
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 // Skip Resource Descriptor HOBs that do not describe tested= system memory
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 ResourceHob =3D Hob.ResourceDescriptor;
-=C2=A0 =C2=A0 if (ResourceHob->ResourceType !=3D EFI_RESOURCE_SYSTEM_ME= MORY) {
-=C2=A0 =C2=A0 =C2=A0 continue;
-=C2=A0 =C2=A0 }
-
-=C2=A0 =C2=A0 if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUT= E_MASK) !=3D TESTED_MEMORY_ATTRIBUTES) {
-=C2=A0 =C2=A0 =C2=A0 continue;
-=C2=A0 =C2=A0 }
-
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 // Skip Resource Descriptor HOBs that do not contain the PHI= T range EfiFreeMemoryBottom..EfiFreeMemoryTop
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 if (Base < ResourceHob->PhysicalStart) {
-=C2=A0 =C2=A0 =C2=A0 continue;
-=C2=A0 =C2=A0 }
-
-=C2=A0 =C2=A0 if (Top > (ResourceHob->PhysicalStart + ResourceHob-&g= t;ResourceLength)) {
-=C2=A0 =C2=A0 =C2=A0 continue;
-=C2=A0 =C2=A0 }
-
-=C2=A0 =C2=A0 return ResourceHob;
-=C2=A0 }
-
-=C2=A0 return NULL;
-}
-
-/**
-=C2=A0 Find the highest below 4G memory resource descriptor, except the in= put Resource Descriptor.
-=C2=A0 @param[in] HobList=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0Hob start address
-=C2=A0 @param[in] MinimalNeededSize=C2=A0 =C2=A0 =C2=A0 =C2=A0Minimal need= ed size.
-=C2=A0 @param[in] ExceptResourceHob=C2=A0 =C2=A0 =C2=A0 =C2=A0Ignore this = Resource Descriptor.
-=C2=A0 @retval=C2=A0 =C2=A0 =C2=A0The pointer to the Resource Descriptor H= OB.
-**/
-EFI_HOB_RESOURCE_DESCRIPTOR *
-FindAnotherHighestBelow4GResourceDescriptor (
-=C2=A0 IN VOID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*HobList,
-=C2=A0 IN UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 MinimalNeededSize,
-=C2=A0 IN EFI_HOB_RESOURCE_DESCRIPTOR=C2=A0 *ExceptResourceHob
-=C2=A0 )
-{
-=C2=A0 EFI_PEI_HOB_POINTERS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Hob;
-=C2=A0 EFI_HOB_RESOURCE_DESCRIPTOR=C2=A0 *ResourceHob;
-=C2=A0 EFI_HOB_RESOURCE_DESCRIPTOR=C2=A0 *ReturnResourceHob;
-
-=C2=A0 ReturnResourceHob =3D NULL;
-
-=C2=A0 for (Hob.Raw =3D (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = =3D GET_NEXT_HOB (Hob)) {
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 // Skip all HOBs except Resource Descriptor HOBs
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 if (GET_HOB_TYPE (Hob) !=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR= ) {
-=C2=A0 =C2=A0 =C2=A0 continue;
-=C2=A0 =C2=A0 }
-
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 // Skip Resource Descriptor HOBs that do not describe tested= system memory
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 ResourceHob =3D Hob.ResourceDescriptor;
-=C2=A0 =C2=A0 if (ResourceHob->ResourceType !=3D EFI_RESOURCE_SYSTEM_ME= MORY) {
-=C2=A0 =C2=A0 =C2=A0 continue;
-=C2=A0 =C2=A0 }
-
-=C2=A0 =C2=A0 if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUT= E_MASK) !=3D TESTED_MEMORY_ATTRIBUTES) {
-=C2=A0 =C2=A0 =C2=A0 continue;
-=C2=A0 =C2=A0 }
-
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 // Skip if the Resource Descriptor HOB equals to ExceptResou= rceHob
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 if (ResourceHob =3D=3D ExceptResourceHob) {
-=C2=A0 =C2=A0 =C2=A0 continue;
-=C2=A0 =C2=A0 }
-
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 // Skip Resource Descriptor HOBs that are beyond 4G
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 if ((ResourceHob->PhysicalStart + ResourceHob->Resourc= eLength) > BASE_4GB) {
-=C2=A0 =C2=A0 =C2=A0 continue;
-=C2=A0 =C2=A0 }
-
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 // Skip Resource Descriptor HOBs that are too small
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 if (ResourceHob->ResourceLength < MinimalNeededSize) {=
-=C2=A0 =C2=A0 =C2=A0 continue;
-=C2=A0 =C2=A0 }
-
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 // Return the topest Resource Descriptor
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 if (ReturnResourceHob =3D=3D NULL) {
-=C2=A0 =C2=A0 =C2=A0 ReturnResourceHob =3D ResourceHob;
-=C2=A0 =C2=A0 } else {
-=C2=A0 =C2=A0 =C2=A0 if (ReturnResourceHob->PhysicalStart < Resource= Hob->PhysicalStart) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 ReturnResourceHob =3D ResourceHob;
-=C2=A0 =C2=A0 =C2=A0 }
-=C2=A0 =C2=A0 }
-=C2=A0 }
-
-=C2=A0 return ReturnResourceHob;
-}
-
-/**
-=C2=A0 Check the HOB and decide if it is need inside Payload
-=C2=A0 Payload maintainer may make decision which HOB is need or needn'= ;t
-=C2=A0 Then add the check logic in the function.
-=C2=A0 @param[in] Hob The HOB to check
-=C2=A0 @retval TRUE=C2=A0 If HOB is need inside Payload
-=C2=A0 @retval FALSE If HOB is needn't inside Payload
-**/
-BOOLEAN
-IsHobNeed (
-=C2=A0 EFI_PEI_HOB_POINTERS=C2=A0 Hob
-=C2=A0 )
-{
-=C2=A0 if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_HANDOFF) {
-=C2=A0 =C2=A0 return FALSE;
-=C2=A0 }
-
-=C2=A0 if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_MEMORY_ALLOCATION) {=
-=C2=A0 =C2=A0 if (CompareGuid (&Hob.MemoryAllocationModule->MemoryA= llocationHeader.Name, &gEfiHobMemoryAllocModuleGuid)) {
-=C2=A0 =C2=A0 =C2=A0 return FALSE;
-=C2=A0 =C2=A0 }
-=C2=A0 }
-
-=C2=A0 // Arrive here mean the HOB is need
-=C2=A0 return TRUE;
-}
-
=C2=A0/**
=C2=A0 =C2=A0It will build Fv HOBs based on information from bootloaders. =C2=A0 =C2=A0@param[out] DxeFv=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 The pointe= r to the DXE FV in memory.
@@ -409,21 +311,25 @@ BuildFitLoadablesFvHob (

=C2=A0 =C2=A0Status =3D FdtCheckHeader (Fdt);
=C2=A0 =C2=A0if (EFI_ERROR (Status)) {
+=C2=A0 =C2=A0 DEBUG ((DEBUG_INFO, "FdtCheckHeader UPSUPPORTED\n"= ));
=C2=A0 =C2=A0 =C2=A0return EFI_UNSUPPORTED;
=C2=A0 =C2=A0}

=C2=A0 =C2=A0ConfigNode =3D FdtSubnodeOffsetNameLen (Fdt, 0, "configur= ations", (INT32)AsciiStrLen ("configurations"));
=C2=A0 =C2=A0if (ConfigNode <=3D 0) {
+=C2=A0 =C2=A0 DEBUG ((DEBUG_INFO, "BuildFitLoadablesFvHob configurati= ons EFI_NOT_FOUND\n"));
=C2=A0 =C2=A0 =C2=A0return EFI_NOT_FOUND;
=C2=A0 =C2=A0}

=C2=A0 =C2=A0Config1Node =3D FdtSubnodeOffsetNameLen (Fdt, ConfigNode, &quo= t;conf-1", (INT32)AsciiStrLen ("conf-1"));
=C2=A0 =C2=A0if (Config1Node <=3D 0) {
+=C2=A0 =C2=A0 DEBUG ((DEBUG_INFO, "BuildFitLoadablesFvHob conf-1 EFI_= NOT_FOUND\n"));
=C2=A0 =C2=A0 =C2=A0return EFI_NOT_FOUND;
=C2=A0 =C2=A0}

=C2=A0 =C2=A0ImageNode =3D FdtSubnodeOffsetNameLen (Fdt, 0, "images&qu= ot;, (INT32)AsciiStrLen ("images"));
=C2=A0 =C2=A0if (ImageNode <=3D 0) {
+=C2=A0 =C2=A0 DEBUG ((DEBUG_INFO, "BuildFitLoadablesFvHob images EFI_= NOT_FOUND\n"));
=C2=A0 =C2=A0 =C2=A0return EFI_NOT_FOUND;
=C2=A0 =C2=A0}

@@ -467,31 +373,25 @@ BuildFitLoadablesFvHob (
=C2=A0}

=C2=A0/**
-=C2=A0 It will build HOBs based on information from bootloaders.
-=C2=A0 @param[in]=C2=A0 BootloaderParameter=C2=A0 =C2=A0The starting memor= y address of bootloader parameter block.
-=C2=A0 @param[out] DxeFv=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0The pointer to the DXE FV in memory.
-=C2=A0 @retval EFI_SUCCESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 If it completed succ= essfully.
-=C2=A0 @retval Others=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0If it= failed to build required HOBs.
+ *
+=C2=A0 Create new HOB for new HOB list
+
+=C2=A0 @param[in]=C2=A0 BootloaderParameter=C2=A0 The HOB to be added into= the HOB list.
=C2=A0**/
-EFI_STATUS
-BuildHobs (
-=C2=A0 IN=C2=A0 UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0BootloaderParameter,
-=C2=A0 OUT EFI_FIRMWARE_VOLUME_HEADER=C2=A0 **DxeFv
+VOID
+CreatNewHobForHoblist (
+=C2=A0 IN UINTN=C2=A0 BootloaderParameter
=C2=A0 =C2=A0)
=C2=A0{
-=C2=A0 EFI_PEI_HOB_POINTERS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Hob;
-=C2=A0 UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0MinimalNeededSize;
-=C2=A0 EFI_PHYSICAL_ADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FreeMemoryBo= ttom;
-=C2=A0 EFI_PHYSICAL_ADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FreeMemoryTo= p;
-=C2=A0 EFI_PHYSICAL_ADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MemoryBottom= ;
-=C2=A0 EFI_PHYSICAL_ADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MemoryTop; -=C2=A0 EFI_HOB_RESOURCE_DESCRIPTOR=C2=A0 =C2=A0*PhitResourceHob;
-=C2=A0 EFI_HOB_RESOURCE_DESCRIPTOR=C2=A0 =C2=A0*ResourceHob;
-=C2=A0 UINT8=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0*GuidHob;
-=C2=A0 EFI_HOB_FIRMWARE_VOLUME=C2=A0 =C2=A0 =C2=A0 =C2=A0*FvHob;
-=C2=A0 UNIVERSAL_PAYLOAD_ACPI_TABLE=C2=A0 *AcpiTable;
-=C2=A0 ACPI_BOARD_INFO=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0*AcpiBoardInfo;
-=C2=A0 EFI_HOB_HANDOFF_INFO_TABLE=C2=A0 =C2=A0 *HobInfo;
+=C2=A0 EFI_PEI_HOB_POINTERS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Hob;
+=C2=A0 UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 MinimalNeededSize;
+=C2=A0 EFI_PHYSICAL_ADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0FreeMemoryBot= tom;
+=C2=A0 EFI_PHYSICAL_ADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0FreeMemoryTop= ;
+=C2=A0 EFI_PHYSICAL_ADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0MemoryBottom;=
+=C2=A0 EFI_PHYSICAL_ADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0MemoryTop; +=C2=A0 EFI_HOB_RESOURCE_DESCRIPTOR=C2=A0 *PhitResourceHob;
+=C2=A0 EFI_HOB_RESOURCE_DESCRIPTOR=C2=A0 *ResourceHob;
+=C2=A0 EFI_HOB_HANDOFF_INFO_TABLE=C2=A0 =C2=A0*HobInfo;

=C2=A0 =C2=A0Hob.Raw=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D (UINT8 *)B= ootloaderParameter;
=C2=A0 =C2=A0MinimalNeededSize =3D FixedPcdGet32 (PcdSystemMemoryUefiRegion= Size);
@@ -512,7 +412,7 @@ BuildHobs (
=C2=A0 =C2=A0 =C2=A0//
=C2=A0 =C2=A0 =C2=A0ResourceHob =3D FindAnotherHighestBelow4GResourceDescri= ptor (Hob.Raw, MinimalNeededSize, NULL);
=C2=A0 =C2=A0 =C2=A0if (ResourceHob =3D=3D NULL) {
-=C2=A0 =C2=A0 =C2=A0 return EFI_NOT_FOUND;
+=C2=A0 =C2=A0 =C2=A0 return;
=C2=A0 =C2=A0 =C2=A0}

=C2=A0 =C2=A0 =C2=A0MemoryBottom=C2=A0 =C2=A0 =C2=A0=3D ResourceHob->Phy= sicalStart + ResourceHob->ResourceLength - MinimalNeededSize;
@@ -542,7 +442,7 @@ BuildHobs (
=C2=A0 =C2=A0 =C2=A0//
=C2=A0 =C2=A0 =C2=A0ResourceHob =3D FindAnotherHighestBelow4GResourceDescri= ptor (Hob.Raw, MinimalNeededSize, PhitResourceHob);
=C2=A0 =C2=A0 =C2=A0if (ResourceHob =3D=3D NULL) {
-=C2=A0 =C2=A0 =C2=A0 return EFI_NOT_FOUND;
+=C2=A0 =C2=A0 =C2=A0 return;
=C2=A0 =C2=A0 =C2=A0}

=C2=A0 =C2=A0 =C2=A0MemoryBottom=C2=A0 =C2=A0 =C2=A0=3D ResourceHob->Phy= sicalStart + ResourceHob->ResourceLength - MinimalNeededSize;
@@ -553,14 +453,7 @@ BuildHobs (

=C2=A0 =C2=A0HobInfo=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D HobConstru= ctor ((VOID *)(UINTN)MemoryBottom, (VOID *)(UINTN)MemoryTop, (VOID *)(UINTN= )FreeMemoryBottom, (VOID *)(UINTN)FreeMemoryTop);
=C2=A0 =C2=A0HobInfo->BootMode =3D Hob.HandoffInformationTable->BootM= ode;
-=C2=A0 //
-=C2=A0 // From now on, mHobList will point to the new Hob range.
-=C2=A0 //

-=C2=A0 //
-=C2=A0 // Create an empty FvHob for the DXE FV that contains DXE core.
-=C2=A0 //
-=C2=A0 BuildFvHob ((EFI_PHYSICAL_ADDRESS)0, 0);
=C2=A0 =C2=A0//
=C2=A0 =C2=A0// Since payload created new Hob, move all hobs except PHIT fr= om boot loader hob list.
=C2=A0 =C2=A0//
@@ -573,7 +466,57 @@ BuildHobs (
=C2=A0 =C2=A0 =C2=A0Hob.Raw =3D GET_NEXT_HOB (Hob);
=C2=A0 =C2=A0}

-=C2=A0 BuildFitLoadablesFvHob (DxeFv);
+=C2=A0 return;
+}
+
+/**
+=C2=A0 It will build HOBs based on information from bootloaders.
+=C2=A0 @param[in]=C2=A0 NewFdtBase=C2=A0 =C2=A0 =C2=A0The pointer to New F= dtBase.
+=C2=A0 @param[out] DxeFv=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 The pointer to = the DXE FV in memory.
+=C2=A0 @retval EFI_SUCCESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 If it completed succ= essfully.
+=C2=A0 @retval Others=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0If it= failed to build required HOBs.
+**/
+EFI_STATUS
+FitBuildHobs (
+=C2=A0 IN=C2=A0 UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0NewFdtBase,
+=C2=A0 OUT EFI_FIRMWARE_VOLUME_HEADER=C2=A0 **DxeFv
+=C2=A0 )
+{
+=C2=A0 UINT8=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 *GuidHob;
+=C2=A0 UINT32=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0FdtSize;
+=C2=A0 EFI_HOB_FIRMWARE_VOLUME=C2=A0 =C2=A0 =C2=A0 =C2=A0 *FvHob;
+=C2=A0 UNIVERSAL_PAYLOAD_ACPI_TABLE=C2=A0 =C2=A0*AcpiTable;
+=C2=A0 ACPI_BOARD_INFO=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 *AcpiBoardInfo;
+=C2=A0 UNIVERSAL_PAYLOAD_DEVICE_TREE=C2=A0 *Fdt;
+
+=C2=A0 if (FixedPcdGetBool (PcdHandOffFdtEnable)) {
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 // Back up FDT in Reserved memory region
+=C2=A0 =C2=A0 //
+
+=C2=A0 =C2=A0 GuidHob =3D GetFirstGuidHob (&gUniversalPayloadDeviceTre= eGuid);
+=C2=A0 =C2=A0 if (GuidHob !=3D NULL) {
+=C2=A0 =C2=A0 =C2=A0 Fdt =3D=C2=A0 (UNIVERSAL_PAYLOAD_DEVICE_TREE *)GET_GU= ID_HOB_DATA (GuidHob);
+=C2=A0 =C2=A0 =C2=A0 if (Fdt !=3D NULL) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 DEBUG ((DEBUG_INFO, "Update FDT base to r= eserved memory\n"));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 FdtSize =3D 4 * EFI_PAGE_SIZE;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 CopyMem ((VOID *)NewFdtBase, (VOID *)(Fdt->= DeviceTreeAddress), FdtSize);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Fdt->DeviceTreeAddress =3D NewFdtBase;
+=C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 }
+=C2=A0 }
+
+=C2=A0 //
+=C2=A0 // To create Memory Type Information HOB
+=C2=A0 //
+=C2=A0 GuidHob =3D GetFirstGuidHob (&gEfiMemoryTypeInformationGuid); +=C2=A0 if (GuidHob =3D=3D NULL) {
+=C2=A0 =C2=A0 BuildGuidDataHob (
+=C2=A0 =C2=A0 =C2=A0 &gEfiMemoryTypeInformationGuid,
+=C2=A0 =C2=A0 =C2=A0 mDefaultMemoryTypeInformation,
+=C2=A0 =C2=A0 =C2=A0 sizeof (mDefaultMemoryTypeInformation)
+=C2=A0 =C2=A0 =C2=A0 );
+=C2=A0 }

=C2=A0 =C2=A0//
=C2=A0 =C2=A0// Create guid hob for acpi board information
@@ -588,6 +531,12 @@ BuildHobs (
=C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0}

+=C2=A0 //
+=C2=A0 // Create an empty FvHob for the DXE FV that contains DXE core.
+=C2=A0 //
+=C2=A0 BuildFvHob ((EFI_PHYSICAL_ADDRESS)0, 0);
+
+=C2=A0 BuildFitLoadablesFvHob (DxeFv);
=C2=A0 =C2=A0//
=C2=A0 =C2=A0// Update DXE FV information to first fv hob in the hob list, = which
=C2=A0 =C2=A0// is the empty FvHob created before.
@@ -600,12 +549,12 @@ BuildHobs (

=C2=A0/**
=C2=A0 =C2=A0Entry point to the C language phase of UEFI payload.
-=C2=A0 @param[in]=C2=A0 =C2=A0BootloaderParameter=C2=A0 =C2=A0 The startin= g address of bootloader parameter block.
+=C2=A0 @param[in]=C2=A0 =C2=A0BootloaderParameter=C2=A0 The starting addre= ss of FDT .
=C2=A0 =C2=A0@retval=C2=A0 =C2=A0 =C2=A0 It will not return if SUCCESS, and= return error when passing bootloader parameter.
=C2=A0**/
=C2=A0EFI_STATUS
=C2=A0EFIAPI
-_ModuleEntryPoint (
+FitUplEntryPoint (
=C2=A0 =C2=A0IN UINTN=C2=A0 BootloaderParameter
=C2=A0 =C2=A0)
=C2=A0{
@@ -613,14 +562,46 @@ _ModuleEntryPoint (
=C2=A0 =C2=A0PHYSICAL_ADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 DxeC= oreEntryPoint;
=C2=A0 =C2=A0EFI_PEI_HOB_POINTERS=C2=A0 =C2=A0 =C2=A0 =C2=A0 Hob;
=C2=A0 =C2=A0EFI_FIRMWARE_VOLUME_HEADER=C2=A0 *DxeFv;
+=C2=A0 PHYSICAL_ADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 HobListPt= r;
+=C2=A0 VOID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 *FdtBase;
+=C2=A0 VOID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 *FdtBaseResvd;

-=C2=A0 mHobList =3D (VOID *)BootloaderParameter;
-=C2=A0 DxeFv=C2=A0 =C2=A0 =3D NULL;
+=C2=A0 if (FixedPcdGetBool (PcdHandOffFdtEnable)) {
+=C2=A0 =C2=A0 mHobList =3D (VOID *)NULL;
+=C2=A0 } else {
+=C2=A0 =C2=A0 mHobList =3D (VOID *)BootloaderParameter;
+=C2=A0 }
+
+=C2=A0 DxeFv =3D NULL;
=C2=A0 =C2=A0// Call constructor for all libraries
=C2=A0 =C2=A0ProcessLibraryConstructorList ();

=C2=A0 =C2=A0DEBUG ((DEBUG_INFO, "Entering Universal Payload...\n"= ;));
=C2=A0 =C2=A0DEBUG ((DEBUG_INFO, "sizeof(UINTN) =3D 0x%x\n", size= of (UINTN)));
+=C2=A0 DEBUG ((DEBUG_INFO, "BootloaderParameter =3D 0x%x\n", Boo= tloaderParameter));
+
+=C2=A0 DEBUG ((DEBUG_INFO, "Start init Hobs...\n"));
+=C2=A0 HobListPtr =3D UplInitHob ((VOID *)BootloaderParameter);
+
+=C2=A0 //
+=C2=A0 // Found hob list node
+=C2=A0 //
+=C2=A0 if (HobListPtr !=3D 0) {
+=C2=A0 =C2=A0 FdtBase =3D (VOID *)BootloaderParameter;
+=C2=A0 =C2=A0 if (FdtCheckHeader (FdtBase) =3D=3D 0) {
+=C2=A0 =C2=A0 =C2=A0 CustomFdtNodeParser ((VOID *)FdtBase, (VOID *)HobList= Ptr);
+=C2=A0 =C2=A0 } else {
+=C2=A0 =C2=A0 =C2=A0 CreatNewHobForHoblist (BootloaderParameter);
+=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 FdtBaseResvd =3D PayloadAllocatePages (4, EfiReservedMemoryT= ype);
+
+=C2=A0 =C2=A0 // Build HOB based on information from Bootloader
+=C2=A0 =C2=A0 Status =3D FitBuildHobs ((UINTN)FdtBaseResvd, &DxeFv); +=C2=A0 }
+
+=C2=A0 // Call constructor for all libraries again since hobs were built +=C2=A0 ProcessLibraryConstructorList ();

=C2=A0 =C2=A0DEBUG_CODE (
=C2=A0 =C2=A0 =C2=A0//
@@ -629,23 +610,10 @@ _ModuleEntryPoint (
=C2=A0 =C2=A0 =C2=A0PrintHob (mHobList);
=C2=A0 =C2=A0 =C2=A0);

-=C2=A0 // Initialize floating point operating environment to be compliant = with UEFI spec.
-=C2=A0 InitializeFloatingPointUnits ();
-
-=C2=A0 // Build HOB based on information from Bootloader
-=C2=A0 Status =3D BuildHobs (BootloaderParameter, &DxeFv);
-=C2=A0 ASSERT_EFI_ERROR (Status);
-
=C2=A0 =C2=A0FixUpPcdDatabase (DxeFv);
=C2=A0 =C2=A0Status =3D UniversalLoadDxeCore (DxeFv, &DxeCoreEntryPoint= );
=C2=A0 =C2=A0ASSERT_EFI_ERROR (Status);

-=C2=A0 //
-=C2=A0 // Mask off all legacy 8259 interrupt sources
-=C2=A0 //
-=C2=A0 IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
-=C2=A0 IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
-
=C2=A0 =C2=A0Hob.HandoffInformationTable =3D (EFI_HOB_HANDOFF_INFO_TABLE *)= GetFirstHob (EFI_HOB_TYPE_HANDOFF);
=C2=A0 =C2=A0HandOffToDxeCore (DxeCoreEntryPoint, Hob);

diff --git a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c b/UefiPaylo= adPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
index 61a9f01ec9e7..cf9c03a9a8e9 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
@@ -15,12 +15,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
=C2=A0#include <Library/MemoryAllocationLib.h>
=C2=A0#include <Library/PcdLib.h>
=C2=A0#include <Library/HobLib.h>
+#include <Library/FdtLib.h>
=C2=A0#include "VirtualMemory.h"
=C2=A0#include "UefiPayloadEntry.h"

=C2=A0#define STACK_SIZE=C2=A0 =C2=A0 =C2=A0 =C2=A00x20000
=C2=A0#define IDT_ENTRY_COUNT=C2=A0 32

+extern VOID=C2=A0 *mHobList;
+
=C2=A0typedef struct _X64_IDT_TABLE {
=C2=A0 =C2=A0//
=C2=A0 =C2=A0// Reserved 4 bytes preceding PeiService and IdtTable,
@@ -268,6 +271,15 @@ HandOffToDxeCore (
=C2=A0 =C2=A0UINT32=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0Index;
=C2=A0 =C2=A0X64_IDT_TABLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *IdtTab= leForX64;

+=C2=A0 // Initialize floating point operating environment to be compliant = with UEFI spec.
+=C2=A0 InitializeFloatingPointUnits ();
+
+=C2=A0 //
+=C2=A0 // Mask off all legacy 8259 interrupt sources
+=C2=A0 //
+=C2=A0 IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
+=C2=A0 IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
+
=C2=A0 =C2=A0//
=C2=A0 =C2=A0// Clear page 0 and mark it as allocated if NULL pointer detec= tion is enabled.
=C2=A0 =C2=A0//
diff --git a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c b/UefiPaylo= adPkg/UefiPayloadEntry/Ia32/DxeLoadFuncFit.c
similarity index 90%
copy from UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
copy to UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFuncFit.c
index 61a9f01ec9e7..439d5bee0b8c 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFuncFit.c
@@ -1,10 +1,8 @@
=C2=A0/** @file
=C2=A0 =C2=A0Ia32-specific functionality for DxeLoad.

-Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR&g= t;
-Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
-
-SPDX-License-Identifier: BSD-2-Clause-Patent
+=C2=A0 Copyright (c) 2024, Intel Corporation. All rights reserved.<BR&g= t;
+=C2=A0 SPDX-License-Identifier: BSD-2-Clause-Patent

=C2=A0**/

@@ -15,12 +13,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
=C2=A0#include <Library/MemoryAllocationLib.h>
=C2=A0#include <Library/PcdLib.h>
=C2=A0#include <Library/HobLib.h>
+#include <Library/FdtLib.h>
=C2=A0#include "VirtualMemory.h"
=C2=A0#include "UefiPayloadEntry.h"

=C2=A0#define STACK_SIZE=C2=A0 =C2=A0 =C2=A0 =C2=A00x20000
=C2=A0#define IDT_ENTRY_COUNT=C2=A0 32

+extern VOID=C2=A0 *mHobList;
+
=C2=A0typedef struct _X64_IDT_TABLE {
=C2=A0 =C2=A0//
=C2=A0 =C2=A0// Reserved 4 bytes preceding PeiService and IdtTable,
@@ -268,6 +269,15 @@ HandOffToDxeCore (
=C2=A0 =C2=A0UINT32=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0Index;
=C2=A0 =C2=A0X64_IDT_TABLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *IdtTab= leForX64;

+=C2=A0 // Initialize floating point operating environment to be compliant = with UEFI spec.
+=C2=A0 InitializeFloatingPointUnits ();
+
+=C2=A0 //
+=C2=A0 // Mask off all legacy 8259 interrupt sources
+=C2=A0 //
+=C2=A0 IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
+=C2=A0 IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
+
=C2=A0 =C2=A0//
=C2=A0 =C2=A0// Clear page 0 and mark it as allocated if NULL pointer detec= tion is enabled.
=C2=A0 =C2=A0//
@@ -379,3 +389,17 @@ HandOffToDxeCore (
=C2=A0 =C2=A0 =C2=A0CpuDeadLoop ();
=C2=A0 =C2=A0}
=C2=A0}
+
+/**
+=C2=A0 Entry point to the C language phase of UEFI payload.
+=C2=A0 @param[in]=C2=A0 =C2=A0BootloaderParameter=C2=A0 =C2=A0 The startin= g address of bootloader parameter block.
+=C2=A0 @retval=C2=A0 =C2=A0 =C2=A0 It will not return if SUCCESS, and retu= rn error when passing bootloader parameter.
+**/
+EFI_STATUS
+EFIAPI
+_ModuleEntryPoint (
+=C2=A0 IN UINTN=C2=A0 BootloaderParameter
+=C2=A0 )
+{
+=C2=A0 return FitUplEntryPoint (BootloaderParameter);
+}
diff --git a/UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c b/UefiPaylo= adPkg/UefiPayloadEntry/MemoryAllocation.c
index 83936ae26e68..36edca81f997 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c
@@ -10,6 +10,56 @@

=C2=A0#include "UefiPayloadEntry.h"

+/**
+=C2=A0 Allocates one or more pages of type EfiBootServicesData.
+
+=C2=A0 Allocates the number of pages of MemoryType and returns a pointer t= o the
+=C2=A0 allocated buffer.=C2=A0 The buffer returned is aligned on a 4KB bou= ndary.
+=C2=A0 If Pages is 0, then NULL is returned.
+=C2=A0 If there is not enough memory availble to satisfy the request, then= NULL
+=C2=A0 is returned.
+
+=C2=A0 @param=C2=A0 =C2=A0Pages=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0The number of 4 KB pages to allocate.
+=C2=A0 @param=C2=A0 =C2=A0MemoryType=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 The MemoryType
+=C2=A0 @return=C2=A0 A pointer to the allocated buffer or NULL if allocati= on fails.
+**/
+VOID *
+EFIAPI
+PayloadAllocatePages (
+=C2=A0 IN UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Pages,
+=C2=A0 IN EFI_MEMORY_TYPE=C2=A0 MemoryType
+=C2=A0 )
+{
+=C2=A0 EFI_PEI_HOB_POINTERS=C2=A0 =C2=A0 =C2=A0 =C2=A0 Hob;
+=C2=A0 EFI_PHYSICAL_ADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 Offset;
+=C2=A0 EFI_HOB_HANDOFF_INFO_TABLE=C2=A0 *HobTable;
+
+=C2=A0 Hob.Raw=C2=A0 =3D GetHobList ();
+=C2=A0 HobTable =3D Hob.HandoffInformationTable;
+
+=C2=A0 if (Pages =3D=3D 0) {
+=C2=A0 =C2=A0 return NULL;
+=C2=A0 }
+
+=C2=A0 // Make sure allocation address is page alligned.
+=C2=A0 Offset =3D HobTable->EfiFreeMemoryTop & EFI_PAGE_MASK;
+=C2=A0 if (Offset !=3D 0) {
+=C2=A0 =C2=A0 HobTable->EfiFreeMemoryTop -=3D Offset;
+=C2=A0 }
+
+=C2=A0 //
+=C2=A0 // Check available memory for the allocation
+=C2=A0 //
+=C2=A0 if (HobTable->EfiFreeMemoryTop - ((Pages * EFI_PAGE_SIZE) + size= of (EFI_HOB_MEMORY_ALLOCATION)) < HobTable->EfiFreeMemoryBottom) { +=C2=A0 =C2=A0 return NULL;
+=C2=A0 }
+
+=C2=A0 HobTable->EfiFreeMemoryTop -=3D Pages * EFI_PAGE_SIZE;
+=C2=A0 BuildMemoryAllocationHob (HobTable->EfiFreeMemoryTop, Pages * EF= I_PAGE_SIZE, MemoryType);
+
+=C2=A0 return (VOID *)(UINTN)HobTable->EfiFreeMemoryTop;
+}
+
=C2=A0/**
=C2=A0 =C2=A0Allocates one or more pages of type EfiBootServicesData.

diff --git a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c b/UefiPayloadPkg/Ue= fiPayloadEntry/PrintHob.c
index b63e93c07ec2..153d1b00f637 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
@@ -169,13 +169,13 @@ PrintMemoryAllocationHob (
=C2=A0}

=C2=A0/**
-=C2=A0 Print the information in Resource Discriptor Hob.
+=C2=A0 Print the information in Resource Descriptor Hob.
=C2=A0 =C2=A0@param[in]=C2=A0 HobStart=C2=A0 =C2=A0 =C2=A0 =C2=A0A pointer = to HOB of type EFI_HOB_TYPE_RESOURCE_DESCRIPTOR.
=C2=A0 =C2=A0@param[in]=C2=A0 HobLength=C2=A0 =C2=A0 =C2=A0 The Length in b= ytes of HOB of type EFI_HOB_TYPE_RESOURCE_DESCRIPTOR.
=C2=A0 =C2=A0@retval EFI_SUCCESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 If it completed= successfully.
=C2=A0**/
=C2=A0EFI_STATUS
-PrintResourceDiscriptorHob (
+PrintResourceDescriptorHob (
=C2=A0 =C2=A0IN=C2=A0 VOID=C2=A0 =C2=A0 *HobStart,
=C2=A0 =C2=A0IN=C2=A0 UINT16=C2=A0 HobLength
=C2=A0 =C2=A0)
@@ -620,7 +620,7 @@ PrintFv3Hob (
=C2=A0HOB_PRINT_HANDLER_TABLE=C2=A0 mHobHandles[] =3D {
=C2=A0 =C2=A0{ EFI_HOB_TYPE_HANDOFF,=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0"EFI_HOB_TYPE_HANDOFF",=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0PrintHandOffHob=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }= ,
=C2=A0 =C2=A0{ EFI_HOB_TYPE_MEMORY_ALLOCATION,=C2=A0 =C2=A0"EFI_HOB_TY= PE_MEMORY_ALLOCATION",=C2=A0 =C2=A0PrintMemoryAllocationHob=C2=A0 =C2= =A0},
-=C2=A0 { EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, "EFI_HOB_TYPE_RESOURCE_DES= CRIPTOR", PrintResourceDiscriptorHob },
+=C2=A0 { EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, "EFI_HOB_TYPE_RESOURCE_DES= CRIPTOR", PrintResourceDescriptorHob },
=C2=A0 =C2=A0{ EFI_HOB_TYPE_GUID_EXTENSION,=C2=A0 =C2=A0 =C2=A0 "EFI_H= OB_TYPE_GUID_EXTENSION",=C2=A0 =C2=A0 =C2=A0 PrintGuidHob=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0},
=C2=A0 =C2=A0{ EFI_HOB_TYPE_FV,=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 "EFI_HOB_TYPE_FV",=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 PrintFvHob=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0},
=C2=A0 =C2=A0{ EFI_HOB_TYPE_CPU,=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0"EFI_HOB_TYPE_CPU",=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0PrintCpuHob=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 },
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c b/Uefi= PayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
index f37c00fad774..5b864eeefe10 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -486,12 +486,6 @@ _ModuleEntryPoint (
=C2=A0 =C2=A0Status =3D UniversalLoadDxeCore (DxeFv, &DxeCoreEntryPoint= );
=C2=A0 =C2=A0ASSERT_EFI_ERROR (Status);

-=C2=A0 //
-=C2=A0 // Mask off all legacy 8259 interrupt sources
-=C2=A0 //
-=C2=A0 IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
-=C2=A0 IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
-
=C2=A0 =C2=A0Hob.HandoffInformationTable =3D (EFI_HOB_HANDOFF_INFO_TABLE *)= GetFirstHob (EFI_HOB_TYPE_HANDOFF);
=C2=A0 =C2=A0HandOffToDxeCore (DxeCoreEntryPoint, Hob);

diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c b/UefiPayloa= dPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
index 346e3feb0459..6c3603f12098 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
@@ -13,10 +13,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
=C2=A0#include <Library/MemoryAllocationLib.h>
=C2=A0#include <Library/PcdLib.h>
=C2=A0#include <Library/HobLib.h>
+#include <Library/FdtLib.h>
=C2=A0#include "X64/VirtualMemory.h"
=C2=A0#include "UefiPayloadEntry.h"
=C2=A0#define STACK_SIZE=C2=A0 0x20000

+extern VOID=C2=A0 *mHobList;
+
=C2=A0/**
=C2=A0 =C2=A0 Transfers control to DxeCore.

@@ -40,6 +43,15 @@ HandOffToDxeCore (
=C2=A0 =C2=A0VOID=C2=A0 =C2=A0*GhcbBase;
=C2=A0 =C2=A0UINTN=C2=A0 GhcbSize;

+=C2=A0 // Initialize floating point operating environment to be compliant = with UEFI spec.
+=C2=A0 InitializeFloatingPointUnits ();
+
+=C2=A0 //
+=C2=A0 // Mask off all legacy 8259 interrupt sources
+=C2=A0 //
+=C2=A0 IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
+=C2=A0 IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
+
=C2=A0 =C2=A0//
=C2=A0 =C2=A0// Clear page 0 and mark it as allocated if NULL pointer detec= tion is enabled.
=C2=A0 =C2=A0//
diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c b/UefiPayloa= dPkg/UefiPayloadEntry/X64/DxeLoadFuncFit.c
similarity index 74%
copy from UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
copy to UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFuncFit.c
index 346e3feb0459..35b52a911df3 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFuncFit.c
@@ -1,8 +1,8 @@
=C2=A0/** @file
=C2=A0 =C2=A0x64-specifc functionality for DxeLoad.

-Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR&g= t;
-SPDX-License-Identifier: BSD-2-Clause-Patent
+=C2=A0 Copyright (c) 2024, Intel Corporation. All rights reserved.<BR&g= t;
+=C2=A0 SPDX-License-Identifier: BSD-2-Clause-Patent

=C2=A0**/

@@ -13,10 +13,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
=C2=A0#include <Library/MemoryAllocationLib.h>
=C2=A0#include <Library/PcdLib.h>
=C2=A0#include <Library/HobLib.h>
+#include <Library/FdtLib.h>
+#include <Library/PcdLib.h>
=C2=A0#include "X64/VirtualMemory.h"
=C2=A0#include "UefiPayloadEntry.h"
=C2=A0#define STACK_SIZE=C2=A0 0x20000

+extern VOID=C2=A0 *mHobList;
+
=C2=A0/**
=C2=A0 =C2=A0 Transfers control to DxeCore.

@@ -40,6 +44,15 @@ HandOffToDxeCore (
=C2=A0 =C2=A0VOID=C2=A0 =C2=A0*GhcbBase;
=C2=A0 =C2=A0UINTN=C2=A0 GhcbSize;

+=C2=A0 // Initialize floating point operating environment to be compliant = with UEFI spec.
+=C2=A0 InitializeFloatingPointUnits ();
+
+=C2=A0 //
+=C2=A0 // Mask off all legacy 8259 interrupt sources
+=C2=A0 //
+=C2=A0 IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
+=C2=A0 IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
+
=C2=A0 =C2=A0//
=C2=A0 =C2=A0// Clear page 0 and mark it as allocated if NULL pointer detec= tion is enabled.
=C2=A0 =C2=A0//
@@ -106,3 +119,17 @@ HandOffToDxeCore (
=C2=A0 =C2=A0 =C2=A0TopOfStack
=C2=A0 =C2=A0 =C2=A0);
=C2=A0}
+
+/**
+=C2=A0 Entry point to the C language phase of UEFI payload.
+=C2=A0 @param[in]=C2=A0 =C2=A0BootloaderParameter=C2=A0 =C2=A0 The startin= g address of bootloader parameter block.
+=C2=A0 @retval=C2=A0 =C2=A0 =C2=A0 It will not return if SUCCESS, and retu= rn error when passing bootloader parameter.
+**/
+EFI_STATUS
+EFIAPI
+_ModuleEntryPoint (
+=C2=A0 IN UINTN=C2=A0 BootloaderParameter
+=C2=A0 )
+{
+=C2=A0 return FitUplEntryPoint (BootloaderParameter);
+}
diff --git a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf b= /UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf
index b87a0989eee3..c87e674f7cbd 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf
@@ -30,13 +30,13 @@
=C2=A0[Sources.Ia32]
=C2=A0 =C2=A0X64/VirtualMemory.h
=C2=A0 =C2=A0X64/VirtualMemory.c
-=C2=A0 Ia32/DxeLoadFunc.c
+=C2=A0 Ia32/DxeLoadFuncFit.c
=C2=A0 =C2=A0Ia32/IdtVectorAsm.nasm

=C2=A0[Sources.X64]
=C2=A0 =C2=A0X64/VirtualMemory.h
=C2=A0 =C2=A0X64/VirtualMemory.c
-=C2=A0 X64/DxeLoadFunc.c
+=C2=A0 X64/DxeLoadFuncFit.c

=C2=A0[Packages]
=C2=A0 =C2=A0MdePkg/MdePkg.dec
@@ -54,6 +54,8 @@
=C2=A0 =C2=A0PeCoffLib
=C2=A0 =C2=A0CpuLib
=C2=A0 =C2=A0FdtLib
+=C2=A0 CustomFdtNodeParserLib
+=C2=A0 PcdLib

=C2=A0[Guids]
=C2=A0 =C2=A0gEfiMemoryTypeInformationGuid
@@ -71,6 +73,7 @@
=C2=A0 =C2=A0gUniversalPayloadAcpiTableGuid
=C2=A0 =C2=A0gUniversalPayloadPciRootBridgeInfoGuid
=C2=A0 =C2=A0gUniversalPayloadSmbios3TableGuid
+=C2=A0 gUniversalPayloadDeviceTreeGuid

=C2=A0[FeaturePcd.IA32]
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode=C2=A0= =C2=A0 =C2=A0 ## CONSUMES
@@ -78,7 +81,6 @@
=C2=A0[FeaturePcd.X64]
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables=C2=A0 = =C2=A0 =C2=A0 =C2=A0## CONSUMES

-
=C2=A0[Pcd.IA32,Pcd.X64]
=C2=A0 =C2=A0gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ## SOMETIMES= _CONSUMES
@@ -88,11 +90,19 @@
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0## CON= SUMES
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ## CONSUMES
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ## CONSUMES
-
=C2=A0 =C2=A0gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemBase
=C2=A0 =C2=A0gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize
=C2=A0 =C2=A0gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize -
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0## SOMETIMES_CONSUMES
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy = ## SOMETIMES_CONSUMES
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy=C2=A0 = =C2=A0 =C2=A0 =C2=A0## SOMETIMES_CONSUMES
+=C2=A0 gUefiPayloadPkgTokenSpaceGuid.PcdHandOffFdtEnable
+=C2=A0 gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS
+=C2=A0 gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
+=C2=A0 gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType +=C2=A0 gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData +=C2=A0 gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode +
+[BuildOptions]
+=C2=A0 MSFT:*_*_*_CC_FLAGS =3D /wd4244 /wd4305
+=C2=A0 GCC:*_*_*_CC_FLAGS=C2=A0 =3D -Wno-error=3Dpointer-to-int-cast -Wno-= error=3Dint-to-pointer-cast
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h b/UefiPaylo= adPkg/UefiPayloadEntry/UefiPayloadEntry.h
index 80ccc5072c55..09fce8dbcf35 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -35,6 +35,7 @@
=C2=A0#include <UniversalPayload/UniversalPayload.h>
=C2=A0#include <UniversalPayload/ExtraData.h>
=C2=A0#include <UniversalPayload/SerialPortInfo.h>
+#include <UniversalPayload/DeviceTree.h>
=C2=A0#include <Guid/PcdDataBaseSignatureGuid.h>

=C2=A0#define LEGACY_8259_MASK_REGISTER_MASTER=C2=A0 0x21
@@ -134,6 +135,31 @@ UniversalLoadDxeCore (
=C2=A0 =C2=A0OUT PHYSICAL_ADDRESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = *DxeCoreEntryPoint
=C2=A0 =C2=A0);

+/**
+=C2=A0 It will Parse FDT -node based on information.
+=C2=A0 @param[in]=C2=A0 FdtBase=C2=A0 =C2=A0The starting memory address of= FdtBase
+=C2=A0 @retval HobList=C2=A0 =C2=A0The base address of Hoblist.
+
+**/
+UINT64
+EFIAPI
+FdtNodeParser (
+=C2=A0 IN VOID=C2=A0 *FdtBase
+=C2=A0 );
+
+/**
+=C2=A0 It will Parse FDT -custom node based on information.
+=C2=A0 @param[in]=C2=A0 FdtBase The starting memory address of FdtBase
+=C2=A0 @param[in]=C2=A0 HostList The starting memory address of New Hob li= st.
+
+**/
+UINTN
+EFIAPI
+CustomFdtNodeParser (
+=C2=A0 IN VOID=C2=A0 *FdtBase,
+=C2=A0 IN VOID=C2=A0 *HostList
+=C2=A0 );
+
=C2=A0/**
=C2=A0 =C2=A0 Transfers control to DxeCore.

@@ -206,4 +232,46 @@ BuildHobFromAcpi (
=C2=A0 =C2=A0IN=C2=A0 =C2=A0UINT64=C2=A0 AcpiTableBase
=C2=A0 =C2=A0);

+/**
+=C2=A0 Allocates one or more pages .
+
+=C2=A0 Allocates the number of pages of MemoryType and returns a pointer t= o the
+=C2=A0 allocated buffer.=C2=A0 The buffer returned is aligned on a 4KB bou= ndary.
+=C2=A0 If Pages is 0, then NULL is returned.
+=C2=A0 If there is not enough memory availble to satisfy the request, then= NULL
+=C2=A0 is returned.
+
+=C2=A0 @param=C2=A0 =C2=A0Pages=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0The number of 4 KB pages to allocate.
+=C2=A0 @param=C2=A0 =C2=A0MemoryType=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 The Memorytype
+=C2=A0 @return=C2=A0 A pointer to the allocated buffer or NULL if allocati= on fails.
+**/
+VOID *
+EFIAPI
+PayloadAllocatePages (
+=C2=A0 IN UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Pages,
+=C2=A0 IN EFI_MEMORY_TYPE=C2=A0 MemoryType
+=C2=A0 );
+
+/**
+=C2=A0 Entry point to the C language phase of UEFI payload.
+=C2=A0 @param[in]=C2=A0 =C2=A0FdtPrt=C2=A0 The starting address of FDT . +=C2=A0 @retval=C2=A0 =C2=A0 =C2=A0 It will not return if SUCCESS, and retu= rn error when passing bootloader parameter.
+**/
+EFI_STATUS
+EFIAPI
+FitUplEntryPoint (
+=C2=A0 IN UINTN=C2=A0 BootloaderParameter
+=C2=A0 );
+
+/**
+=C2=A0 Entry point to the C language phase of UEFI payload.
+=C2=A0 @param[in]=C2=A0 =C2=A0BootloaderParameter=C2=A0 =C2=A0 The startin= g address of bootloader parameter block.
+=C2=A0 @retval=C2=A0 =C2=A0 =C2=A0 It will not return if SUCCESS, and retu= rn error when passing bootloader parameter.
+**/
+EFI_STATUS
+EFIAPI
+UplEntryPoint (
+=C2=A0 IN UINTN=C2=A0 BootloaderParameter
+=C2=A0 );
+
=C2=A0#endif
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf b/Ue= fiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
index a62da5c7059d..be91f7be2819 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
@@ -6,44 +6,37 @@
=C2=A0#=C2=A0 SPDX-License-Identifier: BSD-2-Clause-Patent
=C2=A0#
=C2=A0##
-
=C2=A0[Defines]
=C2=A0 =C2=A0INF_VERSION=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =3D 1.30
=C2=A0 =C2=A0BASE_NAME=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =3D UniversalPayloadEntry
=C2=A0 =C2=A0FILE_GUID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =3D D4F0F269-1209-4A66-8039-C4D5A700EA4E
=C2=A0 =C2=A0MODULE_TYPE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =3D SEC
=C2=A0 =C2=A0VERSION_STRING=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0=3D 1.0
-
=C2=A0#
=C2=A0# The following information is for reference only and not required by= the build tools.
=C2=A0#
=C2=A0#=C2=A0 VALID_ARCHITECTURES=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =3D IA32 X64
=C2=A0#
-
=C2=A0[Sources]
=C2=A0 =C2=A0UniversalPayloadEntry.c
=C2=A0 =C2=A0LoadDxeCore.c
=C2=A0 =C2=A0MemoryAllocation.c
=C2=A0 =C2=A0PrintHob.c
=C2=A0 =C2=A0AcpiTable.c
-
=C2=A0[Sources.Ia32]
=C2=A0 =C2=A0X64/VirtualMemory.h
=C2=A0 =C2=A0X64/VirtualMemory.c
=C2=A0 =C2=A0Ia32/DxeLoadFunc.c
=C2=A0 =C2=A0Ia32/IdtVectorAsm.nasm
-
=C2=A0[Sources.X64]
=C2=A0 =C2=A0X64/VirtualMemory.h
=C2=A0 =C2=A0X64/VirtualMemory.c
=C2=A0 =C2=A0X64/DxeLoadFunc.c
-
=C2=A0[Packages]
=C2=A0 =C2=A0MdePkg/MdePkg.dec
=C2=A0 =C2=A0MdeModulePkg/MdeModulePkg.dec
=C2=A0 =C2=A0UefiCpuPkg/UefiCpuPkg.dec
=C2=A0 =C2=A0UefiPayloadPkg/UefiPayloadPkg.dec
-
=C2=A0[LibraryClasses]
=C2=A0 =C2=A0BaseMemoryLib
=C2=A0 =C2=A0DebugLib
@@ -69,14 +62,12 @@
=C2=A0 =C2=A0gUniversalPayloadAcpiTableGuid
=C2=A0 =C2=A0gUniversalPayloadPciRootBridgeInfoGuid
=C2=A0 =C2=A0gUniversalPayloadSmbios3TableGuid
-
+=C2=A0 gUniversalPayloadBaseGuid
+=C2=A0 gUniversalPayloadDeviceTreeGuid
=C2=A0[FeaturePcd.IA32]
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode=C2=A0= =C2=A0 =C2=A0 ## CONSUMES
-
=C2=A0[FeaturePcd.X64]
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables=C2=A0 = =C2=A0 =C2=A0 =C2=A0## CONSUMES
-
-
=C2=A0[Pcd.IA32,Pcd.X64]
=C2=A0 =C2=A0gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ## SOMETIMES= _CONSUMES
@@ -86,12 +77,9 @@
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0## CON= SUMES
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ## CONSUMES
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ## CONSUMES
-
=C2=A0 =C2=A0gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemBase
=C2=A0 =C2=A0gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize
=C2=A0 =C2=A0gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize -
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0## SOMETIMES_CONSUMES
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy = ## SOMETIMES_CONSUMES
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy=C2=A0 = =C2=A0 =C2=A0 =C2=A0## SOMETIMES_CONSUMES
-
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload= Pkg.dsc
index 2860a659f6a7..779f74da7171 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -55,7 +55,7 @@
=C2=A0 =C2=A0# ELF: Build UniversalPayload file as UniversalPayload.elf
=C2=A0 =C2=A0# FIT: Build UniversalPayload file as UniversalPayload.fit
=C2=A0 =C2=A0#
-=C2=A0 DEFINE UNIVERSAL_PAYLOAD=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =3D FALSE
+=C2=A0 DEFINE UNIVERSAL_PAYLOAD=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =3D TRUE
=C2=A0 =C2=A0DEFINE UNIVERSAL_PAYLOAD_FORMAT=C2=A0 =C2=A0 =C2=A0=3D ELF

=C2=A0 =C2=A0#
@@ -226,6 +226,7 @@
=C2=A0 =C2=A0OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
=C2=A0 =C2=A0RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
=C2=A0 =C2=A0HobLib|UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
+=C2=A0 CustomFdtNodeParserLib|UefiPayloadPkg/Library/CustomFdtNodeParserNu= llLib/CustomFdtNodeParserNullLib.inf

=C2=A0 =C2=A0#
=C2=A0 =C2=A0# UEFI & PI
@@ -470,6 +471,8 @@
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE =C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE
+=C2=A0 gUefiPayloadPkgTokenSpaceGuid.PcdHandOffFdtEnable|TRUE
+

=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, = 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x6= 6, 0x23, 0x31 }
=C2=A0 =C2=A0gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0= xcf, 0x80, 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95= , 0x41 }
@@ -513,7 +516,15 @@
=C2=A0!endif
=C2=A0!endif

+
=C2=A0[PcdsPatchableInModule.X64]
+=C2=A0 #
+=C2=A0 # The following parameters are set by Library/PlatformHookLib
+=C2=A0 #
+=C2=A0 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|FALSE
+=C2=A0 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x3F8
+=C2=A0 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate|$(BAUD_RATE)
+=C2=A0 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|1
=C2=A0!if $(NETWORK_DRIVER_ENABLE) =3D=3D TRUE
=C2=A0 =C2=A0gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE
=C2=A0!endif
@@ -635,7 +646,13 @@
=C2=A0 =C2=A0 =C2=A0!if $(UNIVERSAL_PAYLOAD_FORMAT) =3D=3D "ELF"<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0UefiPayloadPkg/UefiPayloadEntry/UniversalPayload= Entry.inf
=C2=A0 =C2=A0 =C2=A0!elseif $(UNIVERSAL_PAYLOAD_FORMAT) =3D=3D "FIT&qu= ot;
-=C2=A0 =C2=A0 =C2=A0 UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEn= try.inf
+=C2=A0 =C2=A0 =C2=A0 UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEn= try.inf {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 <LibraryClasses>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FdtLib|MdePkg/Library/BaseFdtLib/BaseFd= tLib.inf
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CustomFdtNodeParserLib|UefiPayloadPkg/L= ibrary/CustomFdtNodeParserLib/CustomFdtNodeParserLib.inf
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 NULL|UefiPayloadPkg/Library/FdtParserLi= b/FdtParseLib.inf
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 NULL|UefiPayloadPkg/Library/HobParseLib= /HobParseLib.inf
+=C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0!else
=C2=A0 =C2=A0 =C2=A0 =C2=A0UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry= .inf
=C2=A0 =C2=A0 =C2=A0!endif
@@ -648,7 +665,13 @@
=C2=A0 =C2=A0 =C2=A0!if $(UNIVERSAL_PAYLOAD_FORMAT) =3D=3D "ELF"<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0UefiPayloadPkg/UefiPayloadEntry/UniversalPayload= Entry.inf
=C2=A0 =C2=A0 =C2=A0!elseif $(UNIVERSAL_PAYLOAD_FORMAT) =3D=3D "FIT&qu= ot;
-=C2=A0 =C2=A0 =C2=A0 UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEn= try.inf
+=C2=A0 =C2=A0 =C2=A0 UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEn= try.inf {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 <LibraryClasses>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FdtLib|MdePkg/Library/BaseFdtLib/BaseFd= tLib.inf
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CustomFdtNodeParserLib|UefiPayloadPkg/L= ibrary/CustomFdtNodeParserLib/CustomFdtNodeParserLib.inf
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 NULL|UefiPayloadPkg/Library/FdtParserLi= b/FdtParseLib.inf
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 NULL|UefiPayloadPkg/Library/HobParseLib= /HobParseLib.inf
+=C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0!else
=C2=A0 =C2=A0 =C2=A0 =C2=A0UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry= .inf
=C2=A0 =C2=A0 =C2=A0!endif
--
2.39.2.windows.1



--
Thanks!
=3DD


--
Thanks!
=3DD
_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#119451) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--0000000000004fe06a061a13a364--