]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/arm/_structs.h
xnu-4903.270.47.tar.gz
[apple/xnu.git] / osfmk / mach / arm / _structs.h
1 /*
2 * Copyright (c) 2004-2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * @OSF_COPYRIGHT@
30 */
31 #ifndef _MACH_ARM__STRUCTS_H_
32 #define _MACH_ARM__STRUCTS_H_
33
34 #include <sys/cdefs.h> /* __DARWIN_UNIX03 */
35 #include <machine/types.h> /* __uint32_t */
36
37 #if __DARWIN_UNIX03
38 #define _STRUCT_ARM_EXCEPTION_STATE struct __darwin_arm_exception_state
39 _STRUCT_ARM_EXCEPTION_STATE
40 {
41 __uint32_t __exception; /* number of arm exception taken */
42 __uint32_t __fsr; /* Fault status */
43 __uint32_t __far; /* Virtual Fault Address */
44 };
45 #else /* !__DARWIN_UNIX03 */
46 #define _STRUCT_ARM_EXCEPTION_STATE struct arm_exception_state
47 _STRUCT_ARM_EXCEPTION_STATE
48 {
49 __uint32_t exception; /* number of arm exception taken */
50 __uint32_t fsr; /* Fault status */
51 __uint32_t far; /* Virtual Fault Address */
52 };
53 #endif /* __DARWIN_UNIX03 */
54
55 #if __DARWIN_UNIX03
56 #define _STRUCT_ARM_EXCEPTION_STATE64 struct __darwin_arm_exception_state64
57 _STRUCT_ARM_EXCEPTION_STATE64
58 {
59 __uint64_t __far; /* Virtual Fault Address */
60 __uint32_t __esr; /* Exception syndrome */
61 __uint32_t __exception; /* number of arm exception taken */
62 };
63 #else /* !__DARWIN_UNIX03 */
64 #define _STRUCT_ARM_EXCEPTION_STATE64 struct arm_exception_state64
65 _STRUCT_ARM_EXCEPTION_STATE64
66 {
67 __uint64_t far; /* Virtual Fault Address */
68 __uint32_t esr; /* Exception syndrome */
69 __uint32_t exception; /* number of arm exception taken */
70 };
71 #endif /* __DARWIN_UNIX03 */
72
73 #if __DARWIN_UNIX03
74 #define _STRUCT_ARM_THREAD_STATE struct __darwin_arm_thread_state
75 _STRUCT_ARM_THREAD_STATE
76 {
77 __uint32_t __r[13]; /* General purpose register r0-r12 */
78 __uint32_t __sp; /* Stack pointer r13 */
79 __uint32_t __lr; /* Link register r14 */
80 __uint32_t __pc; /* Program counter r15 */
81 __uint32_t __cpsr; /* Current program status register */
82 };
83 #else /* !__DARWIN_UNIX03 */
84 #define _STRUCT_ARM_THREAD_STATE struct arm_thread_state
85 _STRUCT_ARM_THREAD_STATE
86 {
87 __uint32_t r[13]; /* General purpose register r0-r12 */
88 __uint32_t sp; /* Stack pointer r13 */
89 __uint32_t lr; /* Link register r14 */
90 __uint32_t pc; /* Program counter r15 */
91 __uint32_t cpsr; /* Current program status register */
92 };
93 #endif /* __DARWIN_UNIX03 */
94
95 #if __DARWIN_UNIX03
96 #define _STRUCT_ARM_THREAD_STATE64 struct __darwin_arm_thread_state64
97 _STRUCT_ARM_THREAD_STATE64
98 {
99 __uint64_t __x[29]; /* General purpose registers x0-x28 */
100 __uint64_t __fp; /* Frame pointer x29 */
101 __uint64_t __lr; /* Link register x30 */
102 __uint64_t __sp; /* Stack pointer x31 */
103 __uint64_t __pc; /* Program counter */
104 __uint32_t __cpsr; /* Current program status register */
105 __uint32_t __pad; /* Same size for 32-bit or 64-bit clients */
106 };
107 #else /* !__DARWIN_UNIX03 */
108 #define _STRUCT_ARM_THREAD_STATE64 struct arm_thread_state64
109 _STRUCT_ARM_THREAD_STATE64
110 {
111 __uint64_t x[29]; /* General purpose registers x0-x28 */
112 __uint64_t fp; /* Frame pointer x29 */
113 __uint64_t lr; /* Link register x30 */
114 __uint64_t sp; /* Stack pointer x31 */
115 __uint64_t pc; /* Program counter */
116 __uint32_t cpsr; /* Current program status register */
117 __uint32_t __pad; /* Same size for 32-bit or 64-bit clients */
118 };
119 #endif /* __DARWIN_UNIX03 */
120 #if !defined(KERNEL)
121 #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__)
122 #if __DARWIN_UNIX03
123 #define __darwin_arm_thread_state64_get_pc(ts) \
124 ((ts).__pc)
125 #define __darwin_arm_thread_state64_get_pc_fptr(ts) \
126 ((void*)(uintptr_t)((ts).__pc))
127 #define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
128 ((ts).__pc = (uintptr_t)(fptr))
129 #define __darwin_arm_thread_state64_get_lr(ts) \
130 ((ts).__lr)
131 #define __darwin_arm_thread_state64_get_lr_fptr(ts) \
132 ((void*)(uintptr_t)((ts).__lr))
133 #define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
134 ((ts).__lr = (uintptr_t)(fptr))
135 #define __darwin_arm_thread_state64_get_sp(ts) \
136 ((ts).__sp)
137 #define __darwin_arm_thread_state64_set_sp(ts, ptr) \
138 ((ts).__sp = (uintptr_t)(ptr))
139 #define __darwin_arm_thread_state64_get_fp(ts) \
140 ((ts).__fp)
141 #define __darwin_arm_thread_state64_set_fp(ts, ptr) \
142 ((ts).__fp = (uintptr_t)(ptr))
143 #else /* !__DARWIN_UNIX03 */
144 #define __darwin_arm_thread_state64_get_pc(ts) \
145 ((ts).pc)
146 #define __darwin_arm_thread_state64_get_pc_fptr(ts) \
147 ((void*)(uintptr_t)((ts).pc))
148 #define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
149 ((ts).pc = (uintptr_t)(fptr))
150 #define __darwin_arm_thread_state64_get_lr(ts) \
151 ((ts).lr)
152 #define __darwin_arm_thread_state64_get_lr_fptr(ts) \
153 ((void*)(uintptr_t)((ts).lr))
154 #define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
155 ((ts).lr = (uintptr_t)(fptr))
156 #define __darwin_arm_thread_state64_get_sp(ts) \
157 ((ts).sp)
158 #define __darwin_arm_thread_state64_set_sp(ts, ptr) \
159 ((ts).sp = (uintptr_t)(ptr))
160 #define __darwin_arm_thread_state64_get_fp(ts) \
161 ((ts).fp)
162 #define __darwin_arm_thread_state64_set_fp(ts, ptr) \
163 ((ts).fp = (uintptr_t)(ptr))
164 #endif /* __DARWIN_UNIX03 */
165 #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__) */
166 #endif /* !defined(KERNEL) */
167
168 #if __DARWIN_UNIX03
169 #define _STRUCT_ARM_VFP_STATE struct __darwin_arm_vfp_state
170 _STRUCT_ARM_VFP_STATE
171 {
172 __uint32_t __r[64];
173 __uint32_t __fpscr;
174 };
175 #else /* !__DARWIN_UNIX03 */
176 #define _STRUCT_ARM_VFP_STATE struct arm_vfp_state
177 _STRUCT_ARM_VFP_STATE
178 {
179 __uint32_t r[64];
180 __uint32_t fpscr;
181 };
182 #endif /* __DARWIN_UNIX03 */
183
184 #if __DARWIN_UNIX03
185 #define _STRUCT_ARM_NEON_STATE64 struct __darwin_arm_neon_state64
186 #define _STRUCT_ARM_NEON_STATE struct __darwin_arm_neon_state
187
188 #if defined(__arm64__)
189 _STRUCT_ARM_NEON_STATE64
190 {
191 __uint128_t __v[32];
192 __uint32_t __fpsr;
193 __uint32_t __fpcr;
194 };
195
196 _STRUCT_ARM_NEON_STATE
197 {
198 __uint128_t __v[16];
199 __uint32_t __fpsr;
200 __uint32_t __fpcr;
201 };
202
203 #elif defined(__arm__)
204 /*
205 * No 128-bit intrinsic for ARM; leave it opaque for now.
206 */
207 _STRUCT_ARM_NEON_STATE64
208 {
209 char opaque[(32 * 16) + (2 * sizeof(__uint32_t))];
210 } __attribute__((aligned(16)));
211
212 _STRUCT_ARM_NEON_STATE
213 {
214 char opaque[(16 * 16) + (2 * sizeof(__uint32_t))];
215 } __attribute__((aligned(16)));
216
217 #else
218 #error Unknown architecture.
219 #endif
220
221 #else /* !__DARWIN_UNIX03 */
222 #define _STRUCT_ARM_NEON_STATE64 struct arm_neon_state64
223 #define _STRUCT_ARM_NEON_STATE struct arm_neon_state
224
225 #if defined(__arm64__)
226 _STRUCT_ARM_NEON_STATE64
227 {
228 __uint128_t q[32];
229 uint32_t fpsr;
230 uint32_t fpcr;
231 };
232 _STRUCT_ARM_NEON_STATE
233 {
234 __uint128_t q[16];
235 uint32_t fpsr;
236 uint32_t fpcr;
237 };
238 #elif defined(__arm__)
239 /*
240 * No 128-bit intrinsic for ARM; leave it opaque for now.
241 */
242 _STRUCT_ARM_NEON_STATE64
243 {
244 char opaque[(32 * 16) + (2 * sizeof(__uint32_t))];
245 } __attribute__((aligned(16)));
246
247 _STRUCT_ARM_NEON_STATE
248 {
249 char opaque[(16 * 16) + (2 * sizeof(__uint32_t))];
250 } __attribute__((aligned(16)));
251
252 #else
253 #error Unknown architecture.
254 #endif
255
256 #endif /* __DARWIN_UNIX03 */
257
258 /*
259 * Debug State
260 */
261 #if defined(__arm__)
262 /* Old-fashioned debug state is only for ARM */
263
264 #if __DARWIN_UNIX03
265 #define _STRUCT_ARM_DEBUG_STATE struct __darwin_arm_debug_state
266 _STRUCT_ARM_DEBUG_STATE
267 {
268 __uint32_t __bvr[16];
269 __uint32_t __bcr[16];
270 __uint32_t __wvr[16];
271 __uint32_t __wcr[16];
272 };
273 #else /* !__DARWIN_UNIX03 */
274 #define _STRUCT_ARM_DEBUG_STATE struct arm_debug_state
275 _STRUCT_ARM_DEBUG_STATE
276 {
277 __uint32_t bvr[16];
278 __uint32_t bcr[16];
279 __uint32_t wvr[16];
280 __uint32_t wcr[16];
281 };
282 #endif /* __DARWIN_UNIX03 */
283
284 #elif defined(__arm64__)
285
286 /* ARM's arm_debug_state is ARM64's arm_legacy_debug_state */
287
288 #if __DARWIN_UNIX03
289 #define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state
290 _STRUCT_ARM_LEGACY_DEBUG_STATE
291 {
292 __uint32_t __bvr[16];
293 __uint32_t __bcr[16];
294 __uint32_t __wvr[16];
295 __uint32_t __wcr[16];
296 };
297 #else /* __DARWIN_UNIX03 */
298 #define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state
299 _STRUCT_ARM_LEGACY_DEBUG_STATE
300 {
301 __uint32_t bvr[16];
302 __uint32_t bcr[16];
303 __uint32_t wvr[16];
304 __uint32_t wcr[16];
305 };
306 #endif /* __DARWIN_UNIX03 */
307 #else
308 #error unknown architecture
309 #endif
310
311 #if __DARWIN_UNIX03
312 #define _STRUCT_ARM_DEBUG_STATE32 struct __darwin_arm_debug_state32
313 _STRUCT_ARM_DEBUG_STATE32
314 {
315 __uint32_t __bvr[16];
316 __uint32_t __bcr[16];
317 __uint32_t __wvr[16];
318 __uint32_t __wcr[16];
319 __uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
320 };
321
322 #define _STRUCT_ARM_DEBUG_STATE64 struct __darwin_arm_debug_state64
323 _STRUCT_ARM_DEBUG_STATE64
324 {
325 __uint64_t __bvr[16];
326 __uint64_t __bcr[16];
327 __uint64_t __wvr[16];
328 __uint64_t __wcr[16];
329 __uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
330 };
331 #else /* !__DARWIN_UNIX03 */
332 #define _STRUCT_ARM_DEBUG_STATE32 struct arm_debug_state32
333 _STRUCT_ARM_DEBUG_STATE32
334 {
335 __uint32_t bvr[16];
336 __uint32_t bcr[16];
337 __uint32_t wvr[16];
338 __uint32_t wcr[16];
339 __uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
340 };
341
342 #define _STRUCT_ARM_DEBUG_STATE64 struct arm_debug_state64
343 _STRUCT_ARM_DEBUG_STATE64
344 {
345 __uint64_t bvr[16];
346 __uint64_t bcr[16];
347 __uint64_t wvr[16];
348 __uint64_t wcr[16];
349 __uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
350 };
351 #endif /* __DARWIN_UNIX03 */
352
353 #if __DARWIN_UNIX03
354 #define _STRUCT_ARM_CPMU_STATE64 struct __darwin_arm_cpmu_state64
355 _STRUCT_ARM_CPMU_STATE64
356 {
357 __uint64_t __ctrs[16];
358 };
359 #else /* __DARWIN_UNIX03 */
360 #define _STRUCT_ARM_CPMU_STATE64 struct arm_cpmu_state64
361 _STRUCT_ARM_CPMU_STATE64
362 {
363 __uint64_t ctrs[16];
364 };
365 #endif /* !__DARWIN_UNIX03 */
366
367 #endif /* _MACH_ARM__STRUCTS_H_ */