]>
Commit | Line | Data |
---|---|---|
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 | |
55e303ae A |
30 | |
31 | #define USER_SPRG3 259 // user-mode-readable encoding for SPRG3 | |
32 | ||
33 | ||
91447636 A |
34 | // *********************************************************** |
35 | // * P T H R E A D _ G E T S P E C I F I C _ S P R G 3 _ 3 2 * | |
36 | // *********************************************************** | |
55e303ae | 37 | // |
91447636 | 38 | // For processors with user-readable SPRG3, in 32-bit mode. Called with: |
55e303ae A |
39 | // r3 = word number |
40 | // r4 = offset to thread specific data (_PTHREAD_TSD_OFFSET) | |
41 | ||
91447636 | 42 | pthread_getspecific_sprg3_32: |
55e303ae A |
43 | slwi r5,r3,2 // convert word# to byte offset |
44 | mfspr r3,USER_SPRG3 // get per-thread cookie | |
45 | add r5,r5,r4 // add in offset to first word | |
46 | lwzx r3,r3,r5 // get the thread-specific word | |
47 | blr | |
48 | ||
91447636 A |
49 | COMMPAGE_DESCRIPTOR(pthread_getspecific_sprg3_32,_COMM_PAGE_PTHREAD_GETSPECIFIC,k64Bit,0,kCommPage32) |
50 | ||
51 | ||
52 | // *********************************************************** | |
53 | // * P T H R E A D _ G E T S P E C I F I C _ S P R G 3 _ 6 4 * | |
54 | // *********************************************************** | |
55 | // | |
56 | // For processors with user-readable SPRG3, in 64-bit mode. This may not be used | |
57 | // because the 64-bit ABI uses r13 for the thread-local-data pointer. Called with: | |
58 | // r3 = word number | |
59 | // r4 = offset to thread specific data (_PTHREAD_TSD_OFFSET) | |
60 | ||
61 | pthread_getspecific_sprg3_64: | |
62 | sldi r5,r3,3 // convert double-word# to byte offset | |
63 | mfspr r3,USER_SPRG3 // get per-thread cookie | |
64 | add r5,r5,r4 // add in offset to first word | |
65 | ldx r3,r3,r5 // get the thread-specific doubleword | |
66 | blr | |
67 | ||
68 | COMMPAGE_DESCRIPTOR(pthread_getspecific_sprg3_64,_COMM_PAGE_PTHREAD_GETSPECIFIC,k64Bit,0,kCommPage64) | |
55e303ae A |
69 | |
70 | ||
71 | // *************************************** | |
72 | // * P T H R E A D _ S E L F _ S P R G 3 * | |
73 | // *************************************** | |
74 | // | |
91447636 | 75 | // For processors with user-readable SPRG3. Useable both in 32 and 64-bit modes. |
55e303ae A |
76 | |
77 | pthread_self_sprg3: | |
78 | mfspr r3,USER_SPRG3 // get per-thread cookie | |
79 | blr | |
80 | ||
91447636 | 81 | COMMPAGE_DESCRIPTOR(pthread_self_sprg3,_COMM_PAGE_PTHREAD_SELF,k64Bit,0,kCommPageBoth) |
55e303ae A |
82 | |
83 | ||
84 | // ******************************************************* | |
85 | // * P T H R E A D _ G E T S P E C I F I C _ U F T R A P * | |
86 | // ******************************************************* | |
87 | // | |
88 | // For processors that use the Ultra-Fast-Trap to get the thread-specific ptr. | |
89 | // Called with: | |
90 | // r3 = word number | |
91 | // r4 = offset to thread specific data (_PTHREAD_TSD_OFFSET) | |
92 | ||
93 | pthread_getspecific_uftrap: | |
94 | slwi r5,r3,2 // convert word# to byte offset | |
95 | li r0,0x7FF2 // magic "pthread_self" ultra-fast trap code | |
96 | sc | |
97 | add r5,r5,r4 // add in offset to first word | |
98 | lwzx r3,r3,r5 // get the thread-specific word | |
99 | blr | |
100 | ||
91447636 | 101 | COMMPAGE_DESCRIPTOR(pthread_getspecific_uftrap,_COMM_PAGE_PTHREAD_GETSPECIFIC,0,k64Bit,kCommPage32) |
55e303ae A |
102 | |
103 | ||
104 | // ***************************************** | |
105 | // * P T H R E A D _ S E L F _ U F T R A P * | |
106 | // ***************************************** | |
107 | // | |
108 | // For processors that use the Ultra-Fast-Trap to get the thread-specific ptr. | |
109 | ||
110 | pthread_self_uftrap: | |
111 | li r0,0x7FF2 // magic "pthread_self" ultra-fast trap code | |
112 | sc // get r3==TLDP | |
113 | blr | |
114 | ||
91447636 | 115 | COMMPAGE_DESCRIPTOR(pthread_self_uftrap,_COMM_PAGE_PTHREAD_SELF,0,k64Bit,kCommPage32) |