]>
Commit | Line | Data |
---|---|---|
43866e37 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. | |
43866e37 | 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 | |
43866e37 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. | |
43866e37 A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | ||
23 | #ifndef _PPC_CPU_CAPABILITIES_H | |
24 | #define _PPC_CPU_CAPABILITIES_H | |
25 | ||
26 | /* Sadly, some clients of this interface misspell __APPLE_API_PRIVATE. | |
27 | * To avoid breaking them, we accept the incorrect _APPLE_API_PRIVATE. | |
28 | */ | |
29 | #ifdef _APPLE_API_PRIVATE | |
30 | #ifndef __APPLE_API_PRIVATE | |
31 | #define __APPLE_API_PRIVATE | |
32 | #endif /* __APPLE_API_PRIVATE */ | |
33 | #endif /* _APPLE_API_PRIVATE */ | |
34 | ||
35 | #ifndef __APPLE_API_PRIVATE | |
36 | #error cpu_capabilities.h is for Apple Internal use only | |
37 | #else /* __APPLE_API_PRIVATE */ | |
38 | ||
39 | /* _cpu_capabilities | |
40 | * | |
41 | * This is the authoritative way to determine from user mode what | |
42 | * implementation-specific processor features are available. | |
43 | * This API only supported for Apple internal use. | |
44 | * | |
45 | */ | |
46 | ||
47 | #ifndef __ASSEMBLER__ | |
48 | ||
49 | extern int _cpu_capabilities; | |
50 | ||
51 | #endif /* __ASSEMBLER__ */ | |
52 | ||
53 | /* Bit definitions for _cpu_capabilities: */ | |
54 | ||
55 | #define kHasAltivec 0x00000001 | |
56 | #define k64Bit 0x00000002 // 64-bit GPRs | |
57 | #define kCache32 0x00000004 // cache line size is 32 bytes | |
58 | #define kCache64 0x00000008 | |
59 | #define kCache128 0x00000010 | |
60 | #define kDcbaRecommended 0x00000020 // PPC: dcba is available and recommended | |
61 | #define kDcbaAvailable 0x00000040 // PPC: dcba is available but is not recommended | |
62 | #define kDataStreamsRecommended 0x00000080 // PPC: dst, dstt, dstst, dss, and dssall instructions available and recommended | |
63 | #define kDataStreamsAvailable 0x00000100 // PPC: dst, dstt, dstst, dss, and dssall instructions available but not recommended | |
64 | #define kDcbtStreamsRecommended 0x00000200 // PPC: enhanced dcbt instruction available and recommended | |
65 | #define kDcbtStreamsAvailable 0x00000400 // PPC: enhanced dcbt instruction available and recommended | |
66 | ||
67 | #define kUP 0x00008000 // set if (kNumCPUs == 1) | |
68 | #define kNumCPUs 0x00FF0000 // number of CPUs (see _NumCPUs() below) | |
69 | ||
70 | #define kNumCPUsShift 16 // see _NumCPUs() below | |
71 | ||
72 | #define kHasGraphicsOps 0x08000000 // PPC: has fres, frsqrte, and fsel instructions | |
73 | #define kHasStfiwx 0x10000000 // PPC: has stfiwx instruction | |
74 | #define kHasFsqrt 0x20000000 // PPC: has fsqrt and fsqrts instructions | |
75 | ||
76 | #ifndef __ASSEMBLER__ | |
77 | ||
78 | static __inline__ int _NumCPUs( void ) { return (_cpu_capabilities & kNumCPUs) >> kNumCPUsShift; } | |
79 | ||
80 | #endif /* __ASSEMBLER__ */ | |
55e303ae A |
81 | |
82 | ||
83 | /* | |
84 | * The shared kernel/user "comm page(s)": | |
85 | * | |
86 | * The last eight pages of every address space are reserved for the kernel/user | |
87 | * "comm area". Because they can be addressed via a sign-extended 16-bit field, | |
88 | * it is particularly efficient to access code or data in the comm area with | |
89 | * absolute branches (ba, bla, bca) or absolute load/stores ("lwz r0,-4096(0)"). | |
90 | * Because the comm area can be reached from anywhere, dyld is not needed. | |
91 | * Although eight pages are reserved, presently only two are populated and mapped. | |
92 | * | |
93 | * Routines on the comm page(s) can be thought of as the firmware for extended processor | |
94 | * instructions, whose opcodes are special forms of "bla". Ie, they are cpu | |
95 | * capabilities. During system initialization, the kernel populates the comm page with | |
96 | * code customized for the particular processor and platform. | |
97 | * | |
98 | * Because Mach VM cannot map the last page of an address space, the max length of | |
99 | * the comm area is seven pages. | |
100 | */ | |
101 | ||
102 | #define _COMM_PAGE_BASE_ADDRESS (-8*4096) // start at page -8, ie 0xFFFF8000 | |
103 | #define _COMM_PAGE_AREA_LENGTH ( 7*4096) // reserved length of entire comm area | |
104 | #define _COMM_PAGE_AREA_USED ( 2*4096) // we use two pages so far | |
105 | ||
106 | /* data in the comm page */ | |
107 | ||
108 | #define _COMM_PAGE_SIGNATURE (_COMM_PAGE_BASE_ADDRESS+0x000) // first few bytes are a signature | |
109 | #define _COMM_PAGE_VERSION (_COMM_PAGE_BASE_ADDRESS+0x01E) // 16-bit version# | |
110 | #define _COMM_PAGE_THIS_VERSION 1 // this is version 1 of the commarea format | |
111 | ||
112 | #define _COMM_PAGE_CPU_CAPABILITIES (_COMM_PAGE_BASE_ADDRESS+0x020) // mirror of extern int _cpu_capabilities | |
113 | #define _COMM_PAGE_NCPUS (_COMM_PAGE_BASE_ADDRESS+0x021) // number of configured CPUs | |
114 | #define _COMM_PAGE_ALTIVEC (_COMM_PAGE_BASE_ADDRESS+0x024) // nonzero if Altivec available | |
115 | #define _COMM_PAGE_64_BIT (_COMM_PAGE_BASE_ADDRESS+0x025) // nonzero if 64-bit processor | |
116 | #define _COMM_PAGE_CACHE_LINESIZE (_COMM_PAGE_BASE_ADDRESS+0x026) // cache line size (16-bit field) | |
117 | ||
118 | #define _COMM_PAGE_UNUSED1 (_COMM_PAGE_BASE_ADDRESS+0x030) // 16 unused bytes | |
119 | ||
120 | #define _COMM_PAGE_2_TO_52 (_COMM_PAGE_BASE_ADDRESS+0x040) // double float constant 2**52 | |
121 | #define _COMM_PAGE_10_TO_6 (_COMM_PAGE_BASE_ADDRESS+0x048) // double float constant 10**6 | |
122 | ||
123 | #define _COMM_PAGE_UNUSED2 (_COMM_PAGE_BASE_ADDRESS+0x050) // 16 unused bytes | |
124 | ||
125 | #define _COMM_PAGE_TIMEBASE (_COMM_PAGE_BASE_ADDRESS+0x060) // used by gettimeofday() | |
126 | #define _COMM_PAGE_TIMESTAMP (_COMM_PAGE_BASE_ADDRESS+0x068) // used by gettimeofday() | |
127 | #define _COMM_PAGE_SEC_PER_TICK (_COMM_PAGE_BASE_ADDRESS+0x070) // used by gettimeofday() | |
128 | ||
129 | #define _COMM_PAGE_UNUSED3 (_COMM_PAGE_BASE_ADDRESS+0x080) // 384 unused bytes | |
130 | ||
131 | /* jump table (bla to this address, which may be a branch to the actual code somewhere else) */ | |
132 | /* When new jump table entries are added, corresponding symbols should be added below */ | |
133 | ||
134 | #define _COMM_PAGE_ABSOLUTE_TIME (_COMM_PAGE_BASE_ADDRESS+0x200) // mach_absolute_time() | |
135 | #define _COMM_PAGE_SPINLOCK_TRY (_COMM_PAGE_BASE_ADDRESS+0x220) // spinlock_try() | |
136 | #define _COMM_PAGE_SPINLOCK_LOCK (_COMM_PAGE_BASE_ADDRESS+0x260) // spinlock_lock() | |
137 | #define _COMM_PAGE_SPINLOCK_UNLOCK (_COMM_PAGE_BASE_ADDRESS+0x2a0) // spinlock_unlock() | |
138 | #define _COMM_PAGE_PTHREAD_GETSPECIFIC (_COMM_PAGE_BASE_ADDRESS+0x2c0) // pthread_getspecific() | |
139 | #define _COMM_PAGE_GETTIMEOFDAY (_COMM_PAGE_BASE_ADDRESS+0x2e0) // used by gettimeofday() | |
140 | #define _COMM_PAGE_FLUSH_DCACHE (_COMM_PAGE_BASE_ADDRESS+0x4e0) // sys_dcache_flush() | |
141 | #define _COMM_PAGE_FLUSH_ICACHE (_COMM_PAGE_BASE_ADDRESS+0x520) // sys_icache_invalidate() | |
142 | #define _COMM_PAGE_PTHREAD_SELF (_COMM_PAGE_BASE_ADDRESS+0x580) // pthread_self() | |
143 | #define _COMM_PAGE_UNUSED4 (_COMM_PAGE_BASE_ADDRESS+0x5a0) // 32 unused bytes | |
144 | #define _COMM_PAGE_RELINQUISH (_COMM_PAGE_BASE_ADDRESS+0x5c0) // used by spinlocks | |
145 | ||
146 | #define _COMM_PAGE_UNUSED5 (_COMM_PAGE_BASE_ADDRESS+0x5e0) // 32 unused bytes | |
147 | ||
148 | #define _COMM_PAGE_BZERO (_COMM_PAGE_BASE_ADDRESS+0x600) // bzero() | |
149 | #define _COMM_PAGE_BCOPY (_COMM_PAGE_BASE_ADDRESS+0x780) // bcopy() | |
150 | #define _COMM_PAGE_MEMCPY (_COMM_PAGE_BASE_ADDRESS+0x7a0) // memcpy() | |
151 | #define _COMM_PAGE_MEMMOVE (_COMM_PAGE_BASE_ADDRESS+0x7a0) // memmove() | |
152 | ||
153 | #define _COMM_PAGE_UNUSED6 (_COMM_PAGE_BASE_ADDRESS+0xF80) // 128 unused bytes | |
154 | ||
155 | #define _COMM_PAGE_BIGCOPY (_COMM_PAGE_BASE_ADDRESS+0x1000)// very-long-operand copies | |
156 | ||
157 | #define _COMM_PAGE_END (_COMM_PAGE_BASE_ADDRESS+0x1600)// end of common page | |
158 | ||
159 | #ifdef __ASSEMBLER__ | |
160 | #ifdef __COMM_PAGE_SYMBOLS | |
161 | ||
162 | #define CREATE_COMM_PAGE_SYMBOL(symbol_name, symbol_address) \ | |
163 | .org (symbol_address - _COMM_PAGE_BASE_ADDRESS) @\ | |
164 | symbol_name: nop | |
165 | ||
166 | .text // Required to make a well behaved symbol file | |
167 | ||
168 | CREATE_COMM_PAGE_SYMBOL(___mach_absolute_time, _COMM_PAGE_ABSOLUTE_TIME) | |
169 | CREATE_COMM_PAGE_SYMBOL(___spin_lock_try, _COMM_PAGE_SPINLOCK_TRY) | |
170 | CREATE_COMM_PAGE_SYMBOL(___spin_lock, _COMM_PAGE_SPINLOCK_LOCK) | |
171 | CREATE_COMM_PAGE_SYMBOL(___spin_unlock, _COMM_PAGE_SPINLOCK_UNLOCK) | |
172 | CREATE_COMM_PAGE_SYMBOL(___pthread_getspecific, _COMM_PAGE_PTHREAD_GETSPECIFIC) | |
173 | CREATE_COMM_PAGE_SYMBOL(___gettimeofday, _COMM_PAGE_GETTIMEOFDAY) | |
174 | CREATE_COMM_PAGE_SYMBOL(___sys_dcache_flush, _COMM_PAGE_FLUSH_DCACHE) | |
175 | CREATE_COMM_PAGE_SYMBOL(___sys_icache_invalidate, _COMM_PAGE_FLUSH_ICACHE) | |
176 | CREATE_COMM_PAGE_SYMBOL(___pthread_self, _COMM_PAGE_PTHREAD_SELF) | |
177 | CREATE_COMM_PAGE_SYMBOL(___spin_lock_relinquish, _COMM_PAGE_RELINQUISH) | |
178 | CREATE_COMM_PAGE_SYMBOL(___bzero, _COMM_PAGE_BZERO) | |
179 | CREATE_COMM_PAGE_SYMBOL(___bcopy, _COMM_PAGE_BCOPY) | |
180 | CREATE_COMM_PAGE_SYMBOL(___memcpy, _COMM_PAGE_MEMCPY) | |
181 | // CREATE_COMM_PAGE_SYMBOL(___memmove, _COMM_PAGE_MEMMOVE) | |
182 | CREATE_COMM_PAGE_SYMBOL(___bigcopy, _COMM_PAGE_BIGCOPY) | |
183 | CREATE_COMM_PAGE_SYMBOL(___end_comm_page, _COMM_PAGE_END) | |
184 | ||
185 | .data // Required to make a well behaved symbol file | |
186 | .long 0 // Required to make a well behaved symbol file | |
187 | ||
188 | #endif /* __COMM_PAGE_SYMBOLS */ | |
189 | #endif /* __ASSEMBLER__ */ | |
190 | ||
43866e37 A |
191 | #endif /* __APPLE_API_PRIVATE */ |
192 | #endif /* _PPC_CPU_CAPABILITIES_H */ |