]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/mach_port.defs
xnu-6153.121.1.tar.gz
[apple/xnu.git] / osfmk / mach / mach_port.defs
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
A
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.
8f6c56a5 14 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
29 * @OSF_FREE_COPYRIGHT@
30 */
31/*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989 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 * File: mach/mach_port.defs
60 * Author: Rich Draves
61 *
62 * Exported kernel calls.
63 */
64
65subsystem
66#if KERNEL_SERVER
67 KernelServer
55e303ae 68#endif /* KERNEL_SERVER */
1c79356b
A
69 mach_port 3200;
70
316670eb
A
71#if !KERNEL && !LIBSYSCALL_INTERFACE
72 UserPrefix _kernelrpc_;
73#endif
74
1c79356b
A
75#include <mach/std_types.defs>
76#include <mach/mach_types.defs>
77#include <mach_debug/mach_debug_types.defs>
78
ea3f0419
A
79type kobject_description_t = c_string[*:512];
80
1c79356b
A
81/*
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.
85 */
86
87routine mach_port_names(
88 task : ipc_space_t;
89 out names : mach_port_name_array_t;
90 out types : mach_port_type_array_t);
91
92/*
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.
96 */
97
98routine mach_port_type(
99 task : ipc_space_t;
100 name : mach_port_name_t;
101 out ptype : mach_port_type_t);
102
103/*
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.
316670eb
A
107 *
108 * This interface is OBSOLETE and will always
109 * return KERN_NOT_SUPPORTED.
1c79356b
A
110 */
111
112routine mach_port_rename(
113 task : ipc_space_t;
114 old_name : mach_port_name_t;
115 new_name : mach_port_name_t);
116
117/*
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.
127 */
128
129routine mach_port_allocate_name(
130 task : ipc_space_t;
131 right : mach_port_right_t;
132 name : mach_port_name_t);
133
134/*
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.
142 */
143
144routine mach_port_allocate(
145 task : ipc_space_t;
146 right : mach_port_right_t;
147 out name : mach_port_name_t);
148
149/*
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).
154 */
155
156routine mach_port_destroy(
157 task : ipc_space_t;
158 name : mach_port_name_t);
159
160/*
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.
166 */
167
168routine mach_port_deallocate(
169 task : ipc_space_t;
170 name : mach_port_name_t);
171
172/*
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
184 */
185
186routine mach_port_get_refs(
187 task : ipc_space_t;
188 name : mach_port_name_t;
189 right : mach_port_right_t;
190 out refs : mach_port_urefs_t);
191
192/*
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
205 */
206
207routine mach_port_mod_refs(
208 task : ipc_space_t;
209 name : mach_port_name_t;
210 right : mach_port_right_t;
211 delta : mach_port_delta_t);
212
39236c6e
A
213/*
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.
219 *
220 * Only the following trailer types are currently supported:
221 * MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0)
222 *
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)
228 */
229routine mach_port_peek(
230 task : ipc_space_t;
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);
1c79356b
A
237
238/*
239 * Only valid for receive rights.
240 * Sets the make-send count for the port.
241 */
242routine mach_port_set_mscount(
243 task : ipc_space_t;
244 name : mach_port_name_t;
245 mscount : mach_port_mscount_t);
246
247/*
248 * Only valid for port sets. Returns a list of
249 * the members.
250 */
251
252routine mach_port_get_set_status(
813fb2f6 253 task : ipc_space_inspect_t;
1c79356b
A
254 name : mach_port_name_t;
255 out members : mach_port_name_array_t);
256
257/*
258 * Puts the member port (the task must have receive rights)
2d21ac55
A
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).
1c79356b
A
263 */
264
265routine mach_port_move_member(
266 task : ipc_space_t;
267 member : mach_port_name_t;
268 after : mach_port_name_t);
269
270/*
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
6d2010ae 274 * registered, it is returned. The msgid must be one of:
1c79356b
A
275 * MACH_NOTIFY_PORT_DESTROYED (receive rights)
276 * MACH_NOTIFY_DEAD_NAME (send/receive/send-once rights)
6d2010ae 277 * MACH_NOTIFY_SEND_POSSIBLE (send/receive/send-once rights)
1c79356b
A
278 * MACH_NOTIFY_NO_SENDERS (receive rights)
279 *
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.
6d2010ae
A
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.
1c79356b
A
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.
6d2010ae
A
298 *
299 * If the name is deleted before a successfully registered notification
300 * is delivered, it is replaced with a port-deleted notification.
1c79356b
A
301 */
302
303routine mach_port_request_notification(
304 task : ipc_space_t;
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;
0b4e3aa0 309 out previous : mach_port_move_send_once_t);
1c79356b
A
310
311/*
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.
317 */
318
319routine mach_port_insert_right(
320 task : ipc_space_t;
321 name : mach_port_name_t;
322 poly : mach_port_poly_t);
323
324/*
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
336 */
337
338routine mach_port_extract_right(
339 task : ipc_space_t;
340 name : mach_port_name_t;
341 msgt_name : mach_msg_type_name_t;
342 out poly : mach_port_poly_t);
343
344/*
345 * Only valid for receive rights.
346 * Sets the sequence number for the port.
347 */
348
349routine mach_port_set_seqno(
350 task : ipc_space_t;
351 name : mach_port_name_t;
352 seqno : mach_port_seqno_t);
353
354/*
355 * Returns information about a port.
356 */
357
358routine mach_port_get_attributes(
813fb2f6 359 task : ipc_space_inspect_t;
1c79356b
A
360 name : mach_port_name_t;
361 flavor : mach_port_flavor_t;
362 out port_info_out : mach_port_info_t, CountInOut);
363
364/*
365 * Set attributes of a port
366 */
367
368routine mach_port_set_attributes(
369 task : ipc_space_t;
370 name : mach_port_name_t;
371 flavor : mach_port_flavor_t;
372 port_info : mach_port_info_t);
373
374
375/*
376 * Allocates the specified kind of object, qos version.
377 * The right must be
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.
381 */
382
383routine mach_port_allocate_qos(
384 task : ipc_space_t;
385 right : mach_port_right_t;
386 inout qos : mach_port_qos_t;
387 out name : mach_port_name_t);
388
9bccf70c 389
1c79356b
A
390/*
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).
394 */
395
396routine mach_port_allocate_full(
397 task : ipc_space_t;
398 right : mach_port_right_t;
9bccf70c 399 proto : mach_port_t;
1c79356b
A
400 inout qos : mach_port_qos_t;
401 inout name : mach_port_name_t);
402
403
404/*
405 * Pre-expand task port name space.
406 */
407routine task_set_port_space(
408 task : ipc_space_t;
409 table_entries : int);
410
411
412/*
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.
417 */
418routine mach_port_get_srights(
419 task : ipc_space_t;
420 name : mach_port_name_t;
421 out srights : mach_port_rights_t);
422
423
424/*
425 * Returns information about an IPC space.
426 * This call is only valid on MACH_IPC_DEBUG kernels.
427 * Otherwise, KERN_FAILURE is returned.
428 */
429routine mach_port_space_info(
813fb2f6 430 task : ipc_space_inspect_t;
91447636 431 out space_info : ipc_info_space_t;
2d21ac55
A
432 out table_info : ipc_info_name_array_t;
433 out tree_info : ipc_info_tree_name_array_t);
1c79356b
A
434
435/*
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.
440 */
441routine mach_port_dnrequest_info(
442 task : ipc_space_t;
443 name : mach_port_name_t;
91447636
A
444 out dnr_total : unsigned; /* total size of table */
445 out dnr_used : unsigned); /* amount used */
1c79356b
A
446
447/*
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.
b0d623f7
A
452 *
453 * This interface is DEPRECATED in favor of the new
454 * mach_port_kernel_object64() call (see below).
1c79356b
A
455 */
456routine mach_port_kernel_object(
813fb2f6 457 task : ipc_space_inspect_t;
1c79356b
A
458 name : mach_port_name_t;
459 out object_type : unsigned;
b0d623f7 460 out object_addr : unsigned);
1c79356b
A
461
462
463/*
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
467 * receive right.
468 *
469 * If the <task,pset> pair does not represent a valid portset
470 * KERN_INVALID_RIGHT is returned.
471 *
472 * If the passed in name argument does not represent a receive
473 * right, KERN_INVALID_CAPABILITY will be returned.
474 *
475 * If the port represented by the receive right is already in
476 * the portset, KERN_ALREADY_IN_SET is returned.
477 */
478routine mach_port_insert_member(
479 task : ipc_space_t;
480 name : mach_port_name_t;
481 pset : mach_port_name_t);
482
483/*
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
495 */
496
497routine mach_port_extract_member(
498 task : ipc_space_t;
499 name : mach_port_name_t;
500 pset : mach_port_name_t);
501
b0d623f7
A
502/*
503 * Only valid for receive rights.
504 * Gets the context pointer for the port.
505 */
506
507routine mach_port_get_context(
813fb2f6 508 task : ipc_space_inspect_t;
b0d623f7 509 name : mach_port_name_t;
316670eb
A
510#ifdef LIBSYSCALL_INTERFACE
511 out context : mach_port_context_t
512#else
513 out context : mach_vm_address_t
514#endif
515 );
b0d623f7
A
516
517/*
518 * Only valid for receive rights.
519 * Sets the context pointer for the port.
520 */
521
522routine mach_port_set_context(
523 task : ipc_space_t;
524 name : mach_port_name_t;
316670eb
A
525#ifdef LIBSYSCALL_INTERFACE
526 context : mach_port_context_t
527#else
528 context : mach_vm_address_t
529#endif
530 );
b0d623f7
A
531
532/*
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.
537 */
538routine mach_port_kobject(
813fb2f6 539 task : ipc_space_inspect_t;
b0d623f7
A
540 name : mach_port_name_t;
541 out object_type : natural_t;
542 out object_addr : mach_vm_address_t);
543
544
39236c6e
A
545/*
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
549 * right.
550 */
551routine mach_port_construct(
552 task : ipc_space_t;
553 options : mach_port_options_ptr_t;
554#ifdef LIBSYSCALL_INTERFACE
555 context : mach_port_context_t;
556#else
557 context : uint64_t;
558#endif
559 out name : mach_port_name_t);
560
561/*
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.
565 */
566routine mach_port_destruct(
567 task : ipc_space_t;
568 name : mach_port_name_t;
569 srdelta : mach_port_delta_t;
570#ifdef LIBSYSCALL_INTERFACE
571 guard : mach_port_context_t
572#else
573 guard : uint64_t
574#endif
575 );
576
577/*
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.
581 */
582routine mach_port_guard(
583 task : ipc_space_t;
584 name : mach_port_name_t;
585#ifdef LIBSYSCALL_INTERFACE
586 guard : mach_port_context_t;
587#else
588 guard : uint64_t;
589#endif
590 strict : boolean_t);
591
592/*
593 * Unguard a port guarded previously. For unguarded ports
594 * or incorrect guards passed in it raises an exception
595 * indicating guarding misbehavior.
596 */
597routine mach_port_unguard(
598 task : ipc_space_t;
599 name : mach_port_name_t;
600#ifdef LIBSYSCALL_INTERFACE
601 guard : mach_port_context_t
602#else
603 guard : uint64_t
604#endif
605 );
606
fe8ab488
A
607/*
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.
611 */
612routine mach_port_space_basic_info(
813fb2f6 613 task : ipc_space_inspect_t;
fe8ab488
A
614 out basic_info : ipc_info_space_basic_t);
615
d9a64523
A
616#if KERNEL || !LIBSYSCALL_INTERFACE
617/*
618 * Returns sync ipc turnstile link status
619 * for special reply ports.
620 */
621routine mach_port_special_reply_port_reset_link(
622 task : ipc_space_t;
623 name : mach_port_name_t;
624 out srp_lost_link : boolean_t);
625#else
626skip;
627#endif
cb323159
A
628
629/*
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.
633 */
634routine mach_port_guard_with_flags(
635 task : ipc_space_t;
636 name : mach_port_name_t;
637#ifdef LIBSYSCALL_INTERFACE
638 guard : mach_port_context_t;
639#else
640 guard : uint64_t;
641#endif
642 flags : uint64_t);
643
644/*
645 * Swap guard value of an existing guarded port. Works
646 * only if it is not a strict guard.
647 */
648routine mach_port_swap_guard(
649 task : ipc_space_t;
650 name : mach_port_name_t;
651#ifdef LIBSYSCALL_INTERFACE
652 old_guard : mach_port_context_t;
653#else
654 old_guard : uint64_t;
655#endif
656
657#ifdef LIBSYSCALL_INTERFACE
658 new_guard : mach_port_context_t);
659#else
660 new_guard : uint64_t);
661#endif
662
ea3f0419
A
663/*
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.
668 */
669routine 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);
675
2d21ac55 676/* vim: set ft=c : */