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