From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.80]) by mx.groups.io with SMTP id smtpd.web09.8667.1665673101163055922 for ; Thu, 13 Oct 2022 07:58:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=osOi8SiY; 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.223.80, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZT95qjZpv0HXKkEX1vbjr+nbo1DZtl1pKdbHTz4QW+1tK0JJMcwmr6oUDCBN1DXS4qnNIel2hExRk6QYS9WcAIgToed4GinEFIYBy/AMGd2VVhwHUd3Y1gScBHMPOjmSZk9MDpJswwnMN8QN6tY8Ud7OgX6rnOff9U2ECbVM80PDShQSsPxNEhccJaHryF9UxylEQG1dqcocQz+LLVCP19fW1u/ZuK34Sw5RDP4YlZVXOy+twPGiM9D57n7QiJi93wyNs5ml+jGotePUN2ynmfVQGv9XpbRCu2UGFcOgAtmoyhERSs/dc0KWO3ONz2thB8H8IBlSLqDoRmWDiQWTNg== 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=UrJR0A5lAbgK7wrSYAzdS8Z2GMc/g4qKQfTfmTLepzw=; b=OveCmvNtyewCAqF0PZhyh/+O5iWDVxuefH+0T7tunswhMBZo/0z+16zOUpop4MIOjr1lWrIKQ1DUshxBse8O3T7+/+rDOwXYIUDC9zqwEcYN4MQCU/bf89ozcFRoi+aC6KivPIKnAIM3ffNbv6fNgkjgAXCphyou8JFU7H1yawN5DPk+4fKkK1OfzxQjhlwSfHXoBUMesyXpfw9e+LUQ5vnSwoBFXwDpRAnekrvDkNNnQx+jzdPDz+4DAR2uuaKC+Ce98SFctSG+FKRpBPRPVyMUKohcnRTgOhHa5GTDwqB0iSV2QoT9U4TcWO421b9ac21HGOcXiNVBs/O6J3i7ug== 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=UrJR0A5lAbgK7wrSYAzdS8Z2GMc/g4qKQfTfmTLepzw=; b=osOi8SiYp9T05fzjmN33ciOYCwHvx8RZH3A+GXm7Zby1AOLQ+wb3WSfkVEN2OiXpiG57yr9aJYD+7Ouy3UeLu1o0ptEJOSzwP+1Z6DjBPIZMV1ZK7/TnRTT/zQWY19P2ST4kBB92xiVfJ2xzFqdBckub9MU3ZBoZRdCw2hKFBVI= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by PH7PR12MB7454.namprd12.prod.outlook.com (2603:10b6:510:20d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.19; Thu, 13 Oct 2022 14:58:18 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::dd29:6efb:1027:cfb2]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::dd29:6efb:1027:cfb2%5]) with mapi id 15.20.5723.026; Thu, 13 Oct 2022 14:58:18 +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 V3 06/34] OvmfPkg/PlatformInitLib: Add support for RISC-V Thread-Topic: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V3 06/34] OvmfPkg/PlatformInitLib: Add support for RISC-V Thread-Index: AQHY3up323rrxI5fH0Sul0wNpffMW64MaE4Q Date: Thu, 13 Oct 2022 14:58:17 +0000 Message-ID: References: <20221013095829.1454581-1-sunilvl@ventanamicro.com> <20221013095829.1454581-7-sunilvl@ventanamicro.com> In-Reply-To: <20221013095829.1454581-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-13T14:58:16Z; 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=17201bb2-383e-4aee-880f-0564635f1c76; 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_|PH7PR12MB7454:EE_ x-ms-office365-filtering-correlation-id: 849546de-e035-40e6-de74-08daad2b5cec x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: FQNoJQyqqUvfBCzDUk4skfMrLRiuoNoOpJ6RdS6gmMQJ7cCKJt1XmT9D3WlsYLh4RhNVFRFkcSjiYtE/JUEJLGqRudyU5kpbfvyuNA3XajpmDBW33v4Io0sHxXL2QguNfKws1bKe9uTh/FilElMEz4/FW1EogS5m6VBWnfkORev+nWB+uVPUIS7Sy9VdwhUlMbz2AsjGx+BjQW/rvvWCqptt0DkQcDxWz3LlWoFXFWUpTfkbZtjnv2jBpslCYs+DVxFWuQUWbv/RPZ/tlbfvWS4Q7cpBxOeuaUz3KtD5uOHukRL+PyyKoJvSC3JvzB6phCYYEVW60SGENtgQqBRD6Zut/EQt1M+pUi2g1v1vqDjfqf/0XyTKm1o+9vFxLRpi6H/UAPQoxAzFVj9nJqwfJH2T03Zq51h5oeXr7U3CtHH0RcegTha97kGtYflw6aCC05EAQZYSv6+MDDLfHLLY/tDZJoLRuid+F7CHAkEfhSkhfOZgy5CqP+kmo6oO9dceSYjI0KYT0W27ZEmoFDQecL9os3TXvYYYpzNgAhqlDyYV+G4iVUWyg5Ro345L2RdbRvi2tjO9q/TmR29Sb817Nf5D+DjETbkeG4DtuhWjnqQHDE/ND1l6KQ6qq+nS7o0+EFUwSOQENEFZlajXGkLi6PaurutJWVsSliA5El9/h8ZCABc9j1QSvQJB3RKuw2LNaAeBBUIbroE09dYiM2XMl5FhCggcb9L1ZqDnWoIuC2fsPDwk3kDGv/PVD8qL/GOESkekiOrRDCoTN9WooAJvZk/k6P9tsm6a4CubYsL18THy7ZElb3szsCQnhhBkpTi4a7GBkbv044Md0PSnWbc/Jw== 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)(39860400002)(136003)(396003)(366004)(346002)(376002)(451199015)(66899015)(26005)(9686003)(122000001)(33656002)(38100700002)(71200400001)(38070700005)(8676002)(19627235002)(110136005)(54906003)(7696005)(52536014)(86362001)(83380400001)(966005)(66556008)(186003)(5660300002)(6506007)(478600001)(45080400002)(316002)(8936002)(66476007)(41300700001)(66446008)(2906002)(53546011)(76116006)(55016003)(66946007)(4326008)(64756008);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ydkmYSJkBOYV5inVTxk/YPLbJGn6fbkyaX3nwRyb18NohzBc3Zg9GMP2B76Z?= =?us-ascii?Q?9XxovExEiDpIDBgKb9Ycu/tWtHRYBH/NCszbGug7AOmnmzC6a1UgjxdPNVs9?= =?us-ascii?Q?P9XXl49uSmjKzwRHeGjYS+I0wsGtGfEhBG8+cY5UcFL8PY/kwF7QtSA9N8EO?= =?us-ascii?Q?SgCST9cY1Rs/EAheSh4LaUH8hwB0CFQDIWhuLXZb/OmljNMCGLv15Vqe2d1T?= =?us-ascii?Q?v7o+tTE6CJ36G1LBsOWrmCOHGckuzSQrDTdKnUs7rpYrVamhEEJq6hG9LRqr?= =?us-ascii?Q?N5PrN/N+C9jQFzGsOC36wuaZbiLINtkAQoJ3S18i5Po5fWHjI8Emh9KzAv05?= =?us-ascii?Q?3rjIBw67U4CRi1rsOOfSBHldjEKgEYXrjyGQnDSQrjqwIeXIiXqGFD63bMxt?= =?us-ascii?Q?g6QHdrXixKCWmTdlCRbNVuM0gGPW7V30dPycHX8ODa+zA0fq30NB1mxWu20y?= =?us-ascii?Q?mbtE9Ea4etZAn+chjz9zvxIuS8F9rqwyzgXb7rrcFzDPiZfxDFGQEchHLXqd?= =?us-ascii?Q?ww3f8Y7UYMO/msvcR12ir7GgsZpAKA+1KLycH8IttOP86yF2TQjJbojzGrxl?= =?us-ascii?Q?aOQgyALKOe02ehbxUGf0ChHjSydqhEOEs8rg2mfLftE4l5jKMWre83N9hlLB?= =?us-ascii?Q?h7RkLtKcqflQ1M+UddrxVNdZT5LaSWwfpScYRSEfpLg2DZwQAnGzgetDKQCf?= =?us-ascii?Q?KQetRKeehwsApG5lvFdnoXESLgJIEE8T5FEwBTItCvay+X+8K24++UNNjIE4?= =?us-ascii?Q?AyO1mWhFqKl2gxMoa6qJEJo+8qfbamiDH9PeXUKKFMa+2fm4FZ5W0X1mnNgD?= =?us-ascii?Q?5SWkRQZpkEGPyOBUJDL68HeIV86CjFNMV/P9iuR1gdhMooNvpImTMGhgKgNh?= =?us-ascii?Q?o0QM1Dmw5mm5naFsbhBbUVN0T7azMBaou+3elLv4YfSuFB6AaLV0oc+oqllf?= =?us-ascii?Q?otV22EEN9HXISXw11r2Jl4OF+j8nF49qe3PoKWkostjd9w6EcVnahz+1EA3L?= =?us-ascii?Q?mbKppzMf8tTT8EnFeT4enoEVlyJ9o7RGQLwcogC6VKxIFArSKAq3oJ6BUncm?= =?us-ascii?Q?hf6e2gkmiJDPdi6rDk6GDGw7nA822bX5cgqmkecM1nOlINqydh2FAuZk8EmS?= =?us-ascii?Q?YcXCUIlcTeAWig5h6NS/fFpy1vHMYFR0J6R2X8Ea9Sr5z8RGQfCM8S3Rzp+j?= =?us-ascii?Q?/Kkyvt4SODq5bHPlJwVyMZ4s1Lbp8Al0PYdunqmcUGLwkH6fap1GjFPuUQSd?= =?us-ascii?Q?7AJ0JPyM7ISjfwghS7H0lhWlJhA+Oe7q/8QpH/5G7CJibFXamrvincu9TmyG?= =?us-ascii?Q?9HyuGsOQfLHRSj0SSA15Ckl/SS9GvUEl2l8LFEzzWP5KIbpVHCQZKk3gGcFb?= =?us-ascii?Q?A6X58hBPHiOs/MqHg29CPXpbHsvz0KoP81JvyuxYTULLqIZ6kbUDazexfguk?= =?us-ascii?Q?MxrOdiROJhYoxeUieu0C0MVyevT5QExvqSifqqzbZIByqGoJWfdH870MDDNe?= =?us-ascii?Q?qVbc145wE8os/SBLrJc/R+IR40flMI5Q7KsIUsg0mErswqA6nK0lz35kJGuE?= =?us-ascii?Q?TxTh7a/bI3sH+YmVYQg=3D?= 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: 849546de-e035-40e6-de74-08daad2b5cec X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Oct 2022 14:58:17.9947 (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: kYZXMCLfIR9wSGQQrylmWWUBBy7M+XDMqU5a3CpzD9Xww58RDbc3B0IVRrFaJfaYnh/j5EO/mocTnhv4C42CpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7454 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Hi Sunil, This file is originally from RISC-V FdtPeim.c. Please just keep HPE copyrig= ht because the difference between this one and the original one is the head= er file reference for the build and the correction of DEBUG macro. Or you c= an separate this this commit into two commits, one is the original file ano= ther is the changes made by Ventana. I have no problem with the code logic by the way.=20 Thanks Abner=20 > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Sunil V L > via groups.io > Sent: Thursday, October 13, 2022 5:58 PM > To: devel@edk2.groups.io > Cc: Ard Biesheuvel ; Jiewen Yao > ; Jordan Justen ; Gerd > Hoffmann ; Daniel Schaefer > Subject: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V3 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%7C03bbd4f7f5f748c8964a08daad01988b%7C3dd896 > 1fe4884e608e11a82d994e183d%7C0%7C0%7C638012519614946969%7CUnkn > own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik > 1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3DPXc%2FF92%2F > N67WFosTnDPCf%2FMGmaGVSnjUw2MXdk4Uq%2F8%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 > --- > .../PlatformInitLib/PlatformInitLib.inf | 9 ++- > OvmfPkg/Include/Library/PlatformInitLib.h | 6 ++ > .../PlatformInitLib/RiscV64/PlatformPeiLib.c | 73 +++++++++++++++++++ > 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 > OvmfPkg/Library/PlatformInitLib/RiscV64/PlatformPeiLib.c >=20 > diff --git a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf > b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf > index d4449e40af61..ef8675999583 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] > Ia32_X64/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..c5db7777c849 > --- /dev/null > +++ b/OvmfPkg/Library/PlatformInitLib/RiscV64/PlatformPeiLib.c > @@ -0,0 +1,73 @@ > +/** @file > +The library call to pass the device tree to DXE via HOB. > + > +Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All > +rights reserved.
Copyright (c) 2022, Ventana Micro Systems Inc. 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.25.1 >=20 >=20 >=20 >=20 >=20