From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mx.groups.io with SMTP id smtpd.web10.53277.1683789177463820536 for ; Thu, 11 May 2023 00:12:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=v33Wefe2; spf=pass (domain: rivosinc.com, ip: 209.85.210.172, mailfrom: dhaval@rivosinc.com) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-64115eef620so55676129b3a.1 for ; Thu, 11 May 2023 00:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1683789177; x=1686381177; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s0TVE809SLp+eu4+cuvzzyUg4CB7J3kgryfu+H3vbsE=; b=v33Wefe2+uDWYG3Npch538e1No3nTh55+8H1GMFWxkWx6Bih/0Zv4OUkl8wdzyIUzc SQPuCvDFnKyTfAFW2AC14eQUwxhwbHnpI1ILCCBzDDGfNk7QHm3wBtzL5j/IjOBScEO4 oAqxKtbAYlizQZ3iNQGXKV2xK5vKxtg2kJud0w2zQYs4gIYoP/Jgmp0ln3o3xRehn5l0 rbIsrD1kGfnSweJ/V0J/lsmwsRzLewuFjLRQMnrYRU/IXPK4dIHi8sFHwa1PltdF7cMS 2dDshl1smUGLsPjXX7dv+mOsnff86SQ9HTEOrMCJcyaUqCjJaYDYgLehfGVu//VIvfv9 bc9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683789177; x=1686381177; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s0TVE809SLp+eu4+cuvzzyUg4CB7J3kgryfu+H3vbsE=; b=SL/X7t0g7n+Je7gIYl+LttRDlfVYuSzFt0IgjF9uEPtDNZZ0gYTxU8ubDnR7uOhKO6 ZoQjm5bwDzyeEdh+xZ3kgCyXu7oZATBoquu/cmeIqkxWYS2OqgtL5Y4sJQTgzhfTsNDL wBRb0bxOUwzsh9akv3XfqvTcR+tF7MWt3XpAsAvZmqGJhWcy3ZyTJksObu2iINJ19sYT tM5QhE+BPIR9UwuB6+zM25dYrHfjj6EOubZOwEmap0VQbEz76Z5349Xkd67HlhlmkD7B RxADODdQB9ebH/seruPwwlwI2lBQF8lHE/C73ZA+UyFA6Gi088G6T1dV1r44k6Aidz06 hnQg== X-Gm-Message-State: AC+VfDxRExCPBvn9ewxXMFBuikCD2QOnNzlheCT8YrxSepnK8NXy1w4n BXasOdHqbhAXmfX9f2v83cg2iYjrxGjhtloSPi0= X-Google-Smtp-Source: ACHHUZ77/od2ZR3m3OW/bm9qyqq4WhSF+gaFv/nSrM8ztS8PWKnK8kiSUp/UG8/+CdSAdToYP5+APA== X-Received: by 2002:a17:902:f685:b0:1ac:731b:bc9a with SMTP id l5-20020a170902f68500b001ac731bbc9amr17780508plg.27.1683789176696; Thu, 11 May 2023 00:12:56 -0700 (PDT) Return-Path: Received: from dhaval.. ([42.106.13.180]) by smtp.gmail.com with ESMTPSA id w20-20020a1709029a9400b001a9884c02e3sm5111214plp.10.2023.05.11.00.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 00:12:56 -0700 (PDT) From: "Dhaval Sharma" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Sean Rhodes , James Lu , Gua Guo , Sunil V Subject: [PATCH v1 5/8] UefiPayloadPkg: Hook to parse IN params as per UPL spec Date: Thu, 11 May 2023 12:42:23 +0530 Message-Id: <20230511071226.19726-6-dhaval@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230511071226.19726-1-dhaval@rivosinc.com> References: <20230511071226.19726-1-dhaval@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Provide an arch specific hook which will consume IN params to UPL and populate FDT variable properly. Each Arch has its own ABI and accordingly input param changes. First part, This hook will ensure correct input param is used to populate FDT value. Second part, after finding proper FDT, it uses FDT to create HOBs that are later consumed by UPL.New implementation may remove HOB creation as per latest spec. First part will still be relevant. Test: Able to parse FDT, create HOBs and get serial debug logs. Cc: Guo Dong Cc: Ray Ni Cc: Sean Rhodes Cc: James Lu Cc: Gua Guo Cc: Sunil V Signed-off-by: Dhaval Sharma --- UefiPayloadPkg/UefiPayloadPkg.dsc | 2 +- UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf | 6 + UefiPayloadPkg/UefiPayloadEntry/Ia32/Ia32FdtParserLib.c | 33 ++ UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c | 469 +++++++++= +++++++++++ UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 13 +- UefiPayloadPkg/UefiPayloadEntry/X64/X64FdtParserLib.c | 33 ++ 6 files changed, 553 insertions(+), 3 deletions(-) diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload= Pkg.dsc index 998d22290922..e5eac44d06b2 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -305,7 +305,7 @@ [LibraryClasses] VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseV= ariableFlashInfoLib.inf=0D CcExitLib|UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf=0D ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeRepor= tStatusCodeLib.inf=0D -=0D + FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf=0D [LibraryClasses.common]=0D !if $(BOOTSPLASH_IMAGE)=0D SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf=0D diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf b/Ue= fiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf index 14d072e1198f..9b21b218a657 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf @@ -32,19 +32,23 @@ [Sources.Ia32] X64/VirtualMemory.c=0D Ia32/DxeLoadFunc.c=0D Ia32/IdtVectorAsm.nasm=0D + Ia32/Ia32FdtParserLib.c=0D =0D [Sources.X64]=0D X64/VirtualMemory.h=0D X64/VirtualMemory.c=0D X64/DxeLoadFunc.c=0D + X64/X64FdtParserLib.c=0D =0D [Sources.RISCV64]=0D RiscV64/DxeLoadFunc.c=0D + RiscV64/Rv64FdtParserLib.c=0D [Packages]=0D MdePkg/MdePkg.dec=0D MdeModulePkg/MdeModulePkg.dec=0D UefiCpuPkg/UefiCpuPkg.dec=0D UefiPayloadPkg/UefiPayloadPkg.dec=0D + EmbeddedPkg/EmbeddedPkg.dec=0D =0D [LibraryClasses]=0D BaseMemoryLib=0D @@ -55,6 +59,7 @@ [LibraryClasses] HobLib=0D PeCoffLib=0D CpuLib=0D + FdtLib=0D =0D [Guids]=0D gEfiMemoryTypeInformationGuid=0D @@ -72,6 +77,7 @@ [Guids] gUniversalPayloadPciRootBridgeInfoGuid=0D gUniversalPayloadSmbios3TableGuid=0D gEdkiiBootManagerMenuFileGuid=0D + gFdtHobGuid=0D =0D [FeaturePcd.IA32]=0D gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUME= S=0D diff --git a/UefiPayloadPkg/UefiPayloadEntry/Ia32/Ia32FdtParserLib.c b/Uefi= PayloadPkg/UefiPayloadEntry/Ia32/Ia32FdtParserLib.c new file mode 100644 index 000000000000..ec35834a782b --- /dev/null +++ b/UefiPayloadPkg/UefiPayloadEntry/Ia32/Ia32FdtParserLib.c @@ -0,0 +1,33 @@ +/** @file=0D + This library will parse the coreboot table in memory and extract those r= equired=0D + information.=0D +=0D + Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +EFI_STATUS=0D +BuildBlHobs (=0D + IN UINTN Param1,=0D + IN UINTN Param2,=0D + OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv=0D + );=0D +=0D +/**=0D + It will build HOBs based on information from bootloaders.=0D +=0D + @param[in] Param1 Hard ID=0D + @param[in] Param2 FDT blob pointer=0D + @param[out] DxeFv The pointer to the DXE FV in memory.=0D +=0D + @retval EFI_SUCCESS If it completed successfully.=0D +**/=0D +EFI_STATUS=0D +BuildBlHobs (=0D + IN UINTN Param1,=0D + IN UINTN Param2,=0D + OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv=0D + )=0D +{=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c b/U= efiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c new file mode 100644 index 000000000000..76f0600482f7 --- /dev/null +++ b/UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c @@ -0,0 +1,469 @@ +/** @file=0D + This library will parse the coreboot table in memory and extract those r= equired=0D + information.=0D +=0D + Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#define E820_RAM 1=0D +#define E820_RESERVED 2=0D +#define E820_ACPI 3=0D +#define E820_NVS 4=0D +#define E820_UNUSABLE 5=0D +#define E820_DISABLED 6=0D +#define E820_PMEM 7=0D +#define E820_UNDEFINED 8=0D +=0D +/**=0D + Auto-generated function that calls the library constructors for all of t= he module's=0D + dependent libraries.=0D +**/=0D +VOID=0D +EFIAPI=0D +ProcessLibraryConstructorList (=0D + VOID=0D + );=0D +=0D +/**=0D + Add a new HOB to the HOB List.=0D +=0D + @param HobType Type of the new HOB.=0D + @param HobLength Length of the new HOB to allocate.=0D +=0D + @return NULL if there is no space to create a hob.=0D + @return The address point to the new created hob.=0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +CreateHob (=0D + IN UINT16 HobType,=0D + IN UINT16 HobLength=0D + );=0D +=0D +/**=0D + Build a Handoff Information Table HOB.=0D +=0D + This function initialize a HOB region from EfiMemoryBegin to=0D + EfiMemoryTop. And EfiFreeMemoryBottom and EfiFreeMemoryTop should=0D + be inside the HOB region.=0D +=0D + @param[in] EfiMemoryBottom Total memory start address=0D + @param[in] EfiMemoryTop Total memory end address.=0D + @param[in] EfiFreeMemoryBottom Free memory start address=0D + @param[in] EfiFreeMemoryTop Free memory end address.=0D +=0D + @return The pointer to the handoff HOB table.=0D +**/=0D +EFI_HOB_HANDOFF_INFO_TABLE *=0D +EFIAPI=0D +HobConstructor (=0D + IN VOID *EfiMemoryBottom,=0D + IN VOID *EfiMemoryTop,=0D + IN VOID *EfiFreeMemoryBottom,=0D + IN VOID *EfiFreeMemoryTop=0D + );=0D +=0D +/**=0D + Build ACPI board info HOB using infomation from ACPI table.=0D +=0D + @param AcpiTableBase ACPI table start address in memory=0D + @retval A pointer to ACPI board HOB ACPI_BOARD_INFO. Null if build HOB = failure.=0D +**/=0D +ACPI_BOARD_INFO *=0D +BuildHobFromAcpi (=0D + IN UINT64 AcpiTableBase=0D + );=0D +=0D +/**=0D + Callback function to build resource descriptor HOB.=0D +=0D + This function build a HOB based on the memory map entry info.=0D + Only add EFI_RESOURCE_SYSTEM_MEMORY.=0D +=0D + @param MemoryMapEntry Memory map entry info got from bootloader= .=0D +=0D + @retval RETURN_SUCCESS Successfully build a HOB.=0D +**/=0D +EFI_STATUS=0D +MemInfoCallback (=0D + IN MEMORY_MAP_ENTRY *MemoryMapEntry=0D + )=0D +{=0D + EFI_RESOURCE_ATTRIBUTE_TYPE Attribue;=0D +=0D + Attribue =3D EFI_RESOURCE_ATTRIBUTE_PRESENT |=0D + EFI_RESOURCE_ATTRIBUTE_INITIALIZED |=0D + EFI_RESOURCE_ATTRIBUTE_TESTED |=0D + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |=0D + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |=0D + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |=0D + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE;=0D +=0D + BuildResourceDescriptorHob (MemoryMapEntry->Type, Attribue, (EFI_PHYSICA= L_ADDRESS)MemoryMapEntry->Base, MemoryMapEntry->Size);=0D + DEBUG ((DEBUG_INFO, "buildhob: base =3D 0x%lx, size =3D 0x%lx, type =3D = 0x%x\n", MemoryMapEntry->Base, MemoryMapEntry->Size, MemoryMapEntry->Type))= ;=0D +=0D + if (MemoryMapEntry->Type =3D=3D E820_ACPI) {=0D + BuildMemoryAllocationHob (MemoryMapEntry->Base, MemoryMapEntry->Size, = EfiACPIReclaimMemory);=0D + } else if (MemoryMapEntry->Type =3D=3D E820_NVS) {=0D + BuildMemoryAllocationHob (MemoryMapEntry->Base, MemoryMapEntry->Size, = EfiACPIMemoryNVS);=0D + }=0D +=0D + return RETURN_SUCCESS;=0D +}=0D +=0D +/**=0D + Build memory hob from FDT.=0D +=0D + @param Fdt=0D + @retval Status: Success/Failure=0D +**/=0D +RETURN_STATUS=0D +EFIAPI=0D +BuildMemHobFromFDT (=0D + CONST VOID *Fdt=0D + )=0D +{=0D + MEMORY_MAP_ENTRY MemoryMap;=0D + MEMORY_MAP_ENTRY RsvdMemoryMap;=0D + CONST INT32 *Prop;=0D + INT32 AddressCells;=0D + INT32 SizeCells;=0D + INT32 Length;=0D + INT32 MemoryNode;=0D +=0D + if (fdt_check_header (Fdt) !=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + DEBUG ((DEBUG_INFO, "Fdt Arg =3D 0x%x. fdt_check_header() =3D %d\n", Fdt= , fdt_check_header ((VOID *)Fdt)));=0D + DEBUG ((DEBUG_INFO, "fdt_num_mem_rsv() =3D %d\n", fdt_num_mem_rsv ((VOID= *)Fdt)));=0D +=0D + //=0D + // Look for a node called "memory" at the lowest level of the tree=0D + //=0D + MemoryNode =3D fdt_path_offset (Fdt, "/reserved-memory/mmode_resv0@80000= 000");=0D + if (MemoryNode <=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + //=0D + // Retrieve the #address-cells and #size-cells properties=0D + // from the root node, or use the default if not provided.=0D + //=0D + AddressCells =3D 1;=0D + SizeCells =3D 1;=0D +=0D + Prop =3D fdt_getprop (Fdt, 0, "#address-cells", &Length);=0D + if (Length =3D=3D 4) {=0D + AddressCells =3D fdt32_to_cpu (*Prop);=0D + }=0D +=0D + Prop =3D fdt_getprop (Fdt, 0, "#size-cells", &Length);=0D + if (Length =3D=3D 4) {=0D + SizeCells =3D fdt32_to_cpu (*Prop);=0D + }=0D +=0D + //=0D + // Now find the 'reg' property of the /memory node, and read the first=0D + // range listed.=0D + //=0D + Prop =3D fdt_getprop (Fdt, MemoryNode, "reg", &Length);=0D +=0D + if (Length < (AddressCells + SizeCells) * sizeof (INT32)) {=0D + return FALSE;=0D + }=0D +=0D + UINT32 Ranges;=0D +=0D + Ranges =3D Length / ((AddressCells + SizeCells) * sizeof (INT32));=0D +=0D + UINT32 Range;=0D +=0D + for (Range =3D 0; Range < Ranges; Range++) {=0D + UINT64 Address, Size;=0D + Address =3D fdt32_to_cpu (Prop[0]);=0D + if (AddressCells > 1) {=0D + Address =3D (Address << 32) | fdt32_to_cpu (Prop[1]);=0D + }=0D +=0D + Prop +=3D AddressCells;=0D + Size =3D fdt32_to_cpu (Prop[0]);=0D + if (SizeCells > 1) {=0D + Size =3D (Size << 32) | fdt32_to_cpu (Prop[1]);=0D + }=0D +=0D + Prop +=3D SizeCells;=0D +=0D + RsvdMemoryMap.Base =3D Address;=0D + RsvdMemoryMap.Size =3D Size;=0D + RsvdMemoryMap.Type =3D EFI_RESOURCE_MEMORY_RESERVED;=0D + RsvdMemoryMap.Flag =3D 0;=0D + MemInfoCallback (&RsvdMemoryMap);=0D + }=0D +=0D + //=0D + // Look for a node called "memory" at the lowest level of the tree=0D + //=0D + MemoryNode =3D fdt_path_offset (Fdt, "/memory");=0D + if (MemoryNode <=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + //=0D + // Now find the 'reg' property of the /memory node, and read the first=0D + // range listed.=0D + //=0D + Prop =3D fdt_getprop (Fdt, MemoryNode, "reg", &Length);=0D + if (Length < (AddressCells + SizeCells) * sizeof (INT32)) {=0D + return FALSE;=0D + }=0D +=0D + Ranges =3D Length / ((AddressCells + SizeCells) * sizeof (INT32));=0D +=0D + for (Range =3D 0; Range < Ranges; Range++) {=0D + UINT64 Address, Size;=0D + Address =3D fdt32_to_cpu (Prop[0]);=0D + if (AddressCells > 1) {=0D + Address =3D (Address << 32) | fdt32_to_cpu (Prop[1]);=0D + }=0D +=0D + Prop +=3D AddressCells;=0D +=0D + Size =3D fdt32_to_cpu (Prop[0]);=0D + if (SizeCells > 1) {=0D + Size =3D (Size << 32) | fdt32_to_cpu (Prop[1]);=0D + }=0D +=0D + Prop +=3D SizeCells;=0D +=0D + /* For now make an assumption that we will have one mem rsvd=0D + region from BL. FDT seems to create overlapping regions as in=0D + total mem range includes rsvd range as well. So we need to=0D + adjust the available mem base accordingly otherwise GCD does=0D + not like it */=0D +=0D + MemoryMap.Base =3D Address + RsvdMemoryMap.Size; // address;=0D + MemoryMap.Size =3D Size - RsvdMemoryMap.Size;=0D + MemoryMap.Type =3D EFI_RESOURCE_SYSTEM_MEMORY;=0D + MemoryMap.Flag =3D 0;=0D + MemInfoCallback (&MemoryMap);=0D + }=0D +=0D + return RETURN_SUCCESS;=0D +}=0D +=0D +/**=0D + Build Serial info HOB using infomation from FDT.=0D +=0D + @param Fdt=0D + @param UniversalSerialPort=0D +=0D + @retval Pointer to Universal Serial Port.=0D +**/=0D +RETURN_STATUS=0D +EFIAPI=0D +BuildSerialHobFromFDT (=0D + IN CONST VOID *Fdt,=0D + OUT UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *UniversalSerialPort=0D + )=0D +{=0D + CONST INT32 *Prop;=0D + INT32 Length;=0D + INT32 SerialNode;=0D + UINT32 Freq;=0D + UINT64 Address;=0D +=0D + if (fdt_check_header (Fdt) !=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + //=0D + // Look for "compatible property with value "ns16550a"=0D + //=0D + SerialNode =3D fdt_path_offset (Fdt, "/soc");=0D + if (SerialNode <=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + SerialNode =3D fdt_node_offset_by_prop_value (Fdt, SerialNode, "compatib= le", "ns16550a", strlen ("ns16550a")+1);=0D +=0D + if (SerialNode <=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + //=0D + // Now find the 'reg' property of the /memory node, and read the first=0D + // range listed.=0D + //=0D + Prop =3D fdt_getprop (Fdt, SerialNode, "reg", &Length);=0D + Address =3D fdt32_to_cpu (Prop[0]);=0D + Address =3D (Address << 32) | fdt32_to_cpu (Prop[1]);=0D +=0D + Prop =3D fdt_getprop (Fdt, SerialNode, "clock-frequency", &Length);=0D + Freq =3D fdt32_to_cpu (Prop[0]);=0D +=0D + UniversalSerialPort->Header.Revision =3D UNIVERSAL_PAYLOAD_SERIAL_PORT_I= NFO_REVISION;=0D + UniversalSerialPort->Header.Length =3D sizeof (UNIVERSAL_PAYLOAD_SERIA= L_PORT_INFO);=0D + UniversalSerialPort->UseMmio =3D TRUE;=0D + UniversalSerialPort->RegisterBase =3D Address;=0D + UniversalSerialPort->BaudRate =3D Freq;=0D + UniversalSerialPort->RegisterStride =3D 1;=0D +=0D + return TRUE;=0D +}=0D +=0D +EFI_STATUS=0D +BuildBlHobs (=0D + IN UINTN Param1,=0D + IN UINTN Param2,=0D + OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv=0D + );=0D +=0D +/**=0D + It will build HOBs based on information from bootloaders.=0D +=0D + @param[in] Param1 Hard ID=0D + @param[in] Param2 FDT blob pointer=0D + @param[out] DxeFv The pointer to the DXE FV in memory.=0D +=0D + @retval EFI_SUCCESS If it completed successfully.=0D +**/=0D +EFI_STATUS=0D +BuildBlHobs (=0D + IN UINTN Param1,=0D + IN UINTN Param2,=0D + OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv=0D + )=0D +{=0D + UINTN MinimalNeededSize;=0D + EFI_PHYSICAL_ADDRESS FreeMemoryBottom;=0D + EFI_PHYSICAL_ADDRESS FreeMemoryTop;=0D + EFI_PHYSICAL_ADDRESS MemoryBottom;=0D + UINT8 *GuidHob;=0D + UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTable;=0D + ACPI_BOARD_INFO *AcpiBoardInfo;=0D + UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *UniversalSerialPort;=0D + VOID *NewBase;=0D + UINTN FdtSize;=0D + UINTN FdtPages;=0D + UINT64 *FdtHobData;=0D + CONST VOID *Fdt;=0D +=0D + Fdt =3D (VOID *)Param2;=0D + MinimalNeededSize =3D FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);=0D +=0D + ASSERT ((UINT8 *)Fdt !=3D NULL);=0D +=0D + // HOB region is used for HOB and memory allocation for this module=0D + MemoryBottom =3D PcdGet32 (PcdPayloadFdMemBase);=0D + FreeMemoryBottom =3D ALIGN_VALUE (MemoryBottom + PcdGet32 (PcdPayloadFdM= emSize), SIZE_1MB);=0D + FreeMemoryTop =3D FreeMemoryBottom + FixedPcdGet32 (PcdSystemMemoryUe= fiRegionSize);=0D +=0D + HobConstructor ((VOID *)(UINTN)MemoryBottom, (VOID *)(UINTN)FreeMemoryTo= p, (VOID *)(UINTN)FreeMemoryBottom, (VOID *)(UINTN)FreeMemoryTop);=0D + //=0D + // Build serial port info=0D + //=0D + UniversalSerialPort =3D BuildGuidHob (&gUniversalPayloadSerialPortInfoGu= id, sizeof (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO));=0D + ASSERT (UniversalSerialPort !=3D NULL);=0D + BuildSerialHobFromFDT (Fdt, UniversalSerialPort);=0D + BuildMemHobFromFDT (Fdt);=0D +=0D + // Build the CPU HOB with guest RAM size dependent address width and 16-= bits=0D + // of IO space. (Side note: unlike other HOBs, the CPU HOB is needed dur= ing=0D + // S3 resume as well, so we build it unconditionally.)=0D + //=0D + // TODO: Determine this dynamically from the platform=0D + // setting or the HART configuration.=0D + //=0D + BuildCpuHob (48, 32);=0D +=0D + ASSERT ((UINT8 *)Fdt !=3D NULL);=0D + ASSERT (fdt_check_header (Fdt) =3D=3D 0);=0D +=0D + FdtSize =3D fdt_totalsize (Fdt);=0D + FdtPages =3D EFI_SIZE_TO_PAGES (FdtSize);=0D + NewBase =3D AllocatePages (FdtPages);=0D + ASSERT (NewBase !=3D NULL);=0D + fdt_open_into (Fdt, NewBase, EFI_PAGES_TO_SIZE (FdtPages));=0D +=0D + FdtHobData =3D BuildGuidHob (&gFdtHobGuid, sizeof *FdtHobData);=0D + ASSERT (FdtHobData !=3D NULL);=0D + *FdtHobData =3D (UINTN)NewBase;=0D +=0D + //=0D + // Create guid hob for acpi board information=0D + //=0D + GuidHob =3D GetFirstGuidHob (&gUniversalPayloadAcpiTableGuid);=0D + if (GuidHob !=3D NULL) {=0D + AcpiTable =3D (UNIVERSAL_PAYLOAD_ACPI_TABLE *)GET_GUID_HOB_DATA (G= uidHob);=0D + AcpiBoardInfo =3D BuildHobFromAcpi ((UINT64)AcpiTable->Rsdp);=0D + ASSERT (AcpiBoardInfo !=3D NULL);=0D + }=0D +=0D + *DxeFv =3D (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdPayloadFdMe= mBase);=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Acquire SMBIOS table from Boot Loader.Get a pointer from BL via FDT.=0D +=0D + @param SmbiosTable Pointer to the SMBIOS table info.=0D +=0D + @retval RETURN_SUCCESS Successfully find out the tables.=0D + @retval RETURN_NOT_FOUND Failed to find the tables.=0D +=0D +**/=0D +RETURN_STATUS=0D +EFIAPI=0D +ParseSmbiosTable (=0D + OUT UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmbiosTable=0D + )=0D +{=0D + return RETURN_SUCCESS;=0D +}=0D +=0D +/**=0D + Acquire ACPI table from Boot loader.Get a pointer from BL via FDT=0D +=0D + @param AcpiTableHob Pointer to the ACPI table info.=0D +=0D + @retval RETURN_SUCCESS Successfully find out the tables.=0D + @retval RETURN_NOT_FOUND Failed to find the tables.=0D +=0D +**/=0D +RETURN_STATUS=0D +EFIAPI=0D +ParseAcpiTableInfo (=0D + OUT UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob=0D + )=0D +{=0D + return RETURN_SUCCESS;=0D +}=0D diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c b/Uefi= PayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c index 59cb4d56e314..5c8503e30279 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c @@ -440,10 +440,18 @@ BuildHobs ( return EFI_SUCCESS;=0D }=0D =0D +EFI_STATUS=0D +BuildBlHobs (=0D + IN UINTN Param1,=0D + IN UINTN Param2,=0D + OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv=0D + );=0D +=0D /**=0D Entry point to the C language phase of UEFI payload.=0D =0D - @param[in] BootloaderParameter The starting address of bootloader p= arameter block.=0D + @param[in] Param1 First parameter from the stack=0D + @param[in] Param2 Second parameter from the stack=0D =0D @retval It will not return if SUCCESS, and return error when passin= g bootloader parameter.=0D **/=0D @@ -457,8 +465,9 @@ _ModuleEntryPoint ( EFI_STATUS Status;=0D PHYSICAL_ADDRESS DxeCoreEntryPoint;=0D EFI_PEI_HOB_POINTERS Hob;=0D - EFI_FIRMWARE_VOLUME_HEADER *DxeFv =3D NULL;=0D + EFI_FIRMWARE_VOLUME_HEADER *DxeFv;=0D =0D + BuildBlHobs (Param1, Param2, &DxeFv);=0D // Call constructor for all libraries=0D ProcessLibraryConstructorList ();=0D =0D diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/X64FdtParserLib.c b/UefiPa= yloadPkg/UefiPayloadEntry/X64/X64FdtParserLib.c new file mode 100644 index 000000000000..ec35834a782b --- /dev/null +++ b/UefiPayloadPkg/UefiPayloadEntry/X64/X64FdtParserLib.c @@ -0,0 +1,33 @@ +/** @file=0D + This library will parse the coreboot table in memory and extract those r= equired=0D + information.=0D +=0D + Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +EFI_STATUS=0D +BuildBlHobs (=0D + IN UINTN Param1,=0D + IN UINTN Param2,=0D + OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv=0D + );=0D +=0D +/**=0D + It will build HOBs based on information from bootloaders.=0D +=0D + @param[in] Param1 Hard ID=0D + @param[in] Param2 FDT blob pointer=0D + @param[out] DxeFv The pointer to the DXE FV in memory.=0D +=0D + @retval EFI_SUCCESS If it completed successfully.=0D +**/=0D +EFI_STATUS=0D +BuildBlHobs (=0D + IN UINTN Param1,=0D + IN UINTN Param2,=0D + OUT EFI_FIRMWARE_VOLUME_HEADER **DxeFv=0D + )=0D +{=0D + return EFI_SUCCESS;=0D +}=0D --=20 2.34.1