1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2023 StarFive Technology Co., Ltd.
5 * Author: Jee Heng Sia <jeeheng.sia@starfivetech.com>
9 #error "Only include this from assembly code"
12 #ifndef __ASM_ASSEMBLER_H
13 #define __ASM_ASSEMBLER_H
16 #include <asm/asm-offsets.h>
20 * suspend_restore_csrs - restore CSRs
22 .macro suspend_restore_csrs
23 REG_L t0
, (SUSPEND_CONTEXT_REGS
+ PT_EPC
)(a0
)
25 REG_L t0
, (SUSPEND_CONTEXT_REGS
+ PT_STATUS
)(a0
)
27 REG_L t0
, (SUSPEND_CONTEXT_REGS
+ PT_BADADDR
)(a0
)
29 REG_L t0
, (SUSPEND_CONTEXT_REGS
+ PT_CAUSE
)(a0
)
34 * suspend_restore_regs - Restore registers (except A0 and T0-T6)
36 .macro suspend_restore_regs
37 REG_L ra
, (SUSPEND_CONTEXT_REGS
+ PT_RA
)(a0
)
38 REG_L sp
, (SUSPEND_CONTEXT_REGS
+ PT_SP
)(a0
)
39 REG_L gp
, (SUSPEND_CONTEXT_REGS
+ PT_GP
)(a0
)
40 REG_L tp
, (SUSPEND_CONTEXT_REGS
+ PT_TP
)(a0
)
41 REG_L s0
, (SUSPEND_CONTEXT_REGS
+ PT_S0
)(a0
)
42 REG_L s1
, (SUSPEND_CONTEXT_REGS
+ PT_S1
)(a0
)
43 REG_L a1
, (SUSPEND_CONTEXT_REGS
+ PT_A1
)(a0
)
44 REG_L a2
, (SUSPEND_CONTEXT_REGS
+ PT_A2
)(a0
)
45 REG_L a3
, (SUSPEND_CONTEXT_REGS
+ PT_A3
)(a0
)
46 REG_L a4
, (SUSPEND_CONTEXT_REGS
+ PT_A4
)(a0
)
47 REG_L a5
, (SUSPEND_CONTEXT_REGS
+ PT_A5
)(a0
)
48 REG_L a6
, (SUSPEND_CONTEXT_REGS
+ PT_A6
)(a0
)
49 REG_L a7
, (SUSPEND_CONTEXT_REGS
+ PT_A7
)(a0
)
50 REG_L s2
, (SUSPEND_CONTEXT_REGS
+ PT_S2
)(a0
)
51 REG_L s3
, (SUSPEND_CONTEXT_REGS
+ PT_S3
)(a0
)
52 REG_L s4
, (SUSPEND_CONTEXT_REGS
+ PT_S4
)(a0
)
53 REG_L s5
, (SUSPEND_CONTEXT_REGS
+ PT_S5
)(a0
)
54 REG_L s6
, (SUSPEND_CONTEXT_REGS
+ PT_S6
)(a0
)
55 REG_L s7
, (SUSPEND_CONTEXT_REGS
+ PT_S7
)(a0
)
56 REG_L s8
, (SUSPEND_CONTEXT_REGS
+ PT_S8
)(a0
)
57 REG_L s9
, (SUSPEND_CONTEXT_REGS
+ PT_S9
)(a0
)
58 REG_L s10
, (SUSPEND_CONTEXT_REGS
+ PT_S10
)(a0
)
59 REG_L s11
, (SUSPEND_CONTEXT_REGS
+ PT_S11
)(a0
)
63 * copy_page - copy 1 page (4KB) of data from source to destination
67 .macro copy_page a0
, a1
77 addi a0
, a0
, 2 * SZREG
78 addi a1
, a1
, 2 * SZREG
82 #endif /* __ASM_ASSEMBLER_H */