summaryrefslogtreecommitdiff
path: root/bsp/env
diff options
context:
space:
mode:
authorDrew Barbier <dbarbi1@gmail.com>2017-07-26 09:04:08 -0500
committerDrew Barbier <dbarbi1@gmail.com>2017-07-26 09:04:08 -0500
commit595d44b8c7857ff2aacc588ffcc54a1d1b763a65 (patch)
tree5928fb18fd122fc8e4b665e5e0ddb39b99f10573 /bsp/env
parentdb71fcb94796e465096bb0fa2ff579ac7477948a (diff)
fixed TRAP_EXIT macro. TRAP_ENTRY/EXIT2 only saves/restores callee
registers
Diffstat (limited to 'bsp/env')
-rw-r--r--bsp/env/ventry.S59
1 files changed, 52 insertions, 7 deletions
diff --git a/bsp/env/ventry.S b/bsp/env/ventry.S
index de6b197..ed79789 100644
--- a/bsp/env/ventry.S
+++ b/bsp/env/ventry.S
@@ -42,11 +42,11 @@
STORE x31, 31*REGBYTES(sp)
.endm
+.macro TRAP_EXIT
# Remain in M-mode after mret
li t0, MSTATUS_MPP
csrs mstatus, t0
-.macro TRAP_EXIT
LOAD x1, 1*REGBYTES(sp)
LOAD x2, 2*REGBYTES(sp)
LOAD x3, 3*REGBYTES(sp)
@@ -83,6 +83,51 @@
mret
.endm
+
+
+.macro TRAP_ENTRY2
+ addi sp, sp, -14*REGBYTES
+
+ STORE x2, 1*REGBYTES(sp)
+ STORE x8, 2*REGBYTES(sp)
+ STORE x9, 3*REGBYTES(sp)
+ STORE x18, 4*REGBYTES(sp)
+ STORE x19, 5*REGBYTES(sp)
+ STORE x20, 6*REGBYTES(sp)
+ STORE x21, 7*REGBYTES(sp)
+ STORE x22, 8*REGBYTES(sp)
+ STORE x23, 9*REGBYTES(sp)
+ STORE x24, 10*REGBYTES(sp)
+ STORE x25, 11*REGBYTES(sp)
+ STORE x26, 12*REGBYTES(sp)
+ STORE x27, 13*REGBYTES(sp)
+.endm
+
+.macro TRAP_EXIT2
+# Remain in M-mode after mret
+ li t0, MSTATUS_MPP
+ csrs mstatus, t0
+
+ LOAD x3, 1*REGBYTES(sp)
+ LOAD x8, 2*REGBYTES(sp)
+ LOAD x9, 3*REGBYTES(sp)
+ LOAD x18, 4*REGBYTES(sp)
+ LOAD x19, 5*REGBYTES(sp)
+ LOAD x20, 6*REGBYTES(sp)
+ LOAD x21, 7*REGBYTES(sp)
+ LOAD x22, 8*REGBYTES(sp)
+ LOAD x23, 9*REGBYTES(sp)
+ LOAD x24, 10*REGBYTES(sp)
+ LOAD x25, 11*REGBYTES(sp)
+ LOAD x26, 12*REGBYTES(sp)
+ LOAD x27, 13*REGBYTES(sp)
+
+ addi sp, sp, 14*REGBYTES
+ mret
+.endm
+
+
+
#Vector table for E31/E51
.section .text.entry
@@ -171,15 +216,15 @@ vmsi_Handler:
#Machine Timer Interrupt
vmti_Handler:
- TRAP_ENTRY
+ TRAP_ENTRY2
jal handle_m_time_interrupt
- TRAP_EXIT
+ TRAP_EXIT2
#Machine External Interrupt
vmei_Handler:
- TRAP_ENTRY
+ TRAP_ENTRY2
jal handle_m_external_interrupt
- TRAP_EXIT
+ TRAP_EXIT2
#LIP0
vlip_Handler0:
@@ -213,9 +258,9 @@ vlip_Handler4:
#LIP5
vlip_Handler5:
- TRAP_ENTRY
+ TRAP_ENTRY2
jal handle_local_interrupt5
- TRAP_EXIT
+ TRAP_EXIT2
#LIP6
vlip_Handler6: