MdePkg/BaseLib: BaseLib for LOONGARCH64 architecture.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4053 Add LoongArch LOONGARCH64 BaseLib functions. 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> Co-authored-by: Baoqi Zhang <zhangbaoqi@loongson.cn> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
39
MdePkg/Library/BaseLib/LoongArch64/SwitchStack.S
Normal file
39
MdePkg/Library/BaseLib/LoongArch64/SwitchStack.S
Normal file
@@ -0,0 +1,39 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# InternalSwitchStackAsm for LoongArch
|
||||
#
|
||||
# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#define STORE st.d /* 64 bit mode regsave instruction */
|
||||
#define LOAD ld.d /* 64 bit mode regload instruction */
|
||||
#define RSIZE 8 /* 64 bit mode register size */
|
||||
|
||||
ASM_GLOBAL ASM_PFX(InternalSwitchStackAsm)
|
||||
|
||||
/**
|
||||
This allows the caller to switch the stack and goes to the new entry point
|
||||
|
||||
@param JumpBuffer A pointer to CPU context buffer.
|
||||
**/
|
||||
|
||||
ASM_PFX(InternalSwitchStackAsm):
|
||||
LOAD $ra, $a0, RSIZE * 11
|
||||
LOAD $s0, $a0, RSIZE * 0
|
||||
LOAD $s1, $a0, RSIZE * 1
|
||||
LOAD $s2, $a0, RSIZE * 2
|
||||
LOAD $s3, $a0, RSIZE * 3
|
||||
LOAD $s4, $a0, RSIZE * 4
|
||||
LOAD $s5, $a0, RSIZE * 5
|
||||
LOAD $s6, $a0, RSIZE * 6
|
||||
LOAD $s7, $a0, RSIZE * 7
|
||||
LOAD $s8, $a0, RSIZE * 8
|
||||
LOAD $sp, $a0, RSIZE * 9
|
||||
LOAD $fp, $a0, RSIZE * 10
|
||||
LOAD $a0, $sp, 0
|
||||
LOAD $a1, $sp, 8
|
||||
jirl $zero, $ra, 0
|
||||
.end
|
Reference in New Issue
Block a user