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