2 * Copyright (c) 2004-2007 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifdef XNU_KERNEL_PRIVATE
31 #ifndef _VM_VM_PROTOS_H_
32 #define _VM_VM_PROTOS_H_
34 #include <mach/mach_types.h>
35 #include <kern/kern_types.h>
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.
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
51 extern kern_return_t
device_data_action(
52 uintptr_t device_handle
,
53 ipc_port_t device_pager
,
55 vm_object_offset_t offset
,
58 extern kern_return_t
device_close(
59 uintptr_t device_handle
);
64 extern int start_def_pager(
66 extern int default_pager_init_flag
;
71 #ifndef _KERN_IPC_TT_H_ /* XXX FBDP */
72 /* these should be exported cleanly from OSFMK since BSD needs them */
73 extern ipc_port_t
convert_task_to_port(
75 extern ipc_port_t
convert_thread_to_port(
77 extern ipc_port_t
convert_task_name_to_port(
78 task_name_t task_name
);
79 #endif /* _KERN_IPC_TT_H_ */
80 #ifndef _IPC_IPC_PORT_H_
81 extern mach_port_name_t
ipc_port_copyout_send(
84 extern task_t
port_name_to_task(
85 mach_port_name_t name
);
86 #endif /* _IPC_IPC_PORT_H_ */
88 extern ipc_space_t
get_task_ipcspace(
91 /* Some loose-ends VM stuff */
93 extern vm_map_t kalloc_map
;
94 extern vm_size_t msg_ool_size_small
;
95 extern vm_map_t zone_map
;
97 extern void consider_machine_adjust(void);
98 extern pmap_t
get_map_pmap(vm_map_t
);
99 extern vm_map_offset_t
get_map_min(vm_map_t
);
100 extern vm_map_offset_t
get_map_max(vm_map_t
);
101 extern vm_map_size_t
get_vmmap_size(vm_map_t
);
102 extern int get_vmmap_entries(vm_map_t
);
104 extern boolean_t
coredumpok(vm_map_t map
, vm_offset_t va
);
107 * VM routines that used to be published to
108 * user space, and are now restricted to the kernel.
110 * They should eventually go away entirely -
111 * to be replaced with standard vm_map() and
112 * vm_deallocate() calls.
115 extern kern_return_t vm_upl_map
117 vm_map_t target_task
,
119 vm_address_t
*address
122 extern kern_return_t vm_upl_unmap
124 vm_map_t target_task
,
128 extern kern_return_t vm_region_object_create
130 vm_map_t target_task
,
132 ipc_port_t
*object_handle
135 extern mach_vm_offset_t
mach_get_vm_start(vm_map_t
);
136 extern mach_vm_offset_t
mach_get_vm_end(vm_map_t
);
139 * Legacy routines to get the start and end for a vm_map_t. They
140 * return them in the vm_offset_t format. So, they should only be
141 * called on maps that are the same size as the kernel map for
144 extern vm_offset_t
get_vm_start(vm_map_t
);
145 extern vm_offset_t
get_vm_end(vm_map_t
);
147 #if CONFIG_CODE_DECRYPTION
148 struct pager_crypt_info
;
149 extern kern_return_t
vm_map_apple_protected(
151 vm_map_offset_t start
,
153 struct pager_crypt_info
*crypt_info
);
154 extern void apple_protect_pager_bootstrap(void);
155 extern memory_object_t
apple_protect_pager_setup(vm_object_t backing_object
,
156 struct pager_crypt_info
*crypt_info
);
157 #endif /* CONFIG_CODE_DECRYPTION */
160 extern void swapfile_pager_bootstrap(void);
161 extern memory_object_t
swapfile_pager_setup(struct vnode
*vp
);
162 extern memory_object_control_t
swapfile_pager_control(memory_object_t mem_obj
);
169 extern void vnode_pager_shutdown(void);
170 extern void *upl_get_internal_page_list(
173 typedef int pager_return_t
;
174 extern pager_return_t
vnode_pagein(
175 struct vnode
*, upl_t
,
176 upl_offset_t
, vm_object_offset_t
,
177 upl_size_t
, int, int *);
178 extern pager_return_t
vnode_pageout(
179 struct vnode
*, upl_t
,
180 upl_offset_t
, vm_object_offset_t
,
181 upl_size_t
, int, int *);
182 extern memory_object_t
vnode_pager_setup(
183 struct vnode
*, memory_object_t
);
184 extern vm_object_offset_t
vnode_pager_get_filesize(
186 extern uint32_t vnode_pager_isinuse(
188 extern uint32_t vnode_pager_return_hard_throttle_limit(
192 extern kern_return_t
vnode_pager_get_pathname(
195 vm_size_t
*length_p
);
196 extern kern_return_t
vnode_pager_get_filename(
198 const char **filename
);
199 extern kern_return_t
vnode_pager_get_cs_blobs(
204 extern void vnode_pager_bootstrap(void) __attribute__((section("__TEXT, initcode")));
206 vnode_pager_data_unlock(
207 memory_object_t mem_obj
,
208 memory_object_offset_t offset
,
209 memory_object_size_t size
,
210 vm_prot_t desired_access
);
211 extern kern_return_t
vnode_pager_init(
213 memory_object_control_t
,
214 memory_object_cluster_size_t
);
215 extern kern_return_t
vnode_pager_get_object_size(
217 memory_object_offset_t
*);
218 extern kern_return_t
vnode_pager_get_isinuse(
221 extern kern_return_t
vnode_pager_check_hard_throttle(
225 extern kern_return_t
vnode_pager_get_object_pathname(
226 memory_object_t mem_obj
,
228 vm_size_t
*length_p
);
229 extern kern_return_t
vnode_pager_get_object_filename(
230 memory_object_t mem_obj
,
231 const char **filename
);
232 extern kern_return_t
vnode_pager_get_object_cs_blobs(
233 memory_object_t mem_obj
,
235 extern kern_return_t
vnode_pager_data_request(
237 memory_object_offset_t
,
238 memory_object_cluster_size_t
,
240 memory_object_fault_info_t
);
241 extern kern_return_t
vnode_pager_data_return(
243 memory_object_offset_t
,
244 memory_object_cluster_size_t
,
245 memory_object_offset_t
*,
250 extern kern_return_t
vnode_pager_data_initialize(
252 memory_object_offset_t
,
253 memory_object_cluster_size_t
);
254 extern void vnode_pager_reference(
255 memory_object_t mem_obj
);
256 extern kern_return_t
vnode_pager_synchronize(
257 memory_object_t mem_obj
,
258 memory_object_offset_t offset
,
259 memory_object_size_t length
,
260 vm_sync_t sync_flags
);
261 extern kern_return_t
vnode_pager_map(
262 memory_object_t mem_obj
,
264 extern kern_return_t
vnode_pager_last_unmap(
265 memory_object_t mem_obj
);
266 extern void vnode_pager_deallocate(
268 extern kern_return_t
vnode_pager_terminate(
270 extern void vnode_pager_vrele(
272 extern void vnode_pager_release_from_cache(
277 extern void ubc_unmap(
281 extern struct vm_object
*find_vnode_object(struct vm_map_entry
*entry
);
283 extern void dp_memory_object_reference(memory_object_t
);
284 extern void dp_memory_object_deallocate(memory_object_t
);
285 #ifndef _memory_object_server_
286 extern kern_return_t
dp_memory_object_init(memory_object_t
,
287 memory_object_control_t
,
288 memory_object_cluster_size_t
);
289 extern kern_return_t
dp_memory_object_terminate(memory_object_t
);
290 extern kern_return_t
dp_memory_object_data_request(memory_object_t
,
291 memory_object_offset_t
,
292 memory_object_cluster_size_t
,
294 memory_object_fault_info_t
);
295 extern kern_return_t
dp_memory_object_data_return(memory_object_t
,
296 memory_object_offset_t
,
297 memory_object_cluster_size_t
,
298 memory_object_offset_t
*,
303 extern kern_return_t
dp_memory_object_data_initialize(memory_object_t
,
304 memory_object_offset_t
,
305 memory_object_cluster_size_t
);
306 extern kern_return_t
dp_memory_object_data_unlock(memory_object_t
,
307 memory_object_offset_t
,
308 memory_object_size_t
,
310 extern kern_return_t
dp_memory_object_synchronize(memory_object_t
,
311 memory_object_offset_t
,
312 memory_object_size_t
,
314 extern kern_return_t
dp_memory_object_map(memory_object_t
,
316 extern kern_return_t
dp_memory_object_last_unmap(memory_object_t
);
317 #endif /* _memory_object_server_ */
318 #ifndef _memory_object_default_server_
319 extern kern_return_t
default_pager_memory_object_create(
320 memory_object_default_t
,
323 #endif /* _memory_object_default_server_ */
325 extern void device_pager_reference(memory_object_t
);
326 extern void device_pager_deallocate(memory_object_t
);
327 extern kern_return_t
device_pager_init(memory_object_t
,
328 memory_object_control_t
,
329 memory_object_cluster_size_t
);
330 extern kern_return_t
device_pager_terminate(memory_object_t
);
331 extern kern_return_t
device_pager_data_request(memory_object_t
,
332 memory_object_offset_t
,
333 memory_object_cluster_size_t
,
335 memory_object_fault_info_t
);
336 extern kern_return_t
device_pager_data_return(memory_object_t
,
337 memory_object_offset_t
,
338 memory_object_cluster_size_t
,
339 memory_object_offset_t
*,
344 extern kern_return_t
device_pager_data_initialize(memory_object_t
,
345 memory_object_offset_t
,
346 memory_object_cluster_size_t
);
347 extern kern_return_t
device_pager_data_unlock(memory_object_t
,
348 memory_object_offset_t
,
349 memory_object_size_t
,
351 extern kern_return_t
device_pager_synchronize(memory_object_t
,
352 memory_object_offset_t
,
353 memory_object_size_t
,
355 extern kern_return_t
device_pager_map(memory_object_t
, vm_prot_t
);
356 extern kern_return_t
device_pager_last_unmap(memory_object_t
);
357 extern kern_return_t
device_pager_populate_object(
358 memory_object_t device
,
359 memory_object_offset_t offset
,
362 extern memory_object_t
device_pager_setup(
367 extern void device_pager_bootstrap(void) __attribute__((section("__TEXT, initcode")));
369 extern kern_return_t
memory_object_create_named(
370 memory_object_t pager
,
371 memory_object_offset_t size
,
372 memory_object_control_t
*control
);
374 struct macx_triggers_args
;
375 extern int mach_macx_triggers(
376 struct macx_triggers_args
*args
);
378 extern int macx_swapinfo(
379 memory_object_size_t
*total_p
,
380 memory_object_size_t
*avail_p
,
381 vm_size_t
*pagesize_p
,
382 boolean_t
*encrypted_p
);
384 extern void log_stack_execution_failure(addr64_t vaddr
, vm_prot_t prot
);
385 extern void log_unnest_badness(vm_map_t
, vm_map_offset_t
, vm_map_offset_t
);
387 extern int cs_allow_invalid(struct proc
*p
);
388 extern int cs_invalid_page(addr64_t vaddr
);
389 extern boolean_t
cs_validate_page(void *blobs
,
390 memory_object_offset_t offset
,
394 extern kern_return_t
mach_memory_entry_purgable_control(
395 ipc_port_t entry_port
,
396 vm_purgable_t control
,
399 extern kern_return_t
mach_memory_entry_page_op(
400 ipc_port_t entry_port
,
401 vm_object_offset_t offset
,
406 extern kern_return_t
mach_memory_entry_range_op(
407 ipc_port_t entry_port
,
408 vm_object_offset_t offset_beg
,
409 vm_object_offset_t offset_end
,
413 extern void mach_memory_entry_port_release(ipc_port_t port
);
414 extern void mach_destroy_memory_entry(ipc_port_t port
);
415 extern kern_return_t
mach_memory_entry_allocate(
416 struct vm_named_entry
**user_entry_p
,
417 ipc_port_t
*user_handle_p
);
419 extern void vm_paging_map_init(void);
421 extern int macx_backing_store_compaction(int flags
);
422 extern unsigned int mach_vm_ctl_page_free_wanted(void);
424 extern void no_paging_space_action(void);
425 #endif /* _VM_VM_PROTOS_H_ */
427 #endif /* XNU_KERNEL_PRIVATE */