public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Linus Liu" <linus.liu@intel.com>
To: Dhaval Sharma <dhaval@rivosinc.com>,
	"Chiu, Chasel" <chasel.chiu@intel.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Lin, Benny" <benny.lin@intel.com>,
	"Guo, Gua" <gua.guo@intel.com>, "Lu, James" <james.lu@intel.com>
Subject: [edk2-devel] FW: [PATCH v4 6/6] UefiPayloadPkg: Update UefiPayload driver for FDT support.
Date: Wed, 5 Jun 2024 01:34:21 +0000	[thread overview]
Message-ID: <PH7PR11MB58885DEDDA1DF769A7D5DE20FCF92@PH7PR11MB5888.namprd11.prod.outlook.com> (raw)
In-Reply-To: <BN9PR11MB5483A643647D33DD901EA806E6F82@BN9PR11MB5483.namprd11.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 44400 bytes --]

Hi Chasel and Dhaval

Reply inline.

Thanks



From: Chiu, Chasel <chasel.chiu@intel.com>
Sent: Wednesday, June 5, 2024 7:11 AM
To: Dhaval Sharma <dhaval@rivosinc.com>; Liu, Linus <linus.liu@intel.com>
Cc: devel@edk2.groups.io; Lin, Benny <benny.lin@intel.com>; Guo, Gua <gua.guo@intel.com>; Lu, James <james.lu@intel.com>
Subject: RE: [PATCH v4 6/6] UefiPayloadPkg: Update UefiPayload driver for FDT support.


Hi Dhaval,

Thanks for good catch! I just copied your feedbacks to the PR, let’s discuss there which will be easier than mail thread.

Thanks,
Chasel

https://github.com/tianocore/edk2/pull/5669/files#r1626731653



From: Dhaval Sharma <dhaval@rivosinc.com<mailto:dhaval@rivosinc.com>>
Sent: Monday, June 3, 2024 4:28 AM
To: Liu, Linus <linus.liu@intel.com<mailto:linus.liu@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Lin, Benny <benny.lin@intel.com<mailto:benny.lin@intel.com>>; Guo, Gua <gua.guo@intel.com<mailto:gua.guo@intel.com>>; Chiu, Chasel <chasel.chiu@intel.com<mailto:chasel.chiu@intel.com>>; Lu, James <james.lu@intel.com<mailto:james.lu@intel.com>>
Subject: Re: [PATCH v4 6/6] UefiPayloadPkg: Update UefiPayload driver for FDT support.

BuildFitLoadablesFvHob:

  *   Fdt variable is not initialized.
   [Linus] , will update the patch soon.

  *   It ONLY gets initialized if GuidHob is found. What if it is not found?
  [Linus] , if the payload base wasn’t found the system will assert in HandoffDxe..


  *   FdtCheckHeader still evaluating it?
  [Linus] , Yes , we can evaluating the payload image format with FdtCheckHeader.


On Mon, Jun 3, 2024 at 7:49 AM Linus Liu <linus.liu@intel.com<mailto:linus.liu@intel.com>> wrote:
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 <benny.lin@intel.com<mailto:benny.lin@intel.com>>
Cc: Gua Guo <gua.guo@intel.com<mailto:gua.guo@intel.com>>
Cc: Chasel Chiu <chasel.chiu@intel.com<mailto:chasel.chiu@intel.com>>
Cc: James Lu <james.lu@intel.com<mailto:james.lu@intel.com>>
Cc: Dhaval Sharma <dhaval@rivosinc.com<mailto:dhaval@rivosinc.com>>

