xref: /xnu-12377.81.4/osfmk/mach/exception_types.h (revision 043036a2b3718f7f0be807e2870f8f47d3fa0796)
1*043036a2SApple OSS Distributions /*
2*043036a2SApple OSS Distributions  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3*043036a2SApple OSS Distributions  *
4*043036a2SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*043036a2SApple OSS Distributions  *
6*043036a2SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*043036a2SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*043036a2SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*043036a2SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*043036a2SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*043036a2SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*043036a2SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*043036a2SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*043036a2SApple OSS Distributions  *
15*043036a2SApple OSS Distributions  * Please obtain a copy of the License at
16*043036a2SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*043036a2SApple OSS Distributions  *
18*043036a2SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*043036a2SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*043036a2SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*043036a2SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*043036a2SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*043036a2SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*043036a2SApple OSS Distributions  * limitations under the License.
25*043036a2SApple OSS Distributions  *
26*043036a2SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*043036a2SApple OSS Distributions  */
28*043036a2SApple OSS Distributions /*
29*043036a2SApple OSS Distributions  * @OSF_COPYRIGHT@
30*043036a2SApple OSS Distributions  */
31*043036a2SApple OSS Distributions /*
32*043036a2SApple OSS Distributions  * Mach Operating System
33*043036a2SApple OSS Distributions  * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
34*043036a2SApple OSS Distributions  * All Rights Reserved.
35*043036a2SApple OSS Distributions  *
36*043036a2SApple OSS Distributions  * Permission to use, copy, modify and distribute this software and its
37*043036a2SApple OSS Distributions  * documentation is hereby granted, provided that both the copyright
38*043036a2SApple OSS Distributions  * notice and this permission notice appear in all copies of the
39*043036a2SApple OSS Distributions  * software, derivative works or modified versions, and any portions
40*043036a2SApple OSS Distributions  * thereof, and that both notices appear in supporting documentation.
41*043036a2SApple OSS Distributions  *
42*043036a2SApple OSS Distributions  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43*043036a2SApple OSS Distributions  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44*043036a2SApple OSS Distributions  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45*043036a2SApple OSS Distributions  *
46*043036a2SApple OSS Distributions  * Carnegie Mellon requests users of this software to return to
47*043036a2SApple OSS Distributions  *
48*043036a2SApple OSS Distributions  *  Software Distribution Coordinator  or  [email protected]
49*043036a2SApple OSS Distributions  *  School of Computer Science
50*043036a2SApple OSS Distributions  *  Carnegie Mellon University
51*043036a2SApple OSS Distributions  *  Pittsburgh PA 15213-3890
52*043036a2SApple OSS Distributions  *
53*043036a2SApple OSS Distributions  * any improvements or extensions that they make and grant Carnegie Mellon
54*043036a2SApple OSS Distributions  * the rights to redistribute these changes.
55*043036a2SApple OSS Distributions  */
56*043036a2SApple OSS Distributions /*
57*043036a2SApple OSS Distributions  */
58*043036a2SApple OSS Distributions 
59*043036a2SApple OSS Distributions #ifndef _MACH_EXCEPTION_TYPES_H_
60*043036a2SApple OSS Distributions #define _MACH_EXCEPTION_TYPES_H_
61*043036a2SApple OSS Distributions 
62*043036a2SApple OSS Distributions #include <mach/machine/exception.h>
63*043036a2SApple OSS Distributions 
64*043036a2SApple OSS Distributions /*
65*043036a2SApple OSS Distributions  *	Machine-independent exception definitions.
66*043036a2SApple OSS Distributions  */
67*043036a2SApple OSS Distributions 
68*043036a2SApple OSS Distributions #define EXC_BAD_ACCESS          1       /* Could not access memory */
69*043036a2SApple OSS Distributions /* Code contains kern_return_t describing error. */
70*043036a2SApple OSS Distributions /* Subcode contains bad memory address. */
71*043036a2SApple OSS Distributions 
72*043036a2SApple OSS Distributions #define EXC_BAD_INSTRUCTION     2       /* Instruction failed */
73*043036a2SApple OSS Distributions /* Illegal or undefined instruction or operand */
74*043036a2SApple OSS Distributions 
75*043036a2SApple OSS Distributions #define EXC_ARITHMETIC          3       /* Arithmetic exception */
76*043036a2SApple OSS Distributions /* Exact nature of exception is in code field */
77*043036a2SApple OSS Distributions 
78*043036a2SApple OSS Distributions #define EXC_EMULATION           4       /* Emulation instruction */
79*043036a2SApple OSS Distributions /* Emulation support instruction encountered */
80*043036a2SApple OSS Distributions /* Details in code and subcode fields	*/
81*043036a2SApple OSS Distributions 
82*043036a2SApple OSS Distributions #define EXC_SOFTWARE            5       /* Software generated exception */
83*043036a2SApple OSS Distributions /* Exact exception is in code field. */
84*043036a2SApple OSS Distributions /* Codes 0 - 0xFFFF reserved to hardware */
85*043036a2SApple OSS Distributions /* Codes 0x10000 - 0x1FFFF reserved for OS emulation (Unix) */
86*043036a2SApple OSS Distributions 
87*043036a2SApple OSS Distributions #define EXC_BREAKPOINT          6       /* Trace, breakpoint, etc. */
88*043036a2SApple OSS Distributions /* Details in code field. */
89*043036a2SApple OSS Distributions 
90*043036a2SApple OSS Distributions #define EXC_SYSCALL             7       /* System calls. */
91*043036a2SApple OSS Distributions 
92*043036a2SApple OSS Distributions #define EXC_MACH_SYSCALL        8       /* Mach system calls. */
93*043036a2SApple OSS Distributions 
94*043036a2SApple OSS Distributions #define EXC_RPC_ALERT           9       /* RPC alert */
95*043036a2SApple OSS Distributions 
96*043036a2SApple OSS Distributions #define EXC_CRASH               10      /* Abnormal process exit */
97*043036a2SApple OSS Distributions 
98*043036a2SApple OSS Distributions #define EXC_RESOURCE            11      /* Hit resource consumption limit */
99*043036a2SApple OSS Distributions /* Exact resource is in code field. */
100*043036a2SApple OSS Distributions 
101*043036a2SApple OSS Distributions #define EXC_GUARD               12      /* Violated guarded resource protections */
102*043036a2SApple OSS Distributions 
103*043036a2SApple OSS Distributions #define EXC_CORPSE_NOTIFY       13      /* Abnormal process exited to corpse state */
104*043036a2SApple OSS Distributions 
105*043036a2SApple OSS Distributions 
106*043036a2SApple OSS Distributions /*
107*043036a2SApple OSS Distributions  *	Machine-independent exception behaviors
108*043036a2SApple OSS Distributions  */
109*043036a2SApple OSS Distributions 
110*043036a2SApple OSS Distributions #define EXCEPTION_DEFAULT              1
111*043036a2SApple OSS Distributions /*	Send a catch_exception_raise message including the identity.
112*043036a2SApple OSS Distributions  */
113*043036a2SApple OSS Distributions 
114*043036a2SApple OSS Distributions #define EXCEPTION_STATE                2
115*043036a2SApple OSS Distributions /*	Send a catch_exception_raise_state message including the
116*043036a2SApple OSS Distributions  *	thread state.
117*043036a2SApple OSS Distributions  */
118*043036a2SApple OSS Distributions 
119*043036a2SApple OSS Distributions #define EXCEPTION_STATE_IDENTITY       3
120*043036a2SApple OSS Distributions /*	Send a catch_exception_raise_state_identity message including
121*043036a2SApple OSS Distributions  *	the thread identity and state.
122*043036a2SApple OSS Distributions  */
123*043036a2SApple OSS Distributions 
124*043036a2SApple OSS Distributions #define EXCEPTION_IDENTITY_PROTECTED   4
125*043036a2SApple OSS Distributions /*	Send a catch_exception_raise_identity_protected message including protected task
126*043036a2SApple OSS Distributions  *  and thread identity.
127*043036a2SApple OSS Distributions  */
128*043036a2SApple OSS Distributions 
129*043036a2SApple OSS Distributions #define EXCEPTION_STATE_IDENTITY_PROTECTED   5
130*043036a2SApple OSS Distributions /*	Send a catch_exception_raise_state_identity_protected message including protected task
131*043036a2SApple OSS Distributions  *  and thread identity plus the thread state.
132*043036a2SApple OSS Distributions  */
133*043036a2SApple OSS Distributions 
134*043036a2SApple OSS Distributions #define MACH_EXCEPTION_BACKTRACE_PREFERRED   0x20000000
135*043036a2SApple OSS Distributions /* Prefer sending a catch_exception_raise_backtrace message, if applicable */
136*043036a2SApple OSS Distributions 
137*043036a2SApple OSS Distributions #define MACH_EXCEPTION_ERRORS           0x40000000
138*043036a2SApple OSS Distributions /*	include additional exception specific errors, not used yet.  */
139*043036a2SApple OSS Distributions 
140*043036a2SApple OSS Distributions #define MACH_EXCEPTION_CODES            0x80000000
141*043036a2SApple OSS Distributions /*	Send 64-bit code and subcode in the exception header */
142*043036a2SApple OSS Distributions 
143*043036a2SApple OSS Distributions #define MACH_EXCEPTION_MASK             (MACH_EXCEPTION_CODES | \
144*043036a2SApple OSS Distributions 	                                    MACH_EXCEPTION_ERRORS | \
145*043036a2SApple OSS Distributions 	                                    MACH_EXCEPTION_BACKTRACE_PREFERRED)
146*043036a2SApple OSS Distributions /*
147*043036a2SApple OSS Distributions  * Masks for exception definitions, above
148*043036a2SApple OSS Distributions  * bit zero is unused, therefore 1 word = 31 exception types
149*043036a2SApple OSS Distributions  */
150*043036a2SApple OSS Distributions 
151*043036a2SApple OSS Distributions #define EXC_MASK_BAD_ACCESS             (1 << EXC_BAD_ACCESS)
152*043036a2SApple OSS Distributions #define EXC_MASK_BAD_INSTRUCTION        (1 << EXC_BAD_INSTRUCTION)
153*043036a2SApple OSS Distributions #define EXC_MASK_ARITHMETIC             (1 << EXC_ARITHMETIC)
154*043036a2SApple OSS Distributions #define EXC_MASK_EMULATION              (1 << EXC_EMULATION)
155*043036a2SApple OSS Distributions #define EXC_MASK_SOFTWARE               (1 << EXC_SOFTWARE)
156*043036a2SApple OSS Distributions #define EXC_MASK_BREAKPOINT             (1 << EXC_BREAKPOINT)
157*043036a2SApple OSS Distributions #define EXC_MASK_SYSCALL                (1 << EXC_SYSCALL)
158*043036a2SApple OSS Distributions #define EXC_MASK_MACH_SYSCALL           (1 << EXC_MACH_SYSCALL)
159*043036a2SApple OSS Distributions #define EXC_MASK_RPC_ALERT              (1 << EXC_RPC_ALERT)
160*043036a2SApple OSS Distributions #define EXC_MASK_CRASH                  (1 << EXC_CRASH)
161*043036a2SApple OSS Distributions #define EXC_MASK_RESOURCE               (1 << EXC_RESOURCE)
162*043036a2SApple OSS Distributions #define EXC_MASK_GUARD                  (1 << EXC_GUARD)
163*043036a2SApple OSS Distributions #define EXC_MASK_CORPSE_NOTIFY          (1 << EXC_CORPSE_NOTIFY)
164*043036a2SApple OSS Distributions 
165*043036a2SApple OSS Distributions #define EXC_MASK_ALL    (EXC_MASK_BAD_ACCESS |                  \
166*043036a2SApple OSS Distributions 	                 EXC_MASK_BAD_INSTRUCTION |             \
167*043036a2SApple OSS Distributions 	                 EXC_MASK_ARITHMETIC |                  \
168*043036a2SApple OSS Distributions 	                 EXC_MASK_EMULATION |                   \
169*043036a2SApple OSS Distributions 	                 EXC_MASK_SOFTWARE |                    \
170*043036a2SApple OSS Distributions 	                 EXC_MASK_BREAKPOINT |                  \
171*043036a2SApple OSS Distributions 	                 EXC_MASK_SYSCALL |                     \
172*043036a2SApple OSS Distributions 	                 EXC_MASK_MACH_SYSCALL |                \
173*043036a2SApple OSS Distributions 	                 EXC_MASK_RPC_ALERT |                   \
174*043036a2SApple OSS Distributions 	                 EXC_MASK_RESOURCE |                    \
175*043036a2SApple OSS Distributions 	                 EXC_MASK_GUARD |                       \
176*043036a2SApple OSS Distributions 	                 EXC_MASK_MACHINE)
177*043036a2SApple OSS Distributions 
178*043036a2SApple OSS Distributions #ifdef  KERNEL_PRIVATE
179*043036a2SApple OSS Distributions #define EXC_MASK_VALID  (EXC_MASK_ALL | EXC_MASK_CRASH | EXC_MASK_CORPSE_NOTIFY)
180*043036a2SApple OSS Distributions 
181*043036a2SApple OSS Distributions /*
182*043036a2SApple OSS Distributions  * Additional mask for use with EXC_BREAKPOINT.
183*043036a2SApple OSS Distributions  * Note this is used just while the exception is shuffled around within xnu.
184*043036a2SApple OSS Distributions  * It's wiped off before we reach exception_triage_thread().
185*043036a2SApple OSS Distributions  */
186*043036a2SApple OSS Distributions #define EXC_MAY_BE_UNRECOVERABLE_BIT    0x400   /* Set if this exception may be uncatchable by userspace */
187*043036a2SApple OSS Distributions #endif /* KERNEL_PRIVATE */
188*043036a2SApple OSS Distributions 
189*043036a2SApple OSS Distributions #define FIRST_EXCEPTION         1       /* ZERO is illegal */
190*043036a2SApple OSS Distributions 
191*043036a2SApple OSS Distributions /*
192*043036a2SApple OSS Distributions  * Machine independent codes for EXC_SOFTWARE
193*043036a2SApple OSS Distributions  * Codes 0x10000 - 0x1FFFF reserved for OS emulation (Unix)
194*043036a2SApple OSS Distributions  * 0x10000 - 0x10002 in use for unix signals
195*043036a2SApple OSS Distributions  * 0x20000 - 0x2FFFF reserved for MACF
196*043036a2SApple OSS Distributions  */
197*043036a2SApple OSS Distributions #define EXC_SOFT_SIGNAL         0x10003 /* Unix signal exceptions */
198*043036a2SApple OSS Distributions 
199*043036a2SApple OSS Distributions #define EXC_MACF_MIN            0x20000 /* MACF exceptions */
200*043036a2SApple OSS Distributions #define EXC_MACF_MAX            0x2FFFF
201*043036a2SApple OSS Distributions 
202*043036a2SApple OSS Distributions #ifndef ASSEMBLER
203*043036a2SApple OSS Distributions 
204*043036a2SApple OSS Distributions #include <mach/port.h>
205*043036a2SApple OSS Distributions #include <mach/thread_status.h>
206*043036a2SApple OSS Distributions #include <mach/machine/vm_types.h>
207*043036a2SApple OSS Distributions #include <mach_debug/ipc_info.h>
208*043036a2SApple OSS Distributions /*
209*043036a2SApple OSS Distributions  * Exported types
210*043036a2SApple OSS Distributions  */
211*043036a2SApple OSS Distributions 
212*043036a2SApple OSS Distributions typedef int                             exception_type_t;
213*043036a2SApple OSS Distributions typedef integer_t                       exception_data_type_t;
214*043036a2SApple OSS Distributions typedef int64_t                         mach_exception_data_type_t;
215*043036a2SApple OSS Distributions typedef int                             exception_behavior_t;
216*043036a2SApple OSS Distributions typedef exception_data_type_t           *exception_data_t;
217*043036a2SApple OSS Distributions typedef mach_exception_data_type_t      *mach_exception_data_t;
218*043036a2SApple OSS Distributions typedef unsigned int                    exception_mask_t;
219*043036a2SApple OSS Distributions typedef exception_mask_t                *exception_mask_array_t;
220*043036a2SApple OSS Distributions typedef exception_behavior_t            *exception_behavior_array_t;
221*043036a2SApple OSS Distributions typedef thread_state_flavor_t           *exception_flavor_array_t;
222*043036a2SApple OSS Distributions typedef mach_port_t                     *exception_port_array_t;
223*043036a2SApple OSS Distributions typedef ipc_info_port_t                 *exception_port_info_array_t;
224*043036a2SApple OSS Distributions typedef mach_exception_data_type_t      mach_exception_code_t;
225*043036a2SApple OSS Distributions typedef mach_exception_data_type_t      mach_exception_subcode_t;
226*043036a2SApple OSS Distributions 
227*043036a2SApple OSS Distributions #endif  /* ASSEMBLER */
228*043036a2SApple OSS Distributions 
229*043036a2SApple OSS Distributions #endif  /* _MACH_EXCEPTION_TYPES_H_ */
230