2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28 * All Rights Reserved.
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.
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.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
53 * Definitions of general Mach system traps.
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>.
60 #ifndef _MACH_MACH_TRAPS_H_
61 #define _MACH_MACH_TRAPS_H_
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>
72 #include <machine/endian.h>
74 #include <sys/cdefs.h>
82 extern mach_port_name_t
mach_reply_port(void);
84 extern mach_port_name_t
thread_self_trap(void);
86 extern mach_port_name_t
host_self_trap(void);
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
);
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
);
108 extern kern_return_t
semaphore_signal_trap(
109 mach_port_name_t signal_name
);
111 extern kern_return_t
semaphore_signal_all_trap(
112 mach_port_name_t signal_name
);
114 extern kern_return_t
semaphore_signal_thread_trap(
115 mach_port_name_t signal_name
,
116 mach_port_name_t thread_name
);
118 extern kern_return_t
semaphore_wait_trap(
119 mach_port_name_t wait_name
);
121 extern kern_return_t
semaphore_wait_signal_trap(
122 mach_port_name_t wait_name
,
123 mach_port_name_t signal_name
);
125 extern kern_return_t
semaphore_timedwait_trap(
126 mach_port_name_t wait_name
,
130 extern kern_return_t
semaphore_timedwait_signal_trap(
131 mach_port_name_t wait_name
,
132 mach_port_name_t signal_name
,
136 #if !defined(__LP64__)
137 /* these should go away altogether - so no 64 legacy please */
139 extern kern_return_t
init_process(void);
141 #endif /* !defined(__LP64__) */
143 #if !defined(__LP64__)
145 /* more that should go away so no 64-bit legacy please */
146 extern kern_return_t
macx_swapon(
152 extern kern_return_t
macx_swapoff(
156 extern kern_return_t
macx_triggers(
160 mach_port_t alert_port
);
162 extern kern_return_t
macx_backing_store_suspend(
165 extern kern_return_t
macx_backing_store_recovery(
168 #endif /* !defined(__LP64__) */
170 extern kern_return_t
clock_sleep_trap(
171 mach_port_name_t clock_name
,
172 sleep_type_t sleep_type
,
175 mach_timespec_t
*wakeup_time
);
179 extern boolean_t
swtch_pri(int pri
);
181 extern boolean_t
swtch(void);
183 extern kern_return_t
thread_switch(
184 mach_port_name_t thread_name
,
186 mach_msg_timeout_t option_time
);
188 extern mach_port_name_t
task_self_trap(void);
191 * Obsolete interfaces.
194 extern kern_return_t
task_for_pid(
195 mach_port_name_t target_tport
,
197 mach_port_name_t
*t
);
199 extern kern_return_t
pid_for_task(
203 #if !defined(__LP64__)
204 /* these should go away altogether - so no 64 legacy please */
206 extern kern_return_t
map_fd(
213 #endif /* !defined(__LP64__) */
217 #ifdef XNU_KERNEL_PRIVATE
219 /* Syscall data translations routines */
221 #define PAD_(t) (sizeof(uint64_t) <= sizeof(t) \
222 ? 0 : sizeof(uint64_t) - sizeof(t))
224 #define PAD_(t) (sizeof(register_t) <= sizeof(t) \
225 ? 0 : sizeof(register_t) - sizeof(t))
228 #if BYTE_ORDER == LITTLE_ENDIAN
230 #define PADR_(t) PAD_(t)
232 #define PADL_(t) PAD_(t)
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)];
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 *);
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
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
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
288 #endif /* !__MUNGE_ONCE */
290 struct kern_invalid_args
{
293 extern kern_return_t
kern_invalid(
294 struct kern_invalid_args
*args
);
296 struct mach_reply_port_args
{
299 extern mach_port_name_t
mach_reply_port(
300 struct mach_reply_port_args
*args
);
302 struct thread_self_trap_args
{
305 extern mach_port_name_t
thread_self_trap(
306 struct thread_self_trap_args
*args
);
308 struct task_self_trap_args
{
311 extern mach_port_name_t
task_self_trap(
312 struct task_self_trap_args
*args
);
314 struct host_self_trap_args
{
317 extern mach_port_name_t
host_self_trap(
318 struct host_self_trap_args
*args
);
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 */
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
);
335 struct semaphore_signal_trap_args
{
336 PAD_ARG_(mach_port_name_t
, signal_name
);
338 extern kern_return_t
semaphore_signal_trap(
339 struct semaphore_signal_trap_args
*args
);
341 struct semaphore_signal_all_trap_args
{
342 PAD_ARG_(mach_port_name_t
, signal_name
);
344 extern kern_return_t
semaphore_signal_all_trap(
345 struct semaphore_signal_all_trap_args
*args
);
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
);
351 extern kern_return_t
semaphore_signal_thread_trap(
352 struct semaphore_signal_thread_trap_args
*args
);
354 struct semaphore_wait_trap_args
{
355 PAD_ARG_(mach_port_name_t
, wait_name
);
357 extern kern_return_t
semaphore_wait_trap(
358 struct semaphore_wait_trap_args
*args
);
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
);
364 extern kern_return_t
semaphore_wait_signal_trap(
365 struct semaphore_wait_signal_trap_args
*args
);
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
);
372 extern kern_return_t
semaphore_timedwait_trap(
373 struct semaphore_timedwait_trap_args
*args
);
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
);
381 extern kern_return_t
semaphore_timedwait_signal_trap(
382 struct semaphore_timedwait_signal_trap_args
*args
);
384 /* not published to LP64 clients */
385 struct init_process_args
{
388 extern kern_return_t
init_process(
389 struct init_process_args
*args
);
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
);
398 extern kern_return_t
map_fd(
399 struct map_fd_args
*args
);
401 struct task_for_pid_args
{
402 PAD_ARG_(mach_port_name_t
, target_tport
);
404 PAD_ARG_(user_addr_t
, t
);
406 extern kern_return_t
task_for_pid(
407 struct task_for_pid_args
*args
);
409 struct pid_for_task_args
{
410 PAD_ARG_(mach_port_name_t
, t
);
411 PAD_ARG_(user_addr_t
, pid
);
413 extern kern_return_t
pid_for_task(
414 struct pid_for_task_args
*args
);
416 /* not published to LP64 clients*/
417 struct macx_swapon_args
{
418 PAD_ARG_(char *, filename
);
419 PAD_ARG_(int, flags
);
421 PAD_ARG_(int, priority
);
423 extern kern_return_t
macx_swapon(
424 struct macx_swapon_args
*args
);
426 struct macx_swapoff_args
{
427 PAD_ARG_(char *, filename
);
428 PAD_ARG_(int, flags
);
430 extern kern_return_t
macx_swapoff(
431 struct macx_swapoff_args
*args
);
433 struct macx_triggers_args
{
434 PAD_ARG_(int, hi_water
);
435 PAD_ARG_(int, low_water
);
436 PAD_ARG_(int, flags
);
437 PAD_ARG_(mach_port_t
, alert_port
);
439 extern kern_return_t
macx_triggers(
440 struct macx_triggers_args
*args
);
442 struct macx_backing_store_suspend_args
{
443 PAD_ARG_(boolean_t
, suspend
);
445 extern kern_return_t
macx_backing_store_suspend(
446 struct macx_backing_store_suspend_args
*args
);
448 struct macx_backing_store_recovery_args
{
451 extern kern_return_t
macx_backing_store_recovery(
452 struct macx_backing_store_recovery_args
*args
);
454 struct swtch_pri_args
{
457 extern boolean_t
swtch_pri(
458 struct swtch_pri_args
*args
);
463 extern boolean_t
swtch(
464 struct swtch_args
*args
);
466 struct clock_sleep_trap_args
{
467 PAD_ARG_(mach_port_name_t
, clock_name
);
468 PAD_ARG_(sleep_type_t
, sleep_type
);
469 PAD_ARG_(int, sleep_sec
);
470 PAD_ARG_(int, sleep_nsec
);
471 PAD_ARG_(mach_vm_address_t
, wakeup_time
);
473 extern kern_return_t
clock_sleep_trap(
474 struct clock_sleep_trap_args
*args
);
476 struct thread_switch_args
{
477 PAD_ARG_(mach_port_name_t
, thread_name
);
478 PAD_ARG_(int, option
);
479 PAD_ARG_(mach_msg_timeout_t
, option_time
);
481 extern kern_return_t
thread_switch(
482 struct thread_switch_args
*args
);
484 struct mach_timebase_info_trap_args
{
485 PAD_ARG_(mach_vm_address_t
, info
);
487 extern kern_return_t
mach_timebase_info_trap(
488 struct mach_timebase_info_trap_args
*args
);
490 struct mach_wait_until_trap_args
{
491 PAD_ARG_(uint64_t, deadline
);
493 extern kern_return_t
mach_wait_until_trap(
494 struct mach_wait_until_trap_args
*args
);
496 struct mk_timer_create_trap_args
{
499 extern mach_port_name_t
mk_timer_create_trap(
500 struct mk_timer_create_trap_args
*args
);
502 struct mk_timer_destroy_trap_args
{
503 PAD_ARG_(mach_port_name_t
, name
);
505 extern kern_return_t
mk_timer_destroy_trap(
506 struct mk_timer_destroy_trap_args
*args
);
508 struct mk_timer_arm_trap_args
{
509 PAD_ARG_(mach_port_name_t
, name
);
510 PAD_ARG_(uint64_t, expire_time
);
512 extern kern_return_t
mk_timer_arm_trap(
513 struct mk_timer_arm_trap_args
*args
);
515 struct mk_timer_cancel_trap_args
{
516 PAD_ARG_(mach_port_name_t
, name
);
517 PAD_ARG_(mach_vm_address_t
, result_time
);
519 extern kern_return_t
mk_timer_cancel_trap(
520 struct mk_timer_cancel_trap_args
*args
);
522 /* no user-level prototype for this one */
523 struct mk_timebase_info_trap_args
{
524 PAD_ARG_(uint32_t *, delta
);
525 PAD_ARG_(uint32_t *, abs_to_ns_numer
);
526 PAD_ARG_(uint32_t *, abs_to_ns_denom
);
527 PAD_ARG_(uint32_t *, proc_to_abs_numer
);
528 PAD_ARG_(uint32_t *, proc_to_abs_denom
);
530 extern void mk_timebase_info_trap(
531 struct mk_timebase_info_trap_args
*args
);
533 /* not published to LP64 clients yet */
534 struct iokit_user_client_trap_args
{
535 PAD_ARG_(void *, userClientRef
);
536 PAD_ARG_(uint32_t, index
);
537 PAD_ARG_(void *, p1
);
538 PAD_ARG_(void *, p2
);
539 PAD_ARG_(void *, p3
);
540 PAD_ARG_(void *, p4
);
541 PAD_ARG_(void *, p5
);
542 PAD_ARG_(void *, p6
);
544 kern_return_t
iokit_user_client_trap(
545 struct iokit_user_client_trap_args
*args
);
552 #endif /* XNU_KERNEL_PRIVATE */
558 #endif /* _MACH_MACH_TRAPS_H_ */