summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Li <lichao@loongson.cn>2023-10-12 11:18:28 +0800
committerLiming Gao <gaoliming@byosoft.com.cn>2024-02-06 23:51:47 +0800
commit414ad233a51192662ed66ceee7a23007c6710ec9 (patch)
treeac15c7230782745e18ec5140f45e85e6c2e3b2e1
parent344dc4b9d3c29965ecc92686f9f7a7e2e69c6576 (diff)
downloadedk2-414ad233a51192662ed66ceee7a23007c6710ec9.tar.gz
edk2-414ad233a51192662ed66ceee7a23007c6710ec9.tar.bz2
edk2-414ad233a51192662ed66ceee7a23007c6710ec9.zip
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> Acked-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
-rw-r--r--MdePkg/Include/Library/BaseLib.h12
-rw-r--r--MdePkg/Library/BaseLib/BaseLib.inf1
-rw-r--r--MdePkg/Library/BaseLib/LoongArch64/ReadStableCounter.S24
3 files changed, 37 insertions, 0 deletions
diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h
index d64e406b7c..29009adbc9 100644
--- a/MdePkg/Include/Library/BaseLib.h
+++ b/MdePkg/Include/Library/BaseLib.h
@@ -339,6 +339,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 2f1e3b3d91..1dad587b0c 100644
--- a/MdePkg/Library/BaseLib/BaseLib.inf
+++ b/MdePkg/Library/BaseLib/BaseLib.inf
@@ -422,6 +422,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..aa74ff603e
--- /dev/null
+++ b/MdePkg/Library/BaseLib/LoongArch64/ReadStableCounter.S
@@ -0,0 +1,24 @@
+#------------------------------------------------------------------------------
+#
+# LoongArch Read Stable Counter
+#
+# Copyright (c) 2024, 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