1/* 2 * Copyright (c) 2007 Apple Inc. All rights reserved. 3 */ 4/* 5 * FILE_ID: thread_status.h 6 */ 7 8 9#ifndef _ARM_THREAD_STATUS_H_ 10#define _ARM_THREAD_STATUS_H_ 11 12#include <mach/arm/_structs.h> 13#include <mach/message.h> 14#include <mach/arm/thread_state.h> 15 16/* 17 * Support for determining the state of a thread 18 */ 19 20 21/* 22 * Flavors 23 */ 24 25#define ARM_THREAD_STATE 1 26#define ARM_UNIFIED_THREAD_STATE ARM_THREAD_STATE 27#define ARM_VFP_STATE 2 28#define ARM_EXCEPTION_STATE 3 29#define ARM_DEBUG_STATE 4 /* pre-armv8 */ 30#define THREAD_STATE_NONE 5 31#define ARM_THREAD_STATE64 6 32#define ARM_EXCEPTION_STATE64 7 33// ARM_THREAD_STATE_LAST (legacy) 8 34#define ARM_THREAD_STATE32 9 35 36/* API */ 37#define ARM_DEBUG_STATE32 14 38#define ARM_DEBUG_STATE64 15 39#define ARM_NEON_STATE 16 40#define ARM_NEON_STATE64 17 41 42 43#define VALID_THREAD_STATE_FLAVOR(x)\ 44((x == ARM_THREAD_STATE) || \ 45 (x == ARM_VFP_STATE) || \ 46 (x == ARM_EXCEPTION_STATE) || \ 47 (x == ARM_DEBUG_STATE) || \ 48 (x == THREAD_STATE_NONE) || \ 49 (x == ARM_THREAD_STATE32) || \ 50 (x == ARM_THREAD_STATE64) || \ 51 (x == ARM_EXCEPTION_STATE64) || \ 52 (x == ARM_NEON_STATE) || \ 53 (x == ARM_NEON_STATE64) || \ 54 (x == ARM_DEBUG_STATE32) || \ 55 (x == ARM_DEBUG_STATE64)) 56 57struct arm_state_hdr { 58 uint32_t flavor; 59 uint32_t count; 60}; 61typedef struct arm_state_hdr arm_state_hdr_t; 62 63typedef _STRUCT_ARM_THREAD_STATE arm_thread_state_t; 64typedef _STRUCT_ARM_THREAD_STATE arm_thread_state32_t; 65typedef _STRUCT_ARM_THREAD_STATE64 arm_thread_state64_t; 66 67struct arm_unified_thread_state { 68 arm_state_hdr_t ash; 69 union { 70 arm_thread_state32_t ts_32; 71 arm_thread_state64_t ts_64; 72 } uts; 73}; 74#define ts_32 uts.ts_32 75#define ts_64 uts.ts_64 76typedef struct arm_unified_thread_state arm_unified_thread_state_t; 77 78#define ARM_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ 79 (sizeof (arm_thread_state_t)/sizeof(uint32_t))) 80#define ARM_THREAD_STATE32_COUNT ((mach_msg_type_number_t) \ 81 (sizeof (arm_thread_state32_t)/sizeof(uint32_t))) 82#define ARM_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \ 83 (sizeof (arm_thread_state64_t)/sizeof(uint32_t))) 84#define ARM_UNIFIED_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ 85 (sizeof (arm_unified_thread_state_t)/sizeof(uint32_t))) 86 87 88typedef _STRUCT_ARM_VFP_STATE arm_vfp_state_t; 89typedef _STRUCT_ARM_NEON_STATE arm_neon_state_t; 90typedef _STRUCT_ARM_NEON_STATE arm_neon_state32_t; 91typedef _STRUCT_ARM_NEON_STATE64 arm_neon_state64_t; 92 93typedef _STRUCT_ARM_EXCEPTION_STATE arm_exception_state_t; 94typedef _STRUCT_ARM_EXCEPTION_STATE arm_exception_state32_t; 95typedef _STRUCT_ARM_EXCEPTION_STATE64 arm_exception_state64_t; 96 97typedef arm_thread_state_t arm_saved_state_t; 98 99typedef _STRUCT_ARM_DEBUG_STATE32 arm_debug_state32_t; 100typedef _STRUCT_ARM_DEBUG_STATE64 arm_debug_state64_t; 101 102/* 103 * Otherwise not ARM64 kernel and we must preserve legacy ARM definitions of 104 * arm_debug_state for binary compatability of userland consumers of this file. 105 */ 106#if defined(__arm__) 107typedef _STRUCT_ARM_DEBUG_STATE arm_debug_state_t; 108#elif defined(__arm64__) 109typedef _STRUCT_ARM_LEGACY_DEBUG_STATE arm_debug_state_t; 110#else 111#error Undefined architecture 112#endif 113 114#define ARM_VFP_STATE_COUNT ((mach_msg_type_number_t) \ 115 (sizeof (arm_vfp_state_t)/sizeof(uint32_t))) 116 117#define ARM_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \ 118 (sizeof (arm_exception_state_t)/sizeof(uint32_t))) 119 120#define ARM_EXCEPTION_STATE64_COUNT ((mach_msg_type_number_t) \ 121 (sizeof (arm_exception_state64_t)/sizeof(uint32_t))) 122 123#define ARM_DEBUG_STATE_COUNT ((mach_msg_type_number_t) \ 124 (sizeof (arm_debug_state_t)/sizeof(uint32_t))) 125 126#define ARM_DEBUG_STATE32_COUNT ((mach_msg_type_number_t) \ 127 (sizeof (arm_debug_state32_t)/sizeof(uint32_t))) 128 129#define ARM_DEBUG_STATE64_COUNT ((mach_msg_type_number_t) \ 130 (sizeof (arm_debug_state64_t)/sizeof(uint32_t))) 131 132#define ARM_NEON_STATE_COUNT ((mach_msg_type_number_t) \ 133 (sizeof (arm_neon_state_t)/sizeof(uint32_t))) 134 135#define ARM_NEON_STATE64_COUNT ((mach_msg_type_number_t) \ 136 (sizeof (arm_neon_state64_t)/sizeof(uint32_t))) 137 138#define MACHINE_THREAD_STATE ARM_THREAD_STATE 139#define MACHINE_THREAD_STATE_COUNT ARM_UNIFIED_THREAD_STATE_COUNT 140 141/* 142 * Largest state on this machine: 143 */ 144#define THREAD_MACHINE_STATE_MAX THREAD_STATE_MAX 145 146static inline void *saved_state64(void *iss) 147{ 148 return iss; 149} 150 151#endif /* _ARM_THREAD_STATUS_H_ */ 152