]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/mach_vm.defs
xnu-1504.9.17.tar.gz
[apple/xnu.git] / osfmk / mach / mach_vm.defs
1 /*
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * @OSF_FREE_COPYRIGHT@
30 */
31 /*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
34 * All Rights Reserved.
35 *
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.
41 *
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.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56 /*
57 */
58 /*
59 * File: mach/mach_vm.defs
60 *
61 * Exported kernel VM calls (for any task on the platform).
62 */
63
64 subsystem
65 #if KERNEL_SERVER
66 KernelServer
67 #endif /* KERNEL_SERVER */
68 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
69 mach_vm
70 #else
71 vm_map_lp64_local
72 #endif
73 4800;
74
75 #include <mach/std_types.defs>
76 #include <mach/mach_types.defs>
77 #include <mach_debug/mach_debug_types.defs>
78
79 /*
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.
85 */
86 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
87 routine mach_vm_allocate(
88 #else
89 routine vm_allocate(
90 #endif
91 target : vm_task_entry_t;
92 inout address : mach_vm_address_t;
93 size : mach_vm_size_t;
94 flags : int);
95
96 /*
97 * Deallocate the specified range from the virtual
98 * address space of the target virtual memory map.
99 */
100 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
101 routine mach_vm_deallocate(
102 #else
103 routine vm_deallocate(
104 #endif
105 target : vm_task_entry_t;
106 address : mach_vm_address_t;
107 size : mach_vm_size_t);
108
109 /*
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}
117 * *permissions*.
118 */
119 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
120 routine mach_vm_protect(
121 #else
122 routine vm_protect(
123 #endif
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);
129
130 /*
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.
136 */
137 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
138 routine mach_vm_inherit(
139 #else
140 routine vm_inherit(
141 #endif
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);
146
147 /*
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.]
153 */
154 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
155 routine mach_vm_read(
156 #else
157 routine vm_read(
158 #endif
159 target_task : vm_map_t;
160 address : mach_vm_address_t;
161 size : mach_vm_size_t;
162 out data : pointer_t);
163
164 /*
165 * List corrollary to vm_read, returns mapped contents of specified
166 * ranges within target address space.
167 */
168 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
169 routine mach_vm_read_list(
170 #else
171 routine vm_read_list(
172 #endif
173 target_task : vm_map_t;
174 inout data_list : mach_vm_read_entry_t;
175 count : natural_t);
176
177 /*
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.]
183 */
184 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
185 routine mach_vm_write(
186 #else
187 routine vm_write(
188 #endif
189 target_task : vm_map_t;
190 address : mach_vm_address_t;
191 data : pointer_t);
192
193 /*
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
201 * permit writing.]
202 */
203 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
204 routine mach_vm_copy(
205 #else
206 routine vm_copy(
207 #endif
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);
212
213 /*
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.]
220 */
221 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
222 routine mach_vm_read_overwrite(
223 #else
224 routine vm_read_overwrite(
225 #endif
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);
231
232
233 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
234 routine mach_vm_msync(
235 #else
236 routine vm_msync(
237 #endif
238 target_task : vm_map_t;
239 address : mach_vm_address_t;
240 size : mach_vm_size_t;
241 sync_flags : vm_sync_t );
242
243 /*
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.
249 */
250 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
251 routine mach_vm_behavior_set(
252 #else
253 routine vm_behavior_set(
254 #endif
255 target_task : vm_map_t;
256 address : mach_vm_address_t;
257 size : mach_vm_size_t;
258 new_behavior : vm_behavior_t);
259
260
261 /*
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.
266 *
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.
272 *
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.
276 *
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.
280 *
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.]
290 */
291 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
292 routine mach_vm_map(
293 #else
294 routine vm_map(
295 #endif
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;
300 flags : int;
301 object : mem_entry_name_port_t;
302 offset : memory_object_offset_t;
303 copy : boolean_t;
304 cur_protection : vm_prot_t;
305 max_protection : vm_prot_t;
306 inheritance : vm_inherit_t);
307
308 /*
309 * Set/Get special properties of memory associated
310 * to some virtual address range, such as cachability,
311 * migrability, replicability. Machine-dependent.
312 */
313 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
314 routine mach_vm_machine_attribute(
315 #else
316 routine vm_machine_attribute(
317 #endif
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);
323
324 /*
325 * Map portion of a task's address space.
326 */
327 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
328 routine mach_vm_remap(
329 #else
330 routine vm_remap(
331 #endif
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;
337 src_task : vm_map_t;
338 src_address : mach_vm_address_t;
339 copy : boolean_t;
340 out cur_protection : vm_prot_t;
341 out max_protection : vm_prot_t;
342 inheritance : vm_inherit_t);
343
344 /*
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.
347 */
348 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
349 routine mach_vm_page_query(
350 #else
351 routine vm_map_page_query(
352 #endif
353 target_map :vm_map_t;
354 offset :mach_vm_offset_t;
355 out disposition :integer_t;
356 out ref_count :integer_t);
357
358
359 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
360 routine mach_vm_region_recurse(
361 #else
362 routine vm_region_recurse_64(
363 #endif
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);
369
370 /*
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.]
380 */
381 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
382 routine mach_vm_region(
383 #else
384 routine vm_region_64(
385 #endif
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
393 ctype: mach_port_t);
394
395 /*
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
400 *
401 * THIS INTERFACE IS STILL EVOLVING.
402 */
403 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
404 #if !defined(__LP64__) || KERNEL_SERVER || XNU_KERNEL_PRIVATE || LIBSYSCALL_INTERFACE
405 routine _mach_make_memory_entry(
406 #else
407 routine mach_make_memory_entry(
408 #endif
409 #else
410 routine mach_make_memory_entry_64(
411 #endif
412 target_task :vm_map_t;
413 inout size :memory_object_size_t;
414 offset :memory_object_offset_t;
415 permission :vm_prot_t;
416 out object_handle :mem_entry_name_port_move_send_t;
417 parent_handle :mem_entry_name_port_t);
418
419 /*
420 * Control behavior and investigate state of a "purgable" object in
421 * the virtual address space of the target task. A purgable object is
422 * created via a call to mach_vm_allocate() with VM_FLAGS_PURGABLE
423 * specified. See the routine implementation for a complete
424 * definition of the routine.
425 */
426 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
427 routine mach_vm_purgable_control(
428 #else
429 routine vm_purgable_control(
430 #endif
431 target_task : vm_map_t;
432 address : mach_vm_address_t;
433 control : vm_purgable_t;
434 inout state : int);
435
436
437 #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
438 routine mach_vm_page_info(
439 target_task : vm_map_t;
440 address : mach_vm_address_t;
441 flavor : vm_page_info_flavor_t;
442 out info : vm_page_info_t, CountInOut);
443 #else
444 skip;
445 #endif
446
447 /****************************** Legacy section ***************************/
448 /* The following definitions are exist to provide compatibility with */
449 /* the legacy APIs. They are no different. We just need to produce */
450 /* the user-level stub interface for them. */
451 /****************************** Legacy section ***************************/
452
453
454 /*
455 * These interfaces just aren't supported in the new (wide) model:
456 *
457 * mach_vm_region_info() -
458 * vm_map_pages_info() -
459 * no user-level replacement for these MACH_DEBUG interfaces
460 * vm_map_get_upl() -
461 * no user-level replacement at the moment
462 * vm_region_info() -
463 * use mach_vm_region_info() or vm_region_info_64()
464 * vm_region_recurse() -
465 * use mach_vm_region_recurse() or vm_region_recurse_64()
466 */
467
468 /*
469 * The following legacy interfaces are provides as macro wrappers to the new
470 * interfaces. You should strive to use the new ones instead:
471 *
472 * vm_map() -
473 * use mach_vm_map() or vm_map_64()
474 * vm_region() -
475 * use mach_vm_region() or vm_region_64()
476 * mach_make_memory_entry() -
477 * use mach_vm_make_memory_entry() or mach_make_memory_entry_64()
478 */
479
480 /* vim: set ft=c : */