Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/vax First cut of multiprocessor support for vax. St...



details:   https://anonhg.NetBSD.org/src/rev/e5e3354c9e0c
branches:  trunk
changeset: 483841:e5e3354c9e0c
user:      ragge <ragge%NetBSD.org@localhost>
date:      Sun Mar 19 14:56:52 2000 +0000

description:
First cut of multiprocessor support for vax. Still much to do before
other CPUs than the master can spin up.

diffstat:

 sys/arch/vax/conf/GENERIC.MP |   7 ++++
 sys/arch/vax/include/cpu.h   |  63 ++++++++++++++++++++++++++++++++-------
 sys/arch/vax/include/lock.h  |  69 ++++++++++++++++++++++++++++++++++++++++++++
 sys/arch/vax/include/pmap.h  |   4 +-
 sys/arch/vax/vax/genassym.cf |   6 +++-
 sys/arch/vax/vax/machdep.c   |  31 +++++++++++++++++++-
 sys/arch/vax/vax/subr.s      |  20 +++++++++++-
 sys/arch/vax/vax/trap.c      |  11 ++++++-
 8 files changed, 192 insertions(+), 19 deletions(-)

diffs (truncated from 379 to 300 lines):

diff -r 45bdb074c9a7 -r e5e3354c9e0c sys/arch/vax/conf/GENERIC.MP
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/vax/conf/GENERIC.MP      Sun Mar 19 14:56:52 2000 +0000
@@ -0,0 +1,7 @@
+# $NetBSD: GENERIC.MP,v 1.1 2000/03/19 14:56:52 ragge Exp $
+#
+# Generic VAX kernel with multiprocessor support.
+
+include "arch/vax/conf/GENERIC"
+
+options        MULTIPROCESSOR          # include multiprocessor support
diff -r 45bdb074c9a7 -r e5e3354c9e0c sys/arch/vax/include/cpu.h
--- a/sys/arch/vax/include/cpu.h        Sun Mar 19 14:43:13 2000 +0000
+++ b/sys/arch/vax/include/cpu.h        Sun Mar 19 14:56:52 2000 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: cpu.h,v 1.41 1999/10/21 20:01:36 ragge Exp $      */
+/*      $NetBSD: cpu.h,v 1.42 2000/03/19 14:56:53 ragge Exp $      */
 
 /*
  * Copyright (c) 1994 Ludd, University of Lule}, Sweden
@@ -32,10 +32,17 @@
 
 #ifndef _VAX_CPU_H_
 #define _VAX_CPU_H_
+
+#if defined(_KERNEL) && !defined(_LKM)
+#include "opt_multiprocessor.h"
+#endif
+
+
 #ifdef _KERNEL
 
 #include <sys/cdefs.h>
 #include <sys/device.h>
+#include <sys/lock.h>
 
 #include <machine/mtpr.h>
 #include <machine/pcb.h>
@@ -45,7 +52,6 @@
 #define enablertclock()
 #define        cpu_wait(p)
 #define        cpu_swapout(p)
-#define        cpu_number()                    0
 
 /*
  * All cpu-dependent info is kept in this struct. Pointer to the
@@ -74,6 +80,49 @@
         int     ps;
 };
 
+#if defined(MULTIPROCESSOR)
+
+struct cpu_info {
+       /*
+        * Public members.
+        */
+       struct proc *ci_curproc;        /* current owner of the processor */
+       struct simplelock ci_slock;     /* lock on this data structure */
+       cpuid_t ci_cpuid;               /* our CPU ID */
+#if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
+       u_long ci_spin_locks;           /* # of spin locks held */
+       u_long ci_simple_locks;         /* # of simple locks held */
+#endif
+       /*
+        * Private members.
+        */
+       int     ci_want_resched;        /* Should change process */
+};
+
+/*
+ * VAX internal CPU numbering is not sequential; therefore have a separate
+ * function call that returns the cpu_info struct for this CPU.
+ *
+ * For the master CPU (or only) this struct is allocated early in startup;
+ * for other CPUs it is allocated when the CPU is found.
+ */
+extern int (*vax_cpu_number)(void);
+extern struct cpu_info *(*vax_curcpu)(void);
+
+#define        cpu_number()            (*vax_cpu_number)()
+#define        curcpu()                (*vax_curcpu)()
+#define        need_resched() {curcpu()->ci_want_resched++; mtpr(AST_OK,PR_ASTLVL); }
+#define        cpu_boot_secondary_processors()
+
+#else /* MULTIPROCESSOR */
+
+extern int     want_resched;   /* resched() was called */
+
+#define        cpu_number()                    0
+#define need_resched() { want_resched++; mtpr(AST_OK,PR_ASTLVL); }
+
+#endif /* MULTIPROCESSOR */
+
 extern struct device *booted_from;
 extern int mastercpu;
 extern int bootdev;
