]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/vm_region.h
xnu-6153.121.1.tar.gz
[apple/xnu.git] / osfmk / mach / vm_region.h
CommitLineData
1c79356b 1/*
39037602 2 * Copyright (c) 2000-2016 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
2d21ac55
A
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.
0a7de745 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
0a7de745 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
1c79356b
A
31/*
32 * File: mach/vm_region.h
33 *
34 * Define the attributes of a task's memory region
35 *
36 */
37
0a7de745 38#ifndef _MACH_VM_REGION_H_
1c79356b
A
39#define _MACH_VM_REGION_H_
40
41#include <mach/boolean.h>
42#include <mach/vm_prot.h>
43#include <mach/vm_inherit.h>
44#include <mach/vm_behavior.h>
91447636
A
45#include <mach/vm_types.h>
46#include <mach/message.h>
47#include <mach/machine/vm_param.h>
48#include <mach/machine/vm_types.h>
49#include <mach/memory_object_types.h>
50
51#include <sys/cdefs.h>
52
cb323159 53#pragma pack(push, 4)
1c79356b 54
b0d623f7
A
55// LP64todo: all the current tools are 32bit, obviously never worked for 64b
56// so probably should be a real 32b ID vs. ptr.
57// Current users just check for equality
58typedef uint32_t vm32_object_id_t;
59
1c79356b
A
60/*
61 * Types defined:
62 *
63 * vm_region_info_t memory region attributes
64 */
65
66#define VM_REGION_INFO_MAX (1024)
0a7de745
A
67typedef int *vm_region_info_t;
68typedef int *vm_region_info_64_t;
69typedef int *vm_region_recurse_info_t;
70typedef int *vm_region_recurse_info_64_t;
71typedef int vm_region_flavor_t;
72typedef int vm_region_info_data_t[VM_REGION_INFO_MAX];
73
74#define VM_REGION_BASIC_INFO_64 9
1c79356b 75struct vm_region_basic_info_64 {
0a7de745
A
76 vm_prot_t protection;
77 vm_prot_t max_protection;
78 vm_inherit_t inheritance;
79 boolean_t shared;
80 boolean_t reserved;
81 memory_object_offset_t offset;
82 vm_behavior_t behavior;
83 unsigned short user_wired_count;
1c79356b 84};
0a7de745
A
85typedef struct vm_region_basic_info_64 *vm_region_basic_info_64_t;
86typedef struct vm_region_basic_info_64 vm_region_basic_info_data_64_t;
1c79356b 87
0a7de745 88#define VM_REGION_BASIC_INFO_COUNT_64 ((mach_msg_type_number_t) \
91447636 89 (sizeof(vm_region_basic_info_data_64_t)/sizeof(int)))
1c79356b 90
91447636
A
91/*
92 * Passing VM_REGION_BASIC_INFO to vm_region_64
93 * automatically converts it to a VM_REGION_BASIC_INFO_64.
94 * Please use that explicitly instead.
95 */
0a7de745 96#define VM_REGION_BASIC_INFO 10
1c79356b 97
91447636
A
98/*
99 * This is the legacy basic info structure. It is
100 * deprecated because it passes only a 32-bit memory object
101 * offset back - too small for many larger objects (e.g. files).
102 */
1c79356b 103struct vm_region_basic_info {
0a7de745
A
104 vm_prot_t protection;
105 vm_prot_t max_protection;
106 vm_inherit_t inheritance;
107 boolean_t shared;
108 boolean_t reserved;
109 uint32_t offset; /* too small for a real offset */
110 vm_behavior_t behavior;
111 unsigned short user_wired_count;
1c79356b
A
112};
113
0a7de745
A
114typedef struct vm_region_basic_info *vm_region_basic_info_t;
115typedef struct vm_region_basic_info vm_region_basic_info_data_t;
1c79356b 116
91447636
A
117#define VM_REGION_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
118 (sizeof(vm_region_basic_info_data_t)/sizeof(int)))
1c79356b 119
1c79356b
A
120#define SM_COW 1
121#define SM_PRIVATE 2
122#define SM_EMPTY 3
123#define SM_SHARED 4
124#define SM_TRUESHARED 5
125#define SM_PRIVATE_ALIASED 6
126#define SM_SHARED_ALIASED 7
6d2010ae 127#define SM_LARGE_PAGE 8
1c79356b 128
0a7de745 129/*
1c79356b
A
130 * For submap info, the SM flags above are overlayed when a submap
131 * is encountered. The field denotes whether or not machine level mapping
132 * information is being shared. PTE's etc. When such sharing is taking
133 * place the value returned is SM_TRUESHARED otherwise SM_PRIVATE is passed
134 * back.
135 */
136
39037602 137#ifdef MACH_KERNEL_PRIVATE
0a7de745 138#define VM_REGION_EXTENDED_INFO__legacy 11
39236c6e 139struct vm_region_extended_info__legacy {
0a7de745
A
140 vm_prot_t protection;
141 unsigned int user_tag;
142 unsigned int pages_resident;
143 unsigned int pages_shared_now_private;
144 unsigned int pages_swapped_out;
145 unsigned int pages_dirtied;
146 unsigned int ref_count;
147 unsigned short shadow_depth;
148 unsigned char external_pager;
149 unsigned char share_mode;
39236c6e
A
150 /*
151 * XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
152 * DO NOT EXTEND THIS DATA STRUCTURE.
153 * IT IS NOW ABANDONED AND REPLACED WITH vm_region_extended_info BELOW.
154 * XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
155 */
1c79356b 156};
0a7de745
A
157#define VM_REGION_EXTENDED_INFO_COUNT__legacy \
158 ((mach_msg_type_number_t) \
39236c6e
A
159 (sizeof (struct vm_region_extended_info__legacy) / \
160 sizeof (natural_t)))
161#endif /* MACH_KERNEL_PRIVATE */
162
1c79356b 163
39236c6e 164
0a7de745 165#define VM_REGION_EXTENDED_INFO 13
39236c6e 166struct vm_region_extended_info {
0a7de745
A
167 vm_prot_t protection;
168 unsigned int user_tag;
169 unsigned int pages_resident;
170 unsigned int pages_shared_now_private;
171 unsigned int pages_swapped_out;
172 unsigned int pages_dirtied;
173 unsigned int ref_count;
174 unsigned short shadow_depth;
175 unsigned char external_pager;
176 unsigned char share_mode;
177 unsigned int pages_reusable;
39236c6e 178};
0a7de745
A
179typedef struct vm_region_extended_info *vm_region_extended_info_t;
180typedef struct vm_region_extended_info vm_region_extended_info_data_t;
181#define VM_REGION_EXTENDED_INFO_COUNT \
182 ((mach_msg_type_number_t) \
39236c6e
A
183 (sizeof (vm_region_extended_info_data_t) / sizeof (natural_t)))
184
1c79356b 185
1c79356b
A
186
187
0a7de745 188#define VM_REGION_TOP_INFO 12
1c79356b
A
189
190struct vm_region_top_info {
0a7de745
A
191 unsigned int obj_id;
192 unsigned int ref_count;
193 unsigned int private_pages_resident;
194 unsigned int shared_pages_resident;
195 unsigned char share_mode;
1c79356b
A
196};
197
0a7de745
A
198typedef struct vm_region_top_info *vm_region_top_info_t;
199typedef struct vm_region_top_info vm_region_top_info_data_t;
1c79356b 200
0a7de745
A
201#define VM_REGION_TOP_INFO_COUNT \
202 ((mach_msg_type_number_t) \
39236c6e 203 (sizeof(vm_region_top_info_data_t) / sizeof(natural_t)))
1c79356b
A
204
205
206
0a7de745 207/*
1c79356b
A
208 * vm_region_submap_info will return information on a submap or object.
209 * The user supplies a nesting level on the call. When a walk of the
210 * user's map is done and a submap is encountered, the nesting count is
211 * checked. If the nesting count is greater than 1 the submap is entered and
212 * the offset relative to the address in the base map is examined. If the
213 * nesting count is zero, the information on the submap is returned.
214 * The caller may thus learn about a submap and its contents by judicious
215 * choice of the base map address and nesting count. The nesting count
216 * allows penetration of recursively mapped submaps. If a submap is
217 * encountered as a mapped entry of another submap, the caller may bump
218 * the nesting count and call vm_region_recurse again on the target address
219 * range. The "is_submap" field tells the caller whether or not a submap
220 * has been encountered.
221 *
222 * Object only fields are filled in through a walking of the object shadow
223 * chain (where one is present), and a walking of the resident page queue.
0a7de745 224 *
1c79356b 225 */
91447636 226
1c79356b 227struct vm_region_submap_info {
0a7de745
A
228 vm_prot_t protection; /* present access protection */
229 vm_prot_t max_protection; /* max avail through vm_prot */
230 vm_inherit_t inheritance;/* behavior of map/obj on fork */
231 uint32_t offset; /* offset into object/map */
232 unsigned int user_tag; /* user tag on map entry */
233 unsigned int pages_resident; /* only valid for objects */
234 unsigned int pages_shared_now_private; /* only for objects */
235 unsigned int pages_swapped_out; /* only for objects */
236 unsigned int pages_dirtied; /* only for objects */
237 unsigned int ref_count; /* obj/map mappers, etc */
238 unsigned short shadow_depth; /* only for obj */
239 unsigned char external_pager; /* only for obj */
240 unsigned char share_mode; /* see enumeration */
241 boolean_t is_submap; /* submap vs obj */
242 vm_behavior_t behavior; /* access behavior hint */
243 vm32_object_id_t object_id; /* obj/map name, not a handle */
244 unsigned short user_wired_count;
1c79356b
A
245};
246
0a7de745
A
247typedef struct vm_region_submap_info *vm_region_submap_info_t;
248typedef struct vm_region_submap_info vm_region_submap_info_data_t;
1c79356b 249
0a7de745
A
250#define VM_REGION_SUBMAP_INFO_COUNT \
251 ((mach_msg_type_number_t) \
39236c6e 252 (sizeof(vm_region_submap_info_data_t) / sizeof(natural_t)))
1c79356b
A
253
254struct vm_region_submap_info_64 {
0a7de745
A
255 vm_prot_t protection; /* present access protection */
256 vm_prot_t max_protection; /* max avail through vm_prot */
257 vm_inherit_t inheritance;/* behavior of map/obj on fork */
258 memory_object_offset_t offset; /* offset into object/map */
259 unsigned int user_tag; /* user tag on map entry */
260 unsigned int pages_resident; /* only valid for objects */
261 unsigned int pages_shared_now_private; /* only for objects */
262 unsigned int pages_swapped_out; /* only for objects */
263 unsigned int pages_dirtied; /* only for objects */
264 unsigned int ref_count; /* obj/map mappers, etc */
265 unsigned short shadow_depth; /* only for obj */
266 unsigned char external_pager; /* only for obj */
267 unsigned char share_mode; /* see enumeration */
268 boolean_t is_submap; /* submap vs obj */
269 vm_behavior_t behavior; /* access behavior hint */
270 vm32_object_id_t object_id; /* obj/map name, not a handle */
271 unsigned short user_wired_count;
272 unsigned int pages_reusable;
cb323159 273 vm_object_id_t object_id_full;
1c79356b
A
274};
275
0a7de745
A
276typedef struct vm_region_submap_info_64 *vm_region_submap_info_64_t;
277typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t;
1c79356b 278
cb323159 279#define VM_REGION_SUBMAP_INFO_V2_SIZE \
39236c6e 280 (sizeof (vm_region_submap_info_data_64_t))
cb323159
A
281#define VM_REGION_SUBMAP_INFO_V1_SIZE \
282 (VM_REGION_SUBMAP_INFO_V2_SIZE - \
283 sizeof (vm_object_id_t) /* object_id_full */ )
0a7de745 284#define VM_REGION_SUBMAP_INFO_V0_SIZE \
39236c6e 285 (VM_REGION_SUBMAP_INFO_V1_SIZE - \
0a7de745 286 sizeof (unsigned int) /* pages_reusable */ )
39236c6e 287
cb323159
A
288#define VM_REGION_SUBMAP_INFO_V2_COUNT_64 \
289 ((mach_msg_type_number_t) \
290 (VM_REGION_SUBMAP_INFO_V2_SIZE / sizeof (natural_t)))
39236c6e
A
291#define VM_REGION_SUBMAP_INFO_V1_COUNT_64 \
292 ((mach_msg_type_number_t) \
293 (VM_REGION_SUBMAP_INFO_V1_SIZE / sizeof (natural_t)))
294#define VM_REGION_SUBMAP_INFO_V0_COUNT_64 \
295 ((mach_msg_type_number_t) \
296 (VM_REGION_SUBMAP_INFO_V0_SIZE / sizeof (natural_t)))
297
298/* set this to the latest version */
cb323159 299#define VM_REGION_SUBMAP_INFO_COUNT_64 VM_REGION_SUBMAP_INFO_V2_COUNT_64
1c79356b 300
2d21ac55 301struct vm_region_submap_short_info_64 {
0a7de745
A
302 vm_prot_t protection; /* present access protection */
303 vm_prot_t max_protection; /* max avail through vm_prot */
304 vm_inherit_t inheritance;/* behavior of map/obj on fork */
305 memory_object_offset_t offset; /* offset into object/map */
306 unsigned int user_tag; /* user tag on map entry */
307 unsigned int ref_count; /* obj/map mappers, etc */
308 unsigned short shadow_depth; /* only for obj */
309 unsigned char external_pager; /* only for obj */
310 unsigned char share_mode; /* see enumeration */
311 boolean_t is_submap; /* submap vs obj */
312 vm_behavior_t behavior; /* access behavior hint */
313 vm32_object_id_t object_id; /* obj/map name, not a handle */
314 unsigned short user_wired_count;
2d21ac55
A
315};
316
0a7de745
A
317typedef struct vm_region_submap_short_info_64 *vm_region_submap_short_info_64_t;
318typedef struct vm_region_submap_short_info_64 vm_region_submap_short_info_data_64_t;
2d21ac55 319
0a7de745
A
320#define VM_REGION_SUBMAP_SHORT_INFO_COUNT_64 \
321 ((mach_msg_type_number_t) \
39236c6e
A
322 (sizeof (vm_region_submap_short_info_data_64_t) / sizeof (natural_t)))
323
91447636
A
324struct mach_vm_read_entry {
325 mach_vm_address_t address;
326 mach_vm_size_t size;
e5568f75
A
327};
328
1c79356b 329struct vm_read_entry {
0a7de745
A
330 vm_address_t address;
331 vm_size_t size;
1c79356b
A
332};
333
39037602 334#ifdef VM32_SUPPORT
b0d623f7 335struct vm32_read_entry {
0a7de745
A
336 vm32_address_t address;
337 vm32_size_t size;
b0d623f7
A
338};
339#endif
340
341
1c79356b
A
342#define VM_MAP_ENTRY_MAX (256)
343
0a7de745
A
344typedef struct mach_vm_read_entry mach_vm_read_entry_t[VM_MAP_ENTRY_MAX];
345typedef struct vm_read_entry vm_read_entry_t[VM_MAP_ENTRY_MAX];
39037602 346#ifdef VM32_SUPPORT
0a7de745 347typedef struct vm32_read_entry vm32_read_entry_t[VM_MAP_ENTRY_MAX];
b0d623f7 348#endif
91447636 349
cb323159 350#pragma pack(pop)
1c79356b 351
b0d623f7 352
0a7de745 353#define VM_PAGE_INFO_MAX
b0d623f7
A
354typedef int *vm_page_info_t;
355typedef int vm_page_info_data_t[VM_PAGE_INFO_MAX];
356typedef int vm_page_info_flavor_t;
357
0a7de745 358#define VM_PAGE_INFO_BASIC 1
b0d623f7 359struct vm_page_info_basic {
0a7de745
A
360 int disposition;
361 int ref_count;
362 vm_object_id_t object_id;
363 memory_object_offset_t offset;
364 int depth;
365 int __pad; /* pad to 64-bit boundary */
b0d623f7 366};
0a7de745
A
367typedef struct vm_page_info_basic *vm_page_info_basic_t;
368typedef struct vm_page_info_basic vm_page_info_basic_data_t;
b0d623f7 369
0a7de745 370#define VM_PAGE_INFO_BASIC_COUNT ((mach_msg_type_number_t) \
b0d623f7
A
371 (sizeof(vm_page_info_basic_data_t)/sizeof(int)))
372
373
0a7de745 374#endif /*_MACH_VM_REGION_H_*/