summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2011-11-17 15:49:42 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2011-11-17 15:49:42 +0000
commitef4c84e32bd0feba0a4aa485c44c23db1bc24293 (patch)
tree97cd6167540839daf45973e80763fcda71433a10
parent6f4edbc71847532df7e5dbb131dc1bf0bb75d255 (diff)
downloadFreeBSD-src-ef4c84e32bd0feba0a4aa485c44c23db1bc24293.zip
FreeBSD-src-ef4c84e32bd0feba0a4aa485c44c23db1bc24293.tar.gz
Use a global __pure2 function instead of a global register variable for
curthread, like on x86 and sparc64. This makes the kernel somewhat more clang friendly, which doesn't support global register variables.
-rw-r--r--sys/powerpc/aim/machdep.c7
-rw-r--r--sys/powerpc/aim/mp_cpudep.c7
-rw-r--r--sys/powerpc/include/pcpu.h15
3 files changed, 23 insertions, 6 deletions
diff --git a/sys/powerpc/aim/machdep.c b/sys/powerpc/aim/machdep.c
index c368c68..2049949 100644
--- a/sys/powerpc/aim/machdep.c
+++ b/sys/powerpc/aim/machdep.c
@@ -303,7 +303,12 @@ powerpc_init(vm_offset_t startkernel, vm_offset_t endkernel,
*/
pc = __pcpu;
pcpu_init(pc, 0, sizeof(struct pcpu));
- curthread_reg = pc->pc_curthread = &thread0;
+ pc->pc_curthread = &thread0;
+#ifdef __powerpc64__
+ __asm __volatile("mr 13,%0" :: "r"(pc->pc_curthread));
+#else
+ __asm __volatile("mr 2,%0" :: "r"(pc->pc_curthread));
+#endif
pc->pc_cpuid = 0;
__asm __volatile("mtsprg 0, %0" :: "r"(pc));
diff --git a/sys/powerpc/aim/mp_cpudep.c b/sys/powerpc/aim/mp_cpudep.c
index 68fe517..607256c 100644
--- a/sys/powerpc/aim/mp_cpudep.c
+++ b/sys/powerpc/aim/mp_cpudep.c
@@ -88,7 +88,12 @@ cpudep_ap_bootstrap(void)
msr = PSL_KERNSET & ~PSL_EE;
mtmsr(msr);
- curthread_reg = pcpup->pc_curthread = pcpup->pc_idlethread;
+ pcpup->pc_curthread = pcpup->pc_idlethread;
+#ifdef __powerpc64__
+ __asm __volatile("mr 13,%0" :: "r"(pcpup->pc_curthread));
+#else
+ __asm __volatile("mr 2,%0" :: "r"(pcpup->pc_curthread));
+#endif
pcpup->pc_curpcb = pcpup->pc_curthread->td_pcb;
sp = pcpup->pc_curpcb->pcb_sp;
diff --git a/sys/powerpc/include/pcpu.h b/sys/powerpc/include/pcpu.h
index 631abd2..2dac1b4 100644
--- a/sys/powerpc/include/pcpu.h
+++ b/sys/powerpc/include/pcpu.h
@@ -135,13 +135,20 @@ struct pmap;
#ifdef _KERNEL
#define pcpup ((struct pcpu *) powerpc_get_pcpup())
+
+#ifdef AIM /* Book-E not yet adapted */
+static __inline __pure2 struct thread *
+__curthread(void)
+{
+ struct thread *td;
#ifdef __powerpc64__
-register struct thread *curthread_reg __asm("%r13");
+ __asm __volatile("mr %0,13" : "=r"(td));
#else
-register struct thread *curthread_reg __asm("%r2");
+ __asm __volatile("mr %0,2" : "=r"(td));
#endif
-#ifdef AIM /* Book-E not yet adapted */
-#define curthread curthread_reg
+ return (td);
+}
+#define curthread (__curthread())
#endif
#define PCPU_GET(member) (pcpup->pc_ ## member)
OpenPOWER on IntegriCloud