diff options
-rw-r--r-- | pk/entry.S | 20 | ||||
-rw-r--r-- | pk/pcr.h | 6 | ||||
-rw-r--r-- | pk/riscv-pk.c | 12 |
3 files changed, 30 insertions, 8 deletions
@@ -116,7 +116,17 @@ pop_tf: # write the trap frame onto the stack eret .end pop_tf - + #define TIMER_IRQ_HANDLER \ + .align 7; \ + mtpcr $x2,ASM_CR(PCR_K0); \ + mtpcr $x1,ASM_CR(PCR_K1); \ + mfpcr $x1,ASM_CR(PCR_COMPARE); \ + liw $x2,TIMER_PERIOD; \ + addw $x1,$x1,$x2; \ + mtpcr $x1,ASM_CR(PCR_COMPARE); \ + mfpcr $x1,ASM_CR(PCR_K1); \ + mfpcr $x2,ASM_CR(PCR_K0); \ + eret #define TRAP_TABLE_ENTRY(x) \ .align 7; \ @@ -150,6 +160,14 @@ trap_table: TRAP_TABLE_ENTRY(handle_badtrap) TRAP_TABLE_ENTRY(handle_badtrap) TRAP_TABLE_ENTRY(handle_badtrap) + TRAP_TABLE_ENTRY(handle_badtrap) + TRAP_TABLE_ENTRY(handle_badtrap) + TRAP_TABLE_ENTRY(handle_badtrap) + TRAP_TABLE_ENTRY(handle_badtrap) + TRAP_TABLE_ENTRY(handle_badtrap) + TRAP_TABLE_ENTRY(handle_badtrap) + TRAP_TABLE_ENTRY(handle_badtrap) + TIMER_IRQ_HANDLER .align 12 .end trap_table @@ -8,18 +8,22 @@ #define SR_S 0x0000000000000008 #define SR_EF 0x0000000000000010 #define SR_UX 0x0000000000000020 -#define SR_KX 0x0000000000000040 +#define SR_SX 0x0000000000000040 #define SR_IM 0x000000000000FF00 #define PCR_SR 0 #define PCR_EPC 1 #define PCR_BADVADDR 2 #define PCR_TBR 3 +#define PCR_COUNT 4 +#define PCR_COMPARE 5 #define PCR_TOHOST 16 #define PCR_FROMHOST 17 #define PCR_K0 24 #define PCR_K1 25 +#define TIMER_PERIOD 0x1000000 + #define ASM_CR(r) _ASM_CR(r) #define _ASM_CR(r) $cr##r diff --git a/pk/riscv-pk.c b/pk/riscv-pk.c index 8168b33..2c955e4 100644 --- a/pk/riscv-pk.c +++ b/pk/riscv-pk.c @@ -5,19 +5,19 @@ void __attribute__((section(".boottext"))) __start() extern char stack_top; asm("move $sp,%0" : : "r"(&stack_top-64)); - register long sr0 = SR_S | SR_PS | SR_ET; + extern char trap_table; + register void* tt = &trap_table; + mtpcr(tt,PCR_TBR); + + register long sr0 = SR_S | SR_PS | SR_ET | SR_IM; #ifdef PK_ENABLE_KERNEL_64BIT - sr0 |= SR_KX; + sr0 |= SR_SX; #ifdef PK_ENABLE_USER_64BIT sr0 |= SR_UX; #endif #endif mtpcr(sr0,PCR_SR); - extern char trap_table; - register void* tt = &trap_table; - mtpcr(tt,PCR_TBR); - extern void boot(); register void (*boot_p)() = &boot; asm("" : "=r"(boot_p) : "0"(boot_p)); |