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