2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
34 * All Rights Reserved.
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
46 * Carnegie Mellon requests users of this software to return to
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
59 * Definitions of general Mach system traps.
61 * These are the definitions as seen from user-space.
62 * The kernel definitions are in <mach/syscall_sw.h>.
63 * Kernel RPC functions are defined in <mach/mach_interface.h>.
66 #ifndef _MACH_MACH_TRAPS_H_
67 #define _MACH_MACH_TRAPS_H_
71 #include <mach/std_types.h>
72 #include <mach/mach_types.h>
73 #include <mach/kern_return.h>
74 #include <mach/port.h>
75 #include <mach/vm_types.h>
76 #include <mach/clock_types.h>
78 #include <machine/endian.h>
80 #include <sys/cdefs.h>
88 extern mach_port_name_t
mach_reply_port(void);
90 extern mach_port_name_t
thread_self_trap(void);
92 extern mach_port_name_t
host_self_trap(void);
94 extern mach_msg_return_t
mach_msg_trap(
95 mach_msg_header_t
*msg
,
96 mach_msg_option_t option
,
97 mach_msg_size_t send_size
,
98 mach_msg_size_t rcv_size
,
99 mach_port_name_t rcv_name
,
100 mach_msg_timeout_t timeout
,
101 mach_port_name_t notify
);
103 extern mach_msg_return_t
mach_msg_overwrite_trap(
104 mach_msg_header_t
*msg
,
105 mach_msg_option_t option
,
106 mach_msg_size_t send_size
,
107 mach_msg_size_t rcv_size
,
108 mach_port_name_t rcv_name
,
109 mach_msg_timeout_t timeout
,
110 mach_port_name_t notify
,
111 mach_msg_header_t
*rcv_msg
,
112 mach_msg_size_t rcv_limit
);
114 extern kern_return_t
semaphore_signal_trap(
115 mach_port_name_t signal_name
);
117 extern kern_return_t
semaphore_signal_all_trap(
118 mach_port_name_t signal_name
);
120 extern kern_return_t
semaphore_signal_thread_trap(
121 mach_port_name_t signal_name
,
122 mach_port_name_t thread_name
);
124 extern kern_return_t
semaphore_wait_trap(
125 mach_port_name_t wait_name
);
127 extern kern_return_t
semaphore_wait_signal_trap(
128 mach_port_name_t wait_name
,
129 mach_port_name_t signal_name
);
131 extern kern_return_t
semaphore_timedwait_trap(
132 mach_port_name_t wait_name
,
136 extern kern_return_t
semaphore_timedwait_signal_trap(
137 mach_port_name_t wait_name
,
138 mach_port_name_t signal_name
,
142 #if !defined(__LP64__)
143 /* these should go away altogether - so no 64 legacy please */
145 extern kern_return_t
init_process(void);
147 #endif /* !defined(__LP64__) */
149 #if !defined(__LP64__)
151 /* more that should go away so no 64-bit legacy please */
152 extern kern_return_t
macx_swapon(
158 extern kern_return_t
macx_swapoff(
162 extern kern_return_t
macx_triggers(
166 mach_port_t alert_port
);
168 extern kern_return_t
macx_backing_store_suspend(
171 extern kern_return_t
macx_backing_store_recovery(
174 #endif /* !defined(__LP64__) */
176 extern kern_return_t
clock_sleep_trap(
177 mach_port_name_t clock_name
,
178 sleep_type_t sleep_type
,
181 mach_timespec_t
*wakeup_time
);
185 extern boolean_t
swtch_pri(int pri
);
187 extern boolean_t
swtch(void);
189 extern kern_return_t
thread_switch(
190 mach_port_name_t thread_name
,
192 mach_msg_timeout_t option_time
);
194 extern mach_port_name_t
task_self_trap(void);
197 * Obsolete interfaces.
200 extern kern_return_t
task_for_pid(
201 mach_port_name_t target_tport
,
203 mach_port_name_t
*t
);
205 extern kern_return_t
pid_for_task(
209 #if !defined(__LP64__)
210 /* these should go away altogether - so no 64 legacy please */
212 extern kern_return_t
map_fd(
219 #endif /* !defined(__LP64__) */
223 #ifdef XNU_KERNEL_PRIVATE
225 /* Syscall data translations routines */
227 #define PAD_(t) (sizeof(uint64_t) <= sizeof(t) \
228 ? 0 : sizeof(uint64_t) - sizeof(t))
230 #define PAD_(t) (sizeof(register_t) <= sizeof(t) \
231 ? 0 : sizeof(register_t) - sizeof(t))
234 #if BYTE_ORDER == LITTLE_ENDIAN
236 #define PADR_(t) PAD_(t)
238 #define PADL_(t) PAD_(t)
242 #define PAD_ARG_(arg_type, arg_name) \
243 char arg_name##_l_[PADL_(arg_type)]; arg_type arg_name; char arg_name##_r_[PADR_(arg_type)];
248 void munge_w(const void *, void *);
249 void munge_ww(const void *, void *);
250 void munge_www(const void *, void *);
251 void munge_wwww(const void *, void *);
252 void munge_wwwww(const void *, void *);
253 void munge_wwwwww(const void *, void *);
254 void munge_wwwwwww(const void *, void *);
255 void munge_wwwwwwww(const void *, void *);
256 void munge_d(const void *, void *);
257 void munge_dd(const void *, void *);
258 void munge_ddd(const void *, void *);
259 void munge_dddd(const void *, void *);
260 void munge_ddddd(const void *, void *);
261 void munge_dddddd(const void *, void *);
262 void munge_ddddddd(const void *, void *);
263 void munge_dddddddd(const void *, void *);
264 void munge_l(const void *, void *);
265 void munge_wl(const void *, void *);
266 void munge_wlw(const void *, void *);
267 void munge_wwwl(const void *, void *);
268 void munge_wwwwl(const void *, void *);
269 void munge_wwwwwl(const void *, void *);
272 #define munge_ww NULL
273 #define munge_www NULL
274 #define munge_wwww NULL
275 #define munge_wwwww NULL
276 #define munge_wwwwww NULL
277 #define munge_wwwwwww NULL
278 #define munge_wwwwwwww NULL
280 #define munge_dd NULL
281 #define munge_ddd NULL
282 #define munge_dddd NULL
283 #define munge_ddddd NULL
284 #define munge_dddddd NULL
285 #define munge_ddddddd NULL
286 #define munge_dddddddd NULL
288 #define munge_wl NULL
289 #define munge_wlw NULL
290 #define munge_wwwl NULL
291 #define munge_wwwwl NULL
292 #define munge_wwwwwl NULL
294 #endif /* !__MUNGE_ONCE */
296 struct kern_invalid_args
{
299 extern kern_return_t
kern_invalid(
300 struct kern_invalid_args
*args
);
302 struct mach_reply_port_args
{
305 extern mach_port_name_t
mach_reply_port(
306 struct mach_reply_port_args
*args
);
308 struct thread_self_trap_args
{
311 extern mach_port_name_t
thread_self_trap(
312 struct thread_self_trap_args
*args
);
314 struct task_self_trap_args
{
317 extern mach_port_name_t
task_self_trap(
318 struct task_self_trap_args
*args
);
320 struct host_self_trap_args
{
323 extern mach_port_name_t
host_self_trap(
324 struct host_self_trap_args
*args
);
326 struct mach_msg_overwrite_trap_args
{
327 PAD_ARG_(mach_vm_address_t
, msg
);
328 PAD_ARG_(mach_msg_option_t
, option
);
329 PAD_ARG_(mach_msg_size_t
, send_size
);
330 PAD_ARG_(mach_msg_size_t
, rcv_size
);
331 PAD_ARG_(mach_port_name_t
, rcv_name
);
332 PAD_ARG_(mach_msg_timeout_t
, timeout
);
333 PAD_ARG_(mach_port_name_t
, notify
);
334 PAD_ARG_(mach_vm_address_t
, rcv_msg
); /* Unused on mach_msg_trap */
336 extern mach_msg_return_t
mach_msg_trap(
337 struct mach_msg_overwrite_trap_args
*args
);
338 extern mach_msg_return_t
mach_msg_overwrite_trap(
339 struct mach_msg_overwrite_trap_args
*args
);
341 struct semaphore_signal_trap_args
{
342 PAD_ARG_(mach_port_name_t
, signal_name
);
344 extern kern_return_t
semaphore_signal_trap(
345 struct semaphore_signal_trap_args
*args
);
347 struct semaphore_signal_all_trap_args
{
348 PAD_ARG_(mach_port_name_t
, signal_name
);
350 extern kern_return_t
semaphore_signal_all_trap(
351 struct semaphore_signal_all_trap_args
*args
);
353 struct semaphore_signal_thread_trap_args
{
354 PAD_ARG_(mach_port_name_t
, signal_name
);
355 PAD_ARG_(mach_port_name_t
, thread_name
);
357 extern kern_return_t
semaphore_signal_thread_trap(
358 struct semaphore_signal_thread_trap_args
*args
);
360 struct semaphore_wait_trap_args
{
361 PAD_ARG_(mach_port_name_t
, wait_name
);
363 extern kern_return_t
semaphore_wait_trap(
364 struct semaphore_wait_trap_args
*args
);
366 struct semaphore_wait_signal_trap_args
{
367 PAD_ARG_(mach_port_name_t
, wait_name
);
368 PAD_ARG_(mach_port_name_t
, signal_name
);
370 extern kern_return_t
semaphore_wait_signal_trap(
371 struct semaphore_wait_signal_trap_args
*args
);
373 struct semaphore_timedwait_trap_args
{
374 PAD_ARG_(mach_port_name_t
, wait_name
);
375 PAD_ARG_(unsigned int, sec
);
376 PAD_ARG_(clock_res_t
, nsec
);
378 extern kern_return_t
semaphore_timedwait_trap(
379 struct semaphore_timedwait_trap_args
*args
);
381 struct semaphore_timedwait_signal_trap_args
{
382 PAD_ARG_(mach_port_name_t
, wait_name
);
383 PAD_ARG_(mach_port_name_t
, signal_name
);
384 PAD_ARG_(unsigned int, sec
);
385 PAD_ARG_(clock_res_t
, nsec
);
387 extern kern_return_t
semaphore_timedwait_signal_trap(
388 struct semaphore_timedwait_signal_trap_args
*args
);
390 /* not published to LP64 clients */
391 struct init_process_args
{
394 extern kern_return_t
init_process(
395 struct init_process_args
*args
);
399 PAD_ARG_(vm_offset_t
, offset
);
400 PAD_ARG_(vm_offset_t
*, va
);
401 PAD_ARG_(boolean_t
, findspace
);
402 PAD_ARG_(vm_size_t
, size
);
404 extern kern_return_t
map_fd(
405 struct map_fd_args
*args
);
407 struct task_for_pid_args
{
408 PAD_ARG_(mach_port_name_t
, target_tport
);
410 PAD_ARG_(user_addr_t
, t
);
412 extern kern_return_t
task_for_pid(
413 struct task_for_pid_args
*args
);
415 struct pid_for_task_args
{
416 PAD_ARG_(mach_port_name_t
, t
);
417 PAD_ARG_(user_addr_t
, pid
);
419 extern kern_return_t
pid_for_task(
420 struct pid_for_task_args
*args
);
422 /* not published to LP64 clients*/
423 struct macx_swapon_args
{
424 PAD_ARG_(char *, filename
);
425 PAD_ARG_(int, flags
);
427 PAD_ARG_(int, priority
);
429 extern kern_return_t
macx_swapon(
430 struct macx_swapon_args
*args
);
432 struct macx_swapoff_args
{
433 PAD_ARG_(char *, filename
);
434 PAD_ARG_(int, flags
);
436 extern kern_return_t
macx_swapoff(
437 struct macx_swapoff_args
*args
);
439 struct macx_triggers_args
{
440 PAD_ARG_(int, hi_water
);
441 PAD_ARG_(int, low_water
);
442 PAD_ARG_(int, flags
);
443 PAD_ARG_(mach_port_t
, alert_port
);
445 extern kern_return_t
macx_triggers(
446 struct macx_triggers_args
*args
);
448 struct macx_backing_store_suspend_args
{
449 PAD_ARG_(boolean_t
, suspend
);
451 extern kern_return_t
macx_backing_store_suspend(
452 struct macx_backing_store_suspend_args
*args
);
454 struct macx_backing_store_recovery_args
{
457 extern kern_return_t
macx_backing_store_recovery(
458 struct macx_backing_store_recovery_args
*args
);
460 struct swtch_pri_args
{
463 extern boolean_t
swtch_pri(
464 struct swtch_pri_args
*args
);
469 extern boolean_t
swtch(
470 struct swtch_args
*args
);
472 struct clock_sleep_trap_args
{
473 PAD_ARG_(mach_port_name_t
, clock_name
);
474 PAD_ARG_(sleep_type_t
, sleep_type
);
475 PAD_ARG_(int, sleep_sec
);
476 PAD_ARG_(int, sleep_nsec
);
477 PAD_ARG_(mach_vm_address_t
, wakeup_time
);
479 extern kern_return_t
clock_sleep_trap(
480 struct clock_sleep_trap_args
*args
);
482 struct thread_switch_args
{
483 PAD_ARG_(mach_port_name_t
, thread_name
);
484 PAD_ARG_(int, option
);
485 PAD_ARG_(mach_msg_timeout_t
, option_time
);
487 extern kern_return_t
thread_switch(
488 struct thread_switch_args
*args
);
490 struct mach_timebase_info_trap_args
{
491 PAD_ARG_(mach_vm_address_t
, info
);
493 extern kern_return_t
mach_timebase_info_trap(
494 struct mach_timebase_info_trap_args
*args
);
496 struct mach_wait_until_trap_args
{
497 PAD_ARG_(uint64_t, deadline
);
499 extern kern_return_t
mach_wait_until_trap(
500 struct mach_wait_until_trap_args
*args
);
502 struct mk_timer_create_trap_args
{
505 extern mach_port_name_t
mk_timer_create_trap(
506 struct mk_timer_create_trap_args
*args
);
508 struct mk_timer_destroy_trap_args
{
509 PAD_ARG_(mach_port_name_t
, name
);
511 extern kern_return_t
mk_timer_destroy_trap(
512 struct mk_timer_destroy_trap_args
*args
);
514 struct mk_timer_arm_trap_args
{
515 PAD_ARG_(mach_port_name_t
, name
);
516 PAD_ARG_(uint64_t, expire_time
);
518 extern kern_return_t
mk_timer_arm_trap(
519 struct mk_timer_arm_trap_args
*args
);
521 struct mk_timer_cancel_trap_args
{
522 PAD_ARG_(mach_port_name_t
, name
);
523 PAD_ARG_(mach_vm_address_t
, result_time
);
525 extern kern_return_t
mk_timer_cancel_trap(
526 struct mk_timer_cancel_trap_args
*args
);
528 /* no user-level prototype for this one */
529 struct mk_timebase_info_trap_args
{
530 PAD_ARG_(uint32_t *, delta
);
531 PAD_ARG_(uint32_t *, abs_to_ns_numer
);
532 PAD_ARG_(uint32_t *, abs_to_ns_denom
);
533 PAD_ARG_(uint32_t *, proc_to_abs_numer
);
534 PAD_ARG_(uint32_t *, proc_to_abs_denom
);
536 extern void mk_timebase_info_trap(
537 struct mk_timebase_info_trap_args
*args
);
539 /* not published to LP64 clients yet */
540 struct iokit_user_client_trap_args
{
541 PAD_ARG_(void *, userClientRef
);
542 PAD_ARG_(uint32_t, index
);
543 PAD_ARG_(void *, p1
);
544 PAD_ARG_(void *, p2
);
545 PAD_ARG_(void *, p3
);
546 PAD_ARG_(void *, p4
);
547 PAD_ARG_(void *, p5
);
548 PAD_ARG_(void *, p6
);
550 kern_return_t
iokit_user_client_trap(
551 struct iokit_user_client_trap_args
*args
);
558 #endif /* XNU_KERNEL_PRIVATE */
564 #endif /* _MACH_MACH_TRAPS_H_ */