Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Minimal changes to allow a kernel with "options MUL...



details:   https://anonhg.NetBSD.org/src/rev/99e9a9de2d0e
branches:  trunk
changeset: 537742:99e9a9de2d0e
user:      bjh21 <bjh21%NetBSD.org@localhost>
date:      Sat Oct 05 13:46:57 2002 +0000

description:
Minimal changes to allow a kernel with "options MULTIPROCESSOR" to compile
and boot multi-user on a single-processor machine.  Many of these changes
are wildly inappropriate for actual multi-processor operation, and correcting
this will be my next task.

diffstat:

 sys/arch/acorn32/acorn32/hydra.c |  29 +++++++++++++++++++++++-
 sys/arch/acorn32/include/cpu.h   |  46 +++++++++++++++++++++++++++++++++++++++-
 sys/arch/arm/arm/syscall.c       |  14 ++++++++---
 sys/arch/arm/arm32/cpuswitch.S   |  28 ++++++++++++++++++++----
 sys/arch/arm/arm32/genassym.cf   |   8 ++++++-
 sys/arch/arm/include/cpu.h       |   7 +++++-
 6 files changed, 118 insertions(+), 14 deletions(-)

diffs (truncated from 304 to 300 lines):

diff -r de5b970cfa06 -r 99e9a9de2d0e sys/arch/acorn32/acorn32/hydra.c
--- a/sys/arch/acorn32/acorn32/hydra.c  Sat Oct 05 13:29:29 2002 +0000
+++ b/sys/arch/acorn32/acorn32/hydra.c  Sat Oct 05 13:46:57 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hydra.c,v 1.5 2002/10/02 02:23:50 thorpej Exp $        */
+/*     $NetBSD: hydra.c,v 1.6 2002/10/05 13:46:57 bjh21 Exp $  */
 
 /*-
  * Copyright (c) 2002 Ben Harris
@@ -29,7 +29,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: hydra.c,v 1.5 2002/10/02 02:23:50 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hydra.c,v 1.6 2002/10/05 13:46:57 bjh21 Exp $");
 
 #include <sys/device.h>
 #include <sys/systm.h>
@@ -268,3 +268,28 @@
        bus_space_write_1(iot, ioh, HYDRA_MMU_MSN, 0);
        bus_space_write_1(iot, ioh, HYDRA_MMU_CLR, 0xf);
 }
+
+#ifdef MULTIPROCESSOR
+void
+cpu_boot_secondary_processors(void)
+{
+
+       /* Do nothing for now. */
+}
+
+cpuid_t
+cpu_number(void)
+{
+
+       return 0;
+}
+
+extern struct cpu_info cpu_info_store;
+
+struct cpu_info *
+curcpu(void)
+{
+
+       return &cpu_info_store;
+}
+#endif
diff -r de5b970cfa06 -r 99e9a9de2d0e sys/arch/acorn32/include/cpu.h
--- a/sys/arch/acorn32/include/cpu.h    Sat Oct 05 13:29:29 2002 +0000
+++ b/sys/arch/acorn32/include/cpu.h    Sat Oct 05 13:46:57 2002 +0000
@@ -1,3 +1,47 @@
-/* $NetBSD: cpu.h,v 1.1 2001/10/05 22:27:49 reinoud Exp $ */
+/*     $NetBSD: cpu.h,v 1.2 2002/10/05 13:46:58 bjh21 Exp $    */
+
+/*-
+ * Copyright (c) 2002 Ben Harris
+ * 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. 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.
+ */
+
+#if defined(_KERNEL) && defined(_KERNEL_OPT) && !defined(_LOCORE)
+#include "opt_multiprocessor.h"
+
+#ifdef MULTIPROCESSOR
+void   cpu_boot_secondary_processors(void);
+
+#define MP_CPU_INFO_MEMBERS                                            \
+       int ci_cpunum;                                                  \
+       struct proc *ci_curproc;
+
+#define CPU_IS_PRIMARY(ci)     ((ci)->ci_cpunum == 0)
+extern cpuid_t cpu_number(void);
+extern struct cpu_info *curcpu();
+
+#endif /* MULTIPROCESSOR */
+#endif /* _KERNEL && _KERNEL_OPT && !_LOCORE */
 
 #include <arm/cpu.h>
