]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/vm_region.h
336d1f8b75505bcef07c4f737ccf956cce0c59f2
[apple/xnu.git] / osfmk / mach / vm_region.h
1 /*
2 * Copyright (c) 2000-2005 Apple Computer, 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 * @OSF_COPYRIGHT@
25 */
26 /*
27 * File: mach/vm_region.h
28 *
29 * Define the attributes of a task's memory region
30 *
31 */
32
33 #ifndef _MACH_VM_REGION_H_
34 #define _MACH_VM_REGION_H_
35
36 #include <mach/boolean.h>
37 #include <mach/vm_prot.h>
38 #include <mach/vm_inherit.h>
39 #include <mach/vm_behavior.h>
40 #include <mach/vm_types.h>
41 #include <mach/message.h>
42 #include <mach/machine/vm_param.h>
43 #include <mach/machine/vm_types.h>
44 #include <mach/memory_object_types.h>
45
46 #include <sys/cdefs.h>
47
48 #if __DARWIN_ALIGN_POWER
49 #pragma options align=power
50 #endif
51
52 /*
53 * Types defined:
54 *
55 * vm_region_info_t memory region attributes
56 */
57
58 #define VM_REGION_INFO_MAX (1024)
59 typedef int *vm_region_info_t;
60 typedef int *vm_region_info_64_t;
61 typedef int *vm_region_recurse_info_t;
62 typedef int *vm_region_recurse_info_64_t;
63 typedef int vm_region_flavor_t;
64 typedef int vm_region_info_data_t[VM_REGION_INFO_MAX];
65
66 #define VM_REGION_BASIC_INFO_64 9
67 struct vm_region_basic_info_64 {
68 vm_prot_t protection;
69 vm_prot_t max_protection;
70 vm_inherit_t inheritance;
71 boolean_t shared;
72 boolean_t reserved;
73 memory_object_offset_t offset;
74 vm_behavior_t behavior;
75 unsigned short user_wired_count;
76 };
77 typedef struct vm_region_basic_info_64 *vm_region_basic_info_64_t;
78 typedef struct vm_region_basic_info_64 vm_region_basic_info_data_64_t;
79
80 #define VM_REGION_BASIC_INFO_COUNT_64 ((mach_msg_type_number_t) \
81 (sizeof(vm_region_basic_info_data_64_t)/sizeof(int)))
82
83 /*
84 * Passing VM_REGION_BASIC_INFO to vm_region_64
85 * automatically converts it to a VM_REGION_BASIC_INFO_64.
86 * Please use that explicitly instead.
87 */
88 #define VM_REGION_BASIC_INFO 10
89
90 /*
91 * This is the legacy basic info structure. It is
92 * deprecated because it passes only a 32-bit memory object
93 * offset back - too small for many larger objects (e.g. files).
94 */
95 struct vm_region_basic_info {
96 vm_prot_t protection;
97 vm_prot_t max_protection;
98 vm_inherit_t inheritance;
99 boolean_t shared;
100 boolean_t reserved;
101 uint32_t offset; /* too small for a real offset */
102 vm_behavior_t behavior;
103 unsigned short user_wired_count;
104 };
105
106 typedef struct vm_region_basic_info *vm_region_basic_info_t;
107 typedef struct vm_region_basic_info vm_region_basic_info_data_t;
108
109 #define VM_REGION_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
110 (sizeof(vm_region_basic_info_data_t)/sizeof(int)))
111
112 #define VM_REGION_EXTENDED_INFO 11
113
114 #define SM_COW 1
115 #define SM_PRIVATE 2
116 #define SM_EMPTY 3
117 #define SM_SHARED 4
118 #define SM_TRUESHARED 5
119 #define SM_PRIVATE_ALIASED 6
120 #define SM_SHARED_ALIASED 7
121
122 /*
123 * For submap info, the SM flags above are overlayed when a submap
124 * is encountered. The field denotes whether or not machine level mapping
125 * information is being shared. PTE's etc. When such sharing is taking
126 * place the value returned is SM_TRUESHARED otherwise SM_PRIVATE is passed
127 * back.
128 */
129
130 struct vm_region_extended_info {
131 vm_prot_t protection;
132 unsigned int user_tag;
133 unsigned int pages_resident;
134 unsigned int pages_shared_now_private;
135 unsigned int pages_swapped_out;
136 unsigned int pages_dirtied;
137 unsigned int ref_count;
138 unsigned short shadow_depth;
139 unsigned char external_pager;
140 unsigned char share_mode;
141 };
142
143 typedef struct vm_region_extended_info *vm_region_extended_info_t;
144 typedef struct vm_region_extended_info vm_region_extended_info_data_t;
145
146 #define VM_REGION_EXTENDED_INFO_COUNT ((mach_msg_type_number_t) \
147 (sizeof(vm_region_extended_info_data_t)/sizeof(int)))
148
149
150 #define VM_REGION_TOP_INFO 12
151
152 struct vm_region_top_info {
153 unsigned int obj_id;
154 unsigned int ref_count;
155 unsigned int private_pages_resident;
156 unsigned int shared_pages_resident;
157 unsigned char share_mode;
158 };
159
160 typedef struct vm_region_top_info *vm_region_top_info_t;
161 typedef struct vm_region_top_info vm_region_top_info_data_t;
162
163 #define VM_REGION_TOP_INFO_COUNT ((mach_msg_type_number_t) \
164 (sizeof(vm_region_top_info_data_t)/sizeof(int)))
165
166
167
168 /*
169 * vm_region_submap_info will return information on a submap or object.
170 * The user supplies a nesting level on the call. When a walk of the
171 * user's map is done and a submap is encountered, the nesting count is
172 * checked. If the nesting count is greater than 1 the submap is entered and
173 * the offset relative to the address in the base map is examined. If the
174 * nesting count is zero, the information on the submap is returned.
175 * The caller may thus learn about a submap and its contents by judicious
176 * choice of the base map address and nesting count. The nesting count
177 * allows penetration of recursively mapped submaps. If a submap is
178 * encountered as a mapped entry of another submap, the caller may bump
179 * the nesting count and call vm_region_recurse again on the target address
180 * range. The "is_submap" field tells the caller whether or not a submap
181 * has been encountered.
182 *
183 * Object only fields are filled in through a walking of the object shadow
184 * chain (where one is present), and a walking of the resident page queue.
185 *
186 */
187
188 struct vm_region_submap_info {
189 vm_prot_t protection; /* present access protection */
190 vm_prot_t max_protection; /* max avail through vm_prot */
191 vm_inherit_t inheritance;/* behavior of map/obj on fork */
192 uint32_t offset; /* offset into object/map */
193 unsigned int user_tag; /* user tag on map entry */
194 unsigned int pages_resident; /* only valid for objects */
195 unsigned int pages_shared_now_private; /* only for objects */
196 unsigned int pages_swapped_out; /* only for objects */
197 unsigned int pages_dirtied; /* only for objects */
198 unsigned int ref_count; /* obj/map mappers, etc */
199 unsigned short shadow_depth; /* only for obj */
200 unsigned char external_pager; /* only for obj */
201 unsigned char share_mode; /* see enumeration */
202 boolean_t is_submap; /* submap vs obj */
203 vm_behavior_t behavior; /* access behavior hint */
204 vm_offset_t object_id; /* obj/map name, not a handle */
205 unsigned short user_wired_count;
206 };
207
208 typedef struct vm_region_submap_info *vm_region_submap_info_t;
209 typedef struct vm_region_submap_info vm_region_submap_info_data_t;
210
211 #define VM_REGION_SUBMAP_INFO_COUNT ((mach_msg_type_number_t) \
212 (sizeof(vm_region_submap_info_data_t)/sizeof(int)))
213
214 struct vm_region_submap_info_64 {
215 vm_prot_t protection; /* present access protection */
216 vm_prot_t max_protection; /* max avail through vm_prot */
217 vm_inherit_t inheritance;/* behavior of map/obj on fork */
218 memory_object_offset_t offset; /* offset into object/map */
219 unsigned int user_tag; /* user tag on map entry */
220 unsigned int pages_resident; /* only valid for objects */
221 unsigned int pages_shared_now_private; /* only for objects */
222 unsigned int pages_swapped_out; /* only for objects */
223 unsigned int pages_dirtied; /* only for objects */
224 unsigned int ref_count; /* obj/map mappers, etc */
225 unsigned short shadow_depth; /* only for obj */
226 unsigned char external_pager; /* only for obj */
227 unsigned char share_mode; /* see enumeration */
228 boolean_t is_submap; /* submap vs obj */
229 vm_behavior_t behavior; /* access behavior hint */
230 vm_offset_t object_id; /* obj/map name, not a handle */
231 unsigned short user_wired_count;
232 };
233
234 typedef struct vm_region_submap_info_64 *vm_region_submap_info_64_t;
235 typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t;
236
237 #define VM_REGION_SUBMAP_INFO_COUNT_64 ((mach_msg_type_number_t) \
238 (sizeof(vm_region_submap_info_data_64_t)/sizeof(int)))
239
240 struct mach_vm_read_entry {
241 mach_vm_address_t address;
242 mach_vm_size_t size;
243 };
244
245 struct vm_read_entry {
246 vm_address_t address;
247 vm_size_t size;
248 };
249
250 #define VM_MAP_ENTRY_MAX (256)
251
252 typedef struct mach_vm_read_entry mach_vm_read_entry_t[VM_MAP_ENTRY_MAX];
253 typedef struct vm_read_entry vm_read_entry_t[VM_MAP_ENTRY_MAX];
254
255 #if __DARWIN_ALIGN_POWER
256 #pragma options align=reset
257 #endif
258
259 #endif /*_MACH_VM_REGION_H_*/