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