2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28 * All Rights Reserved.
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.
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.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
53 * File: vm/vm_pageout.h
54 * Author: Avadis Tevanian, Jr.
57 * Declarations for the pageout daemon interface.
60 #ifndef _VM_VM_PAGEOUT_H_
61 #define _VM_VM_PAGEOUT_H_
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>
70 #include <kern/kern_types.h>
71 #include <kern/lock.h>
73 extern kern_return_t
vm_map_create_upl(
75 vm_map_address_t offset
,
78 upl_page_info_array_t page_list
,
82 extern ppnum_t
upl_get_highest_page(
85 #ifdef MACH_KERNEL_PRIVATE
87 #include <vm/vm_page.h>
89 extern unsigned int vm_pageout_scan_event_counter
;
90 extern unsigned int vm_zf_count
;
93 * Routines exported to Mach.
95 extern void vm_pageout(void);
97 extern vm_object_t
vm_pageout_object_allocate(
100 vm_object_offset_t offset
);
102 extern void vm_pageout_object_terminate(
105 extern vm_page_t
vm_pageout_setup(
107 vm_object_t new_object
,
108 vm_object_offset_t new_offset
);
110 extern void vm_pageout_cluster(
113 extern void vm_pageout_initialize_page(
116 extern void vm_pageclean_setup(
119 vm_object_t new_object
,
120 vm_object_offset_t new_offset
);
122 extern void vm_pageclean_copy(
125 vm_object_t new_object
,
126 vm_object_offset_t new_offset
);
128 /* UPL exported routines and structures */
130 #define upl_lock_init(object) mutex_init(&(object)->Lock, 0)
131 #define upl_lock(object) mutex_lock(&(object)->Lock)
132 #define upl_unlock(object) mutex_unlock(&(object)->Lock)
135 /* universal page list structure */
138 decl_mutex_data(, Lock
) /* Synchronization */
141 vm_object_t src_object
; /* object derived from */
142 vm_object_offset_t offset
;
143 upl_size_t size
; /* size in bytes of the address space */
144 vm_offset_t kaddr
; /* secondary mapping in kernel */
145 vm_object_t map_object
;
146 ppnum_t highest_page
;
148 unsigned int ubc_alias1
;
149 unsigned int ubc_alias2
;
150 queue_chain_t uplq
; /* List of outstanding upls on an obj */
151 #endif /* UPL_DEBUG */
154 /* upl struct flags */
155 #define UPL_PAGE_LIST_MAPPED 0x1
156 #define UPL_KERNEL_MAPPED 0x2
157 #define UPL_CLEAR_DIRTY 0x4
158 #define UPL_COMPOSITE_LIST 0x8
159 #define UPL_INTERNAL 0x10
160 #define UPL_PAGE_SYNC_DONE 0x20
161 #define UPL_DEVICE_MEMORY 0x40
162 #define UPL_PAGEOUT 0x80
163 #define UPL_LITE 0x100
164 #define UPL_IO_WIRE 0x200
165 #define UPL_ACCESS_BLOCKED 0x400
166 #define UPL_ENCRYPTED 0x800
169 /* flags for upl_create flags parameter */
170 #define UPL_CREATE_EXTERNAL 0
171 #define UPL_CREATE_INTERNAL 0x1
172 #define UPL_CREATE_LITE 0x2
174 extern kern_return_t
vm_object_iopl_request(
176 vm_object_offset_t offset
,
179 upl_page_info_array_t user_page_list
,
180 unsigned int *page_list_count
,
183 extern kern_return_t
vm_object_super_upl_request(
185 vm_object_offset_t offset
,
187 upl_size_t super_cluster
,
189 upl_page_info_t
*user_page_list
,
190 unsigned int *page_list_count
,
193 /* should be just a regular vm_map_enter() */
194 extern kern_return_t
vm_map_enter_upl(
197 vm_map_offset_t
*dst_addr
);
199 /* should be just a regular vm_map_remove() */
200 extern kern_return_t
vm_map_remove_upl(
205 extern kern_return_t
upl_ubc_alias_set(
208 unsigned int alias2
);
209 extern int upl_ubc_alias_get(
213 #endif /* UPL_DEBUG */
215 /* wired page list structure */
216 typedef unsigned long *wpl_array_t
;
218 extern void vm_page_free_list(
219 register vm_page_t mem
);
221 extern void vm_page_free_reserve(int pages
);
223 extern void vm_pageout_throttle_down(vm_page_t page
);
224 extern void vm_pageout_throttle_up(vm_page_t page
);
229 extern void upl_encrypt(
231 upl_offset_t crypt_offset
,
232 upl_size_t crypt_size
);
233 extern void vm_page_encrypt(
235 vm_map_offset_t kernel_map_offset
);
236 extern boolean_t vm_pages_encrypted
; /* are there encrypted pages ? */
237 extern void vm_page_decrypt(
239 vm_map_offset_t kernel_map_offset
);
240 extern kern_return_t
vm_paging_map_object(
241 vm_map_offset_t
*address
,
244 vm_object_offset_t offset
,
245 vm_map_size_t
*size
);
246 extern void vm_paging_unmap_object(
248 vm_map_offset_t start
,
249 vm_map_offset_t end
);
250 decl_simple_lock_data(extern, vm_paging_lock
)
253 * Backing store throttle when BS is exhausted
255 extern unsigned int vm_backing_store_low
;
257 #endif /* MACH_KERNEL_PRIVATE */
259 extern void vm_countdirtypages(void);
261 extern void vm_backing_store_disable(
264 extern kern_return_t
upl_transpose(
268 #endif /* KERNEL_PRIVATE */
270 #endif /* _VM_VM_PAGEOUT_H_ */