Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386/isa Support for proper siginfo FP codes. Also...
details: https://anonhg.NetBSD.org/src/rev/75b6dce1a0bf
branches: trunk
changeset: 552956:75b6dce1a0bf
user: skd <skd%NetBSD.org@localhost>
date: Tue Oct 07 14:35:37 2003 +0000
description:
Support for proper siginfo FP codes. Also, set si_trap to fp status word.
Approved by fvdl.
diffstat:
sys/arch/i386/isa/npx.c | 49 +++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 41 insertions(+), 8 deletions(-)
diffs (95 lines):
diff -r dd10be972888 -r 75b6dce1a0bf sys/arch/i386/isa/npx.c
--- a/sys/arch/i386/isa/npx.c Tue Oct 07 14:12:36 2003 +0000
+++ b/sys/arch/i386/isa/npx.c Tue Oct 07 14:35:37 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npx.c,v 1.95 2003/09/06 23:15:35 christos Exp $ */
+/* $NetBSD: npx.c,v 1.96 2003/10/07 14:35:37 skd Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.95 2003/09/06 23:15:35 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.96 2003/10/07 14:35:37 skd Exp $");
#if 0
#define IPRINTF(x) printf x
@@ -143,6 +143,7 @@
#ifdef I686_CPU
static int npxdna_xmm(struct cpu_info *);
#endif /* I686_CPU */
+static int x86fpflags_to_ksiginfo(u_int32_t flags);
#ifdef I686_CPU
#define fxsave(addr) __asm("fxsave %0" : "=m" (*addr))
@@ -361,7 +362,6 @@
union savefpu *addr;
struct intrframe *frame = &iframe;
struct npx_softc *sc;
- int code;
ksiginfo_t ksi;
sc = npx_softc;
@@ -451,15 +451,22 @@
* just before it is used).
*/
l->l_md.md_regs = (struct trapframe *)&frame->if_gs;
-#ifdef notyet
+
/*
* Encode the appropriate code for detailed information on
* this exception.
*/
- code = XXX_ENCODE(addr->sv_ex_sw);
-#else
- code = 0; /* XXX */
-#endif
+
+ if (i386_use_fxsave) {
+ ksi.ksi_code =
+ x86fpflags_to_ksiginfo(addr->sv_xmm.sv_ex_sw);
+ ksi.ksi_trap = (int)addr->sv_xmm.sv_ex_sw;
+ } else {
+ ksi.ksi_code =
+ x86fpflags_to_ksiginfo(addr->sv_87.sv_ex_sw);
+ ksi.ksi_trap = (int)addr->sv_87.sv_ex_sw;
+ }
+
trapsignal(l, &ksi);
} else {
/*
@@ -477,6 +484,32 @@
return (1);
}
+/* map x86 fp flags to ksiginfo fp codes */
+/* see table 8-4 of the IA-32 Intel Architecture */
+/* Software Developer's Manual, Volume 1 */
+/* XXX punting on the stack fault with FLTINV */
+static int
+x86fpflags_to_ksiginfo(u_int32_t flags)
+{
+ int i;
+ static int x86fp_ksiginfo_table[] = {
+ FPE_FLTINV, /* bit 0 - invalid operation */
+ FPE_FLTRES, /* bit 1 - denormal operand */
+ FPE_FLTDIV, /* bit 2 - divide by zero */
+ FPE_FLTOVF, /* bit 3 - fp overflow */
+ FPE_FLTUND, /* bit 4 - fp underflow */
+ FPE_FLTRES, /* bit 5 - fp precision */
+ FPE_FLTINV, /* bit 6 - stack fault */
+ };
+
+ for(i=0;i < sizeof(x86fp_ksiginfo_table)/sizeof(int); i++) {
+ if (flags & (1 << i))
+ return(x86fp_ksiginfo_table[i]);
+ }
+ /* punt if flags not set */
+ return(0);
+}
+
/*
* Implement device not available (DNA) exception
*
Home |
Main Index |
Thread Index |
Old Index