]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/mach_traps.h
xnu-792.25.20.tar.gz
[apple/xnu.git] / osfmk / mach / mach_traps.h
1 /*
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * @OSF_COPYRIGHT@
24 */
25 /*
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28 * All Rights Reserved.
29 *
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
35 *
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
39 *
40 * Carnegie Mellon requests users of this software to return to
41 *
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
46 *
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
49 */
50 /*
51 */
52 /*
53 * Definitions of general Mach system traps.
54 *
55 * These are the definitions as seen from user-space.
56 * The kernel definitions are in <mach/syscall_sw.h>.
57 * Kernel RPC functions are defined in <mach/mach_interface.h>.
58 */
59
60 #ifndef _MACH_MACH_TRAPS_H_
61 #define _MACH_MACH_TRAPS_H_
62
63 #include <stdint.h>
64
65 #include <mach/std_types.h>
66 #include <mach/mach_types.h>
67 #include <mach/kern_return.h>
68 #include <mach/port.h>
69 #include <mach/vm_types.h>
70 #include <mach/clock_types.h>
71
72 #include <machine/endian.h>
73
74 #include <sys/cdefs.h>
75
76 __BEGIN_DECLS
77
78 #ifndef KERNEL
79
80 #ifdef PRIVATE
81
82 extern mach_port_name_t mach_reply_port(void);
83
84 extern mach_port_name_t thread_self_trap(void);
85
86 extern mach_port_name_t host_self_trap(void);
87
88 extern mach_msg_return_t mach_msg_trap(
89 mach_msg_header_t *msg,
90 mach_msg_option_t option,
91 mach_msg_size_t send_size,
92 mach_msg_size_t rcv_size,
93 mach_port_name_t rcv_name,
94 mach_msg_timeout_t timeout,
95 mach_port_name_t notify);
96
97 extern mach_msg_return_t mach_msg_overwrite_trap(
98 mach_msg_header_t *msg,
99 mach_msg_option_t option,
100 mach_msg_size_t send_size,
101 mach_msg_size_t rcv_size,
102 mach_port_name_t rcv_name,
103 mach_msg_timeout_t timeout,
104 mach_port_name_t notify,
105 mach_msg_header_t *rcv_msg,
106 mach_msg_size_t rcv_limit);
107
108 extern kern_return_t semaphore_signal_trap(
109 mach_port_name_t signal_name);
110
111 extern kern_return_t semaphore_signal_all_trap(
112 mach_port_name_t signal_name);
113
114 extern kern_return_t semaphore_signal_thread_trap(
115 mach_port_name_t signal_name,
116 mach_port_name_t thread_name);
117
118 extern kern_return_t semaphore_wait_trap(
119 mach_port_name_t wait_name);
120
121 extern kern_return_t semaphore_wait_signal_trap(
122 mach_port_name_t wait_name,
123 mach_port_name_t signal_name);
124
125 extern kern_return_t semaphore_timedwait_trap(
126 mach_port_name_t wait_name,
127 unsigned int sec,
128 clock_res_t nsec);
129
130 extern kern_return_t semaphore_timedwait_signal_trap(
131 mach_port_name_t wait_name,
132 mach_port_name_t signal_name,
133 unsigned int sec,
134 clock_res_t nsec);
135
136 #if !defined(__LP64__)
137 /* these should go away altogether - so no 64 legacy please */
138
139 extern kern_return_t init_process(void);
140
141 #endif /* !defined(__LP64__) */
142
143 #if !defined(__LP64__)
144
145 /* more that should go away so no 64-bit legacy please */
146 extern kern_return_t macx_swapon(
147 char *filename,
148 int flags,
149 int size,
150 int priority);
151
152 extern kern_return_t macx_swapoff(
153 char *filename,
154 int flags);
155
156 extern kern_return_t macx_triggers(
157 int hi_water,
158 int low_water,
159 int flags,
160 mach_port_t alert_port);
161
162 extern kern_return_t macx_backing_store_suspend(
163 boolean_t suspend);
164
165 extern kern_return_t macx_backing_store_recovery(
166 int pid);
167
168 #endif /* !defined(__LP64__) */
169
170 extern kern_return_t clock_sleep_trap(
171 mach_port_name_t clock_name,
172 sleep_type_t sleep_type,
173 int sleep_sec,
174 int sleep_nsec,
175 mach_timespec_t *wakeup_time);
176
177 #endif /* PRIVATE */
178
179 extern boolean_t swtch_pri(int pri);
180
181 extern boolean_t swtch(void);
182
183 extern kern_return_t thread_switch(
184 mach_port_name_t thread_name,
185 int option,
186 mach_msg_timeout_t option_time);
187
188 extern mach_port_name_t task_self_trap(void);
189
190 /*
191 * Obsolete interfaces.
192 */
193
194 extern kern_return_t task_for_pid(
195 mach_port_name_t target_tport,
196 int pid,
197 mach_port_name_t *t);
198
199 extern kern_return_t task_name_for_pid(
200 mach_port_name_t target_tport,
201 int pid,
202 mach_port_name_t *tn);
203
204 extern kern_return_t pid_for_task(
205 mach_port_name_t t,
206 int *x);
207
208 #if !defined(__LP64__)
209 /* these should go away altogether - so no 64 legacy please */
210
211 extern kern_return_t map_fd(
212 int fd,
213 vm_offset_t offset,
214 vm_offset_t *va,
215 boolean_t findspace,
216 vm_size_t size);
217
218 #endif /* !defined(__LP64__) */
219
220 #else /* KERNEL */
221
222 #ifdef XNU_KERNEL_PRIVATE
223
224 /* Syscall data translations routines */
225 #define PAD_(t) (sizeof(uint64_t) <= sizeof(t) \
226 ? 0 : sizeof(uint64_t) - sizeof(t))
227
228 #if BYTE_ORDER == LITTLE_ENDIAN
229 #define PADL_(t) 0
230 #define PADR_(t) PAD_(t)
231 #else
232 #define PADL_(t) PAD_(t)
233 #define PADR_(t) 0
234 #endif
235
236 #define PAD_ARG_(arg_type, arg_name) \
237 char arg_name##_l_[PADL_(arg_type)]; arg_type arg_name; char arg_name##_r_[PADR_(arg_type)];
238
239 #ifndef __MUNGE_ONCE
240 #define __MUNGE_ONCE
241 #ifdef __ppc__
242 void munge_w(const void *, void *);
243 void munge_ww(const void *, void *);
244 void munge_www(const void *, void *);
245 void munge_wwww(const void *, void *);
246 void munge_wwwww(const void *, void *);
247 void munge_wwwwww(const void *, void *);
248 void munge_wwwwwww(const void *, void *);
249 void munge_wwwwwwww(const void *, void *);
250 void munge_d(const void *, void *);
251 void munge_dd(const void *, void *);
252 void munge_ddd(const void *, void *);
253 void munge_dddd(const void *, void *);
254 void munge_ddddd(const void *, void *);
255 void munge_dddddd(const void *, void *);
256 void munge_ddddddd(const void *, void *);
257 void munge_dddddddd(const void *, void *);
258 void munge_l(const void *, void *);
259 void munge_wl(const void *, void *);
260 void munge_wlw(const void *, void *);
261 void munge_wwwl(const void *, void *);
262 void munge_wwwwl(const void *, void *);
263 void munge_wwwwwl(const void *, void *);
264 #else
265 #define munge_w NULL
266 #define munge_ww NULL
267 #define munge_www NULL
268 #define munge_wwww NULL
269 #define munge_wwwww NULL
270 #define munge_wwwwww NULL
271 #define munge_wwwwwww NULL
272 #define munge_wwwwwwww NULL
273 #define munge_d NULL
274 #define munge_dd NULL
275 #define munge_ddd NULL
276 #define munge_dddd NULL
277 #define munge_ddddd NULL
278 #define munge_dddddd NULL
279 #define munge_ddddddd NULL
280 #define munge_dddddddd NULL
281 #define munge_l NULL
282 #define munge_wl NULL
283 #define munge_wlw NULL
284 #define munge_wwwl NULL
285 #define munge_wwwwl NULL
286 #define munge_wwwwwl NULL
287 #endif /* __ppc__ */
288 #endif /* !__MUNGE_ONCE */
289
290 struct kern_invalid_args {
291 register_t dummy;
292 };
293 extern kern_return_t kern_invalid(
294 struct kern_invalid_args *args);
295
296 struct mach_reply_port_args {
297 register_t dummy;
298 };
299 extern mach_port_name_t mach_reply_port(
300 struct mach_reply_port_args *args);
301
302 struct thread_self_trap_args {
303 register_t dummy;
304 };
305 extern mach_port_name_t thread_self_trap(
306 struct thread_self_trap_args *args);
307
308 struct task_self_trap_args {
309 register_t dummy;
310 };
311 extern mach_port_name_t task_self_trap(
312 struct task_self_trap_args *args);
313
314 struct host_self_trap_args {
315 register_t dummy;
316 };
317 extern mach_port_name_t host_self_trap(
318 struct host_self_trap_args *args);
319
320 struct mach_msg_overwrite_trap_args {
321 PAD_ARG_(mach_vm_address_t, msg);
322 PAD_ARG_(mach_msg_option_t, option);
323 PAD_ARG_(mach_msg_size_t, send_size);
324 PAD_ARG_(mach_msg_size_t, rcv_size);
325 PAD_ARG_(mach_port_name_t, rcv_name);
326 PAD_ARG_(mach_msg_timeout_t, timeout);
327 PAD_ARG_(mach_port_name_t, notify);
328 PAD_ARG_(mach_vm_address_t, rcv_msg); /* Unused on mach_msg_trap */
329 };
330 extern mach_msg_return_t mach_msg_trap(
331 struct mach_msg_overwrite_trap_args *args);
332 extern mach_msg_return_t mach_msg_overwrite_trap(
333 struct mach_msg_overwrite_trap_args *args);
334
335 struct semaphore_signal_trap_args {
336 PAD_ARG_(mach_port_name_t, signal_name);
337 };
338 extern kern_return_t semaphore_signal_trap(
339 struct semaphore_signal_trap_args *args);
340
341 struct semaphore_signal_all_trap_args {
342 PAD_ARG_(mach_port_name_t, signal_name);
343 };
344 extern kern_return_t semaphore_signal_all_trap(
345 struct semaphore_signal_all_trap_args *args);
346
347 struct semaphore_signal_thread_trap_args {
348 PAD_ARG_(mach_port_name_t, signal_name);
349 PAD_ARG_(mach_port_name_t, thread_name);
350 };
351 extern kern_return_t semaphore_signal_thread_trap(
352 struct semaphore_signal_thread_trap_args *args);
353
354 struct semaphore_wait_trap_args {
355 PAD_ARG_(mach_port_name_t, wait_name);
356 };
357 extern kern_return_t semaphore_wait_trap(
358 struct semaphore_wait_trap_args *args);
359
360 struct semaphore_wait_signal_trap_args {
361 PAD_ARG_(mach_port_name_t, wait_name);
362 PAD_ARG_(mach_port_name_t, signal_name);
363 };
364 extern kern_return_t semaphore_wait_signal_trap(
365 struct semaphore_wait_signal_trap_args *args);
366
367 struct semaphore_timedwait_trap_args {
368 PAD_ARG_(mach_port_name_t, wait_name);
369 PAD_ARG_(unsigned int, sec);
370 PAD_ARG_(clock_res_t, nsec);
371 };
372 extern kern_return_t semaphore_timedwait_trap(
373 struct semaphore_timedwait_trap_args *args);
374
375 struct semaphore_timedwait_signal_trap_args {
376 PAD_ARG_(mach_port_name_t, wait_name);
377 PAD_ARG_(mach_port_name_t, signal_name);
378 PAD_ARG_(unsigned int, sec);
379 PAD_ARG_(clock_res_t, nsec);
380 };
381 extern kern_return_t semaphore_timedwait_signal_trap(
382 struct semaphore_timedwait_signal_trap_args *args);
383
384 /* not published to LP64 clients */
385 struct init_process_args {
386 register_t dummy;
387 };
388 extern kern_return_t init_process(
389 struct init_process_args *args);
390
391 struct map_fd_args {
392 PAD_ARG_(int, fd);
393 PAD_ARG_(vm_offset_t, offset);
394 PAD_ARG_(vm_offset_t *, va);
395 PAD_ARG_(boolean_t, findspace);
396 PAD_ARG_(vm_size_t, size);
397 };
398 extern kern_return_t map_fd(
399 struct map_fd_args *args);
400
401 struct task_for_pid_args {
402 PAD_ARG_(mach_port_name_t, target_tport);
403 PAD_ARG_(int, pid);
404 PAD_ARG_(user_addr_t, t);
405 };
406 extern kern_return_t task_for_pid(
407 struct task_for_pid_args *args);
408
409 struct task_name_for_pid_args {
410 PAD_ARG_(mach_port_name_t, target_tport);
411 PAD_ARG_(int, pid);
412 PAD_ARG_(user_addr_t, t);
413 };
414 extern kern_return_t task_name_for_pid(
415 struct task_name_for_pid_args *args);
416
417 struct pid_for_task_args {
418 PAD_ARG_(mach_port_name_t, t);
419 PAD_ARG_(user_addr_t, pid);
420 };
421 extern kern_return_t pid_for_task(
422 struct pid_for_task_args *args);
423
424 /* not published to LP64 clients*/
425 struct macx_swapon_args {
426 PAD_ARG_(char *, filename);
427 PAD_ARG_(int, flags);
428 PAD_ARG_(int, size);
429 PAD_ARG_(int, priority);
430 };
431 extern kern_return_t macx_swapon(
432 struct macx_swapon_args *args);
433
434 struct macx_swapoff_args {
435 PAD_ARG_(char *, filename);
436 PAD_ARG_(int, flags);
437 };
438 extern kern_return_t macx_swapoff(
439 struct macx_swapoff_args *args);
440
441 struct macx_triggers_args {
442 PAD_ARG_(int, hi_water);
443 PAD_ARG_(int, low_water);
444 PAD_ARG_(int, flags);
445 PAD_ARG_(mach_port_t, alert_port);
446 };
447 extern kern_return_t macx_triggers(
448 struct macx_triggers_args *args);
449
450 struct macx_backing_store_suspend_args {
451 PAD_ARG_(boolean_t, suspend);
452 };
453 extern kern_return_t macx_backing_store_suspend(
454 struct macx_backing_store_suspend_args *args);
455
456 struct macx_backing_store_recovery_args {
457 PAD_ARG_(int, pid);
458 };
459 extern kern_return_t macx_backing_store_recovery(
460 struct macx_backing_store_recovery_args *args);
461
462 struct swtch_pri_args {
463 PAD_ARG_(int, pri);
464 };
465 extern boolean_t swtch_pri(
466 struct swtch_pri_args *args);
467
468 struct swtch_args {
469 register_t dummy;
470 };
471 extern boolean_t swtch(
472 struct swtch_args *args);
473
474 struct clock_sleep_trap_args{
475 PAD_ARG_(mach_port_name_t, clock_name);
476 PAD_ARG_(sleep_type_t, sleep_type);
477 PAD_ARG_(int, sleep_sec);
478 PAD_ARG_(int, sleep_nsec);
479 PAD_ARG_(mach_vm_address_t, wakeup_time);
480 };
481 extern kern_return_t clock_sleep_trap(
482 struct clock_sleep_trap_args *args);
483
484 struct thread_switch_args {
485 PAD_ARG_(mach_port_name_t, thread_name);
486 PAD_ARG_(int, option);
487 PAD_ARG_(mach_msg_timeout_t, option_time);
488 };
489 extern kern_return_t thread_switch(
490 struct thread_switch_args *args);
491
492 struct mach_timebase_info_trap_args {
493 PAD_ARG_(mach_vm_address_t, info);
494 };
495 extern kern_return_t mach_timebase_info_trap(
496 struct mach_timebase_info_trap_args *args);
497
498 struct mach_wait_until_trap_args {
499 PAD_ARG_(uint64_t, deadline);
500 };
501 extern kern_return_t mach_wait_until_trap(
502 struct mach_wait_until_trap_args *args);
503
504 struct mk_timer_create_trap_args {
505 register_t dummy;
506 };
507 extern mach_port_name_t mk_timer_create_trap(
508 struct mk_timer_create_trap_args *args);
509
510 struct mk_timer_destroy_trap_args {
511 PAD_ARG_(mach_port_name_t, name);
512 };
513 extern kern_return_t mk_timer_destroy_trap(
514 struct mk_timer_destroy_trap_args *args);
515
516 struct mk_timer_arm_trap_args {
517 PAD_ARG_(mach_port_name_t, name);
518 PAD_ARG_(uint64_t, expire_time);
519 };
520 extern kern_return_t mk_timer_arm_trap(
521 struct mk_timer_arm_trap_args *args);
522
523 struct mk_timer_cancel_trap_args {
524 PAD_ARG_(mach_port_name_t, name);
525 PAD_ARG_(mach_vm_address_t, result_time);
526 };
527 extern kern_return_t mk_timer_cancel_trap(
528 struct mk_timer_cancel_trap_args *args);
529
530 /* not published to LP64 clients yet */
531 struct iokit_user_client_trap_args {
532 PAD_ARG_(void *, userClientRef);
533 PAD_ARG_(uint32_t, index);
534 PAD_ARG_(void *, p1);
535 PAD_ARG_(void *, p2);
536 PAD_ARG_(void *, p3);
537 PAD_ARG_(void *, p4);
538 PAD_ARG_(void *, p5);
539 PAD_ARG_(void *, p6);
540 };
541 kern_return_t iokit_user_client_trap(
542 struct iokit_user_client_trap_args *args);
543
544 #undef PAD_
545 #undef PADL_
546 #undef PADR_
547 #undef PAD_ARG_
548
549 #endif /* XNU_KERNEL_PRIVATE */
550
551 #endif /* KERNEL */
552
553 __END_DECLS
554
555 #endif /* _MACH_MACH_TRAPS_H_ */