From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web11.3759.1641630367561099594 for ; Sat, 08 Jan 2022 00:26:07 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=NPOD0u0m; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=000704d8ca=abner.chang@hpe.com) Received: from pps.filterd (m0134420.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 2086Zt80031570 for ; Sat, 8 Jan 2022 08:26:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=SFjXhSB2K89sd3wdbK+pA+oY00u86FOemDtQZad7/Hc=; b=NPOD0u0m5TUMgC+Y3s5KfewRC9PFfS84Kk+zR6WpQhozmrdwm9P53gOaYe8B5BOP9tM3 gsduFrHfPjUzQDBhpXk1crn9z/Bk/vVzb/jdiH69MR2EDHDLmoiTSkZuBumk6WBBu6hb z/5Nc0kUuQ/Wxns5aqFO+2DAhv8N5ndM1WRRiVpO4mLXeTgp4L/LU+XcwEiI0IXEm4V1 zk00Fe3eYJ5qwZhfLmKBbcK/gXJWWKw6CJNvt6qw8x46vRc44qkNsYp/S3fnZ6aCsOjr HXbgogi5go6mknr7CBhyuFt15Pn3tjXt76nlHK06SBAZJL7/dZELdRJfUsNfM/av8vMk DA== Received: from g2t2353.austin.hpe.com (g2t2353.austin.hpe.com [15.233.44.26]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3df0049pua-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 08 Jan 2022 08:26:00 +0000 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2353.austin.hpe.com (Postfix) with ESMTP id 5466065 for ; Sat, 8 Jan 2022 08:25:59 +0000 (UTC) Received: from UB16Abner.asiapacific.hpqcorp.net (ub16abner.asiapacific.hpqcorp.net [15.119.209.229]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 93BAB37; Sat, 8 Jan 2022 08:25:58 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: abner.chang@hpe.com Subject: [PATCH 55/79] RiscV/ProcessorPkg: Use mtime CSR library Date: Sat, 8 Jan 2022 15:24:38 +0800 Message-Id: <20220108072444.17879-14-abner.chang@hpe.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220108072444.17879-1-abner.chang@hpe.com> References: <20220108072444.17879-1-abner.chang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: wEIMh_i4i2e_k5MFjcegcRHrfZc9fpHL X-Proofpoint-ORIG-GUID: wEIMh_i4i2e_k5MFjcegcRHrfZc9fpHL X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-08_03,2022-01-07_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=951 bulkscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 malwarescore=0 adultscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201080064 Content-Transfer-Encoding: quoted-printable (This is migrated from edk2-platforms:Silicon) Use mtime CSR library interface to access mtime CSR. Cc: Sunil V L Cc: Daniel Schaefer Signed-off-by: Abner Chang Reviewed-by: Daniel Schaefer Reviewed-by: Sunil V L --- .../Library/RiscVTimerLib/BaseRiscVTimerLib.inf | 3 ++- Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf | 1 + .../ProcessorPkg/Library/RiscVTimerLib/RiscVTimerLib.c | 6 +++--- Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.c | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTim= erLib.inf b/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTime= rLib.inf index c914d3b4b6..3c61149da8 100644 --- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.i= nf +++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.i= nf @@ -30,5 +30,6 @@ BaseLib=0D PcdLib=0D RiscVCpuLib=0D - RiscVPlatformTimerLib=0D + MachineModeTimerLib=0D +=0D =0D diff --git a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf b/Sili= con/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf index 29cc4413bd..a422c12e32 100644 --- a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf +++ b/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf @@ -26,6 +26,7 @@ CpuLib=0D CpuExceptionHandlerLib=0D DebugLib=0D + MachineModeTimerLib=0D RiscVCpuLib=0D TimerLib=0D UefiBootServicesTableLib=0D diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/RiscVTimerLi= b.c b/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/RiscVTimerLib.c index 97fe2aef4b..54ca99787e 100644 --- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/RiscVTimerLib.c +++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/RiscVTimerLib.c @@ -36,9 +36,9 @@ InternalRiscVTimerDelay ( //=0D // The target timer count is calculated here=0D //=0D - Ticks =3D RiscVReadMachineTimer () + Delay;=0D + Ticks =3D RiscVReadMachineTimerInterface () + Delay;=0D Delay =3D 1 << (RISCV_TIMER_COMPARE_BITS - 2);=0D - while (((Ticks - RiscVReadMachineTimer ()) & ( 1 << (RISCV_TIMER_COMPA= RE_BITS - 1))) =3D=3D 0) {=0D + while (((Ticks - RiscVReadMachineTimerInterface ()) & ( 1 << (RISCV_TI= MER_COMPARE_BITS - 1))) =3D=3D 0) {=0D CpuPause ();=0D }=0D } while (Times-- > 0);=0D @@ -118,7 +118,7 @@ GetPerformanceCounter ( VOID=0D )=0D {=0D - return (UINT64)RiscVReadMachineTimer ();=0D + return (UINT64)RiscVReadMachineTimerInterface ();=0D }=0D =0D /**return=0D diff --git a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.c b/Silico= n/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.c index b8b8e91a6c..3104c6d2de 100644 --- a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.c +++ b/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.c @@ -223,7 +223,7 @@ CpuGetTimerValue ( return EFI_INVALID_PARAMETER;=0D }=0D =0D - *TimerValue =3D (UINT64)RiscVReadMachineTimer ();=0D + *TimerValue =3D (UINT64)RiscVReadMachineTimerInterface ();=0D if (TimerPeriod !=3D NULL) {=0D *TimerPeriod =3D DivU64x32 (=0D 1000000000000000u,=0D --=20 2.31.1