diff -r de5b970cfa06 -r 99e9a9de2d0e sys/arch/arm/arm/syscall.c
--- a/sys/arch/arm/arm/syscall.c        Sat Oct 05 13:29:29 2002 +0000
+++ b/sys/arch/arm/arm/syscall.c        Sat Oct 05 13:46:57 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syscall.c,v 1.10 2002/06/17 16:32:59 christos Exp $    */
+/*     $NetBSD: syscall.c,v 1.11 2002/10/05 13:46:59 bjh21 Exp $       */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -82,7 +82,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.10 2002/06/17 16:32:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.11 2002/10/05 13:46:59 bjh21 Exp $");
 
 #include <sys/device.h>
 #include <sys/errno.h>
@@ -187,6 +187,8 @@
        u_int nap, nargs;
        register_t *ap, *args, copyargs[MAXARGS], rval[2];
 
+       KERNEL_PROC_LOCK(p);
+
        switch (insn & SWI_OS_MASK) { /* Which OS is the SWI from? */
        case SWI_OS_ARM: /* ARM-defined SWIs */
                code = insn & 0x00ffffff;
@@ -291,7 +293,7 @@
        }
 
        trace_exit(p, code, args, rval, error);
-
+       KERNEL_PROC_UNLOCK(p);
        userret(p);
 }
 
@@ -309,10 +311,14 @@
                frame->tf_r15 &= ~R15_FLAG_C;   /* carry bit */
 #endif
 
+       KERNEL_PROC_UNLOCK(p);
        userret(p);
 #ifdef KTRACE
-       if (KTRPOINT(p, KTR_SYSRET))
+       if (KTRPOINT(p, KTR_SYSRET)) {
+               KERNEL_PROC_LOCK(p);
                ktrsysret(p, SYS_fork, 0, 0);
+               KERNEL_PROC_UNLOCK(p);
+       }
 #endif
 }
 
diff -r de5b970cfa06 -r 99e9a9de2d0e sys/arch/arm/arm32/cpuswitch.S
--- a/sys/arch/arm/arm32/cpuswitch.S    Sat Oct 05 13:29:29 2002 +0000
+++ b/sys/arch/arm/arm32/cpuswitch.S    Sat Oct 05 13:46:57 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpuswitch.S,v 1.18 2002/08/31 03:07:32 thorpej Exp $   */
+/*     $NetBSD: cpuswitch.S,v 1.19 2002/10/05 13:46:59 bjh21 Exp $     */
 
 /*
  * Copyright (c) 1994-1998 Mark Brinicombe.
@@ -44,6 +44,7 @@
  */
 
 #include "opt_armfpe.h"
+#include "opt_multiprocessor.h"
 
 #include "assym.h"
 #include <machine/param.h>
@@ -207,8 +208,16 @@
  * This function has several entry points
  */
 
+#ifdef MULTIPROCESSOR
+.Lcpu_info_store:
+       .word   _C_LABEL(cpu_info_store)
+.Lcurproc:
+       /* FIXME: This is bogus in the general case. */
+       .word   _C_LABEL(cpu_info_store) + CI_CURPROC
+#else
 .Lcurproc:
        .word   _C_LABEL(curproc)
+#endif
 
 .Lcurpcb:
        .word   _C_LABEL(curpcb)
@@ -240,7 +249,7 @@
  */
 /* LINTSTUB: Ignore */
 ASENTRY_NP(idle)
-#if defined(LOCKDEBUG)
+#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
        bl      _C_LABEL(sched_unlock_idle)
 #endif
        ldr     r3, .Lcpu_do_powersave
@@ -306,7 +315,7 @@
        /* stash the old proc while we call functions */
        mov     r5, r1
 
-#if defined(LOCKDEBUG)
+#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
        /* release the sched_lock before handling interrupts */
        bl      _C_LABEL(sched_unlock_idle)
 #endif
@@ -336,7 +345,7 @@
 
 .Lswitch_search:
        IRQdisable
