]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/mach_vm.defs
xnu-6153.121.1.tar.gz
[apple/xnu.git] / osfmk / mach / mach_vm.defs
CommitLineData
91447636
A
1/*
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
8f6c56a5 5 *
2d21ac55
A
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.
8f6c56a5 14 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
91447636
A
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
64subsystem
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
5ba3f43e 79#define CONCAT(a,b) a ## b
316670eb 80#if !KERNEL && !LIBSYSCALL_INTERFACE
5ba3f43e 81#define PREFIX(NAME) CONCAT(_kernelrpc_, NAME)
316670eb
A
82#else
83#define PREFIX(NAME) NAME
84#endif
85
5ba3f43e
A
86#if KERNEL_SERVER
87#define KERNEL_SERVER_SUFFIX(NAME) CONCAT(NAME, _external)
88#else
89#define KERNEL_SERVER_SUFFIX(NAME) NAME
90#endif
91
91447636
A
92/*
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.
98 */
99#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
5ba3f43e 100routine PREFIX(KERNEL_SERVER_SUFFIX(mach_vm_allocate)) (
316670eb
A
101 target : vm_task_entry_t;
102 inout address : mach_vm_address_t;
103 size : mach_vm_size_t;
104 flags : int);
105
91447636 106#else
316670eb
A
107
108#if !KERNEL && !LIBSYSCALL_INTERFACE
109skip;
110#else
5ba3f43e 111routine PREFIX(KERNEL_SERVER_SUFFIX(vm_allocate)) (
91447636
A
112 target : vm_task_entry_t;
113 inout address : mach_vm_address_t;
114 size : mach_vm_size_t;
115 flags : int);
116
316670eb
A
117#endif
118
119#endif
120
121
91447636
A
122/*
123 * Deallocate the specified range from the virtual
124 * address space of the target virtual memory map.
125 */
126#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
316670eb
A
127routine PREFIX(mach_vm_deallocate) (
128 target : vm_task_entry_t;
129 address : mach_vm_address_t;
130 size : mach_vm_size_t);
131
91447636 132#else
316670eb
A
133
134#if !KERNEL && !LIBSYSCALL_INTERFACE
135skip;
136#else
137routine PREFIX(vm_deallocate) (
91447636
A
138 target : vm_task_entry_t;
139 address : mach_vm_address_t;
140 size : mach_vm_size_t);
316670eb
A
141#endif
142
143#endif
91447636
A
144
145/*
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}
153 * *permissions*.
154 */
155#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
316670eb
A
156routine 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);
162
163
91447636 164#else
316670eb
A
165
166#if !KERNEL && !LIBSYSCALL_INTERFACE
167skip;
168#else
169
170routine PREFIX(vm_protect) (
91447636
A
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);
176
316670eb
A
177#endif
178
179#endif
180
91447636
A
181/*
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.
187 */
188#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
189routine mach_vm_inherit(
190#else
191routine vm_inherit(
192#endif
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);
197
198/*
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.]
204 */
205#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
39236c6e 206routine PREFIX(mach_vm_read) (
91447636 207#else
39236c6e 208routine PREFIX(vm_read) (
91447636
A
209#endif
210 target_task : vm_map_t;
211 address : mach_vm_address_t;
212 size : mach_vm_size_t;
213 out data : pointer_t);
214
215/*
216 * List corrollary to vm_read, returns mapped contents of specified
217 * ranges within target address space.
218 */
219#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
220routine mach_vm_read_list(
221#else
222routine vm_read_list(
223#endif
224 target_task : vm_map_t;
225 inout data_list : mach_vm_read_entry_t;
226 count : natural_t);
227
228/*
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.]
234 */
235#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
236routine mach_vm_write(
237#else
238routine vm_write(
239#endif
240 target_task : vm_map_t;
241 address : mach_vm_address_t;
242 data : pointer_t);
243
244/*
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
252 * permit writing.]
253 */
254#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
255routine mach_vm_copy(
256#else
257routine vm_copy(
258#endif
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);
263
264/*
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.]
271 */
272#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
273routine mach_vm_read_overwrite(
274#else
275routine vm_read_overwrite(
276#endif
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);
282
283
284#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
285routine mach_vm_msync(
286#else
287routine vm_msync(
288#endif
289 target_task : vm_map_t;
290 address : mach_vm_address_t;
291 size : mach_vm_size_t;
292 sync_flags : vm_sync_t );
293
294/*
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.
300 */
301#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
302routine mach_vm_behavior_set(
303#else
304routine vm_behavior_set(
305#endif
306 target_task : vm_map_t;
307 address : mach_vm_address_t;
308 size : mach_vm_size_t;
309 new_behavior : vm_behavior_t);
310
311
312/*
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.
317 *
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.
323 *
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.
327 *
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.
331 *
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.]
341 */
342#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
5ba3f43e 343routine PREFIX(KERNEL_SERVER_SUFFIX(mach_vm_map)) (
91447636 344#else
6d2010ae
A
345#if defined(__arm__) && !LIBSYSCALL_INTERFACE
346routine _vm_map_arm(
347#else
5ba3f43e 348routine PREFIX(KERNEL_SERVER_SUFFIX(vm_map)) (
6d2010ae 349#endif
91447636
A
350#endif
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;
355 flags : int;
356 object : mem_entry_name_port_t;
357 offset : memory_object_offset_t;
358 copy : boolean_t;
359 cur_protection : vm_prot_t;
360 max_protection : vm_prot_t;
361 inheritance : vm_inherit_t);
362
363/*
364 * Set/Get special properties of memory associated
365 * to some virtual address range, such as cachability,
366 * migrability, replicability. Machine-dependent.
367 */
368#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
369routine mach_vm_machine_attribute(
370#else
371routine vm_machine_attribute(
372#endif
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);
378
379/*
380 * Map portion of a task's address space.
381 */
382#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
5ba3f43e 383routine PREFIX(KERNEL_SERVER_SUFFIX(mach_vm_remap)) (
91447636 384#else
5ba3f43e 385routine PREFIX(KERNEL_SERVER_SUFFIX(vm_remap)) (
91447636
A
386#endif
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;
060df5ea 391 flags : int;
91447636
A
392 src_task : vm_map_t;
393 src_address : mach_vm_address_t;
394 copy : boolean_t;
395 out cur_protection : vm_prot_t;
396 out max_protection : vm_prot_t;
397 inheritance : vm_inherit_t);
398
399/*
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.
402 */
403#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
404routine mach_vm_page_query(
405#else
406routine vm_map_page_query(
407#endif
408 target_map :vm_map_t;
409 offset :mach_vm_offset_t;
410 out disposition :integer_t;
411 out ref_count :integer_t);
412
413
414#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
415routine mach_vm_region_recurse(
416#else
417routine vm_region_recurse_64(
418#endif
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);
424
425/*
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.]
435 */
436#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
437routine mach_vm_region(
438#else
439routine vm_region_64(
440#endif
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
448 ctype: mach_port_t);
449
450/*
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
455 *
456 * THIS INTERFACE IS STILL EVOLVING.
457 */
458#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
b0d623f7 459#if !defined(__LP64__) || KERNEL_SERVER || XNU_KERNEL_PRIVATE || LIBSYSCALL_INTERFACE
91447636
A
460routine _mach_make_memory_entry(
461#else
2d21ac55
A
462routine mach_make_memory_entry(
463#endif
464#else
91447636
A
465routine mach_make_memory_entry_64(
466#endif
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);
473
2d21ac55
A
474/*
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.
480 */
481#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
39037602 482routine PREFIX(mach_vm_purgable_control) (
2d21ac55 483#else
39037602 484routine PREFIX(vm_purgable_control) (
2d21ac55
A
485#endif
486 target_task : vm_map_t;
487 address : mach_vm_address_t;
488 control : vm_purgable_t;
489 inout state : int);
490
91447636 491
b0d623f7
A
492#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
493routine 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);
498#else
499skip;
500#endif
501
5ba3f43e
A
502#if !defined(_MACH_VM_PUBLISH_AS_LOCAL_)
503routine 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);
509#else
510skip;
511#endif
512
91447636
A
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 ***************************/
518
519
520/*
521 * These interfaces just aren't supported in the new (wide) model:
522 *
523 * mach_vm_region_info() -
524 * vm_map_pages_info() -
525 * no user-level replacement for these MACH_DEBUG interfaces
526 * vm_map_get_upl() -
527 * no user-level replacement at the moment
528 * vm_region_info() -
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()
532 */
533
534/*
535 * The following legacy interfaces are provides as macro wrappers to the new
536 * interfaces. You should strive to use the new ones instead:
537 *
538 * vm_map() -
539 * use mach_vm_map() or vm_map_64()
540 * vm_region() -
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()
544 */
2d21ac55
A
545
546/* vim: set ft=c : */