summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2010-06-29 00:50:41 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2010-06-29 00:50:41 +0000
commitee9fbb25fcfb3ae874851496be412c5ad521429e (patch)
treedeb7ea6e1e543cdfc117685fd48398deda8086b4 /sys/arch
parent1acc8b2a30f81c6375bb98f6a00963e71cad9e1a (diff)
Store pointer to process FPU state in struct cpu_info.
ok kettenis@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/hppa/hppa/genassym.cf3
-rw-r--r--sys/arch/hppa/hppa/hpux_machdep.c7
-rw-r--r--sys/arch/hppa/hppa/locore.S20
-rw-r--r--sys/arch/hppa/hppa/machdep.c31
-rw-r--r--sys/arch/hppa/hppa/process_machdep.c13
-rw-r--r--sys/arch/hppa/hppa/vm_machdep.c12
-rw-r--r--sys/arch/hppa/include/cpu.h3
7 files changed, 39 insertions, 50 deletions
diff --git a/sys/arch/hppa/hppa/genassym.cf b/sys/arch/hppa/hppa/genassym.cf
index 622c1e844dc..89a633a3269 100644
--- a/sys/arch/hppa/hppa/genassym.cf
+++ b/sys/arch/hppa/hppa/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.39 2010/06/03 15:48:58 jsing Exp $
+# $OpenBSD: genassym.cf,v 1.40 2010/06/29 00:50:40 jsing Exp $
#
# Copyright (c) 1982, 1990, 1993
@@ -163,6 +163,7 @@ member ci_psw
member ci_cpl
member ci_ipending
member ci_trap_save
+member ci_fpu_state
# system calls
export SYSCALLGATE
diff --git a/sys/arch/hppa/hppa/hpux_machdep.c b/sys/arch/hppa/hppa/hpux_machdep.c
index fa22421b955..6483ea25c02 100644
--- a/sys/arch/hppa/hppa/hpux_machdep.c
+++ b/sys/arch/hppa/hppa/hpux_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hpux_machdep.c,v 1.4 2010/05/24 15:04:54 deraadt Exp $ */
+/* $OpenBSD: hpux_machdep.c,v 1.5 2010/06/29 00:50:40 jsing Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
@@ -72,7 +72,6 @@ hpux_setregs(struct proc *p, struct exec_package *pack, u_long stack,
register_t *retval)
{
extern int cpu_model_hpux; /* machdep.c */
- extern paddr_t fpu_curpcb; /* from locore.S */
extern u_int fpu_version; /* from machdep.c */
struct ps_strings arginfo; /* XXX copy back in from the stack */
struct hpux_keybits {
@@ -120,8 +119,8 @@ hpux_setregs(struct proc *p, struct exec_package *pack, u_long stack,
pcb->pcb_fpregs->fpr_regs[1] = 0;
pcb->pcb_fpregs->fpr_regs[2] = 0;
pcb->pcb_fpregs->fpr_regs[3] = 0;
- if (tf->tf_cr30 == fpu_curpcb) {
- fpu_curpcb = 0;
+ if (tf->tf_cr30 == curcpu()->ci_fpu_state) {
+ curcpu()->ci_fpu_state = 0;
/* force an fpu ctxsw, we won't be hugged by the cpu_switch */
mtctl(0, CR_CCR);
}
diff --git a/sys/arch/hppa/hppa/locore.S b/sys/arch/hppa/hppa/locore.S
index 308e3416d1f..5d1726cd540 100644
--- a/sys/arch/hppa/hppa/locore.S
+++ b/sys/arch/hppa/hppa/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.172 2010/06/03 15:48:58 jsing Exp $ */
+/* $OpenBSD: locore.S,v 1.173 2010/06/29 00:50:40 jsing Exp $ */
/*
* Copyright (c) 1998-2004 Michael Shalayeff
@@ -115,8 +115,6 @@ netisr
.export kernelmapped, data
BSS(kernelmapped, 4) /* set when kernel is mapped */
- .export fpu_curpcb, data
- BSS(fpu_curpcb, 4) /* pcb of the fpu owner */
.export fpu_enable, data
BSS(fpu_enable, 4) /* bits to set in the ccr to enable fpu */
BSS(cpu_fpuena, 4) /* enable FPU, otherwise force emulate */
@@ -991,9 +989,9 @@ ENTRY(TLABEL(excpt),0)
copy r9, arg0
copy r1, rp
copy r8, arg0
+ mfctl cr29, r1
mtctl r0, ccr /* cause a reload after exception */
- ldil L%fpu_curpcb, r1
- stw r0, R%fpu_curpcb(r1)
+ stw r0, CI_FPU_STATE(r1)
/* now, check for trap */
ldw 0(r9), r1
@@ -1057,7 +1055,6 @@ ENTRY(TLABEL(emu),0)
ldil L%cpu_fpuena, r1
ldw R%cpu_fpuena(r1), r9
comib,= 0, r9, $fpusw_emu
- ldil L%fpu_curpcb, r1
/* if we are already enabled and hit again, emulate */
mfctl ccr, r1
@@ -1066,8 +1063,9 @@ ENTRY(TLABEL(emu),0)
nop
$fpusw_emu
+ mfctl cr29, r1
mtctl r0, ccr /* cause a reload after exception */
- stw r0, R%fpu_curpcb(r1)
+ stw r0, CI_FPU_STATE(r1)
#if 0
/* here we emulate the fld/fst */
mfctl iir, r1
@@ -1090,9 +1088,9 @@ $fpusw_set
depi 3, 25, 2, r1
mtctl r1, ccr
- ldil L%fpu_curpcb, r16
+ mfctl cr29, r16
mfctl cr30, r9
- ldw R%fpu_curpcb(r16), r16
+ ldw CI_FPU_STATE(r16), r16
comb,=,n r16, r0, $fpusw_nosave
comb,=,n r16, r9, $fpusw_done
@@ -1151,8 +1149,8 @@ $fpusw_nosave
fldds,ma -8(r17), fr1
fldds 0(r17), fr0 /* fr0 must be restored last */
- ldil L%fpu_curpcb, r1
- stw r17, R%fpu_curpcb(r1)
+ mfctl cr29, r1
+ stw r17, CI_FPU_STATE(r1)
$fpusw_done
rfir
diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c
index 2cc6fe47640..57b2a26de6c 100644
--- a/sys/arch/hppa/hppa/machdep.c
+++ b/sys/arch/hppa/hppa/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.189 2010/06/27 03:03:48 thib Exp $ */
+/* $OpenBSD: machdep.c,v 1.190 2010/06/29 00:50:40 jsing Exp $ */
/*
* Copyright (c) 1999-2003 Michael Shalayeff
@@ -1200,7 +1200,6 @@ setregs(p, pack, stack, retval)
u_long stack;
register_t *retval;
{
- extern paddr_t fpu_curpcb; /* from locore.S */
struct trapframe *tf = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;
register_t zero;
@@ -1221,9 +1220,9 @@ setregs(p, pack, stack, retval)
copyout(&zero, (caddr_t)(stack + HPPA_FRAME_CRP), sizeof(register_t));
/* reset any of the pending FPU exceptions */
- if (tf->tf_cr30 == fpu_curpcb) {
+ if (tf->tf_cr30 == curcpu()->ci_fpu_state) {
fpu_exit();
- fpu_curpcb = 0;
+ curcpu()->ci_fpu_state = 0;
}
pcb->pcb_fpregs->fpr_regs[0] = ((u_int64_t)HPPA_FPU_INIT) << 32;
pcb->pcb_fpregs->fpr_regs[1] = 0;
@@ -1246,7 +1245,6 @@ sendsig(catcher, sig, mask, code, type, val)
int type;
union sigval val;
{
- extern paddr_t fpu_curpcb; /* from locore.S */
extern u_int fpu_enable;
struct proc *p = curproc;
struct trapframe *tf = p->p_md.md_regs;
@@ -1264,9 +1262,9 @@ sendsig(catcher, sig, mask, code, type, val)
#endif
/* flush the FPU ctx first */
- if (tf->tf_cr30 == fpu_curpcb) {
+ if (tf->tf_cr30 == curcpu()->ci_fpu_state) {
mtctl(fpu_enable, CR_CCR);
- fpu_save(fpu_curpcb);
+ fpu_save(curcpu()->ci_fpu_state);
/* fpu_curpcb = 0; only needed if fpregs are preset */
mtctl(0, CR_CCR);
}
@@ -1381,7 +1379,6 @@ sys_sigreturn(p, v, retval)
void *v;
register_t *retval;
{
- extern paddr_t fpu_curpcb; /* from locore.S */
struct sys_sigreturn_args /* {
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
@@ -1396,9 +1393,9 @@ sys_sigreturn(p, v, retval)
#endif
/* flush the FPU ctx first */
- if (tf->tf_cr30 == fpu_curpcb) {
+ if (tf->tf_cr30 == curcpu()->ci_fpu_state) {
fpu_exit();
- fpu_curpcb = 0;
+ curcpu()->ci_fpu_state = 0;
}
if ((error = copyin((caddr_t)scp, (caddr_t)&ksc, sizeof ksc)))
@@ -1474,7 +1471,6 @@ void
hpux_sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
union sigval val)
{
- extern paddr_t fpu_curpcb; /* from locore.S */
extern u_int fpu_enable;
struct proc *p = curproc;
struct pcb *pcb = &p->p_addr->u_pcb;
@@ -1490,10 +1486,10 @@ hpux_sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
p->p_comm, p->p_pid, sig, catcher);
#endif
/* flush the FPU ctx first */
- if (tf->tf_cr30 == fpu_curpcb) {
+ if (tf->tf_cr30 == curcpu()->ci_fpu_state) {
mtctl(fpu_enable, CR_CCR);
- fpu_save(fpu_curpcb);
- fpu_curpcb = 0;
+ fpu_save(curcpu()->ci_fpu_state);
+ curcpu()->ci_fpu_state = 0;
mtctl(0, CR_CCR);
}
@@ -1625,7 +1621,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
size_t newlen;
struct proc *p;
{
- extern paddr_t fpu_curpcb; /* from locore.S */
extern u_int fpu_enable;
extern int cpu_fpuena;
dev_t consdev;
@@ -1643,10 +1638,10 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
sizeof consdev));
case CPU_FPU:
- if (fpu_curpcb) {
+ if (curcpu()->ci_fpu_state) {
mtctl(fpu_enable, CR_CCR);
- fpu_save(fpu_curpcb);
- fpu_curpcb = 0;
+ fpu_save(curcpu()->ci_fpu_state);
+ curcpu()->ci_fpu_state = 0;
mtctl(0, CR_CCR);
}
return (sysctl_int(oldp, oldlenp, newp, newlen, &cpu_fpuena));
diff --git a/sys/arch/hppa/hppa/process_machdep.c b/sys/arch/hppa/hppa/process_machdep.c
index 30e37188824..7d9cadc7a6f 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.16 2010/03/30 14:57:02 kettenis Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.17 2010/06/29 00:50:40 jsing Exp $ */
/*
* Copyright (c) 1999-2004 Michael Shalayeff
@@ -86,12 +86,11 @@ process_read_fpregs(p, fpregs)
struct proc *p;
struct fpreg *fpregs;
{
- extern paddr_t fpu_curpcb;
extern u_int fpu_enable;
- if (p->p_md.md_regs->tf_cr30 == fpu_curpcb) {
+ if (p->p_md.md_regs->tf_cr30 == curcpu()->ci_fpu_state) {
mtctl(fpu_enable, CR_CCR);
- fpu_save((vaddr_t)p->p_addr->u_pcb.pcb_fpregs);
+ fpu_save(curcpu()->ci_fpu_state);
mtctl(0, CR_CCR);
}
bcopy(p->p_addr->u_pcb.pcb_fpregs, fpregs, 32 * 8);
@@ -151,11 +150,9 @@ process_write_fpregs(p, fpregs)
struct proc *p;
struct fpreg *fpregs;
{
- extern paddr_t fpu_curpcb;
-
- if (p->p_md.md_regs->tf_cr30 == fpu_curpcb) {
+ if (p->p_md.md_regs->tf_cr30 == curcpu()->ci_fpu_state) {
fpu_exit();
- fpu_curpcb = 0;
+ curcpu()->ci_fpu_state = 0;
}
bcopy(fpregs, p->p_addr->u_pcb.pcb_fpregs, 32 * 8);
diff --git a/sys/arch/hppa/hppa/vm_machdep.c b/sys/arch/hppa/hppa/vm_machdep.c
index 84941a7b0fb..a3dbef8b224 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.70 2010/05/02 22:59:11 kettenis Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.71 2010/06/29 00:50:40 jsing Exp $ */
/*
* Copyright (c) 1999-2004 Michael Shalayeff
@@ -100,7 +100,6 @@ cpu_fork(p1, p2, stack, stacksize, func, arg)
void (*func)(void *);
void *arg;
{
- extern paddr_t fpu_curpcb; /* from locore.S */
extern u_int fpu_enable;
struct pcb *pcbp;
struct trapframe *tf;
@@ -110,9 +109,9 @@ cpu_fork(p1, p2, stack, stacksize, func, arg)
if (round_page(sizeof(struct user)) > NBPG)
panic("USPACE too small for user");
#endif
- if (p1->p_md.md_regs->tf_cr30 == fpu_curpcb) {
+ if (p1->p_md.md_regs->tf_cr30 == curcpu()->ci_fpu_state) {
mtctl(fpu_enable, CR_CCR);
- fpu_save(fpu_curpcb);
+ fpu_save(curcpu()->ci_fpu_state);
mtctl(0, CR_CCR);
}
@@ -179,13 +178,12 @@ void
cpu_exit(p)
struct proc *p;
{
- extern paddr_t fpu_curpcb; /* from locore.S */
struct trapframe *tf = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;
- if (fpu_curpcb == tf->tf_cr30) {
+ if (tf->tf_cr30 == curcpu()->ci_fpu_state) {
fpu_exit();
- fpu_curpcb = 0;
+ curcpu()->ci_fpu_state = 0;
}
pool_put(&hppa_fppl, pcb->pcb_fpregs);
diff --git a/sys/arch/hppa/include/cpu.h b/sys/arch/hppa/include/cpu.h
index 576b9189826..07868e52f3e 100644
--- a/sys/arch/hppa/include/cpu.h
+++ b/sys/arch/hppa/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.74 2010/06/03 15:48:58 jsing Exp $ */
+/* $OpenBSD: cpu.h,v 1.75 2010/06/29 00:50:40 jsing Exp $ */
/*
* Copyright (c) 2000-2004 Michael Shalayeff
@@ -84,6 +84,7 @@ struct cpu_info {
volatile int ci_flags;
struct proc *ci_curproc;
+ paddr_t ci_fpu_state; /* Process FPU state. */
paddr_t ci_stack;
register_t ci_psw; /* Processor Status Word. */