aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Whitehorn <nwhitehorn@FreeBSD.org>2017-11-25 23:23:24 +0000
committerNathan Whitehorn <nwhitehorn@FreeBSD.org>2017-11-25 23:23:24 +0000
commit91419bdafdfee515afb4e20e5c92035cc19074bb (patch)
treedc7ecc1d06e01113f92f376be9f7b7991083050b
parent8a92c52a84ab17738ae7cf73946ee49df3cd9efc (diff)
downloadsrc-91419bdafdfee515afb4e20e5c92035cc19074bb.tar.gz
src-91419bdafdfee515afb4e20e5c92035cc19074bb.zip
Avoid assumptions about the BSP being CPU 0.
MFC after: 3 weeks
Notes
Notes: svn path=/head/; revision=326217
-rw-r--r--sys/powerpc/ofw/ofw_machdep.c15
-rw-r--r--sys/powerpc/powerpc/machdep.c51
2 files changed, 33 insertions, 33 deletions
diff --git a/sys/powerpc/ofw/ofw_machdep.c b/sys/powerpc/ofw/ofw_machdep.c
index b0aa1860b38e..d9e5614d0ce0 100644
--- a/sys/powerpc/ofw/ofw_machdep.c
+++ b/sys/powerpc/ofw/ofw_machdep.c
@@ -530,11 +530,16 @@ openfirmware(void *args)
return (-1);
#ifdef SMP
- rv_args.args = args;
- rv_args.in_progress = 1;
- smp_rendezvous(smp_no_rendezvous_barrier, ofw_rendezvous_dispatch,
- smp_no_rendezvous_barrier, &rv_args);
- result = rv_args.retval;
+ if (cold) {
+ result = openfirmware_core(args);
+ } else {
+ rv_args.args = args;
+ rv_args.in_progress = 1;
+ smp_rendezvous(smp_no_rendezvous_barrier,
+ ofw_rendezvous_dispatch, smp_no_rendezvous_barrier,
+ &rv_args);
+ result = rv_args.retval;
+ }
#else
result = openfirmware_core(args);
#endif
diff --git a/sys/powerpc/powerpc/machdep.c b/sys/powerpc/powerpc/machdep.c
index 733d3f2ada8e..05736bb9efdd 100644
--- a/sys/powerpc/powerpc/machdep.c
+++ b/sys/powerpc/powerpc/machdep.c
@@ -235,9 +235,10 @@ uintptr_t
powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
{
struct pcpu *pc;
+ struct cpuref bsp;
vm_offset_t startkernel, endkernel;
void *kmdp;
- char *env;
+ char *env;
bool ofw_bootargs = false;
#ifdef DDB
vm_offset_t ksym_start;
@@ -311,32 +312,20 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
*/
proc_linkup0(&proc0, &thread0);
thread0.td_frame = &frame0;
-
- /*
- * Set up per-cpu data.
- */
- pc = __pcpu;
- pcpu_init(pc, 0, sizeof(struct pcpu));
- pc->pc_curthread = &thread0;
#ifdef __powerpc64__
- __asm __volatile("mr 13,%0" :: "r"(pc->pc_curthread));
+ __asm __volatile("mr 13,%0" :: "r"(&thread0));
#else
- __asm __volatile("mr 2,%0" :: "r"(pc->pc_curthread));
+ __asm __volatile("mr 2,%0" :: "r"(&thread0));
#endif
- pc->pc_cpuid = 0;
-
- __asm __volatile("mtsprg 0, %0" :: "r"(pc));
/*
* Init mutexes, which we use heavily in PMAP
*/
-
mutex_init();
/*
* Install the OF client interface
*/
-
OF_bootstrap();
if (ofw_bootargs)
@@ -347,19 +336,6 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
*/
cninit();
- /*
- * Complain if there is no metadata.
- */
- if (mdp == NULL || kmdp == NULL) {
- printf("powerpc_init: no loader metadata.\n");
- }
-
- /*
- * Init KDB
- */
-
- kdb_init();
-
#ifdef AIM
aim_cpu_init(toc);
#else /* BOOKE */
@@ -376,6 +352,25 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
platform_probe_and_attach();
/*
+ * Set up real per-cpu data.
+ */
+ if (platform_smp_get_bsp(&bsp) != 0)
+ bsp.cr_cpuid = 0;
+ pc = &__pcpu[bsp.cr_cpuid];
+ pcpu_init(pc, bsp.cr_cpuid, sizeof(struct pcpu));
+ pc->pc_curthread = &thread0;
+ thread0.td_oncpu = bsp.cr_cpuid;
+ pc->pc_cpuid = bsp.cr_cpuid;
+ pc->pc_hwref = bsp.cr_hwref;
+ pc->pc_pir = mfspr(SPR_PIR);
+ __asm __volatile("mtsprg 0, %0" :: "r"(pc));
+
+ /*
+ * Init KDB
+ */
+ kdb_init();
+
+ /*
* Bring up MMU
*/
pmap_bootstrap(startkernel, endkernel);