2 * Copyright (c) 2000-2010 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
31 #ifndef _DEFAULT_FREEZER_H_
32 #define _DEFAULT_FREEZER_H_
36 #include <default_pager/default_pager_internal.h>
37 #include <default_pager/default_pager_object_server.h>
38 #include <mach/memory_object_default_server.h>
39 #include <mach/memory_object_control.h>
40 #include <mach/memory_object_types.h>
41 #include <mach/memory_object_server.h>
43 #include <mach/vm_map.h>
44 #include <vm/memory_object.h>
45 #include <vm/vm_pageout.h>
46 #include <vm/vm_map.h>
50 * Begin declaration for default_freezer_ops.
52 extern void df_memory_object_reference(memory_object_t
);
53 extern void df_memory_object_deallocate(memory_object_t
);
54 extern kern_return_t
df_memory_object_init(memory_object_t
,
55 memory_object_control_t
,
56 memory_object_cluster_size_t
);
57 extern kern_return_t
df_memory_object_terminate(memory_object_t
);
58 extern kern_return_t
df_memory_object_data_request(memory_object_t
,
59 memory_object_offset_t
,
60 memory_object_cluster_size_t
,
62 memory_object_fault_info_t
);
63 extern kern_return_t
df_memory_object_data_return(memory_object_t
,
64 memory_object_offset_t
,
65 memory_object_cluster_size_t
,
66 memory_object_offset_t
*,
71 extern kern_return_t
df_memory_object_data_initialize(memory_object_t
,
72 memory_object_offset_t
,
73 memory_object_cluster_size_t
);
74 extern kern_return_t
df_memory_object_data_unlock(memory_object_t
,
75 memory_object_offset_t
,
78 extern kern_return_t
df_memory_object_synchronize(memory_object_t
,
79 memory_object_offset_t
,
82 extern kern_return_t
df_memory_object_map(memory_object_t
,
84 extern kern_return_t
df_memory_object_last_unmap(memory_object_t
);
86 extern kern_return_t
df_memory_object_data_reclaim( memory_object_t
,
89 * End declaration for default_freezer_ops.
92 const struct memory_object_pager_ops default_freezer_ops
= {
93 df_memory_object_reference
,
94 df_memory_object_deallocate
,
95 df_memory_object_init
,
96 df_memory_object_terminate
,
97 df_memory_object_data_request
,
98 df_memory_object_data_return
,
99 df_memory_object_data_initialize
,
100 df_memory_object_data_unlock
,
101 df_memory_object_synchronize
,
102 df_memory_object_map
,
103 df_memory_object_last_unmap
,
104 df_memory_object_data_reclaim
,
108 #define MAX_FREEZE_TABLE_ENTRIES 128
110 struct default_freezer_mapping_table_entry
{
111 memory_object_t memory_object
; /* memory object will lead us to the most current VM object */
112 memory_object_offset_t offset
;
114 typedef struct default_freezer_mapping_table
*default_freezer_mapping_table_t
;
116 struct default_freezer_mapping_table
{
117 struct default_freezer_mapping_table
*next
;
118 vm_object_t object
; /* packed object */
119 vm_object_offset_t offset
;
121 struct default_freezer_mapping_table_entry entry
[MAX_FREEZE_TABLE_ENTRIES
];
123 typedef struct default_freezer_mapping_table_entry
*default_freezer_mapping_table_entry_t
;
125 struct default_freezer_memory_object
{
126 struct ipc_object_header fo_pager_header
; /* fake ip_kotype() */
127 memory_object_pager_ops_t fo_pager_ops
; /* == &default_freezer_ops */
128 memory_object_control_t fo_pager_control
;
129 vm_object_t fo_compact_object
;
130 default_freezer_mapping_table_t fo_table
;
132 typedef struct default_freezer_memory_object
*default_freezer_memory_object_t
;
135 __private_extern__
void* default_freezer_mapping_create(vm_object_t
, vm_offset_t
);
137 __private_extern__
void default_freezer_mapping_free(void**, boolean_t all
);
139 __private_extern__ kern_return_t
default_freezer_mapping_store( default_freezer_mapping_table_t
*,
140 memory_object_offset_t
,
142 memory_object_offset_t
);
144 __private_extern__ kern_return_t
default_freezer_mapping_update( default_freezer_mapping_table_t
,
146 memory_object_offset_t
,
147 memory_object_offset_t
*,
150 __private_extern__
void default_freezer_memory_object_create(vm_object_t
, vm_object_t
, default_freezer_mapping_table_t
);
152 __private_extern__
void default_freezer_pack_page(vm_page_t
, vm_object_t
, vm_object_offset_t
, void**);
154 __private_extern__
void default_freezer_unpack(vm_object_t
, void**);
156 __private_extern__ vm_object_t
default_freezer_get_compact_vm_object(void**);
158 #endif /* MACH_KERNEL */
159 #endif /* DEFAULT_FREEZER_H */
160 #endif /* CONFIG_FREEZE */