-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrap_vector.S
55 lines (48 loc) · 1.05 KB
/
trap_vector.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
.global trap_vector
.align 4
trap_vector:
csrrw t0, mscratch, t0
sd ra, 0(t0)
sd sp, 8(t0)
sd gp, 16(t0)
sd tp, 24(t0)
sd t0, 32(t0)
sd t1, 40(t0)
sd t2, 48(t0)
sd a0, 72(t0)
sd a1, 80(t0)
sd a2, 88(t0)
sd a3, 96(t0)
sd a4, 104(t0)
sd a5, 112(t0)
sd a6, 120(t0)
sd a7, 128(t0)
sd t3, 216(t0)
sd t4, 224(t0)
sd t5, 232(t0)
sd t6, 240(t0)
csrw mscratch, t0
csrr a0, mepc
csrr a1, mcause
call handle_trap
csrw mepc, a0
csrr t0, mscratch
ld ra, 0(t0)
ld sp, 8(t0)
ld gp, 16(t0)
ld t0, 32(t0)
ld t1, 40(t0)
ld t2, 48(t0)
ld a0, 72(t0)
ld a1, 80(t0)
ld a2, 88(t0)
ld a3, 96(t0)
ld a4, 104(t0)
ld a5, 112(t0)
ld a6, 120(t0)
ld a7, 128(t0)
ld t3, 216(t0)
ld t4, 224(t0)
ld t5, 232(t0)
ld t6, 240(t0)
mret