2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * @OSF_FREE_COPYRIGHT@
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
28 * All Rights Reserved.
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
53 * File: mach/mach_port.defs
56 * Exported kernel calls.
65 #include <mach/std_types.defs>
66 #include <mach/mach_types.defs>
67 #include <mach_debug/mach_debug_types.defs>
70 * Returns the set of port and port set names
71 * to which the target task has access, along with
72 * the type (set or port) for each name.
75 routine mach_port_names(
77 out names : mach_port_name_array_t;
78 out types : mach_port_type_array_t);
81 * Returns the type (set or port) for the port name
82 * within the target task. Also indicates whether
83 * there is a dead-name request for the name.
86 routine mach_port_type(
88 name : mach_port_name_t;
89 out ptype : mach_port_type_t);
92 * Changes the name by which a port (or port set) is known to
93 * the target task. The new name can't be in use. The
94 * old name becomes available for recycling.
97 routine mach_port_rename(
99 old_name : mach_port_name_t;
100 new_name : mach_port_name_t);
103 * Allocates the specified kind of object, with the given name.
104 * The right must be one of
105 * MACH_PORT_RIGHT_RECEIVE
106 * MACH_PORT_RIGHT_PORT_SET
107 * MACH_PORT_RIGHT_DEAD_NAME
108 * New port sets are empty. New ports don't have any
109 * send/send-once rights or queued messages. The make-send
110 * count is zero and their queue limit is MACH_PORT_QLIMIT_DEFAULT.
111 * New sets, ports, and dead names have one user reference.
114 routine mach_port_allocate_name(
116 right : mach_port_right_t;
117 name : mach_port_name_t);
120 * Allocates the specified kind of object.
121 * The right must be one of
122 * MACH_PORT_RIGHT_RECEIVE
123 * MACH_PORT_RIGHT_PORT_SET
124 * MACH_PORT_RIGHT_DEAD_NAME
125 * Like port_allocate_name, but the kernel picks a name.
126 * It can use any name not associated with a right.
129 routine mach_port_allocate(
131 right : mach_port_right_t;
132 out name : mach_port_name_t);
135 * Destroys all rights associated with the name and makes it
136 * available for recycling immediately. The name can be a
137 * port (possibly with multiple user refs), a port set, or
138 * a dead name (again, with multiple user refs).
141 routine mach_port_destroy(
143 name : mach_port_name_t);
146 * Releases one send/send-once/dead-name user ref.
147 * Just like mach_port_mod_refs -1, but deduces the
148 * correct type of right. This allows a user task
149 * to release a ref for a port without worrying
150 * about whether the port has died or not.
153 routine mach_port_deallocate(
155 name : mach_port_name_t);
158 * A port set always has one user ref.
159 * A send-once right always has one user ref.
160 * A dead name always has one or more user refs.
161 * A send right always has one or more user refs.
162 * A receive right always has one user ref.
163 * The right must be one of
164 * MACH_PORT_RIGHT_RECEIVE
165 * MACH_PORT_RIGHT_PORT_SET
166 * MACH_PORT_RIGHT_DEAD_NAME
167 * MACH_PORT_RIGHT_SEND
168 * MACH_PORT_RIGHT_SEND_ONCE
171 routine mach_port_get_refs(
173 name : mach_port_name_t;
174 right : mach_port_right_t;
175 out refs : mach_port_urefs_t);
178 * The delta is a signed change to the task's
179 * user ref count for the right. Only dead names
180 * and send rights can have a positive delta.
181 * The resulting user ref count can't be negative.
182 * If it is zero, the right is deallocated.
183 * If the name isn't a composite right, it becomes
184 * available for recycling. The right must be one of
185 * MACH_PORT_RIGHT_RECEIVE
186 * MACH_PORT_RIGHT_PORT_SET
187 * MACH_PORT_RIGHT_DEAD_NAME
188 * MACH_PORT_RIGHT_SEND
189 * MACH_PORT_RIGHT_SEND_ONCE
192 routine mach_port_mod_refs(
194 name : mach_port_name_t;
195 right : mach_port_right_t;
196 delta : mach_port_delta_t);
199 * Allocates a new receive right, and associates it with the
200 * specified RPC subsystem attributes.
202 routine mach_port_allocate_subsystem(
204 subsys : subsystem_t;
205 out name : mach_port_name_t);
208 * Only valid for receive rights.
209 * Sets the make-send count for the port.
211 routine mach_port_set_mscount(
213 name : mach_port_name_t;
214 mscount : mach_port_mscount_t);
217 * Only valid for port sets. Returns a list of
221 routine mach_port_get_set_status(
223 name : mach_port_name_t;
224 out members : mach_port_name_array_t);
227 * Puts the member port (the task must have receive rights)
228 * into the after port set. (Or removes it from any port set
229 * if after is MACH_PORT_NULL.) If the port is already in
230 * a set, does an atomic move.
233 routine mach_port_move_member(
235 member : mach_port_name_t;
236 after : mach_port_name_t);
239 * Requests a notification from the kernel. The request
240 * must supply the send-once right which is used for
241 * the notification. If a send-once right was previously
242 * registered, it is returned. The msg_id must be one of
243 * MACH_NOTIFY_PORT_DESTROYED (receive rights)
244 * MACH_NOTIFY_DEAD_NAME (send/receive/send-once rights)
245 * MACH_NOTIFY_NO_SENDERS (receive rights)
247 * The sync value specifies whether a notification should
248 * get sent immediately, if appropriate. The exact meaning
249 * depends on the notification:
250 * MACH_NOTIFY_PORT_DESTROYED: must be zero.
251 * MACH_NOTIFY_DEAD_NAME: if non-zero, then name can be dead,
252 * and the notification gets sent immediately.
253 * If zero, then name can't be dead.
254 * MACH_NOTIFY_NO_SENDERS: the notification gets sent
255 * immediately if the current mscount is greater
256 * than or equal to the sync value and there are no
257 * extant send rights.
260 routine mach_port_request_notification(
262 name : mach_port_name_t;
263 msgid : mach_msg_id_t;
264 sync : mach_port_mscount_t;
265 notify : mach_port_send_once_t;
266 out previous : mach_port_move_send_once_t);
269 * Inserts the specified rights into the target task,
270 * using the specified name. If inserting send/receive
271 * rights and the task already has send/receive rights
272 * for the port, then the names must agree. In any case,
273 * the task gains a user ref for the port.
276 routine mach_port_insert_right(
278 name : mach_port_name_t;
279 poly : mach_port_poly_t);
282 * Returns the specified right for the named port
283 * in the target task, extracting that right from
284 * the target task. The target task loses a user
285 * ref and the name may be available for recycling.
286 * msgt_name must be one of
287 * MACH_MSG_TYPE_MOVE_RECEIVE
288 * MACH_MSG_TYPE_COPY_SEND
289 * MACH_MSG_TYPE_MAKE_SEND
290 * MACH_MSG_TYPE_MOVE_SEND
291 * MACH_MSG_TYPE_MAKE_SEND_ONCE
292 * MACH_MSG_TYPE_MOVE_SEND_ONCE
295 routine mach_port_extract_right(
297 name : mach_port_name_t;
298 msgt_name : mach_msg_type_name_t;
299 out poly : mach_port_poly_t);
302 * Only valid for receive rights.
303 * Sets the sequence number for the port.
306 routine mach_port_set_seqno(
308 name : mach_port_name_t;
309 seqno : mach_port_seqno_t);
312 * Returns information about a port.
315 routine mach_port_get_attributes(
317 name : mach_port_name_t;
318 flavor : mach_port_flavor_t;
319 out port_info_out : mach_port_info_t, CountInOut);
322 * Set attributes of a port
325 routine mach_port_set_attributes(
327 name : mach_port_name_t;
328 flavor : mach_port_flavor_t;
329 port_info : mach_port_info_t);
333 * Allocates the specified kind of object, qos version.
335 * MACH_PORT_RIGHT_RECEIVE
336 * Like port_allocate_name, but the kernel picks a name.
337 * It can use any name not associated with a right.
340 routine mach_port_allocate_qos(
342 right : mach_port_right_t;
343 inout qos : mach_port_qos_t;
344 out name : mach_port_name_t);
347 * Generic interface to allocation various kinds of ports.
348 * Should never be called directly by users (at least not
349 * unless they are exceedingly masochistic).
352 routine mach_port_allocate_full(
354 right : mach_port_right_t;
356 inout qos : mach_port_qos_t;
357 inout name : mach_port_name_t);
361 * Pre-expand task port name space.
363 routine task_set_port_space(
365 table_entries : int);
369 * Returns the exact number of extant send rights
370 * for the given receive right.
371 * This call is only valid on MACH_IPC_DEBUG kernels.
372 * Otherwise, KERN_FAILURE is returned.
374 routine mach_port_get_srights(
376 name : mach_port_name_t;
377 out srights : mach_port_rights_t);
381 * Returns information about an IPC space.
382 * This call is only valid on MACH_IPC_DEBUG kernels.
383 * Otherwise, KERN_FAILURE is returned.
385 routine mach_port_space_info(
387 out info : ipc_info_space_t;
388 out table_info : ipc_info_name_array_t,
390 out tree_info : ipc_info_tree_name_array_t,
394 * Returns information about the dead-name requests
395 * registered with the named receive right.
396 * This call is only valid on MACH_IPC_DEBUG kernels.
397 * Otherwise, KERN_FAILURE is returned.
399 routine mach_port_dnrequest_info(
401 name : mach_port_name_t;
402 out total : unsigned; /* total size of table */
403 out used : unsigned); /* amount used */
406 * Return the type and address of the kernel object
407 * that the given send/receive right represents.
408 * This call is only valid on MACH_IPC_DEBUG kernels.
409 * Otherwise, KERN_FAILURE is returned.
411 routine mach_port_kernel_object(
413 name : mach_port_name_t;
414 out object_type : unsigned;
415 out object_addr : vm_offset_t);
419 * Inserts the specified rights into the portset identified
420 * by the <task, pset> pair. The results of passing in the
421 * Poly argument via the supplied disposition must yield a
424 * If the <task,pset> pair does not represent a valid portset
425 * KERN_INVALID_RIGHT is returned.
427 * If the passed in name argument does not represent a receive
428 * right, KERN_INVALID_CAPABILITY will be returned.
430 * If the port represented by the receive right is already in
431 * the portset, KERN_ALREADY_IN_SET is returned.
433 routine mach_port_insert_member(
435 name : mach_port_name_t;
436 pset : mach_port_name_t);
439 * Extracts the specified right from the named portset
440 * in the target task.
441 * the target task. The target task loses a user
442 * ref and the name may be available for recycling.
443 * msgt_name must be one of
444 * MACH_MSG_TYPE_MOVE_RECEIVE
445 * MACH_MSG_TYPE_COPY_SEND
446 * MACH_MSG_TYPE_MAKE_SEND
447 * MACH_MSG_TYPE_MOVE_SEND
448 * MACH_MSG_TYPE_MAKE_SEND_ONCE
449 * MACH_MSG_TYPE_MOVE_SEND_ONCE
452 routine mach_port_extract_member(
454 name : mach_port_name_t;
455 pset : mach_port_name_t);