1 | #ifndef _exc_server_ |
2 | #define _exc_server_ |
3 | |
4 | /* Module exc */ |
5 | |
6 | #include <string.h> |
7 | #include <mach/ndr.h> |
8 | #include <mach/boolean.h> |
9 | #include <mach/kern_return.h> |
10 | #include <mach/notify.h> |
11 | #include <mach/mach_types.h> |
12 | #include <mach/message.h> |
13 | #include <mach/mig_errors.h> |
14 | #include <mach/port.h> |
15 | |
16 | /* BEGIN MIG_STRNCPY_ZEROFILL CODE */ |
17 | |
18 | #if defined(__has_include) |
19 | #if __has_include(<mach/mig_strncpy_zerofill_support.h>) |
20 | #ifndef USING_MIG_STRNCPY_ZEROFILL |
21 | #define USING_MIG_STRNCPY_ZEROFILL |
22 | #endif |
23 | #ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ |
24 | #define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ |
25 | #ifdef __cplusplus |
26 | extern "C" { |
27 | #endif |
28 | extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import)); |
29 | #ifdef __cplusplus |
30 | } |
31 | #endif |
32 | #endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */ |
33 | #endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */ |
34 | #endif /* __has_include */ |
35 | |
36 | /* END MIG_STRNCPY_ZEROFILL CODE */ |
37 | |
38 | |
39 | #ifdef AUTOTEST |
40 | #ifndef FUNCTION_PTR_T |
41 | #define FUNCTION_PTR_T |
42 | typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); |
43 | typedef struct { |
44 | char *name; |
45 | function_ptr_t function; |
46 | } function_table_entry; |
47 | typedef function_table_entry *function_table_t; |
48 | #endif /* FUNCTION_PTR_T */ |
49 | #endif /* AUTOTEST */ |
50 | |
51 | #ifndef exc_MSG_COUNT |
52 | #define exc_MSG_COUNT 3 |
53 | #endif /* exc_MSG_COUNT */ |
54 | |
55 | #include <mach/std_types.h> |
56 | #include <mach/mig.h> |
57 | #include <ipc/ipc_voucher.h> |
58 | #include <kern/ipc_kobject.h> |
59 | #include <kern/ipc_tt.h> |
60 | #include <kern/ipc_host.h> |
61 | #include <kern/ipc_sync.h> |
62 | #include <kern/ledger.h> |
63 | #include <kern/processor.h> |
64 | #include <kern/sync_lock.h> |
65 | #include <kern/sync_sema.h> |
66 | #include <vm/memory_object.h> |
67 | #include <vm/vm_map.h> |
68 | #include <kern/ipc_mig.h> |
69 | #include <mach/mig.h> |
70 | #include <mach/mach_types.h> |
71 | |
72 | #ifdef __BeforeMigServerHeader |
73 | __BeforeMigServerHeader |
74 | #endif /* __BeforeMigServerHeader */ |
75 | |
76 | |
77 | /* Routine exception_raise */ |
78 | #ifdef mig_external |
79 | mig_external |
80 | #else |
81 | extern |
82 | #endif /* mig_external */ |
83 | kern_return_t catch_exception_raise |
84 | ( |
85 | mach_port_t exception_port, |
86 | mach_port_t thread, |
87 | mach_port_t task, |
88 | exception_type_t exception, |
89 | exception_data_t code, |
90 | mach_msg_type_number_t codeCnt |
91 | ); |
92 | |
93 | /* Routine exception_raise_state */ |
94 | #ifdef mig_external |
95 | mig_external |
96 | #else |
97 | extern |
98 | #endif /* mig_external */ |
99 | kern_return_t catch_exception_raise_state |
100 | ( |
101 | mach_port_t exception_port, |
102 | exception_type_t exception, |
103 | const exception_data_t code, |
104 | mach_msg_type_number_t codeCnt, |
105 | int *flavor, |
106 | const thread_state_t old_state, |
107 | mach_msg_type_number_t old_stateCnt, |
108 | thread_state_t new_state, |
109 | mach_msg_type_number_t *new_stateCnt |
110 | ); |
111 | |
112 | /* Routine exception_raise_state_identity */ |
113 | #ifdef mig_external |
114 | mig_external |
115 | #else |
116 | extern |
117 | #endif /* mig_external */ |
118 | kern_return_t catch_exception_raise_state_identity |
119 | ( |
120 | mach_port_t exception_port, |
121 | mach_port_t thread, |
122 | mach_port_t task, |
123 | exception_type_t exception, |
124 | exception_data_t code, |
125 | mach_msg_type_number_t codeCnt, |
126 | int *flavor, |
127 | thread_state_t old_state, |
128 | mach_msg_type_number_t old_stateCnt, |
129 | thread_state_t new_state, |
130 | mach_msg_type_number_t *new_stateCnt |
131 | ); |
132 | |
133 | #ifdef mig_external |
134 | mig_external |
135 | #else |
136 | extern |
137 | #endif /* mig_external */ |
138 | boolean_t exc_server( |
139 | mach_msg_header_t *InHeadP, |
140 | mach_msg_header_t *OutHeadP); |
141 | |
142 | #ifdef mig_external |
143 | mig_external |
144 | #else |
145 | extern |
146 | #endif /* mig_external */ |
147 | mig_routine_t exc_server_routine( |
148 | mach_msg_header_t *InHeadP); |
149 | |
150 | |
151 | /* Description of this subsystem, for use in direct RPC */ |
152 | extern const struct catch_exc_subsystem { |
153 | mig_server_routine_t server; /* Server routine */ |
154 | mach_msg_id_t start; /* Min routine number */ |
155 | mach_msg_id_t end; /* Max routine number + 1 */ |
156 | unsigned int maxsize; /* Max msg size */ |
157 | vm_address_t reserved; /* Reserved */ |
158 | struct routine_descriptor /*Array of routine descriptors */ |
159 | routine[3]; |
160 | } catch_exc_subsystem; |
161 | |
162 | /* typedefs for all requests */ |
163 | |
164 | #ifndef __Request__exc_subsystem__defined |
165 | #define __Request__exc_subsystem__defined |
166 | |
167 | #ifdef __MigPackStructs |
168 | #pragma pack(4) |
169 | #endif |
170 | typedef struct { |
171 | mach_msg_header_t Head; |
172 | /* start of the kernel processed data */ |
173 | mach_msg_body_t msgh_body; |
174 | mach_msg_port_descriptor_t thread; |
175 | mach_msg_port_descriptor_t task; |
176 | /* end of the kernel processed data */ |
177 | NDR_record_t NDR; |
178 | exception_type_t exception; |
179 | mach_msg_type_number_t codeCnt; |
180 | integer_t code[2]; |
181 | } __Request__exception_raise_t __attribute__((unused)); |
182 | #ifdef __MigPackStructs |
183 | #pragma pack() |
184 | #endif |
185 | |
186 | #ifdef __MigPackStructs |
187 | #pragma pack(4) |
188 | #endif |
189 | typedef struct { |
190 | mach_msg_header_t Head; |
191 | NDR_record_t NDR; |
192 | exception_type_t exception; |
193 | mach_msg_type_number_t codeCnt; |
194 | integer_t code[2]; |
195 | int flavor; |
196 | mach_msg_type_number_t old_stateCnt; |
197 | natural_t old_state[614]; |
198 | } __Request__exception_raise_state_t __attribute__((unused)); |
199 | #ifdef __MigPackStructs |
200 | #pragma pack() |
201 | #endif |
202 | |
203 | #ifdef __MigPackStructs |
204 | #pragma pack(4) |
205 | #endif |
206 | typedef struct { |
207 | mach_msg_header_t Head; |
208 | /* start of the kernel processed data */ |
209 | mach_msg_body_t msgh_body; |
210 | mach_msg_port_descriptor_t thread; |
211 | mach_msg_port_descriptor_t task; |
212 | /* end of the kernel processed data */ |
213 | NDR_record_t NDR; |
214 | exception_type_t exception; |
215 | mach_msg_type_number_t codeCnt; |
216 | integer_t code[2]; |
217 | int flavor; |
218 | mach_msg_type_number_t old_stateCnt; |
219 | natural_t old_state[614]; |
220 | } __Request__exception_raise_state_identity_t __attribute__((unused)); |
221 | #ifdef __MigPackStructs |
222 | #pragma pack() |
223 | #endif |
224 | #endif /* !__Request__exc_subsystem__defined */ |
225 | |
226 | |
227 | /* union of all requests */ |
228 | |
229 | #ifndef __RequestUnion__catch_exc_subsystem__defined |
230 | #define __RequestUnion__catch_exc_subsystem__defined |
231 | union __RequestUnion__catch_exc_subsystem { |
232 | __Request__exception_raise_t Request_exception_raise; |
233 | __Request__exception_raise_state_t Request_exception_raise_state; |
234 | __Request__exception_raise_state_identity_t Request_exception_raise_state_identity; |
235 | }; |
236 | #endif /* __RequestUnion__catch_exc_subsystem__defined */ |
237 | /* typedefs for all replies */ |
238 | |
239 | #ifndef __Reply__exc_subsystem__defined |
240 | #define __Reply__exc_subsystem__defined |
241 | |
242 | #ifdef __MigPackStructs |
243 | #pragma pack(4) |
244 | #endif |
245 | typedef struct { |
246 | mach_msg_header_t Head; |
247 | NDR_record_t NDR; |
248 | kern_return_t RetCode; |
249 | } __Reply__exception_raise_t __attribute__((unused)); |
250 | #ifdef __MigPackStructs |
251 | #pragma pack() |
252 | #endif |
253 | |
254 | #ifdef __MigPackStructs |
255 | #pragma pack(4) |
256 | #endif |
257 | typedef struct { |
258 | mach_msg_header_t Head; |
259 | NDR_record_t NDR; |
260 | kern_return_t RetCode; |
261 | int flavor; |
262 | mach_msg_type_number_t new_stateCnt; |
263 | natural_t new_state[614]; |
264 | } __Reply__exception_raise_state_t __attribute__((unused)); |
265 | #ifdef __MigPackStructs |
266 | #pragma pack() |
267 | #endif |
268 | |
269 | #ifdef __MigPackStructs |
270 | #pragma pack(4) |
271 | #endif |
272 | typedef struct { |
273 | mach_msg_header_t Head; |
274 | NDR_record_t NDR; |
275 | kern_return_t RetCode; |
276 | int flavor; |
277 | mach_msg_type_number_t new_stateCnt; |
278 | natural_t new_state[614]; |
279 | } __Reply__exception_raise_state_identity_t __attribute__((unused)); |
280 | #ifdef __MigPackStructs |
281 | #pragma pack() |
282 | #endif |
283 | #endif /* !__Reply__exc_subsystem__defined */ |
284 | |
285 | |
286 | /* union of all replies */ |
287 | |
288 | #ifndef __ReplyUnion__catch_exc_subsystem__defined |
289 | #define __ReplyUnion__catch_exc_subsystem__defined |
290 | union __ReplyUnion__catch_exc_subsystem { |
291 | __Reply__exception_raise_t Reply_exception_raise; |
292 | __Reply__exception_raise_state_t Reply_exception_raise_state; |
293 | __Reply__exception_raise_state_identity_t Reply_exception_raise_state_identity; |
294 | }; |
295 | #endif /* __RequestUnion__catch_exc_subsystem__defined */ |
296 | |
297 | #ifndef subsystem_to_name_map_exc |
298 | #define subsystem_to_name_map_exc \ |
299 | { "exception_raise", 2401 },\ |
300 | { "exception_raise_state", 2402 },\ |
301 | { "exception_raise_state_identity", 2403 } |
302 | #endif |
303 | |
304 | #ifdef __AfterMigServerHeader |
305 | __AfterMigServerHeader |
306 | #endif /* __AfterMigServerHeader */ |
307 | |
308 | #endif /* _exc_server_ */ |
309 | |