Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc - allocate state if we did not have any in fp...
details: https://anonhg.NetBSD.org/src/rev/5391dc1fb278
branches: trunk
changeset: 349980:5391dc1fb278
user: christos <christos%NetBSD.org@localhost>
date: Fri Dec 30 17:54:43 2016 +0000
description:
- allocate state if we did not have any in fpregs
- make fpstate explicitly start with fpregs for better type checking
- use c11 initializers
diffstat:
sys/arch/sparc/include/reg.h | 16 +++--
sys/arch/sparc/sparc/process_machdep.c | 80 +++++++++++++++++----------------
sys/arch/sparc/sparc/trap.c | 21 ++++++--
3 files changed, 66 insertions(+), 51 deletions(-)
diffs (205 lines):
diff -r 81b52c87c813 -r 5391dc1fb278 sys/arch/sparc/include/reg.h
--- a/sys/arch/sparc/include/reg.h Fri Dec 30 17:29:34 2016 +0000
+++ b/sys/arch/sparc/include/reg.h Fri Dec 30 17:54:43 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: reg.h,v 1.8 2005/12/11 12:19:06 christos Exp $ */
+/* $NetBSD: reg.h,v 1.9 2016/12/30 17:54:43 christos Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -102,9 +102,15 @@
int *fq_addr; /* the instruction's address */
int fq_instr; /* the instruction itself */
};
+
+struct fpreg {
+ u_int fr_regs[32]; /* our view is 32 32-bit registers */
+ int fr_fsr; /* %fsr */
+};
struct fpstate {
- u_int fs_regs[32]; /* our view is 32 32-bit registers */
- int fs_fsr; /* %fsr */
+ struct fpreg fs_reg;
+#define fs_regs fs_reg.fr_regs
+#define fs_fsr fs_reg.fr_fsr
int fs_qsize; /* actual queue depth */
struct fp_qentry fs_queue[FP_QSIZE]; /* queue contents */
};
@@ -114,9 +120,5 @@
* a `struct fpreg'; <arch/sparc/sparc/process_machdep.c> relies on the
* fact that `fpreg' is a prefix of `fpstate'.
*/
-struct fpreg {
- u_int fr_regs[32]; /* our view is 32 32-bit registers */
- int fr_fsr; /* %fsr */
-};
#endif /* _MACHINE_REG_H_ */
diff -r 81b52c87c813 -r 5391dc1fb278 sys/arch/sparc/sparc/process_machdep.c
--- a/sys/arch/sparc/sparc/process_machdep.c Fri Dec 30 17:29:34 2016 +0000
+++ b/sys/arch/sparc/sparc/process_machdep.c Fri Dec 30 17:54:43 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: process_machdep.c,v 1.18 2014/01/04 00:10:03 dsl Exp $ */
+/* $NetBSD: process_machdep.c,v 1.19 2016/12/30 17:54:43 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.18 2014/01/04 00:10:03 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.19 2016/12/30 17:54:43 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -109,67 +109,71 @@
#include <sys/ptrace.h>
int
-process_read_regs(struct lwp *p, struct reg *regs)
+process_read_regs(struct lwp *l, struct reg *regs)
{
/* NOTE: struct reg == struct trapframe */
- memcpy((void *)regs, p->l_md.md_tf, sizeof(struct reg));
- return (0);
+ memcpy(regs, l->l_md.md_tf, sizeof(*regs));
+ return 0;
}
int
-process_write_regs(struct lwp *p, const struct reg *regs)
+process_write_regs(struct lwp *l, const struct reg *regs)
{
- int psr = p->l_md.md_tf->tf_psr & ~PSR_ICC;
+ int psr = l->l_md.md_tf->tf_psr & ~PSR_ICC;
- memcpy(p->l_md.md_tf, regs, sizeof(struct reg));
- p->l_md.md_tf->tf_psr = psr | (regs->r_psr & PSR_ICC);
- return (0);
+ memcpy(l->l_md.md_tf, regs, sizeof(*regs));
+ l->l_md.md_tf->tf_psr = psr | (regs->r_psr & PSR_ICC);
+ return 0;
}
int
-process_sstep(struct lwp *p, int sstep)
+process_sstep(struct lwp *l, int sstep)
{
if (sstep)
- return (EINVAL);
- return (0);
+ return EINVAL;
+ return 0;
}
int
-process_set_pc(struct lwp *p, void *addr)
+process_set_pc(struct lwp *l, void *addr)
{
- p->l_md.md_tf->tf_pc = (u_int)addr;
- p->l_md.md_tf->tf_npc = (u_int)addr + 4;
- return (0);
+ l->l_md.md_tf->tf_pc = (u_int)addr;
+ l->l_md.md_tf->tf_npc = (u_int)addr + 4;
+ return 0;
+}
+
+extern struct fpstate initfpstate;
+
+int
+process_read_fpregs(struct lwp *l, struct fpreg *regs, size_t *sz)
+{
+ struct fpstate *fs;
+
+ if ((fs = l->l_md.md_fpstate) == NULL)
+ fs = &initfpstate;
+
+ *regs = fs->fs_reg;
+ return 0;
}
int
-process_read_fpregs(struct lwp *p, struct fpreg *regs, size_t *sz)
+process_write_fpregs(struct lwp *l, const struct fpreg *regs, size_t sz)
{
- extern struct fpstate initfpstate;
- struct fpstate *statep = &initfpstate;
+ struct fpstate *fs;
- /* NOTE: struct fpreg == prefix of struct fpstate */
- if (p->l_md.md_fpstate)
- statep = p->l_md.md_fpstate;
- memcpy(regs, statep, sizeof(struct fpreg));
- return (0);
-}
-
-int
-process_write_fpregs(struct lwp *p, const struct fpreg *regs, size_t sz)
-{
-
- if (p->l_md.md_fpstate == 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 {
+ /* Reset FP queue in this process `fpstate' */
+ fs->fs_qsize = 0;
+ }
/* Write new values to the FP registers */
- memcpy(p->l_md.md_fpstate, regs, sizeof(struct fpreg));
+ fs->fs_reg = *regs;
- /* Reset FP queue in this process `fpstate' */
- p->l_md.md_fpstate->fs_qsize = 0;
-
- return (0);
+ return 0;
}
diff -r 81b52c87c813 -r 5391dc1fb278 sys/arch/sparc/sparc/trap.c
--- a/sys/arch/sparc/sparc/trap.c Fri Dec 30 17:29:34 2016 +0000
+++ b/sys/arch/sparc/sparc/trap.c Fri Dec 30 17:54:43 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.195 2015/12/13 19:49:34 christos Exp $ */
+/* $NetBSD: trap.c,v 1.196 2016/12/30 17:54:43 christos Exp $ */
/*
* Copyright (c) 1996
@@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.195 2015/12/13 19:49:34 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.196 2016/12/30 17:54:43 christos Exp $");
#include "opt_ddb.h"
#include "opt_compat_svr4.h"
@@ -107,10 +107,19 @@
* set, no matter how it is interpreted. Appendix N of the Sparc V8 document
* seems to imply that we should do this, and it does make sense.
*/
-struct fpstate initfpstate = {
- { ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0,
- ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0 },
- 0, 0,
+struct fpstate initfpstate = {
+ .fs_reg = {
+ .fr_regs = {
+ ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0,
+ ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0,
+ },
+ .fr_fsr = 0,
+ },
+ .fs_qsize = 0,
+ .fs_queue = { {
+ .fq_addr = NULL,
+ .fq_instr = 0,
+ }, },
};
/*
Home |
Main Index |
Thread Index |
Old Index