]> git.saurik.com Git - apple/xnu.git/blob - osfmk/vm/vm_protos.h
xnu-1504.15.3.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 uintptr_t 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 uintptr_t 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 struct vnode;
160 extern void swapfile_pager_bootstrap(void);
161 extern memory_object_t swapfile_pager_setup(struct vnode *vp);
162 extern memory_object_control_t swapfile_pager_control(memory_object_t mem_obj);
163
164
165 /*
166 * bsd
167 */
168 struct vnode;
169 extern void vnode_pager_shutdown(void);
170 extern void *upl_get_internal_page_list(
171 upl_t upl);
172
173 typedef int pager_return_t;
174 extern pager_return_t vnode_pagein(
175 struct vnode *, upl_t,
176 upl_offset_t, vm_object_offset_t,
177 upl_size_t, int, int *);
178 extern pager_return_t vnode_pageout(
179 struct vnode *, upl_t,
180 upl_offset_t, vm_object_offset_t,
181 upl_size_t, int, int *);
182 extern memory_object_t vnode_pager_setup(
183 struct vnode *, memory_object_t);
184 extern vm_object_offset_t vnode_pager_get_filesize(
185 struct vnode *);
186 extern uint32_t vnode_pager_isinuse(
187 struct vnode *);
188 extern uint32_t vnode_pager_return_hard_throttle_limit(
189 struct vnode *,
190 uint32_t *,
191 uint32_t);
192 extern kern_return_t vnode_pager_get_pathname(
193 struct vnode *vp,
194 char *pathname,
195 vm_size_t *length_p);
196 extern kern_return_t vnode_pager_get_filename(
197 struct vnode *vp,
198 const char **filename);
199 extern kern_return_t vnode_pager_get_cs_blobs(
200 struct vnode *vp,
201 void **blobs);
202
203
204 extern void vnode_pager_bootstrap(void) __attribute__((section("__TEXT, initcode")));
205 extern kern_return_t
206 vnode_pager_data_unlock(
207 memory_object_t mem_obj,
208 memory_object_offset_t offset,
209 memory_object_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 memory_object_cluster_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_isinuse(
219 memory_object_t,
220 uint32_t *);
221 extern kern_return_t vnode_pager_check_hard_throttle(
222 memory_object_t,
223 uint32_t *,
224 uint32_t);
225 extern kern_return_t vnode_pager_get_object_pathname(
226 memory_object_t mem_obj,
227 char *pathname,
228 vm_size_t *length_p);
229 extern kern_return_t vnode_pager_get_object_filename(
230 memory_object_t mem_obj,
231 const char **filename);
232 extern kern_return_t vnode_pager_get_object_cs_blobs(
233 memory_object_t mem_obj,
234 void **blobs);
235 extern kern_return_t vnode_pager_data_request(
236 memory_object_t,
237 memory_object_offset_t,
238 memory_object_cluster_size_t,
239 vm_prot_t,
240 memory_object_fault_info_t);
241 extern kern_return_t vnode_pager_data_return(
242 memory_object_t,
243 memory_object_offset_t,
244 memory_object_cluster_size_t,
245 memory_object_offset_t *,
246 int *,
247 boolean_t,
248 boolean_t,
249 int);
250 extern kern_return_t vnode_pager_data_initialize(
251 memory_object_t,
252 memory_object_offset_t,
253 memory_object_cluster_size_t);
254 extern void vnode_pager_reference(
255 memory_object_t mem_obj);
256 extern kern_return_t vnode_pager_synchronize(
257 memory_object_t mem_obj,
258 memory_object_offset_t offset,
259 memory_object_size_t length,
260 vm_sync_t sync_flags);
261 extern kern_return_t vnode_pager_map(
262 memory_object_t mem_obj,
263 vm_prot_t prot);
264 extern kern_return_t vnode_pager_last_unmap(
265 memory_object_t mem_obj);
266 extern void vnode_pager_deallocate(
267 memory_object_t);
268 extern kern_return_t vnode_pager_terminate(
269 memory_object_t);
270 extern void vnode_pager_vrele(
271 struct vnode *vp);
272 extern void vnode_pager_release_from_cache(
273 int *);
274 extern int ubc_map(
275 struct vnode *vp,
276 int flags);
277 extern void ubc_unmap(
278 struct vnode *vp);
279
280 struct vm_map_entry;
281 extern struct vm_object *find_vnode_object(struct vm_map_entry *entry);
282
283 extern void dp_memory_object_reference(memory_object_t);
284 extern void dp_memory_object_deallocate(memory_object_t);
285 #ifndef _memory_object_server_
286 extern kern_return_t dp_memory_object_init(memory_object_t,
287 memory_object_control_t,
288 memory_object_cluster_size_t);
289 extern kern_return_t dp_memory_object_terminate(memory_object_t);
290 extern kern_return_t dp_memory_object_data_request(memory_object_t,
291 memory_object_offset_t,
292 memory_object_cluster_size_t,
293 vm_prot_t,
294 memory_object_fault_info_t);
295 extern kern_return_t dp_memory_object_data_return(memory_object_t,
296 memory_object_offset_t,
297 memory_object_cluster_size_t,
298 memory_object_offset_t *,
299 int *,
300 boolean_t,
301 boolean_t,
302 int);
303 extern kern_return_t dp_memory_object_data_initialize(memory_object_t,
304 memory_object_offset_t,
305 memory_object_cluster_size_t);
306 extern kern_return_t dp_memory_object_data_unlock(memory_object_t,
307 memory_object_offset_t,
308 memory_object_size_t,
309 vm_prot_t);
310 extern kern_return_t dp_memory_object_synchronize(memory_object_t,
311 memory_object_offset_t,
312 memory_object_size_t,
313 vm_sync_t);
314 extern kern_return_t dp_memory_object_map(memory_object_t,
315 vm_prot_t);
316 extern kern_return_t dp_memory_object_last_unmap(memory_object_t);
317 #endif /* _memory_object_server_ */
318 #ifndef _memory_object_default_server_
319 extern kern_return_t default_pager_memory_object_create(
320 memory_object_default_t,
321 vm_size_t,
322 memory_object_t *);
323 #endif /* _memory_object_default_server_ */
324
325 extern void device_pager_reference(memory_object_t);
326 extern void device_pager_deallocate(memory_object_t);
327 extern kern_return_t device_pager_init(memory_object_t,
328 memory_object_control_t,
329 memory_object_cluster_size_t);
330 extern kern_return_t device_pager_terminate(memory_object_t);
331 extern kern_return_t device_pager_data_request(memory_object_t,
332 memory_object_offset_t,
333 memory_object_cluster_size_t,
334 vm_prot_t,
335 memory_object_fault_info_t);
336 extern kern_return_t device_pager_data_return(memory_object_t,
337 memory_object_offset_t,
338 memory_object_cluster_size_t,
339 memory_object_offset_t *,
340 int *,
341 boolean_t,
342 boolean_t,
343 int);
344 extern kern_return_t device_pager_data_initialize(memory_object_t,
345 memory_object_offset_t,
346 memory_object_cluster_size_t);
347 extern kern_return_t device_pager_data_unlock(memory_object_t,
348 memory_object_offset_t,
349 memory_object_size_t,
350 vm_prot_t);
351 extern kern_return_t device_pager_synchronize(memory_object_t,
352 memory_object_offset_t,
353 memory_object_size_t,
354 vm_sync_t);
355 extern kern_return_t device_pager_map(memory_object_t, vm_prot_t);
356 extern kern_return_t device_pager_last_unmap(memory_object_t);
357 extern kern_return_t device_pager_populate_object(
358 memory_object_t device,
359 memory_object_offset_t offset,
360 ppnum_t page_num,
361 vm_size_t size);
362 extern memory_object_t device_pager_setup(
363 memory_object_t,
364 uintptr_t,
365 vm_size_t,
366 int);
367 extern void device_pager_bootstrap(void) __attribute__((section("__TEXT, initcode")));
368
369 extern kern_return_t memory_object_create_named(
370 memory_object_t pager,
371 memory_object_offset_t size,
372 memory_object_control_t *control);
373
374 struct macx_triggers_args;
375 extern int mach_macx_triggers(
376 struct macx_triggers_args *args);
377
378 extern int macx_swapinfo(
379 memory_object_size_t *total_p,
380 memory_object_size_t *avail_p,
381 vm_size_t *pagesize_p,
382 boolean_t *encrypted_p);
383
384 extern void log_stack_execution_failure(addr64_t vaddr, vm_prot_t prot);
385 extern void log_unnest_badness(vm_map_t, vm_map_offset_t, vm_map_offset_t);
386
387 extern int cs_allow_invalid(struct proc *p);
388 extern int cs_invalid_page(addr64_t vaddr);
389 extern boolean_t cs_validate_page(void *blobs,
390 memory_object_offset_t offset,
391 const void *data,
392 boolean_t *tainted);
393
394 extern kern_return_t mach_memory_entry_purgable_control(
395 ipc_port_t entry_port,
396 vm_purgable_t control,
397 int *state);
398
399 extern kern_return_t mach_memory_entry_page_op(
400 ipc_port_t entry_port,
401 vm_object_offset_t offset,
402 int ops,
403 ppnum_t *phys_entry,
404 int *flags);
405
406 extern kern_return_t mach_memory_entry_range_op(
407 ipc_port_t entry_port,
408 vm_object_offset_t offset_beg,
409 vm_object_offset_t offset_end,
410 int ops,
411 int *range);
412
413 extern void mach_memory_entry_port_release(ipc_port_t port);
414 extern void mach_destroy_memory_entry(ipc_port_t port);
415 extern kern_return_t mach_memory_entry_allocate(
416 struct vm_named_entry **user_entry_p,
417 ipc_port_t *user_handle_p);
418
419 extern void vm_paging_map_init(void);
420
421 extern int macx_backing_store_compaction(int flags);
422 extern unsigned int mach_vm_ctl_page_free_wanted(void);
423
424 extern void no_paging_space_action(void);
425 #endif /* _VM_VM_PROTOS_H_ */
426
427 #endif /* XNU_KERNEL_PRIVATE */