/* * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. The rights granted to you under the License * may not be used to create, or enable the creation or redistribution of, * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* * @OSF_FREE_COPYRIGHT@ */ /* * Mach Operating System * Copyright (c) 1991,1990,1989 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ /* */ /* * File: mach/mach_vm.defs * * Exported kernel VM calls (for any task on the platform). */ subsystem #if KERNEL_SERVER KernelServer #endif /* KERNEL_SERVER */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) mach_vm #else vm_map_lp64_local #endif 4800; #include #include #include /* * Allocate zero-filled memory in the address space * of the target task, either at the specified address, * or wherever space can be found (controlled by flags), * of the specified size. The address at which the * allocation actually took place is returned. */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_allocate( #else routine vm_allocate( #endif target : vm_task_entry_t; inout address : mach_vm_address_t; size : mach_vm_size_t; flags : int); /* * Deallocate the specified range from the virtual * address space of the target virtual memory map. */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_deallocate( #else routine vm_deallocate( #endif target : vm_task_entry_t; address : mach_vm_address_t; size : mach_vm_size_t); /* * Set the current or maximum protection attribute * for the specified range of the virtual address * space of the target virtual memory map. The current * protection limits the memory access rights of threads * within the map; the maximum protection limits the accesses * that may be given in the current protection. * Protections are specified as a set of {read, write, execute} * *permissions*. */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_protect( #else routine vm_protect( #endif target_task : vm_task_entry_t; address : mach_vm_address_t; size : mach_vm_size_t; set_maximum : boolean_t; new_protection : vm_prot_t); /* * Set the inheritance attribute for the specified range * of the virtual address space of the target address space. * The inheritance value is one of {none, copy, share}, and * specifies how the child address space should acquire * this memory at the time of a task_create call. */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_inherit( #else routine vm_inherit( #endif target_task : vm_task_entry_t; address : mach_vm_address_t; size : mach_vm_size_t; new_inheritance : vm_inherit_t); /* * Returns the contents of the specified range of the * virtual address space of the target task. [The * range must be aligned on a virtual page boundary, * and must be a multiple of pages in extent. The * protection on the specified range must permit reading.] */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_read( #else routine vm_read( #endif target_task : vm_map_t; address : mach_vm_address_t; size : mach_vm_size_t; out data : pointer_t); /* * List corrollary to vm_read, returns mapped contents of specified * ranges within target address space. */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_read_list( #else routine vm_read_list( #endif target_task : vm_map_t; inout data_list : mach_vm_read_entry_t; count : natural_t); /* * Writes the contents of the specified range of the * virtual address space of the target task. [The * range must be aligned on a virtual page boundary, * and must be a multiple of pages in extent. The * protection on the specified range must permit writing.] */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_write( #else routine vm_write( #endif target_task : vm_map_t; address : mach_vm_address_t; data : pointer_t); /* * Copy the contents of the source range of the virtual * address space of the target task to the destination * range in that same address space. [Both of the * ranges must be aligned on a virtual page boundary, * and must be multiples of pages in extent. The * protection on the source range must permit reading, * and the protection on the destination range must * permit writing.] */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_copy( #else routine vm_copy( #endif target_task : vm_map_t; source_address : mach_vm_address_t; size : mach_vm_size_t; dest_address : mach_vm_address_t); /* * Returns the contents of the specified range of the * virtual address space of the target task. [There * are no alignment restrictions, and the results will * overwrite the area pointed to by data - which must * already exist. The protection on the specified range * must permit reading.] */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_read_overwrite( #else routine vm_read_overwrite( #endif target_task : vm_map_t; address : mach_vm_address_t; size : mach_vm_size_t; data : mach_vm_address_t; out outsize : mach_vm_size_t); #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_msync( #else routine vm_msync( #endif target_task : vm_map_t; address : mach_vm_address_t; size : mach_vm_size_t; sync_flags : vm_sync_t ); /* * Set the paging behavior attribute for the specified range * of the virtual address space of the target task. * The behavior value is one of {default, random, forward * sequential, reverse sequential} and indicates the expected * page reference pattern for the specified range. */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_behavior_set( #else routine vm_behavior_set( #endif target_task : vm_map_t; address : mach_vm_address_t; size : mach_vm_size_t; new_behavior : vm_behavior_t); /* * Map a user-supplie memory object into the virtual address * space of the target task. If desired (anywhere is TRUE), * the kernel will find a suitable address range of the * specified size; else, the specific address will be allocated. * * The beginning address of the range will be aligned on a virtual * page boundary, be at or beyond the address specified, and * meet the mask requirements (bits turned on in the mask must not * be turned on in the result); the size of the range, in bytes, * will be rounded up to an integral number of virtual pages. * * The memory in the resulting range will be associated with the * specified memory object, with the beginning of the memory range * referring to the specified offset into the memory object. * * The mapping will take the current and maximum protections and * the inheritance attributes specified; see the vm_protect and * vm_inherit calls for a description of these attributes. * * If desired (copy is TRUE), the memory range will be filled * with a copy of the data from the memory object; this copy will * be private to this mapping in this target task. Otherwise, * the memory in this mapping will be shared with other mappings * of the same memory object at the same offset (in this task or * in other tasks). [The Mach kernel only enforces shared memory * consistency among mappings on one host with similar page alignments. * The user-defined memory manager for this object is responsible * for further consistency.] */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_map( #else routine vm_map( #endif target_task : vm_task_entry_t; inout address : mach_vm_address_t; size : mach_vm_size_t; mask : mach_vm_offset_t; flags : int; object : mem_entry_name_port_t; offset : memory_object_offset_t; copy : boolean_t; cur_protection : vm_prot_t; max_protection : vm_prot_t; inheritance : vm_inherit_t); /* * Set/Get special properties of memory associated * to some virtual address range, such as cachability, * migrability, replicability. Machine-dependent. */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_machine_attribute( #else routine vm_machine_attribute( #endif target_task : vm_map_t; address : mach_vm_address_t; size : mach_vm_size_t; attribute : vm_machine_attribute_t; inout value : vm_machine_attribute_val_t); /* * Map portion of a task's address space. */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_remap( #else routine vm_remap( #endif target_task : vm_map_t; inout target_address : mach_vm_address_t; size : mach_vm_size_t; mask : mach_vm_offset_t; anywhere : boolean_t; src_task : vm_map_t; src_address : mach_vm_address_t; copy : boolean_t; out cur_protection : vm_prot_t; out max_protection : vm_prot_t; inheritance : vm_inherit_t); /* * Give the caller information on the given location in a virtual * address space. If a page is mapped return ref and dirty info. */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_page_query( #else routine vm_map_page_query( #endif target_map :vm_map_t; offset :mach_vm_offset_t; out disposition :integer_t; out ref_count :integer_t); #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_region_recurse( #else routine vm_region_recurse_64( #endif target_task : vm_map_t; inout address : mach_vm_address_t; out size : mach_vm_size_t; inout nesting_depth : natural_t; out info : vm_region_recurse_info_t,CountInOut); /* * Returns information about the contents of the virtual * address space of the target task at the specified * address. The returned protection, inheritance, sharing * and memory object values apply to the entire range described * by the address range returned; the memory object offset * corresponds to the beginning of the address range. * [If the specified address is not allocated, the next * highest address range is described. If no addresses beyond * the one specified are allocated, the call returns KERN_NO_SPACE.] */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_region( #else routine vm_region_64( #endif target_task : vm_map_t; inout address : mach_vm_address_t; out size : mach_vm_size_t; flavor : vm_region_flavor_t; out info : vm_region_info_t, CountInOut; out object_name : memory_object_name_t = MACH_MSG_TYPE_MOVE_SEND ctype: mach_port_t); /* * Allow application level processes to create named entries which * correspond to mapped portions of their address space. These named * entries can then be manipulated, shared with other processes in * other address spaces and ultimately mapped in ohter address spaces * * THIS INTERFACE IS STILL EVOLVING. */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) #if !defined(__LP64__) routine _mach_make_memory_entry( #else routine mach_make_memory_entry( #endif #else routine mach_make_memory_entry_64( #endif target_task :vm_map_t; inout size :memory_object_size_t; offset :memory_object_offset_t; permission :vm_prot_t; out object_handle :mem_entry_name_port_move_send_t; parent_handle :mem_entry_name_port_t); /* * Control behavior and investigate state of a "purgable" object in * the virtual address space of the target task. A purgable object is * created via a call to mach_vm_allocate() with VM_FLAGS_PURGABLE * specified. See the routine implementation for a complete * definition of the routine. */ #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) routine mach_vm_purgable_control( #else routine vm_purgable_control( #endif target_task : vm_map_t; address : mach_vm_address_t; control : vm_purgable_t; inout state : int); /****************************** Legacy section ***************************/ /* The following definitions are exist to provide compatibility with */ /* the legacy APIs. They are no different. We just need to produce */ /* the user-level stub interface for them. */ /****************************** Legacy section ***************************/ /* * These interfaces just aren't supported in the new (wide) model: * * mach_vm_region_info() - * vm_map_pages_info() - * no user-level replacement for these MACH_DEBUG interfaces * vm_map_get_upl() - * no user-level replacement at the moment * vm_region_info() - * use mach_vm_region_info() or vm_region_info_64() * vm_region_recurse() - * use mach_vm_region_recurse() or vm_region_recurse_64() */ /* * The following legacy interfaces are provides as macro wrappers to the new * interfaces. You should strive to use the new ones instead: * * vm_map() - * use mach_vm_map() or vm_map_64() * vm_region() - * use mach_vm_region() or vm_region_64() * mach_make_memory_entry() - * use mach_vm_make_memory_entry() or mach_make_memory_entry_64() */ /* vim: set ft=c : */