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