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