]> git.saurik.com Git - apple/xnu.git/blame_incremental - osfmk/mach/mach_traps.h
xnu-792.6.76.tar.gz
[apple/xnu.git] / osfmk / mach / mach_traps.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 2000-2004 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
82extern mach_port_name_t mach_reply_port(void);
83
84extern mach_port_name_t thread_self_trap(void);
85
86extern mach_port_name_t host_self_trap(void);
87
88extern 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
97extern 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
108extern kern_return_t semaphore_signal_trap(
109 mach_port_name_t signal_name);
110
111extern kern_return_t semaphore_signal_all_trap(
112 mach_port_name_t signal_name);
113
114extern kern_return_t semaphore_signal_thread_trap(
115 mach_port_name_t signal_name,
116 mach_port_name_t thread_name);
117
118extern kern_return_t semaphore_wait_trap(
119 mach_port_name_t wait_name);
120
121extern kern_return_t semaphore_wait_signal_trap(
122 mach_port_name_t wait_name,
123 mach_port_name_t signal_name);
124
125extern kern_return_t semaphore_timedwait_trap(
126 mach_port_name_t wait_name,
127 unsigned int sec,
128 clock_res_t nsec);
129
130extern 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
139extern 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 */
146extern kern_return_t macx_swapon(
147 char *filename,
148 int flags,
149 int size,
150 int priority);
151
152extern kern_return_t macx_swapoff(
153 char *filename,
154 int flags);
155
156extern kern_return_t macx_triggers(
157 int hi_water,
158 int low_water,
159 int flags,
160 mach_port_t alert_port);
161
162extern kern_return_t macx_backing_store_suspend(
163 boolean_t suspend);
164
165extern kern_return_t macx_backing_store_recovery(
166 int pid);
167
168#endif /* !defined(__LP64__) */
169
170extern 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
179extern boolean_t swtch_pri(int pri);
180
181extern boolean_t swtch(void);
182
183extern kern_return_t thread_switch(
184 mach_port_name_t thread_name,
185 int option,
186 mach_msg_timeout_t option_time);
187
188extern mach_port_name_t task_self_trap(void);
189
190/*
191 * Obsolete interfaces.
192 */
193
194extern kern_return_t task_for_pid(
195 mach_port_name_t target_tport,
196 int pid,
197 mach_port_name_t *t);
198
199extern kern_return_t pid_for_task(
200 mach_port_name_t t,
201 int *x);
202
203#if !defined(__LP64__)
204/* these should go away altogether - so no 64 legacy please */
205
206extern kern_return_t map_fd(
207 int fd,
208 vm_offset_t offset,
209 vm_offset_t *va,
210 boolean_t findspace,
211 vm_size_t size);
212
213#endif /* !defined(__LP64__) */
214
215#else /* KERNEL */
216
217#ifdef XNU_KERNEL_PRIVATE
218
219/* Syscall data translations routines */
220#ifdef __ppc__
221#define PAD_(t) (sizeof(uint64_t) <= sizeof(t) \
222 ? 0 : sizeof(uint64_t) - sizeof(t))
223#else
224#define PAD_(t) (sizeof(register_t) <= sizeof(t) \
225 ? 0 : sizeof(register_t) - sizeof(t))
226#endif
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__
242void munge_w(const void *, void *);
243void munge_ww(const void *, void *);
244void munge_www(const void *, void *);
245void munge_wwww(const void *, void *);
246void munge_wwwww(const void *, void *);
247void munge_wwwwww(const void *, void *);
248void munge_wwwwwww(const void *, void *);
249void munge_wwwwwwww(const void *, void *);
250void munge_d(const void *, void *);
251void munge_dd(const void *, void *);
252void munge_ddd(const void *, void *);
253void munge_dddd(const void *, void *);
254void munge_ddddd(const void *, void *);
255void munge_dddddd(const void *, void *);
256void munge_ddddddd(const void *, void *);
257void munge_dddddddd(const void *, void *);
258void munge_l(const void *, void *);
259void munge_wl(const void *, void *);
260void munge_wlw(const void *, void *);
261void munge_wwwl(const void *, void *);
262void munge_wwwwl(const void *, void *);
263void 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
290struct kern_invalid_args {
291 register_t dummy;
292};
293extern kern_return_t kern_invalid(
294 struct kern_invalid_args *args);
295
296struct mach_reply_port_args {
297 register_t dummy;
298};
299extern mach_port_name_t mach_reply_port(
300 struct mach_reply_port_args *args);
301
302struct thread_self_trap_args {
303 register_t dummy;
304};
305extern mach_port_name_t thread_self_trap(
306 struct thread_self_trap_args *args);
307
308struct task_self_trap_args {
309 register_t dummy;
310};
311extern mach_port_name_t task_self_trap(
312 struct task_self_trap_args *args);
313
314struct host_self_trap_args {
315 register_t dummy;
316};
317extern mach_port_name_t host_self_trap(
318 struct host_self_trap_args *args);
319
320struct 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};
330extern mach_msg_return_t mach_msg_trap(
331 struct mach_msg_overwrite_trap_args *args);
332extern mach_msg_return_t mach_msg_overwrite_trap(
333 struct mach_msg_overwrite_trap_args *args);
334
335struct semaphore_signal_trap_args {
336 PAD_ARG_(mach_port_name_t, signal_name);
337};
338extern kern_return_t semaphore_signal_trap(
339 struct semaphore_signal_trap_args *args);
340
341struct semaphore_signal_all_trap_args {
342 PAD_ARG_(mach_port_name_t, signal_name);
343};
344extern kern_return_t semaphore_signal_all_trap(
345 struct semaphore_signal_all_trap_args *args);
346
347struct semaphore_signal_thread_trap_args {
348 PAD_ARG_(mach_port_name_t, signal_name);
349 PAD_ARG_(mach_port_name_t, thread_name);
350};
351extern kern_return_t semaphore_signal_thread_trap(
352 struct semaphore_signal_thread_trap_args *args);
353
354struct semaphore_wait_trap_args {
355 PAD_ARG_(mach_port_name_t, wait_name);
356};
357extern kern_return_t semaphore_wait_trap(
358 struct semaphore_wait_trap_args *args);
359
360struct semaphore_wait_signal_trap_args {
361 PAD_ARG_(mach_port_name_t, wait_name);
362 PAD_ARG_(mach_port_name_t, signal_name);
363};
364extern kern_return_t semaphore_wait_signal_trap(
365 struct semaphore_wait_signal_trap_args *args);
366
367struct 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};
372extern kern_return_t semaphore_timedwait_trap(
373 struct semaphore_timedwait_trap_args *args);
374
375struct 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};
381extern kern_return_t semaphore_timedwait_signal_trap(
382 struct semaphore_timedwait_signal_trap_args *args);
383
384/* not published to LP64 clients */
385struct init_process_args {
386 register_t dummy;
387};
388extern kern_return_t init_process(
389 struct init_process_args *args);
390
391struct 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};
398extern kern_return_t map_fd(
399 struct map_fd_args *args);
400
401struct 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};
406extern kern_return_t task_for_pid(
407 struct task_for_pid_args *args);
408
409struct pid_for_task_args {
410 PAD_ARG_(mach_port_name_t, t);
411 PAD_ARG_(user_addr_t, pid);
412};
413extern kern_return_t pid_for_task(
414 struct pid_for_task_args *args);
415
416/* not published to LP64 clients*/
417struct macx_swapon_args {
418 PAD_ARG_(char *, filename);
419 PAD_ARG_(int, flags);
420 PAD_ARG_(int, size);
421 PAD_ARG_(int, priority);
422};
423extern kern_return_t macx_swapon(
424 struct macx_swapon_args *args);
425
426struct macx_swapoff_args {
427 PAD_ARG_(char *, filename);
428 PAD_ARG_(int, flags);
429};
430extern kern_return_t macx_swapoff(
431 struct macx_swapoff_args *args);
432
433struct 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);
438};
439extern kern_return_t macx_triggers(
440 struct macx_triggers_args *args);
441
442struct macx_backing_store_suspend_args {
443 PAD_ARG_(boolean_t, suspend);
444};
445extern kern_return_t macx_backing_store_suspend(
446 struct macx_backing_store_suspend_args *args);
447
448struct macx_backing_store_recovery_args {
449 PAD_ARG_(int, pid);
450};
451extern kern_return_t macx_backing_store_recovery(
452 struct macx_backing_store_recovery_args *args);
453
454struct swtch_pri_args {
455 PAD_ARG_(int, pri);
456};
457extern boolean_t swtch_pri(
458 struct swtch_pri_args *args);
459
460struct swtch_args {
461 register_t dummy;
462};
463extern boolean_t swtch(
464 struct swtch_args *args);
465
466struct 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);
472};
473extern kern_return_t clock_sleep_trap(
474 struct clock_sleep_trap_args *args);
475
476struct 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);
480};
481extern kern_return_t thread_switch(
482 struct thread_switch_args *args);
483
484struct mach_timebase_info_trap_args {
485 PAD_ARG_(mach_vm_address_t, info);
486};
487extern kern_return_t mach_timebase_info_trap(
488 struct mach_timebase_info_trap_args *args);
489
490struct mach_wait_until_trap_args {
491 PAD_ARG_(uint64_t, deadline);
492};
493extern kern_return_t mach_wait_until_trap(
494 struct mach_wait_until_trap_args *args);
495
496struct mk_timer_create_trap_args {
497 register_t dummy;
498};
499extern mach_port_name_t mk_timer_create_trap(
500 struct mk_timer_create_trap_args *args);
501
502struct mk_timer_destroy_trap_args {
503 PAD_ARG_(mach_port_name_t, name);
504};
505extern kern_return_t mk_timer_destroy_trap(
506 struct mk_timer_destroy_trap_args *args);
507
508struct mk_timer_arm_trap_args {
509 PAD_ARG_(mach_port_name_t, name);
510 PAD_ARG_(uint64_t, expire_time);
511};
512extern kern_return_t mk_timer_arm_trap(
513 struct mk_timer_arm_trap_args *args);
514
515struct mk_timer_cancel_trap_args {
516 PAD_ARG_(mach_port_name_t, name);
517 PAD_ARG_(mach_vm_address_t, result_time);
518};
519extern kern_return_t mk_timer_cancel_trap(
520 struct mk_timer_cancel_trap_args *args);
521
522/* no user-level prototype for this one */
523struct 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);
529};
530extern void mk_timebase_info_trap(
531 struct mk_timebase_info_trap_args *args);
532
533/* not published to LP64 clients yet */
534struct 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);
543};
544kern_return_t iokit_user_client_trap(
545 struct iokit_user_client_trap_args *args);
546
547#undef PAD_
548#undef PADL_
549#undef PADR_
550#undef PAD_ARG_
551
552#endif /* XNU_KERNEL_PRIVATE */
553
554#endif /* KERNEL */
555
556__END_DECLS
557
558#endif /* _MACH_MACH_TRAPS_H_ */