]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/mach_port.defs
xnu-6153.121.1.tar.gz
[apple/xnu.git] / osfmk / mach / mach_port.defs
1 /*
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
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
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
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
65 subsystem
66 #if KERNEL_SERVER
67 KernelServer
68 #endif /* KERNEL_SERVER */
69 mach_port 3200;
70
71 #if !KERNEL && !LIBSYSCALL_INTERFACE
72 UserPrefix _kernelrpc_;
73 #endif
74
75 #include <mach/std_types.defs>
76 #include <mach/mach_types.defs>
77 #include <mach_debug/mach_debug_types.defs>
78
79 type kobject_description_t = c_string[*:512];
80
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
87 routine 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
98 routine 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.
107 *
108 * This interface is OBSOLETE and will always
109 * return KERN_NOT_SUPPORTED.
110 */
111
112 routine 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
129 routine 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
144 routine 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
156 routine 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
168 routine 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
186 routine 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
207 routine 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
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 */
229 routine 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);
237
238 /*
239 * Only valid for receive rights.
240 * Sets the make-send count for the port.
241 */
242 routine 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
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);
256
257 /*
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).
263 */
264
265 routine 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
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)
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.
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.
298 *
299 * If the name is deleted before a successfully registered notification
300 * is delivered, it is replaced with a port-deleted notification.
301 */
302
303 routine 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;
309 out previous : mach_port_move_send_once_t);
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
319 routine 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
338 routine 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
349 routine 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
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);
363
364 /*
365 * Set attributes of a port
366 */
367
368 routine 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
383 routine 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
389
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
396 routine mach_port_allocate_full(
397 task : ipc_space_t;
398 right : mach_port_right_t;
399 proto : mach_port_t;
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 */
407 routine 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 */
418 routine 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 */
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);
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 */
441 routine mach_port_dnrequest_info(
442 task : ipc_space_t;
443 name : mach_port_name_t;
444 out dnr_total : unsigned; /* total size of table */
445 out dnr_used : unsigned); /* amount used */
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.
452 *
453 * This interface is DEPRECATED in favor of the new
454 * mach_port_kernel_object64() call (see below).
455 */
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);
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 */
478 routine 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
497 routine mach_port_extract_member(
498 task : ipc_space_t;
499 name : mach_port_name_t;
500 pset : mach_port_name_t);
501
502 /*
503 * Only valid for receive rights.
504 * Gets the context pointer for the port.
505 */
506
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
512 #else
513 out context : mach_vm_address_t
514 #endif
515 );
516
517 /*
518 * Only valid for receive rights.
519 * Sets the context pointer for the port.
520 */
521
522 routine mach_port_set_context(
523 task : ipc_space_t;
524 name : mach_port_name_t;
525 #ifdef LIBSYSCALL_INTERFACE
526 context : mach_port_context_t
527 #else
528 context : mach_vm_address_t
529 #endif
530 );
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 */
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);
543
544
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 */
551 routine 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 */
566 routine 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 */
582 routine 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 */
597 routine 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
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 */
612 routine mach_port_space_basic_info(
613 task : ipc_space_inspect_t;
614 out basic_info : ipc_info_space_basic_t);
615
616 #if KERNEL || !LIBSYSCALL_INTERFACE
617 /*
618 * Returns sync ipc turnstile link status
619 * for special reply ports.
620 */
621 routine 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
626 skip;
627 #endif
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 */
634 routine 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 */
648 routine 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
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 */
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);
675
676 /* vim: set ft=c : */