aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@s144.Millennium.Berkeley.EDU>2011-04-16 19:46:00 -0700
committerAndrew Waterman <waterman@s144.Millennium.Berkeley.EDU>2011-04-16 19:46:00 -0700
commit0be1f5eb1b1ff0c31036c9f1b7efeedee7fe4909 (patch)
treee5b6e4d5a1238c32c84f59638c8ac88f81ebcdee
parent6b9ea8b8e0d3bdf66727a2bc3e9dce72a77fa514 (diff)
downloadpk-0be1f5eb1b1ff0c31036c9f1b7efeedee7fe4909.zip
pk-0be1f5eb1b1ff0c31036c9f1b7efeedee7fe4909.tar.gz
pk-0be1f5eb1b1ff0c31036c9f1b7efeedee7fe4909.tar.bz2
[pk] fixed timer interrupt handler, etc.
-rw-r--r--pk/entry.S9
-rw-r--r--pk/handlers.c11
-rw-r--r--pk/pcr.h2
-rw-r--r--pk/riscv-pk.S5
4 files changed, 19 insertions, 8 deletions
diff --git a/pk/entry.S b/pk/entry.S
index 5fe0be2..6f0d1a0 100644
--- a/pk/entry.S
+++ b/pk/entry.S
@@ -128,8 +128,15 @@ pop_tf: # write the trap frame onto the stack
trap_entry:
mtpcr $ra,ASM_CR(PCR_K0)
mtpcr $x2,ASM_CR(PCR_K1)
+
+ # when coming from kernel, continue below its stack
+ mfpcr $ra,ASM_CR(PCR_SR)
+ and $ra,$ra,SR_PS
+ add $x2, $sp, -320
+ bnez $ra, 1f
la $x2,stack_top-320
- jal save_tf
+
+1:jal save_tf
move $sp,$x2
move $a0,$x2
jal handle_trap
diff --git a/pk/handlers.c b/pk/handlers.c
index 597c675..c9b6a96 100644
--- a/pk/handlers.c
+++ b/pk/handlers.c
@@ -101,10 +101,13 @@ static void handle_interrupt(trapframe_t* tf)
for(int i = 0; interrupts; interrupts >>= 1, i++)
{
- if(i == TIMER_IRQ)
- handle_timer_interrupt(tf);
- else
- handle_bad_interrupt(tf,i);
+ if(interrupts & 1)
+ {
+ if(i == TIMER_IRQ)
+ handle_timer_interrupt(tf);
+ else
+ handle_bad_interrupt(tf,i);
+ }
}
}
diff --git a/pk/pcr.h b/pk/pcr.h
index 8f182dc..e9643ae 100644
--- a/pk/pcr.h
+++ b/pk/pcr.h
@@ -32,7 +32,7 @@
#define MEMSIZE_SHIFT 12
-#define TIMER_PERIOD 0x1000000
+#define TIMER_PERIOD 0x1000
#define TIMER_IRQ 7
#define CAUSE_EXCCODE 0x000000FF
diff --git a/pk/riscv-pk.S b/pk/riscv-pk.S
index 0696a2d..6b91787 100644
--- a/pk/riscv-pk.S
+++ b/pk/riscv-pk.S
@@ -14,9 +14,10 @@ __start:
mtpcr $t0, ASM_CR(PCR_EVEC)
mtpcr $x0, ASM_CR(PCR_COUNT)
- mtpcr $x0, ASM_CR(PCR_COMPARE)
+ li $t0, TIMER_PERIOD
+ mtpcr $t0, ASM_CR(PCR_COMPARE)
- li $t0, SR_S | SR_PS | SR_ET | SR_IM | SR_EC | SR_SX
+ li $t0, SR_S | SR_PS | SR_ET | SR_EC | SR_SX
or $t1, $t0, SR_EF | SR_EV
mtpcr $t1, ASM_CR(PCR_SR)
mfpcr $t1, ASM_CR(PCR_SR)