add target-openrisc floating point exception
From: Feng Gao <[email protected]>
This patch complete target-openrisc floating point exception. When float exception, the right PC can be saved, so exception handler could do proper processing, and back to the right address letting the program continue.
The patch I have tested it ok.
--- target-openrisc/exception.c | 23 +++++++++++++++-- target-openrisc/exception.h | 5 ++-- target-openrisc/exception_helper.c | 2 +- target-openrisc/fpu_helper.c | 48 +++++++++++++++++++----------------- target-openrisc/int_helper.c | 2 +- target-openrisc/mmu_helper.c | 17 +++---------- 6 files changed, 55 insertions(+), 42 deletions(-)
target-openrisc/exception.c +21 -2
@@ -20,8 +20,27 @@#include "cpu.h" #include "exception.h" -void QEMU_NORETURN raise_exception(OpenRISCCPU *cpu, uint32_t excp) +void QEMU_NORETURN do_raise_exception(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc) { - cpu->env.exception_index = excp; +TranslationBlock *tb; + +/* openrisc cpu has fifteen exceptions */ +if (exception <0xe ) +qemu_log ("%s: %d\n" , __func__, exception); + + cpu->env.exception_index = exception; + +if (pc) { +/* now we have a real cpu fault */ + tb =tb_find_pc (pc); +if (tb) { +/* the PC is inside the translated code. It means that we have +a virtual CPU fault */ +cpu_restore_state (tb, &cpu->env, pc); + } + } +cpu_loop_exit (&cpu->env); }
target-openrisc/exception.h +3 -2
@@ -23,6 +23,7 @@#include "cpu.h" #include "qemu-common.h" -void QEMU_NORETURN raise_exception(OpenRISCCPU *cpu, uint32_t excp); - +void QEMU_NORETURN do_raise_exception(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc);#endif /* QEMU_OPENRISC_EXCP_H */
target-openrisc/exception_helper.c +1 -1
@@ -25,5 +25,5 @@ void HELPER(exception)(CPUOpenRISCState *env, uint32_t excp) {OpenRISCCPU *cpu =OPENRISC_CPU (ENV_GET_CPU (env)); -raise_exception (cpu, excp); +do_raise_exception (cpu, excp,0 ); }
target-openrisc/fpu_helper.c +26 -22
155 lines not on this page · raw message
target-openrisc/int_helper.c +1 -1
@@ -72,7 +72,7 @@ uint32_t HELPER(mul32)(CPUOpenRISCState *env, cpu->env.sr |= (SR_OV |SR_CY );if (cpu->env.sr &SR_OVE ) { -raise_exception (cpu,EXCP_RANGE ); +do_raise_exception (cpu,EXCP_RANGE ,GETPC ()); }return result;
target-openrisc/mmu_helper.c +3 -14
@@ -19,6 +19,7 @@*/ #include "cpu.h" +#include "exception.h" #ifndef CONFIG_USER_ONLY #include "softmmu_exec.h"
@@ -39,25 +40,13 @@void tlb_fill (CPUOpenRISCState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { -TranslationBlock *tb; -unsigned long pc;int ret; +OpenRISCCPU *cpu =OPENRISC_CPU (ENV_GET_CPU (env)); ret =cpu_openrisc_handle_mmu_fault (env, addr, is_write, mmu_idx);if (ret) { -if (retaddr) { -/* now we have a real cpu fault. */ - pc = (unsigned long )retaddr; - tb =tb_find_pc (pc); -if (tb) { -/* the PC is inside the translated code. It means that we -have a virtual CPU fault. */ -cpu_restore_state (tb, env, pc); - } - } -/* Raise Exception. */ -cpu_loop_exit (env); +do_raise_exception (cpu, env->exception_index, retaddr); } }#endif
Signature · 1 line
1.7.10.4