From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.40]) by mx.groups.io with SMTP id smtpd.web10.19270.1665840948707195021 for ; Sat, 15 Oct 2022 06:35:49 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=ovW36eG6; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.236.40, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iSlH9rupTod3fpIePHTSFcWmqJFOJIOg3Eq5EtYqSo7smvUkWWBo2uAi4OJuk7vDm/zgtJU8O3rkasXf3Ceh+tKXmSl4Oc1SkqrugW1Nuky+n0dgakKX1Y9Uz43MCv4vTKRqt4c9xIuLO8wkV0GJRPSnqIYaJMT6bSnrfgH86YJRtmTX8ND/HT9C5zixRABuRrypPvAHU1E77F3XV41iMAnfllK9WA+auKFdQVBFoo7r2SAzh0SSE51XT9Y1Wx7DFZ8j1Wpk7nW/YEd+c6SsIunGF+ZaDH8e9pYt0UU1RKAy2q/eIW/2GTCk0u9PqRA+ASohtNjcxIKThVIXFg6YXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2x7y0iruXpcT6/YLJUFzT8w/GVdz21GLQ6EyJpSribA=; b=GahImZV2dHZUYBTK0VU5sQlfyApCf6BiGRGkJUI5t++Gs6bYGVkmBQ89aZvFxDGdEsnGeGuLUc2sPvG3H3NJiiIMYzmct69w3a3RIS2CW0Fjk92dzwcfFegmIT4Z4F0JemNtLoXBly8Sr+a0Lo/jvitSCuM8fnEgx7yGgcN3DiQ7kwN6oU5scL0TD8y4I8U+YxcQAnMN/O4w+eQKbHzJPm7urazWcDrG4TKAdl46F1Hbh2oPVQNeW0bbOjfUL8L+OE11kEHg1NMRspto3gmVCpcEDL8w0sf4u8zi5MZZJKHe13JKOhYQFK4BXAsX5lw47sMA6cL950E3EN8SlVB5ug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2x7y0iruXpcT6/YLJUFzT8w/GVdz21GLQ6EyJpSribA=; b=ovW36eG65tHlB3UTdWPGPD6r1RbBJibMeSkIgVRnsd038ViR5f0UkIwl4eeAvCoS4OXSpoAPjzbrRqGIu7V9ebHC2f2GYGsRCrAxo6se+AvkGZ/R5tWs8lsHH3YBUicfD5+GRiiQJ1M3X3oAGSaooW8gsDaliqsxVH+sAV/CySE= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by DM4PR12MB6448.namprd12.prod.outlook.com (2603:10b6:8:8a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.36; Sat, 15 Oct 2022 13:35:46 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::2eab:b851:827c:1d88]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::2eab:b851:827c:1d88%3]) with mapi id 15.20.5723.030; Sat, 15 Oct 2022 13:35:46 +0000 From: "Chang, Abner" To: "devel@edk2.groups.io" , "sunilvl@ventanamicro.com" CC: Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann , Daniel Schaefer Subject: Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V4 06/34] OvmfPkg/PlatformInitLib: Add support for RISC-V Thread-Topic: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V4 06/34] OvmfPkg/PlatformInitLib: Add support for RISC-V Thread-Index: AQHY3+zuIcwCkhXGOE6SwA353ZiR7K4PdjBw Date: Sat, 15 Oct 2022 13:35:46 +0000 Message-ID: References: <20221014164836.1513036-1-sunilvl@ventanamicro.com> <20221014164836.1513036-7-sunilvl@ventanamicro.com> In-Reply-To: <20221014164836.1513036-7-sunilvl@ventanamicro.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2022-10-15T13:35:43Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=4472b55a-5a74-42f1-92a1-72750ab46ba1; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|DM4PR12MB6448:EE_ x-ms-office365-filtering-correlation-id: 1843ba74-6c33-4b43-0575-08daaeb22a59 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: IIbRs2JIbR1QiaHEx4buDLS2eMi+ldXxVjjIn2fxJgdYj8jDrOPG4dd4D7ZKLmPAMo9sgs9SgXFQ3SJAP1uFTTDLGqbKZ1LkMu9bv3w5jNet6R8qFeeGBmtgR2U4iXoCB8pAnWKHcikKdQoepjf/fTcMNZJTUawsbz5oaVJRD3xUZkJX5YVvwyNmePd+slQM2MrxNWwmCOInFYUlc668k1ae8K7IWIRvuedEz81eWRqoUibLHKukbZuBxNa78NRNDmJOZfsBR+vND9UnM7y/t+eRDXOYf2uyQ1NMCZVqZl2NsmPCQ8yH3fFPCTB9aw3+Jd0PB2vgab8Pye+W4RmXUnjYngvKAO0K+mLYOBAkuPsSGtvTxFdyoXcAj9UNNL/iakIVi1KT5HJWYwmdy3oTRnVCCYejF+anxy1Obf6UKuHyZcfrHDZVfP28PYlqdK6Ui6XZHFmtPGPY5HMOz0pxLiAzDc55SqwhhtzKSQ2z7uAc0leA96CCfPgmNJYnOiDMt3siYI5v1al1PgzOFA5VePRlvXGywxFyEYnA5GQRWv8k7vA2f0ZxIRoUrpvpjacgiHksa24xk4SUZDmAQI59MP52vH38u4KTxyI6lRsQqYrZznjh4RGshN1MF7AVplzDilSKyjGHE9iDcYLMqXRG12zUXXnOMfiNhM0fsvTb9fr0UUag4w3WDRlozebffTUzM/GG7mvRnzHZjwEKsUaGrDVJdQ7uHla+xa/sC4EFRAvadiGLxH/MPbDMshff3eZO3cM5BmoXp/vibz7V1z0w5sUO+6lmcruJyiHIR1SMTrs8HNceFT9cVXaxm5gM/Lxx/31EtGC8mqy37JOIe59t+A== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(396003)(39860400002)(346002)(136003)(376002)(451199015)(966005)(45080400002)(478600001)(66446008)(38070700005)(66946007)(6506007)(66556008)(4326008)(316002)(53546011)(64756008)(7696005)(76116006)(83380400001)(71200400001)(8676002)(110136005)(19627235002)(54906003)(86362001)(122000001)(41300700001)(26005)(38100700002)(33656002)(186003)(9686003)(55016003)(8936002)(2906002)(5660300002)(66899015)(66476007)(52536014);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?UhAIsH2QbuOcrNjbvQ+o/OaFXMpd9HedeOxX6BKF8AekafaMNmx6trm9QFq4?= =?us-ascii?Q?UuiKGRTH7jDMs0dmC9F91rSiVgoBeuglL0cwFWtJHBGCEDCb6NyWbP2S1/27?= =?us-ascii?Q?PK7kcaBXR7vw6jKEb/eEpghK2lFmGSL7L9xEtpoB+rHtolvNWY4rM/niHER9?= =?us-ascii?Q?QNBNufxcYPGvJDuObbUpM/Dskx8czcWirCvkl0hxEOU4FlCZSvZVymfkrO+3?= =?us-ascii?Q?uBctBmE+5YD+0qPiOMgoutYsgMF9xGHGg7U+RhYi22b13WPbC81N8iOqAEUJ?= =?us-ascii?Q?qQtuAIFC95+XQDhPUKrsAuMsE4Sume/YQKDgl3IynLXooV+qWx2Q8Vw6wa0W?= =?us-ascii?Q?0O9zS7JseJ3ThhLMzp7rz8xdra2ExHwLgvCj0N81n/OYmfCevKg9HreEU3pC?= =?us-ascii?Q?21706VTmFVUuXHYn3kGJpigsayMUkfyqPfR3DO/AXBSFk9SAimZkD5DvcOG/?= =?us-ascii?Q?YTxZaTO4w7JunGIW2LdpJo/aeDnDV7A4zBEep0EzFMGDtIB00dF+k8eyWShb?= =?us-ascii?Q?QwNEtoswQgszoV8Dd3CDavOq2Gx3CX6CoF1yfxRJP3rDc1P1yB8jmHZparTq?= =?us-ascii?Q?c3iAZy4fNzSF0I6G2MyZyEILweXtq64nDhRWiSlHGv54Nt9HTMxsfsvze8+K?= =?us-ascii?Q?THu3/9eSMMTXUC1WkbU9/IFOnnTmUdkPnZAPlpRQGoIi566bwUbYao+MIxQF?= =?us-ascii?Q?dxVS8pNgvafOyCFGwm2SFLdj9fIKIMYjvPYVyNlyARmnwQ31D3DxqE500xLC?= =?us-ascii?Q?B6TXhU3UH5NwsOAZPvdspt/l1Y4oxlrLi9t/QF1AsLHaYPLTYLdMmO79wEX5?= =?us-ascii?Q?uHTkmrqPMddfTS60WwoaOGCI5GSuPoB1z826zm4krgL9UQE2bOOErk8iTPLx?= =?us-ascii?Q?TuZFLSWuHOy+UMX4OFMKn0e2L5V2lVR3Fw0to4cE20Lcm55gRuaqqhephhxG?= =?us-ascii?Q?CnF386xoDijtZ1WTajtr7o3u12LGdhBFiXSqhpPApA0Rh+xx4Oav1gcICvxg?= =?us-ascii?Q?i1zMkfKqy6YiA5Z/RuJxpEtzvdUaHrdMv3D6lCkxt5UEbiB4rAMu+7I2sxyW?= =?us-ascii?Q?OR/hZUt7LgACLJrpln/F6M14+ccoUyqbwTKDxPdsJPVH4NME3oZbprpXWEn6?= =?us-ascii?Q?BaWhw9Y+91u4HTOmA8k3KJhKvOyljgnRRir0jNJes+8I9/CD1ZzvxGx4n7l2?= =?us-ascii?Q?Q6ljDhwInLaib26S8xspI/4OI9Yme2Q7f3me3PXhGf/f8dNne8wVm5COtnIM?= =?us-ascii?Q?6MKRcSRI5lvVcbpU7Q78N0il4BYtgdjVC23CuU7RgdrN8e8+OZ2dyfbZiCms?= =?us-ascii?Q?7uu53se/09QwMDD8ZTAomNvoA+A8FdnIjS6f/P+tygtKr1Rue0uKfcqCAx6f?= =?us-ascii?Q?gGmZw533IsrYFCLmPrUEfiPSrymR0zNSAW6yAm7uTGUP10VkVswFyMALmE84?= =?us-ascii?Q?GgZzHeMQlcjEPed+0agkVX/3DRvX/6v4hOgjKtssV0KHXTIC3bUc/AHrwSKC?= =?us-ascii?Q?aNPMdFc9cubCDuSxXcGi7gseAHG7LWk29HpN849Jy1W+pPMa+P08HOTb5Wa7?= =?us-ascii?Q?VE1vJb1ugVijF1dde745pExEj/8+sPSuxSvtMgmA?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1843ba74-6c33-4b43-0575-08daaeb22a59 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Oct 2022 13:35:46.3766 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 2cFPENOGdkHgLiu44/ZYIvO4HAj8FMr2EO9LZd8HlJcD2g10HHpKb0ShD5GXQOS/IHAZlhVX60vF8Q+a5UAdFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6448 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Acked-by: Abner Chang > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Sunil V L > via groups.io > Sent: Saturday, October 15, 2022 12:48 AM > 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 >=20 > Caution: This message originated from an External Source. Use proper > caution when opening attachments, clicking links, or responding. >=20 >=20 > REF: > https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fbugz > illa.tianocore.org%2Fshow_bug.cgi%3Fid%3D4076&data=3D05%7C01%7Ca > bner.chang%40amd.com%7C581b776c7f9b4661b45f08daae040f1e%7C3dd896 > 1fe4884e608e11a82d994e183d%7C0%7C0%7C638013629706513478%7CUnkn > own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik > 1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3DJmzzl5amXOF9Z > 3npK%2FMlaiP91sDVKf1LwDcAuJ8jYXk%3D&reserved=3D0 >=20 > This is copied from > edk2-platforms/Platform/RISC-V/PlatformPkg/Universal/FdtPeim > but added as part of library instead of a separate module. >=20 > Cc: Ard Biesheuvel > Cc: Jiewen Yao > Cc: Jordan Justen > Cc: Gerd Hoffmann > Cc: Daniel Schaefer > Signed-off-by: Sunil V L > --- > 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(-) >=20 > 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 th= e > 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/Library/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/OvmfPkg/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", > + __FUNCTION__, 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; > +} > -- > 2.38.0 >=20 >=20 >=20 >=20 >=20