2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 #include <sys/appleapiopts.h>
27 #include <ppc/asm.h> // EXT, LEXT
28 #include <machine/cpu_capabilities.h>
29 #include <machine/commpage.h>
33 .globl EXT(pthread_getspecific_sprg3)
34 .globl EXT(pthread_getspecific_uftrap)
35 .globl EXT(pthread_self_sprg3)
36 .globl EXT(pthread_self_uftrap)
38 #define USER_SPRG3 259 // user-mode-readable encoding for SPRG3
41 // *****************************************************
42 // * P T H R E A D _ G E T S P E C I F I C _ S P R G 3 *
43 // *****************************************************
45 // For processors with user-readable SPRG3. Called with:
47 // r4 = offset to thread specific data (_PTHREAD_TSD_OFFSET)
49 pthread_getspecific_sprg3:
50 slwi r5,r3,2 // convert word# to byte offset
51 mfspr r3,USER_SPRG3 // get per-thread cookie
52 add r5,r5,r4 // add in offset to first word
53 lwzx r3,r3,r5 // get the thread-specific word
56 COMMPAGE_DESCRIPTOR(pthread_getspecific_sprg3,_COMM_PAGE_PTHREAD_GETSPECIFIC,k64Bit,0,0)
59 // ***************************************
60 // * P T H R E A D _ S E L F _ S P R G 3 *
61 // ***************************************
63 // For processors with user-readable SPRG3.
66 mfspr r3,USER_SPRG3 // get per-thread cookie
69 COMMPAGE_DESCRIPTOR(pthread_self_sprg3,_COMM_PAGE_PTHREAD_SELF,k64Bit,0,0)
72 // *******************************************************
73 // * P T H R E A D _ G E T S P E C I F I C _ U F T R A P *
74 // *******************************************************
76 // For processors that use the Ultra-Fast-Trap to get the thread-specific ptr.
79 // r4 = offset to thread specific data (_PTHREAD_TSD_OFFSET)
81 pthread_getspecific_uftrap:
82 slwi r5,r3,2 // convert word# to byte offset
83 li r0,0x7FF2 // magic "pthread_self" ultra-fast trap code
85 add r5,r5,r4 // add in offset to first word
86 lwzx r3,r3,r5 // get the thread-specific word
89 COMMPAGE_DESCRIPTOR(pthread_getspecific_uftrap,_COMM_PAGE_PTHREAD_GETSPECIFIC,0,k64Bit,0)
92 // *****************************************
93 // * P T H R E A D _ S E L F _ U F T R A P *
94 // *****************************************
96 // For processors that use the Ultra-Fast-Trap to get the thread-specific ptr.
99 li r0,0x7FF2 // magic "pthread_self" ultra-fast trap code
103 COMMPAGE_DESCRIPTOR(pthread_self_uftrap,_COMM_PAGE_PTHREAD_SELF,0,k64Bit,0)