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