]> git.saurik.com Git - apple/xnu.git/blame - osfmk/vm/vm_kern.h
xnu-3248.60.10.tar.gz
[apple/xnu.git] / osfmk / vm / vm_kern.h
CommitLineData
1c79356b 1/*
2d21ac55 2 * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
A
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.
8f6c56a5 14 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
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
91447636 69#include <mach/mach_types.h>
1c79356b
A
70#include <mach/boolean.h>
71#include <mach/kern_return.h>
1c79356b 72
91447636 73#ifdef KERNEL_PRIVATE
1c79356b 74
3e170ce0
A
75#ifdef XNU_KERNEL_PRIVATE
76
1c79356b
A
77extern 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,
3e170ce0
A
82 int flags,
83 vm_tag_t tag);
1c79356b
A
84
85/* flags for kernel_memory_allocate */
86#define KMA_HERE 0x01
87#define KMA_NOPAGEWAIT 0x02
88#define KMA_KOBJECT 0x04
0c530ab8 89#define KMA_LOMEM 0x08
2d21ac55
A
90#define KMA_GUARD_FIRST 0x10
91#define KMA_GUARD_LAST 0x20
b0d623f7 92#define KMA_PERMANENT 0x40
0b4c1975 93#define KMA_NOENCRYPT 0x80
316670eb 94#define KMA_KSTACK 0x100
39236c6e
A
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. */
1c79356b
A
97
98extern 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,
2d21ac55 103 ppnum_t max_pnum,
b0d623f7 104 ppnum_t pnum_mask,
3e170ce0
A
105 int flags,
106 vm_tag_t tag);
1c79356b
A
107
108extern kern_return_t kmem_alloc(
109 vm_map_t map,
110 vm_offset_t *addrp,
3e170ce0
A
111 vm_size_t size,
112 vm_tag_t tag);
1c79356b
A
113
114extern kern_return_t kmem_alloc_pageable(
115 vm_map_t map,
116 vm_offset_t *addrp,
3e170ce0
A
117 vm_size_t size,
118 vm_tag_t tag);
1c79356b 119
1c79356b
A
120extern kern_return_t kmem_alloc_aligned(
121 vm_map_t map,
122 vm_offset_t *addrp,
3e170ce0
A
123 vm_size_t size,
124 vm_tag_t tag);
1c79356b
A
125
126extern 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,
3e170ce0
A
131 vm_size_t newsize,
132 vm_tag_t tag);
1c79356b
A
133
134extern void kmem_free(
135 vm_map_t map,
136 vm_offset_t addr,
137 vm_size_t size);
138
139extern kern_return_t kmem_suballoc(
140 vm_map_t parent,
141 vm_offset_t *addr,
142 vm_size_t size,
143 boolean_t pageable,
b0d623f7 144 int flags,
1c79356b
A
145 vm_map_t *new_map);
146
b0d623f7 147extern kern_return_t kmem_alloc_kobject(
2d21ac55
A
148 vm_map_t map,
149 vm_offset_t *addrp,
3e170ce0
A
150 vm_size_t size,
151 vm_tag_t tag);
2d21ac55 152
39236c6e
A
153extern kern_return_t kernel_memory_populate(
154 vm_map_t map,
155 vm_offset_t addr,
156 vm_size_t size,
3e170ce0
A
157 int flags,
158 vm_tag_t tag);
159
39236c6e
A
160extern void kernel_memory_depopulate(
161 vm_map_t map,
162 vm_offset_t addr,
163 vm_size_t size,
164 int flags);
165
3e170ce0
A
166extern 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
175struct mach_memory_info;
176extern kern_return_t vm_page_diagnose(struct mach_memory_info * sites,
177 unsigned int num_sites);
178
179extern vm_tag_t vm_tag_bt(void);
180
181extern vm_tag_t vm_tag_alloc(vm_allocation_site_t * site);
182
183extern void vm_tag_alloc_locked(vm_allocation_site_t * site);
184
185extern vm_tag_t vm_tag_bt_debug(void);
186
187extern boolean_t vm_kernel_map_is_kernel(vm_map_t map);
188
189extern ppnum_t kernel_pmap_present_mapping(uint64_t vaddr, uint64_t * pvincr);
190
191#else /* XNU_KERNEL_PRIVATE */
192
193extern kern_return_t kmem_alloc(
194 vm_map_t map,
195 vm_offset_t *addrp,
196 vm_size_t size);
197
198extern kern_return_t kmem_alloc_pageable(
199 vm_map_t map,
200 vm_offset_t *addrp,
201 vm_size_t size);
202
203extern kern_return_t kmem_alloc_kobject(
204 vm_map_t map,
205 vm_offset_t *addrp,
206 vm_size_t size);
207
208extern 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
2d21ac55
A
216#ifdef MACH_KERNEL_PRIVATE
217
218extern void kmem_init(
219 vm_offset_t start,
39236c6e 220 vm_offset_t end);
2d21ac55
A
221
222
91447636 223extern kern_return_t copyinmap(
1c79356b 224 vm_map_t map,
91447636
A
225 vm_map_offset_t fromaddr,
226 void *todata,
1c79356b
A
227 vm_size_t length);
228
91447636 229extern kern_return_t copyoutmap(
1c79356b 230 vm_map_t map,
91447636
A
231 void *fromdata,
232 vm_map_offset_t toaddr,
1c79356b
A
233 vm_size_t length);
234
9bccf70c
A
235extern kern_return_t vm_conflict_check(
236 vm_map_t map,
91447636
A
237 vm_map_offset_t off,
238 vm_map_size_t len,
9bccf70c
A
239 memory_object_t pager,
240 vm_object_offset_t file_off);
241
3e170ce0
A
242extern kern_return_t kmem_alloc_external(
243 vm_map_t map,
244 vm_offset_t *addrp,
245 vm_size_t size);
246
247extern kern_return_t kmem_alloc_kobject_external(
248 vm_map_t map,
249 vm_offset_t *addrp,
250 vm_size_t size);
251
252extern kern_return_t kmem_alloc_pageable_external(
253 vm_map_t map,
254 vm_offset_t *addrp,
255 vm_size_t size);
256
91447636
A
257#endif /* MACH_KERNEL_PRIVATE */
258
1c79356b
A
259extern vm_map_t kernel_map;
260extern vm_map_t kernel_pageable_map;
261extern vm_map_t ipc_kernel_map;
262
91447636
A
263#endif /* KERNEL_PRIVATE */
264
3e170ce0
A
265#ifdef KERNEL
266
267extern vm_offset_t vm_kernel_addrperm_ext;
268
269extern void vm_kernel_addrperm_external(
270 vm_offset_t addr,
271 vm_offset_t *perm_addr);
272
273extern void vm_kernel_unslide_or_perm_external(
274 vm_offset_t addr,
275 vm_offset_t *up_addr);
276#endif /* KERNEL */
1c79356b 277#endif /* _VM_VM_KERN_H_ */