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