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 #ifdef MACH_KERNEL_PRIVATE
92 #include <vm/vm_page.h>
94 extern unsigned int vm_pageout_scan_event_counter
;
95 extern unsigned int vm_zf_count
;
98 * Routines exported to Mach.
100 extern void vm_pageout(void);
102 extern vm_object_t
vm_pageout_object_allocate(
105 vm_object_offset_t offset
);
107 extern void vm_pageout_object_terminate(
110 extern vm_page_t
vm_pageout_setup(
112 vm_object_t new_object
,
113 vm_object_offset_t new_offset
);
115 extern void vm_pageout_cluster(
118 extern void vm_pageout_initialize_page(
121 extern void vm_pageclean_setup(
124 vm_object_t new_object
,
125 vm_object_offset_t new_offset
);
127 extern void vm_pageclean_copy(
130 vm_object_t new_object
,
131 vm_object_offset_t new_offset
);
133 /* UPL exported routines and structures */
135 #define upl_lock_init(object) mutex_init(&(object)->Lock, 0)
136 #define upl_lock(object) mutex_lock(&(object)->Lock)
137 #define upl_unlock(object) mutex_unlock(&(object)->Lock)
140 /* universal page list structure */
143 decl_mutex_data(, Lock
) /* Synchronization */
146 vm_object_t src_object
; /* object derived from */
147 vm_object_offset_t offset
;
148 upl_size_t size
; /* size in bytes of the address space */
149 vm_offset_t kaddr
; /* secondary mapping in kernel */
150 vm_object_t map_object
;
152 unsigned int ubc_alias1
;
153 unsigned int ubc_alias2
;
154 queue_chain_t uplq
; /* List of outstanding upls on an obj */
155 #endif /* UPL_DEBUG */
158 /* upl struct flags */
159 #define UPL_PAGE_LIST_MAPPED 0x1
160 #define UPL_KERNEL_MAPPED 0x2
161 #define UPL_CLEAR_DIRTY 0x4
162 #define UPL_COMPOSITE_LIST 0x8
163 #define UPL_INTERNAL 0x10
164 #define UPL_PAGE_SYNC_DONE 0x20
165 #define UPL_DEVICE_MEMORY 0x40
166 #define UPL_PAGEOUT 0x80
167 #define UPL_LITE 0x100
168 #define UPL_IO_WIRE 0x200
169 #define UPL_ACCESS_BLOCKED 0x400
170 #define UPL_ENCRYPTED 0x800
173 /* flags for upl_create flags parameter */
174 #define UPL_CREATE_EXTERNAL 0
175 #define UPL_CREATE_INTERNAL 0x1
176 #define UPL_CREATE_LITE 0x2
178 extern kern_return_t
vm_object_iopl_request(
180 vm_object_offset_t offset
,
183 upl_page_info_array_t user_page_list
,
184 unsigned int *page_list_count
,
187 extern kern_return_t
vm_object_super_upl_request(
189 vm_object_offset_t offset
,
191 upl_size_t super_cluster
,
193 upl_page_info_t
*user_page_list
,
194 unsigned int *page_list_count
,
197 /* should be just a regular vm_map_enter() */
198 extern kern_return_t
vm_map_enter_upl(
201 vm_map_offset_t
*dst_addr
);
203 /* should be just a regular vm_map_remove() */
204 extern kern_return_t
vm_map_remove_upl(
209 extern kern_return_t
upl_ubc_alias_set(
212 unsigned int alias2
);
213 extern int upl_ubc_alias_get(
217 #endif /* UPL_DEBUG */
219 /* wired page list structure */
220 typedef unsigned long *wpl_array_t
;
222 extern void vm_page_free_list(
223 register vm_page_t mem
);
225 extern void vm_page_free_reserve(int pages
);
227 extern void vm_pageout_throttle_down(vm_page_t page
);
228 extern void vm_pageout_throttle_up(vm_page_t page
);
233 extern void upl_encrypt(
235 upl_offset_t crypt_offset
,
236 upl_size_t crypt_size
);
237 extern void vm_page_encrypt(
239 vm_map_offset_t kernel_map_offset
);
240 extern boolean_t vm_pages_encrypted
; /* are there encrypted pages ? */
241 extern void vm_page_decrypt(
243 vm_map_offset_t kernel_map_offset
);
244 extern kern_return_t
vm_paging_map_object(
245 vm_map_offset_t
*address
,
248 vm_object_offset_t offset
,
249 vm_map_size_t
*size
);
250 extern void vm_paging_unmap_object(
252 vm_map_offset_t start
,
253 vm_map_offset_t end
);
254 decl_simple_lock_data(extern, vm_paging_lock
)
257 * Backing store throttle when BS is exhausted
259 extern unsigned int vm_backing_store_low
;
261 #endif /* MACH_KERNEL_PRIVATE */
263 extern void vm_countdirtypages(void);
265 extern void vm_backing_store_disable(
268 extern kern_return_t
upl_transpose(
272 #endif /* KERNEL_PRIVATE */
274 #endif /* _VM_VM_PAGEOUT_H_ */