Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Make it compile with "options MULTIPROCESSOR".



details:   https://anonhg.NetBSD.org/src/rev/31d932f18f08
branches:  trunk
changeset: 494485:31d932f18f08
user:      tsubai <tsubai%NetBSD.org@localhost>
date:      Thu Jul 06 22:56:22 2000 +0000

description:
Make it compile with "options MULTIPROCESSOR".

diffstat:

 sys/arch/macppc/include/cpu.h      |  41 ++++++++++++++-
 sys/arch/macppc/macppc/cpu.c       |  37 ++++++-------
 sys/arch/macppc/macppc/genassym.cf |   9 +++-
 sys/arch/macppc/macppc/locore.S    |  96 ++++++++++++++++++++++++++++++++++---
 sys/arch/macppc/macppc/machdep.c   |   7 +-
 sys/arch/powerpc/include/pcb.h     |   5 +-
 6 files changed, 154 insertions(+), 41 deletions(-)

diffs (truncated from 507 to 300 lines):

diff -r 8a310ce17b91 -r 31d932f18f08 sys/arch/macppc/include/cpu.h
--- a/sys/arch/macppc/include/cpu.h     Thu Jul 06 22:46:54 2000 +0000
+++ b/sys/arch/macppc/include/cpu.h     Thu Jul 06 22:56:22 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.11 2000/05/26 21:19:53 thorpej Exp $ */
+/*     $NetBSD: cpu.h,v 1.12 2000/07/06 22:56:22 tsubai Exp $  */
 
 /*
  * Copyright (C) 1995-1997 Wolfgang Solfrank.
@@ -35,12 +35,14 @@
 
 #if defined(_KERNEL) && !defined(_LKM)
 #include "opt_lockdebug.h"
+#include "opt_multiprocessor.h"
 #endif
 
 #include <machine/frame.h>
 #include <machine/psl.h>
 #include <machine/intr.h>
 
+#ifdef _KERNEL
 #include <sys/sched.h>
 struct cpu_info {
        struct schedstate_percpu ci_schedstate; /* scheduler state */
@@ -48,13 +50,41 @@
        u_long ci_spin_locks;           /* # of spin locks held */
        u_long ci_simple_locks;         /* # of simple locks held */
 #endif
+       struct proc *ci_curproc;        /* current owner of the processor */
+
+       struct pcb *ci_curpcb;
+       struct pmap *ci_curpm;
+       struct proc *ci_fpuproc;
+       struct pcb *ci_idle_pcb;        /* PA of our idle pcb */
+       int ci_cpuid;
 };
 
-#ifdef _KERNEL
+#ifdef MULTIPROCESSOR
+static __inline int
+cpu_number()
+{
+       int pir;
+
+       asm ("mfspr %0,1023" : "=r"(pir));
+       return pir;
+}
+
+extern struct cpu_info cpu_info[];
+
+#define CPU_IS_PRIMARY(ci)     ((ci)->ci_cpuid == 0)
+#define curcpu()               (&cpu_info[cpu_number()])
+#define curproc                        curcpu()->ci_curproc
+#define fpuproc                        curcpu()->ci_fpuproc
+#define curpcb                 curcpu()->ci_curpcb
+#define curpm                  curcpu()->ci_curpm
+
+#else
 extern struct cpu_info cpu_info_store;
 
-#define        curcpu()                (&cpu_info_store)
-#endif
+#define curcpu()               (&cpu_info_store)
+#define cpu_number()           0
+
+#endif /* MULTIPROCESSOR */
 
 #define        CLKF_USERMODE(frame)    (((frame)->srr1 & PSL_PR) != 0)
 #define        CLKF_BASEPRI(frame)     ((frame)->pri == 0)
@@ -63,7 +93,6 @@
 
 #define        cpu_swapout(p)
 #define cpu_wait(p)
-#define        cpu_number()            0
 
 extern void delay __P((unsigned));
 #define        DELAY(n)                delay(n)
@@ -77,6 +106,8 @@
 
 extern char bootpath[];
 
+#endif /* _KERNEL */
+
 #if defined(_KERNEL) || defined(_STANDALONE)
 #define        CACHELINESIZE   32
 #endif
