From 033e1e62bddb71851221ca2076945a22e5c98ca3 Mon Sep 17 00:00:00 2001 From: Yunsup Lee Date: Sat, 9 Apr 2011 20:13:36 -0700 Subject: [pk] add vector_disabled trap handler --- pk/handlers.c | 10 ++++++++++ pk/pk.h | 1 + pk/riscv-pk.c | 4 ++++ 3 files changed, 15 insertions(+) (limited to 'pk') 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; diff --git a/pk/pk.h b/pk/pk.h index 3cbd561..9d007e7 100644 --- a/pk/pk.h +++ b/pk/pk.h @@ -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)); -- cgit v1.1