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