diff -r 8a310ce17b91 -r 31d932f18f08 sys/arch/macppc/macppc/cpu.c
--- a/sys/arch/macppc/macppc/cpu.c      Thu Jul 06 22:46:54 2000 +0000
+++ b/sys/arch/macppc/macppc/cpu.c      Thu Jul 06 22:56:22 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.7 2000/07/05 16:02:38 tsubai Exp $   */
+/*     $NetBSD: cpu.c,v 1.8 2000/07/06 22:56:23 tsubai Exp $   */
 
 /*-
  * Copyright (C) 1998, 1999 Internet Research Institute, Inc.
@@ -62,6 +62,12 @@
 
 int ncpus;
 
+#ifdef MULTIPROCESSOR
+struct cpu_info cpu_info[2];
+#else
+struct cpu_info cpu_info_store;
+#endif
+
 extern struct cfdriver cpu_cd;
 extern int powersave;
 
@@ -69,17 +75,6 @@
 #define HH_ARBCONF     (HAMMERHEAD + 0x90)
 #define HH_INTR                (HAMMERHEAD + 0xc0)
 
-/* XXX for now */
-#undef cpu_number
-static inline int
-cpu_number()
-{
-       int pir;
-
-       asm ("mfspr %0,1023" : "=r"(pir));
-       return pir;
-}
-
 int
 cpumatch(parent, cf, aux)
        struct device *parent;
