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>
79 #if !KERNEL && !LIBSYSCALL_INTERFACE
80 #define PREFIX(NAME) _kernelrpc_ ## NAME
82 #define PREFIX(NAME) NAME
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.
92 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
93 routine PREFIX(mach_vm_allocate) (
94 target : vm_task_entry_t;
95 inout address : mach_vm_address_t;
96 size : mach_vm_size_t;
101 #if !KERNEL && !LIBSYSCALL_INTERFACE
104 routine PREFIX(vm_allocate) (
105 target : vm_task_entry_t;
106 inout address : mach_vm_address_t;
107 size : mach_vm_size_t;
116 * Deallocate the specified range from the virtual
117 * address space of the target virtual memory map.
119 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
120 routine PREFIX(mach_vm_deallocate) (
121 target : vm_task_entry_t;
122 address : mach_vm_address_t;
123 size : mach_vm_size_t);
127 #if !KERNEL && !LIBSYSCALL_INTERFACE
130 routine PREFIX(vm_deallocate) (
131 target : vm_task_entry_t;
132 address : mach_vm_address_t;
133 size : mach_vm_size_t);
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}
148 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
149 routine 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);
159 #if !KERNEL && !LIBSYSCALL_INTERFACE
163 routine 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);
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.
181 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
182 routine mach_vm_inherit(
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);
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.]
198 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
199 routine PREFIX(mach_vm_read) (
201 routine PREFIX(vm_read) (
203 target_task : vm_map_t;
204 address : mach_vm_address_t;
205 size : mach_vm_size_t;
206 out data : pointer_t);
209 * List corrollary to vm_read, returns mapped contents of specified
210 * ranges within target address space.
212 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
213 routine mach_vm_read_list(
215 routine vm_read_list(
217 target_task : vm_map_t;
218 inout data_list : mach_vm_read_entry_t;
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.]
228 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
229 routine mach_vm_write(
233 target_task : vm_map_t;
234 address : mach_vm_address_t;
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
247 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
248 routine mach_vm_copy(
252 target_task : vm_map_t;
253 source_address : mach_vm_address_t;
254 size : mach_vm_size_t;
255 dest_address : mach_vm_address_t);
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.]
265 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
266 routine mach_vm_read_overwrite(
268 routine vm_read_overwrite(
270 target_task : 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);
277 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
278 routine mach_vm_msync(
282 target_task : vm_map_t;
283 address : mach_vm_address_t;
284 size : mach_vm_size_t;
285 sync_flags : vm_sync_t );
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.
294 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
295 routine mach_vm_behavior_set(
297 routine vm_behavior_set(
299 target_task : vm_map_t;
300 address : mach_vm_address_t;
301 size : mach_vm_size_t;
302 new_behavior : vm_behavior_t);
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.
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.
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.
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.
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.]
335 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
336 routine PREFIX(mach_vm_map) (
338 #if defined(__arm__) && !LIBSYSCALL_INTERFACE
341 routine PREFIX(vm_map) (
344 target_task : vm_task_entry_t;
345 inout address : mach_vm_address_t;
346 size : mach_vm_size_t;
347 mask : mach_vm_offset_t;
349 object : mem_entry_name_port_t;
350 offset : memory_object_offset_t;
352 cur_protection : vm_prot_t;
353 max_protection : vm_prot_t;
354 inheritance : vm_inherit_t);
357 * Set/Get special properties of memory associated
358 * to some virtual address range, such as cachability,
359 * migrability, replicability. Machine-dependent.
361 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
362 routine mach_vm_machine_attribute(
364 routine vm_machine_attribute(
366 target_task : vm_map_t;
367 address : mach_vm_address_t;
368 size : mach_vm_size_t;
369 attribute : vm_machine_attribute_t;
370 inout value : vm_machine_attribute_val_t);
373 * Map portion of a task's address space.
375 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
376 routine PREFIX(mach_vm_remap) (
378 routine PREFIX(vm_remap) (
380 target_task : vm_map_t;
381 inout target_address : mach_vm_address_t;
382 size : mach_vm_size_t;
383 mask : mach_vm_offset_t;
386 src_address : mach_vm_address_t;
388 out cur_protection : vm_prot_t;
389 out max_protection : vm_prot_t;
390 inheritance : vm_inherit_t);
393 * Give the caller information on the given location in a virtual
394 * address space. If a page is mapped return ref and dirty info.
396 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
397 routine mach_vm_page_query(
399 routine vm_map_page_query(
401 target_map :vm_map_t;
402 offset :mach_vm_offset_t;
403 out disposition :integer_t;
404 out ref_count :integer_t);
407 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
408 routine mach_vm_region_recurse(
410 routine vm_region_recurse_64(
412 target_task : vm_map_t;
413 inout address : mach_vm_address_t;
414 out size : mach_vm_size_t;
415 inout nesting_depth : natural_t;
416 out info : vm_region_recurse_info_t,CountInOut);
419 * Returns information about the contents of the virtual
420 * address space of the target task at the specified
421 * address. The returned protection, inheritance, sharing
422 * and memory object values apply to the entire range described
423 * by the address range returned; the memory object offset
424 * corresponds to the beginning of the address range.
425 * [If the specified address is not allocated, the next
426 * highest address range is described. If no addresses beyond
427 * the one specified are allocated, the call returns KERN_NO_SPACE.]
429 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
430 routine mach_vm_region(
432 routine vm_region_64(
434 target_task : vm_map_t;
435 inout address : mach_vm_address_t;
436 out size : mach_vm_size_t;
437 flavor : vm_region_flavor_t;
438 out info : vm_region_info_t, CountInOut;
439 out object_name : memory_object_name_t =
440 MACH_MSG_TYPE_MOVE_SEND
444 * Allow application level processes to create named entries which
445 * correspond to mapped portions of their address space. These named
446 * entries can then be manipulated, shared with other processes in
447 * other address spaces and ultimately mapped in ohter address spaces
449 * THIS INTERFACE IS STILL EVOLVING.
451 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
452 #if !defined(__LP64__) || KERNEL_SERVER || XNU_KERNEL_PRIVATE || LIBSYSCALL_INTERFACE
453 routine _mach_make_memory_entry(
455 routine mach_make_memory_entry(
458 routine mach_make_memory_entry_64(
460 target_task :vm_map_t;
461 inout size :memory_object_size_t;
462 offset :memory_object_offset_t;
463 permission :vm_prot_t;
464 out object_handle :mem_entry_name_port_move_send_t;
465 parent_handle :mem_entry_name_port_t);
468 * Control behavior and investigate state of a "purgable" object in
469 * the virtual address space of the target task. A purgable object is
470 * created via a call to mach_vm_allocate() with VM_FLAGS_PURGABLE
471 * specified. See the routine implementation for a complete
472 * definition of the routine.
474 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
475 routine PREFIX(mach_vm_purgable_control) (
477 routine PREFIX(vm_purgable_control) (
479 target_task : vm_map_t;
480 address : mach_vm_address_t;
481 control : vm_purgable_t;
485 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
486 routine mach_vm_page_info(
487 target_task : vm_map_t;
488 address : mach_vm_address_t;
489 flavor : vm_page_info_flavor_t;
490 out info : vm_page_info_t, CountInOut);
495 /****************************** Legacy section ***************************/
496 /* The following definitions are exist to provide compatibility with */
497 /* the legacy APIs. They are no different. We just need to produce */
498 /* the user-level stub interface for them. */
499 /****************************** Legacy section ***************************/
503 * These interfaces just aren't supported in the new (wide) model:
505 * mach_vm_region_info() -
506 * vm_map_pages_info() -
507 * no user-level replacement for these MACH_DEBUG interfaces
509 * no user-level replacement at the moment
511 * use mach_vm_region_info() or vm_region_info_64()
512 * vm_region_recurse() -
513 * use mach_vm_region_recurse() or vm_region_recurse_64()
517 * The following legacy interfaces are provides as macro wrappers to the new
518 * interfaces. You should strive to use the new ones instead:
521 * use mach_vm_map() or vm_map_64()
523 * use mach_vm_region() or vm_region_64()
524 * mach_make_memory_entry() -
525 * use mach_vm_make_memory_entry() or mach_make_memory_entry_64()
528 /* vim: set ft=c : */