2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
34 * File: mach/vm_region.h
36 * Define the attributes of a task's memory region
40 #ifndef _MACH_VM_REGION_H_
41 #define _MACH_VM_REGION_H_
43 #include <mach/boolean.h>
44 #include <mach/vm_prot.h>
45 #include <mach/vm_inherit.h>
46 #include <mach/vm_behavior.h>
47 #include <mach/vm_types.h>
48 #include <mach/message.h>
49 #include <mach/machine/vm_param.h>
50 #include <mach/machine/vm_types.h>
51 #include <mach/memory_object_types.h>
53 #include <sys/cdefs.h>
60 * vm_region_info_t memory region attributes
63 #define VM_REGION_INFO_MAX (1024)
64 typedef int *vm_region_info_t
;
65 typedef int *vm_region_info_64_t
;
66 typedef int *vm_region_recurse_info_t
;
67 typedef int *vm_region_recurse_info_64_t
;
68 typedef int vm_region_flavor_t
;
69 typedef int vm_region_info_data_t
[VM_REGION_INFO_MAX
];
71 #define VM_REGION_BASIC_INFO_64 9
72 struct vm_region_basic_info_64
{
74 vm_prot_t max_protection
;
75 vm_inherit_t inheritance
;
78 memory_object_offset_t offset
;
79 vm_behavior_t behavior
;
80 unsigned short user_wired_count
;
82 typedef struct vm_region_basic_info_64
*vm_region_basic_info_64_t
;
83 typedef struct vm_region_basic_info_64 vm_region_basic_info_data_64_t
;
85 #define VM_REGION_BASIC_INFO_COUNT_64 ((mach_msg_type_number_t) \
86 (sizeof(vm_region_basic_info_data_64_t)/sizeof(int)))
89 * Passing VM_REGION_BASIC_INFO to vm_region_64
90 * automatically converts it to a VM_REGION_BASIC_INFO_64.
91 * Please use that explicitly instead.
93 #define VM_REGION_BASIC_INFO 10
96 * This is the legacy basic info structure. It is
97 * deprecated because it passes only a 32-bit memory object
98 * offset back - too small for many larger objects (e.g. files).
100 struct vm_region_basic_info
{
101 vm_prot_t protection
;
102 vm_prot_t max_protection
;
103 vm_inherit_t inheritance
;
106 uint32_t offset
; /* too small for a real offset */
107 vm_behavior_t behavior
;
108 unsigned short user_wired_count
;
111 typedef struct vm_region_basic_info
*vm_region_basic_info_t
;
112 typedef struct vm_region_basic_info vm_region_basic_info_data_t
;
114 #define VM_REGION_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
115 (sizeof(vm_region_basic_info_data_t)/sizeof(int)))
117 #define VM_REGION_EXTENDED_INFO 11
123 #define SM_TRUESHARED 5
124 #define SM_PRIVATE_ALIASED 6
125 #define SM_SHARED_ALIASED 7
128 * For submap info, the SM flags above are overlayed when a submap
129 * is encountered. The field denotes whether or not machine level mapping
130 * information is being shared. PTE's etc. When such sharing is taking
131 * place the value returned is SM_TRUESHARED otherwise SM_PRIVATE is passed
135 struct vm_region_extended_info
{
136 vm_prot_t protection
;
137 unsigned int user_tag
;
138 unsigned int pages_resident
;
139 unsigned int pages_shared_now_private
;
140 unsigned int pages_swapped_out
;
141 unsigned int pages_dirtied
;
142 unsigned int ref_count
;
143 unsigned short shadow_depth
;
144 unsigned char external_pager
;
145 unsigned char share_mode
;
148 typedef struct vm_region_extended_info
*vm_region_extended_info_t
;
149 typedef struct vm_region_extended_info vm_region_extended_info_data_t
;
151 #define VM_REGION_EXTENDED_INFO_COUNT ((mach_msg_type_number_t) \
152 (sizeof(vm_region_extended_info_data_t)/sizeof(int)))
155 #define VM_REGION_TOP_INFO 12
157 struct vm_region_top_info
{
159 unsigned int ref_count
;
160 unsigned int private_pages_resident
;
161 unsigned int shared_pages_resident
;
162 unsigned char share_mode
;
165 typedef struct vm_region_top_info
*vm_region_top_info_t
;
166 typedef struct vm_region_top_info vm_region_top_info_data_t
;
168 #define VM_REGION_TOP_INFO_COUNT ((mach_msg_type_number_t) \
169 (sizeof(vm_region_top_info_data_t)/sizeof(int)))
174 * vm_region_submap_info will return information on a submap or object.
175 * The user supplies a nesting level on the call. When a walk of the
176 * user's map is done and a submap is encountered, the nesting count is
177 * checked. If the nesting count is greater than 1 the submap is entered and
178 * the offset relative to the address in the base map is examined. If the
179 * nesting count is zero, the information on the submap is returned.
180 * The caller may thus learn about a submap and its contents by judicious
181 * choice of the base map address and nesting count. The nesting count
182 * allows penetration of recursively mapped submaps. If a submap is
183 * encountered as a mapped entry of another submap, the caller may bump
184 * the nesting count and call vm_region_recurse again on the target address
185 * range. The "is_submap" field tells the caller whether or not a submap
186 * has been encountered.
188 * Object only fields are filled in through a walking of the object shadow
189 * chain (where one is present), and a walking of the resident page queue.
193 struct vm_region_submap_info
{
194 vm_prot_t protection
; /* present access protection */
195 vm_prot_t max_protection
; /* max avail through vm_prot */
196 vm_inherit_t inheritance
;/* behavior of map/obj on fork */
197 uint32_t offset
; /* offset into object/map */
198 unsigned int user_tag
; /* user tag on map entry */
199 unsigned int pages_resident
; /* only valid for objects */
200 unsigned int pages_shared_now_private
; /* only for objects */
201 unsigned int pages_swapped_out
; /* only for objects */
202 unsigned int pages_dirtied
; /* only for objects */
203 unsigned int ref_count
; /* obj/map mappers, etc */
204 unsigned short shadow_depth
; /* only for obj */
205 unsigned char external_pager
; /* only for obj */
206 unsigned char share_mode
; /* see enumeration */
207 boolean_t is_submap
; /* submap vs obj */
208 vm_behavior_t behavior
; /* access behavior hint */
209 vm_offset_t object_id
; /* obj/map name, not a handle */
210 unsigned short user_wired_count
;
213 typedef struct vm_region_submap_info
*vm_region_submap_info_t
;
214 typedef struct vm_region_submap_info vm_region_submap_info_data_t
;
216 #define VM_REGION_SUBMAP_INFO_COUNT ((mach_msg_type_number_t) \
217 (sizeof(vm_region_submap_info_data_t)/sizeof(int)))
219 struct vm_region_submap_info_64
{
220 vm_prot_t protection
; /* present access protection */
221 vm_prot_t max_protection
; /* max avail through vm_prot */
222 vm_inherit_t inheritance
;/* behavior of map/obj on fork */
223 memory_object_offset_t offset
; /* offset into object/map */
224 unsigned int user_tag
; /* user tag on map entry */
225 unsigned int pages_resident
; /* only valid for objects */
226 unsigned int pages_shared_now_private
; /* only for objects */
227 unsigned int pages_swapped_out
; /* only for objects */
228 unsigned int pages_dirtied
; /* only for objects */
229 unsigned int ref_count
; /* obj/map mappers, etc */
230 unsigned short shadow_depth
; /* only for obj */
231 unsigned char external_pager
; /* only for obj */
232 unsigned char share_mode
; /* see enumeration */
233 boolean_t is_submap
; /* submap vs obj */
234 vm_behavior_t behavior
; /* access behavior hint */
235 vm_offset_t object_id
; /* obj/map name, not a handle */
236 unsigned short user_wired_count
;
239 typedef struct vm_region_submap_info_64
*vm_region_submap_info_64_t
;
240 typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t
;
242 #define VM_REGION_SUBMAP_INFO_COUNT_64 ((mach_msg_type_number_t) \
243 (sizeof(vm_region_submap_info_data_64_t)/sizeof(int)))
245 struct mach_vm_read_entry
{
246 mach_vm_address_t address
;
250 struct vm_read_entry
{
251 vm_address_t address
;
255 #define VM_MAP_ENTRY_MAX (256)
257 typedef struct mach_vm_read_entry mach_vm_read_entry_t
[VM_MAP_ENTRY_MAX
];
258 typedef struct vm_read_entry vm_read_entry_t
[VM_MAP_ENTRY_MAX
];
262 #endif /*_MACH_VM_REGION_H_*/