@@ -125,24 +120,27 @@
        void *aux;
 {
        struct confargs *ca = aux;
-       int *reg = ca->ca_reg;
+       int id = ca->ca_reg[0];
        int hid0, pvr;
        char model[80];
 
        ncpus++;
+#ifdef MULTIPROCESSOR
+       cpu_info[id].ci_cpuid = id;
+#endif
 
-       switch (reg[0]) {
+       switch (id) {
        case 0:
-               asm volatile ("mtspr 1023,%0" :: "r"(0));       /* PIR */
+               asm volatile ("mtspr 1023,%0" :: "r"(id));      /* PIR */
                identifycpu(model);
                printf(": %s, ID %d (primary)", model, cpu_number());
                break;
-/* #ifdef MULTIPROCESSOR */
+#ifdef MULTIPROCESSOR
        case 1:
                cpu_spinup();
                printf("\n");
                return;
-/* #endif */
+#endif
        default:
                printf(": more than 2 cpus?\n");
                panic("cpuattach");
@@ -315,7 +313,8 @@
        printf("\n");
 }
 
-/* #ifdef MULTIPROCESSOR */
+#ifdef MULTIPROCESSOR
+
 struct cpu_hatch_data {
        int running;
        int pir;
@@ -464,9 +463,7 @@
 
        for (;;);
 }
-/* #endif MULTIPROCESSOR */
 
-#ifdef MULTIPROCESSOR
 void
 cpu_boot_secondary_processors()
 {
diff -r 8a310ce17b91 -r 31d932f18f08 sys/arch/macppc/macppc/genassym.cf
--- a/sys/arch/macppc/macppc/genassym.cf        Thu Jul 06 22:46:54 2000 +0000
+++ b/sys/arch/macppc/macppc/genassym.cf        Thu Jul 06 22:56:22 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.5 2000/07/04 22:25:06 tsubai Exp $
+#      $NetBSD: genassym.cf,v 1.6 2000/07/06 22:56:24 tsubai Exp $
 
 #
 # Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -69,5 +69,12 @@
 define P_BACK          offsetof(struct proc, p_back)
 define P_ADDR          offsetof(struct proc, p_addr)
 define P_STAT          offsetof(struct proc, p_stat)
+define P_CPU           offsetof(struct proc, p_cpu)
 
 define SONPROC         SONPROC
+
+define CI_SIZE         sizeof(struct cpu_info)
+define CI_CURPROC      offsetof(struct cpu_info, ci_curproc)
+define CI_CURPCB       offsetof(struct cpu_info, ci_curpcb)
+define CI_CURPM        offsetof(struct cpu_info, ci_curpm)
+define CI_IDLE_PCB     offsetof(struct cpu_info, ci_idle_pcb)
diff -r 8a310ce17b91 -r 31d932f18f08 sys/arch/macppc/macppc/locore.S
--- a/sys/arch/macppc/macppc/locore.S   Thu Jul 06 22:46:54 2000 +0000
+++ b/sys/arch/macppc/macppc/locore.S   Thu Jul 06 22:56:22 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.25 2000/07/05 16:02:39 tsubai Exp $       */
+/*     $NetBSD: locore.S,v 1.26 2000/07/06 22:56:24 tsubai Exp $       */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -49,6 +49,17 @@
  */
 #define        bdneq   bdnzf 2,
 
+#if defined(MULTIPROCESSOR)
+/*
+ * Get varios per-cpu values.
+ */
+#define        GET_CPUINFO(r)                                          \
+       mfspr   r,1023;                 /* r = cpu_number() */  \
+       mulli   r,r,CI_SIZE;                                    \
+       addis   r,r,_C_LABEL(cpu_info)@ha;                      \
+       addi    r,r,_C_LABEL(cpu_info)@l;
+#endif
+
 /*
  * Globals
  */
@@ -95,8 +106,10 @@
 /*
  * File-scope for locore.S
  */
+#if !defined(MULTIPROCESSOR)
 idle_u:
        .long   0                       /* fake uarea during idle after exit */
+#endif
 openfirmware_entry:
        .long   0                       /* openfirmware entry point */
 srsave:
@@ -153,8 +166,14 @@
        lis     9,_C_LABEL(OF_buf)@ha
        stw     8,_C_LABEL(OF_buf)@l(9)
        addi    8,8,NBPG
+#if defined(MULTIPROCESSOR)
+       lis     9,_C_LABEL(cpu_info)@ha
+       addi    9,9,_C_LABEL(cpu_info)@l
+       stw     8,CI_IDLE_PCB(9)
+#else
        lis     9,idle_u@ha
        stw     8,idle_u@l(9)
+#endif
        addi    8,8,USPACE              /* space for idle_u */
        lis     9,_C_LABEL(proc0paddr)@ha
        stw     8,_C_LABEL(proc0paddr)@l(9)
@@ -355,10 +374,16 @@
  */
 ENTRY(switchexit)
 /* First switch to the idle pcb/kernel stack */
+#if defined(MULTIPROCESSOR)
+       GET_CPUINFO(7)
+       lwz     6,CI_IDLE_PCB(7)
+       stw     6,CI_CURPCB(7)
+#else
        lis     6,idle_u@ha
        lwz     6,idle_u@l(6)
        lis     7,_C_LABEL(curpcb)@ha
        stw     6,_C_LABEL(curpcb)@l(7)
+#endif
        addi    1,6,USPACE-16           /* 16 bytes are reserved at stack top */
        /*
         * Schedule the vmspace and stack to be freed (the proc arg is
@@ -382,11 +407,18 @@
        stw     30,8(1)
 
        mr      30,3
+#if defined(MULTIPROCESSOR)
+       GET_CPUINFO(3)
+       xor     31,31,31
+       stw     31,CI_CURPROC(3)        /* Zero to not accumulate cpu time */
+       lwz     31,CI_CURPCB(3)
+#else
        lis     3,_C_LABEL(curproc)@ha
        xor     31,31,31
        stw     31,_C_LABEL(curproc)@l(3) /* Zero to not accumulate cpu time */
        lis     3,_C_LABEL(curpcb)@ha
        lwz     31,_C_LABEL(curpcb)@l(3)
+#endif
 
        xor     3,3,3
        bl      _C_LABEL(lcsplx)
@@ -433,10 +465,8 @@
        stw     3,P_BACK(31)            /* probably superfluous */
 
 #if defined(MULTIPROCESSOR)
-       /*
-        * XXXSMP
-        * p->p_cpu = curcpu();
-        */
+       GET_CPUINFO(4)
+       stw     4,P_CPU(31)             /* p->p_cpu = curcpu() */



Home | Main Index | Thread Index | Old Index