]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/vm_region.h
xnu-792.6.56.tar.gz
[apple/xnu.git] / osfmk / mach / vm_region.h
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
1c79356b
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
ff6e181a
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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
1c79356b 12 *
ff6e181a
A
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
1c79356b
A
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
ff6e181a
A
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.
1c79356b
A
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/*
24 * @OSF_COPYRIGHT@
25 */
1c79356b
A
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>
91447636
A
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
1c79356b
A
51
52/*
53 * Types defined:
54 *
55 * vm_region_info_t memory region attributes
56 */
57
58#define VM_REGION_INFO_MAX (1024)
59typedef int *vm_region_info_t;
60typedef int *vm_region_info_64_t;
61typedef int *vm_region_recurse_info_t;
62typedef int *vm_region_recurse_info_64_t;
63typedef int vm_region_flavor_t;
64typedef int vm_region_info_data_t[VM_REGION_INFO_MAX];
65
91447636 66#define VM_REGION_BASIC_INFO_64 9
1c79356b
A
67struct 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;
91447636 73 memory_object_offset_t offset;
1c79356b
A
74 vm_behavior_t behavior;
75 unsigned short user_wired_count;
76};
1c79356b
A
77typedef struct vm_region_basic_info_64 *vm_region_basic_info_64_t;
78typedef struct vm_region_basic_info_64 vm_region_basic_info_data_64_t;
79
91447636
A
80#define VM_REGION_BASIC_INFO_COUNT_64 ((mach_msg_type_number_t) \
81 (sizeof(vm_region_basic_info_data_64_t)/sizeof(int)))
1c79356b 82
91447636
A
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
1c79356b 89
91447636
A
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 */
1c79356b
A
95struct 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;
91447636 101 uint32_t offset; /* too small for a real offset */
1c79356b
A
102 vm_behavior_t behavior;
103 unsigned short user_wired_count;
104};
105
106typedef struct vm_region_basic_info *vm_region_basic_info_t;
107typedef struct vm_region_basic_info vm_region_basic_info_data_t;
108
91447636
A
109#define VM_REGION_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
110 (sizeof(vm_region_basic_info_data_t)/sizeof(int)))
1c79356b
A
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
1c79356b
A
130struct 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;
0b4e3aa0 136 unsigned int pages_dirtied;
1c79356b
A
137 unsigned int ref_count;
138 unsigned short shadow_depth;
139 unsigned char external_pager;
140 unsigned char share_mode;
141};
142
143typedef struct vm_region_extended_info *vm_region_extended_info_t;
144typedef struct vm_region_extended_info vm_region_extended_info_data_t;
145
91447636
A
146#define VM_REGION_EXTENDED_INFO_COUNT ((mach_msg_type_number_t) \
147 (sizeof(vm_region_extended_info_data_t)/sizeof(int)))
1c79356b
A
148
149
150#define VM_REGION_TOP_INFO 12
151
152struct 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
160typedef struct vm_region_top_info *vm_region_top_info_t;
161typedef struct vm_region_top_info vm_region_top_info_data_t;
162
91447636
A
163#define VM_REGION_TOP_INFO_COUNT ((mach_msg_type_number_t) \
164 (sizeof(vm_region_top_info_data_t)/sizeof(int)))
1c79356b
A
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 */
91447636 187
1c79356b
A
188struct 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 */
91447636 192 uint32_t offset; /* offset into object/map */
1c79356b
A
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 */
0b4e3aa0 197 unsigned int pages_dirtied; /* only for objects */
1c79356b
A
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
208typedef struct vm_region_submap_info *vm_region_submap_info_t;
209typedef struct vm_region_submap_info vm_region_submap_info_data_t;
210
91447636
A
211#define VM_REGION_SUBMAP_INFO_COUNT ((mach_msg_type_number_t) \
212 (sizeof(vm_region_submap_info_data_t)/sizeof(int)))
1c79356b
A
213
214struct 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 */
91447636 218 memory_object_offset_t offset; /* offset into object/map */
1c79356b
A
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 */
0b4e3aa0 223 unsigned int pages_dirtied; /* only for objects */
1c79356b
A
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
234typedef struct vm_region_submap_info_64 *vm_region_submap_info_64_t;
235typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t;
236
91447636
A
237#define VM_REGION_SUBMAP_INFO_COUNT_64 ((mach_msg_type_number_t) \
238 (sizeof(vm_region_submap_info_data_64_t)/sizeof(int)))
1c79356b 239
91447636
A
240struct mach_vm_read_entry {
241 mach_vm_address_t address;
242 mach_vm_size_t size;
e5568f75
A
243};
244
1c79356b
A
245struct vm_read_entry {
246 vm_address_t address;
247 vm_size_t size;
248};
249
250#define VM_MAP_ENTRY_MAX (256)
251
91447636
A
252typedef struct mach_vm_read_entry mach_vm_read_entry_t[VM_MAP_ENTRY_MAX];
253typedef 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
1c79356b
A
258
259#endif /*_MACH_VM_REGION_H_*/