@@ -81,15 +130,6 @@
 #define        setsoftnet()    mtpr(12,PR_SIRR)
 #define setsoftclock() mtpr(8,PR_SIRR)
 #define        todr()          mfpr(PR_TODR)
-/*
- * Preempt the current process if in interrupt from user mode,
- * or after the current trap/syscall if in system mode.
- */
-
-#define need_resched(){ \
-       want_resched++; \
-       mtpr(AST_OK,PR_ASTLVL); \
-       }
 
 /*
  * Notify the current process (p) that it has a signal pending,
@@ -98,7 +138,6 @@
 
 #define signotify(p)     mtpr(AST_OK,PR_ASTLVL);
 
-extern int     want_resched;   /* resched() was called */
 
 /*
  * Give a profiling tick to the current process when the user profiling
diff -r 45bdb074c9a7 -r e5e3354c9e0c sys/arch/vax/include/lock.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/vax/include/lock.h       Sun Mar 19 14:56:52 2000 +0000
@@ -0,0 +1,69 @@
+/*     $NetBSD: lock.h,v 1.1 2000/03/19 14:56:53 ragge Exp $   */
+
+/*
+ * Copyright (c) 2000 Ludd, University of Lule}, Sweden.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed at Ludd, University of Lule}.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _VAX_LOCK_H_
+#define _VAX_LOCK_H_
+
+static __inline__ void
+cpu_simple_lock_init(__volatile struct simplelock *alp)
+{
+       alp->lock_data = SIMPLELOCK_UNLOCKED;
+}
+
+static __inline__ void
+cpu_simple_lock(__volatile struct simplelock *alp)
+{
+       __asm__ __volatile ("1:;bbssi $0, (%0), 1b"
+               : /* No output */
+               : "r"(&alp->lock_data));
+}
+
+static __inline__ void
+cpu_simple_unlock(__volatile struct simplelock *alp)
+{
+       alp->lock_data = SIMPLELOCK_UNLOCKED;
+}
+
+static __inline__ int
+cpu_simple_lock_try(__volatile struct simplelock *alp)
+{
+       register int ret;
+
+       __asm__ __volatile ("movl $0,%0;bbssi $0,(%1),1f;incl %0;1:"
+               : "&=r"(ret)
+               : "r"(&alp->lock_data));
+
+       return ret;
+}
+
+#endif /* _VAX_LOCK_H_ */
+
diff -r 45bdb074c9a7 -r e5e3354c9e0c sys/arch/vax/include/pmap.h
--- a/sys/arch/vax/include/pmap.h       Sun Mar 19 14:43:13 2000 +0000
+++ b/sys/arch/vax/include/pmap.h       Sun Mar 19 14:56:52 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.38 2000/03/04 07:27:48 matt Exp $      */
+/*     $NetBSD: pmap.h,v 1.39 2000/03/19 14:56:53 ragge Exp $     */
 
 /* 
  * Copyright (c) 1987 Carnegie-Mellon University
@@ -70,7 +70,7 @@
        long             pm_p0lr;       /* page 0 length register */
        struct pte      *pm_p1br;       /* page 1 base register */
        long             pm_p1lr;       /* page 1 length register */
