]> git.saurik.com Git - apple/xnu.git/blob - osfmk/vm/vm_pageout.h
xnu-792.12.6.tar.gz
[apple/xnu.git] / osfmk / vm / vm_pageout.h
1 /*
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * @OSF_COPYRIGHT@
32 */
33 /*
34 * Mach Operating System
35 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
36 * All Rights Reserved.
37 *
38 * Permission to use, copy, modify and distribute this software and its
39 * documentation is hereby granted, provided that both the copyright
40 * notice and this permission notice appear in all copies of the
41 * software, derivative works or modified versions, and any portions
42 * thereof, and that both notices appear in supporting documentation.
43 *
44 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
45 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
46 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
47 *
48 * Carnegie Mellon requests users of this software to return to
49 *
50 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
51 * School of Computer Science
52 * Carnegie Mellon University
53 * Pittsburgh PA 15213-3890
54 *
55 * any improvements or extensions that they make and grant Carnegie Mellon
56 * the rights to redistribute these changes.
57 */
58 /*
59 */
60 /*
61 * File: vm/vm_pageout.h
62 * Author: Avadis Tevanian, Jr.
63 * Date: 1986
64 *
65 * Declarations for the pageout daemon interface.
66 */
67
68 #ifndef _VM_VM_PAGEOUT_H_
69 #define _VM_VM_PAGEOUT_H_
70
71 #ifdef KERNEL_PRIVATE
72
73 #include <mach/mach_types.h>
74 #include <mach/boolean.h>
75 #include <mach/machine/vm_types.h>
76 #include <mach/memory_object_types.h>
77
78 #include <kern/kern_types.h>
79 #include <kern/lock.h>
80
81 extern kern_return_t vm_map_create_upl(
82 vm_map_t map,
83 vm_map_address_t offset,
84 upl_size_t *upl_size,
85 upl_t *upl,
86 upl_page_info_array_t page_list,
87 unsigned int *count,
88 int *flags);
89
90 #ifdef MACH_KERNEL_PRIVATE
91
92 #include <vm/vm_page.h>
93
94 extern unsigned int vm_pageout_scan_event_counter;
95 extern unsigned int vm_zf_count;
96
97 /*
98 * Routines exported to Mach.
99 */
100 extern void vm_pageout(void);
101
102 extern vm_object_t vm_pageout_object_allocate(
103 vm_page_t m,
104 vm_size_t size,
105 vm_object_offset_t offset);
106
107 extern void vm_pageout_object_terminate(
108 vm_object_t object);
109
110 extern vm_page_t vm_pageout_setup(
111 vm_page_t m,
112 vm_object_t new_object,
113 vm_object_offset_t new_offset);
114
115 extern void vm_pageout_cluster(
116 vm_page_t m);
117
118 extern void vm_pageout_initialize_page(
119 vm_page_t m);
120
121 extern void vm_pageclean_setup(
122 vm_page_t m,
123 vm_page_t new_m,
124 vm_object_t new_object,
125 vm_object_offset_t new_offset);
126
127 extern void vm_pageclean_copy(
128 vm_page_t m,
129 vm_page_t new_m,
130 vm_object_t new_object,
131 vm_object_offset_t new_offset);
132
133 /* UPL exported routines and structures */
134
135 #define upl_lock_init(object) mutex_init(&(object)->Lock, 0)
136 #define upl_lock(object) mutex_lock(&(object)->Lock)
137 #define upl_unlock(object) mutex_unlock(&(object)->Lock)
138
139
140 /* universal page list structure */
141
142 struct upl {
143 decl_mutex_data(, Lock) /* Synchronization */
144 int ref_count;
145 int flags;
146 vm_object_t src_object; /* object derived from */
147 vm_object_offset_t offset;
148 upl_size_t size; /* size in bytes of the address space */
149 vm_offset_t kaddr; /* secondary mapping in kernel */
150 vm_object_t map_object;
151 #ifdef UPL_DEBUG
152 unsigned int ubc_alias1;
153 unsigned int ubc_alias2;
154 queue_chain_t uplq; /* List of outstanding upls on an obj */
155 #endif /* UPL_DEBUG */
156 };
157
158 /* upl struct flags */
159 #define UPL_PAGE_LIST_MAPPED 0x1
160 #define UPL_KERNEL_MAPPED 0x2
161 #define UPL_CLEAR_DIRTY 0x4
162 #define UPL_COMPOSITE_LIST 0x8
163 #define UPL_INTERNAL 0x10
164 #define UPL_PAGE_SYNC_DONE 0x20
165 #define UPL_DEVICE_MEMORY 0x40
166 #define UPL_PAGEOUT 0x80
167 #define UPL_LITE 0x100
168 #define UPL_IO_WIRE 0x200
169 #define UPL_ACCESS_BLOCKED 0x400
170 #define UPL_ENCRYPTED 0x800
171
172
173 /* flags for upl_create flags parameter */
174 #define UPL_CREATE_EXTERNAL 0
175 #define UPL_CREATE_INTERNAL 0x1
176 #define UPL_CREATE_LITE 0x2
177
178 extern kern_return_t vm_object_iopl_request(
179 vm_object_t object,
180 vm_object_offset_t offset,
181 upl_size_t size,
182 upl_t *upl_ptr,
183 upl_page_info_array_t user_page_list,
184 unsigned int *page_list_count,
185 int cntrl_flags);
186
187 extern kern_return_t vm_object_super_upl_request(
188 vm_object_t object,
189 vm_object_offset_t offset,
190 upl_size_t size,
191 upl_size_t super_cluster,
192 upl_t *upl,
193 upl_page_info_t *user_page_list,
194 unsigned int *page_list_count,
195 int cntrl_flags);
196
197 /* should be just a regular vm_map_enter() */
198 extern kern_return_t vm_map_enter_upl(
199 vm_map_t map,
200 upl_t upl,
201 vm_map_offset_t *dst_addr);
202
203 /* should be just a regular vm_map_remove() */
204 extern kern_return_t vm_map_remove_upl(
205 vm_map_t map,
206 upl_t upl);
207
208 #ifdef UPL_DEBUG
209 extern kern_return_t upl_ubc_alias_set(
210 upl_t upl,
211 unsigned int alias1,
212 unsigned int alias2);
213 extern int upl_ubc_alias_get(
214 upl_t upl,
215 unsigned int * al,
216 unsigned int * al2);
217 #endif /* UPL_DEBUG */
218
219 /* wired page list structure */
220 typedef unsigned long *wpl_array_t;
221
222 extern void vm_page_free_list(
223 register vm_page_t mem);
224
225 extern void vm_page_free_reserve(int pages);
226
227 extern void vm_pageout_throttle_down(vm_page_t page);
228 extern void vm_pageout_throttle_up(vm_page_t page);
229
230 /*
231 * ENCRYPTED SWAP:
232 */
233 extern void upl_encrypt(
234 upl_t upl,
235 upl_offset_t crypt_offset,
236 upl_size_t crypt_size);
237 extern void vm_page_encrypt(
238 vm_page_t page,
239 vm_map_offset_t kernel_map_offset);
240 extern boolean_t vm_pages_encrypted; /* are there encrypted pages ? */
241 extern void vm_page_decrypt(
242 vm_page_t page,
243 vm_map_offset_t kernel_map_offset);
244 extern kern_return_t vm_paging_map_object(
245 vm_map_offset_t *address,
246 vm_page_t page,
247 vm_object_t object,
248 vm_object_offset_t offset,
249 vm_map_size_t *size);
250 extern void vm_paging_unmap_object(
251 vm_object_t object,
252 vm_map_offset_t start,
253 vm_map_offset_t end);
254 decl_simple_lock_data(extern, vm_paging_lock)
255
256 /*
257 * Backing store throttle when BS is exhausted
258 */
259 extern unsigned int vm_backing_store_low;
260
261 #endif /* MACH_KERNEL_PRIVATE */
262
263 extern void vm_countdirtypages(void);
264
265 extern void vm_backing_store_disable(
266 boolean_t suspend);
267
268 extern kern_return_t upl_transpose(
269 upl_t upl1,
270 upl_t upl2);
271
272 #endif /* KERNEL_PRIVATE */
273
274 #endif /* _VM_VM_PAGEOUT_H_ */