1 /* 2 * Copyright (c) 2000-2019 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_COPYRIGHT@ 30 */ 31 /* 32 * Mach Operating System 33 * Copyright (c) 1991,1990,1989,1988,1987 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 * Definitions of general Mach system traps. 60 * 61 * These are the definitions as seen from user-space. 62 * The kernel definitions are in <mach/syscall_sw.h>. 63 * Kernel RPC functions are defined in <mach/mach_interface.h>. 64 */ 65 66 #ifndef _MACH_MACH_TRAPS_H_ 67 #define _MACH_MACH_TRAPS_H_ 68 69 #include <stdint.h> 70 71 #include <mach/std_types.h> 72 #include <mach/mach_types.h> 73 #include <mach/kern_return.h> 74 #include <mach/port.h> 75 #include <mach/vm_types.h> 76 #include <mach/clock_types.h> 77 78 #include <machine/endian.h> 79 80 #include <sys/cdefs.h> 81 82 __BEGIN_DECLS 83 84 85 86 extern kern_return_t clock_sleep_trap( 87 mach_port_name_t clock_name, 88 sleep_type_t sleep_type, 89 int sleep_sec, 90 int sleep_nsec, 91 mach_timespec_t *wakeup_time); 92 93 extern kern_return_t _kernelrpc_mach_vm_allocate_trap( 94 mach_port_name_t target, 95 mach_vm_offset_t *addr, 96 mach_vm_size_t size, 97 int flags); 98 99 extern kern_return_t _kernelrpc_mach_vm_deallocate_trap( 100 mach_port_name_t target, 101 mach_vm_address_t address, 102 mach_vm_size_t size 103 ); 104 105 extern kern_return_t _kernelrpc_mach_vm_protect_trap( 106 mach_port_name_t target, 107 mach_vm_address_t address, 108 mach_vm_size_t size, 109 boolean_t set_maximum, 110 vm_prot_t new_protection 111 ); 112 113 extern kern_return_t _kernelrpc_mach_vm_map_trap( 114 mach_port_name_t target, 115 mach_vm_offset_t *address, 116 mach_vm_size_t size, 117 mach_vm_offset_t mask, 118 int flags, 119 vm_prot_t cur_protection 120 ); 121 122 extern kern_return_t _kernelrpc_mach_vm_purgable_control_trap( 123 mach_port_name_t target, 124 mach_vm_offset_t address, 125 vm_purgable_t control, 126 int *state); 127 128 extern kern_return_t _kernelrpc_mach_port_allocate_trap( 129 mach_port_name_t target, 130 mach_port_right_t right, 131 mach_port_name_t *name 132 ); 133 134 135 extern kern_return_t _kernelrpc_mach_port_destroy_trap( 136 mach_port_name_t target, 137 mach_port_name_t name 138 ); 139 140 extern kern_return_t _kernelrpc_mach_port_deallocate_trap( 141 mach_port_name_t target, 142 mach_port_name_t name 143 ); 144 145 extern kern_return_t _kernelrpc_mach_port_mod_refs_trap( 146 mach_port_name_t target, 147 mach_port_name_t name, 148 mach_port_right_t right, 149 mach_port_delta_t delta 150 ); 151 152 extern kern_return_t _kernelrpc_mach_port_move_member_trap( 153 mach_port_name_t target, 154 mach_port_name_t member, 155 mach_port_name_t after 156 ); 157 158 extern kern_return_t _kernelrpc_mach_port_insert_right_trap( 159 mach_port_name_t target, 160 mach_port_name_t name, 161 mach_port_name_t poly, 162 mach_msg_type_name_t polyPoly 163 ); 164 165 extern kern_return_t _kernelrpc_mach_port_get_attributes_trap( 166 mach_port_name_t target, 167 mach_port_name_t name, 168 mach_port_flavor_t flavor, 169 mach_port_info_t port_info_out, 170 mach_msg_type_number_t *port_info_outCnt 171 ); 172 173 extern kern_return_t _kernelrpc_mach_port_insert_member_trap( 174 mach_port_name_t target, 175 mach_port_name_t name, 176 mach_port_name_t pset 177 ); 178 179 extern kern_return_t _kernelrpc_mach_port_extract_member_trap( 180 mach_port_name_t target, 181 mach_port_name_t name, 182 mach_port_name_t pset 183 ); 184 185 extern kern_return_t _kernelrpc_mach_port_construct_trap( 186 mach_port_name_t target, 187 mach_port_options_t *options, 188 uint64_t context, 189 mach_port_name_t *name 190 ); 191 192 extern kern_return_t _kernelrpc_mach_port_destruct_trap( 193 mach_port_name_t target, 194 mach_port_name_t name, 195 mach_port_delta_t srdelta, 196 uint64_t guard 197 ); 198 199 extern kern_return_t _kernelrpc_mach_port_guard_trap( 200 mach_port_name_t target, 201 mach_port_name_t name, 202 uint64_t guard, 203 boolean_t strict 204 ); 205 206 extern kern_return_t _kernelrpc_mach_port_unguard_trap( 207 mach_port_name_t target, 208 mach_port_name_t name, 209 uint64_t guard 210 ); 211 212 extern kern_return_t mach_generate_activity_id( 213 mach_port_name_t target, 214 int count, 215 uint64_t *activity_id 216 ); 217 218 extern kern_return_t macx_swapon( 219 uint64_t filename, 220 int flags, 221 int size, 222 int priority); 223 224 extern kern_return_t macx_swapoff( 225 uint64_t filename, 226 int flags); 227 228 extern kern_return_t macx_triggers( 229 int hi_water, 230 int low_water, 231 int flags, 232 mach_port_t alert_port); 233 234 extern kern_return_t macx_backing_store_suspend( 235 boolean_t suspend); 236 237 extern kern_return_t macx_backing_store_recovery( 238 int pid); 239 240 extern boolean_t swtch_pri(int pri); 241 242 extern boolean_t swtch(void); 243 244 extern kern_return_t thread_switch( 245 mach_port_name_t thread_name, 246 int option, 247 mach_msg_timeout_t option_time); 248 249 extern mach_port_name_t task_self_trap(void); 250 251 extern kern_return_t host_create_mach_voucher_trap( 252 mach_port_name_t host, 253 mach_voucher_attr_raw_recipe_array_t recipes, 254 int recipes_size, 255 mach_port_name_t *voucher); 256 257 extern kern_return_t mach_voucher_extract_attr_recipe_trap( 258 mach_port_name_t voucher_name, 259 mach_voucher_attr_key_t key, 260 mach_voucher_attr_raw_recipe_t recipe, 261 mach_msg_type_number_t *recipe_size); 262 263 extern kern_return_t _kernelrpc_mach_port_type_trap( 264 ipc_space_t task, 265 mach_port_name_t name, 266 mach_port_type_t *ptype); 267 268 extern kern_return_t _kernelrpc_mach_port_request_notification_trap( 269 ipc_space_t task, 270 mach_port_name_t name, 271 mach_msg_id_t msgid, 272 mach_port_mscount_t sync, 273 mach_port_name_t notify, 274 mach_msg_type_name_t notifyPoly, 275 mach_port_name_t *previous); 276 277 /* 278 * Obsolete interfaces. 279 */ 280 281 extern kern_return_t task_for_pid( 282 mach_port_name_t target_tport, 283 int pid, 284 mach_port_name_t *t); 285 286 extern kern_return_t task_name_for_pid( 287 mach_port_name_t target_tport, 288 int pid, 289 mach_port_name_t *tn); 290 291 extern kern_return_t pid_for_task( 292 mach_port_name_t t, 293 int *x); 294 295 extern kern_return_t debug_control_port_for_pid( 296 mach_port_name_t target_tport, 297 int pid, 298 mach_port_name_t *t); 299 300 301 __END_DECLS 302 303 #endif /* _MACH_MACH_TRAPS_H_ */