2 * Copyright (c) 2000-2004 Apple Computer, 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 * @OSF_FREE_COPYRIGHT@
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
34 * All Rights Reserved.
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.
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.
46 * Carnegie Mellon requests users of this software to return to
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
59 * File: mach/mach_port.defs
62 * Exported kernel calls.
68 #endif /* KERNEL_SERVER */
71 #if !KERNEL && !LIBSYSCALL_INTERFACE
72 UserPrefix _kernelrpc_;
75 #include <mach/std_types.defs>
76 #include <mach/mach_types.defs>
77 #include <mach_debug/mach_debug_types.defs>
79 type kobject_description_t = c_string[*:512];
82 * Returns the set of port and port set names
83 * to which the target task has access, along with
84 * the type (set or port) for each name.
87 routine mach_port_names(
89 out names : mach_port_name_array_t;
90 out types : mach_port_type_array_t);
93 * Returns the type (set or port) for the port name
94 * within the target task. Also indicates whether
95 * there is a dead-name request for the name.
98 routine mach_port_type(
100 name : mach_port_name_t;
101 out ptype : mach_port_type_t);
104 * Changes the name by which a port (or port set) is known to
105 * the target task. The new name can't be in use. The
106 * old name becomes available for recycling.
108 * This interface is OBSOLETE and will always
109 * return KERN_NOT_SUPPORTED.
112 routine mach_port_rename(
114 old_name : mach_port_name_t;
115 new_name : mach_port_name_t);
118 * Allocates the specified kind of object, with the given name.
119 * The right must be one of
120 * MACH_PORT_RIGHT_RECEIVE
121 * MACH_PORT_RIGHT_PORT_SET
122 * MACH_PORT_RIGHT_DEAD_NAME
123 * New port sets are empty. New ports don't have any
124 * send/send-once rights or queued messages. The make-send
125 * count is zero and their queue limit is MACH_PORT_QLIMIT_DEFAULT.
126 * New sets, ports, and dead names have one user reference.
129 routine mach_port_allocate_name(
131 right : mach_port_right_t;
132 name : mach_port_name_t);
135 * Allocates the specified kind of object.
136 * The right must be one of
137 * MACH_PORT_RIGHT_RECEIVE
138 * MACH_PORT_RIGHT_PORT_SET
139 * MACH_PORT_RIGHT_DEAD_NAME
140 * Like port_allocate_name, but the kernel picks a name.
141 * It can use any name not associated with a right.
144 routine mach_port_allocate(
146 right : mach_port_right_t;
147 out name : mach_port_name_t);
150 * Destroys all rights associated with the name and makes it
151 * available for recycling immediately. The name can be a
152 * port (possibly with multiple user refs), a port set, or
153 * a dead name (again, with multiple user refs).
156 routine mach_port_destroy(
158 name : mach_port_name_t);
161 * Releases one send/send-once/dead-name user ref.
162 * Just like mach_port_mod_refs -1, but deduces the
163 * correct type of right. This allows a user task
164 * to release a ref for a port without worrying
165 * about whether the port has died or not.
168 routine mach_port_deallocate(
170 name : mach_port_name_t);
173 * A port set always has one user ref.
174 * A send-once right always has one user ref.
175 * A dead name always has one or more user refs.
176 * A send right always has one or more user refs.
177 * A receive right always has one user ref.
178 * The right must be one of
179 * MACH_PORT_RIGHT_RECEIVE
180 * MACH_PORT_RIGHT_PORT_SET
181 * MACH_PORT_RIGHT_DEAD_NAME
182 * MACH_PORT_RIGHT_SEND
183 * MACH_PORT_RIGHT_SEND_ONCE
186 routine mach_port_get_refs(
188 name : mach_port_name_t;
189 right : mach_port_right_t;
190 out refs : mach_port_urefs_t);
193 * The delta is a signed change to the task's
194 * user ref count for the right. Only dead names
195 * and send rights can have a positive delta.
196 * The resulting user ref count can't be negative.
197 * If it is zero, the right is deallocated.
198 * If the name isn't a composite right, it becomes
199 * available for recycling. The right must be one of
200 * MACH_PORT_RIGHT_RECEIVE
201 * MACH_PORT_RIGHT_PORT_SET
202 * MACH_PORT_RIGHT_DEAD_NAME
203 * MACH_PORT_RIGHT_SEND
204 * MACH_PORT_RIGHT_SEND_ONCE
207 routine mach_port_mod_refs(
209 name : mach_port_name_t;
210 right : mach_port_right_t;
211 delta : mach_port_delta_t);
214 * Peek at the message queue for the specified receive
215 * right and return info about the message with the
216 * sequence number matching the input. If zero is
217 * specified as the seqno, the first message in the
218 * queue will be peeked.
220 * Only the following trailer types are currently supported:
221 * MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0)
223 * or'ed with one of these element types:
224 * MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_NULL)
225 * MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_SEQNO)
226 * MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_SENDER)
227 * MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT)
229 routine mach_port_peek(
231 name : mach_port_name_t;
232 trailer_type : mach_msg_trailer_type_t;
233 inout request_seqnop : mach_port_seqno_t;
234 out msg_sizep : mach_msg_size_t;
235 out msg_idp : mach_msg_id_t;
236 out trailer_infop : mach_msg_trailer_info_t, CountInOut);
239 * Only valid for receive rights.
240 * Sets the make-send count for the port.
242 routine mach_port_set_mscount(
244 name : mach_port_name_t;
245 mscount : mach_port_mscount_t);
248 * Only valid for port sets. Returns a list of
253 mach_port_get_set_status_from_user(
256 mach_port_get_set_status(
257 task : ipc_space_read_t;
259 name : mach_port_name_t;
260 out members : mach_port_name_array_t);
263 * Puts the member port (the task must have receive rights)
264 * into the after port set. If the port is already a member
265 * of any set(s), it is atomically removed from those sets as
266 * part of this operation. (If after is MACH_PORT_NULL, the
267 * port is still removed from all current sets).
270 routine mach_port_move_member(
272 member : mach_port_name_t;
273 after : mach_port_name_t);
276 * Requests a notification from the kernel. The request
277 * must supply the send-once right which is used for
278 * the notification. If a send-once right was previously
279 * registered, it is returned. The msgid must be one of:
280 * MACH_NOTIFY_PORT_DESTROYED (receive rights)
281 * MACH_NOTIFY_DEAD_NAME (send/receive/send-once rights)
282 * MACH_NOTIFY_SEND_POSSIBLE (send/receive/send-once rights)
283 * MACH_NOTIFY_NO_SENDERS (receive rights)
285 * The sync value specifies whether a notification should
286 * get sent immediately, if appropriate. The exact meaning
287 * depends on the notification:
288 * MACH_NOTIFY_PORT_DESTROYED: must be zero.
289 * MACH_NOTIFY_DEAD_NAME: if non-zero, then name can be dead,
290 * and the notification gets sent immediately.
291 * If zero, then name can't be dead.
292 * MACH_NOTIFY_SEND_POSSIBLE: if non-zero, will generate a send-
293 * possible notification as soon as it is possible to send
294 * to the port. If zero, will generate a send-possible
295 * notification only after a subsequent failed send
296 * (with MACH_SEND_NOTIFY option to mach_msg call). Can
297 * generate a dead-name notification if name is already dead
298 * or becomes dead before a send-possible notification fires.
299 * MACH_NOTIFY_NO_SENDERS: the notification gets sent
300 * immediately if the current mscount is greater
301 * than or equal to the sync value and there are no
302 * extant send rights.
304 * If the name is deleted before a successfully registered notification
305 * is delivered, it is replaced with a port-deleted notification.
308 routine mach_port_request_notification(
310 name : mach_port_name_t;
311 msgid : mach_msg_id_t;
312 sync : mach_port_mscount_t;
313 notify : mach_port_send_once_t;
314 out previous : mach_port_move_send_once_t);
317 * Inserts the specified rights into the target task,
318 * using the specified name. If inserting send/receive
319 * rights and the task already has send/receive rights
320 * for the port, then the names must agree. In any case,
321 * the task gains a user ref for the port.
324 routine mach_port_insert_right(
326 name : mach_port_name_t;
327 poly : mach_port_poly_t);
330 * Returns the specified right for the named port
331 * in the target task, extracting that right from
332 * the target task. The target task loses a user
333 * ref and the name may be available for recycling.
334 * msgt_name must be one of
335 * MACH_MSG_TYPE_MOVE_RECEIVE
336 * MACH_MSG_TYPE_COPY_SEND
337 * MACH_MSG_TYPE_MAKE_SEND
338 * MACH_MSG_TYPE_MOVE_SEND
339 * MACH_MSG_TYPE_MAKE_SEND_ONCE
340 * MACH_MSG_TYPE_MOVE_SEND_ONCE
343 routine mach_port_extract_right(
345 name : mach_port_name_t;
346 msgt_name : mach_msg_type_name_t;
347 out poly : mach_port_poly_t);
350 * Only valid for receive rights.
351 * Sets the sequence number for the port.
354 routine mach_port_set_seqno(
356 name : mach_port_name_t;
357 seqno : mach_port_seqno_t);
360 * Returns information about a port.
364 mach_port_get_attributes_from_user(
367 mach_port_get_attributes(
368 task : ipc_space_read_t;
370 name : mach_port_name_t;
371 flavor : mach_port_flavor_t;
372 out port_info_out : mach_port_info_t, CountInOut);
375 * Set attributes of a port
378 routine mach_port_set_attributes(
380 name : mach_port_name_t;
381 flavor : mach_port_flavor_t;
382 port_info : mach_port_info_t);
386 * Allocates the specified kind of object, qos version.
388 * MACH_PORT_RIGHT_RECEIVE
389 * Like port_allocate_name, but the kernel picks a name.
390 * It can use any name not associated with a right.
393 routine mach_port_allocate_qos(
395 right : mach_port_right_t;
396 inout qos : mach_port_qos_t;
397 out name : mach_port_name_t);
401 * Generic interface to allocation various kinds of ports.
402 * Should never be called directly by users (at least not
403 * unless they are exceedingly masochistic).
406 routine mach_port_allocate_full(
408 right : mach_port_right_t;
410 inout qos : mach_port_qos_t;
411 inout name : mach_port_name_t);
415 * Pre-expand task port name space.
417 routine task_set_port_space(
419 table_entries : int);
423 * Returns the exact number of extant send rights
424 * for the given receive right.
425 * This call is only valid on MACH_IPC_DEBUG kernels.
426 * Otherwise, KERN_FAILURE is returned.
428 routine mach_port_get_srights(
430 name : mach_port_name_t;
431 out srights : mach_port_rights_t);
435 * Returns information about an IPC space.
436 * This call is only valid on MACH_IPC_DEBUG kernels.
437 * Otherwise, KERN_FAILURE is returned.
441 mach_port_space_info_from_user(
444 mach_port_space_info(
445 space : ipc_space_read_t;
447 out space_info : ipc_info_space_t;
448 out table_info : ipc_info_name_array_t;
449 out tree_info : ipc_info_tree_name_array_t);
452 * Returns information about the dead-name requests
453 * registered with the named receive right.
454 * This call is only valid on MACH_IPC_DEBUG kernels.
455 * Otherwise, KERN_FAILURE is returned.
457 routine mach_port_dnrequest_info(
459 name : mach_port_name_t;
460 out dnr_total : unsigned; /* total size of table */
461 out dnr_used : unsigned); /* amount used */
464 * Return the type and address of the kernel object
465 * that the given send/receive right represents.
466 * This call is only valid on MACH_IPC_DEBUG kernels.
467 * Otherwise, KERN_FAILURE is returned.
469 * This interface is DEPRECATED in favor of the new
470 * mach_port_kernel_object64() call (see below).
474 mach_port_kernel_object_from_user(
477 mach_port_kernel_object(
478 task : ipc_space_read_t;
480 name : mach_port_name_t;
481 out object_type : unsigned;
482 out object_addr : unsigned);
486 * Inserts the specified rights into the portset identified
487 * by the <task, pset> pair. The results of passing in the
488 * Poly argument via the supplied disposition must yield a
491 * If the <task,pset> pair does not represent a valid portset
492 * KERN_INVALID_RIGHT is returned.
494 * If the passed in name argument does not represent a receive
495 * right, KERN_INVALID_CAPABILITY will be returned.
497 * If the port represented by the receive right is already in
498 * the portset, KERN_ALREADY_IN_SET is returned.
500 routine mach_port_insert_member(
502 name : mach_port_name_t;
503 pset : mach_port_name_t);
506 * Extracts the specified right from the named portset
507 * in the target task.
508 * the target task. The target task loses a user
509 * ref and the name may be available for recycling.
510 * msgt_name must be one of
511 * MACH_MSG_TYPE_MOVE_RECEIVE
512 * MACH_MSG_TYPE_COPY_SEND
513 * MACH_MSG_TYPE_MAKE_SEND
514 * MACH_MSG_TYPE_MOVE_SEND
515 * MACH_MSG_TYPE_MAKE_SEND_ONCE
516 * MACH_MSG_TYPE_MOVE_SEND_ONCE
519 routine mach_port_extract_member(
521 name : mach_port_name_t;
522 pset : mach_port_name_t);
525 * Only valid for receive rights.
526 * Gets the context pointer for the port.
530 mach_port_get_context_from_user(
533 mach_port_get_context(
534 task : ipc_space_read_t;
536 name : mach_port_name_t;
537 #ifdef LIBSYSCALL_INTERFACE
538 out context : mach_port_context_t
540 out context : mach_vm_address_t
545 * Only valid for receive rights.
546 * Sets the context pointer for the port.
549 routine mach_port_set_context(
551 name : mach_port_name_t;
552 #ifdef LIBSYSCALL_INTERFACE
553 context : mach_port_context_t
555 context : mach_vm_address_t
560 * Return the type and address of the kernel object
561 * that the given send/receive right represents.
562 * This call is only valid on MACH_IPC_DEBUG kernels.
563 * Otherwise, KERN_FAILURE is returned.
567 mach_port_kobject_from_user(
571 task : ipc_space_read_t;
573 name : mach_port_name_t;
574 out object_type : natural_t;
575 out object_addr : mach_vm_address_t);
579 * Constructs a right based on the options passed
580 * in. Also allows guarding the port as one of the
581 * options if the requested right is a receive
584 routine mach_port_construct(
586 options : mach_port_options_ptr_t;
587 #ifdef LIBSYSCALL_INTERFACE
588 context : mach_port_context_t;
592 out name : mach_port_name_t);
595 * Destroys a mach port using the guard provided
596 * for guarded ports. Also reduces the user ref
597 * count for send rights as specified by srdelta.
599 routine mach_port_destruct(
601 name : mach_port_name_t;
602 srdelta : mach_port_delta_t;
603 #ifdef LIBSYSCALL_INTERFACE
604 guard : mach_port_context_t
611 * Guard an already existing port. Allows guarding
612 * receive rights only. Uses the context field in the
613 * port structure to store the guard.
615 routine mach_port_guard(
617 name : mach_port_name_t;
618 #ifdef LIBSYSCALL_INTERFACE
619 guard : mach_port_context_t;
626 * Unguard a port guarded previously. For unguarded ports
627 * or incorrect guards passed in it raises an exception
628 * indicating guarding misbehavior.
630 routine mach_port_unguard(
632 name : mach_port_name_t;
633 #ifdef LIBSYSCALL_INTERFACE
634 guard : mach_port_context_t
641 * Returns basic information about an IPC space.
642 * This call is only valid on MACH_IPC_DEBUG kernels.
643 * Otherwise, KERN_FAILURE is returned.
645 routine mach_port_space_basic_info(
646 task : ipc_space_inspect_t;
647 out basic_info : ipc_info_space_basic_t);
649 #if KERNEL || !LIBSYSCALL_INTERFACE
651 * Returns sync ipc turnstile link status
652 * for special reply ports.
654 routine mach_port_special_reply_port_reset_link(
656 name : mach_port_name_t;
657 out srp_lost_link : boolean_t);
663 * Guard an already existing port. Allows guarding
664 * receive rights only. Uses the context field in the
665 * port structure to store the guard.
667 routine mach_port_guard_with_flags(
669 name : mach_port_name_t;
670 #ifdef LIBSYSCALL_INTERFACE
671 guard : mach_port_context_t;
678 * Swap guard value of an existing guarded port. Works
679 * only if it is not a strict guard.
681 routine mach_port_swap_guard(
683 name : mach_port_name_t;
684 #ifdef LIBSYSCALL_INTERFACE
685 old_guard : mach_port_context_t;
687 old_guard : uint64_t;
690 #ifdef LIBSYSCALL_INTERFACE
691 new_guard : mach_port_context_t);
693 new_guard : uint64_t);
697 * Return the type and address of the kernel object
698 * that the given send/receive right represents.
699 * This call is only valid on MACH_IPC_DEBUG kernels.
700 * Otherwise, KERN_FAILURE is returned.
704 mach_port_kobject_description_from_user(
707 mach_port_kobject_description(
708 task : ipc_space_read_t;
710 name : mach_port_name_t;
711 out object_type : natural_t;
712 out object_addr : mach_vm_address_t;
713 out description : kobject_description_t);
715 /* vim: set ft=c : */