From owner-svn-src-head@FreeBSD.ORG Thu Nov 17 15:49:43 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1725C106566C; Thu, 17 Nov 2011 15:49:43 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E15F58FC15; Thu, 17 Nov 2011 15:49:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAHFngX2015706; Thu, 17 Nov 2011 15:49:42 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAHFngPZ015702; Thu, 17 Nov 2011 15:49:42 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201111171549.pAHFngPZ015702@svn.freebsd.org> From: Nathan Whitehorn Date: Thu, 17 Nov 2011 15:49:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227628 - in head/sys/powerpc: aim include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Nov 2011 15:49:43 -0000 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)