PERFORCE change 111761 for review
Marcel Moolenaar
marcel at FreeBSD.org
Fri Dec 15 17:52:00 PST 2006
http://perforce.freebsd.org/chv.cgi?CH=111761
Change 111761 by marcel at marcel_jnpr on 2006/12/16 01:51:40
First small steps in supporting SMP:
o Make it compile.
o Count the number of CPUs and set mp_ncpus & mp_maxid.
Remove nooption SMP and nooption GDB from NOTES. Both
options can be compiled-in.
Add kernel config files for all my PowerPC boxes (= 2),
so that I always have them around...
Affected files ...
.. //depot/projects/powerpc/sys/powerpc/conf/IMAC#1 add
.. //depot/projects/powerpc/sys/powerpc/conf/NOTES#2 edit
.. //depot/projects/powerpc/sys/powerpc/conf/XSERVE#1 add
.. //depot/projects/powerpc/sys/powerpc/include/pcpu.h#3 edit
.. //depot/projects/powerpc/sys/powerpc/include/smp.h#3 edit
.. //depot/projects/powerpc/sys/powerpc/powerpc/machdep.c#5 edit
.. //depot/projects/powerpc/sys/powerpc/powerpc/mp_machdep.c#5 edit
Differences ...
==== //depot/projects/powerpc/sys/powerpc/conf/NOTES#2 (text+ko) ====
@@ -56,8 +56,6 @@
#####################################################################
# Options we don't want to deal with
-nooption SMP
-nooption GDB
nooption PPC_DEBUG
nooption PPC_PROBE_CHIPSET
nooption UKBD_DFLT_KEYMAP
==== //depot/projects/powerpc/sys/powerpc/include/pcpu.h#3 (text+ko) ====
@@ -54,11 +54,11 @@
#define CPUSAVE_SRR0 6 /* where SRR0 gets saved */
#define CPUSAVE_SRR1 7 /* where SRR1 gets saved */
-#define PCPUP ((struct pcpu *) powerpc_get_pcpup())
+#define pcpup ((struct pcpu *) powerpc_get_pcpup())
-#define PCPU_GET(member) (PCPUP->pc_ ## member)
-#define PCPU_PTR(member) (&PCPUP->pc_ ## member)
-#define PCPU_SET(member,value) (PCPUP->pc_ ## member = (value))
+#define PCPU_GET(member) (pcpup->pc_ ## member)
+#define PCPU_PTR(member) (&pcpup->pc_ ## member)
+#define PCPU_SET(member,value) (pcpup->pc_ ## member = (value))
#endif /* _KERNEL */
==== //depot/projects/powerpc/sys/powerpc/include/smp.h#3 (text+ko) ====
@@ -1,7 +1,48 @@
-/* $FreeBSD: src/sys/powerpc/include/smp.h,v 1.1 2001/06/16 07:14:04 benno Exp $ */
+/*-
+ * Copyright (c) 2006 Marcel Moolenaar
+ * 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.
+ *
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _MACHINE_SMP_H_
+#define _MACHINE_SMP_H_
+
+#ifdef _KERNEL
+
+#define IPI_AST 0
+#define IPI_RENDEZVOUS 1
+#define IPI_STOP 2
+#define IPI_PREEMPT 3
+
+#ifndef LOCORE
+
+void ipi_all(int ipi);
+void ipi_all_but_self(int ipi);
+void ipi_selected(cpumask_t cpus, int ipi);
+void ipi_self(int ipi);
-/*
- * An empty file now,
- * Although in the times to come,
- * More may be found here.
- */
+#endif /* !LOCORE */
+#endif /* _KERNEL */
+#endif /* !_MACHINE_SMP_H */
==== //depot/projects/powerpc/sys/powerpc/powerpc/machdep.c#5 (text+ko) ====
@@ -237,14 +237,6 @@
EVENTHANDLER_REGISTER(shutdown_final, powerpc_ofw_shutdown, 0,
SHUTDOWN_PRI_LAST);
-
-#ifdef SMP
- /*
- * OK, enough kmem_alloc/malloc state should be up, lets get on with it!
- */
- mp_start(); /* fire up the secondaries */
- mp_announce();
-#endif /* SMP */
}
extern char kernel_text[], _end[];
==== //depot/projects/powerpc/sys/powerpc/powerpc/mp_machdep.c#5 (text+ko) ====
@@ -1,60 +1,82 @@
/*-
- * Copyright (c) 2000 Doug Rabson
+ * Copyright (c) 2006 Marcel Moolenaar
* 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.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- *
- * $FreeBSD: src/sys/powerpc/powerpc/mp_machdep.c,v 1.13 2006/05/16 14:32:17 phk Exp $
+ * 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.
*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/sys/powerpc/powerpc/mp_machdep.c,v 1.13 2006/05/16 14:32:17 phk Exp $");
+
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/ktr.h>
-#include <sys/proc.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
-#include <sys/mutex.h>
#include <sys/kernel.h>
+#include <sys/pcpu.h>
#include <sys/smp.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <vm/vm_map.h>
+#include <machine/smp.h>
-#include <machine/atomic.h>
-#include <machine/pmap.h>
-
-int boot_cpu_id;
+#include <dev/ofw/openfirm.h>
void
cpu_mp_setmaxid(void)
{
+ phandle_t dev, root;
+ int res;
+ char buf[8];
+
+ mp_ncpus = 0;
+
+ /*
+ * Count the actual number of processors listed in the OFW
+ * device tree.
+ */
+ root = OF_peer(0);
+ for (dev = OF_child(root); dev != 0; dev = OF_peer(dev)) {
+ res = OF_getprop(dev, "device_type", buf, sizeof(buf));
+ if (res < 0)
+ continue;
+ if (strcmp(buf, "cpu") == 0)
+ mp_ncpus++;
+ }
+ /* Sanity. */
+ if (mp_ncpus == 0)
+ mp_ncpus = 1;
+
+ /*
+ * Set the largest cpuid we're going to use. This is necessary
+ * for * VM initialization.
+ */
+ mp_maxid = min(mp_ncpus, MAXCPU) - 1;
}
int
cpu_mp_probe(void)
{
- all_cpus = 1; /* needed for MB init code */
- return 0;
+
+ /*
+ * We're not going to enable SMP if there's only 1 processor.
+ */
+ return (mp_ncpus > 1);
}
void
@@ -66,3 +88,52 @@
cpu_mp_announce(void)
{
}
+
+static void
+ipi_send(struct pcpu *pc, int ipi)
+{
+}
+
+/* Send an IPI to a set of cpus. */
+void
+ipi_selected(cpumask_t cpus, int ipi)
+{
+ struct pcpu *pc;
+
+ SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
+ if (cpus & pc->pc_cpumask)
+ ipi_send(pc, ipi);
+ }
+}
+
+/* Send an IPI to all CPUs, including myself. */
+void
+ipi_all(int ipi)
+{
+ struct pcpu *pc;
+
+ SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
+ ipi_send(pc, ipi);
+ }
+}
+
+/* Send an IPI to all CPUs EXCEPT myself. */
+void
+ipi_all_but_self(int ipi)
+{
+ struct pcpu *pc;
+
+ SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
+ if (pc != pcpup)
+ ipi_send(pc, ipi);
+ }
+}
+
+/* Send an IPI to myself. */
+void
+ipi_self(int ipi)
+{
+
+ ipi_send(pcpup, ipi);
+}
+
More information about the p4-projects
mailing list