2 * Copyright (c) 2011 Apple 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@
29 #include <mach/mach_port_internal.h>
30 #include <mach/mach.h>
31 #include <mach/mach_vm.h>
32 #include <mach/mach_traps.h>
37 mach_port_name_array_t
*names
,
38 mach_msg_type_number_t
*namesCnt
,
39 mach_port_type_array_t
*types
,
40 mach_msg_type_number_t
*typesCnt
)
44 rv
= _kernelrpc_mach_port_names(task
, names
, namesCnt
, types
,
53 mach_port_name_t name
,
54 mach_port_type_t
*ptype
)
58 rv
= _kernelrpc_mach_port_type(task
, name
, ptype
);
66 mach_port_name_t old_name
,
67 mach_port_name_t new_name
)
71 rv
= _kernelrpc_mach_port_rename(task
, old_name
, new_name
);
77 mach_port_allocate_name(
79 mach_port_right_t right
,
80 mach_port_name_t name
)
84 rv
= _kernelrpc_mach_port_allocate_name(task
, right
, name
);
92 mach_port_right_t right
,
93 mach_port_name_t
*name
)
97 rv
= _kernelrpc_mach_port_allocate_trap(task
, right
, name
);
99 if (rv
== MACH_SEND_INVALID_DEST
)
100 rv
= _kernelrpc_mach_port_allocate(task
, right
, name
);
108 mach_port_name_t name
)
112 rv
= _kernelrpc_mach_port_destroy_trap(task
, name
);
114 if (rv
== MACH_SEND_INVALID_DEST
)
115 rv
= _kernelrpc_mach_port_destroy(task
, name
);
121 mach_port_deallocate(
123 mach_port_name_t name
)
127 rv
= _kernelrpc_mach_port_deallocate_trap(task
, name
);
129 if (rv
== MACH_SEND_INVALID_DEST
)
130 rv
= _kernelrpc_mach_port_deallocate(task
,name
);
138 mach_port_name_t name
,
139 mach_port_right_t right
,
140 mach_port_urefs_t
*refs
)
144 rv
= _kernelrpc_mach_port_get_refs(task
, name
, right
, refs
);
152 mach_port_name_t name
,
153 mach_port_right_t right
,
154 mach_port_delta_t delta
)
158 rv
= _kernelrpc_mach_port_mod_refs_trap(task
, name
, right
, delta
);
160 if (rv
== MACH_SEND_INVALID_DEST
)
161 rv
= _kernelrpc_mach_port_mod_refs(task
, name
, right
, delta
);
167 mach_port_set_mscount(
169 mach_port_name_t name
,
170 mach_port_mscount_t mscount
)
174 rv
= _kernelrpc_mach_port_set_mscount(task
, name
, mscount
);
180 mach_port_get_set_status(
182 mach_port_name_t name
,
183 mach_port_name_array_t
*members
,
184 mach_msg_type_number_t
*membersCnt
)
188 rv
= _kernelrpc_mach_port_get_set_status(task
, name
, members
,
195 mach_port_move_member(
197 mach_port_name_t member
,
198 mach_port_name_t after
)
202 rv
= _kernelrpc_mach_port_move_member_trap(task
, member
, after
);
204 if (rv
== MACH_SEND_INVALID_DEST
)
205 rv
= _kernelrpc_mach_port_move_member(task
, member
, after
);
211 mach_port_request_notification(
213 mach_port_name_t name
,
215 mach_port_mscount_t sync
,
217 mach_msg_type_name_t notifyPoly
,
218 mach_port_t
*previous
)
222 rv
= _kernelrpc_mach_port_request_notification(task
, name
, msgid
,
223 sync
, notify
, notifyPoly
, previous
);
229 mach_port_insert_right(
231 mach_port_name_t name
,
233 mach_msg_type_name_t polyPoly
)
237 rv
= _kernelrpc_mach_port_insert_right_trap(task
, name
, poly
, polyPoly
);
239 if (rv
== MACH_SEND_INVALID_DEST
)
240 rv
= _kernelrpc_mach_port_insert_right(task
, name
, poly
,
247 mach_port_extract_right(
249 mach_port_name_t name
,
250 mach_msg_type_name_t msgt_name
,
252 mach_msg_type_name_t
*polyPoly
)
256 rv
= _kernelrpc_mach_port_extract_right(task
, name
, msgt_name
,
265 mach_port_name_t name
,
266 mach_port_seqno_t seqno
)
270 rv
= _kernelrpc_mach_port_set_seqno(task
, name
, seqno
);
276 mach_port_get_attributes(
278 mach_port_name_t name
,
279 mach_port_flavor_t flavor
,
280 mach_port_info_t port_info_out
,
281 mach_msg_type_number_t
*port_info_outCnt
)
285 rv
= _kernelrpc_mach_port_get_attributes(task
, name
, flavor
,
286 port_info_out
, port_info_outCnt
);
292 mach_port_set_attributes(
294 mach_port_name_t name
,
295 mach_port_flavor_t flavor
,
296 mach_port_info_t port_info
,
297 mach_msg_type_number_t port_infoCnt
)
301 rv
= _kernelrpc_mach_port_set_attributes(task
, name
, flavor
,
302 port_info
, port_infoCnt
);
308 mach_port_allocate_qos(
310 mach_port_right_t right
,
311 mach_port_qos_t
*qos
,
312 mach_port_name_t
*name
)
316 rv
= _kernelrpc_mach_port_allocate_qos(task
, right
, qos
, name
);
322 mach_port_allocate_full(
324 mach_port_right_t right
,
326 mach_port_qos_t
*qos
,
327 mach_port_name_t
*name
)
331 rv
= _kernelrpc_mach_port_allocate_full(task
, right
, proto
, qos
, name
);
343 rv
= _kernelrpc_task_set_port_space(task
, table_entries
);
349 mach_port_get_srights(
351 mach_port_name_t name
,
352 mach_port_rights_t
*srights
)
356 rv
= _kernelrpc_mach_port_get_srights(task
, name
, srights
);
362 mach_port_space_info(
364 ipc_info_space_t
*space_info
,
365 ipc_info_name_array_t
*table_info
,
366 mach_msg_type_number_t
*table_infoCnt
,
367 ipc_info_tree_name_array_t
*tree_info
,
368 mach_msg_type_number_t
*tree_infoCnt
)
372 rv
= _kernelrpc_mach_port_space_info(task
, space_info
, table_info
,
373 table_infoCnt
, tree_info
, tree_infoCnt
);
379 mach_port_dnrequest_info(
381 mach_port_name_t name
,
387 rv
= _kernelrpc_mach_port_dnrequest_info(task
, name
, dnr_total
,
394 mach_port_kernel_object(
396 mach_port_name_t name
,
397 unsigned *object_type
,
398 unsigned *object_addr
)
402 rv
= _kernelrpc_mach_port_kernel_object(task
, name
,
403 object_type
, object_addr
);
409 mach_port_insert_member(
411 mach_port_name_t name
,
412 mach_port_name_t pset
)
416 rv
= _kernelrpc_mach_port_insert_member_trap(task
, name
, pset
);
418 if (rv
== MACH_SEND_INVALID_DEST
)
419 rv
= _kernelrpc_mach_port_insert_member(task
, name
, pset
);
425 mach_port_extract_member(
427 mach_port_name_t name
,
428 mach_port_name_t pset
)
432 rv
= _kernelrpc_mach_port_extract_member_trap(task
, name
, pset
);
434 if (rv
== MACH_SEND_INVALID_DEST
)
435 rv
= _kernelrpc_mach_port_extract_member(task
, name
, pset
);
441 mach_port_get_context(
443 mach_port_name_t name
,
444 mach_port_context_t
*context
)
447 mach_vm_address_t wide_context
;
449 rv
= _kernelrpc_mach_port_get_context(task
, name
, &wide_context
);
451 if (rv
== KERN_SUCCESS
) {
452 *context
= (mach_port_context_t
)wide_context
;
459 mach_port_set_context(
461 mach_port_name_t name
,
462 mach_port_context_t context
)
466 rv
= _kernelrpc_mach_port_set_context(task
, name
, context
);
474 mach_port_name_t name
,
475 natural_t
*object_type
,
476 mach_vm_address_t
*object_addr
)
480 rv
= _kernelrpc_mach_port_kobject(task
, name
, object_type
, object_addr
);