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