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 #define CONCAT(a,b) a ## b
80 #if !KERNEL && !LIBSYSCALL_INTERFACE
81 #define PREFIX(NAME) CONCAT(_kernelrpc_, NAME)
83 #define PREFIX(NAME) NAME
87 #define KERNEL_SERVER_SUFFIX(NAME) CONCAT(NAME, _external)
89 #define KERNEL_SERVER_SUFFIX(NAME) NAME
93 * Allocate zero-filled memory in the address space
94 * of the target task, either at the specified address,
95 * or wherever space can be found (controlled by flags),
96 * of the specified size. The address at which the
97 * allocation actually took place is returned.
99 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
100 routine PREFIX(KERNEL_SERVER_SUFFIX(mach_vm_allocate)) (
101 target : vm_task_entry_t;
102 inout address : mach_vm_address_t;
103 size : mach_vm_size_t;
108 #if !KERNEL && !LIBSYSCALL_INTERFACE
111 routine PREFIX(KERNEL_SERVER_SUFFIX(vm_allocate)) (
112 target : vm_task_entry_t;
113 inout address : mach_vm_address_t;
114 size : mach_vm_size_t;
123 * Deallocate the specified range from the virtual
124 * address space of the target virtual memory map.
126 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
127 routine PREFIX(mach_vm_deallocate) (
128 target : vm_task_entry_t;
129 address : mach_vm_address_t;
130 size : mach_vm_size_t);
134 #if !KERNEL && !LIBSYSCALL_INTERFACE
137 routine PREFIX(vm_deallocate) (
138 target : vm_task_entry_t;
139 address : mach_vm_address_t;
140 size : mach_vm_size_t);
146 * Set the current or maximum protection attribute
147 * for the specified range of the virtual address
148 * space of the target virtual memory map. The current
149 * protection limits the memory access rights of threads
150 * within the map; the maximum protection limits the accesses
151 * that may be given in the current protection.
152 * Protections are specified as a set of {read, write, execute}
155 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
156 routine PREFIX(mach_vm_protect) (
157 target_task : vm_task_entry_t;
158 address : mach_vm_address_t;
159 size : mach_vm_size_t;
160 set_maximum : boolean_t;
161 new_protection : vm_prot_t);
166 #if !KERNEL && !LIBSYSCALL_INTERFACE
170 routine PREFIX(vm_protect) (
171 target_task : vm_task_entry_t;
172 address : mach_vm_address_t;
173 size : mach_vm_size_t;
174 set_maximum : boolean_t;
175 new_protection : vm_prot_t);
182 * Set the inheritance attribute for the specified range
183 * of the virtual address space of the target address space.
184 * The inheritance value is one of {none, copy, share}, and
185 * specifies how the child address space should acquire
186 * this memory at the time of a task_create call.
188 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
189 routine mach_vm_inherit(
193 target_task : vm_task_entry_t;
194 address : mach_vm_address_t;
195 size : mach_vm_size_t;
196 new_inheritance : vm_inherit_t);
199 * Returns the contents of the specified range of the
200 * virtual address space of the target task. [The
201 * range must be aligned on a virtual page boundary,
202 * and must be a multiple of pages in extent. The
203 * protection on the specified range must permit reading.]
205 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
206 routine PREFIX(mach_vm_read) (
208 routine PREFIX(vm_read) (
210 target_task : vm_map_t;
211 address : mach_vm_address_t;
212 size : mach_vm_size_t;
213 out data : pointer_t);
216 * List corrollary to vm_read, returns mapped contents of specified
217 * ranges within target address space.
219 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
220 routine mach_vm_read_list(
222 routine vm_read_list(
224 target_task : vm_map_t;
225 inout data_list : mach_vm_read_entry_t;
229 * Writes the contents of the specified range of the
230 * virtual address space of the target task. [The
231 * range must be aligned on a virtual page boundary,
232 * and must be a multiple of pages in extent. The
233 * protection on the specified range must permit writing.]
235 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
236 routine mach_vm_write(
240 target_task : vm_map_t;
241 address : mach_vm_address_t;
245 * Copy the contents of the source range of the virtual
246 * address space of the target task to the destination
247 * range in that same address space. [Both of the
248 * ranges must be aligned on a virtual page boundary,
249 * and must be multiples of pages in extent. The
250 * protection on the source range must permit reading,
251 * and the protection on the destination range must
254 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
255 routine mach_vm_copy(
259 target_task : vm_map_t;
260 source_address : mach_vm_address_t;
261 size : mach_vm_size_t;
262 dest_address : mach_vm_address_t);
265 * Returns the contents of the specified range of the
266 * virtual address space of the target task. [There
267 * are no alignment restrictions, and the results will
268 * overwrite the area pointed to by data - which must
269 * already exist. The protection on the specified range
270 * must permit reading.]
272 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
273 routine mach_vm_read_overwrite(
275 routine vm_read_overwrite(
277 target_task : vm_map_t;
278 address : mach_vm_address_t;
279 size : mach_vm_size_t;
280 data : mach_vm_address_t;
281 out outsize : mach_vm_size_t);
284 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
285 routine mach_vm_msync(
289 target_task : vm_map_t;
290 address : mach_vm_address_t;
291 size : mach_vm_size_t;
292 sync_flags : vm_sync_t );
295 * Set the paging behavior attribute for the specified range
296 * of the virtual address space of the target task.
297 * The behavior value is one of {default, random, forward
298 * sequential, reverse sequential} and indicates the expected
299 * page reference pattern for the specified range.
301 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
302 routine mach_vm_behavior_set(
304 routine vm_behavior_set(
306 target_task : vm_map_t;
307 address : mach_vm_address_t;
308 size : mach_vm_size_t;
309 new_behavior : vm_behavior_t);
313 * Map a user-supplie memory object into the virtual address
314 * space of the target task. If desired (anywhere is TRUE),
315 * the kernel will find a suitable address range of the
316 * specified size; else, the specific address will be allocated.
318 * The beginning address of the range will be aligned on a virtual
319 * page boundary, be at or beyond the address specified, and
320 * meet the mask requirements (bits turned on in the mask must not
321 * be turned on in the result); the size of the range, in bytes,
322 * will be rounded up to an integral number of virtual pages.
324 * The memory in the resulting range will be associated with the
325 * specified memory object, with the beginning of the memory range
326 * referring to the specified offset into the memory object.
328 * The mapping will take the current and maximum protections and
329 * the inheritance attributes specified; see the vm_protect and
330 * vm_inherit calls for a description of these attributes.
332 * If desired (copy is TRUE), the memory range will be filled
333 * with a copy of the data from the memory object; this copy will
334 * be private to this mapping in this target task. Otherwise,
335 * the memory in this mapping will be shared with other mappings
336 * of the same memory object at the same offset (in this task or
337 * in other tasks). [The Mach kernel only enforces shared memory
338 * consistency among mappings on one host with similar page alignments.
339 * The user-defined memory manager for this object is responsible
340 * for further consistency.]
342 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
343 routine PREFIX(KERNEL_SERVER_SUFFIX(mach_vm_map)) (
345 #if defined(__arm__) && !LIBSYSCALL_INTERFACE
348 routine PREFIX(KERNEL_SERVER_SUFFIX(vm_map)) (
351 target_task : vm_task_entry_t;
352 inout address : mach_vm_address_t;
353 size : mach_vm_size_t;
354 mask : mach_vm_offset_t;
356 object : mem_entry_name_port_t;
357 offset : memory_object_offset_t;
359 cur_protection : vm_prot_t;
360 max_protection : vm_prot_t;
361 inheritance : vm_inherit_t);
364 * Set/Get special properties of memory associated
365 * to some virtual address range, such as cachability,
366 * migrability, replicability. Machine-dependent.
368 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
369 routine mach_vm_machine_attribute(
371 routine vm_machine_attribute(
373 target_task : vm_map_t;
374 address : mach_vm_address_t;
375 size : mach_vm_size_t;
376 attribute : vm_machine_attribute_t;
377 inout value : vm_machine_attribute_val_t);
380 * Map portion of a task's address space.
382 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
383 routine PREFIX(KERNEL_SERVER_SUFFIX(mach_vm_remap)) (
385 routine PREFIX(KERNEL_SERVER_SUFFIX(vm_remap)) (
387 target_task : vm_map_t;
388 inout target_address : mach_vm_address_t;
389 size : mach_vm_size_t;
390 mask : mach_vm_offset_t;
393 src_address : mach_vm_address_t;
395 out cur_protection : vm_prot_t;
396 out max_protection : vm_prot_t;
397 inheritance : vm_inherit_t);
400 * Give the caller information on the given location in a virtual
401 * address space. If a page is mapped return ref and dirty info.
403 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
404 routine mach_vm_page_query(
406 routine vm_map_page_query(
408 target_map :vm_map_t;
409 offset :mach_vm_offset_t;
410 out disposition :integer_t;
411 out ref_count :integer_t);
414 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
415 routine mach_vm_region_recurse(
417 routine vm_region_recurse_64(
419 target_task : vm_map_t;
420 inout address : mach_vm_address_t;
421 out size : mach_vm_size_t;
422 inout nesting_depth : natural_t;
423 out info : vm_region_recurse_info_t,CountInOut);
426 * Returns information about the contents of the virtual
427 * address space of the target task at the specified
428 * address. The returned protection, inheritance, sharing
429 * and memory object values apply to the entire range described
430 * by the address range returned; the memory object offset
431 * corresponds to the beginning of the address range.
432 * [If the specified address is not allocated, the next
433 * highest address range is described. If no addresses beyond
434 * the one specified are allocated, the call returns KERN_NO_SPACE.]
436 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
437 routine mach_vm_region(
439 routine vm_region_64(
441 target_task : vm_map_t;
442 inout address : mach_vm_address_t;
443 out size : mach_vm_size_t;
444 flavor : vm_region_flavor_t;
445 out info : vm_region_info_t, CountInOut;
446 out object_name : memory_object_name_t =
447 MACH_MSG_TYPE_MOVE_SEND
451 * Allow application level processes to create named entries which
452 * correspond to mapped portions of their address space. These named
453 * entries can then be manipulated, shared with other processes in
454 * other address spaces and ultimately mapped in ohter address spaces
456 * THIS INTERFACE IS STILL EVOLVING.
458 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
459 #if !defined(__LP64__) || KERNEL_SERVER || XNU_KERNEL_PRIVATE || LIBSYSCALL_INTERFACE
460 routine _mach_make_memory_entry(
462 routine mach_make_memory_entry(
465 routine mach_make_memory_entry_64(
467 target_task :vm_map_t;
468 inout size :memory_object_size_t;
469 offset :memory_object_offset_t;
470 permission :vm_prot_t;
471 out object_handle :mem_entry_name_port_move_send_t;
472 parent_handle :mem_entry_name_port_t);
475 * Control behavior and investigate state of a "purgable" object in
476 * the virtual address space of the target task. A purgable object is
477 * created via a call to mach_vm_allocate() with VM_FLAGS_PURGABLE
478 * specified. See the routine implementation for a complete
479 * definition of the routine.
481 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
482 routine PREFIX(mach_vm_purgable_control) (
484 routine PREFIX(vm_purgable_control) (
486 target_task : vm_map_t;
487 address : mach_vm_address_t;
488 control : vm_purgable_t;
492 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
493 routine mach_vm_page_info(
494 target_task : vm_map_t;
495 address : mach_vm_address_t;
496 flavor : vm_page_info_flavor_t;
497 out info : vm_page_info_t, CountInOut);
502 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
503 routine mach_vm_page_range_query(
504 target_map : vm_map_t;
505 address : mach_vm_offset_t;
506 size : mach_vm_size_t;
507 dispositions : mach_vm_address_t;
508 inout dispositions_count : mach_vm_size_t);
513 /****************************** Legacy section ***************************/
514 /* The following definitions are exist to provide compatibility with */
515 /* the legacy APIs. They are no different. We just need to produce */
516 /* the user-level stub interface for them. */
517 /****************************** Legacy section ***************************/
521 * These interfaces just aren't supported in the new (wide) model:
523 * mach_vm_region_info() -
524 * vm_map_pages_info() -
525 * no user-level replacement for these MACH_DEBUG interfaces
527 * no user-level replacement at the moment
529 * use mach_vm_region_info() or vm_region_info_64()
530 * vm_region_recurse() -
531 * use mach_vm_region_recurse() or vm_region_recurse_64()
535 * The following legacy interfaces are provides as macro wrappers to the new
536 * interfaces. You should strive to use the new ones instead:
539 * use mach_vm_map() or vm_map_64()
541 * use mach_vm_region() or vm_region_64()
542 * mach_make_memory_entry() -
543 * use mach_vm_make_memory_entry() or mach_make_memory_entry_64()
546 /* vim: set ft=c : */