-#if defined(LOCKDEBUG)
+#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
        bl      _C_LABEL(sched_lock_idle)
 #endif
 
@@ -434,7 +443,7 @@
         */
        str     r0, [r6, #(P_BACK)]
 
-#if defined(LOCKDEBUG)
+#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
        /*
         * unlock the sched_lock, but leave interrupts off, for now.
         */
@@ -443,7 +452,13 @@
        mov     r1, r7
 #endif
 
+#ifdef MULTIPROCESSOR
+       /* XXX use curcpu() */
+       ldr     r0, .Lcpu_info_store
+       str     r0, [r6, #(P_CPU)]
+#else
        /* p->p_cpu initialized in fork1() for single-processor */
+#endif
 
        /* Process is now on a processor. */
        mov     r0, #SONPROC                    /* p->p_stat = SONPROC */
@@ -737,6 +752,9 @@
        ldmfd   sp!, {r4-r7, pc}
 
 ENTRY(proc_trampoline)
+#ifdef MULTIPROCESSOR
+       bl      _C_LABEL(proc_trampoline_mp)
+#endif
        add     lr, pc, #(.Ltrampoline_return - . - 8)
        mov     r0, r5
        mov     r1, sp
diff -r de5b970cfa06 -r 99e9a9de2d0e sys/arch/arm/arm32/genassym.cf
--- a/sys/arch/arm/arm32/genassym.cf    Sat Oct 05 13:29:29 2002 +0000
+++ b/sys/arch/arm/arm32/genassym.cf    Sat Oct 05 13:46:57 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.15 2002/08/31 03:07:32 thorpej Exp $
+#      $NetBSD: genassym.cf,v 1.16 2002/10/05 13:47:00 bjh21 Exp $
 
 # Copyright (c) 1982, 1990 The Regents of the University of California.
 # All rights reserved.
@@ -50,6 +50,8 @@
 include <machine/frame.h>
 include <machine/vmparam.h>
 
+include "opt_multiprocessor.h"
+
 define __PROG32                1
 ifdef __ARM_FIQ_INDIRECT
 define __ARM_FIQ_INDIRECT      1
@@ -67,6 +69,7 @@
 define P_ADDR                  offsetof(struct proc, p_addr)
 define P_BACK                  offsetof(struct proc, p_back)
 define P_FORW                  offsetof(struct proc, p_forw)
+define P_CPU                   offsetof(struct proc, p_cpu)
 define P_PRIORITY              offsetof(struct proc, p_priority)
 define P_STAT                  offsetof(struct proc, p_stat)
 define P_WCHAN                 offsetof(struct proc, p_wchan)
@@ -122,3 +125,6 @@
 define CF_SLEEP                offsetof(struct cpu_functions, cf_sleep)
 
 define CI_CURPRIORITY          offsetof(struct cpu_info, ci_schedstate.spc_curpriority)
+ifdef MULTIPROCESSOR
+define CI_CURPROC              offsetof(struct cpu_info, ci_curproc)
+endif
diff -r de5b970cfa06 -r 99e9a9de2d0e sys/arch/arm/include/cpu.h
--- a/sys/arch/arm/include/cpu.h        Sat Oct 05 13:29:29 2002 +0000
+++ b/sys/arch/arm/include/cpu.h        Sat Oct 05 13:46:57 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.29 2002/08/16 15:25:54 thorpej Exp $ */
+/*     $NetBSD: cpu.h,v 1.30 2002/10/05 13:47:00 bjh21 Exp $   */
 
 /*
  * Copyright (c) 1994-1996 Mark Brinicombe.
@@ -208,11 +208,16 @@
        u_int32_t ci_cpurev;            /* CPU revision */
        u_int32_t ci_ctrl;              /* The CPU control register */
        struct evcnt ci_arm700bugcount;
+#ifdef MULTIPROCESSOR
+       MP_CPU_INFO_MEMBERS
+#endif
 };
 
+#ifndef MULTIPROCESSOR
 extern struct cpu_info cpu_info_store;
 #define        curcpu()        (&cpu_info_store)
 #define cpu_number()   0



Home | Main Index | Thread Index | Old Index