From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.13562.1676033733097571725 for ; Fri, 10 Feb 2023 04:55:33 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=SsCN+e+t; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676033733; x=1707569733; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=dl7sn4vNoCkBXDNC4FQBl6jWKtmHDWUD9U8r4PEt4ds=; b=SsCN+e+tKYA7fHxD9Iid63dclDsl2a64sVav8W3KGj1/VOcnTmSvmIs8 iAbTEBJ5vBBzVRv/pKdByugoQHLZuzlB1CFgUYc196LcKPbhc3QpnyV7y imPjxV6ZnzXwbqQZvD13TeeThE/G8LE8MK7loTSqhNpdObPMV1zJK2NFM oRfII11dCEYsnkMiw0dheLdAqjj+5lpeo374FKx5v+6zSa9JwMOuohK8k Fs39s7YDxa1KhGRLC7wrQ9Pz7sRls4UHZRpl03b3LwFvhanB0hvz3Qdu2 On+ShUQCWFViUl6S9sqgS7AoFLWry4yPCXemN9BMoSmsYU/CzsabXrX3V Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="331718077" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="331718077" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 04:55:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="698417805" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="698417805" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga008.jf.intel.com with ESMTP; 10 Feb 2023 04:55:32 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 10 Feb 2023 04:55:31 -0800 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 10 Feb 2023 04:55:31 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Fri, 10 Feb 2023 04:55:31 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.173) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Fri, 10 Feb 2023 04:55:31 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SEGEUxgTFROElaZSuAB+7QrHBahJSHdE7SDkCrCkRNfs6ijyNV8gmRw5iZr+E/6erLuSWHaxsgyMPG0MA3AHRfm+V3d1NQUnKX36RidhdaC/4Dhyn6N7NijgrM0a2BEycZdZuS7rB2BErL++WjRXtsa1MWpPGh+4vEDsXkNeW6+Ixi1E5tYNqCKDVWaHzNDzC76ZZOqsbETGqXnrRGhvgxOiHILCZRGQvaW4fGbiHpRoOFS41M54Uqc7Apo87vAx8DumC/XHU13kx6j+IOhK7PxwWmlHLy+TT+r/bdgcDA0JIQ3ec3qwmHb1b10AitSNw9AaR0BnJ/VN3o5GJZPmfQ== 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=MM4P6t0oFimt6HJ6L7G76LdZdv6/ZQUraUul75g9SvA=; b=n0mV7dtQvM2lnkdK3ZoqTpyrUAWN//Pb1RrZbmY0dIODUTTrxQFp3l0hmcPutuWv5afj5DxoaeR0wea96kHszRPTUBcgu/QS9yly/UuoD9G6TQpB71vF5bil+75z24CLqndpz7pqyCIdDgrKYFs/cF6AkE/Do1XoBfUKmvBMnEA1x/+/FVaIxAcKjQ2aM2npQB16ewGfneQB0TK+uyq+Dj4sPScD+3T3x6y3iKQIzmZXpi6nb4Dt4pA0PRg57DXYfcj9CiO3SXxi6iVdBvjrN0B4doVr2arlFUU3/uiFgPFxvioC9Cqd6roMmWWlqSZmM3EB6IT1lQVcO1qCRsLxVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by SA1PR11MB6782.namprd11.prod.outlook.com (2603:10b6:806:25e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.19; Fri, 10 Feb 2023 12:55:29 +0000 Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::f890:e4ec:e2d8:5831]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::f890:e4ec:e2d8:5831%3]) with mapi id 15.20.6086.017; Fri, 10 Feb 2023 12:55:29 +0000 From: "Ni, Ray" To: "devel@edk2.groups.io" , "Ni, Ray" , Sunil V L CC: "Dong, Eric" , "Kumar, Rahul R" , Daniel Schaefer , "Gerd Hoffmann" , Abner Chang , "Warkentin, Andrei" Subject: Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V8 07/19] UefiCpuPkg: Add CpuTimerDxeRiscV64 module Thread-Topic: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V8 07/19] UefiCpuPkg: Add CpuTimerDxeRiscV64 module Thread-Index: AQHZPUuThmfdNduaCU2NDrkjCyldlK7IIKmggAACg8A= Date: Fri, 10 Feb 2023 12:55:29 +0000 Message-ID: References: <20230210123041.1489506-1-sunilvl@ventanamicro.com> <20230210123041.1489506-8-sunilvl@ventanamicro.com> <1742774BE3C3A342.6713@groups.io> In-Reply-To: <1742774BE3C3A342.6713@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|SA1PR11MB6782:EE_ x-ms-office365-filtering-correlation-id: afcc3042-3112-4782-b6ce-08db0b661654 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BQGRjy0ZZrSu61GOWk8+ECNrtwFdxctr+RElHL25rvDTuOilwdyvZcH0eALlIv4vmPltgsEH+YztvoCyoeo2ELJ/iMR9J3/TKGntesMUVOA41xXwj/9VfNh8Z3CyUKsk3d6txFFaUjflALxT9JFQaFnvLnk5KZYuvhRRh1MGiUlp0k+Kb2+5XnkVe5SaQ2XwMny0NafAElBjsgSSQHq3htqoBR+5Rush4G1PalkJq/owIulGiVqVeV8XQtRHLQ83GrQ/QGUFHh+N0M44SjLYLLWAfvfMCzuwDNWVwHEdPxv5bpXCqWm9X9iPdIuwEfKJJCBaZ5kFtFLezJbXW24DKlGpvGm8V/AM2oR2FF+LJ6MOhiNCAH61Dse0vCcmNszJN87JVg7cwFPyOccm8qcFFsgUOoOkf3J6Eljo9JPxzzYgsgQvejZ9fqc49eZEmjRVna8UymaLJMrhjYoRAn2FnkriVr8abhLFQSXhXlYyEhKSfte/sn8Iztg/HzEwHSmRvU9VwHnugujfLoTCYgl1hOmXX3Fy7T19sKqNq2Dd1Bbfg5GuW6DsMc3UDXs9iGy5zzus0Lrv5jMGpOOQFGp4Ad6fuJeLD8cwr9MwtJYaZSlmQikd6YmV+LF3Wng+VrfZgpt9F0xY/HTmCCK9kTYhB+4O4YiJUl8J8HTMHO+attn9iEWMjilEpmHPjmAVdkn2srtHyEA3D/rVt/M6JN3yjNOnQDTqv5YoX54ESDuyFSTWI3Kj2FS9IBmYpOydMyOKpbJNaRKdhNdXq4ywSLtUMx5eC6YIJD7eVftp0zF4F7Q= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN6PR11MB8244.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(39860400002)(376002)(346002)(396003)(136003)(451199018)(33656002)(55016003)(83380400001)(66899018)(82960400001)(38100700002)(186003)(9686003)(6506007)(54906003)(107886003)(71200400001)(478600001)(53546011)(2906002)(26005)(19627235002)(966005)(316002)(7696005)(38070700005)(41300700001)(8936002)(5660300002)(30864003)(122000001)(86362001)(66946007)(66556008)(76116006)(4326008)(66446008)(8676002)(64756008)(110136005)(66476007)(52536014)(579004)(559001)(44824005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?d5WVDiN/CR+vdKIgTzy8OXSUuVuO+++9xCv8TIBh9lsw2SLL0ihPdTtEWl7x?= =?us-ascii?Q?8ZUNfj9bW4fN3b8aRS3JA+x/RVDhoVtV+ws9ln/qVYrWJTIjMfdegJEgrum3?= =?us-ascii?Q?gIwiEYMycp8r/EZgCdl57YlSR2ymJJAT571N9k6fytDYYJWxR719PnbvQOFb?= =?us-ascii?Q?mGFBS2S3jaLF288q6khg7j95j0+F/QyzdSkoygOeUG9nPKQ8jHFwL1Aojbpj?= =?us-ascii?Q?fkHwC57T04MKHBj94rTWZgPe8ff9D+xAjmp3bzGTA+3jC7sMf7pmF0E3Ynmz?= =?us-ascii?Q?aDV+OmW00ggpFVYW/NZJDziZtAkH5UcrAmwmkpI1wKi3bFdgdunnkf8VFiLX?= =?us-ascii?Q?yd1VmWMoBm9aGVGrwrKv8biOMGTwG/Q3nA7et2a1gcw1Zu1f6bZFmk4PQVaa?= =?us-ascii?Q?VyZ5D+rmlSY7hE8vzE4iTMCuc6JShtMH2H/M+pTkO/WkLZmoV96WpAhyIjip?= =?us-ascii?Q?2zls/BJTNbM2Qk5u46sqIVz50tsTOjAOpx5vH9oGgz/YHXh8bSlBiYH6lyp5?= =?us-ascii?Q?naIDo65buwiOZvbZilsZnTAYuvcIXL6h5p9GEx4RlLAaXcGlgQwteeQDtMu1?= =?us-ascii?Q?BHypVK4DYifrvPjvM2SsFQ4QG9Ab7/CyzdLmshHNycBAeMfUFJ+MZFVweauV?= =?us-ascii?Q?HoAB5YuDdd3jfezScv9TQnGg9j6g0GXjtn4vb+hadcq0DxxF26HlhOgLsqsS?= =?us-ascii?Q?+u2eM+dDTBmN8WEivgACa5F3ivc0cGYaSaP2dcthk44E4HjXuQBf4zmwYpQH?= =?us-ascii?Q?9V/oT5UmJ9KeYFEFHpuvUHbqV7+6vHmy0C0GrpL8mXdB1lhDzhBP6QiSCQqV?= =?us-ascii?Q?TPkqjkjEKSl7Fvql/x8y65dr9lcTR+FZXX6vkHpd3sBSAI9zoiRfiqLmUMN7?= =?us-ascii?Q?37/nL01oeLS5mTh88KqcaB8vj0//T4ZxFiH7N3v0LBLZnoA4Bp2+//eFG8Fd?= =?us-ascii?Q?VV4P12FV16md7it3/HNaVHbx8jerRZgOC2ltS5Q8eiYygtJ5UJjC0IcE0lCR?= =?us-ascii?Q?NMdXoBsxEOeEDxwFhSbm1vauFDGaq2/O8wCJc+XAulPrJuufJWjgYoCjYGJt?= =?us-ascii?Q?lqr+Ph6No8Vb09bcpmcv3/GZLMRiwohhPnN4m170eQbhXNyyPivim/UNVoyX?= =?us-ascii?Q?Ovk11XkSRR07P5GbndJBMp51sP4qImQe2XSqpRjdBO9bxf4U4cFs5mpoouP0?= =?us-ascii?Q?ouRvIjcNqdnA9SwCOndq9Z6KVU2h4S/SM7mD3F8hUhBoa1FGvrVPYHYrGmEp?= =?us-ascii?Q?P/1E11NPShwN9cbXZ+hRTwrqQ7PHOUacp5T6/l6lcK+0sIajuaidZIPT5PKv?= =?us-ascii?Q?/Fnyy9+vctDKWxebMoBTXGEesCCdyvE7Qk9Cv5C52UwFZgz3qz/T6O7PxCKX?= =?us-ascii?Q?mZrvuKaRqgu1V66bwhIjVKn9bad4Ft3Dj8hNyxLegbUT5BeE9c+MT1dvCRmK?= =?us-ascii?Q?fiujAax6CQ5R6Lao8osHJbrhDFf3XQbuvbSVsj8uuEq7n3Wl24Oygz8f897Y?= =?us-ascii?Q?dWEE78dcOiBFmNfxw6LHP1jgPjLc8G+PE007G0I117GOxH9fnSByt7qHpCnP?= =?us-ascii?Q?2O/yNBaZs37XLMxVVkolfrCi3D4VaVeS6iocf/iY?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: afcc3042-3112-4782-b6ce-08db0b661654 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Feb 2023 12:55:29.1808 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 2JPDFousJ0Q43jL5T1YypALwzc0repuLqpgc0eqgJvD89+K2MU2TymIND43M/S57N56k9K8nxP2NL4E9tzPiag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB6782 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimer.uni | 14 + > UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerExtra.uni | 12 + For the above two file name, better to use the same base name as that of IN= F file. > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Ni, Ray > Sent: Friday, February 10, 2023 8:46 PM > To: Sunil V L ; devel@edk2.groups.io > Cc: Dong, Eric ; Kumar, Rahul R > ; Daniel Schaefer ; Gerd > Hoffmann ; Abner Chang ; > Warkentin, Andrei > Subject: Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V8 07/19] > UefiCpuPkg: Add CpuTimerDxeRiscV64 module >=20 > Acked-by: Ray Ni >=20 > > -----Original Message----- > > From: Sunil V L > > Sent: Friday, February 10, 2023 8:30 PM > > To: devel@edk2.groups.io > > Cc: Dong, Eric ; Ni, Ray ; Kumar= , > > Rahul R ; Daniel Schaefer > ; > > Gerd Hoffmann ; Abner Chang > ; > > Warkentin, Andrei > > Subject: [edk2-staging/RiscV64QemuVirt PATCH V8 07/19] UefiCpuPkg: Add > > CpuTimerDxeRiscV64 module > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4076 > > > > This DXE module initializes the timer interrupt handler > > and installs the Arch Timer protocol. > > > > Cc: Eric Dong > > Cc: Ray Ni > > Cc: Rahul Kumar > > Cc: Daniel Schaefer > > Cc: Gerd Hoffmann > > Signed-off-by: Sunil V L > > Acked-by: Abner Chang > > Reviewed-by: Andrei Warkentin > > --- > > UefiCpuPkg/UefiCpuPkg.dsc | 1 + > > UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf | 51 ++++ > > UefiCpuPkg/CpuTimerDxeRiscV64/Timer.h | 177 +++++++++++= + > > UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c | 294 > > ++++++++++++++++++++ > > UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimer.uni | 14 + > > UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerExtra.uni | 12 + > > 6 files changed, 549 insertions(+) > > > > diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc > > index c511403842b8..aba5ae927586 100644 > > --- a/UefiCpuPkg/UefiCpuPkg.dsc > > +++ b/UefiCpuPkg/UefiCpuPkg.dsc > > @@ -198,6 +198,7 @@ [Components.X64] > > [Components.RISCV64] > > > > > UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/BaseRiscV64CpuExce > > ptionHandlerLib.inf > > UefiCpuPkg/Library/BaseRiscV64CpuTimerLib/BaseRiscV64CpuTimerLib.inf > > + UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf > > > > [BuildOptions] > > *_*_*_CC_FLAGS =3D -D DISABLE_NEW_DEPRECATED_INTERFACES > > diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf > > b/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf > > new file mode 100644 > > index 000000000000..2c1f9f10e165 > > --- /dev/null > > +++ b/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf > > @@ -0,0 +1,51 @@ > > +## @file > > +# Timer Arch protocol module > > +# > > +# Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All r= ights > > reserved.
> > +# > > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > +# > > +## > > + > > +[Defines] > > + INF_VERSION =3D 0x0001001b > > + BASE_NAME =3D RiscVTimerDxe > > + MODULE_UNI_FILE =3D RiscVTimer.uni > > + FILE_GUID =3D 055DDAC6-9142-4013-BF20-FC2E5BC32= 5C9 > > + MODULE_TYPE =3D DXE_DRIVER > > + VERSION_STRING =3D 1.0 > > + ENTRY_POINT =3D TimerDriverInitialize > > +# > > +# The following information is for reference only and not required by = the > build > > +# tools. > > +# > > +# VALID_ARCHITECTURES =3D RISCV64 > > +# > > +[Packages] > > + MdePkg/MdePkg.dec > > + UefiCpuPkg/UefiCpuPkg.dec > > + > > +[LibraryClasses] > > + BaseLib > > + DebugLib > > + IoLib > > + CpuLib > > + UefiBootServicesTableLib > > + UefiDriverEntryPoint > > + > > +[LibraryClasses.RISCV64] > > + RiscVSbiLib > > + > > +[Sources.RISCV64] > > + Timer.h > > + Timer.c > > + > > +[Protocols] > > + gEfiCpuArchProtocolGuid ## CONSUMES > > + gEfiTimerArchProtocolGuid ## PRODUCES > > + > > +[Depex] > > + gEfiCpuArchProtocolGuid > > + > > +[UserExtensions.TianoCore."ExtraFiles"] > > + RiscVTimerExtra.uni > > diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.h > > b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.h > > new file mode 100644 > > index 000000000000..586eb0cfadb4 > > --- /dev/null > > +++ b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.h > > @@ -0,0 +1,177 @@ > > +/** @file > > + RISC-V Timer Architectural Protocol definitions > > + > > + Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All r= ights > > reserved.
> > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#ifndef TIMER_H_ > > +#define TIMER_H_ > > + > > +#include > > + > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > + > > +// > > +// RISC-V use 100us timer. > > +// The default timer tick duration is set to 10 ms =3D 10 * 1000 * 10 = 100 ns units > > +// > > +#define DEFAULT_TIMER_TICK_DURATION 100000 > > + > > +extern VOID > > +RiscvSetTimerPeriod ( > > + UINT32 TimerPeriod > > + ); > > + > > +// > > +// Function Prototypes > > +// > > + > > +/** > > + Initialize the Timer Architectural Protocol driver > > + > > + @param ImageHandle ImageHandle of the loaded driver > > + @param SystemTable Pointer to the System Table > > + > > + @retval EFI_SUCCESS Timer Architectural Protocol created > > + @retval EFI_OUT_OF_RESOURCES Not enough resources available to > > initialize driver. > > + @retval EFI_DEVICE_ERROR A device error occured attempting to > initialize > > the driver. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +TimerDriverInitialize ( > > + IN EFI_HANDLE ImageHandle, > > + IN EFI_SYSTEM_TABLE *SystemTable > > + ) > > +; > > + > > +/** > > + > > + This function adjusts the period of timer interrupts to the value sp= ecified > > + by TimerPeriod. If the timer period is updated, then the selected t= imer > > + period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is return= ed. If > > + the timer hardware is not programmable, then EFI_UNSUPPORTED is > returned. > > + If an error occurs while attempting to update the timer period, then= the > > + timer hardware will be put back in its state prior to this call, and > > + EFI_DEVICE_ERROR is returned. If TimerPeriod is 0, then the timer i= nterrupt > > + is disabled. This is not the same as disabling the CPU's interrupts= . > > + Instead, it must either turn off the timer hardware, or it must adju= st the > > + interrupt controller so that a CPU interrupt is not generated when t= he timer > > + interrupt fires. > > + > > + > > + @param This The EFI_TIMER_ARCH_PROTOCOL instance. > > + @param NotifyFunction The rate to program the timer interrupt in 10= 0 nS > > units. If > > + the timer hardware is not programmable, then > > EFI_UNSUPPORTED is > > + returned. If the timer is programmable, then= the timer period > > + will be rounded up to the nearest timer perio= d that is supported > > + by the timer hardware. If TimerPeriod is set= to 0, then the > > + timer interrupts will be disabled. > > + > > + @retval EFI_SUCCESS The timer period was changed. > > + @retval EFI_UNSUPPORTED The platform cannot change the peri= od of > > the timer interrupt. > > + @retval EFI_DEVICE_ERROR The timer period could not be chang= ed due > > to a device error. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +TimerDriverRegisterHandler ( > > + IN EFI_TIMER_ARCH_PROTOCOL *This, > > + IN EFI_TIMER_NOTIFY NotifyFunction > > + ) > > +; > > + > > +/** > > + > > + This function adjusts the period of timer interrupts to the value sp= ecified > > + by TimerPeriod. If the timer period is updated, then the selected t= imer > > + period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is return= ed. If > > + the timer hardware is not programmable, then EFI_UNSUPPORTED is > returned. > > + If an error occurs while attempting to update the timer period, then= the > > + timer hardware will be put back in its state prior to this call, and > > + EFI_DEVICE_ERROR is returned. If TimerPeriod is 0, then the timer i= nterrupt > > + is disabled. This is not the same as disabling the CPU's interrupts= . > > + Instead, it must either turn off the timer hardware, or it must adju= st the > > + interrupt controller so that a CPU interrupt is not generated when t= he timer > > + interrupt fires. > > + > > + > > + @param This The EFI_TIMER_ARCH_PROTOCOL instance. > > + @param TimerPeriod The rate to program the timer interrupt in 10= 0 nS > units. > > If > > + the timer hardware is not programmable, then > > EFI_UNSUPPORTED is > > + returned. If the timer is programmable, then= the timer period > > + will be rounded up to the nearest timer perio= d that is supported > > + by the timer hardware. If TimerPeriod is set= to 0, then the > > + timer interrupts will be disabled. > > + > > + @retval EFI_SUCCESS The timer period was changed. > > + @retval EFI_UNSUPPORTED The platform cannot change the peri= od of > > the timer interrupt. > > + @retval EFI_DEVICE_ERROR The timer period could not be chang= ed due > > to a device error. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +TimerDriverSetTimerPeriod ( > > + IN EFI_TIMER_ARCH_PROTOCOL *This, > > + IN UINT64 TimerPeriod > > + ) > > +; > > + > > +/** > > + > > + This function retrieves the period of timer interrupts in 100 ns uni= ts, > > + returns that value in TimerPeriod, and returns EFI_SUCCESS. If Time= rPeriod > > + is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod o= f 0 is > > + returned, then the timer is currently disabled. > > + > > + > > + @param This The EFI_TIMER_ARCH_PROTOCOL instance. > > + @param TimerPeriod A pointer to the timer period to retrieve in = 100 ns > > units. If > > + 0 is returned, then the timer is currently di= sabled. > > + > > + @retval EFI_SUCCESS The timer period was returned in Time= rPeriod. > > + @retval EFI_INVALID_PARAMETER TimerPeriod is NULL. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +TimerDriverGetTimerPeriod ( > > + IN EFI_TIMER_ARCH_PROTOCOL *This, > > + OUT UINT64 *TimerPeriod > > + ) > > +; > > + > > +/** > > + > > + This function generates a soft timer interrupt. If the platform does= not > > support soft > > + timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, > > EFI_SUCCESS is returned. > > + If a handler has been registered through the > > EFI_TIMER_ARCH_PROTOCOL.RegisterHandler() > > + service, then a soft timer interrupt will be generated. If the timer= interrupt is > > + enabled when this service is called, then the registered handler wil= l be > invoked. > > The > > + registered handler should not be able to distinguish a hardware-gene= rated > > timer > > + interrupt from a software-generated timer interrupt. > > + > > + > > + @param This The EFI_TIMER_ARCH_PROTOCOL instance. > > + > > + @retval EFI_SUCCESS The soft timer interrupt was generated. > > + @retval EFI_UNSUPPORTEDT The platform does not support the generati= on > > of soft timer interrupts. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +TimerDriverGenerateSoftInterrupt ( > > + IN EFI_TIMER_ARCH_PROTOCOL *This > > + ) > > +; > > + > > +#endif > > diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c > > b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c > > new file mode 100644 > > index 000000000000..db153f715e60 > > --- /dev/null > > +++ b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c > > @@ -0,0 +1,294 @@ > > +/** @file > > + RISC-V Timer Architectural Protocol > > + > > + Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All r= ights > > reserved.
> > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#include > > +#include > > +#include "Timer.h" > > + > > +// > > +// The handle onto which the Timer Architectural Protocol will be inst= alled > > +// > > +STATIC EFI_HANDLE mTimerHandle =3D NULL; > > + > > +// > > +// The Timer Architectural Protocol that this driver produces > > +// > > +EFI_TIMER_ARCH_PROTOCOL mTimer =3D { > > + TimerDriverRegisterHandler, > > + TimerDriverSetTimerPeriod, > > + TimerDriverGetTimerPeriod, > > + TimerDriverGenerateSoftInterrupt > > +}; > > + > > +// > > +// Pointer to the CPU Architectural Protocol instance > > +// > > +EFI_CPU_ARCH_PROTOCOL *mCpu; > > + > > +// > > +// The notification function to call on every timer interrupt. > > +// A bug in the compiler prevents us from initializing this here. > > +// > > +STATIC EFI_TIMER_NOTIFY mTimerNotifyFunction; > > + > > +// > > +// The current period of the timer interrupt > > +// > > +STATIC UINT64 mTimerPeriod =3D 0; > > + > > +/** > > + Timer Interrupt Handler. > > + > > + @param InterruptType The type of interrupt that occured > > + @param SystemContext A pointer to the system context when the > interrupt > > occured > > +**/ > > +VOID > > +EFIAPI > > +TimerInterruptHandler ( > > + IN EFI_EXCEPTION_TYPE InterruptType, > > + IN EFI_SYSTEM_CONTEXT SystemContext > > + ) > > +{ > > + EFI_TPL OriginalTPL; > > + UINT64 RiscvTimer; > > + > > + OriginalTPL =3D gBS->RaiseTPL (TPL_HIGH_LEVEL); > > + if (mTimerNotifyFunction !=3D NULL) { > > + mTimerNotifyFunction (mTimerPeriod); > > + } > > + > > + RiscVDisableTimerInterrupt (); // Disable SMode timer int > > + RiscVClearPendingTimerInterrupt (); > > + if (mTimerPeriod =3D=3D 0) { > > + gBS->RestoreTPL (OriginalTPL); > > + RiscVDisableTimerInterrupt (); // Disable SMode timer int > > + return; > > + } > > + > > + RiscvTimer =3D RiscVReadTimer (); > > + SbiSetTimer (RiscvTimer +=3D mTimerPeriod); > > + gBS->RestoreTPL (OriginalTPL); > > + RiscVEnableTimerInterrupt (); // enable SMode timer int > > +} > > + > > +/** > > + > > + This function registers the handler NotifyFunction so it is called e= very time > > + the timer interrupt fires. It also passes the amount of time since = the last > > + handler call to the NotifyFunction. If NotifyFunction is NULL, then= the > > + handler is unregistered. If the handler is registered, then EFI_SUC= CESS is > > + returned. If the CPU does not support registering a timer interrupt= handler, > > + then EFI_UNSUPPORTED is returned. If an attempt is made to register= a > > handler > > + when a handler is already registered, then EFI_ALREADY_STARTED is > returned. > > + If an attempt is made to unregister a handler when a handler is not > registered, > > + then EFI_INVALID_PARAMETER is returned. If an error occurs attempti= ng to > > + register the NotifyFunction with the timer interrupt, then > EFI_DEVICE_ERROR > > + is returned. > > + > > + @param This The EFI_TIMER_ARCH_PROTOCOL instance. > > + @param NotifyFunction The function to call when a timer interrupt = fires. > > This > > + function executes at TPL_HIGH_LEVEL. The DX= E Core will > > + register a handler for the timer interrupt, = so it can know > > + how much time has passed. This information = is used to > > + signal timer based events. NULL will unregi= ster the handler. > > + > > + @retval EFI_SUCCESS The timer handler was register= ed. > > + @retval EFI_UNSUPPORTED The platform does not support = timer > > interrupts. > > + @retval EFI_ALREADY_STARTED NotifyFunction is not NULL, an= d a > > handler is already > > + registered. > > + @retval EFI_INVALID_PARAMETER NotifyFunction is NULL, and a > handler > > was not > > + previously registered. > > + @retval EFI_DEVICE_ERROR The timer handler could not be > registered. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +TimerDriverRegisterHandler ( > > + IN EFI_TIMER_ARCH_PROTOCOL *This, > > + IN EFI_TIMER_NOTIFY NotifyFunction > > + ) > > +{ > > + DEBUG ((DEBUG_INFO, "TimerDriverRegisterHandler(0x%lx) called\n", > > NotifyFunction)); > > + mTimerNotifyFunction =3D NotifyFunction; > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + > > + This function adjusts the period of timer interrupts to the value sp= ecified > > + by TimerPeriod. If the timer period is updated, then the selected t= imer > > + period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is return= ed. If > > + the timer hardware is not programmable, then EFI_UNSUPPORTED is > returned. > > + If an error occurs while attempting to update the timer period, then= the > > + timer hardware will be put back in its state prior to this call, and > > + EFI_DEVICE_ERROR is returned. If TimerPeriod is 0, then the timer i= nterrupt > > + is disabled. This is not the same as disabling the CPU's interrupts= . > > + Instead, it must either turn off the timer hardware, or it must adju= st the > > + interrupt controller so that a CPU interrupt is not generated when t= he timer > > + interrupt fires. > > + > > + > > + @param This The EFI_TIMER_ARCH_PROTOCOL instance. > > + @param TimerPeriod The rate to program the timer interrupt in 10= 0 nS > units. > > If > > + the timer hardware is not programmable, then > > EFI_UNSUPPORTED is > > + returned. If the timer is programmable, then= the timer period > > + will be rounded up to the nearest timer perio= d that is supported > > + by the timer hardware. If TimerPeriod is set= to 0, then the > > + timer interrupts will be disabled. > > + > > + @retval EFI_SUCCESS The timer period was changed. > > + @retval EFI_UNSUPPORTED The platform cannot change the peri= od of > > the timer interrupt. > > + @retval EFI_DEVICE_ERROR The timer period could not be chang= ed due > > to a device error. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +TimerDriverSetTimerPeriod ( > > + IN EFI_TIMER_ARCH_PROTOCOL *This, > > + IN UINT64 TimerPeriod > > + ) > > +{ > > + UINT64 RiscvTimer; > > + > > + DEBUG ((DEBUG_INFO, "TimerDriverSetTimerPeriod(0x%lx)\n", > TimerPeriod)); > > + > > + if (TimerPeriod =3D=3D 0) { > > + mTimerPeriod =3D 0; > > + RiscVDisableTimerInterrupt (); // Disable SMode timer int > > + return EFI_SUCCESS; > > + } > > + > > + mTimerPeriod =3D TimerPeriod / 10; // convert unit from 100ns to 1us > > + RiscvTimer =3D RiscVReadTimer (); > > + SbiSetTimer (RiscvTimer + mTimerPeriod); > > + > > + mCpu->EnableInterrupt (mCpu); > > + RiscVEnableTimerInterrupt (); // enable SMode timer int > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + > > + This function retrieves the period of timer interrupts in 100 ns uni= ts, > > + returns that value in TimerPeriod, and returns EFI_SUCCESS. If Time= rPeriod > > + is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod o= f 0 is > > + returned, then the timer is currently disabled. > > + > > + > > + @param This The EFI_TIMER_ARCH_PROTOCOL instance. > > + @param TimerPeriod A pointer to the timer period to retrieve in = 100 ns > > units. If > > + 0 is returned, then the timer is currently di= sabled. > > + > > + @retval EFI_SUCCESS The timer period was returned in Time= rPeriod. > > + @retval EFI_INVALID_PARAMETER TimerPeriod is NULL. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +TimerDriverGetTimerPeriod ( > > + IN EFI_TIMER_ARCH_PROTOCOL *This, > > + OUT UINT64 *TimerPeriod > > + ) > > +{ > > + *TimerPeriod =3D mTimerPeriod; > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + > > + This function generates a soft timer interrupt. If the platform does= not > > support soft > > + timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, > > EFI_SUCCESS is returned. > > + If a handler has been registered through the > > EFI_TIMER_ARCH_PROTOCOL.RegisterHandler() > > + service, then a soft timer interrupt will be generated. If the timer= interrupt is > > + enabled when this service is called, then the registered handler wil= l be > invoked. > > The > > + registered handler should not be able to distinguish a hardware-gene= rated > > timer > > + interrupt from a software-generated timer interrupt. > > + > > + > > + @param This The EFI_TIMER_ARCH_PROTOCOL instance. > > + > > + @retval EFI_SUCCESS The soft timer interrupt was generated. > > + @retval EFI_UNSUPPORTEDT The platform does not support the generati= on > > of soft timer interrupts. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +TimerDriverGenerateSoftInterrupt ( > > + IN EFI_TIMER_ARCH_PROTOCOL *This > > + ) > > +{ > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + Initialize the Timer Architectural Protocol driver > > + > > + @param ImageHandle ImageHandle of the loaded driver > > + @param SystemTable Pointer to the System Table > > + > > + @retval EFI_SUCCESS Timer Architectural Protocol created > > + @retval EFI_OUT_OF_RESOURCES Not enough resources available to > > initialize driver. > > + @retval EFI_DEVICE_ERROR A device error occured attempting to > initialize > > the driver. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +TimerDriverInitialize ( > > + IN EFI_HANDLE ImageHandle, > > + IN EFI_SYSTEM_TABLE *SystemTable > > + ) > > +{ > > + EFI_STATUS Status; > > + > > + // > > + // Initialize the pointer to our notify function. > > + // > > + mTimerNotifyFunction =3D NULL; > > + > > + // > > + // Make sure the Timer Architectural Protocol is not already install= ed in the > > system > > + // > > + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, > > &gEfiTimerArchProtocolGuid); > > + > > + // > > + // Find the CPU architectural protocol. > > + // > > + Status =3D gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOI= D > > **)&mCpu); > > + ASSERT_EFI_ERROR (Status); > > + > > + // > > + // Force the timer to be disabled > > + // > > + Status =3D TimerDriverSetTimerPeriod (&mTimer, 0); > > + ASSERT_EFI_ERROR (Status); > > + > > + // > > + // Install interrupt handler for RISC-V Timer. > > + // > > + Status =3D mCpu->RegisterInterruptHandler (mCpu, > EXCEPT_RISCV_TIMER_INT, > > TimerInterruptHandler); > > + ASSERT_EFI_ERROR (Status); > > + > > + // > > + // Force the timer to be enabled at its default period > > + // > > + Status =3D TimerDriverSetTimerPeriod (&mTimer, > > DEFAULT_TIMER_TICK_DURATION); > > + ASSERT_EFI_ERROR (Status); > > + > > + // > > + // Install the Timer Architectural Protocol onto a new handle > > + // > > + Status =3D gBS->InstallMultipleProtocolInterfaces ( > > + &mTimerHandle, > > + &gEfiTimerArchProtocolGuid, > > + &mTimer, > > + NULL > > + ); > > + ASSERT_EFI_ERROR (Status); > > + return Status; > > +} > > diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimer.uni > > b/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimer.uni > > new file mode 100644 > > index 000000000000..76de1f3f352a > > --- /dev/null > > +++ b/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimer.uni > > @@ -0,0 +1,14 @@ > > +// /** @file > > +// > > +// Timer Arch protocol strings. > > +// > > +// Copyright (c) 2016, Hewlett Packard Enterprise Development LP. All = rights > > reserved.
> > +// > > +// SPDX-License-Identifier: BSD-2-Clause-Patent > > +// > > +// **/ > > + > > + > > +#string STR_MODULE_ABSTRACT #language en-US "Timer driver = that > > provides Timer Arch protocol" > > + > > +#string STR_MODULE_DESCRIPTION #language en-US "Timer driver = that > > provides Timer Arch protocol." > > diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerExtra.uni > > b/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerExtra.uni > > new file mode 100644 > > index 000000000000..ceb93a7ce82f > > --- /dev/null > > +++ b/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerExtra.uni > > @@ -0,0 +1,12 @@ > > +// /** @file > > +// Timer Localized Strings and Content > > +// > > +// Copyright (c) 2016, Hewlett Packard Enterprise Development LP. All = rights > > reserved.
> > +// > > +// SPDX-License-Identifier: BSD-2-Clause-Patent > > +// > > +// **/ > > + > > +#string STR_PROPERTIES_MODULE_NAME > > +#language en-US > > +"Timer DXE Driver" > > -- > > 2.34.1 >=20 >=20 >=20 >=20 >=20