]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/arm/_structs.h
xnu-4903.221.2.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 };
176 #else /* !__DARWIN_UNIX03 */
177 #define _STRUCT_ARM_VFP_STATE struct arm_vfp_state
178 _STRUCT_ARM_VFP_STATE
179 {
180 __uint32_t r[64];
181 __uint32_t fpscr;
182 };
183 #endif /* __DARWIN_UNIX03 */
184
185 #if __DARWIN_UNIX03
186 #define _STRUCT_ARM_NEON_STATE64 struct __darwin_arm_neon_state64
187 #define _STRUCT_ARM_NEON_STATE struct __darwin_arm_neon_state
188
189 #if defined(__arm64__)
190 _STRUCT_ARM_NEON_STATE64
191 {
192 __uint128_t __v[32];
193 __uint32_t __fpsr;
194 __uint32_t __fpcr;
195 };
196
197 _STRUCT_ARM_NEON_STATE
198 {
199 __uint128_t __v[16];
200 __uint32_t __fpsr;
201 __uint32_t __fpcr;
202 };
203
204 #elif defined(__arm__)
205 /*
206 * No 128-bit intrinsic for ARM; leave it opaque for now.
207 */
208 _STRUCT_ARM_NEON_STATE64
209 {
210 char opaque[(32 * 16) + (2 * sizeof(__uint32_t))];
211 } __attribute__((aligned(16)));
212
213 _STRUCT_ARM_NEON_STATE
214 {
215 char opaque[(16 * 16) + (2 * sizeof(__uint32_t))];
216 } __attribute__((aligned(16)));
217
218 #else
219 #error Unknown architecture.
220 #endif
221
222 #else /* !__DARWIN_UNIX03 */
223 #define _STRUCT_ARM_NEON_STATE64 struct arm_neon_state64
224 #define _STRUCT_ARM_NEON_STATE struct arm_neon_state
225
226 #if defined(__arm64__)
227 _STRUCT_ARM_NEON_STATE64
228 {
229 __uint128_t q[32];
230 uint32_t fpsr;
231 uint32_t fpcr;
232
233 };
234 _STRUCT_ARM_NEON_STATE
235 {
236 __uint128_t q[16];
237 uint32_t fpsr;
238 uint32_t fpcr;
239
240 };
241 #elif defined(__arm__)
242 /*
243 * No 128-bit intrinsic for ARM; leave it opaque for now.
244 */
245 _STRUCT_ARM_NEON_STATE64
246 {
247 char opaque[(32 * 16) + (2 * sizeof(__uint32_t))];
248 } __attribute__((aligned(16)));
249
250 _STRUCT_ARM_NEON_STATE
251 {
252 char opaque[(16 * 16) + (2 * sizeof(__uint32_t))];
253 } __attribute__((aligned(16)));
254
255 #else
256 #error Unknown architecture.
257 #endif
258
259 #endif /* __DARWIN_UNIX03 */
260
261 /*
262 * Debug State
263 */
264 #if defined(__arm__)
265 /* Old-fashioned debug state is only for ARM */
266
267 #if __DARWIN_UNIX03
268 #define _STRUCT_ARM_DEBUG_STATE struct __darwin_arm_debug_state
269 _STRUCT_ARM_DEBUG_STATE
270 {
271 __uint32_t __bvr[16];
272 __uint32_t __bcr[16];
273 __uint32_t __wvr[16];
274 __uint32_t __wcr[16];
275 };
276 #else /* !__DARWIN_UNIX03 */
277 #define _STRUCT_ARM_DEBUG_STATE struct arm_debug_state
278 _STRUCT_ARM_DEBUG_STATE
279 {
280 __uint32_t bvr[16];
281 __uint32_t bcr[16];
282 __uint32_t wvr[16];
283 __uint32_t wcr[16];
284 };
285 #endif /* __DARWIN_UNIX03 */
286
287 #elif defined(__arm64__)
288
289 /* ARM's arm_debug_state is ARM64's arm_legacy_debug_state */
290
291 #if __DARWIN_UNIX03
292 #define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state
293 _STRUCT_ARM_LEGACY_DEBUG_STATE
294 {
295 __uint32_t __bvr[16];
296 __uint32_t __bcr[16];
297 __uint32_t __wvr[16];
298 __uint32_t __wcr[16];
299 };
300 #else /* __DARWIN_UNIX03 */
301 #define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state
302 _STRUCT_ARM_LEGACY_DEBUG_STATE
303 {
304 __uint32_t bvr[16];
305 __uint32_t bcr[16];
306 __uint32_t wvr[16];
307 __uint32_t wcr[16];
308 };
309 #endif /* __DARWIN_UNIX03 */
310 #else
311 #error unknown architecture
312 #endif
313
314 #if __DARWIN_UNIX03
315 #define _STRUCT_ARM_DEBUG_STATE32 struct __darwin_arm_debug_state32
316 _STRUCT_ARM_DEBUG_STATE32
317 {
318 __uint32_t __bvr[16];
319 __uint32_t __bcr[16];
320 __uint32_t __wvr[16];
321 __uint32_t __wcr[16];
322 __uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
323 };
324
325 #define _STRUCT_ARM_DEBUG_STATE64 struct __darwin_arm_debug_state64
326 _STRUCT_ARM_DEBUG_STATE64
327 {
328 __uint64_t __bvr[16];
329 __uint64_t __bcr[16];
330 __uint64_t __wvr[16];
331 __uint64_t __wcr[16];
332 __uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
333 };
334 #else /* !__DARWIN_UNIX03 */
335 #define _STRUCT_ARM_DEBUG_STATE32 struct arm_debug_state32
336 _STRUCT_ARM_DEBUG_STATE32
337 {
338 __uint32_t bvr[16];
339 __uint32_t bcr[16];
340 __uint32_t wvr[16];
341 __uint32_t wcr[16];
342 __uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
343 };
344
345 #define _STRUCT_ARM_DEBUG_STATE64 struct arm_debug_state64
346 _STRUCT_ARM_DEBUG_STATE64
347 {
348 __uint64_t bvr[16];
349 __uint64_t bcr[16];
350 __uint64_t wvr[16];
351 __uint64_t wcr[16];
352 __uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
353 };
354 #endif /* __DARWIN_UNIX03 */
355
356 #if __DARWIN_UNIX03
357 #define _STRUCT_ARM_CPMU_STATE64 struct __darwin_arm_cpmu_state64
358 _STRUCT_ARM_CPMU_STATE64
359 {
360 __uint64_t __ctrs[16];
361 };
362 #else /* __DARWIN_UNIX03 */
363 #define _STRUCT_ARM_CPMU_STATE64 struct arm_cpmu_state64
364 _STRUCT_ARM_CPMU_STATE64
365 {
366 __uint64_t ctrs[16];
367 };
368 #endif /* !__DARWIN_UNIX03 */
369
370 #endif /* _MACH_ARM__STRUCTS_H_ */