]> git.saurik.com Git - apple/xnu.git/blob - osfmk/vm/vm_protos.h
xnu-1228.9.59.tar.gz
[apple/xnu.git] / osfmk / vm / vm_protos.h
1 /*
2 * Copyright (c) 2004-2007 Apple 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_thread_to_port(
76 thread_t thread);
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(
82 ipc_port_t sright,
83 ipc_space_t space);
84 extern task_t port_name_to_task(
85 mach_port_name_t name);
86 #endif /* _IPC_IPC_PORT_H_ */
87
88 extern ipc_space_t get_task_ipcspace(
89 task_t t);
90
91 /* Some loose-ends VM stuff */
92
93 extern vm_map_t kalloc_map;
94 extern vm_size_t msg_ool_size_small;
95 extern vm_map_t zone_map;
96
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);
103
104 extern boolean_t coredumpok(vm_map_t map, vm_offset_t va);
105
106 /*
107 * VM routines that used to be published to
108 * user space, and are now restricted to the kernel.
109 *
110 * They should eventually go away entirely -
111 * to be replaced with standard vm_map() and
112 * vm_deallocate() calls.
113 */
114
115 extern kern_return_t vm_upl_map
116 (
117 vm_map_t target_task,
118 upl_t upl,
119 vm_address_t *address
120 );
121
122 extern kern_return_t vm_upl_unmap
123 (
124 vm_map_t target_task,
125 upl_t upl
126 );
127
128 extern kern_return_t vm_region_object_create
129 (
130 vm_map_t target_task,
131 vm_size_t size,
132 ipc_port_t *object_handle
133 );
134
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);
137
138 /*
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
142 * accurate results.
143 */
144 extern vm_offset_t get_vm_start(vm_map_t);
145 extern vm_offset_t get_vm_end(vm_map_t);
146
147 #if CONFIG_CODE_DECRYPTION
148 struct pager_crypt_info;
149 extern kern_return_t vm_map_apple_protected(
150 vm_map_t map,
151 vm_map_offset_t start,
152 vm_map_offset_t end,
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 */
158
159
160 /*
161 * bsd
162 */
163 struct vnode;
164 extern void vnode_pager_shutdown(void);
165 extern void *upl_get_internal_page_list(
166 upl_t upl);
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(
180 struct vnode *);
181 extern kern_return_t vnode_pager_get_pathname(
182 struct vnode *vp,
183 char *pathname,
184 vm_size_t *length_p);
185 extern kern_return_t vnode_pager_get_filename(
186 struct vnode *vp,
187 const char **filename);
188 extern kern_return_t vnode_pager_get_cs_blobs(
189 struct vnode *vp,
190 void **blobs);
191
192 #endif /* _VNODE_PAGER_ */
193 extern void vnode_pager_bootstrap(void) __attribute__((section("__TEXT, initcode")));
194 extern kern_return_t
195 vnode_pager_data_unlock(
196 memory_object_t mem_obj,
197 memory_object_offset_t offset,
198 vm_size_t size,
199 vm_prot_t desired_access);
200 extern kern_return_t vnode_pager_init(
201 memory_object_t,
202 memory_object_control_t,
203 vm_size_t);
204 extern kern_return_t vnode_pager_get_object_size(
205 memory_object_t,
206 memory_object_offset_t *);
207 extern kern_return_t vnode_pager_get_object_pathname(
208 memory_object_t mem_obj,
209 char *pathname,
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,
216 void **blobs);
217 extern kern_return_t vnode_pager_data_request(
218 memory_object_t,
219 memory_object_offset_t,
220 vm_size_t,
221 vm_prot_t,
222 memory_object_fault_info_t);
223 extern kern_return_t vnode_pager_data_return(
224 memory_object_t,
225 memory_object_offset_t,
226 vm_size_t,
227 memory_object_offset_t *,
228 int *,
229 boolean_t,
230 boolean_t,
231 int);
232 extern kern_return_t vnode_pager_data_initialize(
233 memory_object_t,
234 memory_object_offset_t,
235 vm_size_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,
241 vm_size_t length,
242 vm_sync_t sync_flags);
243 extern kern_return_t vnode_pager_map(
244 memory_object_t mem_obj,
245 vm_prot_t prot);
246 extern kern_return_t vnode_pager_last_unmap(
247 memory_object_t mem_obj);
248 extern void vnode_pager_deallocate(
249 memory_object_t);
250 extern kern_return_t vnode_pager_terminate(
251 memory_object_t);
252 extern void vnode_pager_vrele(
253 struct vnode *vp);
254 extern void vnode_pager_release_from_cache(
255 int *);
256 extern int ubc_map(
257 struct vnode *vp,
258 int flags);
259 extern void ubc_unmap(
260 struct vnode *vp);
261
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,
267 vm_size_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,
271 vm_size_t,
272 vm_prot_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,
276 vm_size_t,
277 vm_size_t *,
278 int *,
279 boolean_t,
280 boolean_t,
281 int);
282 extern kern_return_t dp_memory_object_data_initialize(memory_object_t,
283 memory_object_offset_t,
284 vm_size_t);
285 extern kern_return_t dp_memory_object_data_unlock(memory_object_t,
286 memory_object_offset_t,
287 vm_size_t,
288 vm_prot_t);
289 extern kern_return_t dp_memory_object_synchronize(memory_object_t,
290 memory_object_offset_t,
291 vm_size_t,
292 vm_sync_t);
293 extern kern_return_t dp_memory_object_map(memory_object_t,
294 vm_prot_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,
300 vm_size_t,
301 memory_object_t *);
302 #endif /* _memory_object_default_server_ */
303
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,
308 vm_size_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,
312 vm_size_t,
313 vm_prot_t,
314 memory_object_fault_info_t);
315 extern kern_return_t device_pager_data_return(memory_object_t,
316 memory_object_offset_t,
317 vm_size_t,
318 memory_object_offset_t *,
319 int *,
320 boolean_t,
321 boolean_t,
322 int);
323 extern kern_return_t device_pager_data_initialize(memory_object_t,
324 memory_object_offset_t,
325 vm_size_t);
326 extern kern_return_t device_pager_data_unlock(memory_object_t,
327 memory_object_offset_t,
328 vm_size_t,
329 vm_prot_t);
330 extern kern_return_t device_pager_synchronize(memory_object_t,
331 memory_object_offset_t,
332 vm_size_t,
333 vm_sync_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,
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) __attribute__((section("__TEXT, initcode")));
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_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,
364 const void *data,
365 boolean_t *tainted);
366
367 extern kern_return_t mach_memory_entry_purgable_control(
368 ipc_port_t entry_port,
369 vm_purgable_t control,
370 int *state);
371
372 extern kern_return_t mach_memory_entry_page_op(
373 ipc_port_t entry_port,
374 vm_object_offset_t offset,
375 int ops,
376 ppnum_t *phys_entry,
377 int *flags);
378
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,
383 int ops,
384 int *range);
385
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);
391
392 extern void vm_paging_map_init(void);
393
394 #endif /* _VM_VM_PROTOS_H_ */
395
396 #endif /* XNU_KERNEL_PRIVATE */