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
252 routine mach_port_get_set_status(
253 task : ipc_space_inspect_t;
254 name : mach_port_name_t;
255 out members : mach_port_name_array_t);
258 * Puts the member port (the task must have receive rights)
259 * into the after port set. If the port is already a member
260 * of any set(s), it is atomically removed from those sets as
261 * part of this operation. (If after is MACH_PORT_NULL, the
262 * port is still removed from all current sets).
265 routine mach_port_move_member(
267 member : mach_port_name_t;
268 after : mach_port_name_t);
271 * Requests a notification from the kernel. The request
272 * must supply the send-once right which is used for
273 * the notification. If a send-once right was previously
274 * registered, it is returned. The msgid must be one of:
275 * MACH_NOTIFY_PORT_DESTROYED (receive rights)
276 * MACH_NOTIFY_DEAD_NAME (send/receive/send-once rights)
277 * MACH_NOTIFY_SEND_POSSIBLE (send/receive/send-once rights)
278 * MACH_NOTIFY_NO_SENDERS (receive rights)
280 * The sync value specifies whether a notification should
281 * get sent immediately, if appropriate. The exact meaning
282 * depends on the notification:
283 * MACH_NOTIFY_PORT_DESTROYED: must be zero.
284 * MACH_NOTIFY_DEAD_NAME: if non-zero, then name can be dead,
285 * and the notification gets sent immediately.
286 * If zero, then name can't be dead.
287 * MACH_NOTIFY_SEND_POSSIBLE: if non-zero, will generate a send-
288 * possible notification as soon as it is possible to send
289 * to the port. If zero, will generate a send-possible
290 * notification only after a subsequent failed send
291 * (with MACH_SEND_NOTIFY option to mach_msg call). Can
292 * generate a dead-name notification if name is already dead
293 * or becomes dead before a send-possible notification fires.
294 * MACH_NOTIFY_NO_SENDERS: the notification gets sent
295 * immediately if the current mscount is greater
296 * than or equal to the sync value and there are no
297 * extant send rights.
299 * If the name is deleted before a successfully registered notification
300 * is delivered, it is replaced with a port-deleted notification.
303 routine mach_port_request_notification(
305 name : mach_port_name_t;
306 msgid : mach_msg_id_t;
307 sync : mach_port_mscount_t;
308 notify : mach_port_send_once_t;
309 out previous : mach_port_move_send_once_t);
312 * Inserts the specified rights into the target task,
313 * using the specified name. If inserting send/receive
314 * rights and the task already has send/receive rights
315 * for the port, then the names must agree. In any case,
316 * the task gains a user ref for the port.
319 routine mach_port_insert_right(
321 name : mach_port_name_t;
322 poly : mach_port_poly_t);
325 * Returns the specified right for the named port
326 * in the target task, extracting that right from
327 * the target task. The target task loses a user
328 * ref and the name may be available for recycling.
329 * msgt_name must be one of
330 * MACH_MSG_TYPE_MOVE_RECEIVE
331 * MACH_MSG_TYPE_COPY_SEND
332 * MACH_MSG_TYPE_MAKE_SEND
333 * MACH_MSG_TYPE_MOVE_SEND
334 * MACH_MSG_TYPE_MAKE_SEND_ONCE
335 * MACH_MSG_TYPE_MOVE_SEND_ONCE
338 routine mach_port_extract_right(
340 name : mach_port_name_t;
341 msgt_name : mach_msg_type_name_t;
342 out poly : mach_port_poly_t);
345 * Only valid for receive rights.
346 * Sets the sequence number for the port.
349 routine mach_port_set_seqno(
351 name : mach_port_name_t;
352 seqno : mach_port_seqno_t);
355 * Returns information about a port.
358 routine mach_port_get_attributes(
359 task : ipc_space_inspect_t;
360 name : mach_port_name_t;
361 flavor : mach_port_flavor_t;
362 out port_info_out : mach_port_info_t, CountInOut);
365 * Set attributes of a port
368 routine mach_port_set_attributes(
370 name : mach_port_name_t;
371 flavor : mach_port_flavor_t;
372 port_info : mach_port_info_t);
376 * Allocates the specified kind of object, qos version.
378 * MACH_PORT_RIGHT_RECEIVE
379 * Like port_allocate_name, but the kernel picks a name.
380 * It can use any name not associated with a right.
383 routine mach_port_allocate_qos(
385 right : mach_port_right_t;
386 inout qos : mach_port_qos_t;
387 out name : mach_port_name_t);
391 * Generic interface to allocation various kinds of ports.
392 * Should never be called directly by users (at least not
393 * unless they are exceedingly masochistic).
396 routine mach_port_allocate_full(
398 right : mach_port_right_t;
400 inout qos : mach_port_qos_t;
401 inout name : mach_port_name_t);
405 * Pre-expand task port name space.
407 routine task_set_port_space(
409 table_entries : int);
413 * Returns the exact number of extant send rights
414 * for the given receive right.
415 * This call is only valid on MACH_IPC_DEBUG kernels.
416 * Otherwise, KERN_FAILURE is returned.
418 routine mach_port_get_srights(
420 name : mach_port_name_t;
421 out srights : mach_port_rights_t);
425 * Returns information about an IPC space.
426 * This call is only valid on MACH_IPC_DEBUG kernels.
427 * Otherwise, KERN_FAILURE is returned.
429 routine mach_port_space_info(
430 task : ipc_space_inspect_t;
431 out space_info : ipc_info_space_t;
432 out table_info : ipc_info_name_array_t;
433 out tree_info : ipc_info_tree_name_array_t);
436 * Returns information about the dead-name requests
437 * registered with the named receive right.
438 * This call is only valid on MACH_IPC_DEBUG kernels.
439 * Otherwise, KERN_FAILURE is returned.
441 routine mach_port_dnrequest_info(
443 name : mach_port_name_t;
444 out dnr_total : unsigned; /* total size of table */
445 out dnr_used : unsigned); /* amount used */
448 * Return the type and address of the kernel object
449 * that the given send/receive right represents.
450 * This call is only valid on MACH_IPC_DEBUG kernels.
451 * Otherwise, KERN_FAILURE is returned.
453 * This interface is DEPRECATED in favor of the new
454 * mach_port_kernel_object64() call (see below).
456 routine mach_port_kernel_object(
457 task : ipc_space_inspect_t;
458 name : mach_port_name_t;
459 out object_type : unsigned;
460 out object_addr : unsigned);
464 * Inserts the specified rights into the portset identified
465 * by the <task, pset> pair. The results of passing in the
466 * Poly argument via the supplied disposition must yield a
469 * If the <task,pset> pair does not represent a valid portset
470 * KERN_INVALID_RIGHT is returned.
472 * If the passed in name argument does not represent a receive
473 * right, KERN_INVALID_CAPABILITY will be returned.
475 * If the port represented by the receive right is already in
476 * the portset, KERN_ALREADY_IN_SET is returned.
478 routine mach_port_insert_member(
480 name : mach_port_name_t;
481 pset : mach_port_name_t);
484 * Extracts the specified right from the named portset
485 * in the target task.
486 * the target task. The target task loses a user
487 * ref and the name may be available for recycling.
488 * msgt_name must be one of
489 * MACH_MSG_TYPE_MOVE_RECEIVE
490 * MACH_MSG_TYPE_COPY_SEND
491 * MACH_MSG_TYPE_MAKE_SEND
492 * MACH_MSG_TYPE_MOVE_SEND
493 * MACH_MSG_TYPE_MAKE_SEND_ONCE
494 * MACH_MSG_TYPE_MOVE_SEND_ONCE
497 routine mach_port_extract_member(
499 name : mach_port_name_t;
500 pset : mach_port_name_t);
503 * Only valid for receive rights.
504 * Gets the context pointer for the port.
507 routine mach_port_get_context(
508 task : ipc_space_inspect_t;
509 name : mach_port_name_t;
510 #ifdef LIBSYSCALL_INTERFACE
511 out context : mach_port_context_t
513 out context : mach_vm_address_t
518 * Only valid for receive rights.
519 * Sets the context pointer for the port.
522 routine mach_port_set_context(
524 name : mach_port_name_t;
525 #ifdef LIBSYSCALL_INTERFACE
526 context : mach_port_context_t
528 context : mach_vm_address_t
533 * Return the type and address of the kernel object
534 * that the given send/receive right represents.
535 * This call is only valid on MACH_IPC_DEBUG kernels.
536 * Otherwise, KERN_FAILURE is returned.
538 routine mach_port_kobject(
539 task : ipc_space_inspect_t;
540 name : mach_port_name_t;
541 out object_type : natural_t;
542 out object_addr : mach_vm_address_t);
546 * Constructs a right based on the options passed
547 * in. Also allows guarding the port as one of the
548 * options if the requested right is a receive
551 routine mach_port_construct(
553 options : mach_port_options_ptr_t;
554 #ifdef LIBSYSCALL_INTERFACE
555 context : mach_port_context_t;
559 out name : mach_port_name_t);
562 * Destroys a mach port using the guard provided
563 * for guarded ports. Also reduces the user ref
564 * count for send rights as specified by srdelta.
566 routine mach_port_destruct(
568 name : mach_port_name_t;
569 srdelta : mach_port_delta_t;
570 #ifdef LIBSYSCALL_INTERFACE
571 guard : mach_port_context_t
578 * Guard an already existing port. Allows guarding
579 * receive rights only. Uses the context field in the
580 * port structure to store the guard.
582 routine mach_port_guard(
584 name : mach_port_name_t;
585 #ifdef LIBSYSCALL_INTERFACE
586 guard : mach_port_context_t;
593 * Unguard a port guarded previously. For unguarded ports
594 * or incorrect guards passed in it raises an exception
595 * indicating guarding misbehavior.
597 routine mach_port_unguard(
599 name : mach_port_name_t;
600 #ifdef LIBSYSCALL_INTERFACE
601 guard : mach_port_context_t
608 * Returns basic information about an IPC space.
609 * This call is only valid on MACH_IPC_DEBUG kernels.
610 * Otherwise, KERN_FAILURE is returned.
612 routine mach_port_space_basic_info(
613 task : ipc_space_inspect_t;
614 out basic_info : ipc_info_space_basic_t);
616 #if KERNEL || !LIBSYSCALL_INTERFACE
618 * Returns sync ipc turnstile link status
619 * for special reply ports.
621 routine mach_port_special_reply_port_reset_link(
623 name : mach_port_name_t;
624 out srp_lost_link : boolean_t);
630 * Guard an already existing port. Allows guarding
631 * receive rights only. Uses the context field in the
632 * port structure to store the guard.
634 routine mach_port_guard_with_flags(
636 name : mach_port_name_t;
637 #ifdef LIBSYSCALL_INTERFACE
638 guard : mach_port_context_t;
645 * Swap guard value of an existing guarded port. Works
646 * only if it is not a strict guard.
648 routine mach_port_swap_guard(
650 name : mach_port_name_t;
651 #ifdef LIBSYSCALL_INTERFACE
652 old_guard : mach_port_context_t;
654 old_guard : uint64_t;
657 #ifdef LIBSYSCALL_INTERFACE
658 new_guard : mach_port_context_t);
660 new_guard : uint64_t);
664 * Return the type and address of the kernel object
665 * that the given send/receive right represents.
666 * This call is only valid on MACH_IPC_DEBUG kernels.
667 * Otherwise, KERN_FAILURE is returned.
669 routine mach_port_kobject_description(
670 task : ipc_space_inspect_t;
671 name : mach_port_name_t;
672 out object_type : natural_t;
673 out object_addr : mach_vm_address_t;
674 out description : kobject_description_t);
676 /* vim: set ft=c : */