Module Name:    src
Committed By:   matt
Date:           Wed Jun 29 06:03:52 UTC 2011

Modified Files:
        src/sys/arch/powerpc/booke: booke_machdep.c

Log Message:
Add cpu_hatch and cpu_boot_secondary_cpus.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/powerpc/booke/booke_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/powerpc/booke/booke_machdep.c
diff -u src/sys/arch/powerpc/booke/booke_machdep.c:1.11 src/sys/arch/powerpc/booke/booke_machdep.c:1.12
--- src/sys/arch/powerpc/booke/booke_machdep.c:1.11	Thu Jun 23 05:42:27 2011
+++ src/sys/arch/powerpc/booke/booke_machdep.c	Wed Jun 29 06:03:52 2011
@@ -52,6 +52,8 @@
 
 #include <uvm/uvm_extern.h>
 
+#include <powerpc/cpuset.h>
+#include <powerpc/pcb.h>
 #include <powerpc/spr.h>
 #include <powerpc/booke/spr.h>
 #include <powerpc/booke/cpuvar.h>
@@ -121,6 +123,7 @@
 		.ci_tlb_info = &pmap_tlb0_info,
 		.ci_softc = &cpu_softc[0],
 		.ci_cpl = IPL_HIGH,
+		.ci_idepth = -1,
 	},
 #ifdef MULTIPROCESSOR
 	[CPU_MAXNUM-1] = {
@@ -128,9 +131,11 @@
 		.ci_tlb_info = &pmap_tlb0_info,
 		.ci_softc = &cpu_softc[CPU_MAXNUM-1],
 		.ci_cpl = IPL_HIGH,
+		.ci_idepth = -1,
 	},
 #endif
 };
+__CTASSERT(__arraycount(cpu_info) == __arraycount(cpu_softc));
 
 /*
  * This should probably be in autoconf!				XXX
@@ -145,6 +150,10 @@
 void *startsym, *endsym;
 #endif
 
+#if defined(MULTIPROCESSOR)
+volatile struct cpu_hatch_data cpu_hatch_data __cacheline_aligned;
+#endif
+
 int fake_mapiodev = 1;
 
 void
@@ -191,6 +200,23 @@
 	 */
 	bus_space_mallocok();
 	fake_mapiodev = 0;
+
+#ifdef MULTIPROCESSOR
+	for (size_t i = 1; i < __arraycount(cpu_info); i++) {
+		struct cpu_info * const ci = &cpu_info[i];
+		struct cpu_softc * const cpu = &cpu_softc[i];
+		cpu->cpu_ci = ci;
+		cpu->cpu_bst = cpu_softc[0].cpu_bst;
+		cpu->cpu_le_bst = cpu_softc[0].cpu_le_bst;
+		cpu->cpu_bsh = cpu_softc[0].cpu_bsh;
+		cpu->cpu_highmem = cpu_softc[0].cpu_highmem;
+		ci->ci_softc = cpu;
+		ci->ci_tlb_info = &pmap_tlb0_info;
+		ci->ci_cpl = IPL_HIGH;
+		ci->ci_idepth = -1;
+		ci->ci_pmap_kern_segtab = curcpu()->ci_pmap_kern_segtab;
+	}
+#endif /* MULTIPROCESSOR */
 }
 
 static void
@@ -338,7 +364,7 @@
 cpu_evcnt_attach(struct cpu_info *ci)
 {
 	struct cpu_softc * const cpu = ci->ci_softc;
-	const char * const xname = device_xname(ci->ci_dev);
+	const char * const xname = ci->ci_data.cpu_name;
 
 	evcnt_attach_dynamic_nozero(&ci->ci_ev_clock, EVCNT_TYPE_INTR,
 		NULL, xname, "clock");
@@ -390,6 +416,63 @@
 		&ci->ci_ev_traps, xname, "inst tlb misses");
 }
 
+#ifdef MULTIPROCESSOR
+register_t
+cpu_hatch(void)
+{
+	volatile struct cpuset_info * const csi = &cpuset_info;
+	const size_t id = cpu_number();
+
+	/*
+	 * We've hatched so tell the spinup code.
+	 */
+	CPUSET_ADD(csi->cpus_hatched, id);
+
+	/*
+	 * Loop until running bit for this cpu is set.
+	 */
+	while (!CPUSET_HAS_P(csi->cpus_running, id)) {
+		continue;
+	}
+
+	/*
+	 * Now that we are active, start the clocks.
+	 */
+	cpu_initclocks();
+
+	/*
+	 * Return sp of the idlelwp.  Which we should be already using but ...
+	 */
+	return curcpu()->ci_curpcb->pcb_sp;
+}
+
+void
+cpu_boot_secondary_processors(void)
+{
+	volatile struct cpuset_info * const csi = &cpuset_info;
+	CPU_INFO_ITERATOR cii;
+	struct cpu_info *ci;
+	__cpuset_t running = CPUSET_NULLSET;
+
+	for (CPU_INFO_FOREACH(cii, ci)) {
+		/*
+		 * Skip this CPU if it didn't sucessfully hatch.
+		 */
+		if (! CPUSET_HAS_P(csi->cpus_hatched, cpu_index(ci)))
+			continue;
+
+		KASSERT(!CPU_IS_PRIMARY(ci));
+		KASSERT(ci->ci_data.cpu_idlelwp);
+
+		CPUSET_ADD(running, cpu_index(ci));
+	}
+	KASSERT(CPUSET_EQUAL_P(csi->cpus_hatched, running));
+	if (!CPUSET_EMPTY_P(running)) {
+		CPUSET_ADDSET(csi->cpus_running, running);
+	}
+}
+#endif
+
 uint32_t
 cpu_read_4(bus_addr_t a)
 {

Reply via email to