]>
Commit | Line | Data |
---|---|---|
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 | #if !KERNEL && !LIBSYSCALL_INTERFACE | |
80 | #define PREFIX(NAME) _kernelrpc_ ## NAME | |
81 | #else | |
82 | #define PREFIX(NAME) NAME | |
83 | #endif | |
84 | ||
85 | /* | |
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. | |
91 | */ | |
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; | |
97 | flags : int); | |
98 | ||
99 | #else | |
100 | ||
101 | #if !KERNEL && !LIBSYSCALL_INTERFACE | |
102 | skip; | |
103 | #else | |
104 | routine PREFIX(vm_allocate) ( | |
105 | target : vm_task_entry_t; | |
106 | inout address : mach_vm_address_t; | |
107 | size : mach_vm_size_t; | |
108 | flags : int); | |
109 | ||
110 | #endif | |
111 | ||
112 | #endif | |
113 | ||
114 | ||
115 | /* | |
116 | * Deallocate the specified range from the virtual | |
117 | * address space of the target virtual memory map. | |
118 | */ | |
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); | |
124 | ||
125 | #else | |
126 | ||
127 | #if !KERNEL && !LIBSYSCALL_INTERFACE | |
128 | skip; | |
129 | #else | |
130 | routine PREFIX(vm_deallocate) ( | |
131 | target : vm_task_entry_t; | |
132 | address : mach_vm_address_t; | |
133 | size : mach_vm_size_t); | |
134 | #endif | |
135 | ||
136 | #endif | |
137 | ||
138 | /* | |
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} | |
146 | * *permissions*. | |
147 | */ | |
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); | |
155 | ||
156 | ||
157 | #else | |
158 | ||
159 | #if !KERNEL && !LIBSYSCALL_INTERFACE | |
160 | skip; | |
161 | #else | |
162 | ||
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); | |
169 | ||
170 | #endif | |
171 | ||
172 | #endif | |
173 | ||
174 | /* | |
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. | |
180 | */ | |
181 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
182 | routine mach_vm_inherit( | |
183 | #else | |
184 | routine vm_inherit( | |
185 | #endif | |
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); | |
190 | ||
191 | /* | |
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.] | |
197 | */ | |
198 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
199 | routine PREFIX(mach_vm_read) ( | |
200 | #else | |
201 | routine PREFIX(vm_read) ( | |
202 | #endif | |
203 | target_task : vm_map_t; | |
204 | address : mach_vm_address_t; | |
205 | size : mach_vm_size_t; | |
206 | out data : pointer_t); | |
207 | ||
208 | /* | |
209 | * List corrollary to vm_read, returns mapped contents of specified | |
210 | * ranges within target address space. | |
211 | */ | |
212 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
213 | routine mach_vm_read_list( | |
214 | #else | |
215 | routine vm_read_list( | |
216 | #endif | |
217 | target_task : vm_map_t; | |
218 | inout data_list : mach_vm_read_entry_t; | |
219 | count : natural_t); | |
220 | ||
221 | /* | |
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.] | |
227 | */ | |
228 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
229 | routine mach_vm_write( | |
230 | #else | |
231 | routine vm_write( | |
232 | #endif | |
233 | target_task : vm_map_t; | |
234 | address : mach_vm_address_t; | |
235 | data : pointer_t); | |
236 | ||
237 | /* | |
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 | |
245 | * permit writing.] | |
246 | */ | |
247 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
248 | routine mach_vm_copy( | |
249 | #else | |
250 | routine vm_copy( | |
251 | #endif | |
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); | |
256 | ||
257 | /* | |
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.] | |
264 | */ | |
265 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
266 | routine mach_vm_read_overwrite( | |
267 | #else | |
268 | routine vm_read_overwrite( | |
269 | #endif | |
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); | |
275 | ||
276 | ||
277 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
278 | routine mach_vm_msync( | |
279 | #else | |
280 | routine vm_msync( | |
281 | #endif | |
282 | target_task : vm_map_t; | |
283 | address : mach_vm_address_t; | |
284 | size : mach_vm_size_t; | |
285 | sync_flags : vm_sync_t ); | |
286 | ||
287 | /* | |
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. | |
293 | */ | |
294 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
295 | routine mach_vm_behavior_set( | |
296 | #else | |
297 | routine vm_behavior_set( | |
298 | #endif | |
299 | target_task : vm_map_t; | |
300 | address : mach_vm_address_t; | |
301 | size : mach_vm_size_t; | |
302 | new_behavior : vm_behavior_t); | |
303 | ||
304 | ||
305 | /* | |
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. | |
310 | * | |
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. | |
316 | * | |
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. | |
320 | * | |
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. | |
324 | * | |
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.] | |
334 | */ | |
335 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
336 | routine PREFIX(mach_vm_map) ( | |
337 | #else | |
338 | #if defined(__arm__) && !LIBSYSCALL_INTERFACE | |
339 | routine _vm_map_arm( | |
340 | #else | |
341 | routine PREFIX(vm_map) ( | |
342 | #endif | |
343 | #endif | |
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; | |
348 | flags : int; | |
349 | object : mem_entry_name_port_t; | |
350 | offset : memory_object_offset_t; | |
351 | copy : boolean_t; | |
352 | cur_protection : vm_prot_t; | |
353 | max_protection : vm_prot_t; | |
354 | inheritance : vm_inherit_t); | |
355 | ||
356 | /* | |
357 | * Set/Get special properties of memory associated | |
358 | * to some virtual address range, such as cachability, | |
359 | * migrability, replicability. Machine-dependent. | |
360 | */ | |
361 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
362 | routine mach_vm_machine_attribute( | |
363 | #else | |
364 | routine vm_machine_attribute( | |
365 | #endif | |
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); | |
371 | ||
372 | /* | |
373 | * Map portion of a task's address space. | |
374 | */ | |
375 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
376 | routine PREFIX(mach_vm_remap) ( | |
377 | #else | |
378 | routine PREFIX(vm_remap) ( | |
379 | #endif | |
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; | |
384 | flags : int; | |
385 | src_task : vm_map_t; | |
386 | src_address : mach_vm_address_t; | |
387 | copy : boolean_t; | |
388 | out cur_protection : vm_prot_t; | |
389 | out max_protection : vm_prot_t; | |
390 | inheritance : vm_inherit_t); | |
391 | ||
392 | /* | |
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. | |
395 | */ | |
396 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
397 | routine mach_vm_page_query( | |
398 | #else | |
399 | routine vm_map_page_query( | |
400 | #endif | |
401 | target_map :vm_map_t; | |
402 | offset :mach_vm_offset_t; | |
403 | out disposition :integer_t; | |
404 | out ref_count :integer_t); | |
405 | ||
406 | ||
407 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
408 | routine mach_vm_region_recurse( | |
409 | #else | |
410 | routine vm_region_recurse_64( | |
411 | #endif | |
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); | |
417 | ||
418 | /* | |
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.] | |
428 | */ | |
429 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
430 | routine mach_vm_region( | |
431 | #else | |
432 | routine vm_region_64( | |
433 | #endif | |
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 | |
441 | ctype: mach_port_t); | |
442 | ||
443 | /* | |
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 | |
448 | * | |
449 | * THIS INTERFACE IS STILL EVOLVING. | |
450 | */ | |
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( | |
454 | #else | |
455 | routine mach_make_memory_entry( | |
456 | #endif | |
457 | #else | |
458 | routine mach_make_memory_entry_64( | |
459 | #endif | |
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); | |
466 | ||
467 | /* | |
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. | |
473 | */ | |
474 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
475 | routine PREFIX(mach_vm_purgable_control) ( | |
476 | #else | |
477 | routine PREFIX(vm_purgable_control) ( | |
478 | #endif | |
479 | target_task : vm_map_t; | |
480 | address : mach_vm_address_t; | |
481 | control : vm_purgable_t; | |
482 | inout state : int); | |
483 | ||
484 | ||
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); | |
491 | #else | |
492 | skip; | |
493 | #endif | |
494 | ||
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 ***************************/ | |
500 | ||
501 | ||
502 | /* | |
503 | * These interfaces just aren't supported in the new (wide) model: | |
504 | * | |
505 | * mach_vm_region_info() - | |
506 | * vm_map_pages_info() - | |
507 | * no user-level replacement for these MACH_DEBUG interfaces | |
508 | * vm_map_get_upl() - | |
509 | * no user-level replacement at the moment | |
510 | * vm_region_info() - | |
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() | |
514 | */ | |
515 | ||
516 | /* | |
517 | * The following legacy interfaces are provides as macro wrappers to the new | |
518 | * interfaces. You should strive to use the new ones instead: | |
519 | * | |
520 | * vm_map() - | |
521 | * use mach_vm_map() or vm_map_64() | |
522 | * vm_region() - | |
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() | |
526 | */ | |
527 | ||
528 | /* vim: set ft=c : */ |