]> git.saurik.com Git - apple/xnu.git/blob - osfmk/vm/vm_protos.h
xnu-792.18.15.tar.gz
[apple/xnu.git] / osfmk / vm / vm_protos.h
1 /*
2 * Copyright (c) 2004-2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
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
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
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(
52 int device_handle,
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(
59 int device_handle);
60
61 /*
62 * default_pager
63 */
64 extern int start_def_pager(
65 char *bs_device);
66 extern int default_pager_init_flag;
67
68 /*
69 * osfmk
70 */
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(
74 task_t task);
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(
80 ipc_port_t sright,
81 ipc_space_t space);
82 extern task_t port_name_to_task(
83 mach_port_name_t name);
84 #endif /* _IPC_IPC_PORT_H_ */
85
86 extern ipc_space_t get_task_ipcspace(
87 task_t t);
88
89 /* Some loose-ends VM stuff */
90
91 extern vm_map_t kalloc_map;
92 extern vm_size_t msg_ool_size_small;
93 extern vm_map_t zone_map;
94
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);
101
102 extern boolean_t coredumpok(vm_map_t map, vm_offset_t va);
103
104 /*
105 * VM routines that used to be published to
106 * user space, and are now restricted to the kernel.
107 *
108 * They should eventually go away entirely -
109 * to be replaced with standard vm_map() and
110 * vm_deallocate() calls.
111 */
112
113 extern kern_return_t vm_upl_map
114 (
115 vm_map_t target_task,
116 upl_t upl,
117 vm_address_t *address
118 );
119
120 extern kern_return_t vm_upl_unmap
121 (
122 vm_map_t target_task,
123 upl_t upl
124 );
125
126 extern kern_return_t vm_region_object_create
127 (
128 vm_map_t target_task,
129 vm_size_t size,
130 ipc_port_t *object_handle
131 );
132
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);
135
136 /*
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
140 * accurate results.
141 */
142 extern vm_offset_t get_vm_start(vm_map_t);
143 extern vm_offset_t get_vm_end(vm_map_t);
144
145 /*
146 * LP64todo - map in the commpage cleanly and remove these.
147 */
148 extern void vm_map_commpage64( vm_map_t );
149 extern void vm_map_remove_commpage( vm_map_t );
150 #ifdef __i386__
151 extern void vm_map_commpage32(vm_map_t);
152 extern kern_return_t vm_map_apple_protected(
153 vm_map_t map,
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__ */
160
161
162 /*
163 * bsd
164 */
165 struct vnode;
166 extern int is_suser(void);
167 extern int bsd_read_page_cache_file(
168 unsigned int user,
169 int *fid,
170 int *mod,
171 char *app_name,
172 struct vnode *app_vp,
173 vm_offset_t *buffer,
174 vm_offset_t *bufsize);
175 extern int bsd_write_page_cache_file(
176 unsigned int user,
177 char *file_name,
178 caddr_t buffer,
179 vm_size_t size,
180 int mod,
181 int fid);
182 extern int prepare_profile_database(
183 int user);
184 extern void vnode_pager_shutdown(void);
185 extern void *upl_get_internal_page_list(
186 upl_t upl);
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(
200 struct vnode *);
201 extern kern_return_t vnode_pager_get_pathname(
202 struct vnode *vp,
203 char *pathname,
204 vm_size_t *length_p);
205 extern kern_return_t vnode_pager_get_filename(
206 struct vnode *vp,
207 char **filename);
208
209 #endif /* _VNODE_PAGER_ */
210 extern void vnode_pager_bootstrap(void);
211 extern kern_return_t
212 vnode_pager_data_unlock(
213 memory_object_t mem_obj,
214 memory_object_offset_t offset,
215 vm_size_t size,
216 vm_prot_t desired_access);
217 extern kern_return_t vnode_pager_init(
218 memory_object_t,
219 memory_object_control_t,
220 vm_size_t);
221 extern kern_return_t vnode_pager_get_object_size(
222 memory_object_t,
223 memory_object_offset_t *);
224 extern kern_return_t vnode_pager_get_object_pathname(
225 memory_object_t mem_obj,
226 char *pathname,
227 vm_size_t *length_p);
228 extern kern_return_t vnode_pager_get_object_filename(
229 memory_object_t mem_obj,
230 char **filename);
231 extern kern_return_t vnode_pager_data_request(
232 memory_object_t,
233 memory_object_offset_t,
234 vm_size_t,
235 vm_prot_t);
236 extern kern_return_t vnode_pager_data_return(
237 memory_object_t,
238 memory_object_offset_t,
239 vm_size_t,
240 memory_object_offset_t *,
241 int *,
242 boolean_t,
243 boolean_t,
244 int);
245 extern kern_return_t vnode_pager_data_initialize(
246 memory_object_t,
247 memory_object_offset_t,
248 vm_size_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,
254 vm_size_t length,
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(
259 memory_object_t);
260 extern kern_return_t vnode_pager_terminate(
261 memory_object_t);
262 extern void vnode_pager_vrele(
263 struct vnode *vp);
264 extern void vnode_pager_release_from_cache(
265 int *);
266 extern void ubc_unmap(
267 struct vnode *vp);
268
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,
274 vm_size_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,
280 vm_size_t,
281 vm_size_t *,
282 int *,
283 boolean_t,
284 boolean_t,
285 int);
286 extern kern_return_t dp_memory_object_data_initialize(memory_object_t,
287 memory_object_offset_t,
288 vm_size_t);
289 extern kern_return_t dp_memory_object_data_unlock(memory_object_t,
290 memory_object_offset_t,
291 vm_size_t,
292 vm_prot_t);
293 extern kern_return_t dp_memory_object_synchronize(memory_object_t,
294 memory_object_offset_t,
295 vm_size_t,
296 vm_sync_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,
302 vm_size_t,
303 memory_object_t *);
304 #endif /* _memory_object_default_server_ */
305
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,
310 vm_size_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,
314 vm_size_t,
315 vm_prot_t);
316 extern kern_return_t device_pager_data_return(memory_object_t,
317 memory_object_offset_t,
318 vm_size_t,
319 memory_object_offset_t *,
320 int *,
321 boolean_t,
322 boolean_t,
323 int);
324 extern kern_return_t device_pager_data_initialize(memory_object_t,
325 memory_object_offset_t,
326 vm_size_t);
327 extern kern_return_t device_pager_data_unlock(memory_object_t,
328 memory_object_offset_t,
329 vm_size_t,
330 vm_prot_t);
331 extern kern_return_t device_pager_synchronize(memory_object_t,
332 memory_object_offset_t,
333 vm_size_t,
334 vm_sync_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,
339 ppnum_t page_num,
340 vm_size_t size);
341 extern memory_object_t device_pager_setup(
342 memory_object_t,
343 int,
344 vm_size_t,
345 int);
346 extern void device_pager_bootstrap(void);
347
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);
352
353
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);
359
360 extern void log_nx_failure(addr64_t vaddr, vm_prot_t prot);
361
362 #endif /* _VM_VM_PROTOS_H_ */
363
364 #endif /* XNU_KERNEL_PRIVATE */