Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/powerpc/booke Add cpu_hatch and cpu_boot_secondary_...



details:   https://anonhg.NetBSD.org/src/rev/d7c8f168957a
branches:  trunk
changeset: 766651:d7c8f168957a
user:      matt <matt%NetBSD.org@localhost>
date:      Wed Jun 29 06:03:52 2011 +0000

description:
Add cpu_hatch and cpu_boot_secondary_cpus.

diffstat:

 sys/arch/powerpc/booke/booke_machdep.c |  85 +++++++++++++++++++++++++++++++++-
 1 files changed, 84 insertions(+), 1 deletions(-)

diffs (140 lines):

diff -r 5b5c8ecde435 -r d7c8f168957a sys/arch/powerpc/booke/booke_machdep.c
--- a/sys/arch/powerpc/booke/booke_machdep.c    Wed Jun 29 06:02:43 2011 +0000
+++ b/sys/arch/powerpc/booke/booke_machdep.c    Wed Jun 29 06:03:52 2011 +0000
@@ -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)
 {



Home | Main Index | Thread Index | Old Index