2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
21 * @APPLE_LICENSE_HEADER_END@
27 * File: mach/vm_region.h
29 * Define the attributes of a task's memory region
33 #ifndef _MACH_VM_REGION_H_
34 #define _MACH_VM_REGION_H_
36 #include <mach/boolean.h>
37 #include <mach/vm_prot.h>
38 #include <mach/vm_inherit.h>
39 #include <mach/vm_behavior.h>
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>
46 #include <sys/cdefs.h>
48 #if __DARWIN_ALIGN_POWER
49 #pragma options align=power
55 * vm_region_info_t memory region attributes
58 #define VM_REGION_INFO_MAX (1024)
59 typedef int *vm_region_info_t
;
60 typedef int *vm_region_info_64_t
;
61 typedef int *vm_region_recurse_info_t
;
62 typedef int *vm_region_recurse_info_64_t
;
63 typedef int vm_region_flavor_t
;
64 typedef int vm_region_info_data_t
[VM_REGION_INFO_MAX
];
66 #define VM_REGION_BASIC_INFO_64 9
67 struct vm_region_basic_info_64
{
69 vm_prot_t max_protection
;
70 vm_inherit_t inheritance
;
73 memory_object_offset_t offset
;
74 vm_behavior_t behavior
;
75 unsigned short user_wired_count
;
77 typedef struct vm_region_basic_info_64
*vm_region_basic_info_64_t
;
78 typedef struct vm_region_basic_info_64 vm_region_basic_info_data_64_t
;
80 #define VM_REGION_BASIC_INFO_COUNT_64 ((mach_msg_type_number_t) \
81 (sizeof(vm_region_basic_info_data_64_t)/sizeof(int)))
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.
88 #define VM_REGION_BASIC_INFO 10
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).
95 struct vm_region_basic_info
{
97 vm_prot_t max_protection
;
98 vm_inherit_t inheritance
;
101 uint32_t offset
; /* too small for a real offset */
102 vm_behavior_t behavior
;
103 unsigned short user_wired_count
;
106 typedef struct vm_region_basic_info
*vm_region_basic_info_t
;
107 typedef struct vm_region_basic_info vm_region_basic_info_data_t
;
109 #define VM_REGION_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
110 (sizeof(vm_region_basic_info_data_t)/sizeof(int)))
112 #define VM_REGION_EXTENDED_INFO 11
118 #define SM_TRUESHARED 5
119 #define SM_PRIVATE_ALIASED 6
120 #define SM_SHARED_ALIASED 7
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
130 struct 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
;
136 unsigned int pages_dirtied
;
137 unsigned int ref_count
;
138 unsigned short shadow_depth
;
139 unsigned char external_pager
;
140 unsigned char share_mode
;
143 typedef struct vm_region_extended_info
*vm_region_extended_info_t
;
144 typedef struct vm_region_extended_info vm_region_extended_info_data_t
;
146 #define VM_REGION_EXTENDED_INFO_COUNT ((mach_msg_type_number_t) \
147 (sizeof(vm_region_extended_info_data_t)/sizeof(int)))
150 #define VM_REGION_TOP_INFO 12
152 struct vm_region_top_info
{
154 unsigned int ref_count
;
155 unsigned int private_pages_resident
;
156 unsigned int shared_pages_resident
;
157 unsigned char share_mode
;
160 typedef struct vm_region_top_info
*vm_region_top_info_t
;
161 typedef struct vm_region_top_info vm_region_top_info_data_t
;
163 #define VM_REGION_TOP_INFO_COUNT ((mach_msg_type_number_t) \
164 (sizeof(vm_region_top_info_data_t)/sizeof(int)))
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.
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.
188 struct 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 */
192 uint32_t offset
; /* offset into object/map */
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 */
197 unsigned int pages_dirtied
; /* only for objects */
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
;
208 typedef struct vm_region_submap_info
*vm_region_submap_info_t
;
209 typedef struct vm_region_submap_info vm_region_submap_info_data_t
;
211 #define VM_REGION_SUBMAP_INFO_COUNT ((mach_msg_type_number_t) \
212 (sizeof(vm_region_submap_info_data_t)/sizeof(int)))
214 struct 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 */
218 memory_object_offset_t offset
; /* offset into object/map */
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 */
223 unsigned int pages_dirtied
; /* only for objects */
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
;
234 typedef struct vm_region_submap_info_64
*vm_region_submap_info_64_t
;
235 typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t
;
237 #define VM_REGION_SUBMAP_INFO_COUNT_64 ((mach_msg_type_number_t) \
238 (sizeof(vm_region_submap_info_data_64_t)/sizeof(int)))
240 struct mach_vm_read_entry
{
241 mach_vm_address_t address
;
245 struct vm_read_entry
{
246 vm_address_t address
;
250 #define VM_MAP_ENTRY_MAX (256)
252 typedef struct mach_vm_read_entry mach_vm_read_entry_t
[VM_MAP_ENTRY_MAX
];
253 typedef struct vm_read_entry vm_read_entry_t
[VM_MAP_ENTRY_MAX
];
255 #if __DARWIN_ALIGN_POWER
256 #pragma options align=reset
259 #endif /*_MACH_VM_REGION_H_*/