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  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
65subsystem
66#if	KERNEL_SERVER
67	  KernelServer
68#endif	/* KERNEL_SERVER */
69	  thread_act 3600;
70
71#include <mach/std_types.defs>
72#include <mach/mach_types.defs>
73
74/*
75 *	Destroy the target thread.
76 *
77 *	JMM - For legacy reasons this consumes a reference to the
78 *	target thread.  This will have to change in the future because
79 *	we want the interfaces to be able to be defined in more standard
80 *	IDLs and transports, and most of them do not support the notion
81 *	of reference ownership transfers (just sharing).
82 */
83routine thread_terminate(
84		target_act	: thread_act_consume_ref_t); 
85
86
87/*
88 *	Return the selected state information for the target
89 *	thr_act.  If the thr_act is currently executing, the results
90 *	may be stale.  [Flavor THREAD_STATE_FLAVOR_LIST provides a
91 *	list of valid flavors for the target thread.]
92 */
93routine act_get_state(
94		target_act	: thread_act_t;
95		flavor		: int;
96	out	old_state	: thread_state_t, CountInOut);
97
98/*
99 *	Set the selected state information for the target thread.
100 *	If the thread is currently executing, the state change
101 *	may be ill-defined.
102 */
103routine	act_set_state(
104		target_act	: thread_act_t;
105		flavor		: int;
106		new_state	: thread_state_t);
107
108/*
109 * Backward compatible old-style thread routines.
110 * These have different semantics than the new activation versions.
111 *
112 *	Return the selected state information for the target
113 *	thread.  If the thread is currently executing, the results
114 *	may be stale.  [Flavor THREAD_STATE_FLAVOR_LIST provides a
115 *	list of valid flavors for the target thr_act.]
116 */
117routine thread_get_state(
118		target_act	: thread_act_t;
119		flavor		: thread_state_flavor_t;
120	out	old_state	: thread_state_t, CountInOut);
121
122/*
123 *	Set the selected state information for the target thread.
124 *	If the thread is currently executing, the state change
125 *	may be ill-defined.
126 */
127routine	thread_set_state(
128		target_act	: thread_act_t;
129		flavor		: thread_state_flavor_t;
130		new_state	: thread_state_t);
131
132/*
133 *	Increment the suspend count for the target thread.
134 *	Once this call has completed, the thread will not
135 *	execute any further user or meta- instructions.
136 *	Once suspended, a thread may not execute again until
137 *	its suspend count is zero, and the suspend count
138 *	for its task is also zero.
139 */
140routine	thread_suspend(
141		target_act	: thread_act_t);
142
143/*
144 *	Decrement the suspend count for the target thread,
145 *	if that count is not already zero.
146 */
147routine	thread_resume(
148		target_act	: thread_act_t);
149
150/*
151 *	Cause any user or meta- instructions currently being
152 *	executed by the target thread to be aborted.  [Meta-
153 *	instructions consist of the basic traps for IPC
154 *	(e.g., msg_send, msg_receive) and self-identification
155 *	(e.g., task_self, thread_self, thread_reply).  Calls
156 *	described by MiG interfaces are not meta-instructions
157 *	themselves.]
158 */
159routine thread_abort(
160		target_act	: thread_act_t);
161
162/*
163 *	Cause any user or meta- instructions currently being
164 *	executed by the target thread to be aborted so that
165 *	they are transparently restartable.  This call fails
166 *	if the abort would result in a non-restartable condition.
167 *	Retry is the caller's responsibility.  [Meta-
168 *	instructions consist of the basic traps for IPC
169 *	(e.g., msg_send, msg_receive) and self-identification
170 *	(e.g., task_self, thread_self, thread_reply).  Calls
171 *	described by MiG interfaces are not meta-instructions
172 *	themselves.]
173 */
174routine thread_abort_safely(
175		target_act	: thread_act_t);
176
177
178routine thread_depress_abort(
179		thread		: thread_act_t);
180
181
182/*
183 *	Returns the current value of the selected special port
184 *	associated with the target thread.
185 */
186routine thread_get_special_port(
187		thr_act		: thread_act_t;
188		which_port	: int;
189	out	special_port	: mach_port_t);
190
191/*
192 *	Set one of the special ports associated with the
193 *	target thread.
194 */
195routine thread_set_special_port(
196		thr_act		: thread_act_t;
197		which_port	: int;
198		special_port	: mach_port_t);
199
200/*
201 *      Returns information about the target thread.
202 */
203routine thread_info(
204                target_act      : thread_act_t;
205                flavor          : thread_flavor_t;
206        out     thread_info_out : thread_info_t, CountInOut);
207
208/*
209 * Set an exception handler for a thread on one or more exception types
210 */
211routine		thread_set_exception_ports(
212			thread		: thread_act_t;
213			exception_mask	: exception_mask_t;
214			new_port	: mach_port_t;
215			behavior	: exception_behavior_t;
216			new_flavor	: thread_state_flavor_t);
217
218/*
219 * Lookup some of the old exception handlers for a thread
220 */
221routine		thread_get_exception_ports(
222			thread		: thread_act_t;
223			exception_mask	: exception_mask_t;
224		  out	masks		: exception_mask_array_t;
225		  out	old_handlers	: exception_handler_array_t, SameCount;
226		  out	old_behaviors	: exception_behavior_array_t, SameCount;
227		  out	old_flavors	: exception_flavor_array_t, SameCount);
228
229/*
230 * Set an exception handler for a thread on one or more exception types.
231 * At the same time, return the previously defined exception handlers for
232 * those types.
233 */
234routine		thread_swap_exception_ports(
235			thread		: thread_act_t;
236			exception_mask	: exception_mask_t;
237			new_port	: mach_port_t;
238			behavior	: exception_behavior_t;
239			new_flavor	: thread_state_flavor_t;
240		  out	masks		: exception_mask_array_t;
241		  out	old_handlers	: exception_handler_array_t, SameCount;
242		  out	old_behaviors	: exception_behavior_array_t, SameCount;
243		  out	old_flavors	: exception_flavor_array_t, SameCount);
244
245/*
246 * OBSOLETE interface.
247 */
248routine thread_policy(
249	thr_act			: thread_act_t;
250	policy			: policy_t;
251	base			: policy_base_t;
252	set_limit		: boolean_t);
253
254/*
255 * Set/get policy information for a thread.
256 * (Approved Mac OS X microkernel interface)
257 */
258
259routine thread_policy_set(
260	thread			: thread_act_t;
261	flavor			: thread_policy_flavor_t;
262	policy_info		: thread_policy_t);
263
264routine thread_policy_get(
265	thread			: thread_act_t;
266	flavor			: thread_policy_flavor_t;
267out	policy_info		: thread_policy_t, CountInOut;
268inout	get_default		: boolean_t);
269
270/*
271 *	Removed from the kernel.
272 */
273#if KERNEL_SERVER
274skip;
275#else
276routine thread_sample(
277		thread		: thread_act_t;
278		reply		: mach_port_make_send_t);
279#endif
280
281/*
282 *	ETAP has been removed from the kernel.
283 */
284#if KERNEL_SERVER
285skip;
286#else
287routine	etap_trace_thread(
288		target_act	: thread_act_t;
289		trace_status	: boolean_t);
290#endif
291
292/*
293 *	Assign thread to processor set.
294 */
295routine	thread_assign(
296		thread		: thread_act_t;
297		new_set		: processor_set_t);
298
299/*
300 *	Assign thread to default set.
301 */
302routine thread_assign_default(
303		thread		: thread_act_t);
304
305/*
306 *	Get current assignment for thread.
307 */
308routine thread_get_assignment(
309		thread		: thread_act_t;
310	out	assigned_set	: processor_set_name_t);
311
312
313/*
314 * OBSOLETE interface.
315 */
316routine thread_set_policy(
317	thr_act			: thread_act_t;
318	pset			: processor_set_t;
319	policy			: policy_t;
320	base			: policy_base_t;
321	limit			: policy_limit_t);
322
323/* vim: set ft=c : */
324