1 /* 2 * Copyright (c) 2000-2020 Apple Computer, 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 */ 31 /* 32 * Mach Operating System 33 * Copyright (c) 1991,1990,1989 Carnegie Mellon University 34 * All Rights Reserved. 35 * 36 * Permission to use, copy, modify and distribute this software and its 37 * documentation is hereby granted, provided that both the copyright 38 * notice and this permission notice appear in all copies of the 39 * software, derivative works or modified versions, and any portions 40 * thereof, and that both notices appear in supporting documentation. 41 * 42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 * 46 * Carnegie Mellon requests users of this software to return to 47 * 48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 * School of Computer Science 50 * Carnegie Mellon University 51 * Pittsburgh PA 15213-3890 52 * 53 * any improvements or extensions that they make and grant Carnegie Mellon 54 * the rights to redistribute these changes. 55 */ 56 /* 57 */ 58 /* 59 * File: thread_status.h 60 * Author: Avadis Tevanian, Jr. 61 * Date: 1985 62 * 63 * This file contains the structure definitions for the thread 64 * state as applied to I386 processors. 65 */ 66 67 #ifndef _MACH_I386_THREAD_STATUS_H_ 68 #define _MACH_I386_THREAD_STATUS_H_ 69 70 #include <mach/machine/_structs.h> 71 #include <mach/message.h> 72 #include <mach/i386/fp_reg.h> 73 #include <mach/i386/thread_state.h> 74 #include <i386/eflags.h> 75 76 77 /* 78 * the i386_xxxx form is kept for legacy purposes since these types 79 * are externally known... eventually they should be deprecated. 80 * our internal implementation has moved to the following naming convention 81 * 82 * x86_xxxx32 names are used to deal with 32 bit states 83 * x86_xxxx64 names are used to deal with 64 bit states 84 * x86_xxxx names are used to deal with either 32 or 64 bit states 85 * via a self-describing mechanism 86 */ 87 88 /* 89 * these are the legacy names which should be deprecated in the future 90 * they are externally known which is the only reason we don't just get 91 * rid of them 92 */ 93 #define i386_THREAD_STATE 1 94 #define i386_FLOAT_STATE 2 95 #define i386_EXCEPTION_STATE 3 96 97 /* 98 * THREAD_STATE_FLAVOR_LIST 0 99 * these are the supported flavors 100 */ 101 #define x86_THREAD_STATE32 1 102 #define x86_FLOAT_STATE32 2 103 #define x86_EXCEPTION_STATE32 3 104 #define x86_THREAD_STATE64 4 105 #define x86_FLOAT_STATE64 5 106 #define x86_EXCEPTION_STATE64 6 107 #define x86_THREAD_STATE 7 108 #define x86_FLOAT_STATE 8 109 #define x86_EXCEPTION_STATE 9 110 #define x86_DEBUG_STATE32 10 111 #define x86_DEBUG_STATE64 11 112 #define x86_DEBUG_STATE 12 113 #define THREAD_STATE_NONE 13 114 /* 14 and 15 are used for the internal x86_SAVED_STATE flavours */ 115 /* Arrange for flavors to take sequential values, 32-bit, 64-bit, non-specific */ 116 #define x86_AVX_STATE32 16 117 #define x86_AVX_STATE64 (x86_AVX_STATE32 + 1) 118 #define x86_AVX_STATE (x86_AVX_STATE32 + 2) 119 #define x86_AVX512_STATE32 19 120 #define x86_AVX512_STATE64 (x86_AVX512_STATE32 + 1) 121 #define x86_AVX512_STATE (x86_AVX512_STATE32 + 2) 122 #define x86_PAGEIN_STATE 22 123 #define x86_THREAD_FULL_STATE64 23 124 #define x86_INSTRUCTION_STATE 24 125 #define x86_LAST_BRANCH_STATE 25 126 127 /* 128 * Largest state on this machine: 129 * (be sure mach/machine/thread_state.h matches!) 130 */ 131 #define THREAD_MACHINE_STATE_MAX THREAD_STATE_MAX 132 133 /* 134 * VALID_THREAD_STATE_FLAVOR is a platform specific macro that when passed 135 * an exception flavor will return if that is a defined flavor for that 136 * platform. The macro must be manually updated to include all of the valid 137 * exception flavors as defined above. 138 */ 139 #define VALID_THREAD_STATE_FLAVOR(x) \ 140 ((x == x86_THREAD_STATE32) || \ 141 (x == x86_FLOAT_STATE32) || \ 142 (x == x86_EXCEPTION_STATE32) || \ 143 (x == x86_DEBUG_STATE32) || \ 144 (x == x86_THREAD_STATE64) || \ 145 (x == x86_THREAD_FULL_STATE64) || \ 146 (x == x86_FLOAT_STATE64) || \ 147 (x == x86_EXCEPTION_STATE64) || \ 148 (x == x86_DEBUG_STATE64) || \ 149 (x == x86_THREAD_STATE) || \ 150 (x == x86_FLOAT_STATE) || \ 151 (x == x86_EXCEPTION_STATE) || \ 152 (x == x86_DEBUG_STATE) || \ 153 (x == x86_AVX_STATE32) || \ 154 (x == x86_AVX_STATE64) || \ 155 (x == x86_AVX_STATE) || \ 156 (x == x86_AVX512_STATE32) || \ 157 (x == x86_AVX512_STATE64) || \ 158 (x == x86_AVX512_STATE) || \ 159 (x == x86_PAGEIN_STATE) || \ 160 (x == x86_INSTRUCTION_STATE) || \ 161 (x == x86_LAST_BRANCH_STATE) || \ 162 (x == THREAD_STATE_NONE)) 163 164 struct x86_state_hdr { 165 uint32_t flavor; 166 uint32_t count; 167 }; 168 typedef struct x86_state_hdr x86_state_hdr_t; 169 170 /* 171 * Default segment register values. 172 */ 173 174 #define USER_CODE_SELECTOR 0x0017 175 #define USER_DATA_SELECTOR 0x001f 176 #define KERN_CODE_SELECTOR 0x0008 177 #define KERN_DATA_SELECTOR 0x0010 178 179 /* 180 * to be deprecated in the future 181 */ 182 typedef _STRUCT_X86_THREAD_STATE32 i386_thread_state_t; 183 #define i386_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ 184 ( sizeof (i386_thread_state_t) / sizeof (int) )) 185 186 typedef _STRUCT_X86_THREAD_STATE32 x86_thread_state32_t; 187 #define x86_THREAD_STATE32_COUNT ((mach_msg_type_number_t) \ 188 ( sizeof (x86_thread_state32_t) / sizeof (int) )) 189 190 /* 191 * to be deprecated in the future 192 */ 193 typedef _STRUCT_X86_FLOAT_STATE32 i386_float_state_t; 194 #define i386_FLOAT_STATE_COUNT ((mach_msg_type_number_t) \ 195 (sizeof(i386_float_state_t)/sizeof(unsigned int))) 196 197 typedef _STRUCT_X86_FLOAT_STATE32 x86_float_state32_t; 198 #define x86_FLOAT_STATE32_COUNT ((mach_msg_type_number_t) \ 199 (sizeof(x86_float_state32_t)/sizeof(unsigned int))) 200 201 typedef _STRUCT_X86_AVX_STATE32 x86_avx_state32_t; 202 #define x86_AVX_STATE32_COUNT ((mach_msg_type_number_t) \ 203 (sizeof(x86_avx_state32_t)/sizeof(unsigned int))) 204 205 typedef _STRUCT_X86_AVX512_STATE32 x86_avx512_state32_t; 206 #define x86_AVX512_STATE32_COUNT ((mach_msg_type_number_t) \ 207 (sizeof(x86_avx512_state32_t)/sizeof(unsigned int))) 208 209 /* 210 * to be deprecated in the future 211 */ 212 typedef _STRUCT_X86_EXCEPTION_STATE32 i386_exception_state_t; 213 #define i386_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \ 214 ( sizeof (i386_exception_state_t) / sizeof (int) )) 215 216 typedef _STRUCT_X86_EXCEPTION_STATE32 x86_exception_state32_t; 217 #define x86_EXCEPTION_STATE32_COUNT ((mach_msg_type_number_t) \ 218 ( sizeof (x86_exception_state32_t) / sizeof (int) )) 219 220 #define I386_EXCEPTION_STATE_COUNT i386_EXCEPTION_STATE_COUNT 221 222 typedef _STRUCT_X86_DEBUG_STATE32 x86_debug_state32_t; 223 #define x86_DEBUG_STATE32_COUNT ((mach_msg_type_number_t) \ 224 ( sizeof (x86_debug_state32_t) / sizeof (int) )) 225 226 #define X86_DEBUG_STATE32_COUNT x86_DEBUG_STATE32_COUNT 227 228 typedef _STRUCT_X86_THREAD_STATE64 x86_thread_state64_t; 229 #define x86_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \ 230 ( sizeof (x86_thread_state64_t) / sizeof (int) )) 231 232 typedef _STRUCT_X86_THREAD_FULL_STATE64 x86_thread_full_state64_t; 233 #define x86_THREAD_FULL_STATE64_COUNT ((mach_msg_type_number_t) \ 234 ( sizeof (x86_thread_full_state64_t) / sizeof (int) )) 235 236 typedef _STRUCT_X86_FLOAT_STATE64 x86_float_state64_t; 237 #define x86_FLOAT_STATE64_COUNT ((mach_msg_type_number_t) \ 238 (sizeof(x86_float_state64_t)/sizeof(unsigned int))) 239 240 typedef _STRUCT_X86_AVX_STATE64 x86_avx_state64_t; 241 #define x86_AVX_STATE64_COUNT ((mach_msg_type_number_t) \ 242 (sizeof(x86_avx_state64_t)/sizeof(unsigned int))) 243 244 typedef _STRUCT_X86_AVX512_STATE64 x86_avx512_state64_t; 245 #define x86_AVX512_STATE64_COUNT ((mach_msg_type_number_t) \ 246 (sizeof(x86_avx512_state64_t)/sizeof(unsigned int))) 247 248 typedef _STRUCT_X86_EXCEPTION_STATE64 x86_exception_state64_t; 249 #define x86_EXCEPTION_STATE64_COUNT ((mach_msg_type_number_t) \ 250 ( sizeof (x86_exception_state64_t) / sizeof (int) )) 251 252 #define X86_EXCEPTION_STATE64_COUNT x86_EXCEPTION_STATE64_COUNT 253 254 typedef _STRUCT_X86_DEBUG_STATE64 x86_debug_state64_t; 255 #define x86_DEBUG_STATE64_COUNT ((mach_msg_type_number_t) \ 256 ( sizeof (x86_debug_state64_t) / sizeof (int) )) 257 258 #define X86_DEBUG_STATE64_COUNT x86_DEBUG_STATE64_COUNT 259 260 typedef _STRUCT_X86_PAGEIN_STATE x86_pagein_state_t; 261 #define x86_PAGEIN_STATE_COUNT \ 262 ((mach_msg_type_number_t)(sizeof(x86_pagein_state_t) / sizeof(int))) 263 264 #define X86_PAGEIN_STATE_COUNT x86_PAGEIN_STATE_COUNT 265 266 typedef _STRUCT_X86_INSTRUCTION_STATE x86_instruction_state_t; 267 #define x86_INSTRUCTION_STATE_COUNT \ 268 ((mach_msg_type_number_t)(sizeof(x86_instruction_state_t) / sizeof(int))) 269 270 #define X86_INSTRUCTION_STATE_COUNT x86_INSTRUCTION_STATE_COUNT 271 272 typedef _STRUCT_LAST_BRANCH_STATE last_branch_state_t; 273 #define x86_LAST_BRANCH_STATE_COUNT \ 274 ((mach_msg_type_number_t)(sizeof(last_branch_state_t) / sizeof(int))) 275 276 #define X86_LAST_BRANCH_STATE_COUNT x86_LAST_BRANCH_STATE_COUNT 277 278 279 /* 280 * Combined thread, float and exception states 281 */ 282 struct x86_thread_state { 283 x86_state_hdr_t tsh; 284 union { 285 x86_thread_state32_t ts32; 286 x86_thread_state64_t ts64; 287 } uts; 288 }; 289 290 struct x86_float_state { 291 x86_state_hdr_t fsh; 292 union { 293 x86_float_state32_t fs32; 294 x86_float_state64_t fs64; 295 } ufs; 296 }; 297 298 struct x86_exception_state { 299 x86_state_hdr_t esh; 300 union { 301 x86_exception_state32_t es32; 302 x86_exception_state64_t es64; 303 } ues; 304 }; 305 306 struct x86_debug_state { 307 x86_state_hdr_t dsh; 308 union { 309 x86_debug_state32_t ds32; 310 x86_debug_state64_t ds64; 311 } uds; 312 }; 313 314 struct x86_avx_state { 315 x86_state_hdr_t ash; 316 union { 317 x86_avx_state32_t as32; 318 x86_avx_state64_t as64; 319 } ufs; 320 }; 321 322 struct x86_avx512_state { 323 x86_state_hdr_t ash; 324 union { 325 x86_avx512_state32_t as32; 326 x86_avx512_state64_t as64; 327 } ufs; 328 }; 329 330 typedef struct x86_thread_state x86_thread_state_t; 331 #define x86_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ 332 ( sizeof (x86_thread_state_t) / sizeof (int) )) 333 334 typedef struct x86_float_state x86_float_state_t; 335 #define x86_FLOAT_STATE_COUNT ((mach_msg_type_number_t) \ 336 (sizeof(x86_float_state_t)/sizeof(unsigned int))) 337 338 typedef struct x86_exception_state x86_exception_state_t; 339 #define x86_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \ 340 (sizeof(x86_exception_state_t)/sizeof(unsigned int))) 341 342 typedef struct x86_debug_state x86_debug_state_t; 343 #define x86_DEBUG_STATE_COUNT ((mach_msg_type_number_t) \ 344 (sizeof(x86_debug_state_t)/sizeof(unsigned int))) 345 346 typedef struct x86_avx_state x86_avx_state_t; 347 #define x86_AVX_STATE_COUNT ((mach_msg_type_number_t) \ 348 (sizeof(x86_avx_state_t)/sizeof(unsigned int))) 349 350 typedef struct x86_avx512_state x86_avx512_state_t; 351 #define x86_AVX512_STATE_COUNT ((mach_msg_type_number_t) \ 352 (sizeof(x86_avx512_state_t)/sizeof(unsigned int))) 353 354 /* 355 * Machine-independent way for servers and Mach's exception mechanism to 356 * choose the most efficient state flavor for exception RPC's: 357 */ 358 #define MACHINE_THREAD_STATE x86_THREAD_STATE 359 #define MACHINE_THREAD_STATE_COUNT x86_THREAD_STATE_COUNT 360 361 362 #endif /* _MACH_I386_THREAD_STATUS_H_ */