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 4346D740041 for ; Fri, 24 May 2024 04:14:37 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=2BHkEJ4RITQXr2LbGQX2mB7yizB1IJh9VXMDFUvsZLw=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1716524070; v=1; b=YUQHDQE/liJpRP3k/wwnnO0FUqaDELpgTxHScuRUEkEQc1YDPOT/cfCV9oOUfW2S8lp2dwCR fEEI9iB0BQ12mVZsneScuR3I3HfWJHtLWMzhvtCd71MQ0WZKKYlezQDEbqVbR7202e+7IIH64b0 h1jZ/ImWGmEm5jOOWj/a9eMKk0LK/D54XmLxiQvYHtyVek/73cm4OCNMY5VcOaS+H8upJEIBFrB vM6VSZeX4YyCcRkEwJozkfxWE4NYb509QpcTb5PfDj3WSsvknvzm3N+7abF4fBhX0Gu10uaOcsC 6vaEKw7fc9Pho+BLdt67dBe4ru1VYSVQVTdA3MhOIiSJA== X-Received: by 127.0.0.2 with SMTP id eZw1YY7687511x98OF1sEmSK; Thu, 23 May 2024 21:14:30 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by mx.groups.io with SMTP id smtpd.web10.8319.1716524067224395658 for ; Thu, 23 May 2024 21:14:30 -0700 X-CSE-ConnectionGUID: IeWE1YcgQUWwr8+PIH/sMA== X-CSE-MsgGUID: hDawU4SXRt+7ufAJsMidAA== X-IronPort-AV: E=McAfee;i="6600,9927,11081"; a="23493624" X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="23493624" X-Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2024 21:14:25 -0700 X-CSE-ConnectionGUID: q7MvRn5rRm64rEdO4buGBQ== X-CSE-MsgGUID: +4xx/izrTduFlWwTj/4AyQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="38464841" X-Received: from linusliu-desk1.gar.corp.intel.com ([10.225.76.64]) by fmviesa004.fm.intel.com with ESMTP; 23 May 2024 21:14:22 -0700 From: "Linus Liu" To: devel@edk2.groups.io Cc: Benny Lin , Gua Guo , Chasel Chiu , James Lu , Dhaval Sharma Subject: [edk2-devel] [PATCH v3 6/6] UefiPayloadPkg: Update UefiPayload driver for FDT support. Date: Thu, 23 May 2024 21:14:19 -0700 Message-Id: <20240524041419.1385-1-linus.liu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Thu, 23 May 2024 21:14:30 -0700 Resent-From: linus.liu@intel.com Reply-To: devel@edk2.groups.io,linus.liu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: tFE7nNbgiztlQPsMyBAcaZg1x7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b="YUQHDQE/"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Add 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/U= efiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c index eb0b325369a0..813d656950d1 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c @@ -6,6 +6,8 @@ #include "UefiPayloadEntry.h"=0D #include =0D #include =0D +#include =0D +#include =0D =0D #define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT = | \=0D EFI_RESOURCE_ATTRIBUTE_INITIALIZED = | \=0D @@ -23,6 +25,15 @@ EFI_RESOURCE_ATTRIBUTE_INITIALIZED = | \=0D EFI_RESOURCE_ATTRIBUTE_TESTED = )=0D =0D +EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] =3D {=0D + { EfiACPIReclaimMemory, FixedPcdGet32 (PcdMemoryTypeEfiACPIReclaimMemo= ry) },=0D + { EfiACPIMemoryNVS, FixedPcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS) = },=0D + { EfiReservedMemoryType, FixedPcdGet32 (PcdMemoryTypeEfiReservedMemoryT= ype) },=0D + { EfiRuntimeServicesData, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServices= Data) },=0D + { EfiRuntimeServicesCode, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServices= Code) },=0D + { EfiMaxMemoryType, 0 = }=0D +};=0D +=0D extern VOID *mHobList;=0D =0D CHAR8 *mLineBuffer =3D NULL;=0D @@ -36,6 +47,78 @@ PrintHob ( IN CONST VOID *HobStart=0D );=0D =0D +/**=0D + Add HOB into HOB list=0D + @param[in] Hob The HOB to be added into the HOB list.=0D +**/=0D +VOID=0D +AddNewHob (=0D + IN EFI_PEI_HOB_POINTERS *Hob=0D + );=0D +=0D +/**=0D + Found the Resource Descriptor HOB that contains a range (Base, Top)=0D + @param[in] HobList Hob start address=0D + @param[in] Base Memory start address=0D + @param[in] Top Memory end address.=0D + @retval The pointer to the Resource Descriptor HOB.=0D +**/=0D +EFI_HOB_RESOURCE_DESCRIPTOR *=0D +FindResourceDescriptorByRange (=0D + IN VOID *HobList,=0D + IN EFI_PHYSICAL_ADDRESS Base,=0D + IN EFI_PHYSICAL_ADDRESS Top=0D + );=0D +=0D +/**=0D + Find the highest below 4G memory resource descriptor, except the input R= esource Descriptor.=0D + @param[in] HobList Hob start address=0D + @param[in] MinimalNeededSize Minimal needed size.=0D + @param[in] ExceptResourceHob Ignore this Resource Descriptor.=0D + @retval The pointer to the Resource Descriptor HOB.=0D +**/=0D +EFI_HOB_RESOURCE_DESCRIPTOR *=0D +FindAnotherHighestBelow4GResourceDescriptor (=0D + IN VOID *HobList,=0D + IN UINTN MinimalNeededSize,=0D + IN EFI_HOB_RESOURCE_DESCRIPTOR *ExceptResourceHob=0D + );=0D +=0D +/**=0D + Check the HOB and decide if it is need inside Payload=0D + Payload maintainer may make decision which HOB is need or needn't=0D + Then add the check logic in the function.=0D + @param[in] Hob The HOB to check=0D + @retval TRUE If HOB is need inside Payload=0D + @retval FALSE If HOB is needn't inside Payload=0D +**/=0D +BOOLEAN=0D +FitIsHobNeed (=0D + EFI_PEI_HOB_POINTERS Hob=0D + );=0D +=0D +/**=0D + Check the HOB and decide if it is need inside Payload=0D +=0D + Payload maintainer may make decision which HOB is need or needn't=0D + Then add the check logic in the function.=0D +=0D + @param[in] Hob The HOB to check=0D +=0D + @retval TRUE If HOB is need inside Payload=0D + @retval FALSE If HOB is needn't inside Payload=0D +**/=0D +BOOLEAN=0D +IsHobNeed (=0D + EFI_PEI_HOB_POINTERS Hob=0D + );=0D +=0D +VOID=0D +EFIAPI=0D +ProcessLibraryConstructorList (=0D + VOID=0D + );=0D +=0D /**=0D Find the first substring.=0D @param String Point to the string where to find the substring.=0D @@ -191,187 +274,6 @@ FixUpPcdDatabase ( return EFI_SUCCESS;=0D }=0D =0D -/**=0D - Add HOB into HOB list=0D - @param[in] Hob The HOB to be added into the HOB list.=0D -**/=0D -VOID=0D -AddNewHob (=0D - IN EFI_PEI_HOB_POINTERS *Hob=0D - )=0D -{=0D - EFI_PEI_HOB_POINTERS NewHob;=0D -=0D - if (Hob->Raw =3D=3D NULL) {=0D - return;=0D - }=0D -=0D - NewHob.Header =3D CreateHob (Hob->Header->HobType, Hob->Header->HobLengt= h);=0D - ASSERT (NewHob.Header !=3D NULL);=0D - if (NewHob.Header =3D=3D NULL) {=0D - return;=0D - }=0D -=0D - CopyMem (NewHob.Header + 1, Hob->Header + 1, Hob->Header->HobLength - si= zeof (EFI_HOB_GENERIC_HEADER));=0D -}=0D -=0D -/**=0D - Found the Resource Descriptor HOB that contains a range (Base, Top)=0D - @param[in] HobList Hob start address=0D - @param[in] Base Memory start address=0D - @param[in] Top Memory end address.=0D - @retval The pointer to the Resource Descriptor HOB.=0D -**/=0D -EFI_HOB_RESOURCE_DESCRIPTOR *=0D -FindResourceDescriptorByRange (=0D - IN VOID *HobList,=0D - IN EFI_PHYSICAL_ADDRESS Base,=0D - IN EFI_PHYSICAL_ADDRESS Top=0D - )=0D -{=0D - EFI_PEI_HOB_POINTERS Hob;=0D - EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;=0D -=0D - for (Hob.Raw =3D (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw =3D G= ET_NEXT_HOB (Hob)) {=0D - //=0D - // Skip all HOBs except Resource Descriptor HOBs=0D - //=0D - if (GET_HOB_TYPE (Hob) !=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {=0D - continue;=0D - }=0D -=0D - //=0D - // Skip Resource Descriptor HOBs that do not describe tested system me= mory=0D - //=0D - ResourceHob =3D Hob.ResourceDescriptor;=0D - if (ResourceHob->ResourceType !=3D EFI_RESOURCE_SYSTEM_MEMORY) {=0D - continue;=0D - }=0D -=0D - if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) !=3D TEST= ED_MEMORY_ATTRIBUTES) {=0D - continue;=0D - }=0D -=0D - //=0D - // Skip Resource Descriptor HOBs that do not contain the PHIT range Ef= iFreeMemoryBottom..EfiFreeMemoryTop=0D - //=0D - if (Base < ResourceHob->PhysicalStart) {=0D - continue;=0D - }=0D -=0D - if (Top > (ResourceHob->PhysicalStart + ResourceHob->ResourceLength)) = {=0D - continue;=0D - }=0D -=0D - return ResourceHob;=0D - }=0D -=0D - return NULL;=0D -}=0D -=0D -/**=0D - Find the highest below 4G memory resource descriptor, except the input R= esource Descriptor.=0D - @param[in] HobList Hob start address=0D - @param[in] MinimalNeededSize Minimal needed size.=0D - @param[in] ExceptResourceHob Ignore this Resource Descriptor.=0D - @retval The pointer to the Resource Descriptor HOB.=0D -**/=0D -EFI_HOB_RESOURCE_DESCRIPTOR *=0D -FindAnotherHighestBelow4GResourceDescriptor (=0D - IN VOID *HobList,=0D - IN UINTN MinimalNeededSize,=0D - IN EFI_HOB_RESOURCE_DESCRIPTOR *ExceptResourceHob=0D - )=0D -{=0D - EFI_PEI_HOB_POINTERS Hob;=0D - EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;=0D - EFI_HOB_RESOURCE_DESCRIPTOR *ReturnResourceHob;=0D -=0D - ReturnResourceHob =3D NULL;=0D -=0D - for (Hob.Raw =3D (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw =3D G= ET_NEXT_HOB (Hob)) {=0D - //=0D - // Skip all HOBs except Resource Descriptor HOBs=0D - //=0D - if (GET_HOB_TYPE (Hob) !=3D EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {=0D - continue;=0D - }=0D -=0D - //=0D - // Skip Resource Descriptor HOBs that do not describe tested system me= mory=0D - //=0D - ResourceHob =3D Hob.ResourceDescriptor;=0D - if (ResourceHob->ResourceType !=3D EFI_RESOURCE_SYSTEM_MEMORY) {=0D - continue;=0D - }=0D -=0D - if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) !=3D TEST= ED_MEMORY_ATTRIBUTES) {=0D - continue;=0D - }=0D -=0D - //=0D - // Skip if the Resource Descriptor HOB equals to ExceptResourceHob=0D - //=0D - if (ResourceHob =3D=3D ExceptResourceHob) {=0D - continue;=0D - }=0D -=0D - //=0D - // Skip Resource Descriptor HOBs that are beyond 4G=0D - //=0D - if ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength) > BASE_= 4GB) {=0D - continue;=0D - }=0D -=0D - //=0D - // Skip Resource Descriptor HOBs that are too small=0D - //=0D - if (ResourceHob->ResourceLength < MinimalNeededSize) {=0D - continue;=0D - }=0D -=0D - //=0D - // Return the topest Resource Descriptor=0D - //=0D - if (ReturnResourceHob =3D=3D NULL) {=0D - ReturnResourceHob =3D ResourceHob;=0D - } else {=0D - if (ReturnResourceHob->PhysicalStart < ResourceHob->PhysicalStart) {= =0D - ReturnResourceHob =3D ResourceHob;=0D - }=0D - }=0D - }=0D -=0D - return ReturnResourceHob;=0D -}=0D -=0D -/**=0D - Check the HOB and decide if it is need inside Payload=0D - Payload maintainer may make decision which HOB is need or needn't=0D - Then add the check logic in the function.=0D - @param[in] Hob The HOB to check=0D - @retval TRUE If HOB is need inside Payload=0D - @retval FALSE If HOB is needn't inside Payload=0D -**/=0D -BOOLEAN=0D -IsHobNeed (=0D - EFI_PEI_HOB_POINTERS Hob=0D - )=0D -{=0D - if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_HANDOFF) {=0D - return FALSE;=0D - }=0D -=0D - if (Hob.Header->HobType =3D=3D EFI_HOB_TYPE_MEMORY_ALLOCATION) {=0D - if (CompareGuid (&Hob.MemoryAllocationModule->MemoryAllocationHeader.N= ame, &gEfiHobMemoryAllocModuleGuid)) {=0D - return FALSE;=0D - }=0D - }=0D -=0D - // Arrive here mean the HOB is need=0D - return TRUE;=0D -}=0D -=0D /**=0D It will build Fv HOBs based on information from bootloaders.=0D @param[out] DxeFv The pointer to the DXE FV in memory.=0D @@ -409,21 +311,25 @@ BuildFitLoadablesFvHob ( =0D Status =3D FdtCheckHeader (Fdt);=0D if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_INFO, "FdtCheckHeader UPSUPPORTED\n"));=0D return EFI_UNSUPPORTED;=0D }=0D =0D ConfigNode =3D FdtSubnodeOffsetNameLen (Fdt, 0, "configurations", (INT32= )AsciiStrLen ("configurations"));=0D if (ConfigNode <=3D 0) {=0D + DEBUG ((DEBUG_INFO, "BuildFitLoadablesFvHob configurations EFI_NOT_FOU= ND\n"));=0D return EFI_NOT_FOUND;=0D }=0D =0D Config1Node =3D FdtSubnodeOffsetNameLen (Fdt, ConfigNode, "conf-1", (INT= 32)AsciiStrLen ("conf-1"));=0D if (Config1Node <=3D 0) {=0D + DEBUG ((DEBUG_INFO, "BuildFitLoadablesFvHob conf-1 EFI_NOT_FOUND\n"));= =0D return EFI_NOT_FOUND;=0D }=0D =0D ImageNode =3D FdtSubnodeOffsetNameLen (Fdt, 0, "images", (INT32)AsciiStr= Len ("images"));=0D if (ImageNode <=3D 0) {=0D + DEBUG ((DEBUG_INFO, "BuildFitLoadablesFvHob images EFI_NOT_FOUND\n"));= =0D return EFI_NOT_FOUND;=0D }=0D =0D @@ -467,31 +373,25 @@ BuildFitLoadablesFvHob ( }=0D =0D /**=0D - It will build HOBs based on information from bootloaders.=0D - @param[in] BootloaderParameter The starting memory address of bootloa= der parameter block.=0D - @param[out] DxeFv The pointer to the DXE FV in memory.=0D - @retval EFI_SUCCESS If it completed successfully.=0D - @retval Others If it failed to build required HOBs.=0D + *=0D + Create new HOB for new HOB list=0D +=0D + @param[in] BootloaderParameter The HOB to be added into the HOB list.= =0D **/=0D -EFI_STATUS=0D -BuildHobs (=0D - IN UINTN BootloaderParameter,=0D - OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv=0D +VOID=0D +CreatNewHobForHoblist (=0D + IN UINTN BootloaderParameter=0D )=0D {=0D - EFI_PEI_HOB_POINTERS Hob;=0D - UINTN MinimalNeededSize;=0D - EFI_PHYSICAL_ADDRESS FreeMemoryBottom;=0D - EFI_PHYSICAL_ADDRESS FreeMemoryTop;=0D - EFI_PHYSICAL_ADDRESS MemoryBottom;=0D - EFI_PHYSICAL_ADDRESS MemoryTop;=0D - EFI_HOB_RESOURCE_DESCRIPTOR *PhitResourceHob;=0D - EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;=0D - UINT8 *GuidHob;=0D - EFI_HOB_FIRMWARE_VOLUME *FvHob;=0D - UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTable;=0D - ACPI_BOARD_INFO *AcpiBoardInfo;=0D - EFI_HOB_HANDOFF_INFO_TABLE *HobInfo;=0D + EFI_PEI_HOB_POINTERS Hob;=0D + UINTN MinimalNeededSize;=0D + EFI_PHYSICAL_ADDRESS FreeMemoryBottom;=0D + EFI_PHYSICAL_ADDRESS FreeMemoryTop;=0D + EFI_PHYSICAL_ADDRESS MemoryBottom;=0D + EFI_PHYSICAL_ADDRESS MemoryTop;=0D + EFI_HOB_RESOURCE_DESCRIPTOR *PhitResourceHob;=0D + EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;=0D + EFI_HOB_HANDOFF_INFO_TABLE *HobInfo;=0D =0D Hob.Raw =3D (UINT8 *)BootloaderParameter;=0D MinimalNeededSize =3D FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);=0D @@ -512,7 +412,7 @@ BuildHobs ( //=0D ResourceHob =3D FindAnotherHighestBelow4GResourceDescriptor (Hob.Raw, = MinimalNeededSize, NULL);=0D if (ResourceHob =3D=3D NULL) {=0D - return EFI_NOT_FOUND;=0D + return;=0D }=0D =0D MemoryBottom =3D ResourceHob->PhysicalStart + ResourceHob->Resourc= eLength - MinimalNeededSize;=0D @@ -542,7 +442,7 @@ BuildHobs ( //=0D ResourceHob =3D FindAnotherHighestBelow4GResourceDescriptor (Hob.Raw, = MinimalNeededSize, PhitResourceHob);=0D if (ResourceHob =3D=3D NULL) {=0D - return EFI_NOT_FOUND;=0D + return;=0D }=0D =0D MemoryBottom =3D ResourceHob->PhysicalStart + ResourceHob->Resourc= eLength - MinimalNeededSize;=0D @@ -553,14 +453,7 @@ BuildHobs ( =0D HobInfo =3D HobConstructor ((VOID *)(UINTN)MemoryBottom, (VOID= *)(UINTN)MemoryTop, (VOID *)(UINTN)FreeMemoryBottom, (VOID *)(UINTN)FreeMe= moryTop);=0D HobInfo->BootMode =3D Hob.HandoffInformationTable->BootMode;=0D - //=0D - // From now on, mHobList will point to the new Hob range.=0D - //=0D =0D - //=0D - // Create an empty FvHob for the DXE FV that contains DXE core.=0D - //=0D - BuildFvHob ((EFI_PHYSICAL_ADDRESS)0, 0);=0D //=0D // Since payload created new Hob, move all hobs except PHIT from boot lo= ader hob list.=0D //=0D @@ -573,7 +466,57 @@ BuildHobs ( Hob.Raw =3D GET_NEXT_HOB (Hob);=0D }=0D =0D - BuildFitLoadablesFvHob (DxeFv);=0D + return;=0D +}=0D +=0D +/**=0D + It will build HOBs based on information from bootloaders.=0D + @param[in] NewFdtBase The pointer to New FdtBase.=0D + @param[out] DxeFv The pointer to the DXE FV in memory.=0D + @retval EFI_SUCCESS If it completed successfully.=0D + @retval Others If it failed to build required HOBs.=0D +**/=0D +EFI_STATUS=0D +FitBuildHobs (=0D + IN UINTN NewFdtBase,=0D + OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv=0D + )=0D +{=0D + UINT8 *GuidHob;=0D + UINT32 FdtSize;=0D + EFI_HOB_FIRMWARE_VOLUME *FvHob;=0D + UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTable;=0D + ACPI_BOARD_INFO *AcpiBoardInfo;=0D + UNIVERSAL_PAYLOAD_DEVICE_TREE *Fdt;=0D +=0D + if (FixedPcdGetBool (PcdHandOffFdtEnable)) {=0D + //=0D + // Back up FDT in Reserved memory region=0D + //=0D +=0D + GuidHob =3D GetFirstGuidHob (&gUniversalPayloadDeviceTreeGuid);=0D + if (GuidHob !=3D NULL) {=0D + Fdt =3D (UNIVERSAL_PAYLOAD_DEVICE_TREE *)GET_GUID_HOB_DATA (GuidHob= );=0D + if (Fdt !=3D NULL) {=0D + DEBUG ((DEBUG_INFO, "Update FDT base to reserved memory\n"));=0D + FdtSize =3D 4 * EFI_PAGE_SIZE;=0D + CopyMem ((VOID *)NewFdtBase, (VOID *)(Fdt->DeviceTreeAddress), Fdt= Size);=0D + Fdt->DeviceTreeAddress =3D NewFdtBase;=0D + }=0D + }=0D + }=0D +=0D + //=0D + // To create Memory Type Information HOB=0D + //=0D + GuidHob =3D GetFirstGuidHob (&gEfiMemoryTypeInformationGuid);=0D + if (GuidHob =3D=3D NULL) {=0D + BuildGuidDataHob (=0D + &gEfiMemoryTypeInformationGuid,=0D + mDefaultMemoryTypeInformation,=0D + sizeof (mDefaultMemoryTypeInformation)=0D + );=0D + }=0D =0D //=0D // Create guid hob for acpi board information=0D @@ -588,6 +531,12 @@ BuildHobs ( }=0D }=0D =0D + //=0D + // Create an empty FvHob for the DXE FV that contains DXE core.=0D + //=0D + BuildFvHob ((EFI_PHYSICAL_ADDRESS)0, 0);=0D +=0D + BuildFitLoadablesFvHob (DxeFv);=0D //=0D // Update DXE FV information to first fv hob in the hob list, which=0D // is the empty FvHob created before.=0D @@ -600,12 +549,12 @@ BuildHobs ( =0D /**=0D Entry point to the C language phase of UEFI payload.=0D - @param[in] BootloaderParameter The starting address of bootloader p= arameter block.=0D + @param[in] BootloaderParameter The starting address of FDT .=0D @retval It will not return if SUCCESS, and return error when passin= g bootloader parameter.=0D **/=0D EFI_STATUS=0D EFIAPI=0D -_ModuleEntryPoint (=0D +FitUplEntryPoint (=0D IN UINTN BootloaderParameter=0D )=0D {=0D @@ -613,14 +562,46 @@ _ModuleEntryPoint ( PHYSICAL_ADDRESS DxeCoreEntryPoint;=0D EFI_PEI_HOB_POINTERS Hob;=0D EFI_FIRMWARE_VOLUME_HEADER *DxeFv;=0D + PHYSICAL_ADDRESS HobListPtr;=0D + VOID *FdtBase;=0D + VOID *FdtBaseResvd;=0D =0D - mHobList =3D (VOID *)BootloaderParameter;=0D - DxeFv =3D NULL;=0D + if (FixedPcdGetBool (PcdHandOffFdtEnable)) {=0D + mHobList =3D (VOID *)NULL;=0D + } else {=0D + mHobList =3D (VOID *)BootloaderParameter;=0D + }=0D +=0D + DxeFv =3D NULL;=0D // Call constructor for all libraries=0D ProcessLibraryConstructorList ();=0D =0D DEBUG ((DEBUG_INFO, "Entering Universal Payload...\n"));=0D DEBUG ((DEBUG_INFO, "sizeof(UINTN) =3D 0x%x\n", sizeof (UINTN)));=0D + DEBUG ((DEBUG_INFO, "BootloaderParameter =3D 0x%x\n", BootloaderParamete= r));=0D +=0D + DEBUG ((DEBUG_INFO, "Start init Hobs...\n"));=0D + HobListPtr =3D UplInitHob ((VOID *)BootloaderParameter);=0D +=0D + //=0D + // Found hob list node=0D + //=0D + if (HobListPtr !=3D 0) {=0D + FdtBase =3D (VOID *)BootloaderParameter;=0D + if (FdtCheckHeader (FdtBase) =3D=3D 0) {=0D + CustomFdtNodeParser ((VOID *)FdtBase, (VOID *)HobListPtr);=0D + } else {=0D + CreatNewHobForHoblist (BootloaderParameter);=0D + }=0D +=0D + FdtBaseResvd =3D PayloadAllocatePages (4, EfiReservedMemoryType);=0D +=0D + // Build HOB based on information from Bootloader=0D + Status =3D FitBuildHobs ((UINTN)FdtBaseResvd, &DxeFv);=0D + }=0D +=0D + // Call constructor for all libraries again since hobs were built=0D + ProcessLibraryConstructorList ();=0D =0D DEBUG_CODE (=0D //=0D @@ -629,23 +610,10 @@ _ModuleEntryPoint ( PrintHob (mHobList);=0D );=0D =0D - // Initialize floating point operating environment to be compliant with = UEFI spec.=0D - InitializeFloatingPointUnits ();=0D -=0D - // Build HOB based on information from Bootloader=0D - Status =3D BuildHobs (BootloaderParameter, &DxeFv);=0D - ASSERT_EFI_ERROR (Status);=0D -=0D FixUpPcdDatabase (DxeFv);=0D Status =3D UniversalLoadDxeCore (DxeFv, &DxeCoreEntryPoint);=0D ASSERT_EFI_ERROR (Status);=0D =0D - //=0D - // Mask off all legacy 8259 interrupt sources=0D - //=0D - IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);=0D - IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);=0D -=0D Hob.HandoffInformationTable =3D (EFI_HOB_HANDOFF_INFO_TABLE *)GetFirstHo= b (EFI_HOB_TYPE_HANDOFF);=0D HandOffToDxeCore (DxeCoreEntryPoint, Hob);=0D =0D 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 #include =0D #include =0D #include =0D +#include =0D #include "VirtualMemory.h"=0D #include "UefiPayloadEntry.h"=0D =0D #define STACK_SIZE 0x20000=0D #define IDT_ENTRY_COUNT 32=0D =0D +extern VOID *mHobList;=0D +=0D typedef struct _X64_IDT_TABLE {=0D //=0D // Reserved 4 bytes preceding PeiService and IdtTable,=0D @@ -268,6 +271,15 @@ HandOffToDxeCore ( UINT32 Index;=0D X64_IDT_TABLE *IdtTableForX64;=0D =0D + // Initialize floating point operating environment to be compliant with = UEFI spec.=0D + InitializeFloatingPointUnits ();=0D +=0D + //=0D + // Mask off all legacy 8259 interrupt sources=0D + //=0D + IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);=0D + IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);=0D +=0D //=0D // Clear page 0 and mark it as allocated if NULL pointer detection is en= abled.=0D //=0D 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 @@ /** @file=0D Ia32-specific functionality for DxeLoad.=0D =0D -Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
=0D -Copyright (c) 2017, AMD Incorporated. All rights reserved.
=0D -=0D -SPDX-License-Identifier: BSD-2-Clause-Patent=0D + Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D =0D @@ -15,12 +13,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =0D #include =0D #include =0D +#include =0D #include "VirtualMemory.h"=0D #include "UefiPayloadEntry.h"=0D =0D #define STACK_SIZE 0x20000=0D #define IDT_ENTRY_COUNT 32=0D =0D +extern VOID *mHobList;=0D +=0D typedef struct _X64_IDT_TABLE {=0D //=0D // Reserved 4 bytes preceding PeiService and IdtTable,=0D @@ -268,6 +269,15 @@ HandOffToDxeCore ( UINT32 Index;=0D X64_IDT_TABLE *IdtTableForX64;=0D =0D + // Initialize floating point operating environment to be compliant with = UEFI spec.=0D + InitializeFloatingPointUnits ();=0D +=0D + //=0D + // Mask off all legacy 8259 interrupt sources=0D + //=0D + IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);=0D + IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);=0D +=0D //=0D // Clear page 0 and mark it as allocated if NULL pointer detection is en= abled.=0D //=0D @@ -379,3 +389,17 @@ HandOffToDxeCore ( CpuDeadLoop ();=0D }=0D }=0D +=0D +/**=0D + Entry point to the C language phase of UEFI payload.=0D + @param[in] BootloaderParameter The starting address of bootloader p= arameter block.=0D + @retval It will not return if SUCCESS, and return error when passin= g bootloader parameter.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +_ModuleEntryPoint (=0D + IN UINTN BootloaderParameter=0D + )=0D +{=0D + return FitUplEntryPoint (BootloaderParameter);=0D +}=0D 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 @@ =0D #include "UefiPayloadEntry.h"=0D =0D +/**=0D + Allocates one or more pages of type EfiBootServicesData.=0D +=0D + Allocates the number of pages of MemoryType and returns a pointer to the= =0D + allocated buffer. The buffer returned is aligned on a 4KB boundary.=0D + If Pages is 0, then NULL is returned.=0D + If there is not enough memory availble to satisfy the request, then NULL= =0D + is returned.=0D +=0D + @param Pages The number of 4 KB pages to allocate.=0D + @param MemoryType The MemoryType=0D + @return A pointer to the allocated buffer or NULL if allocation fails.= =0D +**/=0D +VOID *=0D +EFIAPI=0D +PayloadAllocatePages (=0D + IN UINTN Pages,=0D + IN EFI_MEMORY_TYPE MemoryType=0D + )=0D +{=0D + EFI_PEI_HOB_POINTERS Hob;=0D + EFI_PHYSICAL_ADDRESS Offset;=0D + EFI_HOB_HANDOFF_INFO_TABLE *HobTable;=0D +=0D + Hob.Raw =3D GetHobList ();=0D + HobTable =3D Hob.HandoffInformationTable;=0D +=0D + if (Pages =3D=3D 0) {=0D + return NULL;=0D + }=0D +=0D + // Make sure allocation address is page alligned.=0D + Offset =3D HobTable->EfiFreeMemoryTop & EFI_PAGE_MASK;=0D + if (Offset !=3D 0) {=0D + HobTable->EfiFreeMemoryTop -=3D Offset;=0D + }=0D +=0D + //=0D + // Check available memory for the allocation=0D + //=0D + if (HobTable->EfiFreeMemoryTop - ((Pages * EFI_PAGE_SIZE) + sizeof (EFI_= HOB_MEMORY_ALLOCATION)) < HobTable->EfiFreeMemoryBottom) {=0D + return NULL;=0D + }=0D +=0D + HobTable->EfiFreeMemoryTop -=3D Pages * EFI_PAGE_SIZE;=0D + BuildMemoryAllocationHob (HobTable->EfiFreeMemoryTop, Pages * EFI_PAGE_S= IZE, MemoryType);=0D +=0D + return (VOID *)(UINTN)HobTable->EfiFreeMemoryTop;=0D +}=0D +=0D /**=0D Allocates one or more pages of type EfiBootServicesData.=0D =0D 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 ( }=0D =0D /**=0D - Print the information in Resource Discriptor Hob.=0D + Print the information in Resource Descriptor Hob.=0D @param[in] HobStart A pointer to HOB of type EFI_HOB_TYPE_RESOURC= E_DESCRIPTOR.=0D @param[in] HobLength The Length in bytes of HOB of type EFI_HOB_TY= PE_RESOURCE_DESCRIPTOR.=0D @retval EFI_SUCCESS If it completed successfully.=0D **/=0D EFI_STATUS=0D -PrintResourceDiscriptorHob (=0D +PrintResourceDescriptorHob (=0D IN VOID *HobStart,=0D IN UINT16 HobLength=0D )=0D @@ -620,7 +620,7 @@ PrintFv3Hob ( HOB_PRINT_HANDLER_TABLE mHobHandles[] =3D {=0D { EFI_HOB_TYPE_HANDOFF, "EFI_HOB_TYPE_HANDOFF", = PrintHandOffHob },=0D { EFI_HOB_TYPE_MEMORY_ALLOCATION, "EFI_HOB_TYPE_MEMORY_ALLOCATION", = PrintMemoryAllocationHob },=0D - { EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR", = PrintResourceDiscriptorHob },=0D + { EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR", = PrintResourceDescriptorHob },=0D { EFI_HOB_TYPE_GUID_EXTENSION, "EFI_HOB_TYPE_GUID_EXTENSION", = PrintGuidHob },=0D { EFI_HOB_TYPE_FV, "EFI_HOB_TYPE_FV", = PrintFvHob },=0D { EFI_HOB_TYPE_CPU, "EFI_HOB_TYPE_CPU", = PrintCpuHob },=0D 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 ( Status =3D UniversalLoadDxeCore (DxeFv, &DxeCoreEntryPoint);=0D ASSERT_EFI_ERROR (Status);=0D =0D - //=0D - // Mask off all legacy 8259 interrupt sources=0D - //=0D - IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);=0D - IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);=0D -=0D Hob.HandoffInformationTable =3D (EFI_HOB_HANDOFF_INFO_TABLE *)GetFirstHo= b (EFI_HOB_TYPE_HANDOFF);=0D HandOffToDxeCore (DxeCoreEntryPoint, Hob);=0D =0D 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 #include =0D #include =0D #include =0D +#include =0D #include "X64/VirtualMemory.h"=0D #include "UefiPayloadEntry.h"=0D #define STACK_SIZE 0x20000=0D =0D +extern VOID *mHobList;=0D +=0D /**=0D Transfers control to DxeCore.=0D =0D @@ -40,6 +43,15 @@ HandOffToDxeCore ( VOID *GhcbBase;=0D UINTN GhcbSize;=0D =0D + // Initialize floating point operating environment to be compliant with = UEFI spec.=0D + InitializeFloatingPointUnits ();=0D +=0D + //=0D + // Mask off all legacy 8259 interrupt sources=0D + //=0D + IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);=0D + IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);=0D +=0D //=0D // Clear page 0 and mark it as allocated if NULL pointer detection is en= abled.=0D //=0D 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 @@ /** @file=0D x64-specifc functionality for DxeLoad.=0D =0D -Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
=0D -SPDX-License-Identifier: BSD-2-Clause-Patent=0D + Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D =0D @@ -13,10 +13,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =0D #include =0D #include =0D +#include =0D +#include =0D #include "X64/VirtualMemory.h"=0D #include "UefiPayloadEntry.h"=0D #define STACK_SIZE 0x20000=0D =0D +extern VOID *mHobList;=0D +=0D /**=0D Transfers control to DxeCore.=0D =0D @@ -40,6 +44,15 @@ HandOffToDxeCore ( VOID *GhcbBase;=0D UINTN GhcbSize;=0D =0D + // Initialize floating point operating environment to be compliant with = UEFI spec.=0D + InitializeFloatingPointUnits ();=0D +=0D + //=0D + // Mask off all legacy 8259 interrupt sources=0D + //=0D + IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);=0D + IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);=0D +=0D //=0D // Clear page 0 and mark it as allocated if NULL pointer detection is en= abled.=0D //=0D @@ -106,3 +119,17 @@ HandOffToDxeCore ( TopOfStack=0D );=0D }=0D +=0D +/**=0D + Entry point to the C language phase of UEFI payload.=0D + @param[in] BootloaderParameter The starting address of bootloader p= arameter block.=0D + @retval It will not return if SUCCESS, and return error when passin= g bootloader parameter.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +_ModuleEntryPoint (=0D + IN UINTN BootloaderParameter=0D + )=0D +{=0D + return FitUplEntryPoint (BootloaderParameter);=0D +}=0D 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]=0D X64/VirtualMemory.h=0D X64/VirtualMemory.c=0D - Ia32/DxeLoadFunc.c=0D + Ia32/DxeLoadFuncFit.c=0D Ia32/IdtVectorAsm.nasm=0D =0D [Sources.X64]=0D X64/VirtualMemory.h=0D X64/VirtualMemory.c=0D - X64/DxeLoadFunc.c=0D + X64/DxeLoadFuncFit.c=0D =0D [Packages]=0D MdePkg/MdePkg.dec=0D @@ -54,6 +54,8 @@ PeCoffLib=0D CpuLib=0D FdtLib=0D + CustomFdtNodeParserLib=0D + PcdLib=0D =0D [Guids]=0D gEfiMemoryTypeInformationGuid=0D @@ -71,6 +73,7 @@ gUniversalPayloadAcpiTableGuid=0D gUniversalPayloadPciRootBridgeInfoGuid=0D gUniversalPayloadSmbios3TableGuid=0D + gUniversalPayloadDeviceTreeGuid=0D =0D [FeaturePcd.IA32]=0D gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUME= S=0D @@ -78,7 +81,6 @@ [FeaturePcd.X64]=0D gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables ## CONSUME= S=0D =0D -=0D [Pcd.IA32,Pcd.X64]=0D gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile=0D gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ##= SOMETIMES_CONSUMES=0D @@ -88,11 +90,19 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ##= CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase ##= CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize ##= CONSUMES=0D -=0D gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemBase=0D gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize=0D gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize=0D -=0D gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIM= ES_CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIM= ES_CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIM= ES_CONSUMES=0D + gUefiPayloadPkgTokenSpaceGuid.PcdHandOffFdtEnable=0D + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS=0D + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory=0D + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType=0D + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData=0D + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode=0D +=0D +[BuildOptions]=0D + MSFT:*_*_*_CC_FLAGS =3D /wd4244 /wd4305=0D + GCC:*_*_*_CC_FLAGS =3D -Wno-error=3Dpointer-to-int-cast -Wno-error=3Din= t-to-pointer-cast=0D 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 @@ #include =0D #include =0D #include =0D +#include =0D #include =0D =0D #define LEGACY_8259_MASK_REGISTER_MASTER 0x21=0D @@ -134,6 +135,31 @@ UniversalLoadDxeCore ( OUT PHYSICAL_ADDRESS *DxeCoreEntryPoint=0D );=0D =0D +/**=0D + It will Parse FDT -node based on information.=0D + @param[in] FdtBase The starting memory address of FdtBase=0D + @retval HobList The base address of Hoblist.=0D +=0D +**/=0D +UINT64=0D +EFIAPI=0D +FdtNodeParser (=0D + IN VOID *FdtBase=0D + );=0D +=0D +/**=0D + It will Parse FDT -custom node based on information.=0D + @param[in] FdtBase The starting memory address of FdtBase=0D + @param[in] HostList The starting memory address of New Hob list.=0D +=0D +**/=0D +UINTN=0D +EFIAPI=0D +CustomFdtNodeParser (=0D + IN VOID *FdtBase,=0D + IN VOID *HostList=0D + );=0D +=0D /**=0D Transfers control to DxeCore.=0D =0D @@ -206,4 +232,46 @@ BuildHobFromAcpi ( IN UINT64 AcpiTableBase=0D );=0D =0D +/**=0D + Allocates one or more pages .=0D +=0D + Allocates the number of pages of MemoryType and returns a pointer to the= =0D + allocated buffer. The buffer returned is aligned on a 4KB boundary.=0D + If Pages is 0, then NULL is returned.=0D + If there is not enough memory availble to satisfy the request, then NULL= =0D + is returned.=0D +=0D + @param Pages The number of 4 KB pages to allocate.=0D + @param MemoryType The Memorytype=0D + @return A pointer to the allocated buffer or NULL if allocation fails.= =0D +**/=0D +VOID *=0D +EFIAPI=0D +PayloadAllocatePages (=0D + IN UINTN Pages,=0D + IN EFI_MEMORY_TYPE MemoryType=0D + );=0D +=0D +/**=0D + Entry point to the C language phase of UEFI payload.=0D + @param[in] FdtPrt The starting address of FDT .=0D + @retval It will not return if SUCCESS, and return error when passin= g bootloader parameter.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +FitUplEntryPoint (=0D + IN UINTN BootloaderParameter=0D + );=0D +=0D +/**=0D + Entry point to the C language phase of UEFI payload.=0D + @param[in] BootloaderParameter The starting address of bootloader p= arameter block.=0D + @retval It will not return if SUCCESS, and return error when passin= g bootloader parameter.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +UplEntryPoint (=0D + IN UINTN BootloaderParameter=0D + );=0D +=0D #endif=0D 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 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D -=0D [Defines]=0D INF_VERSION =3D 1.30=0D BASE_NAME =3D UniversalPayloadEntry=0D FILE_GUID =3D D4F0F269-1209-4A66-8039-C4D5A700EA4E= =0D MODULE_TYPE =3D SEC=0D VERSION_STRING =3D 1.0=0D -=0D #=0D # The following information is for reference only and not required by the = build tools.=0D #=0D # VALID_ARCHITECTURES =3D IA32 X64=0D #=0D -=0D [Sources]=0D UniversalPayloadEntry.c=0D LoadDxeCore.c=0D MemoryAllocation.c=0D PrintHob.c=0D AcpiTable.c=0D -=0D [Sources.Ia32]=0D X64/VirtualMemory.h=0D X64/VirtualMemory.c=0D Ia32/DxeLoadFunc.c=0D Ia32/IdtVectorAsm.nasm=0D -=0D [Sources.X64]=0D X64/VirtualMemory.h=0D X64/VirtualMemory.c=0D X64/DxeLoadFunc.c=0D -=0D [Packages]=0D MdePkg/MdePkg.dec=0D MdeModulePkg/MdeModulePkg.dec=0D UefiCpuPkg/UefiCpuPkg.dec=0D UefiPayloadPkg/UefiPayloadPkg.dec=0D -=0D [LibraryClasses]=0D BaseMemoryLib=0D DebugLib=0D @@ -69,14 +62,12 @@ gUniversalPayloadAcpiTableGuid=0D gUniversalPayloadPciRootBridgeInfoGuid=0D gUniversalPayloadSmbios3TableGuid=0D -=0D + gUniversalPayloadBaseGuid=0D + gUniversalPayloadDeviceTreeGuid=0D [FeaturePcd.IA32]=0D gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUME= S=0D -=0D [FeaturePcd.X64]=0D gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables ## CONSUME= S=0D -=0D -=0D [Pcd.IA32,Pcd.X64]=0D gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile=0D gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ##= SOMETIMES_CONSUMES=0D @@ -86,12 +77,9 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ##= CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase ##= CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize ##= CONSUMES=0D -=0D gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemBase=0D gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize=0D gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize=0D -=0D gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIM= ES_CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIM= ES_CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIM= ES_CONSUMES=0D -=0D 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 @@ # ELF: Build UniversalPayload file as UniversalPayload.elf=0D # FIT: Build UniversalPayload file as UniversalPayload.fit=0D #=0D - DEFINE UNIVERSAL_PAYLOAD =3D FALSE=0D + DEFINE UNIVERSAL_PAYLOAD =3D TRUE=0D DEFINE UNIVERSAL_PAYLOAD_FORMAT =3D ELF=0D =0D #=0D @@ -226,6 +226,7 @@ OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf=0D RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf=0D HobLib|UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf=0D + CustomFdtNodeParserLib|UefiPayloadPkg/Library/CustomFdtNodeParserNullLib= /CustomFdtNodeParserNullLib.inf=0D =0D #=0D # UEFI & PI=0D @@ -470,6 +471,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0=0D gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE=0D gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE=0D + gUefiPayloadPkgTokenSpaceGuid.PcdHandOffFdtEnable|TRUE=0D +=0D =0D gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c= , 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0= x31 }=0D gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, 0x80,= 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, 0x41 }=0D @@ -513,7 +516,15 @@ !endif=0D !endif=0D =0D +=0D [PcdsPatchableInModule.X64]=0D + #=0D + # The following parameters are set by Library/PlatformHookLib=0D + #=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|FALSE=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x3F8=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate|$(BAUD_RATE)=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|1=0D !if $(NETWORK_DRIVER_ENABLE) =3D=3D TRUE=0D gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE=0D !endif=0D @@ -635,7 +646,13 @@ !if $(UNIVERSAL_PAYLOAD_FORMAT) =3D=3D "ELF"=0D UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf=0D !elseif $(UNIVERSAL_PAYLOAD_FORMAT) =3D=3D "FIT"=0D - UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf=0D + UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf {=0D + =0D + FdtLib|MdePkg/Library/BaseFdtLib/BaseFdtLib.inf=0D + CustomFdtNodeParserLib|UefiPayloadPkg/Library/CustomFdtNodeParse= rLib/CustomFdtNodeParserLib.inf=0D + NULL|UefiPayloadPkg/Library/FdtParserLib/FdtParseLib.inf=0D + NULL|UefiPayloadPkg/Library/HobParseLib/HobParseLib.inf=0D + }=0D !else=0D UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf=0D !endif=0D @@ -648,7 +665,13 @@ !if $(UNIVERSAL_PAYLOAD_FORMAT) =3D=3D "ELF"=0D UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf=0D !elseif $(UNIVERSAL_PAYLOAD_FORMAT) =3D=3D "FIT"=0D - UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf=0D + UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf {=0D + =0D + FdtLib|MdePkg/Library/BaseFdtLib/BaseFdtLib.inf=0D + CustomFdtNodeParserLib|UefiPayloadPkg/Library/CustomFdtNodeParse= rLib/CustomFdtNodeParserLib.inf=0D + NULL|UefiPayloadPkg/Library/FdtParserLib/FdtParseLib.inf=0D + NULL|UefiPayloadPkg/Library/HobParseLib/HobParseLib.inf=0D + }=0D !else=0D UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf=0D !endif=0D --=20 2.39.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119198): https://edk2.groups.io/g/devel/message/119198 Mute This Topic: https://groups.io/mt/106275998/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-