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