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
);
169 mach_port_name_t name
,
170 mach_msg_trailer_type_t trailer_type
,
171 mach_port_seqno_t
*seqnop
,
172 mach_msg_size_t
*msg_sizep
,
173 mach_msg_id_t
*msg_idp
,
174 mach_msg_trailer_info_t trailer_infop
,
175 mach_msg_type_number_t
*trailer_sizep
)
179 rv
= _kernelrpc_mach_port_peek(task
, name
, trailer_type
,
180 seqnop
, msg_sizep
, msg_idp
,
181 trailer_infop
, trailer_sizep
);
187 mach_port_set_mscount(
189 mach_port_name_t name
,
190 mach_port_mscount_t mscount
)
194 rv
= _kernelrpc_mach_port_set_mscount(task
, name
, mscount
);
200 mach_port_get_set_status(
202 mach_port_name_t name
,
203 mach_port_name_array_t
*members
,
204 mach_msg_type_number_t
*membersCnt
)
208 rv
= _kernelrpc_mach_port_get_set_status(task
, name
, members
,
215 mach_port_move_member(
217 mach_port_name_t member
,
218 mach_port_name_t after
)
222 rv
= _kernelrpc_mach_port_move_member_trap(task
, member
, after
);
224 if (rv
== MACH_SEND_INVALID_DEST
)
225 rv
= _kernelrpc_mach_port_move_member(task
, member
, after
);
231 mach_port_request_notification(
233 mach_port_name_t name
,
235 mach_port_mscount_t sync
,
237 mach_msg_type_name_t notifyPoly
,
238 mach_port_t
*previous
)
242 rv
= _kernelrpc_mach_port_request_notification(task
, name
, msgid
,
243 sync
, notify
, notifyPoly
, previous
);
249 mach_port_insert_right(
251 mach_port_name_t name
,
253 mach_msg_type_name_t polyPoly
)
257 rv
= _kernelrpc_mach_port_insert_right_trap(task
, name
, poly
, polyPoly
);
259 if (rv
== MACH_SEND_INVALID_DEST
)
260 rv
= _kernelrpc_mach_port_insert_right(task
, name
, poly
,
267 mach_port_extract_right(
269 mach_port_name_t name
,
270 mach_msg_type_name_t msgt_name
,
272 mach_msg_type_name_t
*polyPoly
)
276 rv
= _kernelrpc_mach_port_extract_right(task
, name
, msgt_name
,
285 mach_port_name_t name
,
286 mach_port_seqno_t seqno
)
290 rv
= _kernelrpc_mach_port_set_seqno(task
, name
, seqno
);
296 mach_port_get_attributes(
298 mach_port_name_t name
,
299 mach_port_flavor_t flavor
,
300 mach_port_info_t port_info_out
,
301 mach_msg_type_number_t
*port_info_outCnt
)
305 rv
= _kernelrpc_mach_port_get_attributes(task
, name
, flavor
,
306 port_info_out
, port_info_outCnt
);
312 mach_port_set_attributes(
314 mach_port_name_t name
,
315 mach_port_flavor_t flavor
,
316 mach_port_info_t port_info
,
317 mach_msg_type_number_t port_infoCnt
)
321 rv
= _kernelrpc_mach_port_set_attributes(task
, name
, flavor
,
322 port_info
, port_infoCnt
);
328 mach_port_allocate_qos(
330 mach_port_right_t right
,
331 mach_port_qos_t
*qos
,
332 mach_port_name_t
*name
)
336 rv
= _kernelrpc_mach_port_allocate_qos(task
, right
, qos
, name
);
342 mach_port_allocate_full(
344 mach_port_right_t right
,
346 mach_port_qos_t
*qos
,
347 mach_port_name_t
*name
)
351 rv
= _kernelrpc_mach_port_allocate_full(task
, right
, proto
, qos
, name
);
363 rv
= _kernelrpc_task_set_port_space(task
, table_entries
);
369 mach_port_get_srights(
371 mach_port_name_t name
,
372 mach_port_rights_t
*srights
)
376 rv
= _kernelrpc_mach_port_get_srights(task
, name
, srights
);
382 mach_port_space_info(
384 ipc_info_space_t
*space_info
,
385 ipc_info_name_array_t
*table_info
,
386 mach_msg_type_number_t
*table_infoCnt
,
387 ipc_info_tree_name_array_t
*tree_info
,
388 mach_msg_type_number_t
*tree_infoCnt
)
392 rv
= _kernelrpc_mach_port_space_info(task
, space_info
, table_info
,
393 table_infoCnt
, tree_info
, tree_infoCnt
);
399 mach_port_space_basic_info(
401 ipc_info_space_basic_t
*space_basic_info
)
405 rv
= _kernelrpc_mach_port_space_basic_info(task
, space_basic_info
);
411 mach_port_dnrequest_info(
413 mach_port_name_t name
,
419 rv
= _kernelrpc_mach_port_dnrequest_info(task
, name
, dnr_total
,
426 mach_port_kernel_object(
428 mach_port_name_t name
,
429 unsigned *object_type
,
430 unsigned *object_addr
)
434 rv
= _kernelrpc_mach_port_kernel_object(task
, name
,
435 object_type
, object_addr
);
441 mach_port_insert_member(
443 mach_port_name_t name
,
444 mach_port_name_t pset
)
448 rv
= _kernelrpc_mach_port_insert_member_trap(task
, name
, pset
);
450 if (rv
== MACH_SEND_INVALID_DEST
)
451 rv
= _kernelrpc_mach_port_insert_member(task
, name
, pset
);
457 mach_port_extract_member(
459 mach_port_name_t name
,
460 mach_port_name_t pset
)
464 rv
= _kernelrpc_mach_port_extract_member_trap(task
, name
, pset
);
466 if (rv
== MACH_SEND_INVALID_DEST
)
467 rv
= _kernelrpc_mach_port_extract_member(task
, name
, pset
);
473 mach_port_get_context(
475 mach_port_name_t name
,
476 mach_port_context_t
*context
)
479 mach_vm_address_t wide_context
;
481 rv
= _kernelrpc_mach_port_get_context(task
, name
, &wide_context
);
483 if (rv
== KERN_SUCCESS
) {
484 *context
= (mach_port_context_t
)wide_context
;
491 mach_port_set_context(
493 mach_port_name_t name
,
494 mach_port_context_t context
)
498 rv
= _kernelrpc_mach_port_set_context(task
, name
, context
);
506 mach_port_name_t name
,
507 natural_t
*object_type
,
508 mach_vm_address_t
*object_addr
)
512 rv
= _kernelrpc_mach_port_kobject(task
, name
, object_type
, object_addr
);
520 mach_port_options_t
*options
,
521 mach_port_context_t context
,
522 mach_port_name_t
*name
)
526 rv
= _kernelrpc_mach_port_construct_trap(task
, options
, (uint64_t) context
, name
);
528 if (rv
== MACH_SEND_INVALID_DEST
)
529 rv
= _kernelrpc_mach_port_construct(task
, options
, (uint64_t) context
, name
);
537 mach_port_name_t name
,
538 mach_port_delta_t srdelta
,
539 mach_port_context_t guard
)
543 rv
= _kernelrpc_mach_port_destruct_trap(task
, name
, srdelta
, (uint64_t) guard
);
545 if (rv
== MACH_SEND_INVALID_DEST
)
546 rv
= _kernelrpc_mach_port_destruct(task
, name
, srdelta
, (uint64_t) guard
);
555 mach_port_name_t name
,
556 mach_port_context_t guard
,
561 rv
= _kernelrpc_mach_port_guard_trap(task
, name
, (uint64_t) guard
, strict
);
563 if (rv
== MACH_SEND_INVALID_DEST
)
564 rv
= _kernelrpc_mach_port_guard(task
, name
, (uint64_t) guard
, strict
);
573 mach_port_name_t name
,
574 mach_port_context_t guard
)
578 rv
= _kernelrpc_mach_port_unguard_trap(task
, name
, (uint64_t) guard
);
580 if (rv
== MACH_SEND_INVALID_DEST
)
581 rv
= _kernelrpc_mach_port_unguard(task
, name
, (uint64_t) guard
);
588 _kernelrpc_mach_voucher_extract_attr_recipe(
589 mach_port_name_t voucher
,
590 mach_voucher_attr_key_t key
,
591 mach_voucher_attr_raw_recipe_t recipe
,
592 mach_msg_type_number_t
*recipe_size
);
595 mach_voucher_extract_attr_recipe(
596 mach_port_name_t voucher
,
597 mach_voucher_attr_key_t key
,
598 mach_voucher_attr_raw_recipe_t recipe
,
599 mach_msg_type_number_t
*recipe_size
)
603 rv
= mach_voucher_extract_attr_recipe_trap(voucher
, key
, recipe
, recipe_size
);
606 /* REMOVE once XBS kernel has new trap */
607 if (rv
== ((1 << 24) | 72)) /* see mach/i386/syscall_sw.h */
608 rv
= MACH_SEND_INVALID_DEST
;
609 #elif defined(__i386__)
610 /* REMOVE once XBS kernel has new trap */
611 if (rv
== (kern_return_t
)(-72))
612 rv
= MACH_SEND_INVALID_DEST
;
615 if (rv
== MACH_SEND_INVALID_DEST
)
616 rv
= _kernelrpc_mach_voucher_extract_attr_recipe(voucher
, key
, recipe
, recipe_size
);