diff options
-rw-r--r-- | sys/arch/m88k/include/trap.h | 33 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/eh_common.S | 8 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/m88100_fp.S | 23 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/trap.c | 30 |
4 files changed, 63 insertions, 31 deletions
diff --git a/sys/arch/m88k/include/trap.h b/sys/arch/m88k/include/trap.h index 2012ee1c244..5a164427625 100644 --- a/sys/arch/m88k/include/trap.h +++ b/sys/arch/m88k/include/trap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.h,v 1.10 2011/03/23 16:54:35 pirofti Exp $ */ +/* $OpenBSD: trap.h,v 1.11 2013/09/05 20:40:32 miod Exp $ */ /* * Mach Operating System * Copyright (c) 1992 Carnegie Mellon University @@ -24,14 +24,12 @@ * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ -/* - * Trap codes - */ #ifndef _M88K_TRAP_H_ #define _M88K_TRAP_H_ /* - * Trap type values + * Trap type values. These have no relation to the trap vector offsets in + * the VBR page. */ #define T_PRIVINFLT 0 /* privileged instruction fault */ #define T_INSTFLT 1 /* instruction access exception */ @@ -42,18 +40,19 @@ #define T_ZERODIV 6 /* illegal divide exception */ #define T_OVFFLT 7 /* integer overflow exception */ #define T_FPEPFLT 8 /* floating point precise exception */ -#define T_KDB_ENTRY 9 /* force entry to kernel debugger */ -#define T_KDB_BREAK 10 /* break point hit */ -#define T_KDB_TRACE 11 /* trace */ -#define T_UNKNOWNFLT 12 /* unknown exception */ -#define T_SIGSYS 13 /* generate SIGSYS */ -#define T_STEPBPT 14 /* special breakpoint for single step */ -#define T_USERBPT 15 /* user set breakpoint (for debugger) */ -#define T_110_DRM 16 /* 88110 data read miss (sw table walk) */ -#define T_110_DWM 17 /* 88110 data write miss (sw table walk) */ -#define T_110_IAM 18 /* 88110 inst ATC miss (sw table walk) */ +#define T_FPEIFLT 9 /* floating point imprecise exception (88100) */ +#define T_KDB_ENTRY 10 /* force entry to kernel debugger */ +#define T_KDB_BREAK 11 /* break point hit */ +#define T_KDB_TRACE 12 /* trace */ +#define T_UNKNOWNFLT 13 /* unknown exception */ +#define T_SIGSYS 14 /* generate SIGSYS */ +#define T_STEPBPT 15 /* special breakpoint for single step */ +#define T_USERBPT 16 /* user set breakpoint (for debugger) */ +#define T_110_DRM 17 /* 88110 data read miss (sw table walk) */ +#define T_110_DWM 18 /* 88110 data write miss (sw table walk) */ +#define T_110_IAM 19 /* 88110 inst ATC miss (sw table walk) */ -#define T_USER 19 /* user mode fault */ +#define T_USER 20 /* added to trap code if user mode fault */ #ifndef _LOCORE @@ -68,6 +67,8 @@ void m88100_trap(u_int, struct trapframe *); void m88110_syscall(register_t, struct trapframe *); void m88110_trap(u_int, struct trapframe *); +void m88100_fpu_imprecise_exception(struct trapframe *); +void m88100_fpu_precise_exception(struct trapframe *); void m88110_fpu_exception(struct trapframe *); #endif /* _LOCORE */ diff --git a/sys/arch/m88k/m88k/eh_common.S b/sys/arch/m88k/m88k/eh_common.S index dd2d6319a45..11844bc76a2 100644 --- a/sys/arch/m88k/m88k/eh_common.S +++ b/sys/arch/m88k/m88k/eh_common.S @@ -1,4 +1,4 @@ -/* $OpenBSD: eh_common.S,v 1.60 2013/08/18 22:10:58 miod Exp $ */ +/* $OpenBSD: eh_common.S,v 1.61 2013/09/05 20:40:32 miod Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1991 Carnegie Mellon University @@ -451,16 +451,18 @@ GLOBAL(overflow_handler) bsr _ASM_LABEL(clear_FPp_ssbr_bit); GLOBAL(fp_precise_handler) PREP88100("FPU precise", 114, FPp_SSBR_STUFF,) + or %r2, %r0, T_FPEPFLT or %r3, %r0, %r30 - XCALL(_ASM_LABEL(m88100_Xfp_precise), _ASM_LABEL(check_ast)) + XCALL(_C_LABEL(m88100_trap), _ASM_LABEL(check_ast)) /* Floating-point imprecise handler */ #define FPi_SSBR_STUFF \ bsr _ASM_LABEL(clear_FPi_ssbr_bit); GLOBAL(fp_imprecise_handler) PREP88100("FPU imprecise", 115, FPi_SSBR_STUFF,) + or %r2, %r0, T_FPEIFLT or %r3, %r0, %r30 - XCALL(_ASM_LABEL(Xfp_imprecise), _ASM_LABEL(check_ast)) + XCALL(_C_LABEL(m88100_trap), _ASM_LABEL(check_ast)) /* trap 450: system calls */ GLOBAL(syscall_handler) diff --git a/sys/arch/m88k/m88k/m88100_fp.S b/sys/arch/m88k/m88k/m88100_fp.S index 4077d684abf..e0c39c8041f 100644 --- a/sys/arch/m88k/m88k/m88100_fp.S +++ b/sys/arch/m88k/m88k/m88100_fp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: m88100_fp.S,v 1.8 2013/05/27 21:10:33 miod Exp $ */ +/* $OpenBSD: m88100_fp.S,v 1.9 2013/09/05 20:40:32 miod Exp $ */ /* * Mach Operating System * Copyright (c) 1991 Carnegie Mellon University @@ -71,8 +71,8 @@ #define efovf 6 #define efinx 5 -ASENTRY(m88100_Xfp_precise) - or %r29, %r3, %r0 /* r29 is now the E.F. */ +ENTRY(m88100_fpu_precise_exception) + or %r29, %r2, %r0 /* r29 is now the E.F. */ subu %r31, %r31, 16 st %r1, %r31, 8 st %r29, %r31, 12 @@ -148,8 +148,10 @@ ASLOCAL(wrapup) ld %r29, %r31, 12 addu %r31, %r31, 16 - fstcr %r2, FPSR /* write revised value of FPSR */ - fstcr %r3, FPCR /* write revised value of FPCR */ + fstcr %r2, FPSR /* write revised value of FPSR... */ + fstcr %r3, FPCR /* ...and FPCR... */ + st %r2, %r29, EF_FPSR /* ...into the trapframe as well */ + st %r3, %r29, EF_FPCR /* result writeback routine */ addu %r3, %r29, EF_R0 @@ -2634,9 +2636,8 @@ S2noinfd: operation: jmp %r1 -ASENTRY(Xfp_imprecise) -/* input: r3 is the exception frame */ - or %r29, %r3, %r0 /* r29 is now the E.F. */ +ENTRY(m88100_fpu_imprecise_exception) + or %r29, %r2, %r0 /* r29 is now the E.F. */ subu %r31, %r31, 16 st %r1, %r31, 4 st %r29, %r31, 8 @@ -2678,8 +2679,10 @@ fpui_wrapup: ld %r29, %r31, 8 addu %r31, %r31, 16 - fstcr %r2, FPSR /* write revised value of */ - fstcr %r3, FPCR /* FPSR and FPCR */ + fstcr %r2, FPSR /* write revised value of FPSR... */ + fstcr %r3, FPCR /* ...and FPCR... */ + st %r2, %r29, EF_FPSR /* ...into the trapframe as well */ + st %r3, %r29, EF_FPCR /* write back the results */ extu %r2, %r12, 5<0> diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c index d3e39d878b1..d5207d50c51 100644 --- a/sys/arch/m88k/m88k/trap.c +++ b/sys/arch/m88k/m88k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.87 2013/08/26 21:38:09 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.88 2013/09/05 20:40:32 miod Exp $ */ /* * Copyright (c) 2004, Miodrag Vallat. * Copyright (c) 1998 Steve Murphree, Jr. @@ -514,7 +514,33 @@ user_fault: fault_type = FPE_INTOVF; break; case T_FPEPFLT+T_USER: - sig = SIGFPE; + m88100_fpu_precise_exception(frame); + goto maysigfpe; + case T_FPEIFLT+T_USER: + m88100_fpu_imprecise_exception(frame); +maysigfpe: + /* Check for a SIGFPE condition */ + if (frame->tf_fpsr & frame->tf_fpcr) { + sig = SIGFPE; + if (frame->tf_fpecr & FPECR_FIOV) + fault_type = FPE_FLTSUB; + else if (frame->tf_fpecr & FPECR_FROP) + fault_type = FPE_FLTINV; + else if (frame->tf_fpecr & FPECR_FDVZ) + fault_type = FPE_INTDIV; + else if (frame->tf_fpecr & FPECR_FUNF) { + if (frame->tf_fpsr & FPSR_EFUNF) + fault_type = FPE_FLTUND; + else if (frame->tf_fpsr & FPSR_EFINX) + fault_type = FPE_FLTRES; + } else if (frame->tf_fpecr & FPECR_FOVF) { + if (frame->tf_fpsr & FPSR_EFOVF) + fault_type = FPE_FLTOVF; + else if (frame->tf_fpsr & FPSR_EFINX) + fault_type = FPE_FLTRES; + } else if (frame->tf_fpecr & FPECR_FINX) + fault_type = FPE_FLTRES; + } break; case T_SIGSYS+T_USER: sig = SIGSYS; |