PERFORCE change 118512 for review

Marcel Moolenaar marcel at FreeBSD.org
Sat Apr 21 04:26:08 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=118512

Change 118512 by marcel at marcel_xcllnt on 2007/04/21 04:25:39

	Add OF_start_cpu() to start a CPU.

Affected files ...

.. //depot/projects/powerpc/sys/powerpc/include/ofw_machdep.h#2 edit
.. //depot/projects/powerpc/sys/powerpc/powerpc/locore.S#2 edit
.. //depot/projects/powerpc/sys/powerpc/powerpc/mp_machdep.c#10 edit
.. //depot/projects/powerpc/sys/powerpc/powerpc/ofw_machdep.c#8 edit

Differences ...

==== //depot/projects/powerpc/sys/powerpc/include/ofw_machdep.h#2 (text+ko) ====

@@ -32,5 +32,6 @@
 
 int  OF_decode_addr(phandle_t, int, bus_space_tag_t *, bus_space_handle_t *);
 void OF_getetheraddr(device_t dev, u_char *addr);
+void OF_start_cpu(phandle_t, void (*)(void *), void *);
 
 #endif /* _MACHINE_OFW_MACHDEP_H_ */

==== //depot/projects/powerpc/sys/powerpc/powerpc/locore.S#2 (text+ko) ====

@@ -183,6 +183,28 @@
 	b	OF_exit
 
 /*
+ * Kernel entry point for application/auxiliary
+ * processors (APs).
+ */
+	.globl  __start_ap
+__start_ap:
+	li	8,0
+	li	9,0x100
+	mtctr	9
+1:
+	dcbf	0,8
+	icbi	0,8
+	addi	8,8,0x20
+	bdnz	1b
+
+	sync
+	isync
+
+	bl	mi_startup
+9:
+	b       9b
+
+/*
  * int setfault()
  *
  * Similar to setjmp to setup for handling faults on accesses to user memory.

==== //depot/projects/powerpc/sys/powerpc/powerpc/mp_machdep.c#10 (text+ko) ====

@@ -33,9 +33,13 @@
 #include <sys/pcpu.h>
 #include <sys/smp.h>
 
+#include <machine/bus.h>
 #include <machine/smp.h>
 
 #include <dev/ofw/openfirm.h>
+#include <machine/ofw_machdep.h>
+
+extern void __start_ap(void *);
 
 MALLOC_DEFINE(M_SMP, "smp", "SMP specific datastructures");
 
@@ -103,11 +107,8 @@
 
 	/* Get the p-handle of the BSP. */
 	chosen = OF_finddevice("/chosen");
-	if (chosen != -1) {
-		res = OF_getprop(chosen, "cpu", &inst, sizeof(inst));
-		bsp = (res > 0) ? OF_instance_to_package(inst) : -1;
-	} else
-		bsp = -1;
+	res = OF_getprop(chosen, "cpu", &inst, sizeof(inst));
+	bsp = (res > 0) ? OF_instance_to_package(inst) : -1;
 
 	root = OF_peer(0);
 	dev = OF_child(root);
@@ -145,6 +146,11 @@
 			pc->pc_bsp = 1;
 		}
 		all_cpus |= 1 << cpuid;
+		if (pc->pc_bsp)
+			continue;
+
+		/* Start AP */
+		OF_start_cpu(dev, __start_ap, pc);
 	}
 }
 

==== //depot/projects/powerpc/sys/powerpc/powerpc/ofw_machdep.c#8 (text+ko) ====

@@ -278,6 +278,33 @@
 }
 
 void
+OF_start_cpu(phandle_t cpu, void (*entry)(void *), void *arg)
+{
+	static struct {
+		cell_t	name;
+		cell_t	nargs;
+		cell_t	nreturns;
+		cell_t	cpu;
+		cell_t	entry;
+		cell_t	arg;
+	} args = {
+		(cell_t)"start-cpu",
+		3,
+		0
+	};
+
+	printf("XXX: %s: cpu=%x, entry=%p, arg=%p...", __func__, cpu,
+	    entry, arg);
+
+	args.cpu = (cell_t)cpu;
+	args.entry = (cell_t)entry;
+	args.arg = (cell_t)arg;
+	openfirmware(&args);
+
+	printf(" ok\n");
+}
+
+void
 OF_getetheraddr(device_t dev, u_char *addr)
 {
 	phandle_t	node;


More information about the p4-projects mailing list