Signed-off-by: Linus Liu <linus.liu@intel.com<mailto:linus.liu@intel.com>>
---
 UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c               | 428 +++++++++-----------
 UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c                       |  12 +
 UefiPayloadPkg/UefiPayloadEntry/Ia32/{DxeLoadFunc.c => 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 => 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 <Library/FdtLib.h>
 #include <Guid/UniversalPayloadBase.h>
+#include <Guid/MemoryTypeInformation.h>
+#include <Library/FdtParserLib.h>

 #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[] = {
+  { EfiACPIReclaimMemory,   FixedPcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory)   },
+  { EfiACPIMemoryNVS,       FixedPcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS)       },
+  { EfiReservedMemoryType,  FixedPcdGet32 (PcdMemoryTypeEfiReservedMemoryType)  },
+  { EfiRuntimeServicesData, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesData) },
+  { EfiRuntimeServicesCode, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode) },
+  { EfiMaxMemoryType,       0                                                   }
+};
+
 extern VOID  *mHobList;

 CHAR8  *mLineBuffer = 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 input 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 == NULL) {
-    return;
-  }
-
-  NewHob.Header = CreateHob (Hob->Header->HobType, Hob->Header->HobLength);
-  ASSERT (NewHob.Header != NULL);
-  if (NewHob.Header == 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 = (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
-    //
-    // Skip all HOBs except Resource Descriptor HOBs
-    //
-    if (GET_HOB_TYPE (Hob) != EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
-      continue;
-    }
-
-    //
-    // Skip Resource Descriptor HOBs that do not describe tested system memory
-    //
-    ResourceHob = Hob.ResourceDescriptor;
-    if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
-      continue;
-    }
-
-    if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != 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 input 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 = NULL;
-
-  for (Hob.Raw = (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
-    //
-    // Skip all HOBs except Resource Descriptor HOBs
-    //
-    if (GET_HOB_TYPE (Hob) != EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
-      continue;
-    }
-
-    //
-    // Skip Resource Descriptor HOBs that do not describe tested system memory
-    //
-    ResourceHob = Hob.ResourceDescriptor;
-    if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
-      continue;
-    }
-
-    if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) {
-      continue;
-    }
-
-    //
-    // Skip if the Resource Descriptor HOB equals to ExceptResourceHob
-    //
-    if (ResourceHob == 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 == NULL) {
-      ReturnResourceHob = ResourceHob;
-    } else {
-      if (ReturnResourceHob->PhysicalStart < ResourceHob->PhysicalStart) {
-        ReturnResourceHob = 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 == EFI_HOB_TYPE_HANDOFF) {
-    return FALSE;
-  }
-
-  if (Hob.Header->HobType == 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 = FdtCheckHeader (Fdt);
   if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_INFO, "FdtCheckHeader UPSUPPORTED\n"));
     return EFI_UNSUPPORTED;
   }

   ConfigNode = FdtSubnodeOffsetNameLen (Fdt, 0, "configurations", (INT32)AsciiStrLen ("configurations"));
   if (ConfigNode <= 0) {
+    DEBUG ((DEBUG_INFO, "BuildFitLoadablesFvHob configurations EFI_NOT_FOUND\n"));
     return EFI_NOT_FOUND;
   }

   Config1Node = FdtSubnodeOffsetNameLen (Fdt, ConfigNode, "conf-1", (INT32)AsciiStrLen ("conf-1"));
   if (Config1Node <= 0) {
+    DEBUG ((DEBUG_INFO, "BuildFitLoadablesFvHob conf-1 EFI_NOT_FOUND\n"));
     return EFI_NOT_FOUND;
   }

   ImageNode = FdtSubnodeOffsetNameLen (Fdt, 0, "images", (INT32)AsciiStrLen ("images"));
   if (ImageNode <= 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 list.
 **/
-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           = (UINT8 *)BootloaderParameter;
   MinimalNeededSize = FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
@@ -512,7 +412,7 @@ BuildHobs (
     //
     ResourceHob = FindAnotherHighestBelow4GResourceDescriptor (Hob.Raw, MinimalNeededSize, NULL);
     if (ResourceHob == NULL) {
-      return EFI_NOT_FOUND;
+      return;
     }

     MemoryBottom     = ResourceHob->PhysicalStart + ResourceHob->ResourceLength - MinimalNeededSize;
@@ -542,7 +442,7 @@ BuildHobs (
     //
     ResourceHob = FindAnotherHighestBelow4GResourceDescriptor (Hob.Raw, MinimalNeededSize, PhitResourceHob);
     if (ResourceHob == NULL) {
-      return EFI_NOT_FOUND;
+      return;
     }

     MemoryBottom     = ResourceHob->PhysicalStart + ResourceHob->ResourceLength - MinimalNeededSize;
@@ -553,14 +453,7 @@ BuildHobs (

   HobInfo           = HobConstructor ((VOID *)(UINTN)MemoryBottom, (VOID *)(UINTN)MemoryTop, (VOID *)(UINTN)FreeMemoryBottom, (VOID *)(UINTN)FreeMemoryTop);
   HobInfo->BootMode = 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 = 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 = GetFirstGuidHob (&gUniversalPayloadDeviceTreeGuid);
+    if (GuidHob != NULL) {
+      Fdt =  (UNIVERSAL_PAYLOAD_DEVICE_TREE *)GET_GUID_HOB_DATA (GuidHob);
+      if (Fdt != NULL) {
+        DEBUG ((DEBUG_INFO, "Update FDT base to reserved memory\n"));
+        FdtSize = 4 * EFI_PAGE_SIZE;
+        CopyMem ((VOID *)NewFdtBase, (VOID *)(Fdt->DeviceTreeAddress), FdtSize);
+        Fdt->DeviceTreeAddress = NewFdtBase;
+      }
+    }
+  }
+
+  //
+  // To create Memory Type Information HOB
+  //
+  GuidHob = GetFirstGuidHob (&gEfiMemoryTypeInformationGuid);
+  if (GuidHob == 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 bootloader 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 = (VOID *)BootloaderParameter;
-  DxeFv    = NULL;
+  if (FixedPcdGetBool (PcdHandOffFdtEnable)) {
+    mHobList = (VOID *)NULL;
+  } else {
+    mHobList = (VOID *)BootloaderParameter;
+  }
+
+  DxeFv = NULL;
   // Call constructor for all libraries
   ProcessLibraryConstructorList ();

   DEBUG ((DEBUG_INFO, "Entering Universal Payload...\n"));
   DEBUG ((DEBUG_INFO, "sizeof(UINTN) = 0x%x\n", sizeof (UINTN)));
+  DEBUG ((DEBUG_INFO, "BootloaderParameter = 0x%x\n", BootloaderParameter));
+
+  DEBUG ((DEBUG_INFO, "Start init Hobs...\n"));
+  HobListPtr = UplInitHob ((VOID *)BootloaderParameter);
+
+  //
+  // Found hob list node
+  //
+  if (HobListPtr != 0) {
+    FdtBase = (VOID *)BootloaderParameter;
+    if (FdtCheckHeader (FdtBase) == 0) {
+      CustomFdtNodeParser ((VOID *)FdtBase, (VOID *)HobListPtr);
+    } else {
+      CreatNewHobForHoblist (BootloaderParameter);
+    }
+
+    FdtBaseResvd = PayloadAllocatePages (4, EfiReservedMemoryType);
+
+    // Build HOB based on information from Bootloader
+    Status = 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 = BuildHobs (BootloaderParameter, &DxeFv);
-  ASSERT_EFI_ERROR (Status);
-
   FixUpPcdDatabase (DxeFv);
   Status = 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 = (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 <Library/MemoryAllocationLib.h>
 #include <Library/PcdLib.h>
 #include <Library/HobLib.h>
+#include <Library/FdtLib.h>
 #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.<BR>
-Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
-
-SPDX-License-Identifier: BSD-2-Clause-Patent
+  Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent

 **/

@@ -15,12 +13,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/MemoryAllocationLib.h>
 #include <Library/PcdLib.h>
 #include <Library/HobLib.h>
+#include <Library/FdtLib.h>
 #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 bootloader 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 fails.
+**/
+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  = GetHobList ();
+  HobTable = Hob.HandoffInformationTable;
+
+  if (Pages == 0) {
+    return NULL;
+  }
+
+  // Make sure allocation address is page alligned.
+  Offset = HobTable->EfiFreeMemoryTop & EFI_PAGE_MASK;
+  if (Offset != 0) {
+    HobTable->EfiFreeMemoryTop -= 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 -= 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[] = {
   { 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 = 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 = (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 <Library/MemoryAllocationLib.h>
 #include <Library/PcdLib.h>
 #include <Library/HobLib.h>
+#include <Library/FdtLib.h>
 #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.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
+  Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent

 **/

@@ -13,10 +13,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/MemoryAllocationLib.h>
 #include <Library/PcdLib.h>
 #include <Library/HobLib.h>
+#include <Library/FdtLib.h>
+#include <Library/PcdLib.h>
 #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 bootloader 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.inf 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 = /wd4244 /wd4305
+  GCC:*_*_*_CC_FLAGS  = -Wno-error=pointer-to-int-cast -Wno-error=int-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 <UniversalPayload/UniversalPayload.h>
 #include <UniversalPayload/ExtraData.h>
 #include <UniversalPayload/SerialPortInfo.h>
+#include <UniversalPayload/DeviceTree.h>
 #include <Guid/PcdDataBaseSignatureGuid.h>

 #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 fails.
+**/
+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 bootloader 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                    = 1.30
   BASE_NAME                      = UniversalPayloadEntry
   FILE_GUID                      = D4F0F269-1209-4A66-8039-C4D5A700EA4E
   MODULE_TYPE                    = SEC
   VERSION_STRING                 = 1.0
-
 #
 # The following information is for reference only and not required by the build tools.
 #
 #  VALID_ARCHITECTURES           = 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            = FALSE
+  DEFINE UNIVERSAL_PAYLOAD            = TRUE
   DEFINE UNIVERSAL_PAYLOAD_FORMAT     = 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) == TRUE
   gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE
 !endif
@@ -635,7 +646,13 @@
     !if $(UNIVERSAL_PAYLOAD_FORMAT) == "ELF"
       UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
     !elseif $(UNIVERSAL_PAYLOAD_FORMAT) == "FIT"
-      UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf
+      UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf {
+        <LibraryClasses>
+          FdtLib|MdePkg/Library/BaseFdtLib/BaseFdtLib.inf
+          CustomFdtNodeParserLib|UefiPayloadPkg/Library/CustomFdtNodeParserLib/CustomFdtNodeParserLib.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) == "ELF"
       UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
     !elseif $(UNIVERSAL_PAYLOAD_FORMAT) == "FIT"
-      UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf
+      UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf {
+        <LibraryClasses>
+          FdtLib|MdePkg/Library/BaseFdtLib/BaseFdtLib.inf
+          CustomFdtNodeParserLib|UefiPayloadPkg/Library/CustomFdtNodeParserLib/CustomFdtNodeParserLib.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!
=D


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119457): https://edk2.groups.io/g/devel/message/119457
Mute This Topic: https://groups.io/mt/106495599/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 73688 bytes --]

      reply	other threads:[~2024-06-05  1:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-03  2:19 [edk2-devel] [PATCH v4 6/6] UefiPayloadPkg: Update UefiPayload driver for FDT support Linus Liu
2024-06-03 11:27 ` Dhaval Sharma
2024-06-04 17:18   ` Dhaval Sharma
2024-06-05  3:47     ` Linus Liu
2024-06-04 23:10   ` Chiu, Chasel
2024-06-05  1:34     ` Linus Liu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PH7PR11MB58885DEDDA1DF769A7D5DE20FCF92@PH7PR11MB5888.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox