]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/BaseCpuLib: LoongArch Base CPU library implementation.
authorChao Li <lichao@loongson.cn>
Thu, 11 Nov 2021 12:14:20 +0000 (20:14 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 14 Oct 2022 02:16:33 +0000 (02:16 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4053

Implement LoongArch CPU related functions in BaseCpuLib.

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>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
MdePkg/Library/BaseCpuLib/BaseCpuLib.uni
MdePkg/Library/BaseCpuLib/LoongArch/CpuFlushTlb.S [new file with mode: 0644]
MdePkg/Library/BaseCpuLib/LoongArch/CpuSleep.S [new file with mode: 0644]

index c4cd29a7839d53e6cb7f50a9f6d154397a46bcd9..6b230f6e6d5d8f6422b080431d156fafe687f39d 100644 (file)
@@ -8,6 +8,7 @@
 #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
 #  Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>\r
 #  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>\r
+#  Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>\r
 #\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
@@ -25,7 +26,7 @@
 \r
 \r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC ARM AARCH64 RISCV64\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC ARM AARCH64 RISCV64 LOONGARCH64\r
 #\r
 \r
 [Sources.IA32]\r
 [Sources.RISCV64]\r
   RiscV/Cpu.S\r
 \r
+[Sources.LOONGARCH64]\r
+  LoongArch/CpuFlushTlb.S | GCC\r
+  LoongArch/CpuSleep.S    | GCC\r
+\r
 [Packages]\r
   MdePkg/MdePkg.dec\r
 \r
index 80dc49578604d0abfcc709735f8f3af68d965262..7c5c8dfb3757eef5d5adc6a92e737c247f904a7a 100644 (file)
@@ -1,13 +1,14 @@
 // /** @file\r
 // Instance of CPU Library for various architecture.\r
 //\r
-// CPU Library implemented using ASM functions for IA-32, X64 and RISCV64,\r
+// CPU Library implemented using ASM functions for IA-32, X64, RISCV64 and LoongArch64,\r
 // PAL CALLs for IPF, and empty functions for EBC.\r
 //\r
 // Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
 // Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
 // Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>\r
 // Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>\r
+// Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>\r
 //\r
 // SPDX-License-Identifier: BSD-2-Clause-Patent\r
 //\r
@@ -16,5 +17,5 @@
 \r
 #string STR_MODULE_ABSTRACT             #language en-US "Instance of CPU Library for various architectures"\r
 \r
-#string STR_MODULE_DESCRIPTION          #language en-US "CPU Library implemented using ASM functions for IA-32, X64 and RISCV64, PAL CALLs for IPF, and empty functions for EBC."\r
+#string STR_MODULE_DESCRIPTION          #language en-US "CPU Library implemented using ASM functions for IA-32, X64, RISCV64 and LoongArch64, PAL CALLs for IPF, and empty functions for EBC."\r
 \r
diff --git a/MdePkg/Library/BaseCpuLib/LoongArch/CpuFlushTlb.S b/MdePkg/Library/BaseCpuLib/LoongArch/CpuFlushTlb.S
new file mode 100644 (file)
index 0000000..8b792f0
--- /dev/null
@@ -0,0 +1,15 @@
+#------------------------------------------------------------------------------\r
+#\r
+# CpuFlushTlb() for LoongArch64\r
+#\r
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>\r
+#\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+#------------------------------------------------------------------------------\r
+ASM_GLOBAL ASM_PFX(CpuFlushTlb)\r
+\r
+ASM_PFX(CpuFlushTlb):\r
+  tlbflush\r
+  jirl $zero, $ra, 0\r
+  .end\r
diff --git a/MdePkg/Library/BaseCpuLib/LoongArch/CpuSleep.S b/MdePkg/Library/BaseCpuLib/LoongArch/CpuSleep.S
new file mode 100644 (file)
index 0000000..eb31b10
--- /dev/null
@@ -0,0 +1,15 @@
+#------------------------------------------------------------------------------\r
+#\r
+# CpuSleep() for LoongArch64\r
+#\r
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>\r
+#\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+#------------------------------------------------------------------------------\r
+ASM_GLOBAL ASM_PFX(CpuSleep)\r
+\r
+ASM_PFX(CpuSleep):\r
+  idle 0\r
+  jirl $zero, $ra, 0\r
+  .end\r