]>
Commit | Line | Data |
---|---|---|
5ba3f43e A |
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 | */ | |
0a7de745 A |
31 | #ifndef _MACH_ARM__STRUCTS_H_ |
32 | #define _MACH_ARM__STRUCTS_H_ | |
5ba3f43e A |
33 | |
34 | #include <sys/cdefs.h> /* __DARWIN_UNIX03 */ | |
35 | #include <machine/types.h> /* __uint32_t */ | |
36 | ||
37 | #if __DARWIN_UNIX03 | |
cb323159 | 38 | #define _STRUCT_ARM_EXCEPTION_STATE struct __darwin_arm_exception_state |
5ba3f43e A |
39 | _STRUCT_ARM_EXCEPTION_STATE |
40 | { | |
cb323159 A |
41 | __uint32_t __exception; /* number of arm exception taken */ |
42 | __uint32_t __fsr; /* Fault status */ | |
43 | __uint32_t __far; /* Virtual Fault Address */ | |
5ba3f43e A |
44 | }; |
45 | #else /* !__DARWIN_UNIX03 */ | |
cb323159 | 46 | #define _STRUCT_ARM_EXCEPTION_STATE struct arm_exception_state |
5ba3f43e A |
47 | _STRUCT_ARM_EXCEPTION_STATE |
48 | { | |
cb323159 A |
49 | __uint32_t exception; /* number of arm exception taken */ |
50 | __uint32_t fsr; /* Fault status */ | |
51 | __uint32_t far; /* Virtual Fault Address */ | |
5ba3f43e A |
52 | }; |
53 | #endif /* __DARWIN_UNIX03 */ | |
54 | ||
55 | #if __DARWIN_UNIX03 | |
cb323159 | 56 | #define _STRUCT_ARM_EXCEPTION_STATE64 struct __darwin_arm_exception_state64 |
5ba3f43e A |
57 | _STRUCT_ARM_EXCEPTION_STATE64 |
58 | { | |
cb323159 A |
59 | __uint64_t __far; /* Virtual Fault Address */ |
60 | __uint32_t __esr; /* Exception syndrome */ | |
61 | __uint32_t __exception; /* number of arm exception taken */ | |
5ba3f43e A |
62 | }; |
63 | #else /* !__DARWIN_UNIX03 */ | |
cb323159 | 64 | #define _STRUCT_ARM_EXCEPTION_STATE64 struct arm_exception_state64 |
5ba3f43e A |
65 | _STRUCT_ARM_EXCEPTION_STATE64 |
66 | { | |
cb323159 A |
67 | __uint64_t far; /* Virtual Fault Address */ |
68 | __uint32_t esr; /* Exception syndrome */ | |
69 | __uint32_t exception; /* number of arm exception taken */ | |
5ba3f43e A |
70 | }; |
71 | #endif /* __DARWIN_UNIX03 */ | |
72 | ||
73 | #if __DARWIN_UNIX03 | |
cb323159 | 74 | #define _STRUCT_ARM_THREAD_STATE struct __darwin_arm_thread_state |
5ba3f43e A |
75 | _STRUCT_ARM_THREAD_STATE |
76 | { | |
cb323159 A |
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 */ | |
5ba3f43e A |
82 | }; |
83 | #else /* !__DARWIN_UNIX03 */ | |
cb323159 | 84 | #define _STRUCT_ARM_THREAD_STATE struct arm_thread_state |
5ba3f43e A |
85 | _STRUCT_ARM_THREAD_STATE |
86 | { | |
cb323159 A |
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 */ | |
5ba3f43e A |
92 | }; |
93 | #endif /* __DARWIN_UNIX03 */ | |
94 | ||
cb323159 A |
95 | #if defined(KERNEL) |
96 | ||
97 | #define __DARWIN_OPAQUE_ARM_THREAD_STATE64 0 | |
98 | #define __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH 0x1 | |
99 | #define __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR 0x2 | |
100 | ||
0a7de745 | 101 | #define _STRUCT_ARM_THREAD_STATE64 struct arm_thread_state64 |
5ba3f43e A |
102 | _STRUCT_ARM_THREAD_STATE64 |
103 | { | |
0a7de745 A |
104 | __uint64_t x[29]; /* General purpose registers x0-x28 */ |
105 | __uint64_t fp; /* Frame pointer x29 */ | |
106 | __uint64_t lr; /* Link register x30 */ | |
107 | __uint64_t sp; /* Stack pointer x31 */ | |
108 | __uint64_t pc; /* Program counter */ | |
109 | __uint32_t cpsr; /* Current program status register */ | |
cb323159 | 110 | __uint32_t flags; /* Flags describing structure format */ |
5ba3f43e | 111 | }; |
cb323159 A |
112 | |
113 | #else /* defined(KERNEL) */ | |
114 | ||
115 | /* | |
116 | * By default, the pointer fields in the arm_thread_state64_t structure are | |
117 | * opaque on the arm64e architecture and require the use of accessor macros. | |
118 | * This mode can also be enabled on the arm64 architecture by building with | |
119 | * -D__DARWIN_OPAQUE_ARM_THREAD_STATE64=1. | |
120 | */ | |
121 | #if defined(__arm64__) && defined(__LP64__) | |
122 | ||
123 | #if __has_feature(ptrauth_calls) | |
124 | #define __DARWIN_OPAQUE_ARM_THREAD_STATE64 1 | |
125 | #define __DARWIN_PTRAUTH_ARM_THREAD_STATE64 1 | |
126 | #endif /* __has_feature(ptrauth_calls) */ | |
127 | ||
128 | #ifndef __DARWIN_OPAQUE_ARM_THREAD_STATE64 | |
129 | #define __DARWIN_OPAQUE_ARM_THREAD_STATE64 0 | |
130 | #endif | |
131 | ||
132 | #else /* defined(__arm64__) && defined(__LP64__) */ | |
133 | ||
134 | #undef __DARWIN_OPAQUE_ARM_THREAD_STATE64 | |
135 | #define __DARWIN_OPAQUE_ARM_THREAD_STATE64 0 | |
136 | ||
137 | #endif /* defined(__arm64__) && defined(__LP64__) */ | |
138 | ||
139 | #if __DARWIN_UNIX03 | |
140 | #define _STRUCT_ARM_THREAD_STATE64 struct __darwin_arm_thread_state64 | |
141 | #if __DARWIN_OPAQUE_ARM_THREAD_STATE64 | |
142 | _STRUCT_ARM_THREAD_STATE64 | |
143 | { | |
144 | __uint64_t __x[29]; /* General purpose registers x0-x28 */ | |
145 | void* __opaque_fp; /* Frame pointer x29 */ | |
146 | void* __opaque_lr; /* Link register x30 */ | |
147 | void* __opaque_sp; /* Stack pointer x31 */ | |
148 | void* __opaque_pc; /* Program counter */ | |
149 | __uint32_t __cpsr; /* Current program status register */ | |
150 | __uint32_t __opaque_flags; /* Flags describing structure format */ | |
151 | }; | |
152 | #else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ | |
153 | _STRUCT_ARM_THREAD_STATE64 | |
154 | { | |
155 | __uint64_t __x[29]; /* General purpose registers x0-x28 */ | |
156 | __uint64_t __fp; /* Frame pointer x29 */ | |
157 | __uint64_t __lr; /* Link register x30 */ | |
158 | __uint64_t __sp; /* Stack pointer x31 */ | |
159 | __uint64_t __pc; /* Program counter */ | |
160 | __uint32_t __cpsr; /* Current program status register */ | |
161 | __uint32_t __pad; /* Same size for 32-bit or 64-bit clients */ | |
162 | }; | |
163 | #endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ | |
164 | #else /* !__DARWIN_UNIX03 */ | |
165 | #define _STRUCT_ARM_THREAD_STATE64 struct arm_thread_state64 | |
166 | #if __DARWIN_OPAQUE_ARM_THREAD_STATE64 | |
167 | _STRUCT_ARM_THREAD_STATE64 | |
168 | { | |
169 | __uint64_t x[29]; /* General purpose registers x0-x28 */ | |
170 | void* __opaque_fp; /* Frame pointer x29 */ | |
171 | void* __opaque_lr; /* Link register x30 */ | |
172 | void* __opaque_sp; /* Stack pointer x31 */ | |
173 | void* __opaque_pc; /* Program counter */ | |
174 | __uint32_t cpsr; /* Current program status register */ | |
175 | __uint32_t __opaque_flags; /* Flags describing structure format */ | |
176 | }; | |
177 | #else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ | |
178 | _STRUCT_ARM_THREAD_STATE64 | |
179 | { | |
180 | __uint64_t x[29]; /* General purpose registers x0-x28 */ | |
181 | __uint64_t fp; /* Frame pointer x29 */ | |
182 | __uint64_t lr; /* Link register x30 */ | |
183 | __uint64_t sp; /* Stack pointer x31 */ | |
184 | __uint64_t pc; /* Program counter */ | |
185 | __uint32_t cpsr; /* Current program status register */ | |
186 | __uint32_t __pad; /* Same size for 32-bit or 64-bit clients */ | |
187 | }; | |
188 | #endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ | |
5ba3f43e | 189 | #endif /* __DARWIN_UNIX03 */ |
cb323159 | 190 | |
d9a64523 | 191 | #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__) |
cb323159 A |
192 | |
193 | /* Accessor macros for arm_thread_state64_t pointer fields */ | |
194 | ||
195 | #if __has_feature(ptrauth_calls) && defined(__LP64__) | |
196 | #include <ptrauth.h> | |
197 | ||
198 | #if !__DARWIN_OPAQUE_ARM_THREAD_STATE64 || !__DARWIN_PTRAUTH_ARM_THREAD_STATE64 | |
199 | #error "Invalid configuration" | |
200 | #endif | |
201 | ||
202 | #define __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH 0x1 | |
203 | #define __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR 0x2 | |
204 | ||
205 | /* Return pc field of arm_thread_state64_t as a data pointer value */ | |
206 | #define __darwin_arm_thread_state64_get_pc(ts) \ | |
207 | __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ | |
208 | (uintptr_t)(__tsp->__opaque_pc && !(__tsp->__opaque_flags & \ | |
209 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ | |
210 | ptrauth_auth_data(__tsp->__opaque_pc, \ | |
211 | ptrauth_key_process_independent_code, \ | |
212 | ptrauth_string_discriminator("pc")) : __tsp->__opaque_pc); }) | |
213 | /* Return pc field of arm_thread_state64_t as a function pointer. May return | |
214 | * NULL if a valid function pointer cannot be constructed, the caller should | |
215 | * fall back to the __darwin_arm_thread_state64_get_pc() macro in that case. */ | |
216 | #define __darwin_arm_thread_state64_get_pc_fptr(ts) \ | |
217 | __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ | |
218 | (__tsp->__opaque_pc && !(__tsp->__opaque_flags & \ | |
219 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ | |
220 | ptrauth_auth_function(__tsp->__opaque_pc, \ | |
221 | ptrauth_key_process_independent_code, \ | |
222 | ptrauth_string_discriminator("pc")) : NULL); }) | |
223 | /* Set pc field of arm_thread_state64_t to a function pointer */ | |
224 | #define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \ | |
225 | __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ | |
226 | __typeof__(fptr) __f = (fptr); __tsp->__opaque_pc = \ | |
227 | (__f ? (!(__tsp->__opaque_flags & \ | |
228 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ | |
229 | ptrauth_auth_and_resign(__f, ptrauth_key_function_pointer, 0, \ | |
230 | ptrauth_key_process_independent_code, \ | |
231 | ptrauth_string_discriminator("pc")) : ptrauth_auth_data(__f, \ | |
232 | ptrauth_key_function_pointer, 0)) : __f); }) | |
233 | /* Return lr field of arm_thread_state64_t as a data pointer value */ | |
234 | #define __darwin_arm_thread_state64_get_lr(ts) \ | |
235 | __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ | |
236 | (uintptr_t)(__tsp->__opaque_lr && !(__tsp->__opaque_flags & ( \ | |
237 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \ | |
238 | __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? \ | |
239 | ptrauth_auth_data(__tsp->__opaque_lr, \ | |
240 | ptrauth_key_process_independent_code, \ | |
241 | ptrauth_string_discriminator("lr")) : __tsp->__opaque_lr); }) | |
242 | /* Return lr field of arm_thread_state64_t as a function pointer. May return | |
243 | * NULL if a valid function pointer cannot be constructed, the caller should | |
244 | * fall back to the __darwin_arm_thread_state64_get_lr() macro in that case. */ | |
245 | #define __darwin_arm_thread_state64_get_lr_fptr(ts) \ | |
246 | __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ | |
247 | (__tsp->__opaque_lr && !(__tsp->__opaque_flags & ( \ | |
248 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \ | |
249 | __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? \ | |
250 | ptrauth_auth_function(__tsp->__opaque_lr, \ | |
251 | ptrauth_key_process_independent_code, \ | |
252 | ptrauth_string_discriminator("lr")) : NULL); }) | |
253 | /* Set lr field of arm_thread_state64_t to a function pointer */ | |
254 | #define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \ | |
255 | __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ | |
256 | __typeof__(fptr) __f = (fptr); __tsp->__opaque_lr = \ | |
257 | (__f ? (!(__tsp->__opaque_flags & \ | |
258 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? (__tsp->__opaque_flags \ | |
259 | &= ~__DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR , \ | |
260 | ptrauth_auth_and_resign(__f, ptrauth_key_function_pointer, 0, \ | |
261 | ptrauth_key_process_independent_code, \ | |
262 | ptrauth_string_discriminator("lr"))) : ptrauth_auth_data(__f, \ | |
263 | ptrauth_key_function_pointer, 0)) : __f); }) | |
264 | /* Return sp field of arm_thread_state64_t as a data pointer value */ | |
265 | #define __darwin_arm_thread_state64_get_sp(ts) \ | |
266 | __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ | |
267 | (uintptr_t)(__tsp->__opaque_sp && !(__tsp->__opaque_flags & \ | |
268 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ | |
269 | ptrauth_auth_data(__tsp->__opaque_sp, \ | |
270 | ptrauth_key_process_independent_data, \ | |
271 | ptrauth_string_discriminator("sp")) : __tsp->__opaque_sp); }) | |
272 | /* Set sp field of arm_thread_state64_t to a data pointer value */ | |
273 | #define __darwin_arm_thread_state64_set_sp(ts, ptr) \ | |
274 | __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ | |
275 | void *__p = (void*)(uintptr_t)(ptr); __tsp->__opaque_sp = \ | |
276 | (__p && !(__tsp->__opaque_flags & \ | |
277 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ | |
278 | ptrauth_sign_unauthenticated(__p, \ | |
279 | ptrauth_key_process_independent_data, \ | |
280 | ptrauth_string_discriminator("sp")) : __p); }) | |
281 | /* Return fp field of arm_thread_state64_t as a data pointer value */ | |
282 | #define __darwin_arm_thread_state64_get_fp(ts) \ | |
283 | __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ | |
284 | (uintptr_t)(__tsp->__opaque_fp && !(__tsp->__opaque_flags & \ | |
285 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ | |
286 | ptrauth_auth_data(__tsp->__opaque_fp, \ | |
287 | ptrauth_key_process_independent_data, \ | |
288 | ptrauth_string_discriminator("fp")) : __tsp->__opaque_fp); }) | |
289 | /* Set fp field of arm_thread_state64_t to a data pointer value */ | |
290 | #define __darwin_arm_thread_state64_set_fp(ts, ptr) \ | |
291 | __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ | |
292 | void *__p = (void*)(uintptr_t)(ptr); __tsp->__opaque_fp = \ | |
293 | (__p && !(__tsp->__opaque_flags & \ | |
294 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ | |
295 | ptrauth_sign_unauthenticated(__p, \ | |
296 | ptrauth_key_process_independent_data, \ | |
297 | ptrauth_string_discriminator("fp")) : __p); }) | |
298 | ||
299 | #else /* __has_feature(ptrauth_calls) && defined(__LP64__) */ | |
300 | ||
301 | #if __DARWIN_OPAQUE_ARM_THREAD_STATE64 | |
302 | ||
303 | #ifndef __LP64__ | |
304 | #error "Invalid configuration" | |
305 | #endif | |
306 | ||
307 | /* Return pc field of arm_thread_state64_t as a data pointer value */ | |
308 | #define __darwin_arm_thread_state64_get_pc(ts) \ | |
309 | ((uintptr_t)((ts).__opaque_pc)) | |
310 | /* Return pc field of arm_thread_state64_t as a function pointer */ | |
311 | #define __darwin_arm_thread_state64_get_pc_fptr(ts) \ | |
312 | ((ts).__opaque_pc) | |
313 | /* Set pc field of arm_thread_state64_t to a function pointer */ | |
314 | #define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \ | |
315 | ((ts).__opaque_pc = (fptr)) | |
316 | /* Return lr field of arm_thread_state64_t as a data pointer value */ | |
317 | #define __darwin_arm_thread_state64_get_lr(ts) \ | |
318 | ((uintptr_t)((ts).__opaque_lr)) | |
319 | /* Return lr field of arm_thread_state64_t as a function pointer */ | |
320 | #define __darwin_arm_thread_state64_get_lr_fptr(ts) \ | |
321 | ((ts).__opaque_lr) | |
322 | /* Set lr field of arm_thread_state64_t to a function pointer */ | |
323 | #define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \ | |
324 | ((ts).__opaque_lr = (fptr)) | |
325 | /* Return sp field of arm_thread_state64_t as a data pointer value */ | |
326 | #define __darwin_arm_thread_state64_get_sp(ts) \ | |
327 | ((uintptr_t)((ts).__opaque_sp)) | |
328 | /* Set sp field of arm_thread_state64_t to a data pointer value */ | |
329 | #define __darwin_arm_thread_state64_set_sp(ts, ptr) \ | |
330 | ((ts).__opaque_sp = (void*)(uintptr_t)(ptr)) | |
331 | /* Return fp field of arm_thread_state64_t as a data pointer value */ | |
332 | #define __darwin_arm_thread_state64_get_fp(ts) \ | |
333 | ((uintptr_t)((ts).__opaque_fp)) | |
334 | /* Set fp field of arm_thread_state64_t to a data pointer value */ | |
335 | #define __darwin_arm_thread_state64_set_fp(ts, ptr) \ | |
336 | ((ts).__opaque_fp = (void*)(uintptr_t)(ptr)) | |
337 | ||
338 | #else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ | |
d9a64523 | 339 | #if __DARWIN_UNIX03 |
cb323159 A |
340 | |
341 | /* Return pc field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 342 | #define __darwin_arm_thread_state64_get_pc(ts) \ |
cb323159 A |
343 | ((ts).__pc) |
344 | /* Return pc field of arm_thread_state64_t as a function pointer */ | |
d9a64523 | 345 | #define __darwin_arm_thread_state64_get_pc_fptr(ts) \ |
cb323159 A |
346 | ((void*)(uintptr_t)((ts).__pc)) |
347 | /* Set pc field of arm_thread_state64_t to a function pointer */ | |
d9a64523 | 348 | #define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \ |
cb323159 A |
349 | ((ts).__pc = (uintptr_t)(fptr)) |
350 | /* Return lr field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 351 | #define __darwin_arm_thread_state64_get_lr(ts) \ |
cb323159 A |
352 | ((ts).__lr) |
353 | /* Return lr field of arm_thread_state64_t as a function pointer */ | |
d9a64523 | 354 | #define __darwin_arm_thread_state64_get_lr_fptr(ts) \ |
cb323159 A |
355 | ((void*)(uintptr_t)((ts).__lr)) |
356 | /* Set lr field of arm_thread_state64_t to a function pointer */ | |
d9a64523 | 357 | #define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \ |
cb323159 A |
358 | ((ts).__lr = (uintptr_t)(fptr)) |
359 | /* Return sp field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 360 | #define __darwin_arm_thread_state64_get_sp(ts) \ |
cb323159 A |
361 | ((ts).__sp) |
362 | /* Set sp field of arm_thread_state64_t to a data pointer value */ | |
d9a64523 | 363 | #define __darwin_arm_thread_state64_set_sp(ts, ptr) \ |
cb323159 A |
364 | ((ts).__sp = (uintptr_t)(ptr)) |
365 | /* Return fp field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 366 | #define __darwin_arm_thread_state64_get_fp(ts) \ |
cb323159 A |
367 | ((ts).__fp) |
368 | /* Set fp field of arm_thread_state64_t to a data pointer value */ | |
d9a64523 | 369 | #define __darwin_arm_thread_state64_set_fp(ts, ptr) \ |
cb323159 A |
370 | ((ts).__fp = (uintptr_t)(ptr)) |
371 | ||
372 | #else /* __DARWIN_UNIX03 */ | |
373 | ||
374 | /* Return pc field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 375 | #define __darwin_arm_thread_state64_get_pc(ts) \ |
cb323159 A |
376 | ((ts).pc) |
377 | /* Return pc field of arm_thread_state64_t as a function pointer */ | |
d9a64523 | 378 | #define __darwin_arm_thread_state64_get_pc_fptr(ts) \ |
cb323159 A |
379 | ((void*)(uintptr_t)((ts).pc)) |
380 | /* Set pc field of arm_thread_state64_t to a function pointer */ | |
d9a64523 | 381 | #define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \ |
cb323159 A |
382 | ((ts).pc = (uintptr_t)(fptr)) |
383 | /* Return lr field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 384 | #define __darwin_arm_thread_state64_get_lr(ts) \ |
cb323159 A |
385 | ((ts).lr) |
386 | /* Return lr field of arm_thread_state64_t as a function pointer */ | |
d9a64523 | 387 | #define __darwin_arm_thread_state64_get_lr_fptr(ts) \ |
cb323159 A |
388 | ((void*)(uintptr_t)((ts).lr)) |
389 | /* Set lr field of arm_thread_state64_t to a function pointer */ | |
d9a64523 | 390 | #define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \ |
cb323159 A |
391 | ((ts).lr = (uintptr_t)(fptr)) |
392 | /* Return sp field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 393 | #define __darwin_arm_thread_state64_get_sp(ts) \ |
cb323159 A |
394 | ((ts).sp) |
395 | /* Set sp field of arm_thread_state64_t to a data pointer value */ | |
d9a64523 | 396 | #define __darwin_arm_thread_state64_set_sp(ts, ptr) \ |
cb323159 A |
397 | ((ts).sp = (uintptr_t)(ptr)) |
398 | /* Return fp field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 399 | #define __darwin_arm_thread_state64_get_fp(ts) \ |
cb323159 A |
400 | ((ts).fp) |
401 | /* Set fp field of arm_thread_state64_t to a data pointer value */ | |
d9a64523 | 402 | #define __darwin_arm_thread_state64_set_fp(ts, ptr) \ |
cb323159 A |
403 | ((ts).fp = (uintptr_t)(ptr)) |
404 | ||
d9a64523 | 405 | #endif /* __DARWIN_UNIX03 */ |
cb323159 A |
406 | #endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ |
407 | ||
408 | #endif /* __has_feature(ptrauth_calls) && defined(__LP64__) */ | |
d9a64523 A |
409 | #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__) */ |
410 | #endif /* !defined(KERNEL) */ | |
5ba3f43e A |
411 | |
412 | #if __DARWIN_UNIX03 | |
cb323159 | 413 | #define _STRUCT_ARM_VFP_STATE struct __darwin_arm_vfp_state |
5ba3f43e A |
414 | _STRUCT_ARM_VFP_STATE |
415 | { | |
cb323159 A |
416 | __uint32_t __r[64]; |
417 | __uint32_t __fpscr; | |
5ba3f43e A |
418 | }; |
419 | #else /* !__DARWIN_UNIX03 */ | |
cb323159 | 420 | #define _STRUCT_ARM_VFP_STATE struct arm_vfp_state |
5ba3f43e A |
421 | _STRUCT_ARM_VFP_STATE |
422 | { | |
cb323159 A |
423 | __uint32_t r[64]; |
424 | __uint32_t fpscr; | |
5ba3f43e A |
425 | }; |
426 | #endif /* __DARWIN_UNIX03 */ | |
427 | ||
428 | #if __DARWIN_UNIX03 | |
cb323159 A |
429 | #define _STRUCT_ARM_NEON_STATE64 struct __darwin_arm_neon_state64 |
430 | #define _STRUCT_ARM_NEON_STATE struct __darwin_arm_neon_state | |
5ba3f43e A |
431 | |
432 | #if defined(__arm64__) | |
433 | _STRUCT_ARM_NEON_STATE64 | |
434 | { | |
cb323159 A |
435 | __uint128_t __v[32]; |
436 | __uint32_t __fpsr; | |
437 | __uint32_t __fpcr; | |
5ba3f43e A |
438 | }; |
439 | ||
440 | _STRUCT_ARM_NEON_STATE | |
441 | { | |
cb323159 A |
442 | __uint128_t __v[16]; |
443 | __uint32_t __fpsr; | |
444 | __uint32_t __fpcr; | |
5ba3f43e | 445 | }; |
5ba3f43e A |
446 | #elif defined(__arm__) |
447 | /* | |
448 | * No 128-bit intrinsic for ARM; leave it opaque for now. | |
449 | */ | |
450 | _STRUCT_ARM_NEON_STATE64 | |
451 | { | |
452 | char opaque[(32 * 16) + (2 * sizeof(__uint32_t))]; | |
453 | } __attribute__((aligned(16))); | |
454 | ||
455 | _STRUCT_ARM_NEON_STATE | |
456 | { | |
457 | char opaque[(16 * 16) + (2 * sizeof(__uint32_t))]; | |
458 | } __attribute__((aligned(16))); | |
459 | ||
460 | #else | |
461 | #error Unknown architecture. | |
462 | #endif | |
463 | ||
464 | #else /* !__DARWIN_UNIX03 */ | |
465 | #define _STRUCT_ARM_NEON_STATE64 struct arm_neon_state64 | |
466 | #define _STRUCT_ARM_NEON_STATE struct arm_neon_state | |
467 | ||
468 | #if defined(__arm64__) | |
469 | _STRUCT_ARM_NEON_STATE64 | |
470 | { | |
cb323159 A |
471 | __uint128_t q[32]; |
472 | uint32_t fpsr; | |
473 | uint32_t fpcr; | |
5ba3f43e | 474 | }; |
cb323159 | 475 | |
5ba3f43e A |
476 | _STRUCT_ARM_NEON_STATE |
477 | { | |
cb323159 A |
478 | __uint128_t q[16]; |
479 | uint32_t fpsr; | |
480 | uint32_t fpcr; | |
5ba3f43e A |
481 | }; |
482 | #elif defined(__arm__) | |
483 | /* | |
484 | * No 128-bit intrinsic for ARM; leave it opaque for now. | |
485 | */ | |
486 | _STRUCT_ARM_NEON_STATE64 | |
487 | { | |
488 | char opaque[(32 * 16) + (2 * sizeof(__uint32_t))]; | |
489 | } __attribute__((aligned(16))); | |
490 | ||
491 | _STRUCT_ARM_NEON_STATE | |
492 | { | |
493 | char opaque[(16 * 16) + (2 * sizeof(__uint32_t))]; | |
494 | } __attribute__((aligned(16))); | |
495 | ||
496 | #else | |
497 | #error Unknown architecture. | |
498 | #endif | |
499 | ||
500 | #endif /* __DARWIN_UNIX03 */ | |
501 | ||
cb323159 A |
502 | |
503 | #define _STRUCT_ARM_PAGEIN_STATE struct __arm_pagein_state | |
504 | _STRUCT_ARM_PAGEIN_STATE | |
505 | { | |
506 | int __pagein_error; | |
507 | }; | |
508 | ||
5ba3f43e A |
509 | /* |
510 | * Debug State | |
511 | */ | |
512 | #if defined(__arm__) | |
513 | /* Old-fashioned debug state is only for ARM */ | |
514 | ||
515 | #if __DARWIN_UNIX03 | |
0a7de745 | 516 | #define _STRUCT_ARM_DEBUG_STATE struct __darwin_arm_debug_state |
5ba3f43e A |
517 | _STRUCT_ARM_DEBUG_STATE |
518 | { | |
cb323159 A |
519 | __uint32_t __bvr[16]; |
520 | __uint32_t __bcr[16]; | |
521 | __uint32_t __wvr[16]; | |
522 | __uint32_t __wcr[16]; | |
5ba3f43e A |
523 | }; |
524 | #else /* !__DARWIN_UNIX03 */ | |
0a7de745 | 525 | #define _STRUCT_ARM_DEBUG_STATE struct arm_debug_state |
5ba3f43e A |
526 | _STRUCT_ARM_DEBUG_STATE |
527 | { | |
cb323159 A |
528 | __uint32_t bvr[16]; |
529 | __uint32_t bcr[16]; | |
530 | __uint32_t wvr[16]; | |
531 | __uint32_t wcr[16]; | |
5ba3f43e A |
532 | }; |
533 | #endif /* __DARWIN_UNIX03 */ | |
534 | ||
535 | #elif defined(__arm64__) | |
536 | ||
537 | /* ARM's arm_debug_state is ARM64's arm_legacy_debug_state */ | |
538 | ||
539 | #if __DARWIN_UNIX03 | |
cb323159 | 540 | #define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state |
5ba3f43e A |
541 | _STRUCT_ARM_LEGACY_DEBUG_STATE |
542 | { | |
cb323159 A |
543 | __uint32_t __bvr[16]; |
544 | __uint32_t __bcr[16]; | |
545 | __uint32_t __wvr[16]; | |
546 | __uint32_t __wcr[16]; | |
5ba3f43e A |
547 | }; |
548 | #else /* __DARWIN_UNIX03 */ | |
cb323159 | 549 | #define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state |
5ba3f43e A |
550 | _STRUCT_ARM_LEGACY_DEBUG_STATE |
551 | { | |
cb323159 A |
552 | __uint32_t bvr[16]; |
553 | __uint32_t bcr[16]; | |
554 | __uint32_t wvr[16]; | |
555 | __uint32_t wcr[16]; | |
5ba3f43e A |
556 | }; |
557 | #endif /* __DARWIN_UNIX03 */ | |
558 | #else | |
559 | #error unknown architecture | |
560 | #endif | |
561 | ||
562 | #if __DARWIN_UNIX03 | |
cb323159 | 563 | #define _STRUCT_ARM_DEBUG_STATE32 struct __darwin_arm_debug_state32 |
5ba3f43e A |
564 | _STRUCT_ARM_DEBUG_STATE32 |
565 | { | |
cb323159 A |
566 | __uint32_t __bvr[16]; |
567 | __uint32_t __bcr[16]; | |
568 | __uint32_t __wvr[16]; | |
569 | __uint32_t __wcr[16]; | |
570 | __uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */ | |
5ba3f43e A |
571 | }; |
572 | ||
cb323159 | 573 | #define _STRUCT_ARM_DEBUG_STATE64 struct __darwin_arm_debug_state64 |
5ba3f43e A |
574 | _STRUCT_ARM_DEBUG_STATE64 |
575 | { | |
cb323159 A |
576 | __uint64_t __bvr[16]; |
577 | __uint64_t __bcr[16]; | |
578 | __uint64_t __wvr[16]; | |
579 | __uint64_t __wcr[16]; | |
580 | __uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */ | |
5ba3f43e A |
581 | }; |
582 | #else /* !__DARWIN_UNIX03 */ | |
cb323159 | 583 | #define _STRUCT_ARM_DEBUG_STATE32 struct arm_debug_state32 |
5ba3f43e A |
584 | _STRUCT_ARM_DEBUG_STATE32 |
585 | { | |
cb323159 A |
586 | __uint32_t bvr[16]; |
587 | __uint32_t bcr[16]; | |
588 | __uint32_t wvr[16]; | |
589 | __uint32_t wcr[16]; | |
590 | __uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */ | |
5ba3f43e A |
591 | }; |
592 | ||
cb323159 | 593 | #define _STRUCT_ARM_DEBUG_STATE64 struct arm_debug_state64 |
5ba3f43e A |
594 | _STRUCT_ARM_DEBUG_STATE64 |
595 | { | |
cb323159 A |
596 | __uint64_t bvr[16]; |
597 | __uint64_t bcr[16]; | |
598 | __uint64_t wvr[16]; | |
599 | __uint64_t wcr[16]; | |
600 | __uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */ | |
5ba3f43e A |
601 | }; |
602 | #endif /* __DARWIN_UNIX03 */ | |
603 | ||
604 | #if __DARWIN_UNIX03 | |
cb323159 | 605 | #define _STRUCT_ARM_CPMU_STATE64 struct __darwin_arm_cpmu_state64 |
5ba3f43e A |
606 | _STRUCT_ARM_CPMU_STATE64 |
607 | { | |
608 | __uint64_t __ctrs[16]; | |
609 | }; | |
610 | #else /* __DARWIN_UNIX03 */ | |
cb323159 | 611 | #define _STRUCT_ARM_CPMU_STATE64 struct arm_cpmu_state64 |
5ba3f43e A |
612 | _STRUCT_ARM_CPMU_STATE64 |
613 | { | |
614 | __uint64_t ctrs[16]; | |
615 | }; | |
616 | #endif /* !__DARWIN_UNIX03 */ | |
617 | ||
618 | #endif /* _MACH_ARM__STRUCTS_H_ */ |