2 * Copyright (c) 2004-2007 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
31 #ifndef _MACH_ARM__STRUCTS_H_
32 #define _MACH_ARM__STRUCTS_H_
34 #include <sys/cdefs.h> /* __DARWIN_UNIX03 */
35 #include <machine/types.h> /* __uint32_t */
38 #define _STRUCT_ARM_EXCEPTION_STATE struct __darwin_arm_exception_state
39 _STRUCT_ARM_EXCEPTION_STATE
41 __uint32_t __exception
; /* number of arm exception taken */
42 __uint32_t __fsr
; /* Fault status */
43 __uint32_t __far
; /* Virtual Fault Address */
45 #else /* !__DARWIN_UNIX03 */
46 #define _STRUCT_ARM_EXCEPTION_STATE struct arm_exception_state
47 _STRUCT_ARM_EXCEPTION_STATE
49 __uint32_t exception
; /* number of arm exception taken */
50 __uint32_t fsr
; /* Fault status */
51 __uint32_t far
; /* Virtual Fault Address */
53 #endif /* __DARWIN_UNIX03 */
56 #define _STRUCT_ARM_EXCEPTION_STATE64 struct __darwin_arm_exception_state64
57 _STRUCT_ARM_EXCEPTION_STATE64
59 __uint64_t __far
; /* Virtual Fault Address */
60 __uint32_t __esr
; /* Exception syndrome */
61 __uint32_t __exception
; /* number of arm exception taken */
63 #else /* !__DARWIN_UNIX03 */
64 #define _STRUCT_ARM_EXCEPTION_STATE64 struct arm_exception_state64
65 _STRUCT_ARM_EXCEPTION_STATE64
67 __uint64_t far
; /* Virtual Fault Address */
68 __uint32_t esr
; /* Exception syndrome */
69 __uint32_t exception
; /* number of arm exception taken */
71 #endif /* __DARWIN_UNIX03 */
74 #define _STRUCT_ARM_THREAD_STATE struct __darwin_arm_thread_state
75 _STRUCT_ARM_THREAD_STATE
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 */
83 #else /* !__DARWIN_UNIX03 */
84 #define _STRUCT_ARM_THREAD_STATE struct arm_thread_state
85 _STRUCT_ARM_THREAD_STATE
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 */
93 #endif /* __DARWIN_UNIX03 */
96 #define _STRUCT_ARM_THREAD_STATE64 struct __darwin_arm_thread_state64
97 _STRUCT_ARM_THREAD_STATE64
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 */
107 #else /* !__DARWIN_UNIX03 */
108 #define _STRUCT_ARM_THREAD_STATE64 struct arm_thread_state64
109 _STRUCT_ARM_THREAD_STATE64
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 */
119 #endif /* __DARWIN_UNIX03 */
121 #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__)
123 #define __darwin_arm_thread_state64_get_pc(ts) \
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) \
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) \
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) \
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) \
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) \
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) \
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) \
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) */
169 #define _STRUCT_ARM_VFP_STATE struct __darwin_arm_vfp_state
170 _STRUCT_ARM_VFP_STATE
175 #else /* !__DARWIN_UNIX03 */
176 #define _STRUCT_ARM_VFP_STATE struct arm_vfp_state
177 _STRUCT_ARM_VFP_STATE
182 #endif /* __DARWIN_UNIX03 */
185 #define _STRUCT_ARM_NEON_STATE64 struct __darwin_arm_neon_state64
186 #define _STRUCT_ARM_NEON_STATE struct __darwin_arm_neon_state
188 #if defined(__arm64__)
189 _STRUCT_ARM_NEON_STATE64
196 _STRUCT_ARM_NEON_STATE
203 #elif defined(__arm__)
205 * No 128-bit intrinsic for ARM; leave it opaque for now.
207 _STRUCT_ARM_NEON_STATE64
209 char opaque
[(32 * 16) + (2 * sizeof(__uint32_t
))];
210 } __attribute__((aligned(16)));
212 _STRUCT_ARM_NEON_STATE
214 char opaque
[(16 * 16) + (2 * sizeof(__uint32_t
))];
215 } __attribute__((aligned(16)));
218 #error Unknown architecture.
221 #else /* !__DARWIN_UNIX03 */
222 #define _STRUCT_ARM_NEON_STATE64 struct arm_neon_state64
223 #define _STRUCT_ARM_NEON_STATE struct arm_neon_state
225 #if defined(__arm64__)
226 _STRUCT_ARM_NEON_STATE64
232 _STRUCT_ARM_NEON_STATE
238 #elif defined(__arm__)
240 * No 128-bit intrinsic for ARM; leave it opaque for now.
242 _STRUCT_ARM_NEON_STATE64
244 char opaque
[(32 * 16) + (2 * sizeof(__uint32_t
))];
245 } __attribute__((aligned(16)));
247 _STRUCT_ARM_NEON_STATE
249 char opaque
[(16 * 16) + (2 * sizeof(__uint32_t
))];
250 } __attribute__((aligned(16)));
253 #error Unknown architecture.
256 #endif /* __DARWIN_UNIX03 */
262 /* Old-fashioned debug state is only for ARM */
265 #define _STRUCT_ARM_DEBUG_STATE struct __darwin_arm_debug_state
266 _STRUCT_ARM_DEBUG_STATE
268 __uint32_t __bvr
[16];
269 __uint32_t __bcr
[16];
270 __uint32_t __wvr
[16];
271 __uint32_t __wcr
[16];
273 #else /* !__DARWIN_UNIX03 */
274 #define _STRUCT_ARM_DEBUG_STATE struct arm_debug_state
275 _STRUCT_ARM_DEBUG_STATE
282 #endif /* __DARWIN_UNIX03 */
284 #elif defined(__arm64__)
286 /* ARM's arm_debug_state is ARM64's arm_legacy_debug_state */
289 #define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state
290 _STRUCT_ARM_LEGACY_DEBUG_STATE
292 __uint32_t __bvr
[16];
293 __uint32_t __bcr
[16];
294 __uint32_t __wvr
[16];
295 __uint32_t __wcr
[16];
297 #else /* __DARWIN_UNIX03 */
298 #define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state
299 _STRUCT_ARM_LEGACY_DEBUG_STATE
306 #endif /* __DARWIN_UNIX03 */
308 #error unknown architecture
312 #define _STRUCT_ARM_DEBUG_STATE32 struct __darwin_arm_debug_state32
313 _STRUCT_ARM_DEBUG_STATE32
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) */
322 #define _STRUCT_ARM_DEBUG_STATE64 struct __darwin_arm_debug_state64
323 _STRUCT_ARM_DEBUG_STATE64
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) */
331 #else /* !__DARWIN_UNIX03 */
332 #define _STRUCT_ARM_DEBUG_STATE32 struct arm_debug_state32
333 _STRUCT_ARM_DEBUG_STATE32
339 __uint64_t mdscr_el1
; /* Bit 0 is SS (Hardware Single Step) */
342 #define _STRUCT_ARM_DEBUG_STATE64 struct arm_debug_state64
343 _STRUCT_ARM_DEBUG_STATE64
349 __uint64_t mdscr_el1
; /* Bit 0 is SS (Hardware Single Step) */
351 #endif /* __DARWIN_UNIX03 */
354 #define _STRUCT_ARM_CPMU_STATE64 struct __darwin_arm_cpmu_state64
355 _STRUCT_ARM_CPMU_STATE64
357 __uint64_t __ctrs
[16];
359 #else /* __DARWIN_UNIX03 */
360 #define _STRUCT_ARM_CPMU_STATE64 struct arm_cpmu_state64
361 _STRUCT_ARM_CPMU_STATE64
365 #endif /* !__DARWIN_UNIX03 */
367 #endif /* _MACH_ARM__STRUCTS_H_ */