[edk2-devel] [PATCH v2 06/30] MdePkg: Add read stable counter operation for LoongArch

Chao Li posted 30 patches 2 years, 3 months ago
There is a newer version of this series
[edk2-devel] [PATCH v2 06/30] MdePkg: Add read stable counter operation for LoongArch
Posted by Chao Li 2 years, 3 months ago
Add LoongArch gets stable counter ASM function.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
---
 MdePkg/Include/Library/BaseLib.h              | 12 ++++++++++
 MdePkg/Library/BaseLib/BaseLib.inf            |  1 +
 .../BaseLib/LoongArch64/ReadStableCounter.S   | 24 +++++++++++++++++++
 3 files changed, 37 insertions(+)
 create mode 100644 MdePkg/Library/BaseLib/LoongArch64/ReadStableCounter.S

diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h
index 3adf4d0042..55d53c75a0 100644
--- a/MdePkg/Include/Library/BaseLib.h
+++ b/MdePkg/Include/Library/BaseLib.h
@@ -281,6 +281,18 @@ AsmCpucfg (
   OUT UINT32  *Data
   );
 
+/**
+  Gets the timer count value.
+
+  @param[] VOID
+  @retval  timer count value.
+
+**/
+UINTN
+AsmReadStableCounter (
+  VOID
+  );
+
 #endif // defined (MDE_CPU_LOONGARCH64)
 
 //
diff --git a/MdePkg/Library/BaseLib/BaseLib.inf b/MdePkg/Library/BaseLib/BaseLib.inf
index a427aa9359..aaf221822b 100644
--- a/MdePkg/Library/BaseLib/BaseLib.inf
+++ b/MdePkg/Library/BaseLib/BaseLib.inf
@@ -421,6 +421,7 @@
   LoongArch64/SwitchStack.S         | GCC
   LoongArch64/ExceptionBase.S       | GCC
   LoongArch64/Cpucfg.S              | GCC
+  LoongArch64/ReadStableCounter.S   | GCC
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/MdePkg/Library/BaseLib/LoongArch64/ReadStableCounter.S b/MdePkg/Library/BaseLib/LoongArch64/ReadStableCounter.S
new file mode 100644
index 0000000000..59c877211d
--- /dev/null
+++ b/MdePkg/Library/BaseLib/LoongArch64/ReadStableCounter.S
@@ -0,0 +1,24 @@
+#------------------------------------------------------------------------------
+#
+# LoongArch Read Stable Counter
+#
+# Copyright (c) 2023, Loongson Technology Corporation Limited. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#------------------------------------------------------------------------------
+
+ASM_GLOBAL ASM_PFX(AsmReadStableCounter)
+
+#/**
+#  Gets the timer count value.
+#
+#  @param[] VOID
+#  @retval  timer count value.
+#
+#**/
+
+ASM_PFX(AsmReadStableCounter):
+  rdtime.d   $a0, $zero
+  jirl       $zero, $ra, 0
+  .end
-- 
2.27.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110710): https://edk2.groups.io/g/devel/message/110710
Mute This Topic: https://groups.io/mt/102413854/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v2 06/30] MdePkg: Add read stable counter operation for LoongArch
Posted by Michael D Kinney 2 years, 3 months ago
Acked-by: Michael D Kinney <michael.d.kinney@intel.com>

> -----Original Message-----
> From: Chao Li <lichao@loongson.cn>
> Sent: Sunday, November 5, 2023 7:27 PM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
> <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>
> Subject: [PATCH v2 06/30] MdePkg: Add read stable counter operation
> for LoongArch
> 
> Add LoongArch gets stable counter ASM function.
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584
> 
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Signed-off-by: Chao Li <lichao@loongson.cn>
> ---
>  MdePkg/Include/Library/BaseLib.h              | 12 ++++++++++
>  MdePkg/Library/BaseLib/BaseLib.inf            |  1 +
>  .../BaseLib/LoongArch64/ReadStableCounter.S   | 24
> +++++++++++++++++++
>  3 files changed, 37 insertions(+)
>  create mode 100644
> MdePkg/Library/BaseLib/LoongArch64/ReadStableCounter.S
> 
> diff --git a/MdePkg/Include/Library/BaseLib.h
> b/MdePkg/Include/Library/BaseLib.h
> index 3adf4d0042..55d53c75a0 100644
> --- a/MdePkg/Include/Library/BaseLib.h
> +++ b/MdePkg/Include/Library/BaseLib.h
> @@ -281,6 +281,18 @@ AsmCpucfg (
>    OUT UINT32  *Data
>    );
> 
> +/**
> +  Gets the timer count value.
> +
> +  @param[] VOID
> +  @retval  timer count value.
> +
> +**/
> +UINTN
> +AsmReadStableCounter (
> +  VOID
> +  );
> +
>  #endif // defined (MDE_CPU_LOONGARCH64)
> 
>  //
> diff --git a/MdePkg/Library/BaseLib/BaseLib.inf
> b/MdePkg/Library/BaseLib/BaseLib.inf
> index a427aa9359..aaf221822b 100644
> --- a/MdePkg/Library/BaseLib/BaseLib.inf
> +++ b/MdePkg/Library/BaseLib/BaseLib.inf
> @@ -421,6 +421,7 @@
>    LoongArch64/SwitchStack.S         | GCC
>    LoongArch64/ExceptionBase.S       | GCC
>    LoongArch64/Cpucfg.S              | GCC
> +  LoongArch64/ReadStableCounter.S   | GCC
> 
>  [Packages]
>    MdePkg/MdePkg.dec
> diff --git a/MdePkg/Library/BaseLib/LoongArch64/ReadStableCounter.S
> b/MdePkg/Library/BaseLib/LoongArch64/ReadStableCounter.S
> new file mode 100644
> index 0000000000..59c877211d
> --- /dev/null
> +++ b/MdePkg/Library/BaseLib/LoongArch64/ReadStableCounter.S
> @@ -0,0 +1,24 @@
> +#--------------------------------------------------------------------
> ----------
> +#
> +# LoongArch Read Stable Counter
> +#
> +# Copyright (c) 2023, Loongson Technology Corporation Limited. All
> rights reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#--------------------------------------------------------------------
> ----------
> +
> +ASM_GLOBAL ASM_PFX(AsmReadStableCounter)
> +
> +#/**
> +#  Gets the timer count value.
> +#
> +#  @param[] VOID
> +#  @retval  timer count value.
> +#
> +#**/
> +
> +ASM_PFX(AsmReadStableCounter):
> +  rdtime.d   $a0, $zero
> +  jirl       $zero, $ra, 0
> +  .end
> --
> 2.27.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110792): https://edk2.groups.io/g/devel/message/110792
Mute This Topic: https://groups.io/mt/102413854/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076/xyzzy [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-