1 /* $NetBSD: mach_exception.h,v 1.4 2005/02/26 23:10:19 perry Exp $ */
2
3 /*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Emmanuel Dreyfus
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifndef _MACH_EXCEPTION_H_
40 #define _MACH_EXCEPTION_H_
41
42 #define MACH_EXC_BAD_ACCESS 1
43 #define MACH_EXC_BAD_INSTRUCTION 2
44 #define MACH_EXC_ARITHMETIC 3
45 #define MACH_EXC_EMULATION 4
46 #define MACH_EXC_SOFTWARE 5
47 #define MACH_EXC_BREAKPOINT 6
48 #define MACH_EXC_SYSCALL 7
49 #define MACH_EXC_MACH_SYSCALL 8
50 #define MACH_EXC_RPC_ALERT 9
51 #define MACH_EXC_MAX MACH_EXC_RPC_ALERT
52
53 #define MACH_EXC_MASK_BAD_ACCESS (1 << MACH_EXC_BAD_ACCESS)
54 #define MACH_EXC_MASK_BAD_INSTRUCTION (1 << MACH_EXC_BAD_INSTRUCTION)
55 #define MACH_EXC_MASK_ARITHMETIC (1 << MACH_EXC_ARITHMETIC)
56 #define MACH_EXC_MASK_EMULATION (1 << MACH_EXC_EMULATION)
57 #define MACH_EXC_MASK_SOFTWARE (1 << MACH_EXC_SOFTWARE)
58 #define MACH_EXC_MASK_BREAKPOINT (1 << MACH_EXC_BREAKPOINT)
59 #define MACH_EXC_MASK_SYSCALL (1 << MACH_EXC_SYSCALL)
60 #define MACH_EXC_MASK_MACH_SYSCALL (1 << MACH_EXC_MACH_SYSCALL)
61 #define MACH_EXC_MASK_RPC_ALERT (1 << MACH_EXC_RPC_ALERT)
62
63 /*
64 * Exception codes. Values < 0x10000 are machine dependent, and
65 * are defined in sys/<arch>/include/mach_machdep.h.
66 */
67 #define MACH_EXC_UNIX_BAD_SYSCALL 0x10000 /* unused ? */
68 #define MACH_EXC_UNIX_BAD_PIPE 0x10001 /* unused ? */
69 #define MACH_EXC_UNIX_ABORT 0x10002 /* unused ? */
70 #define MACH_SOFT_SIGNAL 0x10003
71
72 /* Exception behaviors and associated messages Id */
73
74 #define MACH_EXCEPTION_DEFAULT 1
75 #define MACH_EXCEPTION_STATE 2
76 #define MACH_EXCEPTION_STATE_IDENTITY 3
77
78 #define MACH_EXC_RAISE_MSGID 2401
79 #define MACH_EXC_RAISE_STATE_MSGID 2402
80 #define MACH_EXC_RAISE_STATE_IDENTITY_MSGID 2403
81
82 /* exception_raise. The kernel is the client, not the server */
83
84 typedef struct {
85 mach_msg_header_t req_msgh;
86 mach_msg_body_t req_body;
87 mach_msg_port_descriptor_t req_thread;
88 mach_msg_port_descriptor_t req_task;
89 mach_ndr_record_t req_ndr;
90 mach_exception_type_t req_exc;
91 mach_msg_type_number_t req_codecount;
92 mach_integer_t req_code[2];
93 mach_msg_trailer_t req_trailer;
94 } mach_exception_raise_request_t;
95
96 typedef struct {
97 mach_msg_header_t rep_msgh;
98 mach_ndr_record_t rep_ndr;
99 mach_kern_return_t rep_retval;
100 } mach_exception_raise_reply_t;
101
102 /* exception_raise_state. The kernel is the client, not the server */
103
104 typedef struct {
105 mach_msg_header_t req_msgh;
106 mach_ndr_record_t req_ndr;
107 mach_exception_type_t req_exc;
108 mach_msg_type_number_t req_codecount;
109 mach_integer_t req_code[2];
110 int req_flavor;
111 mach_msg_type_number_t req_statecount;
112 mach_natural_t req_state[144];
113 mach_msg_trailer_t req_trailer;
114 } mach_exception_raise_state_request_t;
115
116 typedef struct {
117 mach_msg_header_t rep_msgh;
118 mach_ndr_record_t rep_ndr;
119 mach_kern_return_t rep_retval;
120 } mach_exception_raise_state_reply_t;
121
122 /* exception_raise_state_identity. The kernel is the client, not the server */
123
124 typedef struct {
125 mach_msg_header_t req_msgh;
126 mach_msg_body_t req_body;
127 mach_msg_port_descriptor_t req_thread;
128 mach_msg_port_descriptor_t req_task;
129 mach_ndr_record_t req_ndr;
130 mach_exception_type_t req_exc;
131 mach_msg_type_number_t req_codecount;
132 mach_integer_t req_code[2];
133 int req_flavor;
134 mach_msg_type_number_t req_statecount;
135 mach_natural_t req_state[144];
136 mach_msg_trailer_t req_trailer;
137 } mach_exception_raise_state_identity_request_t;
138
139 typedef struct {
140 mach_msg_header_t rep_msgh;
141 mach_ndr_record_t rep_ndr;
142 mach_kern_return_t rep_retval;
143 } mach_exception_raise_state_identity_reply_t;
144
145 struct mach_exc_info {
146 int mei_flavor;
147 int mei_behavior;
148 };
149
150 void mach_trapsignal(struct lwp *, const struct ksiginfo *);
151 int mach_trapsignal1(struct lwp *, const struct ksiginfo *);
152 int mach_exception(struct lwp *, int, int *);
153
154 #endif /* _MACH_EXCEPTION_H_ */
155
Cache object: 3e01f5ac858d5ee9334f6ec1b51ea819
|