]> git.saurik.com Git - apple/xnu.git/blob - osfmk/vm/vm_protos.h
xnu-792.6.22.tar.gz
[apple/xnu.git] / osfmk / vm / vm_protos.h
1 /*
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23 #ifdef XNU_KERNEL_PRIVATE
24
25 #ifndef _VM_VM_PROTOS_H_
26 #define _VM_VM_PROTOS_H_
27
28 #include <mach/mach_types.h>
29 #include <kern/kern_types.h>
30
31 /*
32 * This file contains various type definitions and routine prototypes
33 * that are needed to avoid compilation warnings for VM code (in osfmk,
34 * default_pager and bsd).
35 * Most of these should eventually go into more appropriate header files.
36 *
37 * Include it after all other header files since it doesn't include any
38 * type definitions and it works around some conflicts with other header
39 * files.
40 */
41
42 /*
43 * iokit
44 */
45 extern kern_return_t device_data_action(
46 int device_handle,
47 ipc_port_t device_pager,
48 vm_prot_t protection,
49 vm_object_offset_t offset,
50 vm_size_t size);
51
52 extern kern_return_t device_close(
53 int device_handle);
54
55 /*
56 * default_pager
57 */
58 extern int start_def_pager(
59 char *bs_device);
60
61 /*
62 * osfmk
63 */
64 #ifndef _KERN_IPC_TT_H_ /* XXX FBDP */
65 /* these should be exported cleanly from OSFMK since BSD needs them */
66 extern ipc_port_t convert_task_to_port(
67 task_t task);
68 #endif /* _KERN_IPC_TT_H_ */
69 #ifndef _IPC_IPC_PORT_H_
70 extern mach_port_name_t ipc_port_copyout_send(
71 ipc_port_t sright,
72 ipc_space_t space);
73 extern task_t port_name_to_task(
74 mach_port_name_t name);
75 #endif /* _IPC_IPC_PORT_H_ */
76
77 extern ipc_space_t get_task_ipcspace(
78 task_t t);
79
80 /* Some loose-ends VM stuff */
81
82 extern vm_map_t kalloc_map;
83 extern vm_size_t msg_ool_size_small;
84 extern vm_map_t zone_map;
85
86 extern void consider_machine_adjust(void);
87 extern pmap_t get_map_pmap(vm_map_t);
88 extern vm_map_offset_t get_map_min(vm_map_t);
89 extern vm_map_offset_t get_map_max(vm_map_t);
90 extern vm_map_size_t get_vmmap_size(vm_map_t);
91 extern int get_vmmap_entries(vm_map_t);
92
93 extern boolean_t coredumpok(vm_map_t map, vm_offset_t va);
94
95 /*
96 * VM routines that used to be published to
97 * user space, and are now restricted to the kernel.
98 *
99 * They should eventually go away entirely -
100 * to be replaced with standard vm_map() and
101 * vm_deallocate() calls.
102 */
103
104 extern kern_return_t vm_upl_map
105 (
106 vm_map_t target_task,
107 upl_t upl,
108 vm_address_t *address
109 );
110
111 extern kern_return_t vm_upl_unmap
112 (
113 vm_map_t target_task,
114 upl_t upl
115 );
116
117 extern kern_return_t vm_region_object_create
118 (
119 vm_map_t target_task,
120 vm_size_t size,
121 ipc_port_t *object_handle
122 );
123
124 extern mach_vm_offset_t mach_get_vm_start(vm_map_t);
125 extern mach_vm_offset_t mach_get_vm_end(vm_map_t);
126
127 /*
128 * Legacy routines to get the start and end for a vm_map_t. They
129 * return them in the vm_offset_t format. So, they should only be
130 * called on maps that are the same size as the kernel map for
131 * accurate results.
132 */
133 extern vm_offset_t get_vm_start(vm_map_t);
134 extern vm_offset_t get_vm_end(vm_map_t);
135
136 #ifdef __PPC__
137 /*
138 * LP64todo - map in the commpage cleanly and remove these.
139 */
140 extern void vm_map_commpage64( vm_map_t );
141 extern void vm_map_remove_commpage64( vm_map_t );
142 #endif /* __PPC__ */
143
144 /*
145 * bsd
146 */
147 struct vnode;
148 extern int is_suser(void);
149 extern int bsd_read_page_cache_file(
150 unsigned int user,
151 int *fid,
152 int *mod,
153 char *app_name,
154 struct vnode *app_vp,
155 vm_offset_t *buffer,
156 vm_offset_t *bufsize);
157 extern int bsd_write_page_cache_file(
158 unsigned int user,
159 char *file_name,
160 caddr_t buffer,
161 vm_size_t size,
162 int mod,
163 int fid);
164 extern int prepare_profile_database(
165 int user);
166 extern void vnode_pager_shutdown(void);
167 extern void *upl_get_internal_page_list(
168 upl_t upl);
169 #ifndef _VNODE_PAGER_
170 typedef int pager_return_t;
171 extern pager_return_t vnode_pagein(
172 struct vnode *, upl_t,
173 vm_offset_t, vm_object_offset_t,
174 vm_size_t, int, int *);
175 extern pager_return_t vnode_pageout(
176 struct vnode *, upl_t,
177 vm_offset_t, vm_object_offset_t,
178 vm_size_t, int, int *);
179 extern memory_object_t vnode_pager_setup(
180 struct vnode *, memory_object_t);
181 extern vm_object_offset_t vnode_pager_get_filesize(
182 struct vnode *);
183 #endif /* _VNODE_PAGER_ */
184 extern void vnode_pager_bootstrap(void);
185 extern kern_return_t
186 vnode_pager_data_unlock(
187 memory_object_t mem_obj,
188 memory_object_offset_t offset,
189 vm_size_t size,
190 vm_prot_t desired_access);
191 extern kern_return_t vnode_pager_init(
192 memory_object_t,
193 memory_object_control_t,
194 vm_size_t);
195 extern kern_return_t vnode_pager_get_object_size(
196 memory_object_t,
197 memory_object_offset_t *);
198 extern kern_return_t vnode_pager_data_request(
199 memory_object_t,
200 memory_object_offset_t,
201 vm_size_t,
202 vm_prot_t);
203 extern kern_return_t vnode_pager_data_return(
204 memory_object_t,
205 memory_object_offset_t,
206 vm_size_t,
207 memory_object_offset_t *,
208 int *,
209 boolean_t,
210 boolean_t,
211 int);
212 extern kern_return_t vnode_pager_data_initialize(
213 memory_object_t,
214 memory_object_offset_t,
215 vm_size_t);
216 extern void vnode_pager_reference(
217 memory_object_t mem_obj);
218 extern kern_return_t vnode_pager_synchronize(
219 memory_object_t mem_obj,
220 memory_object_offset_t offset,
221 vm_size_t length,
222 vm_sync_t sync_flags);
223 extern kern_return_t vnode_pager_unmap(
224 memory_object_t mem_obj);
225 extern void vnode_pager_deallocate(
226 memory_object_t);
227 extern kern_return_t vnode_pager_terminate(
228 memory_object_t);
229 extern void vnode_pager_vrele(
230 struct vnode *vp);
231 extern void vnode_pager_release_from_cache(
232 int *);
233 extern void ubc_unmap(
234 struct vnode *vp);
235
236 extern int vnode_pager_workaround;
237 extern int device_pager_workaround;
238
239 extern void dp_memory_object_reference(memory_object_t);
240 extern void dp_memory_object_deallocate(memory_object_t);
241 #ifndef _memory_object_server_
242 extern kern_return_t dp_memory_object_init(memory_object_t,
243 memory_object_control_t,
244 vm_size_t);
245 extern kern_return_t dp_memory_object_terminate(memory_object_t);
246 extern kern_return_t dp_memory_object_data_request(memory_object_t,
247 memory_object_offset_t, vm_size_t, vm_prot_t);
248 extern kern_return_t dp_memory_object_data_return(memory_object_t,
249 memory_object_offset_t,
250 vm_size_t,
251 vm_size_t *,
252 int *,
253 boolean_t,
254 boolean_t,
255 int);
256 extern kern_return_t dp_memory_object_data_initialize(memory_object_t,
257 memory_object_offset_t,
258 vm_size_t);
259 extern kern_return_t dp_memory_object_data_unlock(memory_object_t,
260 memory_object_offset_t,
261 vm_size_t,
262 vm_prot_t);
263 extern kern_return_t dp_memory_object_synchronize(memory_object_t,
264 memory_object_offset_t,
265 vm_size_t,
266 vm_sync_t);
267 extern kern_return_t dp_memory_object_unmap(memory_object_t);
268 #endif /* _memory_object_server_ */
269 #ifndef _memory_object_default_server_
270 extern kern_return_t default_pager_memory_object_create(
271 memory_object_default_t,
272 vm_size_t,
273 memory_object_t *);
274 #endif /* _memory_object_default_server_ */
275
276 extern void device_pager_reference(memory_object_t);
277 extern void device_pager_deallocate(memory_object_t);
278 extern kern_return_t device_pager_init(memory_object_t,
279 memory_object_control_t,
280 vm_size_t);
281 extern kern_return_t device_pager_terminate(memory_object_t);
282 extern kern_return_t device_pager_data_request(memory_object_t,
283 memory_object_offset_t,
284 vm_size_t,
285 vm_prot_t);
286 extern kern_return_t device_pager_data_return(memory_object_t,
287 memory_object_offset_t,
288 vm_size_t,
289 boolean_t,
290 boolean_t,
291 int);
292 extern kern_return_t device_pager_data_initialize(memory_object_t,
293 memory_object_offset_t,
294 vm_size_t);
295 extern kern_return_t device_pager_data_unlock(memory_object_t,
296 memory_object_offset_t,
297 vm_size_t,
298 vm_prot_t);
299 extern kern_return_t device_pager_synchronize(memory_object_t,
300 memory_object_offset_t,
301 vm_size_t,
302 vm_sync_t);
303 extern kern_return_t device_pager_unmap(memory_object_t);
304 extern kern_return_t device_pager_populate_object(
305 memory_object_t device,
306 memory_object_offset_t offset,
307 ppnum_t page_num,
308 vm_size_t size);
309 extern memory_object_t device_pager_setup(
310 memory_object_t,
311 int,
312 vm_size_t,
313 int);
314 extern void device_pager_bootstrap(void);
315
316 extern kern_return_t memory_object_create_named(
317 memory_object_t pager,
318 memory_object_offset_t size,
319 memory_object_control_t *control);
320
321
322 extern int macx_swapinfo(
323 memory_object_size_t *total_p,
324 memory_object_size_t *avail_p,
325 vm_size_t *pagesize_p,
326 boolean_t *encrypted_p);
327
328 #endif /* _VM_VM_PROTOS_H_ */
329
330 #endif /* XNU_KERNEL_PRIVATE */