--- /dev/null
+#------------------------------------------------------------------------------\r
+#\r
+# InternalSwitchStackAsm for LoongArch\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
+\r
+#define STORE st.d /* 64 bit mode regsave instruction */\r
+#define LOAD ld.d /* 64 bit mode regload instruction */\r
+#define RSIZE 8 /* 64 bit mode register size */\r
+\r
+ASM_GLOBAL ASM_PFX(InternalSwitchStackAsm)\r
+\r
+/**\r
+ This allows the caller to switch the stack and goes to the new entry point\r
+\r
+ @param JumpBuffer A pointer to CPU context buffer.\r
+**/\r
+\r
+ASM_PFX(InternalSwitchStackAsm):\r
+ LOAD $ra, $a0, RSIZE * 11\r
+ LOAD $s0, $a0, RSIZE * 0\r
+ LOAD $s1, $a0, RSIZE * 1\r
+ LOAD $s2, $a0, RSIZE * 2\r
+ LOAD $s3, $a0, RSIZE * 3\r
+ LOAD $s4, $a0, RSIZE * 4\r
+ LOAD $s5, $a0, RSIZE * 5\r
+ LOAD $s6, $a0, RSIZE * 6\r
+ LOAD $s7, $a0, RSIZE * 7\r
+ LOAD $s8, $a0, RSIZE * 8\r
+ LOAD $sp, $a0, RSIZE * 9\r
+ LOAD $fp, $a0, RSIZE * 10\r
+ LOAD $a0, $sp, 0\r
+ LOAD $a1, $sp, 8\r
+ jirl $zero, $ra, 0\r
+ .end\r