1/* 2 * Copyright (c) 2000-2004 Apple Computer, 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/vm_map.defs 60 * 61 * Exported (native-sized) kernel VM calls. 62 */ 63 64subsystem 65#if KERNEL_SERVER || KOBJECT_SERVER 66 KernelServer 67#endif /* KERNEL_SERVER || KOBJECT_SERVER */ 68 vm_map 3800; 69 70#include <mach/std_types.defs> 71#include <mach/mach_types.defs> 72#include <mach_debug/mach_debug_types.defs> 73 74#define CONCAT(a,b) a ## b 75#if !KERNEL && !LIBSYSCALL_INTERFACE 76#define PREFIX(NAME) CONCAT(_kernelrpc_, NAME) 77#else 78#define PREFIX(NAME) NAME 79#endif 80 81#if KERNEL_SERVER 82#define KERNEL_SERVER_SUFFIX(NAME) CONCAT(NAME, _external) 83#else 84#define KERNEL_SERVER_SUFFIX(NAME) NAME 85#endif 86 87/* If building for Sandbox, keep NAME unchanged */ 88#if SANDBOX_COMPILER 89#define KERNEL_SERVER_SUFFIX_SANDBOX(NAME) NAME 90#else 91#define KERNEL_SERVER_SUFFIX_SANDBOX(NAME) KERNEL_SERVER_SUFFIX(NAME) 92#endif 93 94/* 95 * Returns information about the contents of the virtual 96 * address space of the target task at the specified 97 * address. The returned protection, inheritance, sharing 98 * and memory object values apply to the entire range described 99 * by the address range returned; the memory object offset 100 * corresponds to the beginning of the address range. 101 * [If the specified address is not allocated, the next 102 * highest address range is described. If no addresses beyond 103 * the one specified are allocated, the call returns KERN_NO_SPACE.] 104 */ 105routine vm_region( 106 target_task : vm_map_read_t; 107 inout address : vm_address_t; 108 out size : vm_size_t; 109 flavor : vm_region_flavor_t; 110 out info : vm_region_info_t, CountInOut; 111 out object_name : memory_object_name_t = 112 MACH_MSG_TYPE_MOVE_SEND 113 ctype: mach_port_t); 114 115/* 116 * Allocate zero-filled memory in the address space 117 * of the target task, either at the specified address, 118 * or wherever space can be found (if anywhere is TRUE), 119 * of the specified size. The address at which the 120 * allocation actually took place is returned. 121 */ 122 123#if !KERNEL && !LIBSYSCALL_INTERFACE 124skip; 125#else 126routine PREFIX(KERNEL_SERVER_SUFFIX(vm_allocate))( 127 target_task : vm_task_entry_t; 128 inout address : vm_address_t; 129 size : vm_size_t; 130 flags : int); 131 132#endif 133 134/* 135 * Deallocate the specified range from the virtual 136 * address space of the target task. 137 */ 138 139#if !KERNEL && !LIBSYSCALL_INTERFACE 140skip; 141#else 142routine PREFIX(vm_deallocate)( 143 target_task : vm_task_entry_t; 144 address : vm_address_t; 145 size : vm_size_t); 146 147#endif 148 149/* 150 * Set the current or maximum protection attribute 151 * for the specified range of the virtual address 152 * space of the target task. The current protection 153 * limits the memory access rights of threads within 154 * the task; the maximum protection limits the accesses 155 * that may be given in the current protection. 156 * Protections are specified as a set of {read, write, execute} 157 * *permissions*. 158 */ 159 160#if !KERNEL && !LIBSYSCALL_INTERFACE 161skip; 162#else 163routine PREFIX(vm_protect)( 164 target_task : vm_task_entry_t; 165 address : vm_address_t; 166 size : vm_size_t; 167 set_maximum : boolean_t; 168 new_protection : vm_prot_t); 169#endif 170 171/* 172 * Set the inheritance attribute for the specified range 173 * of the virtual address space of the target task. 174 * The inheritance value is one of {none, copy, share}, and 175 * specifies how the child address space should acquire 176 * this memory at the time of a task_create call. 177 */ 178routine vm_inherit( 179 target_task : vm_task_entry_t; 180 address : vm_address_t; 181 size : vm_size_t; 182 new_inheritance : vm_inherit_t); 183 184/* 185 * Returns the contents of the specified range of the 186 * virtual address space of the target task. [The 187 * range must be aligned on a virtual page boundary, 188 * and must be a multiple of pages in extent. The 189 * protection on the specified range must permit reading.] 190 */ 191routine PREFIX(vm_read) ( 192 target_task : vm_map_read_t; 193 address : vm_address_t; 194 size : vm_size_t; 195 out data : pointer_t); 196 197/* 198 * List corrollary to vm_read, returns mapped contents of specified 199 * ranges within target address space. 200 */ 201routine vm_read_list( 202 target_task : vm_map_read_t; 203 inout data_list : vm_read_entry_t; 204 count : natural_t); 205 206/* 207 * Writes the contents of the specified range of the 208 * virtual address space of the target task. [The 209 * range must be aligned on a virtual page boundary, 210 * and must be a multiple of pages in extent. The 211 * protection on the specified range must permit writing.] 212 */ 213routine vm_write( 214 target_task : vm_map_t; 215 address : vm_address_t; 216 data : pointer_t); 217 218/* 219 * Copy the contents of the source range of the virtual 220 * address space of the target task to the destination 221 * range in that same address space. [Both of the 222 * ranges must be aligned on a virtual page boundary, 223 * and must be multiples of pages in extent. The 224 * protection on the source range must permit reading, 225 * and the protection on the destination range must 226 * permit writing.] 227 */ 228routine vm_copy( 229 target_task : vm_map_t; 230 source_address : vm_address_t; 231 size : vm_size_t; 232 dest_address : vm_address_t); 233 234/* 235 * Returns the contents of the specified range of the 236 * virtual address space of the target task. [There 237 * are no alignment restrictions, and the results will 238 * overwrite the area pointed to by data - which must 239 * already exist. The protection on the specified range 240 * must permit reading.] 241 */ 242routine vm_read_overwrite( 243 target_task : vm_map_read_t; 244 address : vm_address_t; 245 size : vm_size_t; 246 data : vm_address_t; 247 out outsize : vm_size_t); 248 249 250routine vm_msync( 251 target_task : vm_map_t; 252 address : vm_address_t; 253 size : vm_size_t; 254 sync_flags : vm_sync_t ); 255 256/* 257 * Set the paging behavior attribute for the specified range 258 * of the virtual address space of the target task. 259 * The behavior value is one of {default, random, forward 260 * sequential, reverse sequential} and indicates the expected 261 * page reference pattern for the specified range. 262 */ 263routine vm_behavior_set( 264 target_task : vm_map_t; 265 address : vm_address_t; 266 size : vm_size_t; 267 new_behavior : vm_behavior_t); 268 269 270/* 271 * Map a user-defined memory object into the virtual address 272 * space of the target task. If desired (anywhere is TRUE), 273 * the kernel will find a suitable address range of the 274 * specified size; else, the specific address will be allocated. 275 * 276 * The beginning address of the range will be aligned on a virtual 277 * page boundary, be at or beyond the address specified, and 278 * meet the mask requirements (bits turned on in the mask must not 279 * be turned on in the result); the size of the range, in bytes, 280 * will be rounded up to an integral number of virtual pages. 281 * 282 * The memory in the resulting range will be associated with the 283 * specified memory object, with the beginning of the memory range 284 * referring to the specified offset into the memory object. 285 * 286 * The mapping will take the current and maximum protections and 287 * the inheritance attributes specified; see the vm_protect and 288 * vm_inherit calls for a description of these attributes. 289 * 290 * If desired (copy is TRUE), the memory range will be filled 291 * with a copy of the data from the memory object; this copy will 292 * be private to this mapping in this target task. Otherwise, 293 * the memory in this mapping will be shared with other mappings 294 * of the same memory object at the same offset (in this task or 295 * in other tasks). [The Mach kernel only enforces shared memory 296 * consistency among mappings on one host with similar page alignments. 297 * The user-defined memory manager for this object is responsible 298 * for further consistency.] 299 */ 300routine PREFIX(KERNEL_SERVER_SUFFIX(vm_map)) ( 301 target_task : vm_task_entry_t; 302 inout address : vm_address_t; 303 size : vm_size_t; 304 mask : vm_address_t; 305 flags : int; 306 object : mem_entry_name_port_t; 307 offset : vm_offset_t; 308 copy : boolean_t; 309 cur_protection : vm_prot_t; 310 max_protection : vm_prot_t; 311 inheritance : vm_inherit_t); 312 313/* 314 * Set/Get special properties of memory associated 315 * to some virtual address range, such as cachability, 316 * migrability, replicability. Machine-dependent. 317 */ 318routine vm_machine_attribute( 319 target_task : vm_map_t; 320 address : vm_address_t; 321 size : vm_size_t; 322 attribute : vm_machine_attribute_t; 323 inout value : vm_machine_attribute_val_t); 324 325/* 326 * Map portion of a task's address space. 327 */ 328routine PREFIX(KERNEL_SERVER_SUFFIX(vm_remap)) ( 329 target_task : vm_map_t; 330 inout target_address : vm_address_t; 331 size : vm_size_t; 332 mask : vm_address_t; 333 flags : int; 334 src_task : vm_map_t; 335 src_address : vm_address_t; 336 copy : boolean_t; 337 out cur_protection : vm_prot_t; 338 out max_protection : vm_prot_t; 339 inheritance : vm_inherit_t); 340 341/* 342 * Require that all future virtual memory allocation 343 * allocates wired memory. Setting must_wire to FALSE 344 * disables the wired future feature. 345 */ 346routine task_wire( 347 target_task : vm_map_t; 348 must_wire : boolean_t); 349 350 351/* 352 * Allow application level processes to create named entries which 353 * correspond to mapped portions of their address space. These named 354 * entries can then be manipulated, shared with other processes in 355 * other address spaces and ultimately mapped in ohter address spaces 356 */ 357 358routine mach_make_memory_entry( 359 target_task :vm_map_t; 360 inout size :vm_size_t; 361 offset :vm_offset_t; 362 permission :vm_prot_t; 363 out object_handle :mem_entry_name_port_move_send_t; 364 parent_entry :mem_entry_name_port_t); 365 366/* 367 * Give the caller information on the given location in a virtual 368 * address space. If a page is mapped return ref and dirty info. 369 */ 370routine vm_map_page_query( 371 target_map :vm_map_read_t; 372 offset :vm_offset_t; 373 out disposition :integer_t; 374 out ref_count :integer_t); 375 376/* 377 * Returns information about a region of memory. 378 * Includes info about the chain of objects rooted at that region. 379 * Only available in MACH_VM_DEBUG compiled kernels, 380 * otherwise returns KERN_FAILURE. 381 */ 382routine mach_vm_region_info( 383 task : vm_map_read_t; 384 address : vm_address_t; 385 out region : vm_info_region_t; 386 out objects : vm_info_object_array_t); 387 388routine vm_mapped_pages_info( /* OBSOLETE */ 389 task : vm_map_read_t; 390 out pages : page_address_array_t); 391 392skip; /* was vm_region_object_create */ 393 394/* 395 * A recursive form of vm_region which probes submaps withint the 396 * address space. 397 */ 398routine vm_region_recurse( 399 target_task : vm_map_read_t; 400 inout address : vm_address_t; 401 out size : vm_size_t; 402 inout nesting_depth : natural_t; 403 out info : vm_region_recurse_info_t,CountInOut); 404 405 406/* 407 * The routines below are temporary, meant for transitional use 408 * as their counterparts are moved from 32 to 64 bit data path 409 */ 410 411 412routine vm_region_recurse_64( 413 target_task : vm_map_read_t; 414 inout address : vm_address_t; 415 out size : vm_size_t; 416 inout nesting_depth : natural_t; 417 out info : vm_region_recurse_info_t,CountInOut); 418 419routine mach_vm_region_info_64( /* OBSOLETE */ 420 task : vm_map_read_t; 421 address : vm_address_t; 422 out region : vm_info_region_64_t; 423 out objects : vm_info_object_array_t); 424 425routine vm_region_64( 426 target_task : vm_map_read_t; 427 inout address : vm_address_t; 428 out size : vm_size_t; 429 flavor : vm_region_flavor_t; 430 out info : vm_region_info_t, CountInOut; 431 out object_name : memory_object_name_t = 432 MACH_MSG_TYPE_MOVE_SEND 433 ctype: mach_port_t); 434 435routine mach_make_memory_entry_64( 436 target_task :vm_map_t; 437 inout size :memory_object_size_t; 438 offset :memory_object_offset_t; 439 permission :vm_prot_t; 440 out object_handle :mach_port_move_send_t; 441 parent_entry :mem_entry_name_port_t); 442 443 444 445routine KERNEL_SERVER_SUFFIX(vm_map_64)( 446 target_task : vm_task_entry_t; 447 inout address : vm_address_t; 448 size : vm_size_t; 449 mask : vm_address_t; 450 flags : int; 451 object : mem_entry_name_port_t; 452 offset : memory_object_offset_t; 453 copy : boolean_t; 454 cur_protection : vm_prot_t; 455 max_protection : vm_prot_t; 456 inheritance : vm_inherit_t); 457 458skip; /* was vm_map_get_upl */ 459skip; /* was vm_upl_map */ 460skip; /* was vm_upl_unmap */ 461 462/* 463 * Control behavior and investigate state of a "purgable" object in 464 * the virtual address space of the target task. A purgable object is 465 * created via a call to vm_allocate() with VM_FLAGS_PURGABLE 466 * specified. See the routine implementation for a complete 467 * definition of the routine. 468 */ 469routine PREFIX(KERNEL_SERVER_SUFFIX_SANDBOX(vm_purgable_control)) ( 470#if KERNEL_SERVER 471 target_tport: mach_port_t; 472#else 473 target_task : vm_map_t; 474#endif 475 address : vm_address_t; 476 control : vm_purgable_t; 477 inout state : int); 478 479 480routine vm_map_exec_lockdown( 481 target_task : vm_map_t); 482 483routine PREFIX(KERNEL_SERVER_SUFFIX(vm_remap_new)) ( 484 target_task : vm_map_t; 485inout target_address : vm_address_t; 486 size : vm_size_t; 487 mask : vm_address_t; 488 flags : int; 489#ifdef KERNEL_SERVER 490 src_tport : mach_port_t; 491#else 492 src_task : vm_map_read_t; 493#endif 494 src_address : vm_address_t; 495 copy : boolean_t; 496inout cur_protection : vm_prot_t; 497inout max_protection : vm_prot_t; 498 inheritance : vm_inherit_t); 499 500/* vim: set ft=c : */ 501