From nobody Tue Feb 10 03:57:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+95220+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+95220+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1665766138; cv=none; d=zohomail.com; s=zohoarc; b=QJPlADMkAy9V1HCJAFPc16hPd5pS17QvFhEmjPjO9EcpH67dc/x8fWVnG6x+fmxC0zQSiDlapr304M3ufIRVOBB9WKgN380XYGLHofqEj0cDStM8ELQb3t+g2QtXm8zcUZTMdDWhjLzhqIv8Z37lOdnBTFAmAP94NvZBsKX0lwc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665766138; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=QGs/+f44ob6VJHg4XRUxW92Ib71mmMKVfps1kjGHDvw=; b=F7z0jJWxqiObGl7k2LyxkPBbL2fA2gsq8H39QqNHJxCZKYVmLkaAvIYw9abpRKlxIF68K4y0/sj30ISKhmEyCdwaVeAd9vWPOXN660ub1B0wTakorVCcqTTuHx7EptMkrgpRLiatSuROiWrQ6qZLQEpCvj3cpsHD5yVra3ZKOQU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+95220+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 166576613818040.84357668408643; Fri, 14 Oct 2022 09:48:58 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id RyUrYY1788612xePyFpFezvx; Fri, 14 Oct 2022 09:48:57 -0700 X-Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by mx.groups.io with SMTP id smtpd.web12.9571.1665766137254970157 for ; Fri, 14 Oct 2022 09:48:57 -0700 X-Received: by mail-pf1-f175.google.com with SMTP id 67so5392943pfz.12 for ; Fri, 14 Oct 2022 09:48:57 -0700 (PDT) X-Gm-Message-State: ZhIxSvauhDNzVekjrZAxTArFx1787277AA= X-Google-Smtp-Source: AMsMyM4RBudj8fQ6tVZIDs+fKwv/9BVnkrTBvwWbo7VCxKN00UyLAxqaosZehbAZEu3UfJpxb5VXOA== X-Received: by 2002:a63:7:0:b0:45b:693e:7d86 with SMTP id 7-20020a630007000000b0045b693e7d86mr5427735pga.319.1665766136357; Fri, 14 Oct 2022 09:48:56 -0700 (PDT) X-Received: from localhost.localdomain ([49.206.13.138]) by smtp.gmail.com with ESMTPSA id f3-20020a62db03000000b0056265011136sm1963368pfg.112.2022.10.14.09.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 09:48:55 -0700 (PDT) From: "Sunil V L" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann , Daniel Schaefer Subject: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V4 06/34] OvmfPkg/PlatformInitLib: Add support for RISC-V Date: Fri, 14 Oct 2022 22:18:08 +0530 Message-Id: <20221014164836.1513036-7-sunilvl@ventanamicro.com> In-Reply-To: <20221014164836.1513036-1-sunilvl@ventanamicro.com> References: <20221014164836.1513036-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sunilvl@ventanamicro.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1665766137; bh=wEUw1VZEHbGbzAHCBzFFv7ctQpMOmkMMBcnYaCW8Q20=; h=Cc:Date:From:Reply-To:Subject:To; b=gfw9XspIkTo6EfAjnCIkz2CjVz4ohe4Cy22btoTsyybg2kcU1dqMMZ80vdfWFX5MXmV mo3HeHZTHG0A9roQV6jkaoFcoM7/HAgtOvvcMuKgoeYoHL7p9u66f0CqaHAsaJPSbihNQ Rxj0/CR9TLYFFlDn77U4zBXAjH0DlU3jNmk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1665766140250100002 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4076 This is copied from edk2-platforms/Platform/RISC-V/PlatformPkg/Universal/FdtPeim but added as part of library instead of a separate module. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Gerd Hoffmann Cc: Daniel Schaefer Signed-off-by: Sunil V L Acked-by: Abner Chang --- OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf | 9 ++- OvmfPkg/Include/Library/PlatformInitLib.h | 6 ++ OvmfPkg/Library/PlatformInitLib/RiscV64/PlatformPeiLib.c | 72 ++++++++++++= ++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf b/OvmfPkg/= Library/PlatformInitLib/PlatformInitLib.inf index 5d31cad1b670..b3a69bf9582c 100644 --- a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf +++ b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf @@ -19,7 +19,7 @@ [Defines] # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 X64 EBC +# VALID_ARCHITECTURES =3D IA32 X64 EBC RISCV64 # =20 [Sources.IA32, Sources.X64] @@ -33,6 +33,9 @@ [Sources.IA32] [Sources.X64] Ia32X64/IntelTdx.c =20 +[Sources.RISCV64] + RiscV64/PlatformPeiLib.c + [Packages] EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec @@ -58,6 +61,10 @@ [LibraryClasses.IA32, LibraryClasses.X64] [LibraryClasses.X64] TdxLib =20 +[LibraryClasses.RISCV64] + RiscVSbiLib + FdtLib + [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress =20 diff --git a/OvmfPkg/Include/Library/PlatformInitLib.h b/OvmfPkg/Include/Li= brary/PlatformInitLib.h index c5234bf26d45..1b8d1fad3b49 100644 --- a/OvmfPkg/Include/Library/PlatformInitLib.h +++ b/OvmfPkg/Include/Library/PlatformInitLib.h @@ -285,4 +285,10 @@ PlatformInitEmuVariableNvStore ( IN VOID *EmuVariableNvStore ); =20 +EFI_STATUS +EFIAPI +PlatformPeim ( + VOID + ); + #endif // PLATFORM_INIT_LIB_H_ diff --git a/OvmfPkg/Library/PlatformInitLib/RiscV64/PlatformPeiLib.c b/Ovm= fPkg/Library/PlatformInitLib/RiscV64/PlatformPeiLib.c new file mode 100644 index 000000000000..266d5ddff58e --- /dev/null +++ b/OvmfPkg/Library/PlatformInitLib/RiscV64/PlatformPeiLib.c @@ -0,0 +1,72 @@ +/** @file +The library call to pass the device tree to DXE via HOB. + +Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All rights = reserved.
+ +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +// +//// The package level header files this module uses +//// +#include + +#include +#include +#include +#include + +#include + +#include + +/** + @retval EFI_SUCCESS The address of FDT is passed in HOB. + EFI_UNSUPPORTED Can't locate FDT. +**/ +EFI_STATUS +EFIAPI +PlatformPeim ( + VOID + ) +{ + EFI_RISCV_FIRMWARE_CONTEXT *FirmwareContext; + VOID *FdtPointer; + VOID *Base; + VOID *NewBase; + UINTN FdtSize; + UINTN FdtPages; + UINT64 *FdtHobData; + + FirmwareContext =3D NULL; + GetFirmwareContextPointer (&FirmwareContext); + + if (FirmwareContext =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Firmware Context is NULL\n", __FUNCTION__)); + return EFI_UNSUPPORTED; + } + + FdtPointer =3D (VOID *)FirmwareContext->FlattenedDeviceTree; + if (FdtPointer =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Invalid FDT pointer\n", __FUNCTION__)); + return EFI_UNSUPPORTED; + } + + DEBUG ((DEBUG_INFO, "%a: Build FDT HOB - FDT at address: 0x%x \n", __FUN= CTION__, FdtPointer)); + Base =3D FdtPointer; + ASSERT (Base !=3D NULL); + ASSERT (fdt_check_header (Base) =3D=3D 0); + + FdtSize =3D fdt_totalsize (Base); + FdtPages =3D EFI_SIZE_TO_PAGES (FdtSize); + NewBase =3D AllocatePages (FdtPages); + ASSERT (NewBase !=3D NULL); + fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages)); + + FdtHobData =3D BuildGuidHob (&gFdtHobGuid, sizeof *FdtHobData); + ASSERT (FdtHobData !=3D NULL); + *FdtHobData =3D (UINTN)NewBase; + + return EFI_SUCCESS; +} --=20 2.38.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#95220): https://edk2.groups.io/g/devel/message/95220 Mute This Topic: https://groups.io/mt/94330825/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-