]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/task.defs
4b48bb21b25f713050720ebbc7a7bfc0e004f749
[apple/xnu.git] / osfmk / mach / task.defs
1 /*
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * @OSF_FREE_COPYRIGHT@
32 */
33 /*
34 * Mach Operating System
35 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
36 * All Rights Reserved.
37 *
38 * Permission to use, copy, modify and distribute this software and its
39 * documentation is hereby granted, provided that both the copyright
40 * notice and this permission notice appear in all copies of the
41 * software, derivative works or modified versions, and any portions
42 * thereof, and that both notices appear in supporting documentation.
43 *
44 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
45 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
46 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
47 *
48 * Carnegie Mellon requests users of this software to return to
49 *
50 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
51 * School of Computer Science
52 * Carnegie Mellon University
53 * Pittsburgh PA 15213-3890
54 *
55 * any improvements or extensions that they make and grant Carnegie Mellon
56 * the rights to redistribute these changes.
57 */
58 /*
59 */
60 /*
61 * File: mach/mach_port.defs
62 * Author: Rich Draves
63 *
64 * Exported kernel calls.
65 */
66
67 subsystem
68 #if KERNEL_SERVER
69 KernelServer
70 #endif /* KERNEL_SERVER */
71 task 3400;
72
73 #include <mach/std_types.defs>
74 #include <mach/mach_types.defs>
75 /*
76 * Create a new task with an empty set of IPC rights,
77 * and having an address space constructed from the
78 * target task (or empty, if inherit_memory is FALSE).
79 */
80 routine task_create(
81 target_task : task_t;
82 ledgers : ledger_array_t;
83 inherit_memory : boolean_t;
84 out child_task : task_t);
85
86 /*
87 * Destroy the target task, causing all of its threads
88 * to be destroyed, all of its IPC rights to be deallocated,
89 * and all of its address space to be deallocated.
90 */
91 routine task_terminate(
92 target_task : task_t);
93
94 /*
95 * Returns the set of threads belonging to the target task.
96 */
97 routine task_threads(
98 target_task : task_t;
99 out act_list : thread_act_array_t);
100
101 /*
102 * Stash a handful of ports for the target task; child
103 * tasks inherit this stash at task_create time.
104 */
105 routine mach_ports_register(
106 target_task : task_t;
107 init_port_set : mach_port_array_t =
108 ^array[] of mach_port_t);
109
110 /*
111 * Retrieve the stashed ports for the target task.
112 */
113 routine mach_ports_lookup(
114 target_task : task_t;
115 out init_port_set : mach_port_array_t =
116 ^array[] of mach_port_t);
117
118 /*
119 * Returns information about the target task.
120 */
121 routine task_info(
122 target_task : task_name_t;
123 flavor : task_flavor_t;
124 out task_info_out : task_info_t, CountInOut);
125
126 /*
127 * Set task information.
128 */
129 routine task_set_info(
130 target_task : task_t;
131 flavor : task_flavor_t;
132 task_info_in : task_info_t);
133
134 /*
135 * Increment the suspend count for the target task.
136 * No threads within a task may run when the suspend
137 * count for that task is non-zero.
138 */
139 routine task_suspend(
140 target_task : task_t);
141
142
143 /*
144 * Decrement the suspend count for the target task,
145 * if the count is currently non-zero. If the resulting
146 * suspend count is zero, then threads within the task
147 * that also have non-zero suspend counts may execute.
148 */
149 routine task_resume(
150 target_task : task_t);
151
152 /*
153 * Returns the current value of the selected special port
154 * associated with the target task.
155 */
156 routine task_get_special_port(
157 task : task_t;
158 which_port : int;
159 out special_port : mach_port_t);
160
161 /*
162 * Set one of the special ports associated with the
163 * target task.
164 */
165 routine task_set_special_port(
166 task : task_t;
167 which_port : int;
168 special_port : mach_port_t);
169
170 /*
171 * Create a new thread within the target task, returning
172 * the port representing the first thr_act in that new thread. The
173 * initial execution state of the thread is undefined.
174 */
175 routine thread_create(
176 parent_task : task_t;
177 out child_act : thread_act_t);
178
179 /*
180 * Create a new thread within the target task, returning
181 * the port representing that new thread. The new thread
182 * is not suspended; its initial execution state is given
183 * by flavor and new_state. Returns the port representing
184 * the new thread.
185 */
186 routine thread_create_running(
187 parent_task : task_t;
188 flavor : thread_state_flavor_t;
189 new_state : thread_state_t;
190 out child_act : thread_act_t);
191
192 /*
193 * Set an exception handler for a task on one or more exception types.
194 * These handlers are invoked for all threads in the task if there are
195 * no thread-specific exception handlers or those handlers returned an
196 * error.
197 */
198 routine task_set_exception_ports(
199 task : task_t;
200 exception_mask : exception_mask_t;
201 new_port : mach_port_t;
202 behavior : exception_behavior_t;
203 new_flavor : thread_state_flavor_t);
204
205
206 /*
207 * Lookup some of the old exception handlers for a task
208 */
209 routine task_get_exception_ports(
210 task : task_t;
211 exception_mask : exception_mask_t;
212 out masks : exception_mask_array_t;
213 out old_handlers : exception_handler_array_t, SameCount;
214 out old_behaviors : exception_behavior_array_t, SameCount;
215 out old_flavors : exception_flavor_array_t, SameCount);
216
217
218 /*
219 * Set an exception handler for a thread on one or more exception types.
220 * At the same time, return the previously defined exception handlers for
221 * those types.
222 */
223 routine task_swap_exception_ports(
224 task : task_t;
225 exception_mask : exception_mask_t;
226 new_port : mach_port_t;
227 behavior : exception_behavior_t;
228 new_flavor : thread_state_flavor_t;
229 out masks : exception_mask_array_t;
230 out old_handlerss : exception_handler_array_t, SameCount;
231 out old_behaviors : exception_behavior_array_t, SameCount;
232 out old_flavors : exception_flavor_array_t, SameCount);
233
234 /*
235 * Create and destroy lock_set and semaphore synchronizers on a
236 * per-task basis (i.e. the task owns them).
237 */
238 routine lock_set_create(
239 task : task_t;
240 out new_lock_set : lock_set_t;
241 n_ulocks : int;
242 policy : int);
243
244 routine lock_set_destroy(
245 task : task_t;
246 lock_set : lock_set_t);
247
248 routine semaphore_create(
249 task : task_t;
250 out semaphore : semaphore_t;
251 policy : int;
252 value : int);
253
254 routine semaphore_destroy(
255 task : task_t;
256 semaphore : semaphore_consume_ref_t);
257
258 /*
259 * Set/get policy information for a task.
260 * (Approved Mac OS X microkernel interface)
261 */
262
263 routine task_policy_set(
264 task : task_t;
265 flavor : task_policy_flavor_t;
266 policy_info : task_policy_t);
267
268 routine task_policy_get(
269 task : task_t;
270 flavor : task_policy_flavor_t;
271 out policy_info : task_policy_t, CountInOut;
272 inout get_default : boolean_t);
273
274 /*
275 * Task profiling.
276 */
277 routine task_sample(
278 task : task_t;
279 reply : mach_port_make_send_t);
280
281 /*
282 * JMM - Everything from here down is likely to go away soon
283 */
284 /*
285 * OBSOLETE interface.
286 */
287 routine task_policy(
288 task : task_t;
289 policy : policy_t;
290 base : policy_base_t;
291 set_limit : boolean_t;
292 change : boolean_t);
293
294
295 /*
296 * Establish a user-level handler for the specified
297 * system call.
298 */
299 routine task_set_emulation(
300 target_port : task_t;
301 routine_entry_pt: vm_address_t;
302 routine_number : int);
303
304 /*
305 * Get user-level handler entry points for all
306 * emulated system calls.
307 */
308 routine task_get_emulation_vector(
309 task : task_t;
310 out vector_start : int;
311 out emulation_vector: emulation_vector_t);
312
313 /*
314 * Establish user-level handlers for the specified
315 * system calls. Non-emulated system calls are specified
316 * with emulation_vector[i] == EML_ROUTINE_NULL.
317 */
318 routine task_set_emulation_vector(
319 task : task_t;
320 vector_start : int;
321 emulation_vector: emulation_vector_t);
322
323
324 /*
325 * Establish restart pc for interrupted atomic sequences.
326 */
327 routine task_set_ras_pc(
328 target_task : task_t;
329 basepc : vm_address_t;
330 boundspc : vm_address_t);
331
332
333 skip; /* was kernel_task_create() */
334
335 /*
336 * JMM - Want to eliminate processor_set so keep them at the end.
337 */
338
339 /*
340 * Assign task to processor set.
341 */
342 routine task_assign(
343 task : task_t;
344 new_set : processor_set_t;
345 assign_threads : boolean_t);
346
347 /*
348 * Assign task to default set.
349 */
350 routine task_assign_default(
351 task : task_t;
352 assign_threads : boolean_t);
353
354 /*
355 * Get current assignment for task.
356 */
357 routine task_get_assignment(
358 task : task_t;
359 out assigned_set : processor_set_name_t);
360
361 /*
362 * OBSOLETE interface.
363 */
364 routine task_set_policy(
365 task : task_t;
366 pset : processor_set_t;
367 policy : policy_t;
368 base : policy_base_t;
369 limit : policy_limit_t;
370 change : boolean_t);
371