]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2000-2007 Apple 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 | task 3400; |
70 | ||
71 | #include <mach/std_types.defs> | |
72 | #include <mach/mach_types.defs> | |
6d2010ae A |
73 | #include <mach_debug/mach_debug_types.defs> |
74 | ||
c3c9b80d A |
75 | #if !KERNEL && !LIBSYSCALL_INTERFACE |
76 | #define PREFIX(NAME) _kernelrpc_ ## NAME | |
77 | #else | |
78 | #define PREFIX(NAME) NAME | |
79 | #endif | |
80 | ||
1c79356b A |
81 | /* |
82 | * Create a new task with an empty set of IPC rights, | |
83 | * and having an address space constructed from the | |
84 | * target task (or empty, if inherit_memory is FALSE). | |
85 | */ | |
86 | routine task_create( | |
87 | target_task : task_t; | |
88 | ledgers : ledger_array_t; | |
89 | inherit_memory : boolean_t; | |
90 | out child_task : task_t); | |
91 | ||
92 | /* | |
93 | * Destroy the target task, causing all of its threads | |
94 | * to be destroyed, all of its IPC rights to be deallocated, | |
95 | * and all of its address space to be deallocated. | |
96 | */ | |
97 | routine task_terminate( | |
98 | target_task : task_t); | |
99 | ||
100 | /* | |
101 | * Returns the set of threads belonging to the target task. | |
f427ee49 A |
102 | * [Polymorphic] This routine returns thread port with the same |
103 | * flavor as that of the task port passed in. | |
1c79356b | 104 | */ |
f427ee49 A |
105 | routine |
106 | #ifdef KERNEL_SERVER | |
107 | task_threads_from_user( | |
108 | port : mach_port_t; | |
109 | #else | |
110 | task_threads( | |
813fb2f6 | 111 | target_task : task_inspect_t; |
f427ee49 | 112 | #endif |
1c79356b A |
113 | out act_list : thread_act_array_t); |
114 | ||
f427ee49 | 115 | |
1c79356b A |
116 | /* |
117 | * Stash a handful of ports for the target task; child | |
118 | * tasks inherit this stash at task_create time. | |
119 | */ | |
120 | routine mach_ports_register( | |
121 | target_task : task_t; | |
122 | init_port_set : mach_port_array_t = | |
123 | ^array[] of mach_port_t); | |
124 | ||
125 | /* | |
126 | * Retrieve the stashed ports for the target task. | |
127 | */ | |
128 | routine mach_ports_lookup( | |
129 | target_task : task_t; | |
130 | out init_port_set : mach_port_array_t = | |
131 | ^array[] of mach_port_t); | |
132 | ||
133 | /* | |
134 | * Returns information about the target task. | |
135 | */ | |
5ba3f43e A |
136 | #ifdef KERNEL_SERVER |
137 | routine task_info_from_user( | |
138 | target_task : mach_port_t; | |
139 | flavor : task_flavor_t; | |
140 | out task_info_out : task_info_t, CountInOut); | |
141 | #else | |
1c79356b | 142 | routine task_info( |
0c530ab8 | 143 | target_task : task_name_t; |
1c79356b A |
144 | flavor : task_flavor_t; |
145 | out task_info_out : task_info_t, CountInOut); | |
146 | ||
5ba3f43e | 147 | #endif |
1c79356b A |
148 | /* |
149 | * Set task information. | |
150 | */ | |
151 | routine task_set_info( | |
152 | target_task : task_t; | |
153 | flavor : task_flavor_t; | |
154 | task_info_in : task_info_t); | |
155 | ||
156 | /* | |
157 | * Increment the suspend count for the target task. | |
158 | * No threads within a task may run when the suspend | |
159 | * count for that task is non-zero. | |
160 | */ | |
161 | routine task_suspend( | |
c3c9b80d | 162 | target_task : task_read_t); |
1c79356b A |
163 | |
164 | ||
165 | /* | |
166 | * Decrement the suspend count for the target task, | |
167 | * if the count is currently non-zero. If the resulting | |
168 | * suspend count is zero, then threads within the task | |
169 | * that also have non-zero suspend counts may execute. | |
170 | */ | |
171 | routine task_resume( | |
c3c9b80d | 172 | target_task : task_read_t); |
1c79356b A |
173 | |
174 | /* | |
175 | * Returns the current value of the selected special port | |
176 | * associated with the target task. | |
177 | */ | |
f427ee49 A |
178 | routine |
179 | #ifdef KERNEL_SERVER | |
180 | task_get_special_port_from_user( | |
181 | port : mach_port_t; | |
182 | #else | |
183 | task_get_special_port( | |
813fb2f6 | 184 | task : task_inspect_t; |
f427ee49 | 185 | #endif |
1c79356b A |
186 | which_port : int; |
187 | out special_port : mach_port_t); | |
188 | ||
f427ee49 | 189 | |
1c79356b A |
190 | /* |
191 | * Set one of the special ports associated with the | |
192 | * target task. | |
193 | */ | |
194 | routine task_set_special_port( | |
195 | task : task_t; | |
196 | which_port : int; | |
197 | special_port : mach_port_t); | |
198 | ||
199 | /* | |
200 | * Create a new thread within the target task, returning | |
201 | * the port representing the first thr_act in that new thread. The | |
202 | * initial execution state of the thread is undefined. | |
203 | */ | |
6d2010ae A |
204 | routine |
205 | #ifdef KERNEL_SERVER | |
206 | thread_create_from_user( | |
207 | #else | |
208 | thread_create( | |
209 | #endif | |
1c79356b A |
210 | parent_task : task_t; |
211 | out child_act : thread_act_t); | |
212 | ||
213 | /* | |
214 | * Create a new thread within the target task, returning | |
215 | * the port representing that new thread. The new thread | |
216 | * is not suspended; its initial execution state is given | |
217 | * by flavor and new_state. Returns the port representing | |
218 | * the new thread. | |
219 | */ | |
6d2010ae A |
220 | routine |
221 | #ifdef KERNEL_SERVER | |
222 | thread_create_running_from_user( | |
223 | #else | |
224 | thread_create_running( | |
225 | #endif | |
1c79356b A |
226 | parent_task : task_t; |
227 | flavor : thread_state_flavor_t; | |
228 | new_state : thread_state_t; | |
229 | out child_act : thread_act_t); | |
230 | ||
231 | /* | |
232 | * Set an exception handler for a task on one or more exception types. | |
233 | * These handlers are invoked for all threads in the task if there are | |
234 | * no thread-specific exception handlers or those handlers returned an | |
235 | * error. | |
236 | */ | |
237 | routine task_set_exception_ports( | |
238 | task : task_t; | |
239 | exception_mask : exception_mask_t; | |
240 | new_port : mach_port_t; | |
241 | behavior : exception_behavior_t; | |
242 | new_flavor : thread_state_flavor_t); | |
243 | ||
244 | ||
245 | /* | |
246 | * Lookup some of the old exception handlers for a task | |
247 | */ | |
f427ee49 A |
248 | routine |
249 | #if KERNEL_SERVER | |
250 | task_get_exception_ports_from_user( | |
251 | port : mach_port_t; | |
252 | #else | |
253 | task_get_exception_ports( | |
254 | task : task_t; | |
255 | #endif | |
1c79356b A |
256 | exception_mask : exception_mask_t; |
257 | out masks : exception_mask_array_t; | |
258 | out old_handlers : exception_handler_array_t, SameCount; | |
259 | out old_behaviors : exception_behavior_array_t, SameCount; | |
260 | out old_flavors : exception_flavor_array_t, SameCount); | |
261 | ||
262 | ||
263 | /* | |
264 | * Set an exception handler for a thread on one or more exception types. | |
265 | * At the same time, return the previously defined exception handlers for | |
266 | * those types. | |
267 | */ | |
268 | routine task_swap_exception_ports( | |
269 | task : task_t; | |
270 | exception_mask : exception_mask_t; | |
271 | new_port : mach_port_t; | |
272 | behavior : exception_behavior_t; | |
273 | new_flavor : thread_state_flavor_t; | |
274 | out masks : exception_mask_array_t; | |
c3c9b80d | 275 | out old_handlers : exception_handler_array_t, SameCount; |
1c79356b A |
276 | out old_behaviors : exception_behavior_array_t, SameCount; |
277 | out old_flavors : exception_flavor_array_t, SameCount); | |
278 | ||
279 | /* | |
39236c6e | 280 | * OBSOLETE interface. |
1c79356b A |
281 | */ |
282 | routine lock_set_create( | |
283 | task : task_t; | |
284 | out new_lock_set : lock_set_t; | |
285 | n_ulocks : int; | |
286 | policy : int); | |
287 | ||
39236c6e A |
288 | /* |
289 | * OBSOLETE interface. | |
290 | */ | |
1c79356b A |
291 | routine lock_set_destroy( |
292 | task : task_t; | |
293 | lock_set : lock_set_t); | |
294 | ||
39236c6e A |
295 | /* |
296 | * Create and destroy semaphore synchronizers on a | |
297 | * per-task basis (i.e. the task owns them). | |
298 | */ | |
299 | ||
1c79356b A |
300 | routine semaphore_create( |
301 | task : task_t; | |
302 | out semaphore : semaphore_t; | |
303 | policy : int; | |
304 | value : int); | |
305 | ||
306 | routine semaphore_destroy( | |
307 | task : task_t; | |
308 | semaphore : semaphore_consume_ref_t); | |
309 | ||
310 | /* | |
311 | * Set/get policy information for a task. | |
312 | * (Approved Mac OS X microkernel interface) | |
313 | */ | |
314 | ||
315 | routine task_policy_set( | |
f427ee49 | 316 | task : task_policy_set_t; |
1c79356b A |
317 | flavor : task_policy_flavor_t; |
318 | policy_info : task_policy_t); | |
319 | ||
320 | routine task_policy_get( | |
f427ee49 | 321 | task : task_policy_get_t; |
1c79356b A |
322 | flavor : task_policy_flavor_t; |
323 | out policy_info : task_policy_t, CountInOut; | |
324 | inout get_default : boolean_t); | |
325 | ||
326 | /* | |
2d21ac55 | 327 | * Removed from the kernel. |
1c79356b | 328 | */ |
2d21ac55 A |
329 | #if KERNEL_SERVER |
330 | skip; | |
331 | #else | |
1c79356b A |
332 | routine task_sample( |
333 | task : task_t; | |
334 | reply : mach_port_make_send_t); | |
2d21ac55 | 335 | #endif |
1c79356b A |
336 | |
337 | /* | |
338 | * JMM - Everything from here down is likely to go away soon | |
339 | */ | |
340 | /* | |
341 | * OBSOLETE interface. | |
342 | */ | |
343 | routine task_policy( | |
344 | task : task_t; | |
345 | policy : policy_t; | |
346 | base : policy_base_t; | |
347 | set_limit : boolean_t; | |
348 | change : boolean_t); | |
349 | ||
350 | ||
351 | /* | |
352 | * Establish a user-level handler for the specified | |
353 | * system call. | |
354 | */ | |
355 | routine task_set_emulation( | |
356 | target_port : task_t; | |
357 | routine_entry_pt: vm_address_t; | |
358 | routine_number : int); | |
359 | ||
360 | /* | |
361 | * Get user-level handler entry points for all | |
362 | * emulated system calls. | |
363 | */ | |
364 | routine task_get_emulation_vector( | |
365 | task : task_t; | |
366 | out vector_start : int; | |
367 | out emulation_vector: emulation_vector_t); | |
368 | ||
369 | /* | |
370 | * Establish user-level handlers for the specified | |
371 | * system calls. Non-emulated system calls are specified | |
372 | * with emulation_vector[i] == EML_ROUTINE_NULL. | |
373 | */ | |
374 | routine task_set_emulation_vector( | |
375 | task : task_t; | |
376 | vector_start : int; | |
377 | emulation_vector: emulation_vector_t); | |
378 | ||
379 | ||
380 | /* | |
381 | * Establish restart pc for interrupted atomic sequences. | |
382 | */ | |
383 | routine task_set_ras_pc( | |
384 | target_task : task_t; | |
385 | basepc : vm_address_t; | |
386 | boundspc : vm_address_t); | |
387 | ||
388 | ||
6d2010ae A |
389 | /* |
390 | * Return zone info as seen/used by this task. | |
391 | */ | |
392 | routine task_zone_info( | |
f427ee49 | 393 | target_task : task_inspect_t; |
6d2010ae A |
394 | out names : mach_zone_name_array_t, |
395 | Dealloc; | |
396 | out info : task_zone_info_array_t, | |
397 | Dealloc); | |
398 | ||
91447636 | 399 | |
1c79356b | 400 | /* |
91447636 | 401 | * JMM - Want to eliminate processor_set so keep them at the end. |
1c79356b | 402 | */ |
1c79356b A |
403 | |
404 | /* | |
405 | * Assign task to processor set. | |
406 | */ | |
407 | routine task_assign( | |
408 | task : task_t; | |
409 | new_set : processor_set_t; | |
410 | assign_threads : boolean_t); | |
411 | ||
412 | /* | |
413 | * Assign task to default set. | |
414 | */ | |
415 | routine task_assign_default( | |
416 | task : task_t; | |
417 | assign_threads : boolean_t); | |
418 | ||
419 | /* | |
420 | * Get current assignment for task. | |
421 | */ | |
422 | routine task_get_assignment( | |
f427ee49 | 423 | task : task_inspect_t; |
1c79356b A |
424 | out assigned_set : processor_set_name_t); |
425 | ||
426 | /* | |
427 | * OBSOLETE interface. | |
428 | */ | |
429 | routine task_set_policy( | |
430 | task : task_t; | |
431 | pset : processor_set_t; | |
432 | policy : policy_t; | |
433 | base : policy_base_t; | |
434 | limit : policy_limit_t; | |
435 | change : boolean_t); | |
436 | ||
b0d623f7 A |
437 | /* |
438 | * Read the selected state which is to be installed on new | |
439 | * threads in the task as they are created. | |
440 | */ | |
441 | routine task_get_state( | |
f427ee49 | 442 | task : task_read_t; |
b0d623f7 A |
443 | flavor : thread_state_flavor_t; |
444 | out old_state : thread_state_t, CountInOut); | |
445 | ||
446 | /* | |
447 | * Set the selected state information to be installed on | |
448 | * all subsequently created threads in the task. | |
449 | */ | |
450 | routine task_set_state( | |
451 | task : task_t; | |
452 | flavor : thread_state_flavor_t; | |
453 | new_state : thread_state_t); | |
454 | ||
39236c6e A |
455 | /* |
456 | * Change the task's physical footprint limit (in MB). | |
457 | */ | |
458 | routine task_set_phys_footprint_limit( | |
459 | task : task_t; | |
460 | new_limit : int; | |
461 | out old_limit : int); | |
462 | ||
39236c6e | 463 | routine task_suspend2( |
c3c9b80d | 464 | target_task : task_read_t; |
39236c6e A |
465 | out suspend_token : task_suspension_token_t); |
466 | ||
467 | routine task_resume2( | |
468 | suspend_token : task_suspension_token_t); | |
469 | ||
470 | routine task_purgable_info( | |
f427ee49 | 471 | task : task_inspect_t; |
39236c6e | 472 | out stats : task_purgable_info_t); |
fe8ab488 A |
473 | |
474 | routine task_get_mach_voucher( | |
f427ee49 | 475 | task : task_read_t; |
fe8ab488 A |
476 | which : mach_voucher_selector_t; |
477 | out voucher : ipc_voucher_t); | |
478 | ||
479 | routine task_set_mach_voucher( | |
480 | task : task_t; | |
481 | voucher : ipc_voucher_t); | |
482 | ||
483 | routine task_swap_mach_voucher( | |
484 | task : task_t; | |
485 | new_voucher : ipc_voucher_t; | |
486 | inout old_voucher : ipc_voucher_t); | |
487 | ||
39037602 | 488 | routine task_generate_corpse( |
c3c9b80d | 489 | task :task_read_t; |
39037602 A |
490 | out corpse_task_port:mach_port_t); |
491 | ||
492 | routine task_map_corpse_info( | |
493 | task :task_t; | |
f427ee49 | 494 | corspe_task :task_read_t; |
39037602 A |
495 | out kcd_addr_begin :vm_address_t; |
496 | out kcd_size :uint32_t); | |
497 | ||
498 | routine task_register_dyld_image_infos( | |
499 | task :task_t; | |
500 | dyld_images :dyld_kernel_image_info_array_t); | |
501 | ||
502 | routine task_unregister_dyld_image_infos( | |
503 | task :task_t; | |
504 | dyld_images :dyld_kernel_image_info_array_t); | |
505 | ||
506 | routine task_get_dyld_image_infos( | |
f427ee49 | 507 | task :task_read_t; |
39037602 A |
508 | out dyld_images :dyld_kernel_image_info_array_t); |
509 | ||
510 | routine task_register_dyld_shared_cache_image_info( | |
511 | task :task_t; | |
512 | dyld_cache_image :dyld_kernel_image_info_t; | |
513 | no_cache :boolean_t; | |
514 | private_cache :boolean_t); | |
515 | ||
516 | routine task_register_dyld_set_dyld_state( | |
517 | task :task_t; | |
518 | dyld_state :uint8_t); | |
519 | ||
520 | routine task_register_dyld_get_process_state( | |
521 | task :task_t; | |
522 | out dyld_process_state :dyld_kernel_process_info_t); | |
523 | ||
524 | routine task_map_corpse_info_64( | |
525 | task :task_t; | |
f427ee49 | 526 | corspe_task :task_read_t; |
39037602 A |
527 | out kcd_addr_begin :mach_vm_address_t; |
528 | out kcd_size :mach_vm_size_t); | |
529 | ||
5ba3f43e A |
530 | routine task_inspect( |
531 | task : task_inspect_t; | |
532 | flavor : task_inspect_flavor_t; | |
533 | out info_out : task_inspect_info_t, CountInOut); | |
534 | ||
cb323159 A |
535 | routine task_get_exc_guard_behavior( |
536 | task : task_inspect_t; | |
537 | out behavior : task_exc_guard_behavior_t); | |
538 | ||
539 | routine task_set_exc_guard_behavior( | |
540 | task : task_t; | |
541 | behavior : task_exc_guard_behavior_t); | |
542 | ||
ea3f0419 A |
543 | routine task_create_suid_cred( |
544 | task : task_t; | |
545 | path : suid_cred_path_t; | |
546 | uid : suid_cred_uid_t; | |
547 | out delegation : suid_cred_t); | |
548 | ||
c3c9b80d A |
549 | #if KERNEL || (!KERNEL && !LIBSYSCALL_INTERFACE) |
550 | routine PREFIX(mach_task_is_self)( | |
551 | task : task_name_t; | |
552 | out is_self : boolean_t); | |
553 | #else | |
554 | /* Do not generate header, use the one in mach_init.h */ | |
555 | skip; | |
556 | #endif | |
557 | ||
558 | routine task_dyld_process_info_notify_register( | |
559 | target_task : task_read_t; | |
560 | notify : mach_port_make_send_t); | |
561 | ||
562 | routine task_create_identity_token( | |
563 | task : task_t; | |
564 | out token : task_id_token_t); | |
565 | ||
566 | routine task_identity_token_get_task_port( | |
567 | token : task_id_token_t; | |
568 | flavor : task_flavor_t; | |
569 | out task_port: mach_port_t); | |
570 | ||
571 | routine task_dyld_process_info_notify_deregister( | |
572 | target_task : task_read_t; | |
573 | notify : mach_port_name_t); | |
574 | ||
575 | routine task_get_exception_ports_info( | |
576 | port : mach_port_t; | |
577 | exception_mask : exception_mask_t; | |
578 | out masks : exception_mask_array_t; | |
579 | out old_handlers_info : exception_handler_info_array_t, SameCount; | |
580 | out old_behaviors : exception_behavior_array_t, SameCount; | |
581 | out old_flavors : exception_flavor_array_t, SameCount); | |
582 | ||
fe8ab488 A |
583 | /* vim: set ft=c : */ |
584 |