]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/vm_region.h
xnu-792.17.14.tar.gz
[apple/xnu.git] / osfmk / mach / vm_region.h
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
8f6c56a5 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
8f6c56a5
A
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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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
8ad349bb 24 * limitations under the License.
8f6c56a5
A
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
1c79356b
A
31/*
32 * File: mach/vm_region.h
33 *
34 * Define the attributes of a task's memory region
35 *
36 */
37
38#ifndef _MACH_VM_REGION_H_
39#define _MACH_VM_REGION_H_
40
41#include <mach/boolean.h>
42#include <mach/vm_prot.h>
43#include <mach/vm_inherit.h>
44#include <mach/vm_behavior.h>
91447636
A
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>
50
51#include <sys/cdefs.h>
52
8f6c56a5
A
53#if __DARWIN_ALIGN_POWER
54#pragma options align=power
55#endif
1c79356b
A
56
57/*
58 * Types defined:
59 *
60 * vm_region_info_t memory region attributes
61 */
62
63#define VM_REGION_INFO_MAX (1024)
64typedef int *vm_region_info_t;
65typedef int *vm_region_info_64_t;
66typedef int *vm_region_recurse_info_t;
67typedef int *vm_region_recurse_info_64_t;
68typedef int vm_region_flavor_t;
69typedef int vm_region_info_data_t[VM_REGION_INFO_MAX];
70
91447636 71#define VM_REGION_BASIC_INFO_64 9
1c79356b
A
72struct vm_region_basic_info_64 {
73 vm_prot_t protection;
74 vm_prot_t max_protection;
75 vm_inherit_t inheritance;
76 boolean_t shared;
77 boolean_t reserved;
91447636 78 memory_object_offset_t offset;
1c79356b
A
79 vm_behavior_t behavior;
80 unsigned short user_wired_count;
81};
1c79356b
A
82typedef struct vm_region_basic_info_64 *vm_region_basic_info_64_t;
83typedef struct vm_region_basic_info_64 vm_region_basic_info_data_64_t;
84
91447636
A
85#define VM_REGION_BASIC_INFO_COUNT_64 ((mach_msg_type_number_t) \
86 (sizeof(vm_region_basic_info_data_64_t)/sizeof(int)))
1c79356b 87
91447636
A
88/*
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.
92 */
93#define VM_REGION_BASIC_INFO 10
1c79356b 94
91447636
A
95/*
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).
99 */
1c79356b
A
100struct vm_region_basic_info {
101 vm_prot_t protection;
102 vm_prot_t max_protection;
103 vm_inherit_t inheritance;
104 boolean_t shared;
105 boolean_t reserved;
91447636 106 uint32_t offset; /* too small for a real offset */
1c79356b
A
107 vm_behavior_t behavior;
108 unsigned short user_wired_count;
109};
110
111typedef struct vm_region_basic_info *vm_region_basic_info_t;
112typedef struct vm_region_basic_info vm_region_basic_info_data_t;
113
91447636
A
114#define VM_REGION_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
115 (sizeof(vm_region_basic_info_data_t)/sizeof(int)))
1c79356b
A
116
117#define VM_REGION_EXTENDED_INFO 11
118
119#define SM_COW 1
120#define SM_PRIVATE 2
121#define SM_EMPTY 3
122#define SM_SHARED 4
123#define SM_TRUESHARED 5
124#define SM_PRIVATE_ALIASED 6
125#define SM_SHARED_ALIASED 7
126
127/*
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
132 * back.
133 */
134
1c79356b
A
135struct 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;
0b4e3aa0 141 unsigned int pages_dirtied;
1c79356b
A
142 unsigned int ref_count;
143 unsigned short shadow_depth;
144 unsigned char external_pager;
145 unsigned char share_mode;
146};
147
148typedef struct vm_region_extended_info *vm_region_extended_info_t;
149typedef struct vm_region_extended_info vm_region_extended_info_data_t;
150
91447636
A
151#define VM_REGION_EXTENDED_INFO_COUNT ((mach_msg_type_number_t) \
152 (sizeof(vm_region_extended_info_data_t)/sizeof(int)))
1c79356b
A
153
154
155#define VM_REGION_TOP_INFO 12
156
157struct vm_region_top_info {
158 unsigned int obj_id;
159 unsigned int ref_count;
160 unsigned int private_pages_resident;
161 unsigned int shared_pages_resident;
162 unsigned char share_mode;
163};
164
165typedef struct vm_region_top_info *vm_region_top_info_t;
166typedef struct vm_region_top_info vm_region_top_info_data_t;
167
91447636
A
168#define VM_REGION_TOP_INFO_COUNT ((mach_msg_type_number_t) \
169 (sizeof(vm_region_top_info_data_t)/sizeof(int)))
1c79356b
A
170
171
172
173/*
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.
187 *
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.
190 *
191 */
91447636 192
1c79356b
A
193struct 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 */
91447636 197 uint32_t offset; /* offset into object/map */
1c79356b
A
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 */
0b4e3aa0 202 unsigned int pages_dirtied; /* only for objects */
1c79356b
A
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;
211};
212
213typedef struct vm_region_submap_info *vm_region_submap_info_t;
214typedef struct vm_region_submap_info vm_region_submap_info_data_t;
215
91447636
A
216#define VM_REGION_SUBMAP_INFO_COUNT ((mach_msg_type_number_t) \
217 (sizeof(vm_region_submap_info_data_t)/sizeof(int)))
1c79356b
A
218
219struct 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 */
91447636 223 memory_object_offset_t offset; /* offset into object/map */
1c79356b
A
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 */
0b4e3aa0 228 unsigned int pages_dirtied; /* only for objects */
1c79356b
A
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;
237};
238
239typedef struct vm_region_submap_info_64 *vm_region_submap_info_64_t;
240typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t;
241
91447636
A
242#define VM_REGION_SUBMAP_INFO_COUNT_64 ((mach_msg_type_number_t) \
243 (sizeof(vm_region_submap_info_data_64_t)/sizeof(int)))
1c79356b 244
91447636
A
245struct mach_vm_read_entry {
246 mach_vm_address_t address;
247 mach_vm_size_t size;
e5568f75
A
248};
249
1c79356b
A
250struct vm_read_entry {
251 vm_address_t address;
252 vm_size_t size;
253};
254
255#define VM_MAP_ENTRY_MAX (256)
256
91447636
A
257typedef struct mach_vm_read_entry mach_vm_read_entry_t[VM_MAP_ENTRY_MAX];
258typedef struct vm_read_entry vm_read_entry_t[VM_MAP_ENTRY_MAX];
259
8f6c56a5
A
260#if __DARWIN_ALIGN_POWER
261#pragma options align=reset
262#endif
1c79356b
A
263
264#endif /*_MACH_VM_REGION_H_*/