]>
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 | ||
f427ee49 A |
299 | /* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */ |
300 | #define __darwin_arm_thread_state64_ptrauth_strip(ts) \ | |
301 | __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ | |
302 | __tsp->__opaque_pc = ((__tsp->__opaque_flags & \ | |
303 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_pc : \ | |
304 | ptrauth_strip(__tsp->__opaque_pc, ptrauth_key_process_independent_code)); \ | |
305 | __tsp->__opaque_lr = ((__tsp->__opaque_flags & \ | |
306 | (__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \ | |
307 | __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? __tsp->__opaque_lr : \ | |
308 | ptrauth_strip(__tsp->__opaque_lr, ptrauth_key_process_independent_code)); \ | |
309 | __tsp->__opaque_sp = ((__tsp->__opaque_flags & \ | |
310 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_sp : \ | |
311 | ptrauth_strip(__tsp->__opaque_sp, ptrauth_key_process_independent_data)); \ | |
312 | __tsp->__opaque_fp = ((__tsp->__opaque_flags & \ | |
313 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_fp : \ | |
314 | ptrauth_strip(__tsp->__opaque_fp, ptrauth_key_process_independent_data)); \ | |
315 | __tsp->__opaque_flags |= \ | |
316 | __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH; }) | |
317 | ||
cb323159 A |
318 | #else /* __has_feature(ptrauth_calls) && defined(__LP64__) */ |
319 | ||
320 | #if __DARWIN_OPAQUE_ARM_THREAD_STATE64 | |
321 | ||
322 | #ifndef __LP64__ | |
323 | #error "Invalid configuration" | |
324 | #endif | |
325 | ||
326 | /* Return pc field of arm_thread_state64_t as a data pointer value */ | |
327 | #define __darwin_arm_thread_state64_get_pc(ts) \ | |
328 | ((uintptr_t)((ts).__opaque_pc)) | |
329 | /* Return pc field of arm_thread_state64_t as a function pointer */ | |
330 | #define __darwin_arm_thread_state64_get_pc_fptr(ts) \ | |
331 | ((ts).__opaque_pc) | |
332 | /* Set pc field of arm_thread_state64_t to a function pointer */ | |
333 | #define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \ | |
334 | ((ts).__opaque_pc = (fptr)) | |
335 | /* Return lr field of arm_thread_state64_t as a data pointer value */ | |
336 | #define __darwin_arm_thread_state64_get_lr(ts) \ | |
337 | ((uintptr_t)((ts).__opaque_lr)) | |
338 | /* Return lr field of arm_thread_state64_t as a function pointer */ | |
339 | #define __darwin_arm_thread_state64_get_lr_fptr(ts) \ | |
340 | ((ts).__opaque_lr) | |
341 | /* Set lr field of arm_thread_state64_t to a function pointer */ | |
342 | #define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \ | |
343 | ((ts).__opaque_lr = (fptr)) | |
344 | /* Return sp field of arm_thread_state64_t as a data pointer value */ | |
345 | #define __darwin_arm_thread_state64_get_sp(ts) \ | |
346 | ((uintptr_t)((ts).__opaque_sp)) | |
347 | /* Set sp field of arm_thread_state64_t to a data pointer value */ | |
348 | #define __darwin_arm_thread_state64_set_sp(ts, ptr) \ | |
349 | ((ts).__opaque_sp = (void*)(uintptr_t)(ptr)) | |
350 | /* Return fp field of arm_thread_state64_t as a data pointer value */ | |
351 | #define __darwin_arm_thread_state64_get_fp(ts) \ | |
352 | ((uintptr_t)((ts).__opaque_fp)) | |
353 | /* Set fp field of arm_thread_state64_t to a data pointer value */ | |
354 | #define __darwin_arm_thread_state64_set_fp(ts, ptr) \ | |
355 | ((ts).__opaque_fp = (void*)(uintptr_t)(ptr)) | |
f427ee49 A |
356 | /* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */ |
357 | #define __darwin_arm_thread_state64_ptrauth_strip(ts) \ | |
358 | (void)(ts) | |
cb323159 A |
359 | |
360 | #else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ | |
d9a64523 | 361 | #if __DARWIN_UNIX03 |
cb323159 A |
362 | |
363 | /* Return pc field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 364 | #define __darwin_arm_thread_state64_get_pc(ts) \ |
cb323159 A |
365 | ((ts).__pc) |
366 | /* Return pc field of arm_thread_state64_t as a function pointer */ | |
d9a64523 | 367 | #define __darwin_arm_thread_state64_get_pc_fptr(ts) \ |
cb323159 A |
368 | ((void*)(uintptr_t)((ts).__pc)) |
369 | /* Set pc field of arm_thread_state64_t to a function pointer */ | |
d9a64523 | 370 | #define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \ |
cb323159 A |
371 | ((ts).__pc = (uintptr_t)(fptr)) |
372 | /* Return lr field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 373 | #define __darwin_arm_thread_state64_get_lr(ts) \ |
cb323159 A |
374 | ((ts).__lr) |
375 | /* Return lr field of arm_thread_state64_t as a function pointer */ | |
d9a64523 | 376 | #define __darwin_arm_thread_state64_get_lr_fptr(ts) \ |
cb323159 A |
377 | ((void*)(uintptr_t)((ts).__lr)) |
378 | /* Set lr field of arm_thread_state64_t to a function pointer */ | |
d9a64523 | 379 | #define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \ |
cb323159 A |
380 | ((ts).__lr = (uintptr_t)(fptr)) |
381 | /* Return sp field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 382 | #define __darwin_arm_thread_state64_get_sp(ts) \ |
cb323159 A |
383 | ((ts).__sp) |
384 | /* Set sp field of arm_thread_state64_t to a data pointer value */ | |
d9a64523 | 385 | #define __darwin_arm_thread_state64_set_sp(ts, ptr) \ |
cb323159 A |
386 | ((ts).__sp = (uintptr_t)(ptr)) |
387 | /* Return fp field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 388 | #define __darwin_arm_thread_state64_get_fp(ts) \ |
cb323159 A |
389 | ((ts).__fp) |
390 | /* Set fp field of arm_thread_state64_t to a data pointer value */ | |
d9a64523 | 391 | #define __darwin_arm_thread_state64_set_fp(ts, ptr) \ |
cb323159 | 392 | ((ts).__fp = (uintptr_t)(ptr)) |
f427ee49 A |
393 | /* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */ |
394 | #define __darwin_arm_thread_state64_ptrauth_strip(ts) \ | |
395 | (void)(ts) | |
cb323159 A |
396 | |
397 | #else /* __DARWIN_UNIX03 */ | |
398 | ||
399 | /* Return pc field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 400 | #define __darwin_arm_thread_state64_get_pc(ts) \ |
cb323159 A |
401 | ((ts).pc) |
402 | /* Return pc field of arm_thread_state64_t as a function pointer */ | |
d9a64523 | 403 | #define __darwin_arm_thread_state64_get_pc_fptr(ts) \ |
cb323159 A |
404 | ((void*)(uintptr_t)((ts).pc)) |
405 | /* Set pc field of arm_thread_state64_t to a function pointer */ | |
d9a64523 | 406 | #define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \ |
cb323159 A |
407 | ((ts).pc = (uintptr_t)(fptr)) |
408 | /* Return lr field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 409 | #define __darwin_arm_thread_state64_get_lr(ts) \ |
cb323159 A |
410 | ((ts).lr) |
411 | /* Return lr field of arm_thread_state64_t as a function pointer */ | |
d9a64523 | 412 | #define __darwin_arm_thread_state64_get_lr_fptr(ts) \ |
cb323159 A |
413 | ((void*)(uintptr_t)((ts).lr)) |
414 | /* Set lr field of arm_thread_state64_t to a function pointer */ | |
d9a64523 | 415 | #define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \ |
cb323159 A |
416 | ((ts).lr = (uintptr_t)(fptr)) |
417 | /* Return sp field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 418 | #define __darwin_arm_thread_state64_get_sp(ts) \ |
cb323159 A |
419 | ((ts).sp) |
420 | /* Set sp field of arm_thread_state64_t to a data pointer value */ | |
d9a64523 | 421 | #define __darwin_arm_thread_state64_set_sp(ts, ptr) \ |
cb323159 A |
422 | ((ts).sp = (uintptr_t)(ptr)) |
423 | /* Return fp field of arm_thread_state64_t as a data pointer value */ | |
d9a64523 | 424 | #define __darwin_arm_thread_state64_get_fp(ts) \ |
cb323159 A |
425 | ((ts).fp) |
426 | /* Set fp field of arm_thread_state64_t to a data pointer value */ | |
d9a64523 | 427 | #define __darwin_arm_thread_state64_set_fp(ts, ptr) \ |
cb323159 | 428 | ((ts).fp = (uintptr_t)(ptr)) |
f427ee49 A |
429 | /* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */ |
430 | #define __darwin_arm_thread_state64_ptrauth_strip(ts) \ | |
431 | (void)(ts) | |
cb323159 | 432 | |
d9a64523 | 433 | #endif /* __DARWIN_UNIX03 */ |
cb323159 A |
434 | #endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ |
435 | ||
436 | #endif /* __has_feature(ptrauth_calls) && defined(__LP64__) */ | |
d9a64523 A |
437 | #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__) */ |
438 | #endif /* !defined(KERNEL) */ | |
5ba3f43e A |
439 | |
440 | #if __DARWIN_UNIX03 | |
cb323159 | 441 | #define _STRUCT_ARM_VFP_STATE struct __darwin_arm_vfp_state |
5ba3f43e A |
442 | _STRUCT_ARM_VFP_STATE |
443 | { | |
cb323159 A |
444 | __uint32_t __r[64]; |
445 | __uint32_t __fpscr; | |
5ba3f43e A |
446 | }; |
447 | #else /* !__DARWIN_UNIX03 */ | |
cb323159 | 448 | #define _STRUCT_ARM_VFP_STATE struct arm_vfp_state |
5ba3f43e A |
449 | _STRUCT_ARM_VFP_STATE |
450 | { | |
cb323159 A |
451 | __uint32_t r[64]; |
452 | __uint32_t fpscr; | |
5ba3f43e A |
453 | }; |
454 | #endif /* __DARWIN_UNIX03 */ | |
455 | ||
456 | #if __DARWIN_UNIX03 | |
cb323159 A |
457 | #define _STRUCT_ARM_NEON_STATE64 struct __darwin_arm_neon_state64 |
458 | #define _STRUCT_ARM_NEON_STATE struct __darwin_arm_neon_state | |
5ba3f43e A |
459 | |
460 | #if defined(__arm64__) | |
461 | _STRUCT_ARM_NEON_STATE64 | |
462 | { | |
cb323159 A |
463 | __uint128_t __v[32]; |
464 | __uint32_t __fpsr; | |
465 | __uint32_t __fpcr; | |
5ba3f43e A |
466 | }; |
467 | ||
468 | _STRUCT_ARM_NEON_STATE | |
469 | { | |
cb323159 A |
470 | __uint128_t __v[16]; |
471 | __uint32_t __fpsr; | |
472 | __uint32_t __fpcr; | |
5ba3f43e | 473 | }; |
5ba3f43e A |
474 | #elif defined(__arm__) |
475 | /* | |
476 | * No 128-bit intrinsic for ARM; leave it opaque for now. | |
477 | */ | |
478 | _STRUCT_ARM_NEON_STATE64 | |
479 | { | |
480 | char opaque[(32 * 16) + (2 * sizeof(__uint32_t))]; | |
481 | } __attribute__((aligned(16))); | |
482 | ||
483 | _STRUCT_ARM_NEON_STATE | |
484 | { | |
485 | char opaque[(16 * 16) + (2 * sizeof(__uint32_t))]; | |
486 | } __attribute__((aligned(16))); | |
487 | ||
488 | #else | |
489 | #error Unknown architecture. | |
490 | #endif | |
491 | ||
492 | #else /* !__DARWIN_UNIX03 */ | |
493 | #define _STRUCT_ARM_NEON_STATE64 struct arm_neon_state64 | |
494 | #define _STRUCT_ARM_NEON_STATE struct arm_neon_state | |
495 | ||
496 | #if defined(__arm64__) | |
497 | _STRUCT_ARM_NEON_STATE64 | |
498 | { | |
cb323159 A |
499 | __uint128_t q[32]; |
500 | uint32_t fpsr; | |
501 | uint32_t fpcr; | |
5ba3f43e | 502 | }; |
cb323159 | 503 | |
5ba3f43e A |
504 | _STRUCT_ARM_NEON_STATE |
505 | { | |
cb323159 A |
506 | __uint128_t q[16]; |
507 | uint32_t fpsr; | |
508 | uint32_t fpcr; | |
5ba3f43e A |
509 | }; |
510 | #elif defined(__arm__) | |
511 | /* | |
512 | * No 128-bit intrinsic for ARM; leave it opaque for now. | |
513 | */ | |
514 | _STRUCT_ARM_NEON_STATE64 | |
515 | { | |
516 | char opaque[(32 * 16) + (2 * sizeof(__uint32_t))]; | |
517 | } __attribute__((aligned(16))); | |
518 | ||
519 | _STRUCT_ARM_NEON_STATE | |
520 | { | |
521 | char opaque[(16 * 16) + (2 * sizeof(__uint32_t))]; | |
522 | } __attribute__((aligned(16))); | |
523 | ||
524 | #else | |
525 | #error Unknown architecture. | |
526 | #endif | |
527 | ||
528 | #endif /* __DARWIN_UNIX03 */ | |
529 | ||
cb323159 A |
530 | |
531 | #define _STRUCT_ARM_PAGEIN_STATE struct __arm_pagein_state | |
532 | _STRUCT_ARM_PAGEIN_STATE | |
533 | { | |
534 | int __pagein_error; | |
535 | }; | |
536 | ||
5ba3f43e A |
537 | /* |
538 | * Debug State | |
539 | */ | |
540 | #if defined(__arm__) | |
541 | /* Old-fashioned debug state is only for ARM */ | |
542 | ||
543 | #if __DARWIN_UNIX03 | |
0a7de745 | 544 | #define _STRUCT_ARM_DEBUG_STATE struct __darwin_arm_debug_state |
5ba3f43e A |
545 | _STRUCT_ARM_DEBUG_STATE |
546 | { | |
cb323159 A |
547 | __uint32_t __bvr[16]; |
548 | __uint32_t __bcr[16]; | |
549 | __uint32_t __wvr[16]; | |
550 | __uint32_t __wcr[16]; | |
5ba3f43e A |
551 | }; |
552 | #else /* !__DARWIN_UNIX03 */ | |
0a7de745 | 553 | #define _STRUCT_ARM_DEBUG_STATE struct arm_debug_state |
5ba3f43e A |
554 | _STRUCT_ARM_DEBUG_STATE |
555 | { | |
cb323159 A |
556 | __uint32_t bvr[16]; |
557 | __uint32_t bcr[16]; | |
558 | __uint32_t wvr[16]; | |
559 | __uint32_t wcr[16]; | |
5ba3f43e A |
560 | }; |
561 | #endif /* __DARWIN_UNIX03 */ | |
562 | ||
563 | #elif defined(__arm64__) | |
564 | ||
565 | /* ARM's arm_debug_state is ARM64's arm_legacy_debug_state */ | |
566 | ||
567 | #if __DARWIN_UNIX03 | |
f427ee49 | 568 | #define _STRUCT_ARM_LEGACY_DEBUG_STATE struct __arm_legacy_debug_state |
5ba3f43e A |
569 | _STRUCT_ARM_LEGACY_DEBUG_STATE |
570 | { | |
cb323159 A |
571 | __uint32_t __bvr[16]; |
572 | __uint32_t __bcr[16]; | |
573 | __uint32_t __wvr[16]; | |
574 | __uint32_t __wcr[16]; | |
5ba3f43e A |
575 | }; |
576 | #else /* __DARWIN_UNIX03 */ | |
cb323159 | 577 | #define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state |
5ba3f43e A |
578 | _STRUCT_ARM_LEGACY_DEBUG_STATE |
579 | { | |
cb323159 A |
580 | __uint32_t bvr[16]; |
581 | __uint32_t bcr[16]; | |
582 | __uint32_t wvr[16]; | |
583 | __uint32_t wcr[16]; | |
5ba3f43e A |
584 | }; |
585 | #endif /* __DARWIN_UNIX03 */ | |
586 | #else | |
587 | #error unknown architecture | |
588 | #endif | |
589 | ||
590 | #if __DARWIN_UNIX03 | |
cb323159 | 591 | #define _STRUCT_ARM_DEBUG_STATE32 struct __darwin_arm_debug_state32 |
5ba3f43e A |
592 | _STRUCT_ARM_DEBUG_STATE32 |
593 | { | |
cb323159 A |
594 | __uint32_t __bvr[16]; |
595 | __uint32_t __bcr[16]; | |
596 | __uint32_t __wvr[16]; | |
597 | __uint32_t __wcr[16]; | |
598 | __uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */ | |
5ba3f43e A |
599 | }; |
600 | ||
cb323159 | 601 | #define _STRUCT_ARM_DEBUG_STATE64 struct __darwin_arm_debug_state64 |
5ba3f43e A |
602 | _STRUCT_ARM_DEBUG_STATE64 |
603 | { | |
cb323159 A |
604 | __uint64_t __bvr[16]; |
605 | __uint64_t __bcr[16]; | |
606 | __uint64_t __wvr[16]; | |
607 | __uint64_t __wcr[16]; | |
608 | __uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */ | |
5ba3f43e A |
609 | }; |
610 | #else /* !__DARWIN_UNIX03 */ | |
cb323159 | 611 | #define _STRUCT_ARM_DEBUG_STATE32 struct arm_debug_state32 |
5ba3f43e A |
612 | _STRUCT_ARM_DEBUG_STATE32 |
613 | { | |
cb323159 A |
614 | __uint32_t bvr[16]; |
615 | __uint32_t bcr[16]; | |
616 | __uint32_t wvr[16]; | |
617 | __uint32_t wcr[16]; | |
618 | __uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */ | |
5ba3f43e A |
619 | }; |
620 | ||
cb323159 | 621 | #define _STRUCT_ARM_DEBUG_STATE64 struct arm_debug_state64 |
5ba3f43e A |
622 | _STRUCT_ARM_DEBUG_STATE64 |
623 | { | |
cb323159 A |
624 | __uint64_t bvr[16]; |
625 | __uint64_t bcr[16]; | |
626 | __uint64_t wvr[16]; | |
627 | __uint64_t wcr[16]; | |
628 | __uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */ | |
5ba3f43e A |
629 | }; |
630 | #endif /* __DARWIN_UNIX03 */ | |
631 | ||
632 | #if __DARWIN_UNIX03 | |
cb323159 | 633 | #define _STRUCT_ARM_CPMU_STATE64 struct __darwin_arm_cpmu_state64 |
5ba3f43e A |
634 | _STRUCT_ARM_CPMU_STATE64 |
635 | { | |
636 | __uint64_t __ctrs[16]; | |
637 | }; | |
638 | #else /* __DARWIN_UNIX03 */ | |
cb323159 | 639 | #define _STRUCT_ARM_CPMU_STATE64 struct arm_cpmu_state64 |
5ba3f43e A |
640 | _STRUCT_ARM_CPMU_STATE64 |
641 | { | |
642 | __uint64_t ctrs[16]; | |
643 | }; | |
644 | #endif /* !__DARWIN_UNIX03 */ | |
645 | ||
646 | #endif /* _MACH_ARM__STRUCTS_H_ */ |