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 #ifdef MACH_KERNEL_PRIVATE
84 #include <vm/vm_page.h>
86 extern unsigned int vm_pageout_scan_event_counter
;
87 extern unsigned int vm_zf_count
;
90 * Routines exported to Mach.
92 extern void vm_pageout(void);
94 extern vm_object_t
vm_pageout_object_allocate(
97 vm_object_offset_t offset
);
99 extern void vm_pageout_object_terminate(
102 extern vm_page_t
vm_pageout_setup(
104 vm_object_t new_object
,
105 vm_object_offset_t new_offset
);
107 extern void vm_pageout_cluster(
110 extern void vm_pageout_initialize_page(
113 extern void vm_pageclean_setup(
116 vm_object_t new_object
,
117 vm_object_offset_t new_offset
);
119 extern void vm_pageclean_copy(
122 vm_object_t new_object
,
123 vm_object_offset_t new_offset
);
125 /* UPL exported routines and structures */
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)
132 /* universal page list structure */
135 decl_mutex_data(, Lock
) /* Synchronization */
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
;
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 */
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
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
170 extern kern_return_t
vm_object_iopl_request(
172 vm_object_offset_t offset
,
175 upl_page_info_array_t user_page_list
,
176 unsigned int *page_list_count
,
179 extern kern_return_t
vm_object_super_upl_request(
181 vm_object_offset_t offset
,
183 upl_size_t super_cluster
,
185 upl_page_info_t
*user_page_list
,
186 unsigned int *page_list_count
,
189 /* should be just a regular vm_map_enter() */
190 extern kern_return_t
vm_map_enter_upl(
193 vm_map_offset_t
*dst_addr
);
195 /* should be just a regular vm_map_remove() */
196 extern kern_return_t
vm_map_remove_upl(
201 extern kern_return_t
upl_ubc_alias_set(
204 unsigned int alias2
);
205 extern int upl_ubc_alias_get(
209 #endif /* UPL_DEBUG */
211 /* wired page list structure */
212 typedef unsigned long *wpl_array_t
;
214 extern void vm_page_free_list(
215 register vm_page_t mem
);
217 extern void vm_page_free_reserve(int pages
);
219 extern void vm_pageout_throttle_down(vm_page_t page
);
220 extern void vm_pageout_throttle_up(vm_page_t page
);
225 extern void upl_encrypt(
227 upl_offset_t crypt_offset
,
228 upl_size_t crypt_size
);
229 extern void vm_page_encrypt(
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(
235 vm_map_offset_t kernel_map_offset
);
236 extern kern_return_t
vm_paging_map_object(
237 vm_map_offset_t
*address
,
240 vm_object_offset_t offset
,
241 vm_map_size_t
*size
);
242 extern void vm_paging_unmap_object(
244 vm_map_offset_t start
,
245 vm_map_offset_t end
);
246 decl_simple_lock_data(extern, vm_paging_lock
)
249 * Backing store throttle when BS is exhausted
251 extern unsigned int vm_backing_store_low
;
253 #endif /* MACH_KERNEL_PRIVATE */
255 extern void vm_countdirtypages(void);
257 extern void vm_backing_store_disable(
260 extern kern_return_t
upl_transpose(
264 #endif /* KERNEL_PRIVATE */
266 #endif /* _VM_VM_PAGEOUT_H_ */