]>
Commit | Line | Data |
---|---|---|
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 | ||
65 | subsystem | |
66 | #if KERNEL_SERVER | |
67 | KernelServer | |
55e303ae | 68 | #endif /* KERNEL_SERVER */ |
1c79356b A |
69 | mach_port 3200; |
70 | ||
71 | #include <mach/std_types.defs> | |
72 | #include <mach/mach_types.defs> | |
73 | #include <mach_debug/mach_debug_types.defs> | |
74 | ||
75 | /* | |
76 | * Returns the set of port and port set names | |
77 | * to which the target task has access, along with | |
78 | * the type (set or port) for each name. | |
79 | */ | |
80 | ||
81 | routine mach_port_names( | |
82 | task : ipc_space_t; | |
83 | out names : mach_port_name_array_t; | |
84 | out types : mach_port_type_array_t); | |
85 | ||
86 | /* | |
87 | * Returns the type (set or port) for the port name | |
88 | * within the target task. Also indicates whether | |
89 | * there is a dead-name request for the name. | |
90 | */ | |
91 | ||
92 | routine mach_port_type( | |
93 | task : ipc_space_t; | |
94 | name : mach_port_name_t; | |
95 | out ptype : mach_port_type_t); | |
96 | ||
97 | /* | |
98 | * Changes the name by which a port (or port set) is known to | |
99 | * the target task. The new name can't be in use. The | |
100 | * old name becomes available for recycling. | |
101 | */ | |
102 | ||
103 | routine mach_port_rename( | |
104 | task : ipc_space_t; | |
105 | old_name : mach_port_name_t; | |
106 | new_name : mach_port_name_t); | |
107 | ||
108 | /* | |
109 | * Allocates the specified kind of object, with the given name. | |
110 | * The right must be one of | |
111 | * MACH_PORT_RIGHT_RECEIVE | |
112 | * MACH_PORT_RIGHT_PORT_SET | |
113 | * MACH_PORT_RIGHT_DEAD_NAME | |
114 | * New port sets are empty. New ports don't have any | |
115 | * send/send-once rights or queued messages. The make-send | |
116 | * count is zero and their queue limit is MACH_PORT_QLIMIT_DEFAULT. | |
117 | * New sets, ports, and dead names have one user reference. | |
118 | */ | |
119 | ||
120 | routine mach_port_allocate_name( | |
121 | task : ipc_space_t; | |
122 | right : mach_port_right_t; | |
123 | name : mach_port_name_t); | |
124 | ||
125 | /* | |
126 | * Allocates the specified kind of object. | |
127 | * The right must be one of | |
128 | * MACH_PORT_RIGHT_RECEIVE | |
129 | * MACH_PORT_RIGHT_PORT_SET | |
130 | * MACH_PORT_RIGHT_DEAD_NAME | |
131 | * Like port_allocate_name, but the kernel picks a name. | |
132 | * It can use any name not associated with a right. | |
133 | */ | |
134 | ||
135 | routine mach_port_allocate( | |
136 | task : ipc_space_t; | |
137 | right : mach_port_right_t; | |
138 | out name : mach_port_name_t); | |
139 | ||
140 | /* | |
141 | * Destroys all rights associated with the name and makes it | |
142 | * available for recycling immediately. The name can be a | |
143 | * port (possibly with multiple user refs), a port set, or | |
144 | * a dead name (again, with multiple user refs). | |
145 | */ | |
146 | ||
147 | routine mach_port_destroy( | |
148 | task : ipc_space_t; | |
149 | name : mach_port_name_t); | |
150 | ||
151 | /* | |
152 | * Releases one send/send-once/dead-name user ref. | |
153 | * Just like mach_port_mod_refs -1, but deduces the | |
154 | * correct type of right. This allows a user task | |
155 | * to release a ref for a port without worrying | |
156 | * about whether the port has died or not. | |
157 | */ | |
158 | ||
159 | routine mach_port_deallocate( | |
160 | task : ipc_space_t; | |
161 | name : mach_port_name_t); | |
162 | ||
163 | /* | |
164 | * A port set always has one user ref. | |
165 | * A send-once right always has one user ref. | |
166 | * A dead name always has one or more user refs. | |
167 | * A send right always has one or more user refs. | |
168 | * A receive right always has one user ref. | |
169 | * The right must be one of | |
170 | * MACH_PORT_RIGHT_RECEIVE | |
171 | * MACH_PORT_RIGHT_PORT_SET | |
172 | * MACH_PORT_RIGHT_DEAD_NAME | |
173 | * MACH_PORT_RIGHT_SEND | |
174 | * MACH_PORT_RIGHT_SEND_ONCE | |
175 | */ | |
176 | ||
177 | routine mach_port_get_refs( | |
178 | task : ipc_space_t; | |
179 | name : mach_port_name_t; | |
180 | right : mach_port_right_t; | |
181 | out refs : mach_port_urefs_t); | |
182 | ||
183 | /* | |
184 | * The delta is a signed change to the task's | |
185 | * user ref count for the right. Only dead names | |
186 | * and send rights can have a positive delta. | |
187 | * The resulting user ref count can't be negative. | |
188 | * If it is zero, the right is deallocated. | |
189 | * If the name isn't a composite right, it becomes | |
190 | * available for recycling. The right must be one of | |
191 | * MACH_PORT_RIGHT_RECEIVE | |
192 | * MACH_PORT_RIGHT_PORT_SET | |
193 | * MACH_PORT_RIGHT_DEAD_NAME | |
194 | * MACH_PORT_RIGHT_SEND | |
195 | * MACH_PORT_RIGHT_SEND_ONCE | |
196 | */ | |
197 | ||
198 | routine mach_port_mod_refs( | |
199 | task : ipc_space_t; | |
200 | name : mach_port_name_t; | |
201 | right : mach_port_right_t; | |
202 | delta : mach_port_delta_t); | |
203 | ||
9bccf70c | 204 | skip; |
1c79356b A |
205 | |
206 | /* | |
207 | * Only valid for receive rights. | |
208 | * Sets the make-send count for the port. | |
209 | */ | |
210 | routine mach_port_set_mscount( | |
211 | task : ipc_space_t; | |
212 | name : mach_port_name_t; | |
213 | mscount : mach_port_mscount_t); | |
214 | ||
215 | /* | |
216 | * Only valid for port sets. Returns a list of | |
217 | * the members. | |
218 | */ | |
219 | ||
220 | routine mach_port_get_set_status( | |
221 | task : ipc_space_t; | |
222 | name : mach_port_name_t; | |
223 | out members : mach_port_name_array_t); | |
224 | ||
225 | /* | |
226 | * Puts the member port (the task must have receive rights) | |
2d21ac55 A |
227 | * into the after port set. If the port is already a member |
228 | * of any set(s), it is atomically removed from those sets as | |
229 | * part of this operation. (If after is MACH_PORT_NULL, the | |
230 | * port is still removed from all current sets). | |
1c79356b A |
231 | */ |
232 | ||
233 | routine mach_port_move_member( | |
234 | task : ipc_space_t; | |
235 | member : mach_port_name_t; | |
236 | after : mach_port_name_t); | |
237 | ||
238 | /* | |
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) | |
246 | * | |
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. | |
258 | */ | |
259 | ||
260 | routine mach_port_request_notification( | |
261 | task : ipc_space_t; | |
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; | |
0b4e3aa0 | 266 | out previous : mach_port_move_send_once_t); |
1c79356b A |
267 | |
268 | /* | |
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. | |
274 | */ | |
275 | ||
276 | routine mach_port_insert_right( | |
277 | task : ipc_space_t; | |
278 | name : mach_port_name_t; | |
279 | poly : mach_port_poly_t); | |
280 | ||
281 | /* | |
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 | |
293 | */ | |
294 | ||
295 | routine mach_port_extract_right( | |
296 | task : ipc_space_t; | |
297 | name : mach_port_name_t; | |
298 | msgt_name : mach_msg_type_name_t; | |
299 | out poly : mach_port_poly_t); | |
300 | ||
301 | /* | |
302 | * Only valid for receive rights. | |
303 | * Sets the sequence number for the port. | |
304 | */ | |
305 | ||
306 | routine mach_port_set_seqno( | |
307 | task : ipc_space_t; | |
308 | name : mach_port_name_t; | |
309 | seqno : mach_port_seqno_t); | |
310 | ||
311 | /* | |
312 | * Returns information about a port. | |
313 | */ | |
314 | ||
315 | routine mach_port_get_attributes( | |
316 | task : ipc_space_t; | |
317 | name : mach_port_name_t; | |
318 | flavor : mach_port_flavor_t; | |
319 | out port_info_out : mach_port_info_t, CountInOut); | |
320 | ||
321 | /* | |
322 | * Set attributes of a port | |
323 | */ | |
324 | ||
325 | routine mach_port_set_attributes( | |
326 | task : ipc_space_t; | |
327 | name : mach_port_name_t; | |
328 | flavor : mach_port_flavor_t; | |
329 | port_info : mach_port_info_t); | |
330 | ||
331 | ||
332 | /* | |
333 | * Allocates the specified kind of object, qos version. | |
334 | * The right must be | |
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. | |
338 | */ | |
339 | ||
340 | routine mach_port_allocate_qos( | |
341 | task : ipc_space_t; | |
342 | right : mach_port_right_t; | |
343 | inout qos : mach_port_qos_t; | |
344 | out name : mach_port_name_t); | |
345 | ||
9bccf70c | 346 | |
1c79356b A |
347 | /* |
348 | * Generic interface to allocation various kinds of ports. | |
349 | * Should never be called directly by users (at least not | |
350 | * unless they are exceedingly masochistic). | |
351 | */ | |
352 | ||
353 | routine mach_port_allocate_full( | |
354 | task : ipc_space_t; | |
355 | right : mach_port_right_t; | |
9bccf70c | 356 | proto : mach_port_t; |
1c79356b A |
357 | inout qos : mach_port_qos_t; |
358 | inout name : mach_port_name_t); | |
359 | ||
360 | ||
361 | /* | |
362 | * Pre-expand task port name space. | |
363 | */ | |
364 | routine task_set_port_space( | |
365 | task : ipc_space_t; | |
366 | table_entries : int); | |
367 | ||
368 | ||
369 | /* | |
370 | * Returns the exact number of extant send rights | |
371 | * for the given receive right. | |
372 | * This call is only valid on MACH_IPC_DEBUG kernels. | |
373 | * Otherwise, KERN_FAILURE is returned. | |
374 | */ | |
375 | routine mach_port_get_srights( | |
376 | task : ipc_space_t; | |
377 | name : mach_port_name_t; | |
378 | out srights : mach_port_rights_t); | |
379 | ||
380 | ||
381 | /* | |
382 | * Returns information about an IPC space. | |
383 | * This call is only valid on MACH_IPC_DEBUG kernels. | |
384 | * Otherwise, KERN_FAILURE is returned. | |
385 | */ | |
386 | routine mach_port_space_info( | |
387 | task : ipc_space_t; | |
91447636 | 388 | out space_info : ipc_info_space_t; |
2d21ac55 A |
389 | out table_info : ipc_info_name_array_t; |
390 | out tree_info : ipc_info_tree_name_array_t); | |
1c79356b A |
391 | |
392 | /* | |
393 | * Returns information about the dead-name requests | |
394 | * registered with the named receive right. | |
395 | * This call is only valid on MACH_IPC_DEBUG kernels. | |
396 | * Otherwise, KERN_FAILURE is returned. | |
397 | */ | |
398 | routine mach_port_dnrequest_info( | |
399 | task : ipc_space_t; | |
400 | name : mach_port_name_t; | |
91447636 A |
401 | out dnr_total : unsigned; /* total size of table */ |
402 | out dnr_used : unsigned); /* amount used */ | |
1c79356b A |
403 | |
404 | /* | |
405 | * Return the type and address of the kernel object | |
406 | * that the given send/receive right represents. | |
407 | * This call is only valid on MACH_IPC_DEBUG kernels. | |
408 | * Otherwise, KERN_FAILURE is returned. | |
b0d623f7 A |
409 | * |
410 | * This interface is DEPRECATED in favor of the new | |
411 | * mach_port_kernel_object64() call (see below). | |
1c79356b A |
412 | */ |
413 | routine mach_port_kernel_object( | |
414 | task : ipc_space_t; | |
415 | name : mach_port_name_t; | |
416 | out object_type : unsigned; | |
b0d623f7 | 417 | out object_addr : unsigned); |
1c79356b A |
418 | |
419 | ||
420 | /* | |
421 | * Inserts the specified rights into the portset identified | |
422 | * by the <task, pset> pair. The results of passing in the | |
423 | * Poly argument via the supplied disposition must yield a | |
424 | * receive right. | |
425 | * | |
426 | * If the <task,pset> pair does not represent a valid portset | |
427 | * KERN_INVALID_RIGHT is returned. | |
428 | * | |
429 | * If the passed in name argument does not represent a receive | |
430 | * right, KERN_INVALID_CAPABILITY will be returned. | |
431 | * | |
432 | * If the port represented by the receive right is already in | |
433 | * the portset, KERN_ALREADY_IN_SET is returned. | |
434 | */ | |
435 | routine mach_port_insert_member( | |
436 | task : ipc_space_t; | |
437 | name : mach_port_name_t; | |
438 | pset : mach_port_name_t); | |
439 | ||
440 | /* | |
441 | * Extracts the specified right from the named portset | |
442 | * in the target task. | |
443 | * the target task. The target task loses a user | |
444 | * ref and the name may be available for recycling. | |
445 | * msgt_name must be one of | |
446 | * MACH_MSG_TYPE_MOVE_RECEIVE | |
447 | * MACH_MSG_TYPE_COPY_SEND | |
448 | * MACH_MSG_TYPE_MAKE_SEND | |
449 | * MACH_MSG_TYPE_MOVE_SEND | |
450 | * MACH_MSG_TYPE_MAKE_SEND_ONCE | |
451 | * MACH_MSG_TYPE_MOVE_SEND_ONCE | |
452 | */ | |
453 | ||
454 | routine mach_port_extract_member( | |
455 | task : ipc_space_t; | |
456 | name : mach_port_name_t; | |
457 | pset : mach_port_name_t); | |
458 | ||
b0d623f7 A |
459 | /* |
460 | * Only valid for receive rights. | |
461 | * Gets the context pointer for the port. | |
462 | */ | |
463 | ||
464 | routine mach_port_get_context( | |
465 | task : ipc_space_t; | |
466 | name : mach_port_name_t; | |
467 | out context : mach_vm_address_t); | |
468 | ||
469 | /* | |
470 | * Only valid for receive rights. | |
471 | * Sets the context pointer for the port. | |
472 | */ | |
473 | ||
474 | routine mach_port_set_context( | |
475 | task : ipc_space_t; | |
476 | name : mach_port_name_t; | |
477 | context : mach_vm_address_t); | |
478 | ||
479 | /* | |
480 | * Return the type and address of the kernel object | |
481 | * that the given send/receive right represents. | |
482 | * This call is only valid on MACH_IPC_DEBUG kernels. | |
483 | * Otherwise, KERN_FAILURE is returned. | |
484 | */ | |
485 | routine mach_port_kobject( | |
486 | task : ipc_space_t; | |
487 | name : mach_port_name_t; | |
488 | out object_type : natural_t; | |
489 | out object_addr : mach_vm_address_t); | |
490 | ||
491 | ||
2d21ac55 | 492 | /* vim: set ft=c : */ |