]> git.saurik.com Git - apple/xnu.git/blob - osfmk/vm/vm_pageout.h
xnu-792.13.8.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 extern ppnum_t upl_get_highest_page(
91 upl_t upl);
92
93 #ifdef MACH_KERNEL_PRIVATE
94
95 #include <vm/vm_page.h>
96
97 extern unsigned int vm_pageout_scan_event_counter;
98 extern unsigned int vm_zf_count;
99
100 /*
101 * Routines exported to Mach.
102 */
103 extern void vm_pageout(void);
104
105 extern vm_object_t vm_pageout_object_allocate(
106 vm_page_t m,
107 vm_size_t size,
108 vm_object_offset_t offset);
109
110 extern void vm_pageout_object_terminate(
111 vm_object_t object);
112
113 extern vm_page_t vm_pageout_setup(
114 vm_page_t m,
115 vm_object_t new_object,
116 vm_object_offset_t new_offset);
117
118 extern void vm_pageout_cluster(
119 vm_page_t m);
120
121 extern void vm_pageout_initialize_page(
122 vm_page_t m);
123
124 extern void vm_pageclean_setup(
125 vm_page_t m,
126 vm_page_t new_m,
127 vm_object_t new_object,
128 vm_object_offset_t new_offset);
129
130 extern void vm_pageclean_copy(
131 vm_page_t m,
132 vm_page_t new_m,
133 vm_object_t new_object,
134 vm_object_offset_t new_offset);
135
136 /* UPL exported routines and structures */
137
138 #define upl_lock_init(object) mutex_init(&(object)->Lock, 0)
139 #define upl_lock(object) mutex_lock(&(object)->Lock)
140 #define upl_unlock(object) mutex_unlock(&(object)->Lock)
141
142
143 /* universal page list structure */
144
145 struct upl {
146 decl_mutex_data(, Lock) /* Synchronization */
147 int ref_count;
148 int flags;
149 vm_object_t src_object; /* object derived from */
150 vm_object_offset_t offset;
151 upl_size_t size; /* size in bytes of the address space */
152 vm_offset_t kaddr; /* secondary mapping in kernel */
153 vm_object_t map_object;
154 ppnum_t highest_page;
155 #ifdef UPL_DEBUG
156 unsigned int ubc_alias1;
157 unsigned int ubc_alias2;
158 queue_chain_t uplq; /* List of outstanding upls on an obj */
159 #endif /* UPL_DEBUG */
160 };
161
162 /* upl struct flags */
163 #define UPL_PAGE_LIST_MAPPED 0x1
164 #define UPL_KERNEL_MAPPED 0x2
165 #define UPL_CLEAR_DIRTY 0x4
166 #define UPL_COMPOSITE_LIST 0x8
167 #define UPL_INTERNAL 0x10
168 #define UPL_PAGE_SYNC_DONE 0x20
169 #define UPL_DEVICE_MEMORY 0x40
170 #define UPL_PAGEOUT 0x80
171 #define UPL_LITE 0x100
172 #define UPL_IO_WIRE 0x200
173 #define UPL_ACCESS_BLOCKED 0x400
174 #define UPL_ENCRYPTED 0x800
175
176
177 /* flags for upl_create flags parameter */
178 #define UPL_CREATE_EXTERNAL 0
179 #define UPL_CREATE_INTERNAL 0x1
180 #define UPL_CREATE_LITE 0x2
181
182 extern kern_return_t vm_object_iopl_request(
183 vm_object_t object,
184 vm_object_offset_t offset,
185 upl_size_t size,
186 upl_t *upl_ptr,
187 upl_page_info_array_t user_page_list,
188 unsigned int *page_list_count,
189 int cntrl_flags);
190
191 extern kern_return_t vm_object_super_upl_request(
192 vm_object_t object,
193 vm_object_offset_t offset,
194 upl_size_t size,
195 upl_size_t super_cluster,
196 upl_t *upl,
197 upl_page_info_t *user_page_list,
198 unsigned int *page_list_count,
199 int cntrl_flags);
200
201 /* should be just a regular vm_map_enter() */
202 extern kern_return_t vm_map_enter_upl(
203 vm_map_t map,
204 upl_t upl,
205 vm_map_offset_t *dst_addr);
206
207 /* should be just a regular vm_map_remove() */
208 extern kern_return_t vm_map_remove_upl(
209 vm_map_t map,
210 upl_t upl);
211
212 #ifdef UPL_DEBUG
213 extern kern_return_t upl_ubc_alias_set(
214 upl_t upl,
215 unsigned int alias1,
216 unsigned int alias2);
217 extern int upl_ubc_alias_get(
218 upl_t upl,
219 unsigned int * al,
220 unsigned int * al2);
221 #endif /* UPL_DEBUG */
222
223 /* wired page list structure */
224 typedef unsigned long *wpl_array_t;
225
226 extern void vm_page_free_list(
227 register vm_page_t mem);
228
229 extern void vm_page_free_reserve(int pages);
230
231 extern void vm_pageout_throttle_down(vm_page_t page);
232 extern void vm_pageout_throttle_up(vm_page_t page);
233
234 /*
235 * ENCRYPTED SWAP:
236 */
237 extern void upl_encrypt(
238 upl_t upl,
239 upl_offset_t crypt_offset,
240 upl_size_t crypt_size);
241 extern void vm_page_encrypt(
242 vm_page_t page,
243 vm_map_offset_t kernel_map_offset);
244 extern boolean_t vm_pages_encrypted; /* are there encrypted pages ? */
245 extern void vm_page_decrypt(
246 vm_page_t page,
247 vm_map_offset_t kernel_map_offset);
248 extern kern_return_t vm_paging_map_object(
249 vm_map_offset_t *address,
250 vm_page_t page,
251 vm_object_t object,
252 vm_object_offset_t offset,
253 vm_map_size_t *size);
254 extern void vm_paging_unmap_object(
255 vm_object_t object,
256 vm_map_offset_t start,
257 vm_map_offset_t end);
258 decl_simple_lock_data(extern, vm_paging_lock)
259
260 /*
261 * Backing store throttle when BS is exhausted
262 */
263 extern unsigned int vm_backing_store_low;
264
265 #endif /* MACH_KERNEL_PRIVATE */
266
267 extern void vm_countdirtypages(void);
268
269 extern void vm_backing_store_disable(
270 boolean_t suspend);
271
272 extern kern_return_t upl_transpose(
273 upl_t upl1,
274 upl_t upl2);
275
276 #endif /* KERNEL_PRIVATE */
277
278 #endif /* _VM_VM_PAGEOUT_H_ */