Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386 Change the way the x87 fp register is defined ...



details:   https://anonhg.NetBSD.org/src/rev/ae32a733278d
branches:  trunk
changeset: 793068:ae32a733278d
user:      dsl <dsl%NetBSD.org@localhost>
date:      Sat Jan 25 20:12:53 2014 +0000

description:
Change the way the x87 fp register is defined so that the copies between
  fsave and fxsave layouts can be done by structure assignments.

diffstat:

 sys/arch/i386/i386/process_machdep.c |  18 ++++++++----------
 sys/arch/i386/include/npx.h          |  27 ++++++++++-----------------
 2 files changed, 18 insertions(+), 27 deletions(-)

diffs (120 lines):

diff -r e101565fad1e -r ae32a733278d sys/arch/i386/i386/process_machdep.c
--- a/sys/arch/i386/i386/process_machdep.c      Sat Jan 25 19:51:31 2014 +0000
+++ b/sys/arch/i386/i386/process_machdep.c      Sat Jan 25 20:12:53 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: process_machdep.c,v 1.78 2014/01/25 19:51:31 dsl Exp $ */
+/*     $NetBSD: process_machdep.c,v 1.79 2014/01/25 20:12:53 dsl Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.78 2014/01/25 19:51:31 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.79 2014/01/25 20:12:53 dsl Exp $");
 
 #include "opt_vm86.h"
 #include "opt_ptrace.h"
@@ -95,7 +95,7 @@
 process_xmm_to_s87(const struct fxsave *sxmm, struct save87 *s87)
 {
        unsigned int tag, ab_tag;
-       const struct fpaccxmm *fx_reg;
+       const struct fpaccfx *fx_reg;
        struct fpacc87 *s87_reg;
        int i;
 
@@ -136,11 +136,10 @@
        s87->s87_dp = sxmm->fx_dp;
 
        /* FP registers (in stack order) */
-       fx_reg = sxmm->sv_ac;
+       fx_reg = sxmm->fx_87_ac;
        s87_reg = s87->s87_ac;
        for (i = 0; i < 8; fx_reg++, s87_reg++, i++)
-               memcpy(s87_reg->fp_bytes, fx_reg->fp_bytes,
-                   sizeof(s87_reg->fp_bytes));
+               *s87_reg = fx_reg->r;
 
        /* Tag word and registers. */
        ab_tag = sxmm->fx_tw & 0xff;    /* Bits set if valid */
@@ -162,7 +161,7 @@
 process_s87_to_xmm(const struct save87 *s87, struct fxsave *sxmm)
 {
        unsigned int tag, ab_tag;
-       struct fpaccxmm *fx_reg;
+       struct fpaccfx *fx_reg;
        const struct fpacc87 *s87_reg;
        int i;
 
@@ -203,11 +202,10 @@
        sxmm->fx_tw = ab_tag;
 
        /* FP registers (in stack order) */
-       fx_reg = sxmm->sv_ac;
+       fx_reg = sxmm->fx_87_ac;
        s87_reg = s87->s87_ac;
        for (i = 0; i < 8; fx_reg++, s87_reg++, i++)
-               memcpy(fx_reg->fp_bytes, s87_reg->fp_bytes,
-                   sizeof(fx_reg->fp_bytes));
+               fx_reg->r = *s87_reg;
 }
 
 int
diff -r e101565fad1e -r ae32a733278d sys/arch/i386/include/npx.h
--- a/sys/arch/i386/include/npx.h       Sat Jan 25 19:51:31 2014 +0000
+++ b/sys/arch/i386/include/npx.h       Sat Jan 25 20:12:53 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npx.h,v 1.30 2014/01/25 19:10:56 christos Exp $        */
+/*     $NetBSD: npx.h,v 1.31 2014/01/25 20:12:53 dsl Exp $     */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -57,16 +57,15 @@
        } fa_32;
 } __packed;
 
-/* Contents of each floating point accumulator */
+/* The x87 registers are 80 bits (in ST(n) order) */
 struct fpacc87 {
-#ifdef dontdef /* too unportable */
-       uint32_t fp_mantlo;     /* mantissa low (31:0) */
-       uint32_t fp_manthi;     /* mantissa high (63:32) */
-       int      fp_exp:15;     /* exponent */
-       int      fp_sgn:1;      /* mantissa sign */
-#else
-       uint8_t  fp_bytes[10];
-#endif
+       uint64_t        f87_mantissa;   /* mantissa */
+       uint16_t        f87_exp_sign;   /* exponent and sign */
+} __packed;
+
+/* The x87 registers padded out for fxsave */
+struct fpaccfx {
+       struct fpacc87 r __aligned(16);
 };
 
 /*
@@ -96,12 +95,6 @@
 __CTASSERT(sizeof (struct save87) == 108 + 16);
 #endif
 
-/* FPU regsters in the extended save format. */
-struct fpaccxmm {
-       uint8_t fp_bytes[10];
-       uint8_t fp_rsvd[6];
-};
-
 /* SSE/SSE2 registers. */
 struct xmmreg {
        uint8_t sse_bytes[16];
@@ -118,7 +111,7 @@
 /*16*/ union fp_addr fx_dp;    /* FPU Data pointer */
        uint32_t fx_mxcsr;      /* MXCSR Register State */
        uint32_t fx_mxcsr_mask;
-       struct fpaccxmm sv_ac[8];       /* ST/MM regs */
+       struct fpaccfx fx_87_ac[8];     /* 8 x87 registers */
        struct xmmreg sv_xmmregs[8];    /* XMM regs */
        uint8_t sv_rsvd[16 * 14];
        /* 512-bytes --- end of hardware portion of save area */



Home | Main Index | Thread Index | Old Index