]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/mach_port.defs
xnu-792.6.76.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
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
37839358
A
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.
1c79356b 11 *
37839358
A
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
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
37839358
A
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * @OSF_FREE_COPYRIGHT@
24 */
25/*
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
28 * All Rights Reserved.
29 *
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.
35 *
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.
39 *
40 * Carnegie Mellon requests users of this software to return to
41 *
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
46 *
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
49 */
50/*
51 */
52/*
53 * File: mach/mach_port.defs
54 * Author: Rich Draves
55 *
56 * Exported kernel calls.
57 */
58
59subsystem
60#if KERNEL_SERVER
61 KernelServer
55e303ae 62#endif /* KERNEL_SERVER */
1c79356b
A
63 mach_port 3200;
64
65#include <mach/std_types.defs>
66#include <mach/mach_types.defs>
67#include <mach_debug/mach_debug_types.defs>
68
69/*
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.
73 */
74
75routine mach_port_names(
76 task : ipc_space_t;
77 out names : mach_port_name_array_t;
78 out types : mach_port_type_array_t);
79
80/*
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.
84 */
85
86routine mach_port_type(
87 task : ipc_space_t;
88 name : mach_port_name_t;
89 out ptype : mach_port_type_t);
90
91/*
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.
95 */
96
97routine mach_port_rename(
98 task : ipc_space_t;
99 old_name : mach_port_name_t;
100 new_name : mach_port_name_t);
101
102/*
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.
112 */
113
114routine mach_port_allocate_name(
115 task : ipc_space_t;
116 right : mach_port_right_t;
117 name : mach_port_name_t);
118
119/*
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.
127 */
128
129routine mach_port_allocate(
130 task : ipc_space_t;
131 right : mach_port_right_t;
132 out name : mach_port_name_t);
133
134/*
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).
139 */
140
141routine mach_port_destroy(
142 task : ipc_space_t;
143 name : mach_port_name_t);
144
145/*
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.
151 */
152
153routine mach_port_deallocate(
154 task : ipc_space_t;
155 name : mach_port_name_t);
156
157/*
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
169 */
170
171routine mach_port_get_refs(
172 task : ipc_space_t;
173 name : mach_port_name_t;
174 right : mach_port_right_t;
175 out refs : mach_port_urefs_t);
176
177/*
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
190 */
191
192routine mach_port_mod_refs(
193 task : ipc_space_t;
194 name : mach_port_name_t;
195 right : mach_port_right_t;
196 delta : mach_port_delta_t);
197
9bccf70c 198skip;
1c79356b
A
199
200/*
201 * Only valid for receive rights.
202 * Sets the make-send count for the port.
203 */
204routine mach_port_set_mscount(
205 task : ipc_space_t;
206 name : mach_port_name_t;
207 mscount : mach_port_mscount_t);
208
209/*
210 * Only valid for port sets. Returns a list of
211 * the members.
212 */
213
214routine mach_port_get_set_status(
215 task : ipc_space_t;
216 name : mach_port_name_t;
217 out members : mach_port_name_array_t);
218
219/*
220 * Puts the member port (the task must have receive rights)
221 * into the after port set. (Or removes it from any port set
222 * if after is MACH_PORT_NULL.) If the port is already in
223 * a set, does an atomic move.
224 */
225
226routine mach_port_move_member(
227 task : ipc_space_t;
228 member : mach_port_name_t;
229 after : mach_port_name_t);
230
231/*
232 * Requests a notification from the kernel. The request
233 * must supply the send-once right which is used for
234 * the notification. If a send-once right was previously
235 * registered, it is returned. The msg_id must be one of
236 * MACH_NOTIFY_PORT_DESTROYED (receive rights)
237 * MACH_NOTIFY_DEAD_NAME (send/receive/send-once rights)
238 * MACH_NOTIFY_NO_SENDERS (receive rights)
239 *
240 * The sync value specifies whether a notification should
241 * get sent immediately, if appropriate. The exact meaning
242 * depends on the notification:
243 * MACH_NOTIFY_PORT_DESTROYED: must be zero.
244 * MACH_NOTIFY_DEAD_NAME: if non-zero, then name can be dead,
245 * and the notification gets sent immediately.
246 * If zero, then name can't be dead.
247 * MACH_NOTIFY_NO_SENDERS: the notification gets sent
248 * immediately if the current mscount is greater
249 * than or equal to the sync value and there are no
250 * extant send rights.
251 */
252
253routine mach_port_request_notification(
254 task : ipc_space_t;
255 name : mach_port_name_t;
256 msgid : mach_msg_id_t;
257 sync : mach_port_mscount_t;
258 notify : mach_port_send_once_t;
0b4e3aa0 259 out previous : mach_port_move_send_once_t);
1c79356b
A
260
261/*
262 * Inserts the specified rights into the target task,
263 * using the specified name. If inserting send/receive
264 * rights and the task already has send/receive rights
265 * for the port, then the names must agree. In any case,
266 * the task gains a user ref for the port.
267 */
268
269routine mach_port_insert_right(
270 task : ipc_space_t;
271 name : mach_port_name_t;
272 poly : mach_port_poly_t);
273
274/*
275 * Returns the specified right for the named port
276 * in the target task, extracting that right from
277 * the target task. The target task loses a user
278 * ref and the name may be available for recycling.
279 * msgt_name must be one of
280 * MACH_MSG_TYPE_MOVE_RECEIVE
281 * MACH_MSG_TYPE_COPY_SEND
282 * MACH_MSG_TYPE_MAKE_SEND
283 * MACH_MSG_TYPE_MOVE_SEND
284 * MACH_MSG_TYPE_MAKE_SEND_ONCE
285 * MACH_MSG_TYPE_MOVE_SEND_ONCE
286 */
287
288routine mach_port_extract_right(
289 task : ipc_space_t;
290 name : mach_port_name_t;
291 msgt_name : mach_msg_type_name_t;
292 out poly : mach_port_poly_t);
293
294/*
295 * Only valid for receive rights.
296 * Sets the sequence number for the port.
297 */
298
299routine mach_port_set_seqno(
300 task : ipc_space_t;
301 name : mach_port_name_t;
302 seqno : mach_port_seqno_t);
303
304/*
305 * Returns information about a port.
306 */
307
308routine mach_port_get_attributes(
309 task : ipc_space_t;
310 name : mach_port_name_t;
311 flavor : mach_port_flavor_t;
312 out port_info_out : mach_port_info_t, CountInOut);
313
314/*
315 * Set attributes of a port
316 */
317
318routine mach_port_set_attributes(
319 task : ipc_space_t;
320 name : mach_port_name_t;
321 flavor : mach_port_flavor_t;
322 port_info : mach_port_info_t);
323
324
325/*
326 * Allocates the specified kind of object, qos version.
327 * The right must be
328 * MACH_PORT_RIGHT_RECEIVE
329 * Like port_allocate_name, but the kernel picks a name.
330 * It can use any name not associated with a right.
331 */
332
333routine mach_port_allocate_qos(
334 task : ipc_space_t;
335 right : mach_port_right_t;
336 inout qos : mach_port_qos_t;
337 out name : mach_port_name_t);
338
9bccf70c 339
1c79356b
A
340/*
341 * Generic interface to allocation various kinds of ports.
342 * Should never be called directly by users (at least not
343 * unless they are exceedingly masochistic).
344 */
345
346routine mach_port_allocate_full(
347 task : ipc_space_t;
348 right : mach_port_right_t;
9bccf70c 349 proto : mach_port_t;
1c79356b
A
350 inout qos : mach_port_qos_t;
351 inout name : mach_port_name_t);
352
353
354/*
355 * Pre-expand task port name space.
356 */
357routine task_set_port_space(
358 task : ipc_space_t;
359 table_entries : int);
360
361
362/*
363 * Returns the exact number of extant send rights
364 * for the given receive right.
365 * This call is only valid on MACH_IPC_DEBUG kernels.
366 * Otherwise, KERN_FAILURE is returned.
367 */
368routine mach_port_get_srights(
369 task : ipc_space_t;
370 name : mach_port_name_t;
371 out srights : mach_port_rights_t);
372
373
374/*
375 * Returns information about an IPC space.
376 * This call is only valid on MACH_IPC_DEBUG kernels.
377 * Otherwise, KERN_FAILURE is returned.
378 */
379routine mach_port_space_info(
380 task : ipc_space_t;
91447636 381 out space_info : ipc_info_space_t;
1c79356b
A
382 out table_info : ipc_info_name_array_t,
383 Dealloc;
384 out tree_info : ipc_info_tree_name_array_t,
385 Dealloc);
386
387/*
388 * Returns information about the dead-name requests
389 * registered with the named receive right.
390 * This call is only valid on MACH_IPC_DEBUG kernels.
391 * Otherwise, KERN_FAILURE is returned.
392 */
393routine mach_port_dnrequest_info(
394 task : ipc_space_t;
395 name : mach_port_name_t;
91447636
A
396 out dnr_total : unsigned; /* total size of table */
397 out dnr_used : unsigned); /* amount used */
1c79356b
A
398
399/*
400 * Return the type and address of the kernel object
401 * that the given send/receive right represents.
402 * This call is only valid on MACH_IPC_DEBUG kernels.
403 * Otherwise, KERN_FAILURE is returned.
404 */
405routine mach_port_kernel_object(
406 task : ipc_space_t;
407 name : mach_port_name_t;
408 out object_type : unsigned;
409 out object_addr : vm_offset_t);
410
411
412/*
413 * Inserts the specified rights into the portset identified
414 * by the <task, pset> pair. The results of passing in the
415 * Poly argument via the supplied disposition must yield a
416 * receive right.
417 *
418 * If the <task,pset> pair does not represent a valid portset
419 * KERN_INVALID_RIGHT is returned.
420 *
421 * If the passed in name argument does not represent a receive
422 * right, KERN_INVALID_CAPABILITY will be returned.
423 *
424 * If the port represented by the receive right is already in
425 * the portset, KERN_ALREADY_IN_SET is returned.
426 */
427routine mach_port_insert_member(
428 task : ipc_space_t;
429 name : mach_port_name_t;
430 pset : mach_port_name_t);
431
432/*
433 * Extracts the specified right from the named portset
434 * in the target task.
435 * the target task. The target task loses a user
436 * ref and the name may be available for recycling.
437 * msgt_name must be one of
438 * MACH_MSG_TYPE_MOVE_RECEIVE
439 * MACH_MSG_TYPE_COPY_SEND
440 * MACH_MSG_TYPE_MAKE_SEND
441 * MACH_MSG_TYPE_MOVE_SEND
442 * MACH_MSG_TYPE_MAKE_SEND_ONCE
443 * MACH_MSG_TYPE_MOVE_SEND_ONCE
444 */
445
446routine mach_port_extract_member(
447 task : ipc_space_t;
448 name : mach_port_name_t;
449 pset : mach_port_name_t);
450