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