]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/commpage/pthread.s
xnu-517.12.7.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 *
e5568f75
A
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
55e303ae 11 *
e5568f75
A
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
55e303ae
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
e5568f75
A
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
55e303ae
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23#include <sys/appleapiopts.h>
24#include <ppc/asm.h> // EXT, LEXT
25#include <machine/cpu_capabilities.h>
26#include <machine/commpage.h>
27
28 .text
29 .align 2
30 .globl EXT(pthread_getspecific_sprg3)
31 .globl EXT(pthread_getspecific_uftrap)
32 .globl EXT(pthread_self_sprg3)
33 .globl EXT(pthread_self_uftrap)
34
35#define USER_SPRG3 259 // user-mode-readable encoding for SPRG3
36
37
38// *****************************************************
39// * P T H R E A D _ G E T S P E C I F I C _ S P R G 3 *
40// *****************************************************
41//
42// For processors with user-readable SPRG3. Called with:
43// r3 = word number
44// r4 = offset to thread specific data (_PTHREAD_TSD_OFFSET)
45
46pthread_getspecific_sprg3:
47 slwi r5,r3,2 // convert word# to byte offset
48 mfspr r3,USER_SPRG3 // get per-thread cookie
49 add r5,r5,r4 // add in offset to first word
50 lwzx r3,r3,r5 // get the thread-specific word
51 blr
52
53 COMMPAGE_DESCRIPTOR(pthread_getspecific_sprg3,_COMM_PAGE_PTHREAD_GETSPECIFIC,k64Bit,0,0)
54
55
56// ***************************************
57// * P T H R E A D _ S E L F _ S P R G 3 *
58// ***************************************
59//
60// For processors with user-readable SPRG3.
61
62pthread_self_sprg3:
63 mfspr r3,USER_SPRG3 // get per-thread cookie
64 blr
65
66 COMMPAGE_DESCRIPTOR(pthread_self_sprg3,_COMM_PAGE_PTHREAD_SELF,k64Bit,0,0)
67
68
69// *******************************************************
70// * P T H R E A D _ G E T S P E C I F I C _ U F T R A P *
71// *******************************************************
72//
73// For processors that use the Ultra-Fast-Trap to get the thread-specific ptr.
74// Called with:
75// r3 = word number
76// r4 = offset to thread specific data (_PTHREAD_TSD_OFFSET)
77
78pthread_getspecific_uftrap:
79 slwi r5,r3,2 // convert word# to byte offset
80 li r0,0x7FF2 // magic "pthread_self" ultra-fast trap code
81 sc
82 add r5,r5,r4 // add in offset to first word
83 lwzx r3,r3,r5 // get the thread-specific word
84 blr
85
86 COMMPAGE_DESCRIPTOR(pthread_getspecific_uftrap,_COMM_PAGE_PTHREAD_GETSPECIFIC,0,k64Bit,0)
87
88
89// *****************************************
90// * P T H R E A D _ S E L F _ U F T R A P *
91// *****************************************
92//
93// For processors that use the Ultra-Fast-Trap to get the thread-specific ptr.
94
95pthread_self_uftrap:
96 li r0,0x7FF2 // magic "pthread_self" ultra-fast trap code
97 sc // get r3==TLDP
98 blr
99
100 COMMPAGE_DESCRIPTOR(pthread_self_uftrap,_COMM_PAGE_PTHREAD_SELF,0,k64Bit,0)