]>
Commit | Line | Data |
---|---|---|
91447636 A |
1 | /* |
2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. | |
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. | |
91447636 | 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 | |
91447636 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. | |
91447636 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 | /* | |
53 | * File: mach/mach_vm.defs | |
54 | * | |
55 | * Exported kernel VM calls (for any task on the platform). | |
56 | */ | |
57 | ||
58 | subsystem | |
59 | #if KERNEL_SERVER | |
60 | KernelServer | |
61 | #endif /* KERNEL_SERVER */ | |
62 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
63 | mach_vm | |
64 | #else | |
65 | vm_map_lp64_local | |
66 | #endif | |
67 | 4800; | |
68 | ||
69 | #include <mach/std_types.defs> | |
70 | #include <mach/mach_types.defs> | |
71 | #include <mach_debug/mach_debug_types.defs> | |
72 | ||
73 | /* | |
74 | * Allocate zero-filled memory in the address space | |
75 | * of the target task, either at the specified address, | |
76 | * or wherever space can be found (controlled by flags), | |
77 | * of the specified size. The address at which the | |
78 | * allocation actually took place is returned. | |
79 | */ | |
80 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
81 | routine mach_vm_allocate( | |
82 | #else | |
83 | routine vm_allocate( | |
84 | #endif | |
85 | target : vm_task_entry_t; | |
86 | inout address : mach_vm_address_t; | |
87 | size : mach_vm_size_t; | |
88 | flags : int); | |
89 | ||
90 | /* | |
91 | * Deallocate the specified range from the virtual | |
92 | * address space of the target virtual memory map. | |
93 | */ | |
94 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
95 | routine mach_vm_deallocate( | |
96 | #else | |
97 | routine vm_deallocate( | |
98 | #endif | |
99 | target : vm_task_entry_t; | |
100 | address : mach_vm_address_t; | |
101 | size : mach_vm_size_t); | |
102 | ||
103 | /* | |
104 | * Set the current or maximum protection attribute | |
105 | * for the specified range of the virtual address | |
106 | * space of the target virtual memory map. The current | |
107 | * protection limits the memory access rights of threads | |
108 | * within the map; the maximum protection limits the accesses | |
109 | * that may be given in the current protection. | |
110 | * Protections are specified as a set of {read, write, execute} | |
111 | * *permissions*. | |
112 | */ | |
113 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
114 | routine mach_vm_protect( | |
115 | #else | |
116 | routine vm_protect( | |
117 | #endif | |
118 | target_task : vm_task_entry_t; | |
119 | address : mach_vm_address_t; | |
120 | size : mach_vm_size_t; | |
121 | set_maximum : boolean_t; | |
122 | new_protection : vm_prot_t); | |
123 | ||
124 | /* | |
125 | * Set the inheritance attribute for the specified range | |
126 | * of the virtual address space of the target address space. | |
127 | * The inheritance value is one of {none, copy, share}, and | |
128 | * specifies how the child address space should acquire | |
129 | * this memory at the time of a task_create call. | |
130 | */ | |
131 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
132 | routine mach_vm_inherit( | |
133 | #else | |
134 | routine vm_inherit( | |
135 | #endif | |
136 | target_task : vm_task_entry_t; | |
137 | address : mach_vm_address_t; | |
138 | size : mach_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 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
149 | routine mach_vm_read( | |
150 | #else | |
151 | routine vm_read( | |
152 | #endif | |
153 | target_task : vm_map_t; | |
154 | address : mach_vm_address_t; | |
155 | size : mach_vm_size_t; | |
156 | out data : pointer_t); | |
157 | ||
158 | /* | |
159 | * List corrollary to vm_read, returns mapped contents of specified | |
160 | * ranges within target address space. | |
161 | */ | |
162 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
163 | routine mach_vm_read_list( | |
164 | #else | |
165 | routine vm_read_list( | |
166 | #endif | |
167 | target_task : vm_map_t; | |
168 | inout data_list : mach_vm_read_entry_t; | |
169 | count : natural_t); | |
170 | ||
171 | /* | |
172 | * Writes the contents of the specified range of the | |
173 | * virtual address space of the target task. [The | |
174 | * range must be aligned on a virtual page boundary, | |
175 | * and must be a multiple of pages in extent. The | |
176 | * protection on the specified range must permit writing.] | |
177 | */ | |
178 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
179 | routine mach_vm_write( | |
180 | #else | |
181 | routine vm_write( | |
182 | #endif | |
183 | target_task : vm_map_t; | |
184 | address : mach_vm_address_t; | |
185 | data : pointer_t); | |
186 | ||
187 | /* | |
188 | * Copy the contents of the source range of the virtual | |
189 | * address space of the target task to the destination | |
190 | * range in that same address space. [Both of the | |
191 | * ranges must be aligned on a virtual page boundary, | |
192 | * and must be multiples of pages in extent. The | |
193 | * protection on the source range must permit reading, | |
194 | * and the protection on the destination range must | |
195 | * permit writing.] | |
196 | */ | |
197 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
198 | routine mach_vm_copy( | |
199 | #else | |
200 | routine vm_copy( | |
201 | #endif | |
202 | target_task : vm_map_t; | |
203 | source_address : mach_vm_address_t; | |
204 | size : mach_vm_size_t; | |
205 | dest_address : mach_vm_address_t); | |
206 | ||
207 | /* | |
208 | * Returns the contents of the specified range of the | |
209 | * virtual address space of the target task. [There | |
210 | * are no alignment restrictions, and the results will | |
211 | * overwrite the area pointed to by data - which must | |
212 | * already exist. The protection on the specified range | |
213 | * must permit reading.] | |
214 | */ | |
215 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
216 | routine mach_vm_read_overwrite( | |
217 | #else | |
218 | routine vm_read_overwrite( | |
219 | #endif | |
220 | target_task : vm_map_t; | |
221 | address : mach_vm_address_t; | |
222 | size : mach_vm_size_t; | |
223 | data : mach_vm_address_t; | |
224 | out outsize : mach_vm_size_t); | |
225 | ||
226 | ||
227 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
228 | routine mach_vm_msync( | |
229 | #else | |
230 | routine vm_msync( | |
231 | #endif | |
232 | target_task : vm_map_t; | |
233 | address : mach_vm_address_t; | |
234 | size : mach_vm_size_t; | |
235 | sync_flags : vm_sync_t ); | |
236 | ||
237 | /* | |
238 | * Set the paging behavior attribute for the specified range | |
239 | * of the virtual address space of the target task. | |
240 | * The behavior value is one of {default, random, forward | |
241 | * sequential, reverse sequential} and indicates the expected | |
242 | * page reference pattern for the specified range. | |
243 | */ | |
244 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
245 | routine mach_vm_behavior_set( | |
246 | #else | |
247 | routine vm_behavior_set( | |
248 | #endif | |
249 | target_task : vm_map_t; | |
250 | address : mach_vm_address_t; | |
251 | size : mach_vm_size_t; | |
252 | new_behavior : vm_behavior_t); | |
253 | ||
254 | ||
255 | /* | |
256 | * Map a user-supplie memory object into the virtual address | |
257 | * space of the target task. If desired (anywhere is TRUE), | |
258 | * the kernel will find a suitable address range of the | |
259 | * specified size; else, the specific address will be allocated. | |
260 | * | |
261 | * The beginning address of the range will be aligned on a virtual | |
262 | * page boundary, be at or beyond the address specified, and | |
263 | * meet the mask requirements (bits turned on in the mask must not | |
264 | * be turned on in the result); the size of the range, in bytes, | |
265 | * will be rounded up to an integral number of virtual pages. | |
266 | * | |
267 | * The memory in the resulting range will be associated with the | |
268 | * specified memory object, with the beginning of the memory range | |
269 | * referring to the specified offset into the memory object. | |
270 | * | |
271 | * The mapping will take the current and maximum protections and | |
272 | * the inheritance attributes specified; see the vm_protect and | |
273 | * vm_inherit calls for a description of these attributes. | |
274 | * | |
275 | * If desired (copy is TRUE), the memory range will be filled | |
276 | * with a copy of the data from the memory object; this copy will | |
277 | * be private to this mapping in this target task. Otherwise, | |
278 | * the memory in this mapping will be shared with other mappings | |
279 | * of the same memory object at the same offset (in this task or | |
280 | * in other tasks). [The Mach kernel only enforces shared memory | |
281 | * consistency among mappings on one host with similar page alignments. | |
282 | * The user-defined memory manager for this object is responsible | |
283 | * for further consistency.] | |
284 | */ | |
285 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
286 | routine mach_vm_map( | |
287 | #else | |
288 | routine vm_map( | |
289 | #endif | |
290 | target_task : vm_task_entry_t; | |
291 | inout address : mach_vm_address_t; | |
292 | size : mach_vm_size_t; | |
293 | mask : mach_vm_offset_t; | |
294 | flags : int; | |
295 | object : mem_entry_name_port_t; | |
296 | offset : memory_object_offset_t; | |
297 | copy : boolean_t; | |
298 | cur_protection : vm_prot_t; | |
299 | max_protection : vm_prot_t; | |
300 | inheritance : vm_inherit_t); | |
301 | ||
302 | /* | |
303 | * Set/Get special properties of memory associated | |
304 | * to some virtual address range, such as cachability, | |
305 | * migrability, replicability. Machine-dependent. | |
306 | */ | |
307 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
308 | routine mach_vm_machine_attribute( | |
309 | #else | |
310 | routine vm_machine_attribute( | |
311 | #endif | |
312 | target_task : vm_map_t; | |
313 | address : mach_vm_address_t; | |
314 | size : mach_vm_size_t; | |
315 | attribute : vm_machine_attribute_t; | |
316 | inout value : vm_machine_attribute_val_t); | |
317 | ||
318 | /* | |
319 | * Map portion of a task's address space. | |
320 | */ | |
321 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
322 | routine mach_vm_remap( | |
323 | #else | |
324 | routine vm_remap( | |
325 | #endif | |
326 | target_task : vm_map_t; | |
327 | inout target_address : mach_vm_address_t; | |
328 | size : mach_vm_size_t; | |
329 | mask : mach_vm_offset_t; | |
330 | anywhere : boolean_t; | |
331 | src_task : vm_map_t; | |
332 | src_address : mach_vm_address_t; | |
333 | copy : boolean_t; | |
334 | out cur_protection : vm_prot_t; | |
335 | out max_protection : vm_prot_t; | |
336 | inheritance : vm_inherit_t); | |
337 | ||
338 | /* | |
339 | * Give the caller information on the given location in a virtual | |
340 | * address space. If a page is mapped return ref and dirty info. | |
341 | */ | |
342 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
343 | routine mach_vm_page_query( | |
344 | #else | |
345 | routine vm_map_page_query( | |
346 | #endif | |
347 | target_map :vm_map_t; | |
348 | offset :mach_vm_offset_t; | |
349 | out disposition :integer_t; | |
350 | out ref_count :integer_t); | |
351 | ||
352 | ||
353 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
354 | routine mach_vm_region_recurse( | |
355 | #else | |
356 | routine vm_region_recurse_64( | |
357 | #endif | |
358 | target_task : vm_map_t; | |
359 | inout address : mach_vm_address_t; | |
360 | out size : mach_vm_size_t; | |
361 | inout nesting_depth : natural_t; | |
362 | out info : vm_region_recurse_info_t,CountInOut); | |
363 | ||
364 | /* | |
365 | * Returns information about the contents of the virtual | |
366 | * address space of the target task at the specified | |
367 | * address. The returned protection, inheritance, sharing | |
368 | * and memory object values apply to the entire range described | |
369 | * by the address range returned; the memory object offset | |
370 | * corresponds to the beginning of the address range. | |
371 | * [If the specified address is not allocated, the next | |
372 | * highest address range is described. If no addresses beyond | |
373 | * the one specified are allocated, the call returns KERN_NO_SPACE.] | |
374 | */ | |
375 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
376 | routine mach_vm_region( | |
377 | #else | |
378 | routine vm_region_64( | |
379 | #endif | |
380 | target_task : vm_map_t; | |
381 | inout address : mach_vm_address_t; | |
382 | out size : mach_vm_size_t; | |
383 | flavor : vm_region_flavor_t; | |
384 | out info : vm_region_info_t, CountInOut; | |
385 | out object_name : memory_object_name_t = | |
386 | MACH_MSG_TYPE_MOVE_SEND | |
387 | ctype: mach_port_t); | |
388 | ||
389 | /* | |
390 | * Allow application level processes to create named entries which | |
391 | * correspond to mapped portions of their address space. These named | |
392 | * entries can then be manipulated, shared with other processes in | |
393 | * other address spaces and ultimately mapped in ohter address spaces | |
394 | * | |
395 | * THIS INTERFACE IS STILL EVOLVING. | |
396 | */ | |
397 | #if !defined(_MACH_VM_PUBLISH_AS_LOCAL_) | |
398 | routine _mach_make_memory_entry( | |
399 | #else | |
400 | routine mach_make_memory_entry_64( | |
401 | #endif | |
402 | target_task :vm_map_t; | |
403 | inout size :memory_object_size_t; | |
404 | offset :memory_object_offset_t; | |
405 | permission :vm_prot_t; | |
406 | out object_handle :mem_entry_name_port_move_send_t; | |
407 | parent_handle :mem_entry_name_port_t); | |
408 | ||
409 | ||
410 | /****************************** Legacy section ***************************/ | |
411 | /* The following definitions are exist to provide compatibility with */ | |
412 | /* the legacy APIs. They are no different. We just need to produce */ | |
413 | /* the user-level stub interface for them. */ | |
414 | /****************************** Legacy section ***************************/ | |
415 | ||
416 | ||
417 | /* | |
418 | * These interfaces just aren't supported in the new (wide) model: | |
419 | * | |
420 | * mach_vm_region_info() - | |
421 | * vm_map_pages_info() - | |
422 | * no user-level replacement for these MACH_DEBUG interfaces | |
423 | * vm_map_get_upl() - | |
424 | * no user-level replacement at the moment | |
425 | * vm_region_info() - | |
426 | * use mach_vm_region_info() or vm_region_info_64() | |
427 | * vm_region_recurse() - | |
428 | * use mach_vm_region_recurse() or vm_region_recurse_64() | |
429 | */ | |
430 | ||
431 | /* | |
432 | * The following legacy interfaces are provides as macro wrappers to the new | |
433 | * interfaces. You should strive to use the new ones instead: | |
434 | * | |
435 | * vm_map() - | |
436 | * use mach_vm_map() or vm_map_64() | |
437 | * vm_region() - | |
438 | * use mach_vm_region() or vm_region_64() | |
439 | * mach_make_memory_entry() - | |
440 | * use mach_vm_make_memory_entry() or mach_make_memory_entry_64() | |
441 | */ |