]>
Commit | Line | Data |
---|---|---|
2d21ac55 A |
1 | /* |
2 | * Copyright (c) 2007 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_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. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | /* | |
24 | * | |
25 | * File: vm/vm_shared_region.h | |
26 | * | |
27 | * protos and struct definitions for shared region | |
28 | */ | |
29 | ||
30 | #ifndef _VM_SHARED_REGION_H_ | |
31 | #define _VM_SHARED_REGION_H_ | |
32 | ||
33 | #ifdef KERNEL_PRIVATE | |
34 | ||
35 | #include <mach/vm_prot.h> | |
36 | #include <mach/mach_types.h> | |
37 | #include <mach/shared_region.h> | |
38 | ||
39 | #include <kern/kern_types.h> | |
40 | #include <kern/macro_help.h> | |
41 | ||
42 | #include <vm/vm_map.h> | |
43 | ||
44 | extern int shared_region_version; | |
45 | extern int shared_region_persistence; | |
6d2010ae | 46 | extern boolean_t shared_region_completed_slide; |
2d21ac55 A |
47 | |
48 | #if DEBUG | |
49 | extern int shared_region_debug; | |
50 | #define SHARED_REGION_DEBUG(args) \ | |
51 | MACRO_BEGIN \ | |
52 | if (shared_region_debug) { \ | |
53 | kprintf args; \ | |
54 | } \ | |
55 | MACRO_END | |
56 | #else /* DEBUG */ | |
57 | #define SHARED_REGION_DEBUG(args) | |
58 | #endif /* DEBUG */ | |
59 | ||
60 | extern int shared_region_trace_level; | |
61 | #define SHARED_REGION_TRACE_NONE_LVL 0 /* no trace */ | |
62 | #define SHARED_REGION_TRACE_ERROR_LVL 1 /* trace abnormal events */ | |
63 | #define SHARED_REGION_TRACE_INFO_LVL 2 /* trace all events */ | |
64 | #define SHARED_REGION_TRACE_DEBUG_LVL 3 /* extra traces for debug */ | |
65 | #define SHARED_REGION_TRACE(level, args) \ | |
66 | MACRO_BEGIN \ | |
67 | if (shared_region_trace_level >= level) { \ | |
68 | printf args; \ | |
69 | } \ | |
70 | MACRO_END | |
71 | #define SHARED_REGION_TRACE_NONE(args) | |
72 | #define SHARED_REGION_TRACE_ERROR(args) \ | |
73 | MACRO_BEGIN \ | |
74 | SHARED_REGION_TRACE(SHARED_REGION_TRACE_ERROR_LVL, \ | |
75 | args); \ | |
76 | MACRO_END | |
77 | #define SHARED_REGION_TRACE_INFO(args) \ | |
78 | MACRO_BEGIN \ | |
79 | SHARED_REGION_TRACE(SHARED_REGION_TRACE_INFO_LVL, \ | |
80 | args); \ | |
81 | MACRO_END | |
82 | #define SHARED_REGION_TRACE_DEBUG(args) \ | |
83 | MACRO_BEGIN \ | |
84 | SHARED_REGION_TRACE(SHARED_REGION_TRACE_DEBUG_LVL, \ | |
85 | args); \ | |
86 | MACRO_END | |
87 | ||
88 | typedef struct vm_shared_region *vm_shared_region_t; | |
89 | ||
90 | #ifdef MACH_KERNEL_PRIVATE | |
91 | ||
92 | #include <kern/queue.h> | |
93 | #include <vm/vm_object.h> | |
94 | #include <vm/memory_object.h> | |
95 | ||
96 | /* address space shared region descriptor */ | |
97 | struct vm_shared_region { | |
98 | uint32_t sr_ref_count; | |
b0d623f7 | 99 | queue_chain_t sr_q; |
2d21ac55 A |
100 | void *sr_root_dir; |
101 | cpu_type_t sr_cpu_type; | |
102 | boolean_t sr_64bit; | |
103 | boolean_t sr_mapping_in_progress; | |
104 | boolean_t sr_persists; | |
105 | ipc_port_t sr_mem_entry; | |
106 | mach_vm_offset_t sr_first_mapping; | |
107 | mach_vm_offset_t sr_base_address; | |
108 | mach_vm_size_t sr_size; | |
109 | mach_vm_offset_t sr_pmap_nesting_start; | |
110 | mach_vm_size_t sr_pmap_nesting_size; | |
b0d623f7 | 111 | thread_call_t sr_timer_call; |
2d21ac55 A |
112 | }; |
113 | ||
6d2010ae A |
114 | typedef struct vm_shared_region_slide_info_entry *vm_shared_region_slide_info_entry_t; |
115 | struct vm_shared_region_slide_info_entry { | |
116 | uint32_t version; | |
117 | uint32_t toc_offset; // offset from start of header to table-of-contents | |
118 | uint32_t toc_count; // number of entries in toc (same as number of pages in r/w mapping) | |
119 | uint32_t entry_offset; | |
120 | uint32_t entry_count; | |
121 | }; | |
122 | ||
123 | #define NBBY 8 | |
124 | #define NUM_SLIDING_BITMAPS_PER_PAGE (PAGE_SIZE/sizeof(int)/NBBY) /*128*/ | |
125 | typedef struct slide_info_entry_toc *slide_info_entry_toc_t; | |
126 | struct slide_info_entry_toc { | |
127 | uint8_t entry[NUM_SLIDING_BITMAPS_PER_PAGE]; | |
128 | }; | |
129 | ||
130 | typedef struct vm_shared_region_slide_info vm_shared_region_slide_info_t; | |
131 | struct vm_shared_region_slide_info { | |
132 | mach_vm_offset_t start; | |
133 | mach_vm_offset_t end; | |
134 | uint32_t slide; | |
135 | vm_object_t slide_object; | |
136 | mach_vm_size_t slide_info_size; | |
137 | vm_shared_region_slide_info_entry_t slide_info_entry; | |
138 | vm_shared_region_t sr; | |
139 | }; | |
140 | ||
141 | extern struct vm_shared_region_slide_info slide_info; | |
142 | ||
2d21ac55 A |
143 | #else /* !MACH_KERNEL_PRIVATE */ |
144 | ||
145 | struct vm_shared_region; | |
6d2010ae A |
146 | struct vm_shared_region_slide_info; |
147 | struct vm_shared_region_slide_info_entry; | |
148 | struct slide_info_entry_toc; | |
2d21ac55 A |
149 | |
150 | #endif /* MACH_KERNEL_PRIVATE */ | |
151 | ||
152 | extern void vm_shared_region_init(void); | |
153 | extern kern_return_t vm_shared_region_enter( | |
154 | struct _vm_map *map, | |
155 | struct task *task, | |
156 | void *fsroot, | |
157 | cpu_type_t cpu); | |
158 | extern kern_return_t vm_shared_region_remove( | |
159 | struct _vm_map *map, | |
160 | struct task *task); | |
161 | extern vm_shared_region_t vm_shared_region_get( | |
162 | struct task *task); | |
163 | extern void vm_shared_region_deallocate( | |
164 | struct vm_shared_region *shared_region); | |
165 | extern mach_vm_offset_t vm_shared_region_base_address( | |
166 | struct vm_shared_region *shared_region); | |
167 | extern mach_vm_size_t vm_shared_region_size( | |
168 | struct vm_shared_region *shared_region); | |
169 | extern ipc_port_t vm_shared_region_mem_entry( | |
170 | struct vm_shared_region *shared_region); | |
171 | extern void vm_shared_region_set( | |
172 | struct task *task, | |
173 | struct vm_shared_region *new_shared_region); | |
174 | extern vm_shared_region_t vm_shared_region_lookup( | |
175 | void *root_dir, | |
176 | cpu_type_t cpu, | |
177 | boolean_t is_64bit); | |
178 | extern kern_return_t vm_shared_region_start_address( | |
179 | struct vm_shared_region *shared_region, | |
180 | mach_vm_offset_t *start_address); | |
6d2010ae A |
181 | extern void vm_shared_region_undo_mappings( |
182 | vm_map_t sr_map, | |
183 | mach_vm_offset_t sr_base_address, | |
184 | struct shared_file_mapping_np *mappings, | |
185 | unsigned int mappings_count); | |
2d21ac55 A |
186 | extern kern_return_t vm_shared_region_map_file( |
187 | struct vm_shared_region *shared_region, | |
188 | unsigned int mappings_count, | |
189 | struct shared_file_mapping_np *mappings, | |
190 | memory_object_control_t file_control, | |
191 | memory_object_size_t file_size, | |
6d2010ae A |
192 | void *root_dir, |
193 | struct shared_file_mapping_np *mapping_to_slide); | |
194 | extern kern_return_t vm_shared_region_sliding_valid(uint32_t slide); | |
195 | extern kern_return_t vm_shared_region_slide_sanity_check(void); | |
196 | extern kern_return_t vm_shared_region_slide_init(mach_vm_size_t slide_info_size, | |
197 | mach_vm_offset_t start, | |
198 | mach_vm_size_t size, | |
199 | uint32_t slide, | |
200 | memory_object_control_t); | |
201 | extern void* vm_shared_region_get_slide_info(void); | |
202 | extern void* vm_shared_region_get_slide_info_entry(void); | |
203 | extern kern_return_t vm_shared_region_slide( | |
204 | vm_offset_t vaddr, | |
205 | uint32_t pageIndex); | |
2d21ac55 | 206 | extern void vm_commpage_init(void); |
316670eb | 207 | extern void vm_commpage_text_init(void); |
2d21ac55 A |
208 | extern kern_return_t vm_commpage_enter( |
209 | struct _vm_map *map, | |
210 | struct task *task); | |
211 | extern kern_return_t vm_commpage_remove( | |
212 | struct _vm_map *map, | |
213 | struct task *task); | |
214 | ||
215 | #endif /* KERNEL_PRIVATE */ | |
216 | ||
217 | #endif /* _VM_SHARED_REGION_H_ */ |