Sun Jan 23 09:44:59 2011 UTC ()
Make some more information (psw/fpu_state) per cpu.
(skrll)
diff -r1.38 -r1.39 src/sys/arch/hp700/hp700/autoconf.c
diff -r1.29 -r1.30 src/sys/arch/hp700/hp700/genassym.cf
diff -r1.51 -r1.52 src/sys/arch/hp700/hp700/locore.S
diff -r1.96 -r1.97 src/sys/arch/hp700/hp700/machdep.c
diff -r1.58 -r1.59 src/sys/arch/hp700/include/cpu.h
diff -r1.22 -r1.23 src/sys/arch/hppa/hppa/fpu.c
diff -r1.13 -r1.14 src/sys/arch/hppa/hppa/machdep.h
diff -r1.52 -r1.53 src/sys/arch/hppa/hppa/trap.S
diff -r1.95 -r1.96 src/sys/arch/hppa/hppa/trap.c
diff -r1.45 -r1.46 src/sys/arch/hppa/hppa/vm_machdep.c
--- src/sys/arch/hp700/hp700/Attic/autoconf.c 2011/01/14 16:48:15 1.38
+++ src/sys/arch/hp700/hp700/Attic/autoconf.c 2011/01/23 09:44:58 1.39
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.38 2011/01/14 16:48:15 skrll Exp $ */
+/* $NetBSD: autoconf.c,v 1.39 2011/01/23 09:44:58 skrll Exp $ */
/* $OpenBSD: autoconf.c,v 1.15 2001/06/25 00:43:10 mickey Exp $ */
@@ -86,7 +86,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.38 2011/01/14 16:48:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.39 2011/01/23 09:44:58 skrll Exp $");
#include "opt_kgdb.h"
#include "opt_useleds.h"
@@ -122,12 +122,6 @@
#include <hp700/dev/cpudevs.h>
#include <hp700/gsc/gscbusvar.h>
-register_t kpsw =
- PSW_Q | /* Interrupt State Collection Enable */
- PSW_P | /* Protection Identifier Validation Enable */
- PSW_C | /* Instruction Address Translation Enable */
- PSW_D; /* Data Address Translation Enable */
-
static TAILQ_HEAD(hppa_pdcmodule_head, hppa_pdcmodule) hppa_pdcmodule_list =
TAILQ_HEAD_INITIALIZER(hppa_pdcmodule_list);
@@ -192,7 +186,7 @@
/* in spl*() we trust */
hp700_intr_init();
__asm volatile("ssm %0, %%r0" :: "i" (PSW_I));
- kpsw |= PSW_I;
+ curcpu()->ci_psw |= PSW_I;
spl0();
if (cold_hook)
--- src/sys/arch/hp700/hp700/Attic/genassym.cf 2011/01/23 09:18:29 1.29
+++ src/sys/arch/hp700/hp700/Attic/genassym.cf 2011/01/23 09:44:58 1.30
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.29 2011/01/23 09:18:29 skrll Exp $
+# $NetBSD: genassym.cf,v 1.30 2011/01/23 09:44:58 skrll Exp $
# $OpenBSD: genassym.cf,v 1.18 2001/09/20 18:31:14 mickey Exp $
@@ -97,6 +97,8 @@
#define CI_SOFTLWPS offsetof(struct cpu_info, ci_softlwps)
define CI_MTX_COUNT offsetof(struct cpu_info, ci_mtx_count)
define CI_TRAPSAVE offsetof(struct cpu_info, ci_trapsave)
+define CI_PSW offsetof(struct cpu_info, ci_psw)
+define CI_FPU_STATE offsetof(struct cpu_info, ci_fpu_state)
ifdef MULTIPROCESSOR
define CI_CURLWP offsetof(struct cpu_info, ci_curlwp)
endif
--- src/sys/arch/hp700/hp700/Attic/locore.S 2011/01/23 08:52:02 1.51
+++ src/sys/arch/hp700/hp700/Attic/locore.S 2011/01/23 09:44:58 1.52
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.51 2011/01/23 08:52:02 skrll Exp $ */
+/* $NetBSD: locore.S,v 1.52 2011/01/23 09:44:58 skrll Exp $ */
/* $OpenBSD: locore.S,v 1.158 2008/07/28 19:08:46 miod Exp $ */
/*
@@ -150,10 +150,8 @@
.import esym, data
.import virtual_avail, data
.import lwp0, data
- .import kpsw, data
.import panic, code
.import fpu_csw, data
- .import fpu_cur_uspace, data
.import hp700_int_regs, data
BSS(pdc_stack, 4) /* temp stack for PDC call */
@@ -296,8 +294,8 @@
mtctl %t1, %pcoq
ldo 4(%t1), %t1
mtctl %t1, %pcoq
- ldil L%kpsw, %t1
- ldw R%kpsw(%t1), %t2
+ GET_CURCPU(%t1)
+ ldw CI_PSW(%t1), %t2
mtctl %t2, %ipsw
rfi
nop
@@ -932,10 +930,10 @@
* we'll get an assist emulation trap to swap
* states.
*/
- ldil L%fpu_cur_uspace, %t1
+ GET_CURCPU(%t1)
mfctl %ccr, %r1
mfctl CR_FPPADDR, %t2
- ldw R%fpu_cur_uspace(%t1), %t1
+ ldw CI_FPU_STATE(%t1), %t1
depi 0, 25, 2, %r1 ; disables the FPU
comb,<>,n %t1, %t2, 0 ; nullify if LWPs different
depi 3, 25, 2, %r1 ; enables the FPU
--- src/sys/arch/hp700/hp700/Attic/machdep.c 2011/01/13 21:15:15 1.96
+++ src/sys/arch/hp700/hp700/Attic/machdep.c 2011/01/23 09:44:58 1.97
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.96 2011/01/13 21:15:15 skrll Exp $ */
+/* $NetBSD: machdep.c,v 1.97 2011/01/23 09:44:58 skrll Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.96 2011/01/13 21:15:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.97 2011/01/23 09:44:58 skrll Exp $");
#include "opt_cputype.h"
#include "opt_ddb.h"
@@ -425,6 +425,7 @@
int btlb_slot_i;
struct btinfo_symtab *bi_sym;
struct pcb *pcb0;
+ struct cpu_info *ci;
#ifdef KGDB
boothowto |= RB_KDB; /* go to kgdb early if compiled in. */
@@ -437,6 +438,15 @@
#endif
lwp0.l_cpu = &cpus[0];
+ /* curcpu() is now valid */
+ ci = curcpu();
+
+ ci->ci_psw =
+ PSW_Q | /* Interrupt State Collection Enable */
+ PSW_P | /* Protection Identifier Validation Enable */
+ PSW_C | /* Instruction Address Translation Enable */
+ PSW_D; /* Data Address Translation Enable */
+
/* Copy bootinfo */
if (bi != NULL)
memcpy(&bootinfo, bi, sizeof(struct bootinfo));
@@ -632,7 +642,6 @@
const char *model;
u_int cpu_version, cpu_features;
int error;
- extern int kpsw;
/* may the scientific guessing begin */
cpu_type = hpc_unknown;
@@ -809,7 +818,7 @@
/* force strong ordering for now */
if (hppa_cpu_ispa20_p())
- kpsw |= PSW_O;
+ curcpu()->ci_psw |= PSW_O;
snprintf(cpu_model, sizeof(cpu_model), "HP9000/%s", model);
--- src/sys/arch/hp700/include/Attic/cpu.h 2011/01/22 10:57:07 1.58
+++ src/sys/arch/hp700/include/Attic/cpu.h 2011/01/23 09:44:58 1.59
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.58 2011/01/22 10:57:07 skrll Exp $ */
+/* $NetBSD: cpu.h,v 1.59 2011/01/23 09:44:58 skrll Exp $ */
/* $OpenBSD: cpu.h,v 1.55 2008/07/23 17:39:35 kettenis Exp $ */
@@ -114,7 +114,6 @@
extern const struct hppa_cpu_info *hppa_cpu_info;
extern int cpu_modelno;
extern int cpu_revision;
-extern register_t kpsw;
#endif
#endif
@@ -265,6 +264,10 @@
volatile int ci_cpl;
volatile int ci_ipending; /* The pending interrupts. */
u_int ci_intr_depth; /* Nonzero iff running an interrupt. */
+
+ register_t ci_psw; /* Processor Status Word. */
+ paddr_t ci_fpu_state; /* LWP FPU state address, or zero. */
+ u_long ci_itmr;
#endif /* !_KMEMUSER */
} __aligned(64);
--- src/sys/arch/hppa/hppa/fpu.c 2011/01/14 02:06:26 1.22
+++ src/sys/arch/hppa/hppa/fpu.c 2011/01/23 09:44:59 1.23
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu.c,v 1.22 2011/01/14 02:06:26 rmind Exp $ */
+/* $NetBSD: fpu.c,v 1.23 2011/01/23 09:44:59 skrll Exp $ */
/*
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.22 2011/01/14 02:06:26 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.23 2011/01/23 09:44:59 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -78,9 +78,6 @@
/* The number of times we have had to switch the FPU context. */
u_int fpu_csw;
-/* The U-space physical address of the proc in the FPU, or zero. */
-paddr_t fpu_cur_uspace;
-
/* In locore.S, this swaps states in and out of the FPU. */
void hppa_fpu_swapout(struct pcb *);
void hppa_fpu_swap(struct fpreg *, struct fpreg *);
@@ -193,7 +190,7 @@
* swapped in.
*/
fpu_csw = 0;
- fpu_cur_uspace = 0;
+ curcpu()->ci_fpu_state = 0;
mtctl(ccr_enable & (CCR_MASK ^ HPPA_FPUS), CR_CCR);
}
#ifdef FPEMUL
@@ -219,19 +216,23 @@
{
struct trapframe *tf = l->l_md.md_regs;
struct pcb *pcb = lwp_getpcb(l);
+ struct cpu_info *ci = curcpu();
+ if (!fpu_present)
+ return;
+
/*
* If we have a hardware FPU, and this process'
* state is currently in it, swap it out.
*/
-
- if (!fpu_present || fpu_cur_uspace == 0 ||
- fpu_cur_uspace != tf->tf_cr30) {
+
+ if (ci->ci_fpu_state == 0 ||
+ ci->ci_fpu_state != tf->tf_cr30) {
return;
}
hppa_fpu_swapout(pcb);
- fpu_cur_uspace = 0;
+ ci->ci_fpu_state = 0;
}
#ifdef FPEMUL
--- src/sys/arch/hppa/hppa/machdep.h 2010/03/31 12:56:14 1.13
+++ src/sys/arch/hppa/hppa/machdep.h 2011/01/23 09:44:59 1.14
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.h,v 1.13 2010/03/31 12:56:14 skrll Exp $ */
+/* $NetBSD: machdep.h,v 1.14 2011/01/23 09:44:59 skrll Exp $ */
/*
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -70,7 +70,6 @@
extern int fpu_present;
extern u_int fpu_version;
extern u_int fpu_csw;
-extern paddr_t fpu_cur_uspace;
void hppa_fpu_bootstrap(u_int);
void hppa_fpu_flush(struct lwp *);
void hppa_fpu_emulate(struct trapframe *, struct lwp *, u_int);
--- src/sys/arch/hppa/hppa/trap.S 2011/01/22 19:35:48 1.52
+++ src/sys/arch/hppa/hppa/trap.S 2011/01/23 09:44:59 1.53
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.S,v 1.52 2011/01/22 19:35:48 skrll Exp $ */
+/* $NetBSD: trap.S,v 1.53 2011/01/23 09:44:59 skrll Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -242,8 +242,8 @@
stw %r0, HPPA_FRAME_CRP(%sr1, %sp)
- ldil L%kpsw, %t1
- ldw R%kpsw(%sr1, %t1), %t1
+ GET_CURCPU_SPACE(%sr1, %t1)
+ ldw CI_PSW(%sr1, %t1), %t1
stw %r1, TF_CR15-TRAPFRAME_SIZEOF(%sr1, %t3) /* eiem ,bc */
stw %t1, TF_CR22-TRAPFRAME_SIZEOF(%sr1, %t3) /* ipsw */
@@ -793,10 +793,10 @@
mtctl %r1, CR_VTOP
/* Disable interrupts for the long haul. */
- ldil L%kpsw, %t1
- ldw R%kpsw(%t1), %r1
+ GET_CURCPU(%t1)
+ ldw CI_PSW(%t1), %r1
depi 0, PSW_I_POS, 1, %r1
- stw %r1, R%kpsw(%t1)
+ stw %r1, CI_PSW(%t1)
/* Reload the global data pointer. */
ldil L%$global$, %dp
@@ -842,8 +842,8 @@
L$check_do_rfi:
/* Load IPSW. */
- ldil L%kpsw, %r1
- ldw R%kpsw(%r1), %r1
+ GET_CURCPU(%r1)
+ ldw CI_PSW(%r1), %r1
mtctl %r1, %ipsw
/* Get the address of hppa_machine_check. */
@@ -942,9 +942,9 @@
/*
* The hardware FPU is disabled, so we need to swap in the FPU state of
- * the process whose uspace physical address in CR_UPADDR. We may also
- * need to swap out the FPU state of any process whose uspace physical
- * address is in the fpu_cur_uspace variable.
+ * the LWP whose uspace physical address in CR_UPADDR. We may also
+ * need to swap out the FPU state of any LWP whose uspace physical
+ * address is in curcpu()->ci_fpu_state.
*/
/*
@@ -957,8 +957,8 @@
mtctl %rp, %tr5
/* Call hppa_fpu_swap. */
- ldil L%fpu_cur_uspace, %arg0
- ldw R%fpu_cur_uspace(%arg0), %arg0
+ GET_CURCPU(%arg0)
+ ldw CI_FPU_STATE(%arg0), %arg0
mfctl CR_FPPADDR, %arg1
blr 0, %rp
b hppa_fpu_swap
@@ -1109,18 +1109,18 @@
L$fpu_swap_in:
/*
- * Stash the incoming user structure in fpu_cur_uspace. Because this
- * variable holds a physical address, this means that hppa_fpu_swap can
- * only be called with a non-zero user_in from physical mode (i.e., from
- * the emulation assist trap handler). And that's exactly what happens
- * now.
+ * Stash the incoming user structure in curcpu->ci_fpu_state. Because
+ * this variable holds a physical address, this means that hppa_fpu_swap
+ * can only be called with a non-zero user_in from physical mode (i.e.,
+ * from the emulation assist trap handler). And that's exactly what
+ * happens now.
*
- * So stash fpu_cur_uspace, branching past the swap-in code if it is
+ * So stash ci->ci_fpu_state, branching past the swap-in code if it is
* zero.
*/
- ldil L%fpu_cur_uspace, %r1
+ GET_CURCPU(%r1)
comb,= %r0, %arg1, L$fpu_no_swap_in
- stw %arg1, R%fpu_cur_uspace(%r1)
+ stw %arg1, CI_FPU_STATE(%r1)
/*
* Swap in the new FPU state.
@@ -1946,8 +1946,8 @@
mtsp %r0, %sr3
/* this will enable interrupts after `cold' */
- ldil L%kpsw, %t1
- ldw R%kpsw(%t1), %t2
+ GET_CURCPU(%t1)
+ ldw CI_PSW(%t1), %t2
mtctl %r0, %eiem
mtctl %t2, %ipsw
--- src/sys/arch/hppa/hppa/trap.c 2010/12/20 00:25:34 1.95
+++ src/sys/arch/hppa/hppa/trap.c 2011/01/23 09:44:59 1.96
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.95 2010/12/20 00:25:34 matt Exp $ */
+/* $NetBSD: trap.c,v 1.96 2011/01/23 09:44:59 skrll Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.95 2010/12/20 00:25:34 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.96 2011/01/23 09:44:59 skrll Exp $");
/* #define INTRDEBUG */
/* #define TRAPDEBUG */
@@ -411,7 +411,7 @@
extern int kernel_text;
extern int etext;
#endif
- extern register_t kpsw;
+ struct cpu_info *ci = curcpu();
#define SANITY(e) \
do { \
@@ -423,8 +423,8 @@
} while (/* CONSTCOND */ 0)
KASSERT(l != NULL);
- SANITY((tf->tf_ipsw & kpsw) == kpsw);
- SANITY((kpsw & PSW_I) == 0 || tf->tf_eiem != 0);
+ SANITY((tf->tf_ipsw & ci->ci_psw) == ci->ci_psw);
+ SANITY((ci->ci_psw & PSW_I) == 0 || tf->tf_eiem != 0);
if (tf->tf_iisq_head == HPPA_SID_KERNEL) {
vaddr_t minsp, maxsp, uv;
--- src/sys/arch/hppa/hppa/vm_machdep.c 2010/06/06 09:12:39 1.45
+++ src/sys/arch/hppa/hppa/vm_machdep.c 2011/01/23 09:44:59 1.46
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.45 2010/06/06 09:12:39 skrll Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.46 2011/01/23 09:44:59 skrll Exp $ */
/* $OpenBSD: vm_machdep.c,v 1.64 2008/09/30 18:54:26 miod Exp $ */
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.45 2010/06/06 09:12:39 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.46 2011/01/23 09:44:59 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -142,7 +142,7 @@
tf->tf_sr7 = HPPA_SID_KERNEL;
mfctl(CR_EIEM, tf->tf_eiem);
tf->tf_ipsw = PSW_C | PSW_Q | PSW_P | PSW_D | PSW_I /* | PSW_L */ |
- (kpsw & PSW_O);
+ (curcpu()->ci_psw & PSW_O);
/*
* Set up return value registers as libc:fork() expects