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
26extern "C" {
27#endif
28#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS_CSTRING_ATTR
29#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS_CSTRING_COUNTEDBY_ATTR(C) __unsafe_indexable
30#endif
31 extern int mig_strncpy_zerofill(char * dest, const char * src, int len) __attribute__((weak_import));
32#ifdef __cplusplus
33}
34#endif
35#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */
36#endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */
37#endif /* __has_include */
38
39/* END MIG_STRNCPY_ZEROFILL CODE */
40
41
42#ifdef AUTOTEST
43#ifndef FUNCTION_PTR_T
44#define FUNCTION_PTR_T
45typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t);
46typedef struct {
47 char * name;
48 function_ptr_t function;
49} function_table_entry;
50typedef function_table_entry *function_table_t;
51#endif /* FUNCTION_PTR_T */
52#endif /* AUTOTEST */
53
54#ifndef exc_MSG_COUNT
55#define exc_MSG_COUNT 3
56#endif /* exc_MSG_COUNT */
57
58#include <Availability.h>
59#include <mach/std_types.h>
60#include <mach/mig.h>
61#include <ipc/ipc_voucher.h>
62#include <kern/ipc_kobject.h>
63#include <kern/ipc_tt.h>
64#include <kern/ipc_host.h>
65#include <kern/ledger.h>
66#include <kern/processor.h>
67#include <kern/sync_sema.h>
68#include <ipc/ipc_eventlink.h>
69#include <vm/memory_object.h>
70#include <vm/vm_map.h>
71#include <kern/arcade.h>
72#include <kern/ipc_mig.h>
73#include <kern/task_ident.h>
74#include <kern/kern_cdata.h>
75#include <mach/mig.h>
76#include <mach/mach_types.h>
77
78#ifdef __BeforeMigServerHeader
79__BeforeMigServerHeader
80#endif /* __BeforeMigServerHeader */
81
82#ifndef MIG_SERVER_ROUTINE
83#define MIG_SERVER_ROUTINE
84#endif
85
86
87/* Routine exception_raise */
88#ifdef mig_external
89mig_external
90#else
91extern
92#endif /* mig_external */
93MIG_SERVER_ROUTINE
94kern_return_t catch_exception_raise
95(
96 mach_port_t exception_port,
97 mach_port_t thread,
98 mach_port_t task,
99 exception_type_t exception,
100 exception_data_t code,
101 mach_msg_type_number_t codeCnt
102);
103
104/* Routine exception_raise_state */
105#ifdef mig_external
106mig_external
107#else
108extern
109#endif /* mig_external */
110MIG_SERVER_ROUTINE
111kern_return_t catch_exception_raise_state
112(
113 mach_port_t exception_port,
114 exception_type_t exception,
115 const exception_data_t code,
116 mach_msg_type_number_t codeCnt,
117 int *flavor,
118 const thread_state_t old_state,
119 mach_msg_type_number_t old_stateCnt,
120 thread_state_t new_state,
121 mach_msg_type_number_t *new_stateCnt
122);
123
124/* Routine exception_raise_state_identity */
125#ifdef mig_external
126mig_external
127#else
128extern
129#endif /* mig_external */
130MIG_SERVER_ROUTINE
131kern_return_t catch_exception_raise_state_identity
132(
133 mach_port_t exception_port,
134 mach_port_t thread,
135 mach_port_t task,
136 exception_type_t exception,
137 exception_data_t code,
138 mach_msg_type_number_t codeCnt,
139 int *flavor,
140 thread_state_t old_state,
141 mach_msg_type_number_t old_stateCnt,
142 thread_state_t new_state,
143 mach_msg_type_number_t *new_stateCnt
144);
145
146#ifdef mig_external
147mig_external
148#else
149extern
150#endif /* mig_external */
151boolean_t exc_server(
152 mach_msg_header_t *InHeadP,
153 void *InDataP,
154 mach_msg_max_trailer_t *InTrailerP,
155 mach_msg_header_t *OutHeadP,
156 void *OutDataP);
157
158#ifdef mig_external
159mig_external
160#else
161extern
162#endif /* mig_external */
163mig_kern_routine_t exc_server_routine(
164 mach_msg_header_t *InHeadP);
165
166
167/* Description of this kernel subsystem, for use in direct RPC */
168extern const struct catch_exc_subsystem {
169 mig_kern_server_routine_t kserver; /* Server routine */
170 mach_msg_id_t start; /* Min routine number */
171 mach_msg_id_t end; /* Max routine number + 1 */
172 unsigned int maxsize; /* Max msg size */
173 vm_address_t reserved; /* Reserved */
174 struct kern_routine_descriptor /* Array of routine descriptors */
175 kroutine[3];
176} catch_exc_subsystem;
177
178/* typedefs for all requests */
179
180#ifndef __Request__exc_subsystem__defined
181#define __Request__exc_subsystem__defined
182
183#ifdef __MigPackStructs
184#pragma pack(push, 4)
185#endif
186 typedef struct {
187 mach_msg_header_t Head;
188 /* start of the kernel processed data */
189 mach_msg_body_t msgh_body;
190 mach_msg_port_descriptor_t thread;
191 mach_msg_port_descriptor_t task;
192 /* end of the kernel processed data */
193 NDR_record_t NDR;
194 exception_type_t exception;
195 mach_msg_type_number_t codeCnt;
196 integer_t code[2];
197 } __Request__exception_raise_t __attribute__((unused));
198#ifdef __MigPackStructs
199#pragma pack(pop)
200#endif
201/* Struct for kernel processed data (Header + Descriptors) */
202#ifdef __MigPackStructs
203#pragma pack(push, 4)
204#endif
205 typedef struct {
206 mach_msg_header_t Head;
207 mach_msg_body_t msgh_body;
208 mach_msg_port_descriptor_t thread;
209 mach_msg_port_descriptor_t task;
210 } __RequestKData__exception_raise_t __attribute__((unused));
211#ifdef __MigPackStructs
212#pragma pack(pop)
213#endif
214/* Struct for pure user data */
215#ifdef __MigPackStructs
216#pragma pack(push, 4)
217#endif
218 typedef struct {
219 NDR_record_t NDR;
220 exception_type_t exception;
221 mach_msg_type_number_t codeCnt;
222 integer_t code[2];
223 char padding[0]; /* Avoid generating empty UData structs */
224 } __RequestUData__exception_raise_t __attribute__((unused));
225#ifdef __MigPackStructs
226#pragma pack(pop)
227#endif
228
229#ifdef __MigPackStructs
230#pragma pack(push, 4)
231#endif
232 typedef struct {
233 mach_msg_header_t Head;
234 NDR_record_t NDR;
235 exception_type_t exception;
236 mach_msg_type_number_t codeCnt;
237 integer_t code[2];
238 int flavor;
239 mach_msg_type_number_t old_stateCnt;
240 natural_t old_state[1296];
241 } __Request__exception_raise_state_t __attribute__((unused));
242#ifdef __MigPackStructs
243#pragma pack(pop)
244#endif
245/* Struct for kernel processed data (Header + Descriptors) */
246#ifdef __MigPackStructs
247#pragma pack(push, 4)
248#endif
249 typedef struct {
250 mach_msg_header_t Head;
251 } __RequestKData__exception_raise_state_t __attribute__((unused));
252#ifdef __MigPackStructs
253#pragma pack(pop)
254#endif
255/* Struct for pure user data */
256#ifdef __MigPackStructs
257#pragma pack(push, 4)
258#endif
259 typedef struct {
260 NDR_record_t NDR;
261 exception_type_t exception;
262 mach_msg_type_number_t codeCnt;
263 integer_t code[2];
264 int flavor;
265 mach_msg_type_number_t old_stateCnt;
266 natural_t old_state[1296];
267 char padding[0]; /* Avoid generating empty UData structs */
268 } __RequestUData__exception_raise_state_t __attribute__((unused));
269#ifdef __MigPackStructs
270#pragma pack(pop)
271#endif
272
273#ifdef __MigPackStructs
274#pragma pack(push, 4)
275#endif
276 typedef struct {
277 mach_msg_header_t Head;
278 /* start of the kernel processed data */
279 mach_msg_body_t msgh_body;
280 mach_msg_port_descriptor_t thread;
281 mach_msg_port_descriptor_t task;
282 /* end of the kernel processed data */
283 NDR_record_t NDR;
284 exception_type_t exception;
285 mach_msg_type_number_t codeCnt;
286 integer_t code[2];
287 int flavor;
288 mach_msg_type_number_t old_stateCnt;
289 natural_t old_state[1296];
290 } __Request__exception_raise_state_identity_t __attribute__((unused));
291#ifdef __MigPackStructs
292#pragma pack(pop)
293#endif
294/* Struct for kernel processed data (Header + Descriptors) */
295#ifdef __MigPackStructs
296#pragma pack(push, 4)
297#endif
298 typedef struct {
299 mach_msg_header_t Head;
300 mach_msg_body_t msgh_body;
301 mach_msg_port_descriptor_t thread;
302 mach_msg_port_descriptor_t task;
303 } __RequestKData__exception_raise_state_identity_t __attribute__((unused));
304#ifdef __MigPackStructs
305#pragma pack(pop)
306#endif
307/* Struct for pure user data */
308#ifdef __MigPackStructs
309#pragma pack(push, 4)
310#endif
311 typedef struct {
312 NDR_record_t NDR;
313 exception_type_t exception;
314 mach_msg_type_number_t codeCnt;
315 integer_t code[2];
316 int flavor;
317 mach_msg_type_number_t old_stateCnt;
318 natural_t old_state[1296];
319 char padding[0]; /* Avoid generating empty UData structs */
320 } __RequestUData__exception_raise_state_identity_t __attribute__((unused));
321#ifdef __MigPackStructs
322#pragma pack(pop)
323#endif
324#endif /* !__Request__exc_subsystem__defined */
325
326
327/* union of all requests */
328
329#ifndef __RequestUnion__catch_exc_subsystem__defined
330#define __RequestUnion__catch_exc_subsystem__defined
331union __RequestUnion__catch_exc_subsystem {
332 __Request__exception_raise_t Request_exception_raise;
333 __Request__exception_raise_state_t Request_exception_raise_state;
334 __Request__exception_raise_state_identity_t Request_exception_raise_state_identity;
335};
336#endif /* __RequestUnion__catch_exc_subsystem__defined */
337/* typedefs for all replies */
338
339#ifndef __Reply__exc_subsystem__defined
340#define __Reply__exc_subsystem__defined
341
342#ifdef __MigPackStructs
343#pragma pack(push, 4)
344#endif
345 typedef struct {
346 mach_msg_header_t Head;
347 NDR_record_t NDR;
348 kern_return_t RetCode;
349 } __Reply__exception_raise_t __attribute__((unused));
350#ifdef __MigPackStructs
351#pragma pack(pop)
352#endif
353/* Struct for kernel processed data (Header + Descriptors) */
354#ifdef __MigPackStructs
355#pragma pack(push, 4)
356#endif
357 typedef struct {
358 mach_msg_header_t Head;
359 } __ReplyKData__exception_raise_t __attribute__((unused));
360#ifdef __MigPackStructs
361#pragma pack(pop)
362#endif
363/* Struct for pure user data */
364#ifdef __MigPackStructs
365#pragma pack(push, 4)
366#endif
367 typedef struct {
368 NDR_record_t NDR;
369 kern_return_t RetCode;
370 char padding[0]; /* Avoid generating empty UData structs */
371 } __ReplyUData__exception_raise_t __attribute__((unused));
372#ifdef __MigPackStructs
373#pragma pack(pop)
374#endif
375
376#ifdef __MigPackStructs
377#pragma pack(push, 4)
378#endif
379 typedef struct {
380 mach_msg_header_t Head;
381 NDR_record_t NDR;
382 kern_return_t RetCode;
383 int flavor;
384 mach_msg_type_number_t new_stateCnt;
385 natural_t new_state[1296];
386 } __Reply__exception_raise_state_t __attribute__((unused));
387#ifdef __MigPackStructs
388#pragma pack(pop)
389#endif
390/* Struct for kernel processed data (Header + Descriptors) */
391#ifdef __MigPackStructs
392#pragma pack(push, 4)
393#endif
394 typedef struct {
395 mach_msg_header_t Head;
396 } __ReplyKData__exception_raise_state_t __attribute__((unused));
397#ifdef __MigPackStructs
398#pragma pack(pop)
399#endif
400/* Struct for pure user data */
401#ifdef __MigPackStructs
402#pragma pack(push, 4)
403#endif
404 typedef struct {
405 NDR_record_t NDR;
406 kern_return_t RetCode;
407 int flavor;
408 mach_msg_type_number_t new_stateCnt;
409 natural_t new_state[1296];
410 char padding[0]; /* Avoid generating empty UData structs */
411 } __ReplyUData__exception_raise_state_t __attribute__((unused));
412#ifdef __MigPackStructs
413#pragma pack(pop)
414#endif
415
416#ifdef __MigPackStructs
417#pragma pack(push, 4)
418#endif
419 typedef struct {
420 mach_msg_header_t Head;
421 NDR_record_t NDR;
422 kern_return_t RetCode;
423 int flavor;
424 mach_msg_type_number_t new_stateCnt;
425 natural_t new_state[1296];
426 } __Reply__exception_raise_state_identity_t __attribute__((unused));
427#ifdef __MigPackStructs
428#pragma pack(pop)
429#endif
430/* Struct for kernel processed data (Header + Descriptors) */
431#ifdef __MigPackStructs
432#pragma pack(push, 4)
433#endif
434 typedef struct {
435 mach_msg_header_t Head;
436 } __ReplyKData__exception_raise_state_identity_t __attribute__((unused));
437#ifdef __MigPackStructs
438#pragma pack(pop)
439#endif
440/* Struct for pure user data */
441#ifdef __MigPackStructs
442#pragma pack(push, 4)
443#endif
444 typedef struct {
445 NDR_record_t NDR;
446 kern_return_t RetCode;
447 int flavor;
448 mach_msg_type_number_t new_stateCnt;
449 natural_t new_state[1296];
450 char padding[0]; /* Avoid generating empty UData structs */
451 } __ReplyUData__exception_raise_state_identity_t __attribute__((unused));
452#ifdef __MigPackStructs
453#pragma pack(pop)
454#endif
455#endif /* !__Reply__exc_subsystem__defined */
456
457
458/* union of all replies */
459
460#ifndef __ReplyUnion__catch_exc_subsystem__defined
461#define __ReplyUnion__catch_exc_subsystem__defined
462union __ReplyUnion__catch_exc_subsystem {
463 __Reply__exception_raise_t Reply_exception_raise;
464 __Reply__exception_raise_state_t Reply_exception_raise_state;
465 __Reply__exception_raise_state_identity_t Reply_exception_raise_state_identity;
466};
467#endif /* __ReplyUnion__catch_exc_subsystem__defined */
468
469#ifndef subsystem_to_name_map_exc
470#define subsystem_to_name_map_exc \
471 { "exception_raise", 2401 },\
472 { "exception_raise_state", 2402 },\
473 { "exception_raise_state_identity", 2403 }
474#endif
475
476#ifdef __AfterMigServerHeader
477__AfterMigServerHeader
478#endif /* __AfterMigServerHeader */
479
480#endif /* _exc_server_ */
481