xref: /DragonOS/kernel/crates/asm_macros/src/riscv64/context.rs (revision 7162a8358d94c7799dd2b5300192b6a794b23d79)
1 /// 保存x6-x31寄存器
2 #[macro_export]
3 macro_rules! save_from_x6_to_x31 {
4     () => {
5         concat!(
6             "
7             sd x6, {off_t1}(sp)
8             sd x7, {off_t2}(sp)
9             sd x8, {off_s0}(sp)
10             sd x9, {off_s1}(sp)
11             sd x10, {off_a0}(sp)
12             sd x11, {off_a1}(sp)
13             sd x12, {off_a2}(sp)
14             sd x13, {off_a3}(sp)
15             sd x14, {off_a4}(sp)
16             sd x15, {off_a5}(sp)
17             sd x16, {off_a6}(sp)
18             sd x17, {off_a7}(sp)
19             sd x18, {off_s2}(sp)
20             sd x19, {off_s3}(sp)
21             sd x20, {off_s4}(sp)
22             sd x21, {off_s5}(sp)
23             sd x22, {off_s6}(sp)
24             sd x23, {off_s7}(sp)
25             sd x24, {off_s8}(sp)
26             sd x25, {off_s9}(sp)
27             sd x26, {off_s10}(sp)
28             sd x27, {off_s11}(sp)
29             sd x28, {off_t3}(sp)
30             sd x29, {off_t4}(sp)
31             sd x30, {off_t5}(sp)
32             sd x31, {off_t6}(sp)
33 
34         "
35         )
36     };
37 }
38 
39 #[macro_export]
40 macro_rules! restore_from_x6_to_x31 {
41     () => {
42         concat!("
43 
44             ld x6, {off_t1}(sp)
45             ld x7, {off_t2}(sp)
46             ld x8, {off_s0}(sp)
47             ld x9, {off_s1}(sp)
48             ld x10, {off_a0}(sp)
49             ld x11, {off_a1}(sp)
50             ld x12, {off_a2}(sp)
51             ld x13, {off_a3}(sp)
52             ld x14, {off_a4}(sp)
53             ld x15, {off_a5}(sp)
54             ld x16, {off_a6}(sp)
55             ld x17, {off_a7}(sp)
56             ld x18, {off_s2}(sp)
57             ld x19, {off_s3}(sp)
58             ld x20, {off_s4}(sp)
59             ld x21, {off_s5}(sp)
60             ld x22, {off_s6}(sp)
61             ld x23, {off_s7}(sp)
62             ld x24, {off_s8}(sp)
63             ld x25, {off_s9}(sp)
64             ld x26, {off_s10}(sp)
65             ld x27, {off_s11}(sp)
66             ld x28, {off_t3}(sp)
67             ld x29, {off_t4}(sp)
68             ld x30, {off_t5}(sp)
69             ld x31, {off_t6}(sp)
70         ")
71     };
72 }
73