Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64 - make fpreg{32, 64} actually members of fss...



details:   https://anonhg.NetBSD.org/src/rev/5ac238302fbf
branches:  trunk
changeset: 820123:5ac238302fbf
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Dec 30 18:30:19 2016 +0000

description:
- make fpreg{32,64} actually members of fsstate{32,64}.
- allocate fpstate if we did not have one and we need to write it.

diffstat:

 sys/arch/sparc64/include/reg.h             |  38 ++++++++++----------
 sys/arch/sparc64/sparc64/process_machdep.c |  52 +++++++++++++++---------------
 2 files changed, 45 insertions(+), 45 deletions(-)

diffs (166 lines):

diff -r 88584f8e3d2f -r 5ac238302fbf sys/arch/sparc64/include/reg.h
--- a/sys/arch/sparc64/include/reg.h    Fri Dec 30 17:54:43 2016 +0000
+++ b/sys/arch/sparc64/include/reg.h    Fri Dec 30 18:30:19 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: reg.h,v 1.14 2011/07/12 07:51:34 mrg Exp $ */
+/*     $NetBSD: reg.h,v 1.15 2016/12/30 18:30:19 christos Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -178,24 +178,6 @@
        int     fq_instr;               /* the instruction itself */
 };
 
-struct fpstate64 {
-       u_int   fs_regs[64];            /* our view is 64 32-bit registers */
-       int64_t fs_fsr;                 /* %fsr */
-       int     fs_gsr;                 /* graphics state reg */
-       int     fs_qsize;               /* actual queue depth */
-       struct  fp_qentry fs_queue[FP_QSIZE];   /* queue contents */
-};
-
-/* 
- * For 32-bit emulations.
- */
-struct fpstate32 {
-       u_int   fs_regs[32];            /* our view is 32 32-bit registers */
-       int     fs_fsr;                 /* %fsr */
-       int     fs_qsize;               /* actual queue depth */
-       struct  fp_qentry fs_queue[FP_QSIZE];   /* queue contents */
-};
-
 /*
  * The actual FP registers are made accessible (c.f. ptrace(2)) through
  * a `struct fpreg'; <arch/sparc64/sparc64/process_machdep.c> relies on the
@@ -207,6 +189,15 @@
        int     fr_gsr;                 /* graphics state reg */
 };
 
+struct fpstate64 {
+       struct fpreg64 fs_reg;
+#define fs_regs fs_reg.fr_regs
+#define fs_fsr fs_reg.fr_fsr
+#define fs_gsr fs_reg.fr_gsr
+       int     fs_qsize;               /* actual queue depth */
+       struct  fp_qentry fs_queue[FP_QSIZE];   /* queue contents */
+};
+
 /*
  * 32-bit fpreg used by 32-bit sparc CPUs
  */
@@ -215,6 +206,15 @@
        int     fr_fsr;                 /* %fsr */
 };
 
+/* 
+ * For 32-bit emulations.
+ */
+struct fpstate32 {
+       struct fpreg32 fs_reg;
+       int     fs_qsize;               /* actual queue depth */
+       struct  fp_qentry fs_queue[FP_QSIZE];   /* queue contents */
+};
+
 #if defined(__arch64__)
 /* Here we gotta do naughty things to let gdb work on 32-bit binaries */
 #define reg            reg64
diff -r 88584f8e3d2f -r 5ac238302fbf sys/arch/sparc64/sparc64/process_machdep.c
--- a/sys/arch/sparc64/sparc64/process_machdep.c        Fri Dec 30 17:54:43 2016 +0000
+++ b/sys/arch/sparc64/sparc64/process_machdep.c        Fri Dec 30 18:30:19 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: process_machdep.c,v 1.24 2014/01/04 00:10:03 dsl Exp $ */
+/*     $NetBSD: process_machdep.c,v 1.25 2016/12/30 18:30:19 christos Exp $ */
 
 /*
  * Copyright (c) 1993 The Regents of the University of California.
@@ -95,7 +95,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.24 2014/01/04 00:10:03 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.25 2016/12/30 18:30:19 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -198,28 +198,29 @@
        return (0);
 }
 
+extern const struct fpstate64 initfpstate;
+
 int
 process_read_fpregs(struct lwp *l, struct fpreg *regs, size_t *sz)
 {
-       extern const struct fpstate64 initfpstate;
-       const struct fpstate64  *statep = &initfpstate;
-       struct fpreg32          *regp = (struct fpreg32 *)regs;
-       int i;
+       const struct fpstate64 *fs;
 
-       if (l->l_md.md_fpstate)
-               statep = l->l_md.md_fpstate;
+       if ((fs = l->l_md.md_fpstate) == NULL)
+               fs = &initfpstate;
 #ifdef __arch64__
        if (!(curproc->p_flag & PK_32)) {
                /* 64-bit mode -- copy out fregs */
-               /* NOTE: struct fpreg == struct fpstate */
-               memcpy(regs, statep, sizeof(struct fpreg64));
+               *regs = fs->fs_reg;
                return 0;
        }
 #endif
+
+       struct fpreg32 *regp = (struct fpreg32 *)regs;
+
        /* 32-bit mode -- copy out & convert 32-bit fregs */
-       for (i = 0; i < 32; i++)
-               regp->fr_regs[i] = statep->fs_regs[i];
-       regp->fr_fsr = statep->fs_fsr;
+       for (size_t i = 0; i < __arraycount(regp->fr_regs); i++)
+               regp->fr_regs[i] = fs->fs_regs[i];
+       regp->fr_fsr = fs->fs_fsr;
 
        return 0;
 }
@@ -227,28 +228,27 @@
 int
 process_write_fpregs(struct lwp *l, const struct fpreg *regs, size_t sz)
 {
-       struct fpstate64        *statep;
-       const struct fpreg32    *regp = (const struct fpreg32 *)regs;
-       int i;
+       struct fpstate64        *fs;
 
-       statep = l->l_md.md_fpstate;
-       if (statep == NULL)
-               return EINVAL;
+       if ((fs = l->l_md.md_fpstate) == NULL) {
+               fs = kmem_zalloc(sizeof(*fs), KM_SLEEP);
+               l->l_md.md_fpstate = fs;
+       } else
+               fs->fs_qsize = 0;
 
 #ifdef __arch64__
        if (!(curproc->p_flag & PK_32)) {
                /* 64-bit mode -- copy in fregs */
-               /* NOTE: struct fpreg == struct fpstate */
-               memcpy(statep, regs, sizeof(struct fpreg64));
-               statep->fs_qsize = 0;
+               fs->fs_reg = *regs;
                return 0;
        }
 #endif
+       const struct fpreg32 *regp = (const struct fpreg32 *)regs;
+
        /* 32-bit mode -- copy in & convert 32-bit fregs */
-       for (i = 0; i < 32; i++)
-               statep->fs_regs[i] = regp->fr_regs[i];
-       statep->fs_fsr = regp->fr_fsr;
-       statep->fs_qsize = 0;
+       for (size_t i = 0; i < __arraycount(regp->fr_regs); i++)
+               fs->fs_regs[i] = regp->fr_regs[i];
+       fs->fs_fsr = regp->fr_fsr;
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index