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