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(
53 ipc_port_t device_pager
,
55 vm_object_offset_t offset
,
58 extern kern_return_t
device_close(
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 */
164 extern void vnode_pager_shutdown(void);
165 extern void *upl_get_internal_page_list(
167 #ifndef _VNODE_PAGER_
168 typedef int pager_return_t
;
169 extern pager_return_t
vnode_pagein(
170 struct vnode
*, upl_t
,
171 vm_offset_t
, vm_object_offset_t
,
172 vm_size_t
, int, int *);
173 extern pager_return_t
vnode_pageout(
174 struct vnode
*, upl_t
,
175 vm_offset_t
, vm_object_offset_t
,
176 vm_size_t
, int, int *);
177 extern memory_object_t
vnode_pager_setup(
178 struct vnode
*, memory_object_t
);
179 extern vm_object_offset_t
vnode_pager_get_filesize(
181 extern kern_return_t
vnode_pager_get_pathname(
184 vm_size_t
*length_p
);
185 extern kern_return_t
vnode_pager_get_filename(
187 const char **filename
);
188 extern kern_return_t
vnode_pager_get_cs_blobs(
192 #endif /* _VNODE_PAGER_ */
193 extern void vnode_pager_bootstrap(void) __attribute__((section("__TEXT, initcode")));
195 vnode_pager_data_unlock(
196 memory_object_t mem_obj
,
197 memory_object_offset_t offset
,
199 vm_prot_t desired_access
);
200 extern kern_return_t
vnode_pager_init(
202 memory_object_control_t
,
204 extern kern_return_t
vnode_pager_get_object_size(
206 memory_object_offset_t
*);
207 extern kern_return_t
vnode_pager_get_object_pathname(
208 memory_object_t mem_obj
,
210 vm_size_t
*length_p
);
211 extern kern_return_t
vnode_pager_get_object_filename(
212 memory_object_t mem_obj
,
213 const char **filename
);
214 extern kern_return_t
vnode_pager_get_object_cs_blobs(
215 memory_object_t mem_obj
,
217 extern kern_return_t
vnode_pager_data_request(
219 memory_object_offset_t
,
222 memory_object_fault_info_t
);
223 extern kern_return_t
vnode_pager_data_return(
225 memory_object_offset_t
,
227 memory_object_offset_t
*,
232 extern kern_return_t
vnode_pager_data_initialize(
234 memory_object_offset_t
,
236 extern void vnode_pager_reference(
237 memory_object_t mem_obj
);
238 extern kern_return_t
vnode_pager_synchronize(
239 memory_object_t mem_obj
,
240 memory_object_offset_t offset
,
242 vm_sync_t sync_flags
);
243 extern kern_return_t
vnode_pager_map(
244 memory_object_t mem_obj
,
246 extern kern_return_t
vnode_pager_last_unmap(
247 memory_object_t mem_obj
);
248 extern void vnode_pager_deallocate(
250 extern kern_return_t
vnode_pager_terminate(
252 extern void vnode_pager_vrele(
254 extern void vnode_pager_release_from_cache(
259 extern void ubc_unmap(
262 extern void dp_memory_object_reference(memory_object_t
);
263 extern void dp_memory_object_deallocate(memory_object_t
);
264 #ifndef _memory_object_server_
265 extern kern_return_t
dp_memory_object_init(memory_object_t
,
266 memory_object_control_t
,
268 extern kern_return_t
dp_memory_object_terminate(memory_object_t
);
269 extern kern_return_t
dp_memory_object_data_request(memory_object_t
,
270 memory_object_offset_t
,
273 memory_object_fault_info_t
);
274 extern kern_return_t
dp_memory_object_data_return(memory_object_t
,
275 memory_object_offset_t
,
282 extern kern_return_t
dp_memory_object_data_initialize(memory_object_t
,
283 memory_object_offset_t
,
285 extern kern_return_t
dp_memory_object_data_unlock(memory_object_t
,
286 memory_object_offset_t
,
289 extern kern_return_t
dp_memory_object_synchronize(memory_object_t
,
290 memory_object_offset_t
,
293 extern kern_return_t
dp_memory_object_map(memory_object_t
,
295 extern kern_return_t
dp_memory_object_last_unmap(memory_object_t
);
296 #endif /* _memory_object_server_ */
297 #ifndef _memory_object_default_server_
298 extern kern_return_t
default_pager_memory_object_create(
299 memory_object_default_t
,
302 #endif /* _memory_object_default_server_ */
304 extern void device_pager_reference(memory_object_t
);
305 extern void device_pager_deallocate(memory_object_t
);
306 extern kern_return_t
device_pager_init(memory_object_t
,
307 memory_object_control_t
,
309 extern kern_return_t
device_pager_terminate(memory_object_t
);
310 extern kern_return_t
device_pager_data_request(memory_object_t
,
311 memory_object_offset_t
,
314 memory_object_fault_info_t
);
315 extern kern_return_t
device_pager_data_return(memory_object_t
,
316 memory_object_offset_t
,
318 memory_object_offset_t
*,
323 extern kern_return_t
device_pager_data_initialize(memory_object_t
,
324 memory_object_offset_t
,
326 extern kern_return_t
device_pager_data_unlock(memory_object_t
,
327 memory_object_offset_t
,
330 extern kern_return_t
device_pager_synchronize(memory_object_t
,
331 memory_object_offset_t
,
334 extern kern_return_t
device_pager_map(memory_object_t
, vm_prot_t
);
335 extern kern_return_t
device_pager_last_unmap(memory_object_t
);
336 extern kern_return_t
device_pager_populate_object(
337 memory_object_t device
,
338 memory_object_offset_t offset
,
341 extern memory_object_t
device_pager_setup(
346 extern void device_pager_bootstrap(void) __attribute__((section("__TEXT, initcode")));
348 extern kern_return_t
memory_object_create_named(
349 memory_object_t pager
,
350 memory_object_offset_t size
,
351 memory_object_control_t
*control
);
354 extern int macx_swapinfo(
355 memory_object_size_t
*total_p
,
356 memory_object_size_t
*avail_p
,
357 vm_size_t
*pagesize_p
,
358 boolean_t
*encrypted_p
);
360 extern void log_stack_execution_failure(addr64_t vaddr
, vm_prot_t prot
);
361 extern int cs_invalid_page(addr64_t vaddr
);
362 extern boolean_t
cs_validate_page(void *blobs
,
363 memory_object_offset_t offset
,
367 extern kern_return_t
mach_memory_entry_purgable_control(
368 ipc_port_t entry_port
,
369 vm_purgable_t control
,
372 extern kern_return_t
mach_memory_entry_page_op(
373 ipc_port_t entry_port
,
374 vm_object_offset_t offset
,
379 extern kern_return_t
mach_memory_entry_range_op(
380 ipc_port_t entry_port
,
381 vm_object_offset_t offset_beg
,
382 vm_object_offset_t offset_end
,
386 extern void mach_memory_entry_port_release(ipc_port_t port
);
387 extern void mach_destroy_memory_entry(ipc_port_t port
);
388 extern kern_return_t
mach_memory_entry_allocate(
389 struct vm_named_entry
**user_entry_p
,
390 ipc_port_t
*user_handle_p
);
392 extern void vm_paging_map_init(void);
394 #endif /* _VM_VM_PROTOS_H_ */
396 #endif /* XNU_KERNEL_PRIVATE */