]> git.saurik.com Git - apple/xnu.git/blame - osfmk/vm/default_freezer.h
xnu-2422.1.72.tar.gz
[apple/xnu.git] / osfmk / vm / default_freezer.h
CommitLineData
6d2010ae
A
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
6d2010ae
A
29#ifndef _DEFAULT_FREEZER_H_
30#define _DEFAULT_FREEZER_H_
31
316670eb
A
32#if CONFIG_FREEZE
33
6d2010ae
A
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>
316670eb 44#include <vm/vm_protos.h>
6d2010ae
A
45#include <vm/memory_object.h>
46#include <vm/vm_pageout.h>
47#include <vm/vm_map.h>
48
49
50/*
51 * Begin declaration for default_freezer_ops.
52*/
53extern void df_memory_object_reference(memory_object_t);
54extern void df_memory_object_deallocate(memory_object_t);
55extern kern_return_t df_memory_object_init(memory_object_t,
56 memory_object_control_t,
57 memory_object_cluster_size_t);
58extern kern_return_t df_memory_object_terminate(memory_object_t);
59extern kern_return_t df_memory_object_data_request(memory_object_t,
60 memory_object_offset_t,
61 memory_object_cluster_size_t,
62 vm_prot_t,
63 memory_object_fault_info_t);
64extern kern_return_t df_memory_object_data_return(memory_object_t,
65 memory_object_offset_t,
66 memory_object_cluster_size_t,
67 memory_object_offset_t *,
68 int *,
69 boolean_t,
70 boolean_t,
71 int);
72extern kern_return_t df_memory_object_data_initialize(memory_object_t,
73 memory_object_offset_t,
74 memory_object_cluster_size_t);
75extern kern_return_t df_memory_object_data_unlock(memory_object_t,
76 memory_object_offset_t,
77 memory_object_size_t,
78 vm_prot_t);
79extern kern_return_t df_memory_object_synchronize(memory_object_t,
80 memory_object_offset_t,
81 memory_object_size_t,
82 vm_sync_t);
83extern kern_return_t df_memory_object_map(memory_object_t,
84 vm_prot_t);
85extern kern_return_t df_memory_object_last_unmap(memory_object_t);
86
87extern kern_return_t df_memory_object_data_reclaim( memory_object_t,
88 boolean_t);
89/*
90 * End declaration for default_freezer_ops.
91*/
92
93const struct memory_object_pager_ops default_freezer_ops = {
94 df_memory_object_reference,
95 df_memory_object_deallocate,
96 df_memory_object_init,
97 df_memory_object_terminate,
98 df_memory_object_data_request,
99 df_memory_object_data_return,
100 df_memory_object_data_initialize,
101 df_memory_object_data_unlock,
102 df_memory_object_synchronize,
103 df_memory_object_map,
104 df_memory_object_last_unmap,
105 df_memory_object_data_reclaim,
106 "default freezer"
107};
108
109#define MAX_FREEZE_TABLE_ENTRIES 128
110
111struct default_freezer_mapping_table_entry {
112 memory_object_t memory_object; /* memory object will lead us to the most current VM object */
113 memory_object_offset_t offset;
114};
115typedef struct default_freezer_mapping_table *default_freezer_mapping_table_t;
116
117struct default_freezer_mapping_table {
118 struct default_freezer_mapping_table *next;
119 vm_object_t object; /* packed object */
120 vm_object_offset_t offset;
121 unsigned int index;
122 struct default_freezer_mapping_table_entry entry[MAX_FREEZE_TABLE_ENTRIES];
123};
124typedef struct default_freezer_mapping_table_entry *default_freezer_mapping_table_entry_t;
125
316670eb
A
126struct default_freezer_handle {
127 lck_rw_t dfh_lck;
128 uint32_t dfh_ref_count;
129 default_freezer_mapping_table_t dfh_table;
130 vm_object_t dfh_compact_object;
131 vm_object_offset_t dfh_compact_offset;
132};
133typedef struct default_freezer_handle *default_freezer_handle_t;
134
6d2010ae
A
135struct default_freezer_memory_object{
136 struct ipc_object_header fo_pager_header; /* fake ip_kotype() */
137 memory_object_pager_ops_t fo_pager_ops; /* == &default_freezer_ops */
138 memory_object_control_t fo_pager_control;
316670eb 139 default_freezer_handle_t fo_df_handle;
6d2010ae
A
140};
141typedef struct default_freezer_memory_object *default_freezer_memory_object_t;
142
143
316670eb
A
144__private_extern__ void default_freezer_handle_lock(default_freezer_handle_t);
145__private_extern__ void default_freezer_handle_unlock(default_freezer_handle_t);
6d2010ae 146
316670eb
A
147extern lck_grp_attr_t default_freezer_handle_lck_grp_attr;
148extern lck_grp_t default_freezer_handle_lck_grp;
6d2010ae 149
316670eb
A
150__private_extern__ default_freezer_mapping_table_t default_freezer_mapping_create(vm_object_t, vm_offset_t);
151
152__private_extern__ void default_freezer_mapping_free(default_freezer_mapping_table_t *table_p, boolean_t all);
153
154__private_extern__ kern_return_t default_freezer_mapping_store( default_freezer_mapping_table_t ,
6d2010ae
A
155 memory_object_offset_t,
156 memory_object_t,
157 memory_object_offset_t );
158
159__private_extern__ kern_return_t default_freezer_mapping_update( default_freezer_mapping_table_t,
160 memory_object_t,
161 memory_object_offset_t,
162 memory_object_offset_t *,
163 boolean_t );
164
316670eb 165__private_extern__ void default_freezer_handle_reference_locked(default_freezer_handle_t);
6d2010ae 166
316670eb 167__private_extern__ boolean_t default_freezer_handle_deallocate_locked(default_freezer_handle_t);
6d2010ae 168
316670eb 169__private_extern__ void default_freezer_memory_object_create(vm_object_t, default_freezer_handle_t);
6d2010ae
A
170
171#endif /* MACH_KERNEL */
6d2010ae 172#endif /* CONFIG_FREEZE */
316670eb 173#endif /* DEFAULT_FREEZER_H */