]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2000-2010 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
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. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
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. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
28 | ||
29 | #if CONFIG_FREEZE | |
30 | ||
31 | #ifndef _DEFAULT_FREEZER_H_ | |
32 | #define _DEFAULT_FREEZER_H_ | |
33 | ||
34 | #ifdef MACH_KERNEL | |
35 | ||
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> | |
42 | #include <mach/upl.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> | |
47 | ||
48 | ||
49 | /* | |
50 | * Begin declaration for default_freezer_ops. | |
51 | */ | |
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, | |
61 | vm_prot_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 *, | |
67 | int *, | |
68 | boolean_t, | |
69 | boolean_t, | |
70 | int); | |
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, | |
76 | memory_object_size_t, | |
77 | vm_prot_t); | |
78 | extern kern_return_t df_memory_object_synchronize(memory_object_t, | |
79 | memory_object_offset_t, | |
80 | memory_object_size_t, | |
81 | vm_sync_t); | |
82 | extern kern_return_t df_memory_object_map(memory_object_t, | |
83 | vm_prot_t); | |
84 | extern kern_return_t df_memory_object_last_unmap(memory_object_t); | |
85 | ||
86 | extern kern_return_t df_memory_object_data_reclaim( memory_object_t, | |
87 | boolean_t); | |
88 | /* | |
89 | * End declaration for default_freezer_ops. | |
90 | */ | |
91 | ||
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, | |
105 | "default freezer" | |
106 | }; | |
107 | ||
108 | #define MAX_FREEZE_TABLE_ENTRIES 128 | |
109 | ||
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; | |
113 | }; | |
114 | typedef struct default_freezer_mapping_table *default_freezer_mapping_table_t; | |
115 | ||
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; | |
120 | unsigned int index; | |
121 | struct default_freezer_mapping_table_entry entry[MAX_FREEZE_TABLE_ENTRIES]; | |
122 | }; | |
123 | typedef struct default_freezer_mapping_table_entry *default_freezer_mapping_table_entry_t; | |
124 | ||
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; | |
131 | }; | |
132 | typedef struct default_freezer_memory_object *default_freezer_memory_object_t; | |
133 | ||
134 | ||
135 | __private_extern__ void* default_freezer_mapping_create(vm_object_t, vm_offset_t); | |
136 | ||
137 | __private_extern__ void default_freezer_mapping_free(void**, boolean_t all); | |
138 | ||
139 | __private_extern__ kern_return_t default_freezer_mapping_store( default_freezer_mapping_table_t *, | |
140 | memory_object_offset_t, | |
141 | memory_object_t, | |
142 | memory_object_offset_t ); | |
143 | ||
144 | __private_extern__ kern_return_t default_freezer_mapping_update( default_freezer_mapping_table_t, | |
145 | memory_object_t, | |
146 | memory_object_offset_t, | |
147 | memory_object_offset_t *, | |
148 | boolean_t ); | |
149 | ||
150 | __private_extern__ void default_freezer_memory_object_create(vm_object_t, vm_object_t, default_freezer_mapping_table_t); | |
151 | ||
152 | __private_extern__ void default_freezer_pack_page(vm_page_t, vm_object_t, vm_object_offset_t, void**); | |
153 | ||
154 | __private_extern__ void default_freezer_unpack(vm_object_t, void**); | |
155 | ||
156 | __private_extern__ vm_object_t default_freezer_get_compact_vm_object(void**); | |
157 | ||
158 | #endif /* MACH_KERNEL */ | |
159 | #endif /* DEFAULT_FREEZER_H */ | |
160 | #endif /* CONFIG_FREEZE */ |