]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/arm/thread_status.h
xnu-4570.20.62.tar.gz
[apple/xnu.git] / osfmk / mach / arm / thread_status.h
1 /*
2 * Copyright (c) 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 * FILE_ID: thread_status.h
30 */
31
32
33 #ifndef _ARM_THREAD_STATUS_H_
34 #define _ARM_THREAD_STATUS_H_
35
36 #include <mach/machine/_structs.h>
37 #include <mach/message.h>
38 #include <mach/arm/thread_state.h>
39
40 /*
41 * Support for determining the state of a thread
42 */
43
44
45 /*
46 * Flavors
47 */
48
49 #define ARM_THREAD_STATE 1
50 #define ARM_UNIFIED_THREAD_STATE ARM_THREAD_STATE
51 #define ARM_VFP_STATE 2
52 #define ARM_EXCEPTION_STATE 3
53 #define ARM_DEBUG_STATE 4 /* pre-armv8 */
54 #define THREAD_STATE_NONE 5
55 #define ARM_THREAD_STATE64 6
56 #define ARM_EXCEPTION_STATE64 7
57 // ARM_THREAD_STATE_LAST (legacy) 8
58 #define ARM_THREAD_STATE32 9
59
60 /* API */
61 #define ARM_DEBUG_STATE32 14
62 #define ARM_DEBUG_STATE64 15
63 #define ARM_NEON_STATE 16
64 #define ARM_NEON_STATE64 17
65 #define ARM_CPMU_STATE64 18
66
67 #ifdef XNU_KERNEL_PRIVATE
68 /* For kernel use */
69 #define ARM_SAVED_STATE32 20
70 #define ARM_SAVED_STATE64 21
71 #define ARM_NEON_SAVED_STATE32 22
72 #define ARM_NEON_SAVED_STATE64 23
73 #endif /* XNU_KERNEL_PRIVATE */
74
75 #define VALID_THREAD_STATE_FLAVOR(x)\
76 ((x == ARM_THREAD_STATE) || \
77 (x == ARM_VFP_STATE) || \
78 (x == ARM_EXCEPTION_STATE) || \
79 (x == ARM_DEBUG_STATE) || \
80 (x == THREAD_STATE_NONE) || \
81 (x == ARM_THREAD_STATE32) || \
82 (x == ARM_THREAD_STATE64) || \
83 (x == ARM_EXCEPTION_STATE64) || \
84 (x == ARM_NEON_STATE) || \
85 (x == ARM_NEON_STATE64) || \
86 (x == ARM_DEBUG_STATE32) || \
87 (x == ARM_DEBUG_STATE64))
88
89 struct arm_state_hdr {
90 uint32_t flavor;
91 uint32_t count;
92 };
93 typedef struct arm_state_hdr arm_state_hdr_t;
94
95 typedef _STRUCT_ARM_THREAD_STATE arm_thread_state_t;
96 typedef _STRUCT_ARM_THREAD_STATE arm_thread_state32_t;
97 typedef _STRUCT_ARM_THREAD_STATE64 arm_thread_state64_t;
98
99 struct arm_unified_thread_state {
100 arm_state_hdr_t ash;
101 union {
102 arm_thread_state32_t ts_32;
103 arm_thread_state64_t ts_64;
104 } uts;
105 };
106 #define ts_32 uts.ts_32
107 #define ts_64 uts.ts_64
108 typedef struct arm_unified_thread_state arm_unified_thread_state_t;
109
110 #define ARM_THREAD_STATE_COUNT ((mach_msg_type_number_t) \
111 (sizeof (arm_thread_state_t)/sizeof(uint32_t)))
112 #define ARM_THREAD_STATE32_COUNT ((mach_msg_type_number_t) \
113 (sizeof (arm_thread_state32_t)/sizeof(uint32_t)))
114 #define ARM_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \
115 (sizeof (arm_thread_state64_t)/sizeof(uint32_t)))
116 #define ARM_UNIFIED_THREAD_STATE_COUNT ((mach_msg_type_number_t) \
117 (sizeof (arm_unified_thread_state_t)/sizeof(uint32_t)))
118
119
120 typedef _STRUCT_ARM_VFP_STATE arm_vfp_state_t;
121 typedef _STRUCT_ARM_NEON_STATE arm_neon_state_t;
122 typedef _STRUCT_ARM_NEON_STATE arm_neon_state32_t;
123 typedef _STRUCT_ARM_NEON_STATE64 arm_neon_state64_t;
124
125 typedef _STRUCT_ARM_EXCEPTION_STATE arm_exception_state_t;
126 typedef _STRUCT_ARM_EXCEPTION_STATE arm_exception_state32_t;
127 typedef _STRUCT_ARM_EXCEPTION_STATE64 arm_exception_state64_t;
128
129 typedef _STRUCT_ARM_DEBUG_STATE32 arm_debug_state32_t;
130 typedef _STRUCT_ARM_DEBUG_STATE64 arm_debug_state64_t;
131
132 #if defined(XNU_KERNEL_PRIVATE) && defined(__arm64__)
133 /* See below for ARM64 kernel structure definition for arm_debug_state. */
134 #else
135 /*
136 * Otherwise not ARM64 kernel and we must preserve legacy ARM definitions of
137 * arm_debug_state for binary compatability of userland consumers of this file.
138 */
139 #if defined(__arm__)
140 typedef _STRUCT_ARM_DEBUG_STATE arm_debug_state_t;
141 #elif defined(__arm64__)
142 typedef _STRUCT_ARM_LEGACY_DEBUG_STATE arm_debug_state_t;
143 #else
144 #error Undefined architecture
145 #endif
146 #endif
147
148 #define ARM_VFP_STATE_COUNT ((mach_msg_type_number_t) \
149 (sizeof (arm_vfp_state_t)/sizeof(uint32_t)))
150
151 #define ARM_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \
152 (sizeof (arm_exception_state_t)/sizeof(uint32_t)))
153
154 #define ARM_EXCEPTION_STATE64_COUNT ((mach_msg_type_number_t) \
155 (sizeof (arm_exception_state64_t)/sizeof(uint32_t)))
156
157 #define ARM_DEBUG_STATE_COUNT ((mach_msg_type_number_t) \
158 (sizeof (arm_debug_state_t)/sizeof(uint32_t)))
159
160 #define ARM_DEBUG_STATE32_COUNT ((mach_msg_type_number_t) \
161 (sizeof (arm_debug_state32_t)/sizeof(uint32_t)))
162
163 #define ARM_DEBUG_STATE64_COUNT ((mach_msg_type_number_t) \
164 (sizeof (arm_debug_state64_t)/sizeof(uint32_t)))
165
166 #define ARM_NEON_STATE_COUNT ((mach_msg_type_number_t) \
167 (sizeof (arm_neon_state_t)/sizeof(uint32_t)))
168
169 #define ARM_NEON_STATE64_COUNT ((mach_msg_type_number_t) \
170 (sizeof (arm_neon_state64_t)/sizeof(uint32_t)))
171
172 #define MACHINE_THREAD_STATE ARM_THREAD_STATE
173 #define MACHINE_THREAD_STATE_COUNT ARM_UNIFIED_THREAD_STATE_COUNT
174
175 /*
176 * Largest state on this machine:
177 */
178 #define THREAD_MACHINE_STATE_MAX THREAD_STATE_MAX
179
180 #ifdef XNU_KERNEL_PRIVATE
181
182 static inline boolean_t
183 is_thread_state32(const arm_unified_thread_state_t *its)
184 {
185 return (its->ash.flavor == ARM_THREAD_STATE32);
186 }
187
188 static inline boolean_t
189 is_thread_state64(const arm_unified_thread_state_t *its)
190 {
191 return (its->ash.flavor == ARM_THREAD_STATE64);
192 }
193
194 static inline arm_thread_state32_t*
195 thread_state32(arm_unified_thread_state_t *its)
196 {
197 return &its->ts_32;
198 }
199
200 static inline arm_thread_state64_t*
201 thread_state64(arm_unified_thread_state_t *its)
202 {
203 return &its->ts_64;
204 }
205
206 static inline const arm_thread_state32_t*
207 const_thread_state32(const arm_unified_thread_state_t *its)
208 {
209 return &its->ts_32;
210 }
211
212 static inline const arm_thread_state64_t*
213 const_thread_state64(const arm_unified_thread_state_t *its)
214 {
215 return &its->ts_64;
216 }
217
218 #if defined(__arm__)
219 #include <arm/proc_reg.h>
220
221 #define ARM_SAVED_STATE THREAD_STATE_NONE + 1
222
223 struct arm_saved_state {
224 uint32_t r[13]; /* General purpose register r0-r12 */
225 uint32_t sp; /* Stack pointer r13 */
226 uint32_t lr; /* Link register r14 */
227 uint32_t pc; /* Program counter r15 */
228 uint32_t cpsr; /* Current program status register */
229 uint32_t fsr; /* Fault status */
230 uint32_t far; /* Virtual Fault Address */
231 uint32_t exception; /* exception number */
232 };
233 typedef struct arm_saved_state arm_saved_state_t;
234
235 /*
236 * Just for coexistence with AArch64 code.
237 */
238 typedef struct arm_saved_state arm_saved_state32_t;
239
240 static inline arm_saved_state32_t*
241 saved_state32(arm_saved_state_t *iss)
242 {
243 return iss;
244 }
245
246 static inline boolean_t
247 is_saved_state32(const arm_saved_state_t *iss __unused)
248 {
249 return TRUE;
250 }
251
252
253 struct arm_saved_state_tagged {
254 uint32_t tag;
255 struct arm_saved_state state;
256 };
257 typedef struct arm_saved_state_tagged arm_saved_state_tagged_t;
258
259 #define ARM_SAVED_STATE32_COUNT ((mach_msg_type_number_t) \
260 (sizeof (arm_saved_state_t)/sizeof(unsigned int)))
261
262
263 static inline register_t
264 get_saved_state_pc(const arm_saved_state_t *iss)
265 {
266 return iss->pc;
267 }
268
269 static inline void
270 set_saved_state_pc(arm_saved_state_t *iss, register_t pc)
271 {
272 iss->pc = pc;
273 }
274
275 static inline register_t
276 get_saved_state_sp(const arm_saved_state_t *iss)
277 {
278 return iss->sp;
279 }
280
281 static inline void
282 set_saved_state_sp(arm_saved_state_t *iss, register_t sp)
283 {
284 iss->sp = sp;
285 }
286
287 static inline register_t
288 get_saved_state_fp(const arm_saved_state_t *iss)
289 {
290 return iss->r[7];
291 }
292
293 static inline void
294 set_saved_state_fp(arm_saved_state_t *iss, register_t fp)
295 {
296 iss->r[7] = fp;
297 }
298
299 static inline register_t
300 get_saved_state_lr(const arm_saved_state_t *iss)
301 {
302 return iss->lr;
303 }
304
305 static inline void
306 set_saved_state_lr(arm_saved_state_t *iss, register_t lr)
307 {
308 iss->lr = lr;
309 }
310
311 static inline register_t
312 get_saved_state_cpsr(const arm_saved_state_t *iss)
313 {
314 return iss->cpsr;
315 }
316
317 static inline void
318 set_saved_state_cpsr(arm_saved_state_t *iss, register_t cpsr)
319 {
320 iss->cpsr = cpsr;
321 }
322
323 static inline register_t
324 get_saved_state_reg(const arm_saved_state_t *iss, unsigned regno)
325 {
326 return iss->r[regno];
327 }
328
329 static inline void
330 set_saved_state_reg(arm_saved_state_t *iss, unsigned regno, register_t val)
331 {
332 iss->r[regno] = val;
333 }
334
335 #elif defined(__arm64__)
336
337 #include <kern/assert.h>
338 #include <arm64/proc_reg.h>
339 #define CAST_ASSERT_SAFE(type, val) (assert((val) == ((type)(val))), (type)(val))
340
341 /*
342 * GPR context
343 */
344
345 struct arm_saved_state32 {
346 uint32_t r[13]; /* General purpose register r0-r12 */
347 uint32_t sp; /* Stack pointer r13 */
348 uint32_t lr; /* Link register r14 */
349 uint32_t pc; /* Program counter r15 */
350 uint32_t cpsr; /* Current program status register */
351 uint32_t far; /* Virtual fault address */
352 uint32_t esr; /* Exception syndrome register */
353 uint32_t exception; /* Exception number */
354 };
355 typedef struct arm_saved_state32 arm_saved_state32_t;
356
357 struct arm_saved_state32_tagged {
358 uint32_t tag;
359 struct arm_saved_state32 state;
360 };
361 typedef struct arm_saved_state32_tagged arm_saved_state32_tagged_t;
362
363 #define ARM_SAVED_STATE32_COUNT ((mach_msg_type_number_t) \
364 (sizeof (arm_saved_state32_t)/sizeof(unsigned int)))
365
366 struct arm_saved_state64 {
367 uint64_t x[29]; /* General purpose registers x0-x28 */
368 uint64_t fp; /* Frame pointer x29 */
369 uint64_t lr; /* Link register x30 */
370 uint64_t sp; /* Stack pointer x31 */
371 uint64_t pc; /* Program counter */
372 uint32_t cpsr; /* Current program status register */
373 uint32_t reserved; /* Reserved padding */
374 uint64_t far; /* Virtual fault address */
375 uint32_t esr; /* Exception syndrome register */
376 uint32_t exception; /* Exception number */
377 };
378 typedef struct arm_saved_state64 arm_saved_state64_t;
379
380 #define ARM_SAVED_STATE64_COUNT ((mach_msg_type_number_t) \
381 (sizeof (arm_saved_state64_t)/sizeof(unsigned int)))
382
383 struct arm_saved_state64_tagged {
384 uint32_t tag;
385 struct arm_saved_state64 state;
386 };
387 typedef struct arm_saved_state64_tagged arm_saved_state64_tagged_t;
388
389 struct arm_saved_state {
390 arm_state_hdr_t ash;
391 union {
392 struct arm_saved_state32 ss_32;
393 struct arm_saved_state64 ss_64;
394 } uss;
395 } __attribute__((aligned(16)));
396 #define ss_32 uss.ss_32
397 #define ss_64 uss.ss_64
398
399 typedef struct arm_saved_state arm_saved_state_t;
400
401
402 static inline boolean_t
403 is_saved_state32(const arm_saved_state_t *iss)
404 {
405 return (iss->ash.flavor == ARM_SAVED_STATE32);
406 }
407
408 static inline boolean_t
409 is_saved_state64(const arm_saved_state_t *iss)
410 {
411 return (iss->ash.flavor == ARM_SAVED_STATE64);
412 }
413
414 static inline arm_saved_state32_t*
415 saved_state32(arm_saved_state_t *iss)
416 {
417 return &iss->ss_32;
418 }
419
420 static inline const arm_saved_state32_t*
421 const_saved_state32(const arm_saved_state_t *iss)
422 {
423 return &iss->ss_32;
424 }
425
426 static inline arm_saved_state64_t*
427 saved_state64(arm_saved_state_t *iss)
428 {
429 return &iss->ss_64;
430 }
431
432 static inline const arm_saved_state64_t*
433 const_saved_state64(const arm_saved_state_t *iss)
434 {
435 return &iss->ss_64;
436 }
437
438 static inline register_t
439 get_saved_state_pc(const arm_saved_state_t *iss)
440 {
441 return (is_saved_state32(iss) ? const_saved_state32(iss)->pc : const_saved_state64(iss)->pc);
442 }
443
444 static inline void
445 set_saved_state_pc(arm_saved_state_t *iss, register_t pc)
446 {
447 if (is_saved_state32(iss)) {
448 saved_state32(iss)->pc = CAST_ASSERT_SAFE(uint32_t, pc);
449 } else {
450 saved_state64(iss)->pc = pc;
451 }
452 }
453
454 static inline register_t
455 get_saved_state_sp(const arm_saved_state_t *iss)
456 {
457 return (is_saved_state32(iss) ? const_saved_state32(iss)->sp : const_saved_state64(iss)->sp);
458 }
459
460 static inline void
461 set_saved_state_sp(arm_saved_state_t *iss, register_t sp)
462 {
463 if (is_saved_state32(iss)) {
464 saved_state32(iss)->sp = CAST_ASSERT_SAFE(uint32_t, sp);
465 } else {
466 saved_state64(iss)->sp = sp;
467 }
468 }
469
470 static inline register_t
471 get_saved_state_lr(const arm_saved_state_t *iss)
472 {
473 return (is_saved_state32(iss) ? const_saved_state32(iss)->lr : const_saved_state64(iss)->lr);
474 }
475
476 static inline void
477 set_saved_state_lr(arm_saved_state_t *iss, register_t lr)
478 {
479 if (is_saved_state32(iss)) {
480 saved_state32(iss)->lr = CAST_ASSERT_SAFE(uint32_t, lr);
481 } else {
482 saved_state64(iss)->lr = lr;
483 }
484 }
485
486 static inline register_t
487 get_saved_state_fp(const arm_saved_state_t *iss)
488 {
489 return (is_saved_state32(iss) ? const_saved_state32(iss)->r[7] : const_saved_state64(iss)->fp);
490 }
491
492 static inline void
493 set_saved_state_fp(arm_saved_state_t *iss, register_t fp)
494 {
495 if (is_saved_state32(iss)) {
496 saved_state32(iss)->r[7] = CAST_ASSERT_SAFE(uint32_t, fp);
497 } else {
498 saved_state64(iss)->fp = fp;
499 }
500 }
501
502 static inline int
503 check_saved_state_reglimit(const arm_saved_state_t *iss, unsigned reg)
504 {
505 return (is_saved_state32(iss) ? (reg < ARM_SAVED_STATE32_COUNT) : (reg < ARM_SAVED_STATE64_COUNT));
506 }
507
508 static inline register_t
509 get_saved_state_reg(const arm_saved_state_t *iss, unsigned reg)
510 {
511 if (!check_saved_state_reglimit(iss, reg)) return 0;
512
513 return (is_saved_state32(iss) ? (const_saved_state32(iss)->r[reg]) : (const_saved_state64(iss)->x[reg]));
514 }
515
516 static inline void
517 set_saved_state_reg(arm_saved_state_t *iss, unsigned reg, register_t value)
518 {
519 if (!check_saved_state_reglimit(iss, reg)) return;
520
521 if (is_saved_state32(iss)) {
522 saved_state32(iss)->r[reg] = CAST_ASSERT_SAFE(uint32_t, value);
523 } else {
524 saved_state64(iss)->x[reg] = value;
525 }
526 }
527
528 static inline uint32_t
529 get_saved_state_cpsr(const arm_saved_state_t *iss)
530 {
531 return (is_saved_state32(iss) ? const_saved_state32(iss)->cpsr : const_saved_state64(iss)->cpsr);
532 }
533
534 static inline void
535 set_saved_state_cpsr(arm_saved_state_t *iss, uint32_t cpsr)
536 {
537 if (is_saved_state32(iss)) {
538 saved_state32(iss)->cpsr = cpsr;
539 } else {
540 saved_state64(iss)->cpsr = cpsr;
541 }
542 }
543
544 static inline register_t
545 get_saved_state_far(const arm_saved_state_t *iss)
546 {
547 return (is_saved_state32(iss) ? const_saved_state32(iss)->far : const_saved_state64(iss)->far);
548 }
549
550 static inline void
551 set_saved_state_far(arm_saved_state_t *iss, register_t far)
552 {
553 if (is_saved_state32(iss)) {
554 saved_state32(iss)->far = CAST_ASSERT_SAFE(uint32_t, far);
555 } else {
556 saved_state64(iss)->far = far;
557 }
558 }
559
560 static inline uint32_t
561 get_saved_state_esr(const arm_saved_state_t *iss)
562 {
563 return (is_saved_state32(iss) ? const_saved_state32(iss)->esr : const_saved_state64(iss)->esr);
564 }
565
566 static inline void
567 set_saved_state_esr(arm_saved_state_t *iss, uint32_t esr)
568 {
569 if (is_saved_state32(iss)) {
570 saved_state32(iss)->esr = esr;
571 } else {
572 saved_state64(iss)->esr = esr;
573 }
574 }
575
576 static inline uint32_t
577 get_saved_state_exc(const arm_saved_state_t *iss)
578 {
579 return (is_saved_state32(iss) ? const_saved_state32(iss)->exception : const_saved_state64(iss)->exception);
580 }
581
582 static inline void
583 set_saved_state_exc(arm_saved_state_t *iss, uint32_t exc)
584 {
585 if (is_saved_state32(iss)) {
586 saved_state32(iss)->exception = exc;
587 } else {
588 saved_state64(iss)->exception = exc;
589 }
590 }
591
592 extern void panic_unimplemented(void);
593
594 static inline int
595 get_saved_state_svc_number(const arm_saved_state_t *iss)
596 {
597 return (is_saved_state32(iss) ? (int)const_saved_state32(iss)->r[12] : (int)const_saved_state64(iss)->x[ARM64_SYSCALL_CODE_REG_NUM]); /* Only first word counts here */
598 }
599
600 typedef _STRUCT_ARM_LEGACY_DEBUG_STATE arm_legacy_debug_state_t;
601
602 struct arm_debug_aggregate_state {
603 arm_state_hdr_t dsh;
604 union {
605 arm_debug_state32_t ds32;
606 arm_debug_state64_t ds64;
607 } uds;
608 } __attribute__((aligned(16)));
609
610 typedef struct arm_debug_aggregate_state arm_debug_state_t;
611
612 #define ARM_LEGACY_DEBUG_STATE_COUNT ((mach_msg_type_number_t) \
613 (sizeof (arm_legacy_debug_state_t)/sizeof(uint32_t)))
614
615 /*
616 * NEON context
617 */
618 typedef __uint128_t uint128_t;
619 typedef uint64_t uint64x2_t __attribute__((ext_vector_type(2)));
620 typedef uint32_t uint32x4_t __attribute__((ext_vector_type(4)));
621
622 struct arm_neon_saved_state32 {
623 union {
624 uint128_t q[16];
625 uint64_t d[32];
626 uint32_t s[32];
627 } v;
628 uint32_t fpsr;
629 uint32_t fpcr;
630 };
631 typedef struct arm_neon_saved_state32 arm_neon_saved_state32_t;
632
633 #define ARM_NEON_SAVED_STATE32_COUNT ((mach_msg_type_number_t) \
634 (sizeof (arm_neon_saved_state32_t)/sizeof(unsigned int)))
635
636 struct arm_neon_saved_state64 {
637 union {
638 uint128_t q[32];
639 uint64x2_t d[32];
640 uint32x4_t s[32];
641 } v;
642 uint32_t fpsr;
643 uint32_t fpcr;
644 };
645 typedef struct arm_neon_saved_state64 arm_neon_saved_state64_t;
646
647 #define ARM_NEON_SAVED_STATE64_COUNT ((mach_msg_type_number_t) \
648 (sizeof (arm_neon_saved_state64_t)/sizeof(unsigned int)))
649
650 struct arm_neon_saved_state {
651 arm_state_hdr_t nsh;
652 union {
653 struct arm_neon_saved_state32 ns_32;
654 struct arm_neon_saved_state64 ns_64;
655 } uns;
656 };
657 typedef struct arm_neon_saved_state arm_neon_saved_state_t;
658 #define ns_32 uns.ns_32
659 #define ns_64 uns.ns_64
660
661 static inline boolean_t
662 is_neon_saved_state32(const arm_neon_saved_state_t *state)
663 {
664 return (state->nsh.flavor == ARM_NEON_SAVED_STATE32);
665 }
666
667 static inline boolean_t
668 is_neon_saved_state64(const arm_neon_saved_state_t *state)
669 {
670 return (state->nsh.flavor == ARM_NEON_SAVED_STATE64);
671 }
672
673 static inline arm_neon_saved_state32_t *
674 neon_state32(arm_neon_saved_state_t *state)
675 {
676 return &state->ns_32;
677 }
678
679 static inline arm_neon_saved_state64_t *
680 neon_state64(arm_neon_saved_state_t *state)
681 {
682 return &state->ns_64;
683 }
684
685
686 /*
687 * Aggregated context
688 */
689
690 struct arm_context {
691 struct arm_saved_state ss;
692 struct arm_neon_saved_state ns;
693 };
694 typedef struct arm_context arm_context_t;
695
696 extern void saved_state_to_thread_state64(const arm_saved_state_t*, arm_thread_state64_t*);
697 extern void thread_state64_to_saved_state(const arm_thread_state64_t*, arm_saved_state_t*);
698
699 #else
700 #error Unknown arch
701 #endif
702
703 extern void saved_state_to_thread_state32(const arm_saved_state_t*, arm_thread_state32_t*);
704 extern void thread_state32_to_saved_state(const arm_thread_state32_t*, arm_saved_state_t*);
705
706 #endif /* XNU_KERNEL_PRIVATE */
707
708 #endif /* _ARM_THREAD_STATUS_H_ */