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
176 #else /* !__DARWIN_UNIX03 */
177 #define _STRUCT_ARM_VFP_STATE struct arm_vfp_state
178 _STRUCT_ARM_VFP_STATE
183 #endif /* __DARWIN_UNIX03 */
186 #define _STRUCT_ARM_NEON_STATE64 struct __darwin_arm_neon_state64
187 #define _STRUCT_ARM_NEON_STATE struct __darwin_arm_neon_state
189 #if defined(__arm64__)
190 _STRUCT_ARM_NEON_STATE64
197 _STRUCT_ARM_NEON_STATE
204 #elif defined(__arm__)
206 * No 128-bit intrinsic for ARM; leave it opaque for now.
208 _STRUCT_ARM_NEON_STATE64
210 char opaque
[(32 * 16) + (2 * sizeof(__uint32_t
))];
211 } __attribute__((aligned(16)));
213 _STRUCT_ARM_NEON_STATE
215 char opaque
[(16 * 16) + (2 * sizeof(__uint32_t
))];
216 } __attribute__((aligned(16)));
219 #error Unknown architecture.
222 #else /* !__DARWIN_UNIX03 */
223 #define _STRUCT_ARM_NEON_STATE64 struct arm_neon_state64
224 #define _STRUCT_ARM_NEON_STATE struct arm_neon_state
226 #if defined(__arm64__)
227 _STRUCT_ARM_NEON_STATE64
234 _STRUCT_ARM_NEON_STATE
241 #elif defined(__arm__)
243 * No 128-bit intrinsic for ARM; leave it opaque for now.
245 _STRUCT_ARM_NEON_STATE64
247 char opaque
[(32 * 16) + (2 * sizeof(__uint32_t
))];
248 } __attribute__((aligned(16)));
250 _STRUCT_ARM_NEON_STATE
252 char opaque
[(16 * 16) + (2 * sizeof(__uint32_t
))];
253 } __attribute__((aligned(16)));
256 #error Unknown architecture.
259 #endif /* __DARWIN_UNIX03 */
265 /* Old-fashioned debug state is only for ARM */
268 #define _STRUCT_ARM_DEBUG_STATE struct __darwin_arm_debug_state
269 _STRUCT_ARM_DEBUG_STATE
271 __uint32_t __bvr
[16];
272 __uint32_t __bcr
[16];
273 __uint32_t __wvr
[16];
274 __uint32_t __wcr
[16];
276 #else /* !__DARWIN_UNIX03 */
277 #define _STRUCT_ARM_DEBUG_STATE struct arm_debug_state
278 _STRUCT_ARM_DEBUG_STATE
285 #endif /* __DARWIN_UNIX03 */
287 #elif defined(__arm64__)
289 /* ARM's arm_debug_state is ARM64's arm_legacy_debug_state */
292 #define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state
293 _STRUCT_ARM_LEGACY_DEBUG_STATE
295 __uint32_t __bvr
[16];
296 __uint32_t __bcr
[16];
297 __uint32_t __wvr
[16];
298 __uint32_t __wcr
[16];
300 #else /* __DARWIN_UNIX03 */
301 #define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state
302 _STRUCT_ARM_LEGACY_DEBUG_STATE
309 #endif /* __DARWIN_UNIX03 */
311 #error unknown architecture
315 #define _STRUCT_ARM_DEBUG_STATE32 struct __darwin_arm_debug_state32
316 _STRUCT_ARM_DEBUG_STATE32
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) */
325 #define _STRUCT_ARM_DEBUG_STATE64 struct __darwin_arm_debug_state64
326 _STRUCT_ARM_DEBUG_STATE64
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) */
334 #else /* !__DARWIN_UNIX03 */
335 #define _STRUCT_ARM_DEBUG_STATE32 struct arm_debug_state32
336 _STRUCT_ARM_DEBUG_STATE32
342 __uint64_t mdscr_el1
; /* Bit 0 is SS (Hardware Single Step) */
345 #define _STRUCT_ARM_DEBUG_STATE64 struct arm_debug_state64
346 _STRUCT_ARM_DEBUG_STATE64
352 __uint64_t mdscr_el1
; /* Bit 0 is SS (Hardware Single Step) */
354 #endif /* __DARWIN_UNIX03 */
357 #define _STRUCT_ARM_CPMU_STATE64 struct __darwin_arm_cpmu_state64
358 _STRUCT_ARM_CPMU_STATE64
360 __uint64_t __ctrs
[16];
362 #else /* __DARWIN_UNIX03 */
363 #define _STRUCT_ARM_CPMU_STATE64 struct arm_cpmu_state64
364 _STRUCT_ARM_CPMU_STATE64
368 #endif /* !__DARWIN_UNIX03 */
370 #endif /* _MACH_ARM__STRUCTS_H_ */