summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunsup Lee <yunsup@cs.berkeley.edu>2014-02-06 11:22:32 -0800
committerYunsup Lee <yunsup@cs.berkeley.edu>2014-02-06 11:22:32 -0800
commitfba067ffed05ffff662cb280df822da2eaf12a0b (patch)
tree0df257d3af54df4ca0f59dc51848cd08762d9c14
parent43599293d347be1b30d8feb22c4a8c0091ad80b9 (diff)
downloadenv-fba067ffed05ffff662cb280df822da2eaf12a0b.zip
env-fba067ffed05ffff662cb280df822da2eaf12a0b.tar.gz
env-fba067ffed05ffff662cb280df822da2eaf12a0b.tar.bz2
fix recursive interrupts, and more improvements to code
-rw-r--r--v/entry.S27
-rw-r--r--v/riscv_test.h6
-rw-r--r--v/vm.c11
3 files changed, 29 insertions, 15 deletions
diff --git a/v/entry.S b/v/entry.S
index 662c92f..b4d7a92 100644
--- a/v/entry.S
+++ b/v/entry.S
@@ -68,6 +68,18 @@ save_tf: # write the trap frame onto the stack
csrr x3,cause # cause
STORE x3,35*REGBYTES(x2)
+ # get hwacha cause if IRQ_COP
+ # vxcptcause clears hwacha interrupt bit
+
+ bge x3,x0,1f
+ slli x3,x3,1 # clearing MSB of cause
+ srli x3,x3,1 # clearing MSB of cause
+ li x4,IRQ_COP
+ bne x3,x4,1f
+ vxcptcause x3
+ STORE x3,36*REGBYTES(x2)
+1:
+
ret
.globl pop_tf
@@ -136,18 +148,18 @@ trap_entry:
move a0,x2
csrr ra,status
and ra,ra,SR_EA
- beqz ra, 2f
- addi x2,x2,36*REGBYTES
+ beqz ra,2f
+ addi x2,x2,37*REGBYTES
# rocket currently doesn't support vxcptsave/vxcptrestore natively
csrr x3,impl
li x4,IMPL_ROCKET
bne x3,x4,3f
vgetcfg x4
- sd x4,0(x2)
+ STORE x4,0*REGBYTES(x2)
vgetvl x4
- sd x4,8(x2)
- addi x2,x2,16
+ STORE x4,1*REGBYTES(x2)
+ addi x2,x2,2*REGBYTES
vxcptevac x2
j 2f
@@ -156,8 +168,9 @@ trap_entry:
2:jal handle_trap
# when coming from kernel, continue below its stack
-1:li x2,17712
- sub x2, sp, x2
+ # we assume vector unit wasn't used in kernel
+1:li x2,SIZEOF_TRAPFRAME_T_SCALAR
+ sub x2,sp,x2
jal save_tf
move sp,x2
csrs status,SR_EI
diff --git a/v/riscv_test.h b/v/riscv_test.h
index 26c44f2..685dbac 100644
--- a/v/riscv_test.h
+++ b/v/riscv_test.h
@@ -79,7 +79,8 @@ userstart: \
#define PGSHIFT 13
#define PGSIZE (1 << PGSHIFT)
-#define SIZEOF_TRAPFRAME_T 20768
+#define SIZEOF_TRAPFRAME_T 20776
+#define SIZEOF_TRAPFRAME_T_SCALAR 296
#ifndef __ASSEMBLER__
@@ -145,7 +146,8 @@ typedef struct
long epc;
long badvaddr;
long cause;
- long evac[2560];
+ long hwacha_cause;
+ long hwacha_opaque[2560];
} trapframe_t;
#endif
diff --git a/v/vm.c b/v/vm.c
index a081422..d2f1fd2 100644
--- a/v/vm.c
+++ b/v/vm.c
@@ -150,9 +150,9 @@ static void do_vxcptrestore(long* where)
static void restore_vector(trapframe_t* tf)
{
if (read_csr(impl) == IMPL_ROCKET)
- do_vxcptrestore(tf->evac);
+ do_vxcptrestore(tf->hwacha_opaque);
else
- vxcptrestore(tf->evac);
+ vxcptrestore(tf->hwacha_opaque);
}
void handle_trap(trapframe_t* tf)
@@ -185,10 +185,9 @@ void handle_trap(trapframe_t* tf)
handle_fault(tf->badvaddr);
else if ((long)tf->cause < 0 && (uint8_t)tf->cause == IRQ_COP)
{
- long hwacha_cause = vxcptcause();
- if (hwacha_cause == HWACHA_CAUSE_VF_FAULT_FETCH ||
- hwacha_cause == HWACHA_CAUSE_FAULT_LOAD ||
- hwacha_cause == HWACHA_CAUSE_FAULT_STORE)
+ if (tf->hwacha_cause == HWACHA_CAUSE_VF_FAULT_FETCH ||
+ tf->hwacha_cause == HWACHA_CAUSE_FAULT_LOAD ||
+ tf->hwacha_cause == HWACHA_CAUSE_FAULT_STORE)
{
long badvaddr = vxcptaux();
handle_fault(badvaddr);