]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/LoongArch64/SwitchStack.S
MdePkg/BaseLib: BaseLib for LOONGARCH64 architecture.
[mirror_edk2.git] / MdePkg / Library / BaseLib / LoongArch64 / SwitchStack.S
diff --git a/MdePkg/Library/BaseLib/LoongArch64/SwitchStack.S b/MdePkg/Library/BaseLib/LoongArch64/SwitchStack.S
new file mode 100644 (file)
index 0000000..ad9aa8b
--- /dev/null
@@ -0,0 +1,39 @@
+#------------------------------------------------------------------------------\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