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