]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
37839358 A |
6 | * The contents of this file constitute Original Code as defined in and |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
e5568f75 | 11 | * |
37839358 A |
12 | * This Original Code and all software distributed under the License are |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
37839358 A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * @OSF_FREE_COPYRIGHT@ | |
24 | */ | |
25 | /* | |
26 | * Mach Operating System | |
27 | * Copyright (c) 1991,1990,1989 Carnegie Mellon University | |
28 | * All Rights Reserved. | |
29 | * | |
30 | * Permission to use, copy, modify and distribute this software and its | |
31 | * documentation is hereby granted, provided that both the copyright | |
32 | * notice and this permission notice appear in all copies of the | |
33 | * software, derivative works or modified versions, and any portions | |
34 | * thereof, and that both notices appear in supporting documentation. | |
35 | * | |
36 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
37 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
38 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
39 | * | |
40 | * Carnegie Mellon requests users of this software to return to | |
41 | * | |
42 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
43 | * School of Computer Science | |
44 | * Carnegie Mellon University | |
45 | * Pittsburgh PA 15213-3890 | |
46 | * | |
47 | * any improvements or extensions that they make and grant Carnegie Mellon | |
48 | * the rights to redistribute these changes. | |
49 | */ | |
50 | /* | |
51 | */ | |
52 | /* | |
91447636 | 53 | * File: mach/vm_map.defs |
1c79356b | 54 | * |
91447636 | 55 | * Exported (native-sized) kernel VM calls. |
1c79356b A |
56 | */ |
57 | ||
58 | subsystem | |
59 | #if KERNEL_SERVER | |
60 | KernelServer | |
55e303ae | 61 | #endif /* KERNEL_SERVER */ |
1c79356b A |
62 | vm_map 3800; |
63 | ||
64 | #include <mach/std_types.defs> | |
65 | #include <mach/mach_types.defs> | |
66 | #include <mach_debug/mach_debug_types.defs> | |
67 | ||
68 | /* | |
69 | * Returns information about the contents of the virtual | |
70 | * address space of the target task at the specified | |
71 | * address. The returned protection, inheritance, sharing | |
72 | * and memory object values apply to the entire range described | |
73 | * by the address range returned; the memory object offset | |
74 | * corresponds to the beginning of the address range. | |
75 | * [If the specified address is not allocated, the next | |
76 | * highest address range is described. If no addresses beyond | |
77 | * the one specified are allocated, the call returns KERN_NO_SPACE.] | |
78 | */ | |
79 | routine vm_region( | |
80 | target_task : vm_map_t; | |
81 | inout address : vm_address_t; | |
82 | out size : vm_size_t; | |
83 | flavor : vm_region_flavor_t; | |
84 | out info : vm_region_info_t, CountInOut; | |
85 | out object_name : memory_object_name_t = | |
86 | MACH_MSG_TYPE_MOVE_SEND | |
87 | ctype: mach_port_t); | |
88 | ||
89 | /* | |
90 | * Allocate zero-filled memory in the address space | |
91 | * of the target task, either at the specified address, | |
92 | * or wherever space can be found (if anywhere is TRUE), | |
93 | * of the specified size. The address at which the | |
94 | * allocation actually took place is returned. | |
95 | */ | |
96 | routine vm_allocate( | |
97 | target_task : vm_task_entry_t; | |
98 | inout address : vm_address_t; | |
99 | size : vm_size_t; | |
100 | flags : int); | |
101 | ||
102 | /* | |
103 | * Deallocate the specified range from the virtual | |
104 | * address space of the target task. | |
105 | */ | |
106 | routine vm_deallocate( | |
107 | target_task : vm_task_entry_t; | |
108 | address : vm_address_t; | |
109 | size : vm_size_t); | |
110 | ||
111 | /* | |
112 | * Set the current or maximum protection attribute | |
113 | * for the specified range of the virtual address | |
114 | * space of the target task. The current protection | |
115 | * limits the memory access rights of threads within | |
116 | * the task; the maximum protection limits the accesses | |
117 | * that may be given in the current protection. | |
118 | * Protections are specified as a set of {read, write, execute} | |
119 | * *permissions*. | |
120 | */ | |
121 | routine vm_protect( | |
122 | target_task : vm_task_entry_t; | |
123 | address : vm_address_t; | |
124 | size : vm_size_t; | |
125 | set_maximum : boolean_t; | |
126 | new_protection : vm_prot_t); | |
127 | ||
128 | /* | |
129 | * Set the inheritance attribute for the specified range | |
130 | * of the virtual address space of the target task. | |
131 | * The inheritance value is one of {none, copy, share}, and | |
132 | * specifies how the child address space should acquire | |
133 | * this memory at the time of a task_create call. | |
134 | */ | |
135 | routine vm_inherit( | |
136 | target_task : vm_task_entry_t; | |
137 | address : vm_address_t; | |
138 | size : vm_size_t; | |
139 | new_inheritance : vm_inherit_t); | |
140 | ||
141 | /* | |
142 | * Returns the contents of the specified range of the | |
143 | * virtual address space of the target task. [The | |
144 | * range must be aligned on a virtual page boundary, | |
145 | * and must be a multiple of pages in extent. The | |
146 | * protection on the specified range must permit reading.] | |
147 | */ | |
148 | routine vm_read( | |
149 | target_task : vm_map_t; | |
150 | address : vm_address_t; | |
151 | size : vm_size_t; | |
152 | out data : pointer_t); | |
153 | ||
154 | /* | |
155 | * List corrollary to vm_read, returns mapped contents of specified | |
156 | * ranges within target address space. | |
157 | */ | |
158 | routine vm_read_list( | |
159 | target_task : vm_map_t; | |
160 | inout data_list : vm_read_entry_t; | |
161 | count : natural_t); | |
162 | ||
163 | /* | |
164 | * Writes the contents of the specified range of the | |
165 | * virtual address space of the target task. [The | |
166 | * range must be aligned on a virtual page boundary, | |
167 | * and must be a multiple of pages in extent. The | |
168 | * protection on the specified range must permit writing.] | |
169 | */ | |
170 | routine vm_write( | |
171 | target_task : vm_map_t; | |
172 | address : vm_address_t; | |
173 | data : pointer_t); | |
174 | ||
175 | /* | |
176 | * Copy the contents of the source range of the virtual | |
177 | * address space of the target task to the destination | |
178 | * range in that same address space. [Both of the | |
179 | * ranges must be aligned on a virtual page boundary, | |
180 | * and must be multiples of pages in extent. The | |
181 | * protection on the source range must permit reading, | |
182 | * and the protection on the destination range must | |
183 | * permit writing.] | |
184 | */ | |
185 | routine vm_copy( | |
186 | target_task : vm_map_t; | |
187 | source_address : vm_address_t; | |
188 | size : vm_size_t; | |
189 | dest_address : vm_address_t); | |
190 | ||
191 | /* | |
192 | * Returns the contents of the specified range of the | |
193 | * virtual address space of the target task. [There | |
194 | * are no alignment restrictions, and the results will | |
195 | * overwrite the area pointed to by data - which must | |
196 | * already exist. The protection on the specified range | |
197 | * must permit reading.] | |
198 | */ | |
199 | routine vm_read_overwrite( | |
200 | target_task : vm_map_t; | |
201 | address : vm_address_t; | |
202 | size : vm_size_t; | |
203 | data : vm_address_t; | |
204 | out outsize : vm_size_t); | |
205 | ||
206 | ||
207 | routine vm_msync( | |
208 | target_task : vm_map_t; | |
209 | address : vm_address_t; | |
210 | size : vm_size_t; | |
211 | sync_flags : vm_sync_t ); | |
212 | ||
213 | /* | |
214 | * Set the paging behavior attribute for the specified range | |
215 | * of the virtual address space of the target task. | |
216 | * The behavior value is one of {default, random, forward | |
217 | * sequential, reverse sequential} and indicates the expected | |
218 | * page reference pattern for the specified range. | |
219 | */ | |
220 | routine vm_behavior_set( | |
221 | target_task : vm_map_t; | |
222 | address : vm_address_t; | |
223 | size : vm_size_t; | |
224 | new_behavior : vm_behavior_t); | |
225 | ||
226 | ||
227 | /* | |
228 | * Map a user-defined memory object into the virtual address | |
229 | * space of the target task. If desired (anywhere is TRUE), | |
230 | * the kernel will find a suitable address range of the | |
231 | * specified size; else, the specific address will be allocated. | |
232 | * | |
233 | * The beginning address of the range will be aligned on a virtual | |
234 | * page boundary, be at or beyond the address specified, and | |
235 | * meet the mask requirements (bits turned on in the mask must not | |
236 | * be turned on in the result); the size of the range, in bytes, | |
237 | * will be rounded up to an integral number of virtual pages. | |
238 | * | |
239 | * The memory in the resulting range will be associated with the | |
240 | * specified memory object, with the beginning of the memory range | |
241 | * referring to the specified offset into the memory object. | |
242 | * | |
243 | * The mapping will take the current and maximum protections and | |
244 | * the inheritance attributes specified; see the vm_protect and | |
245 | * vm_inherit calls for a description of these attributes. | |
246 | * | |
247 | * If desired (copy is TRUE), the memory range will be filled | |
248 | * with a copy of the data from the memory object; this copy will | |
249 | * be private to this mapping in this target task. Otherwise, | |
250 | * the memory in this mapping will be shared with other mappings | |
251 | * of the same memory object at the same offset (in this task or | |
252 | * in other tasks). [The Mach kernel only enforces shared memory | |
253 | * consistency among mappings on one host with similar page alignments. | |
254 | * The user-defined memory manager for this object is responsible | |
255 | * for further consistency.] | |
256 | */ | |
257 | routine vm_map( | |
258 | target_task : vm_task_entry_t; | |
259 | inout address : vm_address_t; | |
260 | size : vm_size_t; | |
261 | mask : vm_address_t; | |
262 | flags : int; | |
0b4e3aa0 | 263 | object : mem_entry_name_port_t; |
1c79356b A |
264 | offset : vm_offset_t; |
265 | copy : boolean_t; | |
266 | cur_protection : vm_prot_t; | |
267 | max_protection : vm_prot_t; | |
268 | inheritance : vm_inherit_t); | |
269 | ||
270 | /* | |
271 | * Set/Get special properties of memory associated | |
272 | * to some virtual address range, such as cachability, | |
273 | * migrability, replicability. Machine-dependent. | |
274 | */ | |
275 | routine vm_machine_attribute( | |
276 | target_task : vm_map_t; | |
277 | address : vm_address_t; | |
278 | size : vm_size_t; | |
279 | attribute : vm_machine_attribute_t; | |
280 | inout value : vm_machine_attribute_val_t); | |
281 | ||
282 | /* | |
283 | * Map portion of a task's address space. | |
284 | */ | |
285 | routine vm_remap( | |
286 | target_task : vm_map_t; | |
287 | inout target_address : vm_address_t; | |
288 | size : vm_size_t; | |
289 | mask : vm_address_t; | |
290 | anywhere : boolean_t; | |
291 | src_task : vm_map_t; | |
292 | src_address : vm_address_t; | |
293 | copy : boolean_t; | |
294 | out cur_protection : vm_prot_t; | |
295 | out max_protection : vm_prot_t; | |
296 | inheritance : vm_inherit_t); | |
297 | ||
298 | /* | |
299 | * Require that all future virtual memory allocation | |
300 | * allocates wired memory. Setting must_wire to FALSE | |
301 | * disables the wired future feature. | |
302 | */ | |
303 | routine task_wire( | |
304 | target_task : vm_map_t; | |
305 | must_wire : boolean_t); | |
306 | ||
307 | ||
308 | /* | |
309 | * Allow application level processes to create named entries which | |
310 | * correspond to mapped portions of their address space. These named | |
311 | * entries can then be manipulated, shared with other processes in | |
312 | * other address spaces and ultimately mapped in ohter address spaces | |
313 | */ | |
314 | ||
315 | routine mach_make_memory_entry( | |
316 | target_task :vm_map_t; | |
317 | inout size :vm_size_t; | |
318 | offset :vm_offset_t; | |
319 | permission :vm_prot_t; | |
91447636 | 320 | out object_handle :mem_entry_name_port_move_send_t; |
1c79356b A |
321 | parent_entry :mem_entry_name_port_t); |
322 | ||
323 | /* | |
324 | * Give the caller information on the given location in a virtual | |
325 | * address space. If a page is mapped return ref and dirty info. | |
326 | */ | |
327 | routine vm_map_page_query( | |
328 | target_map :vm_map_t; | |
329 | offset :vm_offset_t; | |
330 | out disposition :integer_t; | |
331 | out ref_count :integer_t); | |
332 | ||
333 | /* | |
334 | * Returns information about a region of memory. | |
335 | * Includes info about the chain of objects rooted at that region. | |
336 | * Only available in MACH_VM_DEBUG compiled kernels, | |
337 | * otherwise returns KERN_FAILURE. | |
338 | */ | |
339 | routine mach_vm_region_info( | |
340 | task : vm_map_t; | |
341 | address : vm_address_t; | |
342 | out region : vm_info_region_t; | |
343 | out objects : vm_info_object_array_t); | |
344 | ||
345 | routine vm_mapped_pages_info( | |
346 | task : vm_map_t; | |
347 | out pages : page_address_array_t); | |
348 | ||
91447636 | 349 | #if 0 |
1c79356b A |
350 | /* |
351 | * Allow application level processes to create named entries which | |
352 | * are backed by sub-maps which describe regions of address space. | |
353 | * These regions of space can have objects mapped into them and | |
354 | * in turn, can be mapped into target address spaces | |
355 | */ | |
356 | ||
1c79356b A |
357 | routine vm_region_object_create( |
358 | target_task :vm_map_t; | |
359 | in size :vm_size_t; | |
360 | out region_object :mach_port_move_send_t); | |
91447636 A |
361 | #else |
362 | skip; /* was vm_region_object_create */ | |
363 | #endif | |
1c79356b A |
364 | |
365 | /* | |
366 | * A recursive form of vm_region which probes submaps withint the | |
367 | * address space. | |
368 | */ | |
369 | routine vm_region_recurse( | |
370 | target_task : vm_map_t; | |
371 | inout address : vm_address_t; | |
372 | out size : vm_size_t; | |
373 | inout nesting_depth : natural_t; | |
374 | out info : vm_region_recurse_info_t,CountInOut); | |
375 | ||
376 | ||
377 | /* | |
378 | * The routines below are temporary, meant for transitional use | |
379 | * as their counterparts are moved from 32 to 64 bit data path | |
380 | */ | |
381 | ||
382 | ||
383 | routine vm_region_recurse_64( | |
384 | target_task : vm_map_t; | |
385 | inout address : vm_address_t; | |
386 | out size : vm_size_t; | |
387 | inout nesting_depth : natural_t; | |
91447636 | 388 | out info : vm_region_recurse_info_t,CountInOut); |
1c79356b A |
389 | |
390 | routine mach_vm_region_info_64( | |
391 | task : vm_map_t; | |
392 | address : vm_address_t; | |
393 | out region : vm_info_region_64_t; | |
394 | out objects : vm_info_object_array_t); | |
395 | ||
396 | routine vm_region_64( | |
397 | target_task : vm_map_t; | |
398 | inout address : vm_address_t; | |
399 | out size : vm_size_t; | |
400 | flavor : vm_region_flavor_t; | |
91447636 | 401 | out info : vm_region_info_t, CountInOut; |
1c79356b A |
402 | out object_name : memory_object_name_t = |
403 | MACH_MSG_TYPE_MOVE_SEND | |
404 | ctype: mach_port_t); | |
405 | ||
406 | routine mach_make_memory_entry_64( | |
407 | target_task :vm_map_t; | |
408 | inout size :memory_object_size_t; | |
409 | offset :memory_object_offset_t; | |
410 | permission :vm_prot_t; | |
411 | out object_handle :mach_port_move_send_t; | |
412 | parent_entry :mem_entry_name_port_t); | |
413 | ||
414 | ||
415 | ||
416 | routine vm_map_64( | |
417 | target_task : vm_task_entry_t; | |
418 | inout address : vm_address_t; | |
419 | size : vm_size_t; | |
420 | mask : vm_address_t; | |
421 | flags : int; | |
0b4e3aa0 | 422 | object : mem_entry_name_port_t; |
1c79356b A |
423 | offset : memory_object_offset_t; |
424 | copy : boolean_t; | |
425 | cur_protection : vm_prot_t; | |
426 | max_protection : vm_prot_t; | |
427 | inheritance : vm_inherit_t); | |
428 | ||
91447636 A |
429 | #if 0 |
430 | /* | |
431 | * The UPL interfaces are not ready for user-level export. | |
432 | */ | |
0b4e3aa0 A |
433 | routine vm_map_get_upl( |
434 | target_task : vm_map_t; | |
435 | address : vm_address_t; | |
436 | inout size : vm_size_t; | |
437 | out upl : upl_t; | |
438 | out page_info : upl_page_info_array_t, CountInOut; | |
439 | inout flags : integer_t; | |
440 | force_data_sync : integer_t); | |
441 | ||
442 | routine vm_upl_map( | |
443 | target_task : vm_map_t; | |
444 | upl : upl_t; | |
445 | inout address : vm_address_t); | |
446 | ||
447 | routine vm_upl_unmap( | |
448 | target_task : vm_map_t; | |
449 | upl : upl_t); | |
91447636 A |
450 | #else |
451 | skip; /* was vm_map_get_upl */ | |
452 | skip; /* was vm_upl_map */ | |
453 | skip; /* was vm_upl_unmap */ | |
454 | #endif | |
455 | ||
456 | /* | |
457 | * Control behavior and investigate state of a "purgable" object in | |
458 | * the virtual address space of the target task. A purgable object is | |
459 | * created via a call to vm_allocate() with VM_FLAGS_PURGABLE | |
460 | * specified. See the routine implementation for a complete | |
461 | * definition of the routine. | |
462 | */ | |
463 | routine vm_purgable_control( | |
464 | target_task : vm_map_t; | |
465 | address : vm_address_t; | |
466 | control : vm_purgable_t; | |
467 | inout state : int); | |
468 | ||
0b4e3aa0 | 469 |