1 | #ifndef _mach_eventlink_server_ |
2 | #define _mach_eventlink_server_ |
3 | |
4 | /* Module mach_eventlink */ |
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 | #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 |
45 | typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); |
46 | typedef struct { |
47 | char * name; |
48 | function_ptr_t function; |
49 | } function_table_entry; |
50 | typedef function_table_entry *function_table_t; |
51 | #endif /* FUNCTION_PTR_T */ |
52 | #endif /* AUTOTEST */ |
53 | |
54 | #ifndef mach_eventlink_MSG_COUNT |
55 | #define mach_eventlink_MSG_COUNT 4 |
56 | #endif /* mach_eventlink_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 | #include <mach/mach_types.h> |
78 | |
79 | #ifdef __BeforeMigServerHeader |
80 | __BeforeMigServerHeader |
81 | #endif /* __BeforeMigServerHeader */ |
82 | |
83 | #ifndef MIG_SERVER_ROUTINE |
84 | #define MIG_SERVER_ROUTINE |
85 | #endif |
86 | |
87 | |
88 | /* Routine mach_eventlink_create */ |
89 | #ifdef mig_external |
90 | mig_external |
91 | #else |
92 | extern |
93 | #endif /* mig_external */ |
94 | MIG_SERVER_ROUTINE |
95 | kern_return_t mach_eventlink_create |
96 | ( |
97 | task_t task, |
98 | mach_eventlink_create_option_t option, |
99 | eventlink_port_pair_t eventlink_pair |
100 | ); |
101 | |
102 | /* Routine mach_eventlink_destroy */ |
103 | #ifdef mig_external |
104 | mig_external |
105 | #else |
106 | extern |
107 | #endif /* mig_external */ |
108 | MIG_SERVER_ROUTINE |
109 | kern_return_t mach_eventlink_destroy |
110 | ( |
111 | ipc_eventlink_t eventlink |
112 | ); |
113 | |
114 | /* Routine mach_eventlink_associate */ |
115 | #ifdef mig_external |
116 | mig_external |
117 | #else |
118 | extern |
119 | #endif /* mig_external */ |
120 | MIG_SERVER_ROUTINE |
121 | kern_return_t mach_eventlink_associate |
122 | ( |
123 | ipc_eventlink_t eventlink, |
124 | thread_t thread, |
125 | mach_vm_address_t copyin_addr_wait, |
126 | uint64_t copyin_mask_wait, |
127 | mach_vm_address_t copyin_addr_signal, |
128 | uint64_t copyin_mask_signal, |
129 | mach_eventlink_associate_option_t option |
130 | ); |
131 | |
132 | /* Routine mach_eventlink_disassociate */ |
133 | #ifdef mig_external |
134 | mig_external |
135 | #else |
136 | extern |
137 | #endif /* mig_external */ |
138 | MIG_SERVER_ROUTINE |
139 | kern_return_t mach_eventlink_disassociate |
140 | ( |
141 | ipc_eventlink_t eventlink, |
142 | mach_eventlink_disassociate_option_t option |
143 | ); |
144 | |
145 | #ifdef mig_external |
146 | mig_external |
147 | #else |
148 | extern |
149 | #endif /* mig_external */ |
150 | boolean_t mach_eventlink_server( |
151 | mach_msg_header_t *InHeadP, |
152 | void *InDataP, |
153 | mach_msg_max_trailer_t *InTrailerP, |
154 | mach_msg_header_t *OutHeadP, |
155 | void *OutDataP); |
156 | |
157 | #ifdef mig_external |
158 | mig_external |
159 | #else |
160 | extern |
161 | #endif /* mig_external */ |
162 | mig_kern_routine_t mach_eventlink_server_routine( |
163 | mach_msg_header_t *InHeadP); |
164 | |
165 | |
166 | /* Description of this kernel subsystem, for use in direct RPC */ |
167 | extern const struct mach_eventlink_subsystem { |
168 | mig_kern_server_routine_t kserver; /* Server routine */ |
169 | mach_msg_id_t start; /* Min routine number */ |
170 | mach_msg_id_t end; /* Max routine number + 1 */ |
171 | unsigned int maxsize; /* Max msg size */ |
172 | vm_address_t reserved; /* Reserved */ |
173 | struct kern_routine_descriptor /* Array of routine descriptors */ |
174 | kroutine[4]; |
175 | } mach_eventlink_subsystem; |
176 | |
177 | /* typedefs for all requests */ |
178 | |
179 | #ifndef __Request__mach_eventlink_subsystem__defined |
180 | #define __Request__mach_eventlink_subsystem__defined |
181 | |
182 | #ifdef __MigPackStructs |
183 | #pragma pack(push, 4) |
184 | #endif |
185 | typedef struct { |
186 | mach_msg_header_t Head; |
187 | NDR_record_t NDR; |
188 | mach_eventlink_create_option_t option; |
189 | } __Request__mach_eventlink_create_t __attribute__((unused)); |
190 | #ifdef __MigPackStructs |
191 | #pragma pack(pop) |
192 | #endif |
193 | /* Struct for kernel processed data (Header + Descriptors) */ |
194 | #ifdef __MigPackStructs |
195 | #pragma pack(push, 4) |
196 | #endif |
197 | typedef struct { |
198 | mach_msg_header_t Head; |
199 | } __RequestKData__mach_eventlink_create_t __attribute__((unused)); |
200 | #ifdef __MigPackStructs |
201 | #pragma pack(pop) |
202 | #endif |
203 | /* Struct for pure user data */ |
204 | #ifdef __MigPackStructs |
205 | #pragma pack(push, 4) |
206 | #endif |
207 | typedef struct { |
208 | NDR_record_t NDR; |
209 | mach_eventlink_create_option_t option; |
210 | char padding[0]; /* Avoid generating empty UData structs */ |
211 | } __RequestUData__mach_eventlink_create_t __attribute__((unused)); |
212 | #ifdef __MigPackStructs |
213 | #pragma pack(pop) |
214 | #endif |
215 | |
216 | #ifdef __MigPackStructs |
217 | #pragma pack(push, 4) |
218 | #endif |
219 | typedef struct { |
220 | mach_msg_header_t Head; |
221 | } __Request__mach_eventlink_destroy_t __attribute__((unused)); |
222 | #ifdef __MigPackStructs |
223 | #pragma pack(pop) |
224 | #endif |
225 | /* Struct for kernel processed data (Header + Descriptors) */ |
226 | #ifdef __MigPackStructs |
227 | #pragma pack(push, 4) |
228 | #endif |
229 | typedef struct { |
230 | mach_msg_header_t Head; |
231 | } __RequestKData__mach_eventlink_destroy_t __attribute__((unused)); |
232 | #ifdef __MigPackStructs |
233 | #pragma pack(pop) |
234 | #endif |
235 | /* Struct for pure user data */ |
236 | #ifdef __MigPackStructs |
237 | #pragma pack(push, 4) |
238 | #endif |
239 | typedef struct { |
240 | char padding[0]; /* Avoid generating empty UData structs */ |
241 | } __RequestUData__mach_eventlink_destroy_t __attribute__((unused)); |
242 | #ifdef __MigPackStructs |
243 | #pragma pack(pop) |
244 | #endif |
245 | |
246 | #ifdef __MigPackStructs |
247 | #pragma pack(push, 4) |
248 | #endif |
249 | typedef struct { |
250 | mach_msg_header_t Head; |
251 | /* start of the kernel processed data */ |
252 | mach_msg_body_t msgh_body; |
253 | mach_msg_port_descriptor_t thread; |
254 | /* end of the kernel processed data */ |
255 | NDR_record_t NDR; |
256 | mach_vm_address_t copyin_addr_wait; |
257 | uint64_t copyin_mask_wait; |
258 | mach_vm_address_t copyin_addr_signal; |
259 | uint64_t copyin_mask_signal; |
260 | mach_eventlink_associate_option_t option; |
261 | } __Request__mach_eventlink_associate_t __attribute__((unused)); |
262 | #ifdef __MigPackStructs |
263 | #pragma pack(pop) |
264 | #endif |
265 | /* Struct for kernel processed data (Header + Descriptors) */ |
266 | #ifdef __MigPackStructs |
267 | #pragma pack(push, 4) |
268 | #endif |
269 | typedef struct { |
270 | mach_msg_header_t Head; |
271 | mach_msg_body_t msgh_body; |
272 | mach_msg_port_descriptor_t thread; |
273 | } __RequestKData__mach_eventlink_associate_t __attribute__((unused)); |
274 | #ifdef __MigPackStructs |
275 | #pragma pack(pop) |
276 | #endif |
277 | /* Struct for pure user data */ |
278 | #ifdef __MigPackStructs |
279 | #pragma pack(push, 4) |
280 | #endif |
281 | typedef struct { |
282 | NDR_record_t NDR; |
283 | mach_vm_address_t copyin_addr_wait; |
284 | uint64_t copyin_mask_wait; |
285 | mach_vm_address_t copyin_addr_signal; |
286 | uint64_t copyin_mask_signal; |
287 | mach_eventlink_associate_option_t option; |
288 | char padding[0]; /* Avoid generating empty UData structs */ |
289 | } __RequestUData__mach_eventlink_associate_t __attribute__((unused)); |
290 | #ifdef __MigPackStructs |
291 | #pragma pack(pop) |
292 | #endif |
293 | |
294 | #ifdef __MigPackStructs |
295 | #pragma pack(push, 4) |
296 | #endif |
297 | typedef struct { |
298 | mach_msg_header_t Head; |
299 | NDR_record_t NDR; |
300 | mach_eventlink_disassociate_option_t option; |
301 | } __Request__mach_eventlink_disassociate_t __attribute__((unused)); |
302 | #ifdef __MigPackStructs |
303 | #pragma pack(pop) |
304 | #endif |
305 | /* Struct for kernel processed data (Header + Descriptors) */ |
306 | #ifdef __MigPackStructs |
307 | #pragma pack(push, 4) |
308 | #endif |
309 | typedef struct { |
310 | mach_msg_header_t Head; |
311 | } __RequestKData__mach_eventlink_disassociate_t __attribute__((unused)); |
312 | #ifdef __MigPackStructs |
313 | #pragma pack(pop) |
314 | #endif |
315 | /* Struct for pure user data */ |
316 | #ifdef __MigPackStructs |
317 | #pragma pack(push, 4) |
318 | #endif |
319 | typedef struct { |
320 | NDR_record_t NDR; |
321 | mach_eventlink_disassociate_option_t option; |
322 | char padding[0]; /* Avoid generating empty UData structs */ |
323 | } __RequestUData__mach_eventlink_disassociate_t __attribute__((unused)); |
324 | #ifdef __MigPackStructs |
325 | #pragma pack(pop) |
326 | #endif |
327 | #endif /* !__Request__mach_eventlink_subsystem__defined */ |
328 | |
329 | |
330 | /* union of all requests */ |
331 | |
332 | #ifndef __RequestUnion__mach_eventlink_subsystem__defined |
333 | #define __RequestUnion__mach_eventlink_subsystem__defined |
334 | union __RequestUnion__mach_eventlink_subsystem { |
335 | __Request__mach_eventlink_create_t Request_mach_eventlink_create; |
336 | __Request__mach_eventlink_destroy_t Request_mach_eventlink_destroy; |
337 | __Request__mach_eventlink_associate_t Request_mach_eventlink_associate; |
338 | __Request__mach_eventlink_disassociate_t Request_mach_eventlink_disassociate; |
339 | }; |
340 | #endif /* __RequestUnion__mach_eventlink_subsystem__defined */ |
341 | /* typedefs for all replies */ |
342 | |
343 | #ifndef __Reply__mach_eventlink_subsystem__defined |
344 | #define __Reply__mach_eventlink_subsystem__defined |
345 | |
346 | #ifdef __MigPackStructs |
347 | #pragma pack(push, 4) |
348 | #endif |
349 | typedef struct { |
350 | mach_msg_header_t Head; |
351 | /* start of the kernel processed data */ |
352 | mach_msg_body_t msgh_body; |
353 | mach_msg_port_descriptor_t eventlink_pair[2]; |
354 | /* end of the kernel processed data */ |
355 | } __Reply__mach_eventlink_create_t __attribute__((unused)); |
356 | #ifdef __MigPackStructs |
357 | #pragma pack(pop) |
358 | #endif |
359 | /* Struct for kernel processed data (Header + Descriptors) */ |
360 | #ifdef __MigPackStructs |
361 | #pragma pack(push, 4) |
362 | #endif |
363 | typedef struct { |
364 | mach_msg_header_t Head; |
365 | mach_msg_body_t msgh_body; |
366 | mach_msg_port_descriptor_t eventlink_pair[2]; |
367 | } __ReplyKData__mach_eventlink_create_t __attribute__((unused)); |
368 | #ifdef __MigPackStructs |
369 | #pragma pack(pop) |
370 | #endif |
371 | /* Struct for pure user data */ |
372 | #ifdef __MigPackStructs |
373 | #pragma pack(push, 4) |
374 | #endif |
375 | typedef struct { |
376 | char padding[0]; /* Avoid generating empty UData structs */ |
377 | } __ReplyUData__mach_eventlink_create_t __attribute__((unused)); |
378 | #ifdef __MigPackStructs |
379 | #pragma pack(pop) |
380 | #endif |
381 | |
382 | #ifdef __MigPackStructs |
383 | #pragma pack(push, 4) |
384 | #endif |
385 | typedef struct { |
386 | mach_msg_header_t Head; |
387 | NDR_record_t NDR; |
388 | kern_return_t RetCode; |
389 | } __Reply__mach_eventlink_destroy_t __attribute__((unused)); |
390 | #ifdef __MigPackStructs |
391 | #pragma pack(pop) |
392 | #endif |
393 | /* Struct for kernel processed data (Header + Descriptors) */ |
394 | #ifdef __MigPackStructs |
395 | #pragma pack(push, 4) |
396 | #endif |
397 | typedef struct { |
398 | mach_msg_header_t Head; |
399 | } __ReplyKData__mach_eventlink_destroy_t __attribute__((unused)); |
400 | #ifdef __MigPackStructs |
401 | #pragma pack(pop) |
402 | #endif |
403 | /* Struct for pure user data */ |
404 | #ifdef __MigPackStructs |
405 | #pragma pack(push, 4) |
406 | #endif |
407 | typedef struct { |
408 | NDR_record_t NDR; |
409 | kern_return_t RetCode; |
410 | char padding[0]; /* Avoid generating empty UData structs */ |
411 | } __ReplyUData__mach_eventlink_destroy_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 | } __Reply__mach_eventlink_associate_t __attribute__((unused)); |
424 | #ifdef __MigPackStructs |
425 | #pragma pack(pop) |
426 | #endif |
427 | /* Struct for kernel processed data (Header + Descriptors) */ |
428 | #ifdef __MigPackStructs |
429 | #pragma pack(push, 4) |
430 | #endif |
431 | typedef struct { |
432 | mach_msg_header_t Head; |
433 | } __ReplyKData__mach_eventlink_associate_t __attribute__((unused)); |
434 | #ifdef __MigPackStructs |
435 | #pragma pack(pop) |
436 | #endif |
437 | /* Struct for pure user data */ |
438 | #ifdef __MigPackStructs |
439 | #pragma pack(push, 4) |
440 | #endif |
441 | typedef struct { |
442 | NDR_record_t NDR; |
443 | kern_return_t RetCode; |
444 | char padding[0]; /* Avoid generating empty UData structs */ |
445 | } __ReplyUData__mach_eventlink_associate_t __attribute__((unused)); |
446 | #ifdef __MigPackStructs |
447 | #pragma pack(pop) |
448 | #endif |
449 | |
450 | #ifdef __MigPackStructs |
451 | #pragma pack(push, 4) |
452 | #endif |
453 | typedef struct { |
454 | mach_msg_header_t Head; |
455 | NDR_record_t NDR; |
456 | kern_return_t RetCode; |
457 | } __Reply__mach_eventlink_disassociate_t __attribute__((unused)); |
458 | #ifdef __MigPackStructs |
459 | #pragma pack(pop) |
460 | #endif |
461 | /* Struct for kernel processed data (Header + Descriptors) */ |
462 | #ifdef __MigPackStructs |
463 | #pragma pack(push, 4) |
464 | #endif |
465 | typedef struct { |
466 | mach_msg_header_t Head; |
467 | } __ReplyKData__mach_eventlink_disassociate_t __attribute__((unused)); |
468 | #ifdef __MigPackStructs |
469 | #pragma pack(pop) |
470 | #endif |
471 | /* Struct for pure user data */ |
472 | #ifdef __MigPackStructs |
473 | #pragma pack(push, 4) |
474 | #endif |
475 | typedef struct { |
476 | NDR_record_t NDR; |
477 | kern_return_t RetCode; |
478 | char padding[0]; /* Avoid generating empty UData structs */ |
479 | } __ReplyUData__mach_eventlink_disassociate_t __attribute__((unused)); |
480 | #ifdef __MigPackStructs |
481 | #pragma pack(pop) |
482 | #endif |
483 | #endif /* !__Reply__mach_eventlink_subsystem__defined */ |
484 | |
485 | |
486 | /* union of all replies */ |
487 | |
488 | #ifndef __ReplyUnion__mach_eventlink_subsystem__defined |
489 | #define __ReplyUnion__mach_eventlink_subsystem__defined |
490 | union __ReplyUnion__mach_eventlink_subsystem { |
491 | __Reply__mach_eventlink_create_t Reply_mach_eventlink_create; |
492 | __Reply__mach_eventlink_destroy_t Reply_mach_eventlink_destroy; |
493 | __Reply__mach_eventlink_associate_t Reply_mach_eventlink_associate; |
494 | __Reply__mach_eventlink_disassociate_t Reply_mach_eventlink_disassociate; |
495 | }; |
496 | #endif /* __ReplyUnion__mach_eventlink_subsystem__defined */ |
497 | |
498 | #ifndef subsystem_to_name_map_mach_eventlink |
499 | #define subsystem_to_name_map_mach_eventlink \ |
500 | { "mach_eventlink_create", 716200 },\ |
501 | { "mach_eventlink_destroy", 716201 },\ |
502 | { "mach_eventlink_associate", 716202 },\ |
503 | { "mach_eventlink_disassociate", 716203 } |
504 | #endif |
505 | |
506 | #ifdef __AfterMigServerHeader |
507 | __AfterMigServerHeader |
508 | #endif /* __AfterMigServerHeader */ |
509 | |
510 | #endif /* _mach_eventlink_server_ */ |
511 | |