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.
This commit is contained in:
nwhitehorn 2011-11-17 15:49:42 +00:00
parent 6f4edbc718
commit ef4c84e32b
3 changed files with 25 additions and 8 deletions

View File

@ -303,7 +303,12 @@ powerpc_init(vm_offset_t startkernel, vm_offset_t endkernel,
*/ */
pc = __pcpu; pc = __pcpu;
pcpu_init(pc, 0, sizeof(struct 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; pc->pc_cpuid = 0;
__asm __volatile("mtsprg 0, %0" :: "r"(pc)); __asm __volatile("mtsprg 0, %0" :: "r"(pc));

View File

@ -88,7 +88,12 @@ cpudep_ap_bootstrap(void)
msr = PSL_KERNSET & ~PSL_EE; msr = PSL_KERNSET & ~PSL_EE;
mtmsr(msr); 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; pcpup->pc_curpcb = pcpup->pc_curthread->td_pcb;
sp = pcpup->pc_curpcb->pcb_sp; sp = pcpup->pc_curpcb->pcb_sp;

View File

@ -135,13 +135,20 @@ struct pmap;
#ifdef _KERNEL #ifdef _KERNEL
#define pcpup ((struct pcpu *) powerpc_get_pcpup()) #define pcpup ((struct pcpu *) powerpc_get_pcpup())
#ifdef __powerpc64__
register struct thread *curthread_reg __asm("%r13");
#else
register struct thread *curthread_reg __asm("%r2");
#endif
#ifdef AIM /* Book-E not yet adapted */ #ifdef AIM /* Book-E not yet adapted */
#define curthread curthread_reg static __inline __pure2 struct thread *
__curthread(void)
{
struct thread *td;
#ifdef __powerpc64__
__asm __volatile("mr %0,13" : "=r"(td));
#else
__asm __volatile("mr %0,2" : "=r"(td));
#endif
return (td);
}
#define curthread (__curthread())
#endif #endif
#define PCPU_GET(member) (pcpup->pc_ ## member) #define PCPU_GET(member) (pcpup->pc_ ## member)