summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2010-07-01 05:33:33 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2010-07-01 05:33:33 +0000
commit6d53558da97510934264ff5994ddbc706ecb0664 (patch)
tree55c6e5e96188bb8ecbe159199da06c78f33a6443
parent543df279f1604ffd36cf1931b8de8749f859609b (diff)
Create a struct to store FP state and include a pointer to the CPU that
currently holds the FPU context for this process. This will be soon used to implement FPU shootdowns on multiprocessor kernels. ok kettenis@
-rw-r--r--sys/arch/hppa/hppa/genassym.cf8
-rw-r--r--sys/arch/hppa/hppa/locore.S12
-rw-r--r--sys/arch/hppa/hppa/machdep.c22
-rw-r--r--sys/arch/hppa/hppa/process_machdep.c6
-rw-r--r--sys/arch/hppa/hppa/trap.c8
-rw-r--r--sys/arch/hppa/hppa/vm_machdep.c20
-rw-r--r--sys/arch/hppa/include/fpu.h12
-rw-r--r--sys/arch/hppa/include/pcb.h5
8 files changed, 56 insertions, 37 deletions
diff --git a/sys/arch/hppa/hppa/genassym.cf b/sys/arch/hppa/hppa/genassym.cf
index 89a633a3269..04caaa5196c 100644
--- a/sys/arch/hppa/hppa/genassym.cf
+++ b/sys/arch/hppa/hppa/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.40 2010/06/29 00:50:40 jsing Exp $
+# $OpenBSD: genassym.cf,v 1.41 2010/07/01 05:33:32 jsing Exp $
#
# Copyright (c) 1982, 1990, 1993
@@ -142,7 +142,7 @@ export SRUN
export SONPROC
struct pcb
-member pcb_fpregs
+member pcb_fpstate
member pcb_onfault
member pcb_space
member pcb_ksp
@@ -165,6 +165,10 @@ member ci_ipending
member ci_trap_save
member ci_fpu_state
+struct hppa_fpstate
+member hfp_regs
+member hfp_cpu
+
# system calls
export SYSCALLGATE
export SYS_exit
diff --git a/sys/arch/hppa/hppa/locore.S b/sys/arch/hppa/hppa/locore.S
index f5312418e2a..5f78e9aef69 100644
--- a/sys/arch/hppa/hppa/locore.S
+++ b/sys/arch/hppa/hppa/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.175 2010/06/30 20:38:49 tedu Exp $ */
+/* $OpenBSD: locore.S,v 1.176 2010/07/01 05:33:32 jsing Exp $ */
/*
* Copyright (c) 1998-2004 Michael Shalayeff
@@ -955,8 +955,8 @@ ENTRY(TLABEL(excpt),0)
copy rp, r1
copy arg0, r8
mfctl cr30, r9
-#if (PCB_FPREGS+U_PCB) != 0
- ldo PCB_FPREGS+U_PCB(r9), r9
+#if HFP_REGS != 0
+ ldo HFP_REGS(r9), r9
#endif
.import fpu_save, code
.call
@@ -1072,8 +1072,8 @@ $fpusw_set
copy arg0, r17
copy rp, r1
-#if (PCB_FPREGS+U_PCB) != 0
- ldo PCB_FPREGS+U_PCB(r16), r16
+#if HFP_REGS != 0
+ ldo HFP_REGS(r16), r16
#endif
.import fpu_save, code
.call
@@ -1087,7 +1087,7 @@ $fpusw_nosave
.import uvmexp, data
ldil L%(uvmexp+FPSWTCH), r1
ldw R%(uvmexp+FPSWTCH)(r1), r16
- ldo 31*8+PCB_FPREGS+U_PCB(r9), r17
+ ldo 31*8+HFP_REGS(r9), r17
ldo 1(r16), r16
stw r16, R%(uvmexp+FPSWTCH)(r1)
diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c
index 6e939f30110..cdb016784da 100644
--- a/sys/arch/hppa/hppa/machdep.c
+++ b/sys/arch/hppa/hppa/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.192 2010/06/29 20:30:32 guenther Exp $ */
+/* $OpenBSD: machdep.c,v 1.193 2010/07/01 05:33:32 jsing Exp $ */
/*
* Copyright (c) 1999-2003 Michael Shalayeff
@@ -156,7 +156,7 @@ struct user *proc0paddr;
long mem_ex_storage[EXTENT_FIXED_STORAGE_SIZE(64) / sizeof(long)];
struct extent *hppa_ex;
struct pool hppa_fppl;
-struct fpreg proc0fpregs;
+struct hppa_fpstate proc0fpstate;
struct consdev *cn_tab;
struct vm_map *exec_map = NULL;
@@ -414,8 +414,9 @@ hppa_init(start)
ficacheall();
fdcacheall();
- proc0paddr->u_pcb.pcb_fpregs = &proc0fpregs;
- pool_init(&hppa_fppl, sizeof(struct fpreg), 16, 0, 0, "hppafp", NULL);
+ proc0paddr->u_pcb.pcb_fpstate = &proc0fpstate;
+ pool_init(&hppa_fppl, sizeof(struct hppa_fpstate), 16, 0, 0,
+ "hppafp", NULL);
}
void
@@ -1202,10 +1203,11 @@ setregs(p, pack, stack, retval)
/* reset any of the pending FPU exceptions */
fpu_proc_flush(p);
- pcb->pcb_fpregs->fpr_regs[0] = ((u_int64_t)HPPA_FPU_INIT) << 32;
- pcb->pcb_fpregs->fpr_regs[1] = 0;
- pcb->pcb_fpregs->fpr_regs[2] = 0;
- pcb->pcb_fpregs->fpr_regs[3] = 0;
+ pcb->pcb_fpstate->hfp_regs.fpr_regs[0] =
+ ((u_int64_t)HPPA_FPU_INIT) << 32;
+ pcb->pcb_fpstate->hfp_regs.fpr_regs[1] = 0;
+ pcb->pcb_fpstate->hfp_regs.fpr_regs[2] = 0;
+ pcb->pcb_fpstate->hfp_regs.fpr_regs[3] = 0;
p->p_md.md_bpva = 0;
@@ -1303,7 +1305,7 @@ sendsig(catcher, sig, mask, code, type, val)
ksc.sc_regs[29] = tf->tf_ret0;
ksc.sc_regs[30] = tf->tf_ret1;
ksc.sc_regs[31] = tf->tf_r31;
- bcopy(p->p_addr->u_pcb.pcb_fpregs, ksc.sc_fpregs,
+ bcopy(&p->p_addr->u_pcb.pcb_fpstate->hfp_regs, ksc.sc_fpregs,
sizeof(ksc.sc_fpregs));
sss += HPPA_FRAME_SIZE;
@@ -1413,7 +1415,7 @@ sys_sigreturn(p, v, retval)
tf->tf_ret0 = ksc.sc_regs[29];
tf->tf_ret1 = ksc.sc_regs[30];
tf->tf_r31 = ksc.sc_regs[31];
- bcopy(ksc.sc_fpregs, p->p_addr->u_pcb.pcb_fpregs,
+ bcopy(ksc.sc_fpregs, &p->p_addr->u_pcb.pcb_fpstate->hfp_regs,
sizeof(ksc.sc_fpregs));
tf->tf_iioq_head = ksc.sc_pcoqh | HPPA_PC_PRIV_USER;
diff --git a/sys/arch/hppa/hppa/process_machdep.c b/sys/arch/hppa/hppa/process_machdep.c
index 6276978e595..7a68605ccd8 100644
--- a/sys/arch/hppa/hppa/process_machdep.c
+++ b/sys/arch/hppa/hppa/process_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process_machdep.c,v 1.18 2010/06/29 04:03:21 jsing Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.19 2010/07/01 05:33:32 jsing Exp $ */
/*
* Copyright (c) 1999-2004 Michael Shalayeff
@@ -89,7 +89,7 @@ process_read_fpregs(p, fpregs)
{
fpu_proc_save(p);
- bcopy(p->p_addr->u_pcb.pcb_fpregs, fpregs, 32 * 8);
+ bcopy(&p->p_addr->u_pcb.pcb_fpstate->hfp_regs, fpregs, 32 * 8);
return (0);
}
@@ -148,7 +148,7 @@ process_write_fpregs(p, fpregs)
{
fpu_proc_flush(p);
- bcopy(fpregs, p->p_addr->u_pcb.pcb_fpregs, 32 * 8);
+ bcopy(fpregs, &p->p_addr->u_pcb.pcb_fpstate->hfp_regs, 32 * 8);
return (0);
}
diff --git a/sys/arch/hppa/hppa/trap.c b/sys/arch/hppa/hppa/trap.c
index bd605be7c6f..1b202152465 100644
--- a/sys/arch/hppa/hppa/trap.c
+++ b/sys/arch/hppa/hppa/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.109 2010/06/26 00:50:03 jsing Exp $ */
+/* $OpenBSD: trap.c,v 1.110 2010/07/01 05:33:32 jsing Exp $ */
/*
* Copyright (c) 1998-2004 Michael Shalayeff
@@ -296,10 +296,14 @@ trap(type, frame)
#endif
case T_EXCEPTION | T_USER: {
- u_int64_t *fpp = (u_int64_t *)frame->tf_cr30;
+ struct hppa_fpstate *hfp;
+ u_int64_t *fpp;
u_int32_t *pex;
int i, flt;
+ hfp = (struct hppa_fpstate *)frame->tf_cr30;
+ fpp = (u_int64_t *)&hfp->hfp_regs;
+
pex = (u_int32_t *)&fpp[0];
for (i = 0, pex++; i < 7 && !*pex; i++, pex++);
flt = 0;
diff --git a/sys/arch/hppa/hppa/vm_machdep.c b/sys/arch/hppa/hppa/vm_machdep.c
index 5bf2cddedfd..097adab32a3 100644
--- a/sys/arch/hppa/hppa/vm_machdep.c
+++ b/sys/arch/hppa/hppa/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.73 2010/06/29 04:54:26 jsing Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.74 2010/07/01 05:33:32 jsing Exp $ */
/*
* Copyright (c) 1999-2004 Michael Shalayeff
@@ -108,14 +108,14 @@ cpu_fork(struct proc *p1, struct proc *p2, void *stack, size_t stacksize,
bcopy(&p1->p_addr->u_pcb, pcbp, sizeof(*pcbp));
/* space is cached for the copy{in,out}'s pleasure */
pcbp->pcb_space = p2->p_vmspace->vm_map.pmap->pm_space;
- pcbp->pcb_fpregs = pool_get(&hppa_fppl, PR_WAITOK);
- *pcbp->pcb_fpregs = *p1->p_addr->u_pcb.pcb_fpregs;
+ pcbp->pcb_fpstate = pool_get(&hppa_fppl, PR_WAITOK);
+ *pcbp->pcb_fpstate = *p1->p_addr->u_pcb.pcb_fpstate;
/* reset any of the pending FPU exceptions from parent */
- pcbp->pcb_fpregs->fpr_regs[0] =
- HPPA_FPU_FORK(pcbp->pcb_fpregs->fpr_regs[0]);
- pcbp->pcb_fpregs->fpr_regs[1] = 0;
- pcbp->pcb_fpregs->fpr_regs[2] = 0;
- pcbp->pcb_fpregs->fpr_regs[3] = 0;
+ pcbp->pcb_fpstate->hfp_regs.fpr_regs[0] =
+ HPPA_FPU_FORK(pcbp->pcb_fpstate->hfp_regs.fpr_regs[0]);
+ pcbp->pcb_fpstate->hfp_regs.fpr_regs[1] = 0;
+ pcbp->pcb_fpstate->hfp_regs.fpr_regs[2] = 0;
+ pcbp->pcb_fpstate->hfp_regs.fpr_regs[3] = 0;
p2->p_md.md_bpva = p1->p_md.md_bpva;
p2->p_md.md_bpsave[0] = p1->p_md.md_bpsave[0];
@@ -126,7 +126,7 @@ cpu_fork(struct proc *p1, struct proc *p2, void *stack, size_t stacksize,
sp += sizeof(struct trapframe);
bcopy(p1->p_md.md_regs, tf, sizeof(*tf));
- tf->tf_cr30 = (paddr_t)pcbp->pcb_fpregs;
+ tf->tf_cr30 = (paddr_t)pcbp->pcb_fpstate;
tf->tf_sr0 = tf->tf_sr1 = tf->tf_sr2 = tf->tf_sr3 =
tf->tf_sr4 = tf->tf_sr5 = tf->tf_sr6 =
@@ -170,7 +170,7 @@ cpu_exit(struct proc *p)
fpu_proc_flush(p);
- pool_put(&hppa_fppl, pcb->pcb_fpregs);
+ pool_put(&hppa_fppl, pcb->pcb_fpstate);
pmap_deactivate(p);
sched_exit(p);
diff --git a/sys/arch/hppa/include/fpu.h b/sys/arch/hppa/include/fpu.h
index 65b3e519c69..162a6b62917 100644
--- a/sys/arch/hppa/include/fpu.h
+++ b/sys/arch/hppa/include/fpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fpu.h,v 1.1 2010/06/29 04:03:22 jsing Exp $ */
+/* $OpenBSD: fpu.h,v 1.2 2010/07/01 05:33:32 jsing Exp $ */
/*
* Copyright (c) 2010 Joel Sing <jsing@openbsd.org>
@@ -19,7 +19,15 @@
#ifndef _MACHINE_FPU_H_
#define _MACHINE_FPU_H_
-void fpu_proc_save(struct proc *);
+#include <machine/cpu.h>
+#include <machine/reg.h>
+
+struct hppa_fpstate {
+ struct fpreg hfp_regs;
+ volatile struct cpu_info *hfp_cpu; /* CPU which FPU state is on. */
+};
+
void fpu_proc_flush(struct proc *);
+void fpu_proc_save(struct proc *);
#endif /* _MACHINE_FPU_H_ */
diff --git a/sys/arch/hppa/include/pcb.h b/sys/arch/hppa/include/pcb.h
index 392d217963c..456ea9dea59 100644
--- a/sys/arch/hppa/include/pcb.h
+++ b/sys/arch/hppa/include/pcb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcb.h,v 1.13 2010/06/29 20:30:32 guenther Exp $ */
+/* $OpenBSD: pcb.h,v 1.14 2010/07/01 05:33:32 jsing Exp $ */
/*
* Copyright (c) 1999-2004 Michael Shalayeff
@@ -30,10 +30,11 @@
#ifndef _MACHINE_PCB_H_
#define _MACHINE_PCB_H_
+#include <machine/fpu.h>
#include <machine/reg.h>
struct pcb {
- struct fpreg *pcb_fpregs; /* not in the trapframe */
+ struct hppa_fpstate *pcb_fpstate; /* not in the trapframe */
u_int pcb_ksp; /* kernel sp for ctxsw */
u_int pcb_onfault; /* SW copy fault handler */