aboutsummaryrefslogtreecommitdiff
path: root/pk/mentry.S
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2015-07-05 16:52:05 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2015-07-05 16:52:05 -0700
commita6da37f21720d12f0295876ce426bc081a62a7d8 (patch)
treece3a531905b52858899a470eca3bfb43050de536 /pk/mentry.S
parent027ba300cbeaa425218fd472e1fcf45c785f645c (diff)
downloadpk-a6da37f21720d12f0295876ce426bc081a62a7d8.zip
pk-a6da37f21720d12f0295876ce426bc081a62a7d8.tar.gz
pk-a6da37f21720d12f0295876ce426bc081a62a7d8.tar.bz2
New M-mode timer and SBI call to use it
Diffstat (limited to 'pk/mentry.S')
-rw-r--r--pk/mentry.S34
1 files changed, 21 insertions, 13 deletions
diff --git a/pk/mentry.S b/pk/mentry.S
index e9e794b..0c1ee6a 100644
--- a/pk/mentry.S
+++ b/pk/mentry.S
@@ -162,23 +162,21 @@ mentry:
.Linterrupt:
sll a0, a0, 1 # discard MSB
+ # See if this is a timer interrupt; post a supervisor interrupt if so.
li a1, IRQ_TIMER * 2
- # Send timer interrupts to the OS.
- beq a0, a1, .Lmrts
-
- # See if this is an IPI; register a supervisor SW interrupt if so.
-#if IRQ_SOFT != 0
-#error
-#endif
- bnez a0, 1f
- csrr a0, mstatus
- csrc mip, MIP_MSIP
- csrs mip, MIP_SSIP
-
+ bne a0, a1, 1f
+ li a0, MIP_MTIP
+ csrc mip, a0
+ li a1, MIP_STIP
+ csrc mie, a0
+ csrs mip, a1
+
+.Linterrupt_supervisor:
# There are three cases: PRV1=U; PRV1=S and IE1=1; and PRV1=S and IE1=0.
# For cases 1-2, do an MRTS; for case 3, we can't, so ERET.
- and a0, a0, MSTATUS_PRV1 | MSTATUS_IE1
+ csrr a0, mstatus
li a1, (MSTATUS_PRV1 & ~(MSTATUS_PRV1<<1)) * PRV_S
+ and a0, a0, MSTATUS_PRV1 | MSTATUS_IE1
bne a0, a1, .Lmrts
# And then go back whence we came.
@@ -186,6 +184,16 @@ mentry:
LOAD a1, 11*REGBYTES(sp)
csrrw sp, mscratch, sp
eret
+
+1:
+ # See if this is an IPI; register a supervisor SW interrupt if so.
+#if IRQ_SOFT != 0
+#error
+#endif
+ bnez a0, 1f
+ csrc mip, MIP_MSIP
+ csrs mip, MIP_SSIP
+ j .Linterrupt_supervisor
1:
# See if this is an HTIF interrupt; if so, handle it in machine mode.