]>
Commit | Line | Data |
---|---|---|
91447636 | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2004-2007 Apple Inc. All rights reserved. |
91447636 | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
91447636 | 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 | #ifdef XNU_KERNEL_PRIVATE | |
30 | ||
31 | #ifndef _VM_VM_PROTOS_H_ | |
32 | #define _VM_VM_PROTOS_H_ | |
33 | ||
34 | #include <mach/mach_types.h> | |
35 | #include <kern/kern_types.h> | |
36 | ||
37 | /* | |
38 | * This file contains various type definitions and routine prototypes | |
39 | * that are needed to avoid compilation warnings for VM code (in osfmk, | |
40 | * default_pager and bsd). | |
41 | * Most of these should eventually go into more appropriate header files. | |
42 | * | |
43 | * Include it after all other header files since it doesn't include any | |
44 | * type definitions and it works around some conflicts with other header | |
45 | * files. | |
46 | */ | |
47 | ||
48 | /* | |
49 | * iokit | |
50 | */ | |
51 | extern kern_return_t device_data_action( | |
b0d623f7 | 52 | uintptr_t device_handle, |
91447636 A |
53 | ipc_port_t device_pager, |
54 | vm_prot_t protection, | |
55 | vm_object_offset_t offset, | |
56 | vm_size_t size); | |
57 | ||
58 | extern kern_return_t device_close( | |
b0d623f7 | 59 | uintptr_t device_handle); |
91447636 A |
60 | |
61 | /* | |
62 | * default_pager | |
63 | */ | |
64 | extern int start_def_pager( | |
65 | char *bs_device); | |
0c530ab8 | 66 | extern int default_pager_init_flag; |
91447636 A |
67 | |
68 | /* | |
69 | * osfmk | |
70 | */ | |
91447636 A |
71 | #ifndef _IPC_IPC_PORT_H_ |
72 | extern mach_port_name_t ipc_port_copyout_send( | |
73 | ipc_port_t sright, | |
74 | ipc_space_t space); | |
75 | extern task_t port_name_to_task( | |
76 | mach_port_name_t name); | |
77 | #endif /* _IPC_IPC_PORT_H_ */ | |
78 | ||
79 | extern ipc_space_t get_task_ipcspace( | |
80 | task_t t); | |
81 | ||
82 | /* Some loose-ends VM stuff */ | |
83 | ||
84 | extern vm_map_t kalloc_map; | |
85 | extern vm_size_t msg_ool_size_small; | |
86 | extern vm_map_t zone_map; | |
87 | ||
88 | extern void consider_machine_adjust(void); | |
89 | extern pmap_t get_map_pmap(vm_map_t); | |
90 | extern vm_map_offset_t get_map_min(vm_map_t); | |
91 | extern vm_map_offset_t get_map_max(vm_map_t); | |
92 | extern vm_map_size_t get_vmmap_size(vm_map_t); | |
93 | extern int get_vmmap_entries(vm_map_t); | |
94 | ||
95 | extern boolean_t coredumpok(vm_map_t map, vm_offset_t va); | |
96 | ||
97 | /* | |
98 | * VM routines that used to be published to | |
99 | * user space, and are now restricted to the kernel. | |
100 | * | |
101 | * They should eventually go away entirely - | |
102 | * to be replaced with standard vm_map() and | |
103 | * vm_deallocate() calls. | |
104 | */ | |
105 | ||
106 | extern kern_return_t vm_upl_map | |
107 | ( | |
108 | vm_map_t target_task, | |
109 | upl_t upl, | |
110 | vm_address_t *address | |
111 | ); | |
112 | ||
113 | extern kern_return_t vm_upl_unmap | |
114 | ( | |
115 | vm_map_t target_task, | |
116 | upl_t upl | |
117 | ); | |
118 | ||
119 | extern kern_return_t vm_region_object_create | |
120 | ( | |
121 | vm_map_t target_task, | |
122 | vm_size_t size, | |
123 | ipc_port_t *object_handle | |
124 | ); | |
125 | ||
126 | extern mach_vm_offset_t mach_get_vm_start(vm_map_t); | |
127 | extern mach_vm_offset_t mach_get_vm_end(vm_map_t); | |
128 | ||
593a1d5f A |
129 | #if CONFIG_CODE_DECRYPTION |
130 | struct pager_crypt_info; | |
0c530ab8 | 131 | extern kern_return_t vm_map_apple_protected( |
593a1d5f A |
132 | vm_map_t map, |
133 | vm_map_offset_t start, | |
134 | vm_map_offset_t end, | |
135 | struct pager_crypt_info *crypt_info); | |
0c530ab8 | 136 | extern void apple_protect_pager_bootstrap(void); |
593a1d5f A |
137 | extern memory_object_t apple_protect_pager_setup(vm_object_t backing_object, |
138 | struct pager_crypt_info *crypt_info); | |
139 | #endif /* CONFIG_CODE_DECRYPTION */ | |
0c530ab8 | 140 | |
b0d623f7 A |
141 | struct vnode; |
142 | extern void swapfile_pager_bootstrap(void); | |
143 | extern memory_object_t swapfile_pager_setup(struct vnode *vp); | |
144 | extern memory_object_control_t swapfile_pager_control(memory_object_t mem_obj); | |
145 | ||
91447636 A |
146 | |
147 | /* | |
148 | * bsd | |
149 | */ | |
150 | struct vnode; | |
91447636 A |
151 | extern void vnode_pager_shutdown(void); |
152 | extern void *upl_get_internal_page_list( | |
153 | upl_t upl); | |
b0d623f7 | 154 | |
91447636 A |
155 | typedef int pager_return_t; |
156 | extern pager_return_t vnode_pagein( | |
157 | struct vnode *, upl_t, | |
b0d623f7 A |
158 | upl_offset_t, vm_object_offset_t, |
159 | upl_size_t, int, int *); | |
91447636 A |
160 | extern pager_return_t vnode_pageout( |
161 | struct vnode *, upl_t, | |
b0d623f7 A |
162 | upl_offset_t, vm_object_offset_t, |
163 | upl_size_t, int, int *); | |
6d2010ae | 164 | extern uint32_t vnode_trim (struct vnode *, int64_t offset, unsigned long len); |
91447636 A |
165 | extern memory_object_t vnode_pager_setup( |
166 | struct vnode *, memory_object_t); | |
167 | extern vm_object_offset_t vnode_pager_get_filesize( | |
168 | struct vnode *); | |
b0d623f7 A |
169 | extern uint32_t vnode_pager_isinuse( |
170 | struct vnode *); | |
6d2010ae A |
171 | extern boolean_t vnode_pager_isSSD( |
172 | struct vnode *); | |
173 | extern void vnode_pager_throttle( | |
174 | void); | |
b0d623f7 A |
175 | extern uint32_t vnode_pager_return_hard_throttle_limit( |
176 | struct vnode *, | |
177 | uint32_t *, | |
178 | uint32_t); | |
0c530ab8 A |
179 | extern kern_return_t vnode_pager_get_pathname( |
180 | struct vnode *vp, | |
181 | char *pathname, | |
182 | vm_size_t *length_p); | |
183 | extern kern_return_t vnode_pager_get_filename( | |
184 | struct vnode *vp, | |
2d21ac55 A |
185 | const char **filename); |
186 | extern kern_return_t vnode_pager_get_cs_blobs( | |
187 | struct vnode *vp, | |
188 | void **blobs); | |
6d2010ae A |
189 | |
190 | #if CHECK_CS_VALIDATION_BITMAP | |
191 | /* used by the vnode_pager_cs_validation_bitmap routine*/ | |
192 | #define CS_BITMAP_SET 1 | |
193 | #define CS_BITMAP_CLEAR 2 | |
194 | #define CS_BITMAP_CHECK 3 | |
195 | ||
196 | #endif /* CHECK_CS_VALIDATION_BITMAP */ | |
b0d623f7 | 197 | |
2d21ac55 | 198 | extern void vnode_pager_bootstrap(void) __attribute__((section("__TEXT, initcode"))); |
91447636 A |
199 | extern kern_return_t |
200 | vnode_pager_data_unlock( | |
201 | memory_object_t mem_obj, | |
202 | memory_object_offset_t offset, | |
b0d623f7 | 203 | memory_object_size_t size, |
91447636 A |
204 | vm_prot_t desired_access); |
205 | extern kern_return_t vnode_pager_init( | |
206 | memory_object_t, | |
207 | memory_object_control_t, | |
b0d623f7 | 208 | memory_object_cluster_size_t); |
91447636 A |
209 | extern kern_return_t vnode_pager_get_object_size( |
210 | memory_object_t, | |
211 | memory_object_offset_t *); | |
b0d623f7 A |
212 | extern kern_return_t vnode_pager_get_isinuse( |
213 | memory_object_t, | |
214 | uint32_t *); | |
6d2010ae A |
215 | extern kern_return_t vnode_pager_get_isSSD( |
216 | memory_object_t, | |
217 | boolean_t *); | |
b0d623f7 A |
218 | extern kern_return_t vnode_pager_check_hard_throttle( |
219 | memory_object_t, | |
220 | uint32_t *, | |
221 | uint32_t); | |
0c530ab8 A |
222 | extern kern_return_t vnode_pager_get_object_pathname( |
223 | memory_object_t mem_obj, | |
224 | char *pathname, | |
225 | vm_size_t *length_p); | |
226 | extern kern_return_t vnode_pager_get_object_filename( | |
227 | memory_object_t mem_obj, | |
2d21ac55 A |
228 | const char **filename); |
229 | extern kern_return_t vnode_pager_get_object_cs_blobs( | |
230 | memory_object_t mem_obj, | |
231 | void **blobs); | |
6d2010ae A |
232 | |
233 | #if CHECK_CS_VALIDATION_BITMAP | |
234 | extern kern_return_t vnode_pager_cs_check_validation_bitmap( | |
235 | memory_object_t mem_obj, | |
236 | memory_object_offset_t offset, | |
237 | int optype); | |
238 | #endif /*CHECK_CS_VALIDATION_BITMAP*/ | |
239 | ||
240 | extern kern_return_t ubc_cs_check_validation_bitmap ( | |
241 | struct vnode *vp, | |
242 | memory_object_offset_t offset, | |
243 | int optype); | |
244 | ||
91447636 A |
245 | extern kern_return_t vnode_pager_data_request( |
246 | memory_object_t, | |
2d21ac55 | 247 | memory_object_offset_t, |
b0d623f7 | 248 | memory_object_cluster_size_t, |
2d21ac55 A |
249 | vm_prot_t, |
250 | memory_object_fault_info_t); | |
91447636 A |
251 | extern kern_return_t vnode_pager_data_return( |
252 | memory_object_t, | |
253 | memory_object_offset_t, | |
b0d623f7 | 254 | memory_object_cluster_size_t, |
91447636 A |
255 | memory_object_offset_t *, |
256 | int *, | |
257 | boolean_t, | |
258 | boolean_t, | |
259 | int); | |
260 | extern kern_return_t vnode_pager_data_initialize( | |
261 | memory_object_t, | |
262 | memory_object_offset_t, | |
b0d623f7 | 263 | memory_object_cluster_size_t); |
91447636 A |
264 | extern void vnode_pager_reference( |
265 | memory_object_t mem_obj); | |
266 | extern kern_return_t vnode_pager_synchronize( | |
267 | memory_object_t mem_obj, | |
268 | memory_object_offset_t offset, | |
b0d623f7 | 269 | memory_object_size_t length, |
91447636 | 270 | vm_sync_t sync_flags); |
593a1d5f A |
271 | extern kern_return_t vnode_pager_map( |
272 | memory_object_t mem_obj, | |
273 | vm_prot_t prot); | |
274 | extern kern_return_t vnode_pager_last_unmap( | |
91447636 A |
275 | memory_object_t mem_obj); |
276 | extern void vnode_pager_deallocate( | |
277 | memory_object_t); | |
278 | extern kern_return_t vnode_pager_terminate( | |
279 | memory_object_t); | |
280 | extern void vnode_pager_vrele( | |
281 | struct vnode *vp); | |
282 | extern void vnode_pager_release_from_cache( | |
283 | int *); | |
593a1d5f A |
284 | extern int ubc_map( |
285 | struct vnode *vp, | |
286 | int flags); | |
91447636 A |
287 | extern void ubc_unmap( |
288 | struct vnode *vp); | |
289 | ||
b0d623f7 A |
290 | struct vm_map_entry; |
291 | extern struct vm_object *find_vnode_object(struct vm_map_entry *entry); | |
292 | ||
91447636 A |
293 | extern void dp_memory_object_reference(memory_object_t); |
294 | extern void dp_memory_object_deallocate(memory_object_t); | |
295 | #ifndef _memory_object_server_ | |
296 | extern kern_return_t dp_memory_object_init(memory_object_t, | |
297 | memory_object_control_t, | |
b0d623f7 | 298 | memory_object_cluster_size_t); |
91447636 A |
299 | extern kern_return_t dp_memory_object_terminate(memory_object_t); |
300 | extern kern_return_t dp_memory_object_data_request(memory_object_t, | |
2d21ac55 | 301 | memory_object_offset_t, |
b0d623f7 | 302 | memory_object_cluster_size_t, |
2d21ac55 A |
303 | vm_prot_t, |
304 | memory_object_fault_info_t); | |
91447636 A |
305 | extern kern_return_t dp_memory_object_data_return(memory_object_t, |
306 | memory_object_offset_t, | |
b0d623f7 A |
307 | memory_object_cluster_size_t, |
308 | memory_object_offset_t *, | |
91447636 A |
309 | int *, |
310 | boolean_t, | |
311 | boolean_t, | |
312 | int); | |
313 | extern kern_return_t dp_memory_object_data_initialize(memory_object_t, | |
314 | memory_object_offset_t, | |
b0d623f7 | 315 | memory_object_cluster_size_t); |
91447636 A |
316 | extern kern_return_t dp_memory_object_data_unlock(memory_object_t, |
317 | memory_object_offset_t, | |
b0d623f7 | 318 | memory_object_size_t, |
91447636 A |
319 | vm_prot_t); |
320 | extern kern_return_t dp_memory_object_synchronize(memory_object_t, | |
321 | memory_object_offset_t, | |
b0d623f7 | 322 | memory_object_size_t, |
91447636 | 323 | vm_sync_t); |
593a1d5f A |
324 | extern kern_return_t dp_memory_object_map(memory_object_t, |
325 | vm_prot_t); | |
326 | extern kern_return_t dp_memory_object_last_unmap(memory_object_t); | |
91447636 A |
327 | #endif /* _memory_object_server_ */ |
328 | #ifndef _memory_object_default_server_ | |
329 | extern kern_return_t default_pager_memory_object_create( | |
330 | memory_object_default_t, | |
331 | vm_size_t, | |
332 | memory_object_t *); | |
333 | #endif /* _memory_object_default_server_ */ | |
334 | ||
6d2010ae A |
335 | #if CONFIG_FREEZE |
336 | extern unsigned int default_pager_swap_pages_free(void); | |
316670eb A |
337 | struct default_freezer_handle; |
338 | struct vm_page; | |
339 | __private_extern__ void default_freezer_init(void); | |
340 | __private_extern__ struct default_freezer_handle* default_freezer_handle_allocate(void); | |
341 | __private_extern__ kern_return_t | |
342 | default_freezer_handle_init( | |
343 | struct default_freezer_handle *df_handle); | |
344 | __private_extern__ void | |
345 | default_freezer_handle_deallocate( | |
346 | struct default_freezer_handle *df_handle); | |
347 | __private_extern__ void | |
348 | default_freezer_pageout( | |
349 | struct default_freezer_handle *df_handle); | |
350 | __private_extern__ kern_return_t | |
351 | default_freezer_pack( | |
352 | unsigned int *purgeable_count, | |
353 | unsigned int *wired_count, | |
354 | unsigned int *clean_count, | |
355 | unsigned int *dirty_count, | |
356 | unsigned int dirty_budget, | |
357 | boolean_t *shared, | |
358 | vm_object_t src_object, | |
359 | struct default_freezer_handle *df_handle); | |
360 | __private_extern__ void | |
361 | default_freezer_unpack( | |
362 | struct default_freezer_handle *df_handle); | |
363 | __private_extern__ void | |
364 | default_freezer_pack_page( | |
365 | struct vm_page* p, | |
366 | struct default_freezer_handle *df_handle); | |
367 | ||
368 | #endif /* CONFIG_FREEZE */ | |
6d2010ae | 369 | |
91447636 A |
370 | extern void device_pager_reference(memory_object_t); |
371 | extern void device_pager_deallocate(memory_object_t); | |
372 | extern kern_return_t device_pager_init(memory_object_t, | |
373 | memory_object_control_t, | |
b0d623f7 | 374 | memory_object_cluster_size_t); |
91447636 A |
375 | extern kern_return_t device_pager_terminate(memory_object_t); |
376 | extern kern_return_t device_pager_data_request(memory_object_t, | |
377 | memory_object_offset_t, | |
b0d623f7 | 378 | memory_object_cluster_size_t, |
2d21ac55 A |
379 | vm_prot_t, |
380 | memory_object_fault_info_t); | |
91447636 A |
381 | extern kern_return_t device_pager_data_return(memory_object_t, |
382 | memory_object_offset_t, | |
b0d623f7 | 383 | memory_object_cluster_size_t, |
0c530ab8 A |
384 | memory_object_offset_t *, |
385 | int *, | |
91447636 A |
386 | boolean_t, |
387 | boolean_t, | |
388 | int); | |
389 | extern kern_return_t device_pager_data_initialize(memory_object_t, | |
390 | memory_object_offset_t, | |
b0d623f7 | 391 | memory_object_cluster_size_t); |
91447636 A |
392 | extern kern_return_t device_pager_data_unlock(memory_object_t, |
393 | memory_object_offset_t, | |
b0d623f7 | 394 | memory_object_size_t, |
91447636 A |
395 | vm_prot_t); |
396 | extern kern_return_t device_pager_synchronize(memory_object_t, | |
397 | memory_object_offset_t, | |
b0d623f7 | 398 | memory_object_size_t, |
91447636 | 399 | vm_sync_t); |
593a1d5f A |
400 | extern kern_return_t device_pager_map(memory_object_t, vm_prot_t); |
401 | extern kern_return_t device_pager_last_unmap(memory_object_t); | |
91447636 A |
402 | extern kern_return_t device_pager_populate_object( |
403 | memory_object_t device, | |
404 | memory_object_offset_t offset, | |
405 | ppnum_t page_num, | |
406 | vm_size_t size); | |
407 | extern memory_object_t device_pager_setup( | |
408 | memory_object_t, | |
b0d623f7 | 409 | uintptr_t, |
91447636 A |
410 | vm_size_t, |
411 | int); | |
2d21ac55 | 412 | extern void device_pager_bootstrap(void) __attribute__((section("__TEXT, initcode"))); |
91447636 A |
413 | |
414 | extern kern_return_t memory_object_create_named( | |
415 | memory_object_t pager, | |
416 | memory_object_offset_t size, | |
417 | memory_object_control_t *control); | |
418 | ||
b0d623f7 A |
419 | struct macx_triggers_args; |
420 | extern int mach_macx_triggers( | |
421 | struct macx_triggers_args *args); | |
91447636 A |
422 | |
423 | extern int macx_swapinfo( | |
424 | memory_object_size_t *total_p, | |
425 | memory_object_size_t *avail_p, | |
426 | vm_size_t *pagesize_p, | |
427 | boolean_t *encrypted_p); | |
428 | ||
2d21ac55 | 429 | extern void log_stack_execution_failure(addr64_t vaddr, vm_prot_t prot); |
b0d623f7 A |
430 | extern void log_unnest_badness(vm_map_t, vm_map_offset_t, vm_map_offset_t); |
431 | ||
432 | extern int cs_allow_invalid(struct proc *p); | |
593a1d5f | 433 | extern int cs_invalid_page(addr64_t vaddr); |
2d21ac55 | 434 | extern boolean_t cs_validate_page(void *blobs, |
316670eb | 435 | memory_object_t pager, |
2d21ac55 A |
436 | memory_object_offset_t offset, |
437 | const void *data, | |
438 | boolean_t *tainted); | |
439 | ||
440 | extern kern_return_t mach_memory_entry_purgable_control( | |
441 | ipc_port_t entry_port, | |
442 | vm_purgable_t control, | |
443 | int *state); | |
444 | ||
445 | extern kern_return_t mach_memory_entry_page_op( | |
446 | ipc_port_t entry_port, | |
447 | vm_object_offset_t offset, | |
448 | int ops, | |
449 | ppnum_t *phys_entry, | |
450 | int *flags); | |
451 | ||
452 | extern kern_return_t mach_memory_entry_range_op( | |
453 | ipc_port_t entry_port, | |
454 | vm_object_offset_t offset_beg, | |
455 | vm_object_offset_t offset_end, | |
456 | int ops, | |
457 | int *range); | |
458 | ||
459 | extern void mach_memory_entry_port_release(ipc_port_t port); | |
460 | extern void mach_destroy_memory_entry(ipc_port_t port); | |
461 | extern kern_return_t mach_memory_entry_allocate( | |
462 | struct vm_named_entry **user_entry_p, | |
463 | ipc_port_t *user_handle_p); | |
464 | ||
465 | extern void vm_paging_map_init(void); | |
0c530ab8 | 466 | |
b0d623f7 A |
467 | extern int macx_backing_store_compaction(int flags); |
468 | extern unsigned int mach_vm_ctl_page_free_wanted(void); | |
469 | ||
470 | extern void no_paging_space_action(void); | |
6d2010ae A |
471 | |
472 | #define VM_TOGGLE_CLEAR 0 | |
473 | #define VM_TOGGLE_SET 1 | |
474 | #define VM_TOGGLE_GETVALUE 999 | |
475 | int vm_toggle_entry_reuse(int, int*); | |
91447636 A |
476 | #endif /* _VM_VM_PROTOS_H_ */ |
477 | ||
478 | #endif /* XNU_KERNEL_PRIVATE */ |