diff options
Diffstat (limited to 'pk')
-rw-r--r-- | pk/handlers.c | 10 | ||||
-rw-r--r-- | pk/pk.h | 1 | ||||
-rw-r--r-- | pk/riscv-pk.c | 4 |
3 files changed, 15 insertions, 0 deletions
diff --git a/pk/handlers.c b/pk/handlers.c index d4c3d7c..474aa34 100644 --- a/pk/handlers.c +++ b/pk/handlers.c @@ -2,6 +2,7 @@ #include "pk.h" int have_fp = 1; // initialized to 1 because it can't be in the .bss section! +int have_vector = 1; static void handle_fp_disabled(trapframe_t* tf) { @@ -21,6 +22,14 @@ static void handle_fp_disabled(trapframe_t* tf) } } +static void handle_vector_disabled(trapframe_t* tf) +{ + if (have_vector) + tf->sr |= SR_EV; + else + panic("No vector hardware! pc %lx, insn %x",tf->epc,(uint32_t)tf->insn); +} + static void handle_privileged_instruction(trapframe_t* tf) { dump_tf(tf); @@ -112,6 +121,7 @@ void handle_trap(trapframe_t* tf) handle_misaligned_ldst, handle_fault_load, handle_fault_store, + handle_vector_disabled, }; int exccode = (tf->cause & CAUSE_EXCCODE) >> CAUSE_EXCCODE_SHIFT; @@ -25,6 +25,7 @@ extern "C" { #endif extern int have_fp; +extern int have_vector; int emulate_fp(trapframe_t*); void init_fp(); diff --git a/pk/riscv-pk.c b/pk/riscv-pk.c index 490a271..0af487d 100644 --- a/pk/riscv-pk.c +++ b/pk/riscv-pk.c @@ -21,6 +21,10 @@ void __attribute__((section(".boottext"))) __start() have_fp = mfpcr(PCR_SR) & SR_EF; mtpcr(sr0, PCR_SR); + mtpcr(sr0 | SR_EV, PCR_SR); + have_vector = mfpcr(PCR_SR) & SR_EV; + mtpcr(sr0, PCR_SR); + extern void boot(); register void (*boot_p)() = &boot; asm("" : "=r"(boot_p) : "0"(boot_p)); |