-       int              pm_lock;       /* Lock entry in MP environment */
+       struct simplelock pm_lock;      /* Lock entry in MP environment */
        struct pmap_statistics   pm_stats;      /* Some statistics */
        u_char           pm_refcnt[NPTEPGS];    /* Refcount per pte page */
 } *pmap_t;
diff -r 45bdb074c9a7 -r e5e3354c9e0c sys/arch/vax/vax/genassym.cf
--- a/sys/arch/vax/vax/genassym.cf      Sun Mar 19 14:43:13 2000 +0000
+++ b/sys/arch/vax/vax/genassym.cf      Sun Mar 19 14:56:52 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.10 1999/11/19 22:09:55 ragge Exp $
+#      $NetBSD: genassym.cf,v 1.11 2000/03/19 14:56:53 ragge Exp $
 #
 # Copyright (c) 1997 Ludd, University of Lule}, Sweden.
 # All rights reserved.
@@ -59,6 +59,10 @@
 
 define KERNBASE        KERNBASE
 
+# Multiprocessor struct members
+define CI_CURPROC      offsetof(struct cpu_info, ci_curproc)
+define CI_WANT_RESCHED offsetof(struct cpu_info, ci_want_resched)
+
 # mtpr register numbers
 define PR_KSP          PR_KSP
 define PR_USP          PR_USP
diff -r 45bdb074c9a7 -r e5e3354c9e0c sys/arch/vax/vax/machdep.c
--- a/sys/arch/vax/vax/machdep.c        Sun Mar 19 14:43:13 2000 +0000
+++ b/sys/arch/vax/vax/machdep.c        Sun Mar 19 14:56:52 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.95 2000/03/07 00:05:59 matt Exp $     */
+/* $NetBSD: machdep.c,v 1.96 2000/03/19 14:56:53 ragge Exp $    */
 
 /*
  * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden.
@@ -51,6 +51,7 @@
 #include "opt_ns.h"
 #include "opt_compat_netbsd.h"
 #include "opt_compat_ultrix.h"
+#include "opt_multiprocessor.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -120,7 +121,15 @@
  * We do these external declarations here, maybe they should be done
  * somewhere else...
  */
+#if defined(MULTIPROCESSOR)
+static int dummy_cpu_number(void);
+static struct cpu_info *dummy_curcpu(void);
+
+int (*vax_cpu_number)(void) = dummy_cpu_number;
+struct cpu_info *(*vax_curcpu)(void) = dummy_curcpu;
+#else
 int            want_resched;
+#endif
 char           machine[] = MACHINE;            /* from <machine/param.h> */
 char           machine_arch[] = MACHINE_ARCH;  /* from <machine/param.h> */
 char           cpu_model[100];
@@ -750,3 +759,23 @@
        else
                rmfree(iomap, size, pageno);
 }
+
+#if defined(MULTIPROCESSOR)
+/*
+ * Default functions that returns CPU numbers etc on non-MP systems
+ * and for just the master CPU.
+ */
+int
+dummy_cpu_number()
+{ 
+       return 0;
+}
+   
+struct cpu_info *
+dummy_curcpu()
+{
+       extern char *scratch;
+
+       return (struct cpu_info *)(scratch + VAX_NBPG);
+}
+#endif 
diff -r 45bdb074c9a7 -r e5e3354c9e0c sys/arch/vax/vax/subr.s
--- a/sys/arch/vax/vax/subr.s   Sun Mar 19 14:43:13 2000 +0000
+++ b/sys/arch/vax/vax/subr.s   Sun Mar 19 14:56:52 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr.s,v 1.34 2000/01/24 02:40:34 matt Exp $      */
+/*     $NetBSD: subr.s,v 1.35 2000/03/19 14:56:54 ragge Exp $     */
 
 /*
  * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -34,6 +34,7 @@
 
 #include "assym.h"



Home | Main Index | Thread Index | Old Index