2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
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.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
34 * Mach Operating System
35 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
36 * All Rights Reserved.
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.
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.
48 * Carnegie Mellon requests users of this software to return to
50 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
51 * School of Computer Science
52 * Carnegie Mellon University
53 * Pittsburgh PA 15213-3890
55 * any improvements or extensions that they make and grant Carnegie Mellon
56 * the rights to redistribute these changes.
61 * File: vm/vm_pageout.h
62 * Author: Avadis Tevanian, Jr.
65 * Declarations for the pageout daemon interface.
68 #ifndef _VM_VM_PAGEOUT_H_
69 #define _VM_VM_PAGEOUT_H_
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>
78 #include <kern/kern_types.h>
79 #include <kern/lock.h>
81 extern kern_return_t
vm_map_create_upl(
83 vm_map_address_t offset
,
86 upl_page_info_array_t page_list
,
90 extern ppnum_t
upl_get_highest_page(
93 #ifdef MACH_KERNEL_PRIVATE
95 #include <vm/vm_page.h>
97 extern unsigned int vm_pageout_scan_event_counter
;
98 extern unsigned int vm_zf_count
;
101 * Routines exported to Mach.
103 extern void vm_pageout(void);
105 extern vm_object_t
vm_pageout_object_allocate(
108 vm_object_offset_t offset
);
110 extern void vm_pageout_object_terminate(
113 extern vm_page_t
vm_pageout_setup(
115 vm_object_t new_object
,
116 vm_object_offset_t new_offset
);
118 extern void vm_pageout_cluster(
121 extern void vm_pageout_initialize_page(
124 extern void vm_pageclean_setup(
127 vm_object_t new_object
,
128 vm_object_offset_t new_offset
);
130 extern void vm_pageclean_copy(
133 vm_object_t new_object
,
134 vm_object_offset_t new_offset
);
136 /* UPL exported routines and structures */
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)
143 /* universal page list structure */
146 decl_mutex_data(, Lock
) /* Synchronization */
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
;
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 */
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
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
182 extern kern_return_t
vm_object_iopl_request(
184 vm_object_offset_t offset
,
187 upl_page_info_array_t user_page_list
,
188 unsigned int *page_list_count
,
191 extern kern_return_t
vm_object_super_upl_request(
193 vm_object_offset_t offset
,
195 upl_size_t super_cluster
,
197 upl_page_info_t
*user_page_list
,
198 unsigned int *page_list_count
,
201 /* should be just a regular vm_map_enter() */
202 extern kern_return_t
vm_map_enter_upl(
205 vm_map_offset_t
*dst_addr
);
207 /* should be just a regular vm_map_remove() */
208 extern kern_return_t
vm_map_remove_upl(
213 extern kern_return_t
upl_ubc_alias_set(
216 unsigned int alias2
);
217 extern int upl_ubc_alias_get(
221 #endif /* UPL_DEBUG */
223 /* wired page list structure */
224 typedef unsigned long *wpl_array_t
;
226 extern void vm_page_free_list(
227 register vm_page_t mem
);
229 extern void vm_page_free_reserve(int pages
);
231 extern void vm_pageout_throttle_down(vm_page_t page
);
232 extern void vm_pageout_throttle_up(vm_page_t page
);
237 extern void upl_encrypt(
239 upl_offset_t crypt_offset
,
240 upl_size_t crypt_size
);
241 extern void vm_page_encrypt(
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(
247 vm_map_offset_t kernel_map_offset
);
248 extern kern_return_t
vm_paging_map_object(
249 vm_map_offset_t
*address
,
252 vm_object_offset_t offset
,
253 vm_map_size_t
*size
);
254 extern void vm_paging_unmap_object(
256 vm_map_offset_t start
,
257 vm_map_offset_t end
);
258 decl_simple_lock_data(extern, vm_paging_lock
)
261 * Backing store throttle when BS is exhausted
263 extern unsigned int vm_backing_store_low
;
265 #endif /* MACH_KERNEL_PRIVATE */
267 extern void vm_countdirtypages(void);
269 extern void vm_backing_store_disable(
272 extern kern_return_t
upl_transpose(
276 #endif /* KERNEL_PRIVATE */
278 #endif /* _VM_VM_PAGEOUT_H_ */