Provide more information on FP exceptions
authortholo <tholo@openbsd.org>
Sat, 8 Feb 1997 23:36:58 +0000 (23:36 +0000)
committertholo <tholo@openbsd.org>
Sat, 8 Feb 1997 23:36:58 +0000 (23:36 +0000)
sys/arch/i386/isa/npx.c

index 683332a..37d8d28 100644 (file)
@@ -1,3 +1,4 @@
+/*     $OpenBSD: npx.c,v 1.13 1997/02/08 23:36:58 tholo Exp $  */
 /*     $NetBSD: npx.c,v 1.57 1996/05/12 23:12:24 mycroft Exp $ */
 
 #if 0
@@ -439,16 +440,28 @@ npxintr(arg)
                 * just before it is used).
                 */
                p->p_md.md_regs = (struct trapframe *)&frame->if_es;
-#ifdef notyet
+
                /*
                 * Encode the appropriate code for detailed information on
                 * this exception.
                 */
-               code = XXX_ENCODE(addr->sv_ex_sw);
-#else
-               code = 0;       /* XXX */
+               if (addr->sv_ex_sw & EN_SW_IE)
+                       code = FPE_FLTINV;
+#ifdef notyet
+               else if (addr->sv_ex_sw & EN_SW_DE)
+                       code = FPE_FLTDEN;
 #endif
-               trapsignal(p, SIGFPE, code, 0, 0);      /* XXX type? */
+               else if (addr->sv_ex_sw & EN_SW_ZE)
+                       code = FPE_FLTDIV;
+               else if (addr->sv_ex_sw & EN_SW_OE)
+                       code = FPE_FLTOVF;
+               else if (addr->sv_ex_sw & EN_SW_UE)
+                       code = FPE_FLTUND;
+               else if (addr->sv_ex_sw & EN_SW_PE)
+                       code = FPE_FLTRES;
+               else
+                       code = 0;               /* XXX unknown */
+               trapsignal(p, SIGFPE, T_ARITHTRAP, code, frame->if_eip);
        } else {
                /*
                 * Nested interrupt.  These losers occur when: