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