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