2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * @OSF_FREE_COPYRIGHT@
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
34 * All Rights Reserved.
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.
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.
46 * Carnegie Mellon requests users of this software to return to
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
59 * File: mach/mach_vm.defs
61 * Exported kernel VM calls (for any task on the platform).
67 #endif /* KERNEL_SERVER */
68 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
75 #include <mach/std_types.defs>
76 #include <mach/mach_types.defs>
77 #include <mach_debug/mach_debug_types.defs>
80 * Allocate zero-filled memory in the address space
81 * of the target task, either at the specified address,
82 * or wherever space can be found (controlled by flags),
83 * of the specified size. The address at which the
84 * allocation actually took place is returned.
86 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
87 routine mach_vm_allocate(
91 target : vm_task_entry_t;
92 inout address : mach_vm_address_t;
93 size : mach_vm_size_t;
97 * Deallocate the specified range from the virtual
98 * address space of the target virtual memory map.
100 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
101 routine mach_vm_deallocate(
103 routine vm_deallocate(
105 target : vm_task_entry_t;
106 address : mach_vm_address_t;
107 size : mach_vm_size_t);
110 * Set the current or maximum protection attribute
111 * for the specified range of the virtual address
112 * space of the target virtual memory map. The current
113 * protection limits the memory access rights of threads
114 * within the map; the maximum protection limits the accesses
115 * that may be given in the current protection.
116 * Protections are specified as a set of {read, write, execute}
119 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
120 routine mach_vm_protect(
124 target_task : vm_task_entry_t;
125 address : mach_vm_address_t;
126 size : mach_vm_size_t;
127 set_maximum : boolean_t;
128 new_protection : vm_prot_t);
131 * Set the inheritance attribute for the specified range
132 * of the virtual address space of the target address space.
133 * The inheritance value is one of {none, copy, share}, and
134 * specifies how the child address space should acquire
135 * this memory at the time of a task_create call.
137 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
138 routine mach_vm_inherit(
142 target_task : vm_task_entry_t;
143 address : mach_vm_address_t;
144 size : mach_vm_size_t;
145 new_inheritance : vm_inherit_t);
148 * Returns the contents of the specified range of the
149 * virtual address space of the target task. [The
150 * range must be aligned on a virtual page boundary,
151 * and must be a multiple of pages in extent. The
152 * protection on the specified range must permit reading.]
154 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
155 routine mach_vm_read(
159 target_task : vm_map_t;
160 address : mach_vm_address_t;
161 size : mach_vm_size_t;
162 out data : pointer_t);
165 * List corrollary to vm_read, returns mapped contents of specified
166 * ranges within target address space.
168 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
169 routine mach_vm_read_list(
171 routine vm_read_list(
173 target_task : vm_map_t;
174 inout data_list : mach_vm_read_entry_t;
178 * Writes the contents of the specified range of the
179 * virtual address space of the target task. [The
180 * range must be aligned on a virtual page boundary,
181 * and must be a multiple of pages in extent. The
182 * protection on the specified range must permit writing.]
184 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
185 routine mach_vm_write(
189 target_task : vm_map_t;
190 address : mach_vm_address_t;
194 * Copy the contents of the source range of the virtual
195 * address space of the target task to the destination
196 * range in that same address space. [Both of the
197 * ranges must be aligned on a virtual page boundary,
198 * and must be multiples of pages in extent. The
199 * protection on the source range must permit reading,
200 * and the protection on the destination range must
203 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
204 routine mach_vm_copy(
208 target_task : vm_map_t;
209 source_address : mach_vm_address_t;
210 size : mach_vm_size_t;
211 dest_address : mach_vm_address_t);
214 * Returns the contents of the specified range of the
215 * virtual address space of the target task. [There
216 * are no alignment restrictions, and the results will
217 * overwrite the area pointed to by data - which must
218 * already exist. The protection on the specified range
219 * must permit reading.]
221 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
222 routine mach_vm_read_overwrite(
224 routine vm_read_overwrite(
226 target_task : vm_map_t;
227 address : mach_vm_address_t;
228 size : mach_vm_size_t;
229 data : mach_vm_address_t;
230 out outsize : mach_vm_size_t);
233 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
234 routine mach_vm_msync(
238 target_task : vm_map_t;
239 address : mach_vm_address_t;
240 size : mach_vm_size_t;
241 sync_flags : vm_sync_t );
244 * Set the paging behavior attribute for the specified range
245 * of the virtual address space of the target task.
246 * The behavior value is one of {default, random, forward
247 * sequential, reverse sequential} and indicates the expected
248 * page reference pattern for the specified range.
250 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
251 routine mach_vm_behavior_set(
253 routine vm_behavior_set(
255 target_task : vm_map_t;
256 address : mach_vm_address_t;
257 size : mach_vm_size_t;
258 new_behavior : vm_behavior_t);
262 * Map a user-supplie memory object into the virtual address
263 * space of the target task. If desired (anywhere is TRUE),
264 * the kernel will find a suitable address range of the
265 * specified size; else, the specific address will be allocated.
267 * The beginning address of the range will be aligned on a virtual
268 * page boundary, be at or beyond the address specified, and
269 * meet the mask requirements (bits turned on in the mask must not
270 * be turned on in the result); the size of the range, in bytes,
271 * will be rounded up to an integral number of virtual pages.
273 * The memory in the resulting range will be associated with the
274 * specified memory object, with the beginning of the memory range
275 * referring to the specified offset into the memory object.
277 * The mapping will take the current and maximum protections and
278 * the inheritance attributes specified; see the vm_protect and
279 * vm_inherit calls for a description of these attributes.
281 * If desired (copy is TRUE), the memory range will be filled
282 * with a copy of the data from the memory object; this copy will
283 * be private to this mapping in this target task. Otherwise,
284 * the memory in this mapping will be shared with other mappings
285 * of the same memory object at the same offset (in this task or
286 * in other tasks). [The Mach kernel only enforces shared memory
287 * consistency among mappings on one host with similar page alignments.
288 * The user-defined memory manager for this object is responsible
289 * for further consistency.]
291 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
296 target_task : vm_task_entry_t;
297 inout address : mach_vm_address_t;
298 size : mach_vm_size_t;
299 mask : mach_vm_offset_t;
301 object : mem_entry_name_port_t;
302 offset : memory_object_offset_t;
304 cur_protection : vm_prot_t;
305 max_protection : vm_prot_t;
306 inheritance : vm_inherit_t);
309 * Set/Get special properties of memory associated
310 * to some virtual address range, such as cachability,
311 * migrability, replicability. Machine-dependent.
313 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
314 routine mach_vm_machine_attribute(
316 routine vm_machine_attribute(
318 target_task : vm_map_t;
319 address : mach_vm_address_t;
320 size : mach_vm_size_t;
321 attribute : vm_machine_attribute_t;
322 inout value : vm_machine_attribute_val_t);
325 * Map portion of a task's address space.
327 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
328 routine mach_vm_remap(
332 target_task : vm_map_t;
333 inout target_address : mach_vm_address_t;
334 size : mach_vm_size_t;
335 mask : mach_vm_offset_t;
336 anywhere : boolean_t;
338 src_address : mach_vm_address_t;
340 out cur_protection : vm_prot_t;
341 out max_protection : vm_prot_t;
342 inheritance : vm_inherit_t);
345 * Give the caller information on the given location in a virtual
346 * address space. If a page is mapped return ref and dirty info.
348 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
349 routine mach_vm_page_query(
351 routine vm_map_page_query(
353 target_map :vm_map_t;
354 offset :mach_vm_offset_t;
355 out disposition :integer_t;
356 out ref_count :integer_t);
359 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
360 routine mach_vm_region_recurse(
362 routine vm_region_recurse_64(
364 target_task : vm_map_t;
365 inout address : mach_vm_address_t;
366 out size : mach_vm_size_t;
367 inout nesting_depth : natural_t;
368 out info : vm_region_recurse_info_t,CountInOut);
371 * Returns information about the contents of the virtual
372 * address space of the target task at the specified
373 * address. The returned protection, inheritance, sharing
374 * and memory object values apply to the entire range described
375 * by the address range returned; the memory object offset
376 * corresponds to the beginning of the address range.
377 * [If the specified address is not allocated, the next
378 * highest address range is described. If no addresses beyond
379 * the one specified are allocated, the call returns KERN_NO_SPACE.]
381 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
382 routine mach_vm_region(
384 routine vm_region_64(
386 target_task : vm_map_t;
387 inout address : mach_vm_address_t;
388 out size : mach_vm_size_t;
389 flavor : vm_region_flavor_t;
390 out info : vm_region_info_t, CountInOut;
391 out object_name : memory_object_name_t =
392 MACH_MSG_TYPE_MOVE_SEND
396 * Allow application level processes to create named entries which
397 * correspond to mapped portions of their address space. These named
398 * entries can then be manipulated, shared with other processes in
399 * other address spaces and ultimately mapped in ohter address spaces
401 * THIS INTERFACE IS STILL EVOLVING.
403 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
404 routine _mach_make_memory_entry(
406 routine mach_make_memory_entry_64(
408 target_task :vm_map_t;
409 inout size :memory_object_size_t;
410 offset :memory_object_offset_t;
411 permission :vm_prot_t;
412 out object_handle :mem_entry_name_port_move_send_t;
413 parent_handle :mem_entry_name_port_t);
416 /****************************** Legacy section ***************************/
417 /* The following definitions are exist to provide compatibility with */
418 /* the legacy APIs. They are no different. We just need to produce */
419 /* the user-level stub interface for them. */
420 /****************************** Legacy section ***************************/
424 * These interfaces just aren't supported in the new (wide) model:
426 * mach_vm_region_info() -
427 * vm_map_pages_info() -
428 * no user-level replacement for these MACH_DEBUG interfaces
430 * no user-level replacement at the moment
432 * use mach_vm_region_info() or vm_region_info_64()
433 * vm_region_recurse() -
434 * use mach_vm_region_recurse() or vm_region_recurse_64()
438 * The following legacy interfaces are provides as macro wrappers to the new
439 * interfaces. You should strive to use the new ones instead:
442 * use mach_vm_map() or vm_map_64()
444 * use mach_vm_region() or vm_region_64()
445 * mach_make_memory_entry() -
446 * use mach_vm_make_memory_entry() or mach_make_memory_entry_64()