Author: nwhitehorn
Date: Thu Nov 17 15:49:42 2011
New Revision: 227628
URL: http://svn.freebsd.org/changeset/base/227628

Log:
  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.

Modified:
  head/sys/powerpc/aim/machdep.c
  head/sys/powerpc/aim/mp_cpudep.c
  head/sys/powerpc/include/pcpu.h

Modified: head/sys/powerpc/aim/machdep.c
==============================================================================
--- head/sys/powerpc/aim/machdep.c      Thu Nov 17 15:48:12 2011        
(r227627)
+++ head/sys/powerpc/aim/machdep.c      Thu Nov 17 15:49:42 2011        
(r227628)
@@ -303,7 +303,12 @@ powerpc_init(vm_offset_t startkernel, vm
         */
        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));

Modified: head/sys/powerpc/aim/mp_cpudep.c
==============================================================================
--- head/sys/powerpc/aim/mp_cpudep.c    Thu Nov 17 15:48:12 2011        
(r227627)
+++ head/sys/powerpc/aim/mp_cpudep.c    Thu Nov 17 15:49:42 2011        
(r227628)
@@ -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;
 

Modified: head/sys/powerpc/include/pcpu.h
==============================================================================
--- head/sys/powerpc/include/pcpu.h     Thu Nov 17 15:48:12 2011        
(r227627)
+++ head/sys/powerpc/include/pcpu.h     Thu Nov 17 15:49:42 2011        
(r227628)
@@ -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)
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to