2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 * @OSF_FREE_COPYRIGHT@
27 * Mach Operating System
28 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
29 * All Rights Reserved.
31 * Permission to use, copy, modify and distribute this software and its
32 * documentation is hereby granted, provided that both the copyright
33 * notice and this permission notice appear in all copies of the
34 * software, derivative works or modified versions, and any portions
35 * thereof, and that both notices appear in supporting documentation.
37 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
38 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
39 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
41 * Carnegie Mellon requests users of this software to return to
43 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
44 * School of Computer Science
45 * Carnegie Mellon University
46 * Pittsburgh PA 15213-3890
48 * any improvements or extensions that they make and grant Carnegie Mellon
49 * the rights to redistribute these changes.
54 * File: mach/vm_map.defs
56 * Exported (native-sized) kernel VM calls.
62 #endif /* KERNEL_SERVER */
65 #include <mach/std_types.defs>
66 #include <mach/mach_types.defs>
67 #include <mach_debug/mach_debug_types.defs>
70 * Returns information about the contents of the virtual
71 * address space of the target task at the specified
72 * address. The returned protection, inheritance, sharing
73 * and memory object values apply to the entire range described
74 * by the address range returned; the memory object offset
75 * corresponds to the beginning of the address range.
76 * [If the specified address is not allocated, the next
77 * highest address range is described. If no addresses beyond
78 * the one specified are allocated, the call returns KERN_NO_SPACE.]
81 target_task : vm_map_t;
82 inout address : vm_address_t;
84 flavor : vm_region_flavor_t;
85 out info : vm_region_info_t, CountInOut;
86 out object_name : memory_object_name_t =
87 MACH_MSG_TYPE_MOVE_SEND
91 * Allocate zero-filled memory in the address space
92 * of the target task, either at the specified address,
93 * or wherever space can be found (if anywhere is TRUE),
94 * of the specified size. The address at which the
95 * allocation actually took place is returned.
98 target_task : vm_task_entry_t;
99 inout address : vm_address_t;
104 * Deallocate the specified range from the virtual
105 * address space of the target task.
107 routine vm_deallocate(
108 target_task : vm_task_entry_t;
109 address : vm_address_t;
113 * Set the current or maximum protection attribute
114 * for the specified range of the virtual address
115 * space of the target task. The current protection
116 * limits the memory access rights of threads within
117 * the task; the maximum protection limits the accesses
118 * that may be given in the current protection.
119 * Protections are specified as a set of {read, write, execute}
123 target_task : vm_task_entry_t;
124 address : vm_address_t;
126 set_maximum : boolean_t;
127 new_protection : vm_prot_t);
130 * Set the inheritance attribute for the specified range
131 * of the virtual address space of the target task.
132 * The inheritance value is one of {none, copy, share}, and
133 * specifies how the child address space should acquire
134 * this memory at the time of a task_create call.
137 target_task : vm_task_entry_t;
138 address : vm_address_t;
140 new_inheritance : vm_inherit_t);
143 * Returns the contents of the specified range of the
144 * virtual address space of the target task. [The
145 * range must be aligned on a virtual page boundary,
146 * and must be a multiple of pages in extent. The
147 * protection on the specified range must permit reading.]
150 target_task : vm_map_t;
151 address : vm_address_t;
153 out data : pointer_t);
156 * List corrollary to vm_read, returns mapped contents of specified
157 * ranges within target address space.
159 routine vm_read_list(
160 target_task : vm_map_t;
161 inout data_list : vm_read_entry_t;
165 * Writes the contents of the specified range of the
166 * virtual address space of the target task. [The
167 * range must be aligned on a virtual page boundary,
168 * and must be a multiple of pages in extent. The
169 * protection on the specified range must permit writing.]
172 target_task : vm_map_t;
173 address : vm_address_t;
177 * Copy the contents of the source range of the virtual
178 * address space of the target task to the destination
179 * range in that same address space. [Both of the
180 * ranges must be aligned on a virtual page boundary,
181 * and must be multiples of pages in extent. The
182 * protection on the source range must permit reading,
183 * and the protection on the destination range must
187 target_task : vm_map_t;
188 source_address : vm_address_t;
190 dest_address : vm_address_t);
193 * Returns the contents of the specified range of the
194 * virtual address space of the target task. [There
195 * are no alignment restrictions, and the results will
196 * overwrite the area pointed to by data - which must
197 * already exist. The protection on the specified range
198 * must permit reading.]
200 routine vm_read_overwrite(
201 target_task : vm_map_t;
202 address : vm_address_t;
205 out outsize : vm_size_t);
209 target_task : vm_map_t;
210 address : vm_address_t;
212 sync_flags : vm_sync_t );
215 * Set the paging behavior attribute for the specified range
216 * of the virtual address space of the target task.
217 * The behavior value is one of {default, random, forward
218 * sequential, reverse sequential} and indicates the expected
219 * page reference pattern for the specified range.
221 routine vm_behavior_set(
222 target_task : vm_map_t;
223 address : vm_address_t;
225 new_behavior : vm_behavior_t);
229 * Map a user-defined memory object into the virtual address
230 * space of the target task. If desired (anywhere is TRUE),
231 * the kernel will find a suitable address range of the
232 * specified size; else, the specific address will be allocated.
234 * The beginning address of the range will be aligned on a virtual
235 * page boundary, be at or beyond the address specified, and
236 * meet the mask requirements (bits turned on in the mask must not
237 * be turned on in the result); the size of the range, in bytes,
238 * will be rounded up to an integral number of virtual pages.
240 * The memory in the resulting range will be associated with the
241 * specified memory object, with the beginning of the memory range
242 * referring to the specified offset into the memory object.
244 * The mapping will take the current and maximum protections and
245 * the inheritance attributes specified; see the vm_protect and
246 * vm_inherit calls for a description of these attributes.
248 * If desired (copy is TRUE), the memory range will be filled
249 * with a copy of the data from the memory object; this copy will
250 * be private to this mapping in this target task. Otherwise,
251 * the memory in this mapping will be shared with other mappings
252 * of the same memory object at the same offset (in this task or
253 * in other tasks). [The Mach kernel only enforces shared memory
254 * consistency among mappings on one host with similar page alignments.
255 * The user-defined memory manager for this object is responsible
256 * for further consistency.]
259 target_task : vm_task_entry_t;
260 inout address : vm_address_t;
264 object : mem_entry_name_port_t;
265 offset : vm_offset_t;
267 cur_protection : vm_prot_t;
268 max_protection : vm_prot_t;
269 inheritance : vm_inherit_t);
272 * Set/Get special properties of memory associated
273 * to some virtual address range, such as cachability,
274 * migrability, replicability. Machine-dependent.
276 routine vm_machine_attribute(
277 target_task : vm_map_t;
278 address : vm_address_t;
280 attribute : vm_machine_attribute_t;
281 inout value : vm_machine_attribute_val_t);
284 * Map portion of a task's address space.
287 target_task : vm_map_t;
288 inout target_address : vm_address_t;
291 anywhere : boolean_t;
293 src_address : vm_address_t;
295 out cur_protection : vm_prot_t;
296 out max_protection : vm_prot_t;
297 inheritance : vm_inherit_t);
300 * Require that all future virtual memory allocation
301 * allocates wired memory. Setting must_wire to FALSE
302 * disables the wired future feature.
305 target_task : vm_map_t;
306 must_wire : boolean_t);
310 * Allow application level processes to create named entries which
311 * correspond to mapped portions of their address space. These named
312 * entries can then be manipulated, shared with other processes in
313 * other address spaces and ultimately mapped in ohter address spaces
316 routine mach_make_memory_entry(
317 target_task :vm_map_t;
318 inout size :vm_size_t;
320 permission :vm_prot_t;
321 out object_handle :mem_entry_name_port_move_send_t;
322 parent_entry :mem_entry_name_port_t);
325 * Give the caller information on the given location in a virtual
326 * address space. If a page is mapped return ref and dirty info.
328 routine vm_map_page_query(
329 target_map :vm_map_t;
331 out disposition :integer_t;
332 out ref_count :integer_t);
335 * Returns information about a region of memory.
336 * Includes info about the chain of objects rooted at that region.
337 * Only available in MACH_VM_DEBUG compiled kernels,
338 * otherwise returns KERN_FAILURE.
340 routine mach_vm_region_info(
342 address : vm_address_t;
343 out region : vm_info_region_t;
344 out objects : vm_info_object_array_t);
346 routine vm_mapped_pages_info(
348 out pages : page_address_array_t);
352 * Allow application level processes to create named entries which
353 * are backed by sub-maps which describe regions of address space.
354 * These regions of space can have objects mapped into them and
355 * in turn, can be mapped into target address spaces
358 routine vm_region_object_create(
359 target_task :vm_map_t;
361 out region_object :mach_port_move_send_t);
363 skip; /* was vm_region_object_create */
367 * A recursive form of vm_region which probes submaps withint the
370 routine vm_region_recurse(
371 target_task : vm_map_t;
372 inout address : vm_address_t;
373 out size : vm_size_t;
374 inout nesting_depth : natural_t;
375 out info : vm_region_recurse_info_t,CountInOut);
379 * The routines below are temporary, meant for transitional use
380 * as their counterparts are moved from 32 to 64 bit data path
384 routine vm_region_recurse_64(
385 target_task : vm_map_t;
386 inout address : vm_address_t;
387 out size : vm_size_t;
388 inout nesting_depth : natural_t;
389 out info : vm_region_recurse_info_t,CountInOut);
391 routine mach_vm_region_info_64(
393 address : vm_address_t;
394 out region : vm_info_region_64_t;
395 out objects : vm_info_object_array_t);
397 routine vm_region_64(
398 target_task : vm_map_t;
399 inout address : vm_address_t;
400 out size : vm_size_t;
401 flavor : vm_region_flavor_t;
402 out info : vm_region_info_t, CountInOut;
403 out object_name : memory_object_name_t =
404 MACH_MSG_TYPE_MOVE_SEND
407 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 :mach_port_move_send_t;
413 parent_entry :mem_entry_name_port_t);
418 target_task : vm_task_entry_t;
419 inout address : vm_address_t;
423 object : mem_entry_name_port_t;
424 offset : memory_object_offset_t;
426 cur_protection : vm_prot_t;
427 max_protection : vm_prot_t;
428 inheritance : vm_inherit_t);
432 * The UPL interfaces are not ready for user-level export.
434 routine vm_map_get_upl(
435 target_task : vm_map_t;
436 address : vm_address_t;
437 inout size : vm_size_t;
439 out page_info : upl_page_info_array_t, CountInOut;
440 inout flags : integer_t;
441 force_data_sync : integer_t);
444 target_task : vm_map_t;
446 inout address : vm_address_t);
448 routine vm_upl_unmap(
449 target_task : vm_map_t;
452 skip; /* was vm_map_get_upl */
453 skip; /* was vm_upl_map */
454 skip; /* was vm_upl_unmap */
458 * Control behavior and investigate state of a "purgable" object in
459 * the virtual address space of the target task. A purgable object is
460 * created via a call to vm_allocate() with VM_FLAGS_PURGABLE
461 * specified. See the routine implementation for a complete
462 * definition of the routine.
464 routine vm_purgable_control(
465 target_task : vm_map_t;
466 address : vm_address_t;
467 control : vm_purgable_t;