2 * Copyright (c) 2004-2006 Apple Computer, 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_task_name_to_port(
76 task_name_t task_name
);
77 #endif /* _KERN_IPC_TT_H_ */
78 #ifndef _IPC_IPC_PORT_H_
79 extern mach_port_name_t
ipc_port_copyout_send(
82 extern task_t
port_name_to_task(
83 mach_port_name_t name
);
84 #endif /* _IPC_IPC_PORT_H_ */
86 extern ipc_space_t
get_task_ipcspace(
89 /* Some loose-ends VM stuff */
91 extern vm_map_t kalloc_map
;
92 extern vm_size_t msg_ool_size_small
;
93 extern vm_map_t zone_map
;
95 extern void consider_machine_adjust(void);
96 extern pmap_t
get_map_pmap(vm_map_t
);
97 extern vm_map_offset_t
get_map_min(vm_map_t
);
98 extern vm_map_offset_t
get_map_max(vm_map_t
);
99 extern vm_map_size_t
get_vmmap_size(vm_map_t
);
100 extern int get_vmmap_entries(vm_map_t
);
102 extern boolean_t
coredumpok(vm_map_t map
, vm_offset_t va
);
105 * VM routines that used to be published to
106 * user space, and are now restricted to the kernel.
108 * They should eventually go away entirely -
109 * to be replaced with standard vm_map() and
110 * vm_deallocate() calls.
113 extern kern_return_t vm_upl_map
115 vm_map_t target_task
,
117 vm_address_t
*address
120 extern kern_return_t vm_upl_unmap
122 vm_map_t target_task
,
126 extern kern_return_t vm_region_object_create
128 vm_map_t target_task
,
130 ipc_port_t
*object_handle
133 extern mach_vm_offset_t
mach_get_vm_start(vm_map_t
);
134 extern mach_vm_offset_t
mach_get_vm_end(vm_map_t
);
137 * Legacy routines to get the start and end for a vm_map_t. They
138 * return them in the vm_offset_t format. So, they should only be
139 * called on maps that are the same size as the kernel map for
142 extern vm_offset_t
get_vm_start(vm_map_t
);
143 extern vm_offset_t
get_vm_end(vm_map_t
);
146 * LP64todo - map in the commpage cleanly and remove these.
148 extern void vm_map_commpage64( vm_map_t
);
149 extern void vm_map_remove_commpage( vm_map_t
);
151 extern void vm_map_commpage32(vm_map_t
);
152 extern kern_return_t
vm_map_apple_protected(
154 vm_map_offset_t start
,
155 vm_map_offset_t end
);
156 extern void apple_protect_pager_bootstrap(void);
157 extern memory_object_t
apple_protect_pager_setup(vm_object_t backing_object
);
158 extern void apple_protect_pager_map(memory_object_t mem_obj
);
159 #endif /* __i386__ */
166 extern int is_suser(void);
167 extern int bsd_read_page_cache_file(
172 struct vnode
*app_vp
,
174 vm_offset_t
*bufsize
);
175 extern int bsd_write_page_cache_file(
182 extern int prepare_profile_database(
184 extern void vnode_pager_shutdown(void);
185 extern void *upl_get_internal_page_list(
187 #ifndef _VNODE_PAGER_
188 typedef int pager_return_t
;
189 extern pager_return_t
vnode_pagein(
190 struct vnode
*, upl_t
,
191 vm_offset_t
, vm_object_offset_t
,
192 vm_size_t
, int, int *);
193 extern pager_return_t
vnode_pageout(
194 struct vnode
*, upl_t
,
195 vm_offset_t
, vm_object_offset_t
,
196 vm_size_t
, int, int *);
197 extern memory_object_t
vnode_pager_setup(
198 struct vnode
*, memory_object_t
);
199 extern vm_object_offset_t
vnode_pager_get_filesize(
201 extern kern_return_t
vnode_pager_get_pathname(
204 vm_size_t
*length_p
);
205 extern kern_return_t
vnode_pager_get_filename(
209 #endif /* _VNODE_PAGER_ */
210 extern void vnode_pager_bootstrap(void);
212 vnode_pager_data_unlock(
213 memory_object_t mem_obj
,
214 memory_object_offset_t offset
,
216 vm_prot_t desired_access
);
217 extern kern_return_t
vnode_pager_init(
219 memory_object_control_t
,
221 extern kern_return_t
vnode_pager_get_object_size(
223 memory_object_offset_t
*);
224 extern kern_return_t
vnode_pager_get_object_pathname(
225 memory_object_t mem_obj
,
227 vm_size_t
*length_p
);
228 extern kern_return_t
vnode_pager_get_object_filename(
229 memory_object_t mem_obj
,
231 extern kern_return_t
vnode_pager_data_request(
233 memory_object_offset_t
,
236 extern kern_return_t
vnode_pager_data_return(
238 memory_object_offset_t
,
240 memory_object_offset_t
*,
245 extern kern_return_t
vnode_pager_data_initialize(
247 memory_object_offset_t
,
249 extern void vnode_pager_reference(
250 memory_object_t mem_obj
);
251 extern kern_return_t
vnode_pager_synchronize(
252 memory_object_t mem_obj
,
253 memory_object_offset_t offset
,
255 vm_sync_t sync_flags
);
256 extern kern_return_t
vnode_pager_unmap(
257 memory_object_t mem_obj
);
258 extern void vnode_pager_deallocate(
260 extern kern_return_t
vnode_pager_terminate(
262 extern void vnode_pager_vrele(
264 extern void vnode_pager_release_from_cache(
266 extern void ubc_unmap(
269 extern void dp_memory_object_reference(memory_object_t
);
270 extern void dp_memory_object_deallocate(memory_object_t
);
271 #ifndef _memory_object_server_
272 extern kern_return_t
dp_memory_object_init(memory_object_t
,
273 memory_object_control_t
,
275 extern kern_return_t
dp_memory_object_terminate(memory_object_t
);
276 extern kern_return_t
dp_memory_object_data_request(memory_object_t
,
277 memory_object_offset_t
, vm_size_t
, vm_prot_t
);
278 extern kern_return_t
dp_memory_object_data_return(memory_object_t
,
279 memory_object_offset_t
,
286 extern kern_return_t
dp_memory_object_data_initialize(memory_object_t
,
287 memory_object_offset_t
,
289 extern kern_return_t
dp_memory_object_data_unlock(memory_object_t
,
290 memory_object_offset_t
,
293 extern kern_return_t
dp_memory_object_synchronize(memory_object_t
,
294 memory_object_offset_t
,
297 extern kern_return_t
dp_memory_object_unmap(memory_object_t
);
298 #endif /* _memory_object_server_ */
299 #ifndef _memory_object_default_server_
300 extern kern_return_t
default_pager_memory_object_create(
301 memory_object_default_t
,
304 #endif /* _memory_object_default_server_ */
306 extern void device_pager_reference(memory_object_t
);
307 extern void device_pager_deallocate(memory_object_t
);
308 extern kern_return_t
device_pager_init(memory_object_t
,
309 memory_object_control_t
,
311 extern kern_return_t
device_pager_terminate(memory_object_t
);
312 extern kern_return_t
device_pager_data_request(memory_object_t
,
313 memory_object_offset_t
,
316 extern kern_return_t
device_pager_data_return(memory_object_t
,
317 memory_object_offset_t
,
319 memory_object_offset_t
*,
324 extern kern_return_t
device_pager_data_initialize(memory_object_t
,
325 memory_object_offset_t
,
327 extern kern_return_t
device_pager_data_unlock(memory_object_t
,
328 memory_object_offset_t
,
331 extern kern_return_t
device_pager_synchronize(memory_object_t
,
332 memory_object_offset_t
,
335 extern kern_return_t
device_pager_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);
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_nx_failure(addr64_t vaddr
, vm_prot_t prot
);
362 #endif /* _VM_VM_PROTOS_H_ */
364 #endif /* XNU_KERNEL_PRIVATE */