]> git.saurik.com Git - apple/xnu.git/blob - osfmk/vm/vm_kern.h
435dae135bafdee461efe51595216745814dd057
[apple/xnu.git] / osfmk / vm / vm_kern.h
1 /*
2 * Copyright (c) 2000-2006 Apple Computer, 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 * @OSF_COPYRIGHT@
30 */
31 /*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
34 * All Rights Reserved.
35 *
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
41 *
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56 /*
57 */
58 /*
59 * File: vm/vm_kern.h
60 * Author: Avadis Tevanian, Jr., Michael Wayne Young
61 * Date: 1985
62 *
63 * Kernel memory management definitions.
64 */
65
66 #ifndef _VM_VM_KERN_H_
67 #define _VM_VM_KERN_H_
68
69 #include <mach/mach_types.h>
70 #include <mach/boolean.h>
71 #include <mach/kern_return.h>
72
73 #ifdef KERNEL_PRIVATE
74
75 #ifdef XNU_KERNEL_PRIVATE
76
77 extern kern_return_t kernel_memory_allocate(
78 vm_map_t map,
79 vm_offset_t *addrp,
80 vm_size_t size,
81 vm_offset_t mask,
82 int flags,
83 vm_tag_t tag);
84
85 /* flags for kernel_memory_allocate */
86 #define KMA_HERE 0x01
87 #define KMA_NOPAGEWAIT 0x02
88 #define KMA_KOBJECT 0x04
89 #define KMA_LOMEM 0x08
90 #define KMA_GUARD_FIRST 0x10
91 #define KMA_GUARD_LAST 0x20
92 #define KMA_PERMANENT 0x40
93 #define KMA_NOENCRYPT 0x80
94 #define KMA_KSTACK 0x100
95 #define KMA_VAONLY 0x200
96 #define KMA_COMPRESSOR 0x400 /* Pages belonging to the compressor are not on the paging queues, nor are they counted as wired. */
97
98 extern kern_return_t kmem_alloc_contig(
99 vm_map_t map,
100 vm_offset_t *addrp,
101 vm_size_t size,
102 vm_offset_t mask,
103 ppnum_t max_pnum,
104 ppnum_t pnum_mask,
105 int flags,
106 vm_tag_t tag);
107
108 extern kern_return_t kmem_alloc(
109 vm_map_t map,
110 vm_offset_t *addrp,
111 vm_size_t size,
112 vm_tag_t tag);
113
114 extern kern_return_t kmem_alloc_pageable(
115 vm_map_t map,
116 vm_offset_t *addrp,
117 vm_size_t size,
118 vm_tag_t tag);
119
120 extern kern_return_t kmem_alloc_aligned(
121 vm_map_t map,
122 vm_offset_t *addrp,
123 vm_size_t size,
124 vm_tag_t tag);
125
126 extern kern_return_t kmem_realloc(
127 vm_map_t map,
128 vm_offset_t oldaddr,
129 vm_size_t oldsize,
130 vm_offset_t *newaddrp,
131 vm_size_t newsize,
132 vm_tag_t tag);
133
134 extern void kmem_free(
135 vm_map_t map,
136 vm_offset_t addr,
137 vm_size_t size);
138
139 extern kern_return_t kmem_suballoc(
140 vm_map_t parent,
141 vm_offset_t *addr,
142 vm_size_t size,
143 boolean_t pageable,
144 int flags,
145 vm_map_t *new_map);
146
147 extern kern_return_t kmem_alloc_kobject(
148 vm_map_t map,
149 vm_offset_t *addrp,
150 vm_size_t size,
151 vm_tag_t tag);
152
153 extern kern_return_t kernel_memory_populate(
154 vm_map_t map,
155 vm_offset_t addr,
156 vm_size_t size,
157 int flags,
158 vm_tag_t tag);
159
160 extern void kernel_memory_depopulate(
161 vm_map_t map,
162 vm_offset_t addr,
163 vm_size_t size,
164 int flags);
165
166 extern kern_return_t memory_object_iopl_request(
167 ipc_port_t port,
168 memory_object_offset_t offset,
169 upl_size_t *upl_size,
170 upl_t *upl_ptr,
171 upl_page_info_array_t user_page_list,
172 unsigned int *page_list_count,
173 upl_control_flags_t *flags);
174
175 struct mach_memory_info;
176 extern kern_return_t vm_page_diagnose(struct mach_memory_info * sites,
177 unsigned int num_sites);
178
179 extern vm_tag_t vm_tag_bt(void);
180
181 extern vm_tag_t vm_tag_alloc(vm_allocation_site_t * site);
182
183 extern void vm_tag_alloc_locked(vm_allocation_site_t * site);
184
185 extern vm_tag_t vm_tag_bt_debug(void);
186
187 extern boolean_t vm_kernel_map_is_kernel(vm_map_t map);
188
189 extern ppnum_t kernel_pmap_present_mapping(uint64_t vaddr, uint64_t * pvincr);
190
191 #else /* XNU_KERNEL_PRIVATE */
192
193 extern kern_return_t kmem_alloc(
194 vm_map_t map,
195 vm_offset_t *addrp,
196 vm_size_t size);
197
198 extern kern_return_t kmem_alloc_pageable(
199 vm_map_t map,
200 vm_offset_t *addrp,
201 vm_size_t size);
202
203 extern kern_return_t kmem_alloc_kobject(
204 vm_map_t map,
205 vm_offset_t *addrp,
206 vm_size_t size);
207
208 extern void kmem_free(
209 vm_map_t map,
210 vm_offset_t addr,
211 vm_size_t size);
212
213 #endif /* !XNU_KERNEL_PRIVATE */
214
215
216 #ifdef MACH_KERNEL_PRIVATE
217
218 extern void kmem_init(
219 vm_offset_t start,
220 vm_offset_t end);
221
222
223 extern kern_return_t copyinmap(
224 vm_map_t map,
225 vm_map_offset_t fromaddr,
226 void *todata,
227 vm_size_t length);
228
229 extern kern_return_t copyoutmap(
230 vm_map_t map,
231 void *fromdata,
232 vm_map_offset_t toaddr,
233 vm_size_t length);
234
235 extern kern_return_t vm_conflict_check(
236 vm_map_t map,
237 vm_map_offset_t off,
238 vm_map_size_t len,
239 memory_object_t pager,
240 vm_object_offset_t file_off);
241
242 extern kern_return_t kmem_alloc_external(
243 vm_map_t map,
244 vm_offset_t *addrp,
245 vm_size_t size);
246
247 extern kern_return_t kmem_alloc_kobject_external(
248 vm_map_t map,
249 vm_offset_t *addrp,
250 vm_size_t size);
251
252 extern kern_return_t kmem_alloc_pageable_external(
253 vm_map_t map,
254 vm_offset_t *addrp,
255 vm_size_t size);
256
257 #endif /* MACH_KERNEL_PRIVATE */
258
259 extern vm_map_t kernel_map;
260 extern vm_map_t kernel_pageable_map;
261 extern vm_map_t ipc_kernel_map;
262
263 #endif /* KERNEL_PRIVATE */
264
265 #ifdef KERNEL
266
267 extern vm_offset_t vm_kernel_addrperm_ext;
268
269 extern void vm_kernel_addrperm_external(
270 vm_offset_t addr,
271 vm_offset_t *perm_addr);
272
273 extern void vm_kernel_unslide_or_perm_external(
274 vm_offset_t addr,
275 vm_offset_t *up_addr);
276 #endif /* KERNEL */
277 #endif /* _VM_VM_KERN_H_ */