]> git.saurik.com Git - apple/xnu.git/blob - osfmk/vm/vm_protos.h
xnu-792.10.96.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_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 extern int default_pager_init_flag;
61
62 /*
63 * osfmk
64 */
65 #ifndef _KERN_IPC_TT_H_ /* XXX FBDP */
66 /* these should be exported cleanly from OSFMK since BSD needs them */
67 extern ipc_port_t convert_task_to_port(
68 task_t task);
69 extern ipc_port_t convert_task_name_to_port(
70 task_name_t task_name);
71 #endif /* _KERN_IPC_TT_H_ */
72 #ifndef _IPC_IPC_PORT_H_
73 extern mach_port_name_t ipc_port_copyout_send(
74 ipc_port_t sright,
75 ipc_space_t space);
76 extern task_t port_name_to_task(
77 mach_port_name_t name);
78 #endif /* _IPC_IPC_PORT_H_ */
79
80 extern ipc_space_t get_task_ipcspace(
81 task_t t);
82
83 /* Some loose-ends VM stuff */
84
85 extern vm_map_t kalloc_map;
86 extern vm_size_t msg_ool_size_small;
87 extern vm_map_t zone_map;
88
89 extern void consider_machine_adjust(void);
90 extern pmap_t get_map_pmap(vm_map_t);
91 extern vm_map_offset_t get_map_min(vm_map_t);
92 extern vm_map_offset_t get_map_max(vm_map_t);
93 extern vm_map_size_t get_vmmap_size(vm_map_t);
94 extern int get_vmmap_entries(vm_map_t);
95
96 extern boolean_t coredumpok(vm_map_t map, vm_offset_t va);
97
98 /*
99 * VM routines that used to be published to
100 * user space, and are now restricted to the kernel.
101 *
102 * They should eventually go away entirely -
103 * to be replaced with standard vm_map() and
104 * vm_deallocate() calls.
105 */
106
107 extern kern_return_t vm_upl_map
108 (
109 vm_map_t target_task,
110 upl_t upl,
111 vm_address_t *address
112 );
113
114 extern kern_return_t vm_upl_unmap
115 (
116 vm_map_t target_task,
117 upl_t upl
118 );
119
120 extern kern_return_t vm_region_object_create
121 (
122 vm_map_t target_task,
123 vm_size_t size,
124 ipc_port_t *object_handle
125 );
126
127 extern mach_vm_offset_t mach_get_vm_start(vm_map_t);
128 extern mach_vm_offset_t mach_get_vm_end(vm_map_t);
129
130 /*
131 * Legacy routines to get the start and end for a vm_map_t. They
132 * return them in the vm_offset_t format. So, they should only be
133 * called on maps that are the same size as the kernel map for
134 * accurate results.
135 */
136 extern vm_offset_t get_vm_start(vm_map_t);
137 extern vm_offset_t get_vm_end(vm_map_t);
138
139 /*
140 * LP64todo - map in the commpage cleanly and remove these.
141 */
142 extern void vm_map_commpage64( vm_map_t );
143 extern void vm_map_remove_commpage( vm_map_t );
144 #ifdef __i386__
145 extern void vm_map_commpage32(vm_map_t);
146 extern kern_return_t vm_map_apple_protected(
147 vm_map_t map,
148 vm_map_offset_t start,
149 vm_map_offset_t end);
150 extern void apple_protect_pager_bootstrap(void);
151 extern memory_object_t apple_protect_pager_setup(vm_object_t backing_object);
152 extern void apple_protect_pager_map(memory_object_t mem_obj);
153 #endif /* __i386__ */
154
155
156 /*
157 * bsd
158 */
159 struct vnode;
160 extern int is_suser(void);
161 extern int bsd_read_page_cache_file(
162 unsigned int user,
163 int *fid,
164 int *mod,
165 char *app_name,
166 struct vnode *app_vp,
167 vm_offset_t *buffer,
168 vm_offset_t *bufsize);
169 extern int bsd_write_page_cache_file(
170 unsigned int user,
171 char *file_name,
172 caddr_t buffer,
173 vm_size_t size,
174 int mod,
175 int fid);
176 extern int prepare_profile_database(
177 int user);
178 extern void vnode_pager_shutdown(void);
179 extern void *upl_get_internal_page_list(
180 upl_t upl);
181 #ifndef _VNODE_PAGER_
182 typedef int pager_return_t;
183 extern pager_return_t vnode_pagein(
184 struct vnode *, upl_t,
185 vm_offset_t, vm_object_offset_t,
186 vm_size_t, int, int *);
187 extern pager_return_t vnode_pageout(
188 struct vnode *, upl_t,
189 vm_offset_t, vm_object_offset_t,
190 vm_size_t, int, int *);
191 extern memory_object_t vnode_pager_setup(
192 struct vnode *, memory_object_t);
193 extern vm_object_offset_t vnode_pager_get_filesize(
194 struct vnode *);
195 extern kern_return_t vnode_pager_get_pathname(
196 struct vnode *vp,
197 char *pathname,
198 vm_size_t *length_p);
199 extern kern_return_t vnode_pager_get_filename(
200 struct vnode *vp,
201 char **filename);
202
203 #endif /* _VNODE_PAGER_ */
204 extern void vnode_pager_bootstrap(void);
205 extern kern_return_t
206 vnode_pager_data_unlock(
207 memory_object_t mem_obj,
208 memory_object_offset_t offset,
209 vm_size_t size,
210 vm_prot_t desired_access);
211 extern kern_return_t vnode_pager_init(
212 memory_object_t,
213 memory_object_control_t,
214 vm_size_t);
215 extern kern_return_t vnode_pager_get_object_size(
216 memory_object_t,
217 memory_object_offset_t *);
218 extern kern_return_t vnode_pager_get_object_pathname(
219 memory_object_t mem_obj,
220 char *pathname,
221 vm_size_t *length_p);
222 extern kern_return_t vnode_pager_get_object_filename(
223 memory_object_t mem_obj,
224 char **filename);
225 extern kern_return_t vnode_pager_data_request(
226 memory_object_t,
227 memory_object_offset_t,
228 vm_size_t,
229 vm_prot_t);
230 extern kern_return_t vnode_pager_data_return(
231 memory_object_t,
232 memory_object_offset_t,
233 vm_size_t,
234 memory_object_offset_t *,
235 int *,
236 boolean_t,
237 boolean_t,
238 int);
239 extern kern_return_t vnode_pager_data_initialize(
240 memory_object_t,
241 memory_object_offset_t,
242 vm_size_t);
243 extern void vnode_pager_reference(
244 memory_object_t mem_obj);
245 extern kern_return_t vnode_pager_synchronize(
246 memory_object_t mem_obj,
247 memory_object_offset_t offset,
248 vm_size_t length,
249 vm_sync_t sync_flags);
250 extern kern_return_t vnode_pager_unmap(
251 memory_object_t mem_obj);
252 extern void vnode_pager_deallocate(
253 memory_object_t);
254 extern kern_return_t vnode_pager_terminate(
255 memory_object_t);
256 extern void vnode_pager_vrele(
257 struct vnode *vp);
258 extern void vnode_pager_release_from_cache(
259 int *);
260 extern void ubc_unmap(
261 struct vnode *vp);
262
263 extern void dp_memory_object_reference(memory_object_t);
264 extern void dp_memory_object_deallocate(memory_object_t);
265 #ifndef _memory_object_server_
266 extern kern_return_t dp_memory_object_init(memory_object_t,
267 memory_object_control_t,
268 vm_size_t);
269 extern kern_return_t dp_memory_object_terminate(memory_object_t);
270 extern kern_return_t dp_memory_object_data_request(memory_object_t,
271 memory_object_offset_t, vm_size_t, vm_prot_t);
272 extern kern_return_t dp_memory_object_data_return(memory_object_t,
273 memory_object_offset_t,
274 vm_size_t,
275 vm_size_t *,
276 int *,
277 boolean_t,
278 boolean_t,
279 int);
280 extern kern_return_t dp_memory_object_data_initialize(memory_object_t,
281 memory_object_offset_t,
282 vm_size_t);
283 extern kern_return_t dp_memory_object_data_unlock(memory_object_t,
284 memory_object_offset_t,
285 vm_size_t,
286 vm_prot_t);
287 extern kern_return_t dp_memory_object_synchronize(memory_object_t,
288 memory_object_offset_t,
289 vm_size_t,
290 vm_sync_t);
291 extern kern_return_t dp_memory_object_unmap(memory_object_t);
292 #endif /* _memory_object_server_ */
293 #ifndef _memory_object_default_server_
294 extern kern_return_t default_pager_memory_object_create(
295 memory_object_default_t,
296 vm_size_t,
297 memory_object_t *);
298 #endif /* _memory_object_default_server_ */
299
300 extern void device_pager_reference(memory_object_t);
301 extern void device_pager_deallocate(memory_object_t);
302 extern kern_return_t device_pager_init(memory_object_t,
303 memory_object_control_t,
304 vm_size_t);
305 extern kern_return_t device_pager_terminate(memory_object_t);
306 extern kern_return_t device_pager_data_request(memory_object_t,
307 memory_object_offset_t,
308 vm_size_t,
309 vm_prot_t);
310 extern kern_return_t device_pager_data_return(memory_object_t,
311 memory_object_offset_t,
312 vm_size_t,
313 memory_object_offset_t *,
314 int *,
315 boolean_t,
316 boolean_t,
317 int);
318 extern kern_return_t device_pager_data_initialize(memory_object_t,
319 memory_object_offset_t,
320 vm_size_t);
321 extern kern_return_t device_pager_data_unlock(memory_object_t,
322 memory_object_offset_t,
323 vm_size_t,
324 vm_prot_t);
325 extern kern_return_t device_pager_synchronize(memory_object_t,
326 memory_object_offset_t,
327 vm_size_t,
328 vm_sync_t);
329 extern kern_return_t device_pager_unmap(memory_object_t);
330 extern kern_return_t device_pager_populate_object(
331 memory_object_t device,
332 memory_object_offset_t offset,
333 ppnum_t page_num,
334 vm_size_t size);
335 extern memory_object_t device_pager_setup(
336 memory_object_t,
337 int,
338 vm_size_t,
339 int);
340 extern void device_pager_bootstrap(void);
341
342 extern kern_return_t memory_object_create_named(
343 memory_object_t pager,
344 memory_object_offset_t size,
345 memory_object_control_t *control);
346
347
348 extern int macx_swapinfo(
349 memory_object_size_t *total_p,
350 memory_object_size_t *avail_p,
351 vm_size_t *pagesize_p,
352 boolean_t *encrypted_p);
353
354 extern void log_nx_failure(addr64_t vaddr, vm_prot_t prot);
355
356 #endif /* _VM_VM_PROTOS_H_ */
357
358 #endif /* XNU_KERNEL_PRIVATE */