Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Make some more information (psw/fpu_state) per cpu.



details:   https://anonhg.NetBSD.org/src/rev/c1c7073fdf11
branches:  trunk
changeset: 761306:c1c7073fdf11
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sun Jan 23 09:44:58 2011 +0000

description:
Make some more information (psw/fpu_state) per cpu.

diffstat:

 sys/arch/hp700/hp700/autoconf.c  |  12 ++-------
 sys/arch/hp700/hp700/genassym.cf |   4 ++-
 sys/arch/hp700/hp700/locore.S    |  12 ++++------
 sys/arch/hp700/hp700/machdep.c   |  17 +++++++++++---
 sys/arch/hp700/include/cpu.h     |   7 ++++-
 sys/arch/hppa/hppa/fpu.c         |  21 +++++++++--------
 sys/arch/hppa/hppa/machdep.h     |   3 +-
 sys/arch/hppa/hppa/trap.S        |  46 ++++++++++++++++++++--------------------
 sys/arch/hppa/hppa/trap.c        |  10 ++++----
 sys/arch/hppa/hppa/vm_machdep.c  |   6 ++--
 10 files changed, 72 insertions(+), 66 deletions(-)

diffs (truncated from 443 to 300 lines):

diff -r 00eba59b7a97 -r c1c7073fdf11 sys/arch/hp700/hp700/autoconf.c
--- a/sys/arch/hp700/hp700/autoconf.c   Sun Jan 23 09:18:29 2011 +0000
+++ b/sys/arch/hp700/hp700/autoconf.c   Sun Jan 23 09:44:58 2011 +0000
@@ -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)
diff -r 00eba59b7a97 -r c1c7073fdf11 sys/arch/hp700/hp700/genassym.cf
--- a/sys/arch/hp700/hp700/genassym.cf  Sun Jan 23 09:18:29 2011 +0000
+++ b/sys/arch/hp700/hp700/genassym.cf  Sun Jan 23 09:44:58 2011 +0000
@@ -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
diff -r 00eba59b7a97 -r c1c7073fdf11 sys/arch/hp700/hp700/locore.S
--- a/sys/arch/hp700/hp700/locore.S     Sun Jan 23 09:18:29 2011 +0000
+++ b/sys/arch/hp700/hp700/locore.S     Sun Jan 23 09:44:58 2011 +0000
@@ -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
diff -r 00eba59b7a97 -r c1c7073fdf11 sys/arch/hp700/hp700/machdep.c
--- a/sys/arch/hp700/hp700/machdep.c    Sun Jan 23 09:18:29 2011 +0000
+++ b/sys/arch/hp700/hp700/machdep.c    Sun Jan 23 09:44:58 2011 +0000
@@ -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);
 
diff -r 00eba59b7a97 -r c1c7073fdf11 sys/arch/hp700/include/cpu.h
--- a/sys/arch/hp700/include/cpu.h      Sun Jan 23 09:18:29 2011 +0000
+++ b/sys/arch/hp700/include/cpu.h      Sun Jan 23 09:44:58 2011 +0000
@@ -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);
 
diff -r 00eba59b7a97 -r c1c7073fdf11 sys/arch/hppa/hppa/fpu.c
--- a/sys/arch/hppa/hppa/fpu.c  Sun Jan 23 09:18:29 2011 +0000
+++ b/sys/arch/hppa/hppa/fpu.c  Sun Jan 23 09:44:58 2011 +0000
@@ -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
diff -r 00eba59b7a97 -r c1c7073fdf11 sys/arch/hppa/hppa/machdep.h
--- a/sys/arch/hppa/hppa/machdep.h      Sun Jan 23 09:18:29 2011 +0000
+++ b/sys/arch/hppa/hppa/machdep.h      Sun Jan 23 09:44:58 2011 +0000
@@ -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);
diff -r 00eba59b7a97 -r c1c7073fdf11 sys/arch/hppa/hppa/trap.S
--- a/sys/arch/hppa/hppa/trap.S Sun Jan 23 09:18:29 2011 +0000
+++ b/sys/arch/hppa/hppa/trap.S Sun Jan 23 09:44:58 2011 +0000
@@ -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



Home | Main Index | Thread Index | Old Index