master
1/*
2 * Copyright (c) 2000-2019 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
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
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
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 *
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>.
64 */
65
66#ifndef _MACH_MACH_TRAPS_H_
67#define _MACH_MACH_TRAPS_H_
68
69#include <stdint.h>
70
71#include <mach/error.h>
72#include <mach/std_types.h>
73#include <mach/mach_types.h>
74#include <mach/kern_return.h>
75#include <mach/port.h>
76#include <mach/vm_types.h>
77#include <mach/clock_types.h>
78
79#include <machine/endian.h>
80
81#include <sys/cdefs.h>
82
83__BEGIN_DECLS
84
85
86
87extern kern_return_t clock_sleep_trap(
88 mach_port_name_t clock_name,
89 sleep_type_t sleep_type,
90 int sleep_sec,
91 int sleep_nsec,
92 mach_timespec_t *wakeup_time);
93
94extern kern_return_t _kernelrpc_mach_vm_allocate_trap(
95 mach_port_name_t target,
96 mach_vm_offset_t *addr,
97 mach_vm_size_t size,
98 int flags);
99
100extern kern_return_t _kernelrpc_mach_vm_deallocate_trap(
101 mach_port_name_t target,
102 mach_vm_address_t address,
103 mach_vm_size_t size
104 );
105
106extern kern_return_t task_dyld_process_info_notify_get(
107 mach_port_name_array_t names_addr,
108 natural_t *names_count_addr
109 );
110
111extern kern_return_t _kernelrpc_mach_vm_protect_trap(
112 mach_port_name_t target,
113 mach_vm_address_t address,
114 mach_vm_size_t size,
115 boolean_t set_maximum,
116 vm_prot_t new_protection
117 );
118
119extern kern_return_t _kernelrpc_mach_vm_map_trap(
120 mach_port_name_t target,
121 mach_vm_offset_t *address,
122 mach_vm_size_t size,
123 mach_vm_offset_t mask,
124 int flags,
125 vm_prot_t cur_protection
126 );
127
128extern kern_return_t _kernelrpc_mach_vm_purgable_control_trap(
129 mach_port_name_t target,
130 mach_vm_offset_t address,
131 vm_purgable_t control,
132 int *state);
133
134extern kern_return_t _kernelrpc_mach_port_allocate_trap(
135 mach_port_name_t target,
136 mach_port_right_t right,
137 mach_port_name_t *name
138 );
139
140extern kern_return_t _kernelrpc_mach_port_deallocate_trap(
141 mach_port_name_t target,
142 mach_port_name_t name
143 );
144
145extern kern_return_t _kernelrpc_mach_port_mod_refs_trap(
146 mach_port_name_t target,
147 mach_port_name_t name,
148 mach_port_right_t right,
149 mach_port_delta_t delta
150 );
151
152extern kern_return_t _kernelrpc_mach_port_move_member_trap(
153 mach_port_name_t target,
154 mach_port_name_t member,
155 mach_port_name_t after
156 );
157
158extern kern_return_t _kernelrpc_mach_port_insert_right_trap(
159 mach_port_name_t target,
160 mach_port_name_t name,
161 mach_port_name_t poly,
162 mach_msg_type_name_t polyPoly
163 );
164
165extern kern_return_t _kernelrpc_mach_port_get_attributes_trap(
166 mach_port_name_t target,
167 mach_port_name_t name,
168 mach_port_flavor_t flavor,
169 mach_port_info_t port_info_out,
170 mach_msg_type_number_t *port_info_outCnt
171 );
172
173extern kern_return_t _kernelrpc_mach_port_insert_member_trap(
174 mach_port_name_t target,
175 mach_port_name_t name,
176 mach_port_name_t pset
177 );
178
179extern kern_return_t _kernelrpc_mach_port_extract_member_trap(
180 mach_port_name_t target,
181 mach_port_name_t name,
182 mach_port_name_t pset
183 );
184
185extern kern_return_t _kernelrpc_mach_port_construct_trap(
186 mach_port_name_t target,
187 mach_port_options_t *options,
188 uint64_t context,
189 mach_port_name_t *name
190 );
191
192extern kern_return_t _kernelrpc_mach_port_destruct_trap(
193 mach_port_name_t target,
194 mach_port_name_t name,
195 mach_port_delta_t srdelta,
196 uint64_t guard
197 );
198
199extern kern_return_t _kernelrpc_mach_port_guard_trap(
200 mach_port_name_t target,
201 mach_port_name_t name,
202 uint64_t guard,
203 boolean_t strict
204 );
205
206extern kern_return_t _kernelrpc_mach_port_unguard_trap(
207 mach_port_name_t target,
208 mach_port_name_t name,
209 uint64_t guard
210 );
211
212extern kern_return_t mach_generate_activity_id(
213 mach_port_name_t target,
214 int count,
215 uint64_t *activity_id
216 );
217
218extern kern_return_t macx_swapon(
219 uint64_t filename,
220 int flags,
221 int size,
222 int priority);
223
224extern kern_return_t macx_swapoff(
225 uint64_t filename,
226 int flags);
227
228extern kern_return_t macx_triggers(
229 int hi_water,
230 int low_water,
231 int flags,
232 mach_port_t alert_port);
233
234extern kern_return_t macx_backing_store_suspend(
235 boolean_t suspend);
236
237extern kern_return_t macx_backing_store_recovery(
238 int pid);
239
240extern boolean_t swtch_pri(int pri);
241
242extern boolean_t swtch(void);
243
244extern kern_return_t thread_switch(
245 mach_port_name_t thread_name,
246 int option,
247 mach_msg_timeout_t option_time);
248
249extern mach_port_name_t task_self_trap(void);
250
251extern kern_return_t host_create_mach_voucher_trap(
252 mach_port_name_t host,
253 mach_voucher_attr_raw_recipe_array_t recipes,
254 int recipes_size,
255 mach_port_name_t *voucher);
256
257extern kern_return_t mach_voucher_extract_attr_recipe_trap(
258 mach_port_name_t voucher_name,
259 mach_voucher_attr_key_t key,
260 mach_voucher_attr_raw_recipe_t recipe,
261 mach_msg_type_number_t *recipe_size);
262
263extern kern_return_t _kernelrpc_mach_port_type_trap(
264 ipc_space_t task,
265 mach_port_name_t name,
266 mach_port_type_t *ptype);
267
268extern kern_return_t _kernelrpc_mach_port_request_notification_trap(
269 ipc_space_t task,
270 mach_port_name_t name,
271 mach_msg_id_t msgid,
272 mach_port_mscount_t sync,
273 mach_port_name_t notify,
274 mach_msg_type_name_t notifyPoly,
275 mach_port_name_t *previous);
276
277/*
278 * Obsolete interfaces.
279 */
280
281extern kern_return_t task_for_pid(
282 mach_port_name_t target_tport,
283 int pid,
284 mach_port_name_t *t);
285
286extern kern_return_t task_name_for_pid(
287 mach_port_name_t target_tport,
288 int pid,
289 mach_port_name_t *tn);
290
291extern kern_return_t pid_for_task(
292 mach_port_name_t t,
293 int *x);
294
295extern kern_return_t debug_control_port_for_pid(
296 mach_port_name_t target_tport,
297 int pid,
298 mach_port_name_t *t);
299
300extern mach_error_t mach_vm_reclaim_update_kernel_accounting_trap(
301 mach_port_name_t target_tport,
302 uint64_t *bytes_reclaimed);
303
304
305__END_DECLS
306
307#endif /* _MACH_MACH_TRAPS_H_ */