]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/commpage/pthread.s
xnu-517.tar.gz
[apple/xnu.git] / osfmk / ppc / commpage / pthread.s
CommitLineData
55e303ae
A
1/*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
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
13 * file.
14 *
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.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26#include <sys/appleapiopts.h>
27#include <ppc/asm.h> // EXT, LEXT
28#include <machine/cpu_capabilities.h>
29#include <machine/commpage.h>
30
31 .text
32 .align 2
33 .globl EXT(pthread_getspecific_sprg3)
34 .globl EXT(pthread_getspecific_uftrap)
35 .globl EXT(pthread_self_sprg3)
36 .globl EXT(pthread_self_uftrap)
37
38#define USER_SPRG3 259 // user-mode-readable encoding for SPRG3
39
40
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// *****************************************************
44//
45// For processors with user-readable SPRG3. Called with:
46// r3 = word number
47// r4 = offset to thread specific data (_PTHREAD_TSD_OFFSET)
48
49pthread_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
54 blr
55
56 COMMPAGE_DESCRIPTOR(pthread_getspecific_sprg3,_COMM_PAGE_PTHREAD_GETSPECIFIC,k64Bit,0,0)
57
58
59// ***************************************
60// * P T H R E A D _ S E L F _ S P R G 3 *
61// ***************************************
62//
63// For processors with user-readable SPRG3.
64
65pthread_self_sprg3:
66 mfspr r3,USER_SPRG3 // get per-thread cookie
67 blr
68
69 COMMPAGE_DESCRIPTOR(pthread_self_sprg3,_COMM_PAGE_PTHREAD_SELF,k64Bit,0,0)
70
71
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// *******************************************************
75//
76// For processors that use the Ultra-Fast-Trap to get the thread-specific ptr.
77// Called with:
78// r3 = word number
79// r4 = offset to thread specific data (_PTHREAD_TSD_OFFSET)
80
81pthread_getspecific_uftrap:
82 slwi r5,r3,2 // convert word# to byte offset
83 li r0,0x7FF2 // magic "pthread_self" ultra-fast trap code
84 sc
85 add r5,r5,r4 // add in offset to first word
86 lwzx r3,r3,r5 // get the thread-specific word
87 blr
88
89 COMMPAGE_DESCRIPTOR(pthread_getspecific_uftrap,_COMM_PAGE_PTHREAD_GETSPECIFIC,0,k64Bit,0)
90
91
92// *****************************************
93// * P T H R E A D _ S E L F _ U F T R A P *
94// *****************************************
95//
96// For processors that use the Ultra-Fast-Trap to get the thread-specific ptr.
97
98pthread_self_uftrap:
99 li r0,0x7FF2 // magic "pthread_self" ultra-fast trap code
100 sc // get r3==TLDP
101 blr
102
103 COMMPAGE_DESCRIPTOR(pthread_self_uftrap,_COMM_PAGE_PTHREAD_SELF,0,k64Bit,0)