]> git.saurik.com Git - apple/xnu.git/blob - libsyscall/mach/mach_port.c
954d45e56a8b1a41b9c39511075935c6c7947951
[apple/xnu.git] / libsyscall / mach / mach_port.c
1 /*
2 * Copyright (c) 2011 Apple 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 #include <mach/mach_port_internal.h>
30 #include <mach/mach.h>
31 #include <mach/mach_vm.h>
32 #include <mach/mach_traps.h>
33
34 kern_return_t
35 mach_port_names(
36 ipc_space_t task,
37 mach_port_name_array_t *names,
38 mach_msg_type_number_t *namesCnt,
39 mach_port_type_array_t *types,
40 mach_msg_type_number_t *typesCnt)
41 {
42 kern_return_t rv;
43
44 rv = _kernelrpc_mach_port_names(task, names, namesCnt, types,
45 typesCnt);
46
47 return (rv);
48 }
49
50 kern_return_t
51 mach_port_type(
52 ipc_space_t task,
53 mach_port_name_t name,
54 mach_port_type_t *ptype)
55 {
56 kern_return_t rv;
57
58 rv = _kernelrpc_mach_port_type(task, name, ptype);
59
60 return (rv);
61 }
62
63 kern_return_t
64 mach_port_rename(
65 ipc_space_t task,
66 mach_port_name_t old_name,
67 mach_port_name_t new_name)
68 {
69 kern_return_t rv;
70
71 rv = _kernelrpc_mach_port_rename(task, old_name, new_name);
72
73 return (rv);
74 }
75
76 kern_return_t
77 mach_port_allocate_name(
78 ipc_space_t task,
79 mach_port_right_t right,
80 mach_port_name_t name)
81 {
82 kern_return_t rv;
83
84 rv = _kernelrpc_mach_port_allocate_name(task, right, name);
85
86 return (rv);
87 }
88
89 kern_return_t
90 mach_port_allocate(
91 ipc_space_t task,
92 mach_port_right_t right,
93 mach_port_name_t *name)
94 {
95 kern_return_t rv;
96
97 rv = _kernelrpc_mach_port_allocate_trap(task, right, name);
98
99 if (rv == MACH_SEND_INVALID_DEST)
100 rv = _kernelrpc_mach_port_allocate(task, right, name);
101
102 return (rv);
103 }
104
105 kern_return_t
106 mach_port_destroy(
107 ipc_space_t task,
108 mach_port_name_t name)
109 {
110 kern_return_t rv;
111
112 rv = _kernelrpc_mach_port_destroy_trap(task, name);
113
114 if (rv == MACH_SEND_INVALID_DEST)
115 rv = _kernelrpc_mach_port_destroy(task, name);
116
117 return (rv);
118 }
119
120 kern_return_t
121 mach_port_deallocate(
122 ipc_space_t task,
123 mach_port_name_t name)
124 {
125 kern_return_t rv;
126
127 rv = _kernelrpc_mach_port_deallocate_trap(task, name);
128
129 if (rv == MACH_SEND_INVALID_DEST)
130 rv = _kernelrpc_mach_port_deallocate(task,name);
131
132 return (rv);
133 }
134
135 kern_return_t
136 mach_port_get_refs(
137 ipc_space_t task,
138 mach_port_name_t name,
139 mach_port_right_t right,
140 mach_port_urefs_t *refs)
141 {
142 kern_return_t rv;
143
144 rv = _kernelrpc_mach_port_get_refs(task, name, right, refs);
145
146 return (rv);
147 }
148
149 kern_return_t
150 mach_port_mod_refs(
151 ipc_space_t task,
152 mach_port_name_t name,
153 mach_port_right_t right,
154 mach_port_delta_t delta)
155 {
156 kern_return_t rv;
157
158 rv = _kernelrpc_mach_port_mod_refs_trap(task, name, right, delta);
159
160 if (rv == MACH_SEND_INVALID_DEST)
161 rv = _kernelrpc_mach_port_mod_refs(task, name, right, delta);
162
163 return (rv);
164 }
165
166 kern_return_t
167 mach_port_set_mscount(
168 ipc_space_t task,
169 mach_port_name_t name,
170 mach_port_mscount_t mscount)
171 {
172 kern_return_t rv;
173
174 rv = _kernelrpc_mach_port_set_mscount(task, name, mscount);
175
176 return (rv);
177 }
178
179 kern_return_t
180 mach_port_get_set_status(
181 ipc_space_t task,
182 mach_port_name_t name,
183 mach_port_name_array_t *members,
184 mach_msg_type_number_t *membersCnt)
185 {
186 kern_return_t rv;
187
188 rv = _kernelrpc_mach_port_get_set_status(task, name, members,
189 membersCnt);
190
191 return (rv);
192 }
193
194 kern_return_t
195 mach_port_move_member(
196 ipc_space_t task,
197 mach_port_name_t member,
198 mach_port_name_t after)
199 {
200 kern_return_t rv;
201
202 rv = _kernelrpc_mach_port_move_member_trap(task, member, after);
203
204 if (rv == MACH_SEND_INVALID_DEST)
205 rv = _kernelrpc_mach_port_move_member(task, member, after);
206
207 return (rv);
208 }
209
210 kern_return_t
211 mach_port_request_notification(
212 ipc_space_t task,
213 mach_port_name_t name,
214 mach_msg_id_t msgid,
215 mach_port_mscount_t sync,
216 mach_port_t notify,
217 mach_msg_type_name_t notifyPoly,
218 mach_port_t *previous)
219 {
220 kern_return_t rv;
221
222 rv = _kernelrpc_mach_port_request_notification(task, name, msgid,
223 sync, notify, notifyPoly, previous);
224
225 return (rv);
226 }
227
228 kern_return_t
229 mach_port_insert_right(
230 ipc_space_t task,
231 mach_port_name_t name,
232 mach_port_t poly,
233 mach_msg_type_name_t polyPoly)
234 {
235 kern_return_t rv;
236
237 rv = _kernelrpc_mach_port_insert_right_trap(task, name, poly, polyPoly);
238
239 if (rv == MACH_SEND_INVALID_DEST)
240 rv = _kernelrpc_mach_port_insert_right(task, name, poly,
241 polyPoly);
242
243 return (rv);
244 }
245
246 kern_return_t
247 mach_port_extract_right(
248 ipc_space_t task,
249 mach_port_name_t name,
250 mach_msg_type_name_t msgt_name,
251 mach_port_t *poly,
252 mach_msg_type_name_t *polyPoly)
253 {
254 kern_return_t rv;
255
256 rv = _kernelrpc_mach_port_extract_right(task, name, msgt_name,
257 poly, polyPoly);
258
259 return (rv);
260 }
261
262 kern_return_t
263 mach_port_set_seqno(
264 ipc_space_t task,
265 mach_port_name_t name,
266 mach_port_seqno_t seqno)
267 {
268 kern_return_t rv;
269
270 rv = _kernelrpc_mach_port_set_seqno(task, name, seqno);
271
272 return (rv);
273 }
274
275 kern_return_t
276 mach_port_get_attributes(
277 ipc_space_t task,
278 mach_port_name_t name,
279 mach_port_flavor_t flavor,
280 mach_port_info_t port_info_out,
281 mach_msg_type_number_t *port_info_outCnt)
282 {
283 kern_return_t rv;
284
285 rv = _kernelrpc_mach_port_get_attributes(task, name, flavor,
286 port_info_out, port_info_outCnt);
287
288 return (rv);
289 }
290
291 kern_return_t
292 mach_port_set_attributes(
293 ipc_space_t task,
294 mach_port_name_t name,
295 mach_port_flavor_t flavor,
296 mach_port_info_t port_info,
297 mach_msg_type_number_t port_infoCnt)
298 {
299 kern_return_t rv;
300
301 rv = _kernelrpc_mach_port_set_attributes(task, name, flavor,
302 port_info, port_infoCnt);
303
304 return (rv);
305 }
306
307 kern_return_t
308 mach_port_allocate_qos(
309 ipc_space_t task,
310 mach_port_right_t right,
311 mach_port_qos_t *qos,
312 mach_port_name_t *name)
313 {
314 kern_return_t rv;
315
316 rv = _kernelrpc_mach_port_allocate_qos(task, right, qos, name);
317
318 return (rv);
319 }
320
321 kern_return_t
322 mach_port_allocate_full(
323 ipc_space_t task,
324 mach_port_right_t right,
325 mach_port_t proto,
326 mach_port_qos_t *qos,
327 mach_port_name_t *name)
328 {
329 kern_return_t rv;
330
331 rv = _kernelrpc_mach_port_allocate_full(task, right, proto, qos, name);
332
333 return (rv);
334 }
335
336 kern_return_t
337 task_set_port_space(
338 ipc_space_t task,
339 int table_entries)
340 {
341 kern_return_t rv;
342
343 rv = _kernelrpc_task_set_port_space(task, table_entries);
344
345 return (rv);
346 }
347
348 kern_return_t
349 mach_port_get_srights(
350 ipc_space_t task,
351 mach_port_name_t name,
352 mach_port_rights_t *srights)
353 {
354 kern_return_t rv;
355
356 rv = _kernelrpc_mach_port_get_srights(task, name, srights);
357
358 return (rv);
359 }
360
361 kern_return_t
362 mach_port_space_info(
363 ipc_space_t task,
364 ipc_info_space_t *space_info,
365 ipc_info_name_array_t *table_info,
366 mach_msg_type_number_t *table_infoCnt,
367 ipc_info_tree_name_array_t *tree_info,
368 mach_msg_type_number_t *tree_infoCnt)
369 {
370 kern_return_t rv;
371
372 rv = _kernelrpc_mach_port_space_info(task, space_info, table_info,
373 table_infoCnt, tree_info, tree_infoCnt);
374
375 return (rv);
376 }
377
378 kern_return_t
379 mach_port_dnrequest_info(
380 ipc_space_t task,
381 mach_port_name_t name,
382 unsigned *dnr_total,
383 unsigned *dnr_used)
384 {
385 kern_return_t rv;
386
387 rv = _kernelrpc_mach_port_dnrequest_info(task, name, dnr_total,
388 dnr_used);
389
390 return (rv);
391 }
392
393 kern_return_t
394 mach_port_kernel_object(
395 ipc_space_t task,
396 mach_port_name_t name,
397 unsigned *object_type,
398 unsigned *object_addr)
399 {
400 kern_return_t rv;
401
402 rv = _kernelrpc_mach_port_kernel_object(task, name,
403 object_type, object_addr);
404
405 return (rv);
406 }
407
408 kern_return_t
409 mach_port_insert_member(
410 ipc_space_t task,
411 mach_port_name_t name,
412 mach_port_name_t pset)
413 {
414 kern_return_t rv;
415
416 rv = _kernelrpc_mach_port_insert_member_trap(task, name, pset);
417
418 if (rv == MACH_SEND_INVALID_DEST)
419 rv = _kernelrpc_mach_port_insert_member(task, name, pset);
420
421 return (rv);
422 }
423
424 kern_return_t
425 mach_port_extract_member(
426 ipc_space_t task,
427 mach_port_name_t name,
428 mach_port_name_t pset)
429 {
430 kern_return_t rv;
431
432 rv = _kernelrpc_mach_port_extract_member_trap(task, name, pset);
433
434 if (rv == MACH_SEND_INVALID_DEST)
435 rv = _kernelrpc_mach_port_extract_member(task, name, pset);
436
437 return (rv);
438 }
439
440 kern_return_t
441 mach_port_get_context(
442 ipc_space_t task,
443 mach_port_name_t name,
444 mach_port_context_t *context)
445 {
446 kern_return_t rv;
447 mach_vm_address_t wide_context;
448
449 rv = _kernelrpc_mach_port_get_context(task, name, &wide_context);
450
451 if (rv == KERN_SUCCESS) {
452 *context = (mach_port_context_t)wide_context;
453 }
454
455 return (rv);
456 }
457
458 kern_return_t
459 mach_port_set_context(
460 ipc_space_t task,
461 mach_port_name_t name,
462 mach_port_context_t context)
463 {
464 kern_return_t rv;
465
466 rv = _kernelrpc_mach_port_set_context(task, name, context);
467
468 return (rv);
469 }
470
471 kern_return_t
472 mach_port_kobject(
473 ipc_space_t task,
474 mach_port_name_t name,
475 natural_t *object_type,
476 mach_vm_address_t *object_addr)
477 {
478 kern_return_t rv;
479
480 rv = _kernelrpc_mach_port_kobject(task, name, object_type, object_addr);
481
482 return (rv);
483 }