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