]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/vm_region.h
xnu-1699.24.8.tar.gz
[apple/xnu.git] / osfmk / mach / vm_region.h
CommitLineData
1c79356b 1/*
2d21ac55 2 * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 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.
8f6c56a5 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.
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
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.
8f6c56a5 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
38#ifndef _MACH_VM_REGION_H_
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
0c530ab8 53#pragma pack(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)
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
91447636 74#define VM_REGION_BASIC_INFO_64 9
1c79356b
A
75struct vm_region_basic_info_64 {
76 vm_prot_t protection;
77 vm_prot_t max_protection;
78 vm_inherit_t inheritance;
79 boolean_t shared;
80 boolean_t reserved;
91447636 81 memory_object_offset_t offset;
1c79356b
A
82 vm_behavior_t behavior;
83 unsigned short user_wired_count;
84};
1c79356b
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;
87
91447636
A
88#define VM_REGION_BASIC_INFO_COUNT_64 ((mach_msg_type_number_t) \
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 */
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
A
103struct vm_region_basic_info {
104 vm_prot_t protection;
105 vm_prot_t max_protection;
106 vm_inherit_t inheritance;
107 boolean_t shared;
108 boolean_t reserved;
91447636 109 uint32_t offset; /* too small for a real offset */
1c79356b
A
110 vm_behavior_t behavior;
111 unsigned short user_wired_count;
112};
113
114typedef struct vm_region_basic_info *vm_region_basic_info_t;
115typedef struct vm_region_basic_info vm_region_basic_info_data_t;
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
A
119
120#define VM_REGION_EXTENDED_INFO 11
121
122#define SM_COW 1
123#define SM_PRIVATE 2
124#define SM_EMPTY 3
125#define SM_SHARED 4
126#define SM_TRUESHARED 5
127#define SM_PRIVATE_ALIASED 6
128#define SM_SHARED_ALIASED 7
6d2010ae 129#define SM_LARGE_PAGE 8
1c79356b
A
130
131/*
132 * For submap info, the SM flags above are overlayed when a submap
133 * is encountered. The field denotes whether or not machine level mapping
134 * information is being shared. PTE's etc. When such sharing is taking
135 * place the value returned is SM_TRUESHARED otherwise SM_PRIVATE is passed
136 * back.
137 */
138
1c79356b
A
139struct vm_region_extended_info {
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;
0b4e3aa0 145 unsigned int pages_dirtied;
1c79356b
A
146 unsigned int ref_count;
147 unsigned short shadow_depth;
148 unsigned char external_pager;
149 unsigned char share_mode;
150};
151
152typedef struct vm_region_extended_info *vm_region_extended_info_t;
153typedef struct vm_region_extended_info vm_region_extended_info_data_t;
154
91447636
A
155#define VM_REGION_EXTENDED_INFO_COUNT ((mach_msg_type_number_t) \
156 (sizeof(vm_region_extended_info_data_t)/sizeof(int)))
1c79356b
A
157
158
159#define VM_REGION_TOP_INFO 12
160
161struct vm_region_top_info {
162 unsigned int obj_id;
163 unsigned int ref_count;
164 unsigned int private_pages_resident;
165 unsigned int shared_pages_resident;
166 unsigned char share_mode;
167};
168
169typedef struct vm_region_top_info *vm_region_top_info_t;
170typedef struct vm_region_top_info vm_region_top_info_data_t;
171
91447636
A
172#define VM_REGION_TOP_INFO_COUNT ((mach_msg_type_number_t) \
173 (sizeof(vm_region_top_info_data_t)/sizeof(int)))
1c79356b
A
174
175
176
177/*
178 * vm_region_submap_info will return information on a submap or object.
179 * The user supplies a nesting level on the call. When a walk of the
180 * user's map is done and a submap is encountered, the nesting count is
181 * checked. If the nesting count is greater than 1 the submap is entered and
182 * the offset relative to the address in the base map is examined. If the
183 * nesting count is zero, the information on the submap is returned.
184 * The caller may thus learn about a submap and its contents by judicious
185 * choice of the base map address and nesting count. The nesting count
186 * allows penetration of recursively mapped submaps. If a submap is
187 * encountered as a mapped entry of another submap, the caller may bump
188 * the nesting count and call vm_region_recurse again on the target address
189 * range. The "is_submap" field tells the caller whether or not a submap
190 * has been encountered.
191 *
192 * Object only fields are filled in through a walking of the object shadow
193 * chain (where one is present), and a walking of the resident page queue.
194 *
195 */
91447636 196
1c79356b
A
197struct vm_region_submap_info {
198 vm_prot_t protection; /* present access protection */
199 vm_prot_t max_protection; /* max avail through vm_prot */
200 vm_inherit_t inheritance;/* behavior of map/obj on fork */
91447636 201 uint32_t offset; /* offset into object/map */
1c79356b
A
202 unsigned int user_tag; /* user tag on map entry */
203 unsigned int pages_resident; /* only valid for objects */
204 unsigned int pages_shared_now_private; /* only for objects */
205 unsigned int pages_swapped_out; /* only for objects */
0b4e3aa0 206 unsigned int pages_dirtied; /* only for objects */
1c79356b
A
207 unsigned int ref_count; /* obj/map mappers, etc */
208 unsigned short shadow_depth; /* only for obj */
209 unsigned char external_pager; /* only for obj */
210 unsigned char share_mode; /* see enumeration */
211 boolean_t is_submap; /* submap vs obj */
212 vm_behavior_t behavior; /* access behavior hint */
b0d623f7 213 vm32_object_id_t object_id; /* obj/map name, not a handle */
1c79356b
A
214 unsigned short user_wired_count;
215};
216
217typedef struct vm_region_submap_info *vm_region_submap_info_t;
218typedef struct vm_region_submap_info vm_region_submap_info_data_t;
219
91447636
A
220#define VM_REGION_SUBMAP_INFO_COUNT ((mach_msg_type_number_t) \
221 (sizeof(vm_region_submap_info_data_t)/sizeof(int)))
1c79356b
A
222
223struct vm_region_submap_info_64 {
224 vm_prot_t protection; /* present access protection */
225 vm_prot_t max_protection; /* max avail through vm_prot */
226 vm_inherit_t inheritance;/* behavior of map/obj on fork */
91447636 227 memory_object_offset_t offset; /* offset into object/map */
1c79356b
A
228 unsigned int user_tag; /* user tag on map entry */
229 unsigned int pages_resident; /* only valid for objects */
230 unsigned int pages_shared_now_private; /* only for objects */
231 unsigned int pages_swapped_out; /* only for objects */
0b4e3aa0 232 unsigned int pages_dirtied; /* only for objects */
1c79356b
A
233 unsigned int ref_count; /* obj/map mappers, etc */
234 unsigned short shadow_depth; /* only for obj */
235 unsigned char external_pager; /* only for obj */
236 unsigned char share_mode; /* see enumeration */
237 boolean_t is_submap; /* submap vs obj */
238 vm_behavior_t behavior; /* access behavior hint */
b0d623f7 239 vm32_object_id_t object_id; /* obj/map name, not a handle */
1c79356b
A
240 unsigned short user_wired_count;
241};
242
243typedef struct vm_region_submap_info_64 *vm_region_submap_info_64_t;
244typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t;
245
91447636
A
246#define VM_REGION_SUBMAP_INFO_COUNT_64 ((mach_msg_type_number_t) \
247 (sizeof(vm_region_submap_info_data_64_t)/sizeof(int)))
1c79356b 248
2d21ac55
A
249struct vm_region_submap_short_info_64 {
250 vm_prot_t protection; /* present access protection */
251 vm_prot_t max_protection; /* max avail through vm_prot */
252 vm_inherit_t inheritance;/* behavior of map/obj on fork */
253 memory_object_offset_t offset; /* offset into object/map */
254 unsigned int user_tag; /* user tag on map entry */
255 unsigned int ref_count; /* obj/map mappers, etc */
256 unsigned short shadow_depth; /* only for obj */
257 unsigned char external_pager; /* only for obj */
258 unsigned char share_mode; /* see enumeration */
259 boolean_t is_submap; /* submap vs obj */
260 vm_behavior_t behavior; /* access behavior hint */
b0d623f7 261 vm32_object_id_t object_id; /* obj/map name, not a handle */
2d21ac55
A
262 unsigned short user_wired_count;
263};
264
265typedef struct vm_region_submap_short_info_64 *vm_region_submap_short_info_64_t;
266typedef struct vm_region_submap_short_info_64 vm_region_submap_short_info_data_64_t;
267
268#define VM_REGION_SUBMAP_SHORT_INFO_COUNT_64 ((mach_msg_type_number_t) \
269 (sizeof(vm_region_submap_short_info_data_64_t)/sizeof(int)))
270
271
91447636
A
272struct mach_vm_read_entry {
273 mach_vm_address_t address;
274 mach_vm_size_t size;
e5568f75
A
275};
276
1c79356b
A
277struct vm_read_entry {
278 vm_address_t address;
279 vm_size_t size;
280};
281
b0d623f7
A
282#if VM32_SUPPORT
283struct vm32_read_entry {
284 vm32_address_t address;
285 vm32_size_t size;
286};
287#endif
288
289
1c79356b
A
290#define VM_MAP_ENTRY_MAX (256)
291
91447636
A
292typedef struct mach_vm_read_entry mach_vm_read_entry_t[VM_MAP_ENTRY_MAX];
293typedef struct vm_read_entry vm_read_entry_t[VM_MAP_ENTRY_MAX];
b0d623f7
A
294#if VM32_SUPPORT
295typedef struct vm32_read_entry vm32_read_entry_t[VM_MAP_ENTRY_MAX];
296#endif
91447636 297
0c530ab8 298#pragma pack()
1c79356b 299
b0d623f7
A
300
301#define VM_PAGE_INFO_MAX
302typedef int *vm_page_info_t;
303typedef int vm_page_info_data_t[VM_PAGE_INFO_MAX];
304typedef int vm_page_info_flavor_t;
305
306#define VM_PAGE_INFO_BASIC 1
307struct vm_page_info_basic {
308 int disposition;
309 int ref_count;
310 vm_object_id_t object_id;
311 memory_object_offset_t offset;
312 int depth;
6d2010ae 313 int __pad; /* pad to 64-bit boundary */
b0d623f7
A
314};
315typedef struct vm_page_info_basic *vm_page_info_basic_t;
316typedef struct vm_page_info_basic vm_page_info_basic_data_t;
317
318#define VM_PAGE_INFO_BASIC_COUNT ((mach_msg_type_number_t) \
319 (sizeof(vm_page_info_basic_data_t)/sizeof(int)))
320
321
1c79356b 322#endif /*_MACH_VM_REGION_H_*/