]> git.saurik.com Git - apple/xnu.git/blob - osfmk/vm/vm_fault.h
c8061ad0edc795cc8882b0145e83ac7150589468
[apple/xnu.git] / osfmk / vm / vm_fault.h
1 /*
2 * Copyright (c) 2000 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 * @OSF_COPYRIGHT@
24 */
25 /*
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28 * All Rights Reserved.
29 *
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
35 *
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
39 *
40 * Carnegie Mellon requests users of this software to return to
41 *
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
46 *
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
49 */
50 /*
51 */
52 /*
53 * File: vm/vm_fault.h
54 *
55 * Page fault handling module declarations.
56 */
57
58 #ifndef _VM_VM_FAULT_H_
59 #define _VM_VM_FAULT_H_
60
61 #include <mach/kern_return.h>
62 #include <mach/boolean.h>
63 #include <mach/vm_prot.h>
64 #include <mach/vm_param.h>
65 #include <mach/vm_behavior.h>
66 #include <vm/vm_page.h>
67 #include <vm/vm_object.h>
68 #include <vm/vm_map.h>
69
70 typedef kern_return_t vm_fault_return_t;
71 #define VM_FAULT_SUCCESS 0
72 #define VM_FAULT_RETRY 1
73 #define VM_FAULT_INTERRUPTED 2
74 #define VM_FAULT_MEMORY_SHORTAGE 3
75 #define VM_FAULT_FICTITIOUS_SHORTAGE 4
76 #define VM_FAULT_MEMORY_ERROR 5
77
78 extern void vm_fault_init(void);
79
80 /*
81 * Page fault handling based on vm_object only.
82 */
83
84 extern vm_fault_return_t vm_fault_page(
85 /* Arguments: */
86 vm_object_t first_object, /* Object to begin search */
87 vm_object_offset_t first_offset,/* Offset into object */
88 vm_prot_t fault_type, /* What access is requested */
89 boolean_t must_be_resident,/* Must page be resident? */
90 int interruptible,/* how may fault be interrupted */
91 vm_object_offset_t lo_offset, /* Map entry start */
92 vm_object_offset_t hi_offset, /* Map entry end */
93 vm_behavior_t behavior, /* Expected paging behavior */
94 /* Modifies in place: */
95 vm_prot_t *protection, /* Protection for mapping */
96 /* Returns: */
97 vm_page_t *result_page, /* Page found, if successful */
98 vm_page_t *top_page, /* Page in top object, if
99 * not result_page. */
100 int *type_of_fault, /* if non-zero, return COW, zero-filled, etc...
101 * used by kernel trace point in vm_fault */
102 /* More arguments: */
103 kern_return_t *error_code, /* code if page is in error */
104 boolean_t no_zero_fill, /* don't fill absent pages */
105 boolean_t data_supply, /* treat as data_supply */
106 vm_map_t map,
107 vm_offset_t vaddr);
108
109 extern void vm_fault_cleanup(
110 vm_object_t object,
111 vm_page_t top_page);
112 /*
113 * Page fault handling based on vm_map (or entries therein)
114 */
115
116 extern kern_return_t vm_fault(
117 vm_map_t map,
118 vm_offset_t vaddr,
119 vm_prot_t fault_type,
120 boolean_t change_wiring,
121 int interruptible);
122
123 extern kern_return_t vm_fault_wire(
124 vm_map_t map,
125 vm_map_entry_t entry,
126 pmap_t pmap);
127
128 extern void vm_fault_unwire(
129 vm_map_t map,
130 vm_map_entry_t entry,
131 boolean_t deallocate,
132 pmap_t pmap);
133
134 extern kern_return_t vm_fault_copy(
135 vm_object_t src_object,
136 vm_object_offset_t src_offset,
137 vm_size_t *src_size, /* INOUT */
138 vm_object_t dst_object,
139 vm_object_offset_t dst_offset,
140 vm_map_t dst_map,
141 vm_map_version_t *dst_version,
142 int interruptible);
143
144 #endif /* _VM_VM_FAULT_H_ */