Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | /* * Copyright (c) 2000-2016 Apple Computer, Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. The rights granted to you under the License * may not be used to create, or enable the creation or redistribution of, * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* * @OSF_COPYRIGHT@ */ /* * File: mach/vm_region.h * * Define the attributes of a task's memory region * */ #ifndef _MACH_VM_REGION_H_ #define _MACH_VM_REGION_H_ #include <mach/boolean.h> #include <mach/vm_prot.h> #include <mach/vm_inherit.h> #include <mach/vm_behavior.h> #include <mach/vm_types.h> #include <mach/message.h> #include <mach/machine/vm_param.h> #include <mach/machine/vm_types.h> #include <mach/memory_object_types.h> #include <sys/cdefs.h> #pragma pack(push, 4) // LP64todo: all the current tools are 32bit, obviously never worked for 64b // so probably should be a real 32b ID vs. ptr. // Current users just check for equality typedef uint32_t vm32_object_id_t; /* * Types defined: * * vm_region_info_t memory region attributes */ #define VM_REGION_INFO_MAX (1024) typedef int *vm_region_info_t; typedef int *vm_region_info_64_t; typedef int *vm_region_recurse_info_t; typedef int *vm_region_recurse_info_64_t; typedef int vm_region_flavor_t; typedef int vm_region_info_data_t[VM_REGION_INFO_MAX]; #define VM_REGION_BASIC_INFO_64 9 struct vm_region_basic_info_64 { vm_prot_t protection; vm_prot_t max_protection; vm_inherit_t inheritance; boolean_t shared; boolean_t reserved; memory_object_offset_t offset; vm_behavior_t behavior; unsigned short user_wired_count; }; typedef struct vm_region_basic_info_64 *vm_region_basic_info_64_t; typedef struct vm_region_basic_info_64 vm_region_basic_info_data_64_t; #define VM_REGION_BASIC_INFO_COUNT_64 ((mach_msg_type_number_t) \ (sizeof(vm_region_basic_info_data_64_t)/sizeof(int))) /* * Passing VM_REGION_BASIC_INFO to vm_region_64 * automatically converts it to a VM_REGION_BASIC_INFO_64. * Please use that explicitly instead. */ #define VM_REGION_BASIC_INFO 10 /* * This is the legacy basic info structure. It is * deprecated because it passes only a 32-bit memory object * offset back - too small for many larger objects (e.g. files). */ struct vm_region_basic_info { vm_prot_t protection; vm_prot_t max_protection; vm_inherit_t inheritance; boolean_t shared; boolean_t reserved; uint32_t offset; /* too small for a real offset */ vm_behavior_t behavior; unsigned short user_wired_count; }; typedef struct vm_region_basic_info *vm_region_basic_info_t; typedef struct vm_region_basic_info vm_region_basic_info_data_t; #define VM_REGION_BASIC_INFO_COUNT ((mach_msg_type_number_t) \ (sizeof(vm_region_basic_info_data_t)/sizeof(int))) #define SM_COW 1 #define SM_PRIVATE 2 #define SM_EMPTY 3 #define SM_SHARED 4 #define SM_TRUESHARED 5 #define SM_PRIVATE_ALIASED 6 #define SM_SHARED_ALIASED 7 #define SM_LARGE_PAGE 8 /* * For submap info, the SM flags above are overlayed when a submap * is encountered. The field denotes whether or not machine level mapping * information is being shared. PTE's etc. When such sharing is taking * place the value returned is SM_TRUESHARED otherwise SM_PRIVATE is passed * back. */ #ifdef MACH_KERNEL_PRIVATE #define VM_REGION_EXTENDED_INFO__legacy 11 struct vm_region_extended_info__legacy { vm_prot_t protection; unsigned int user_tag; unsigned int pages_resident; unsigned int pages_shared_now_private; unsigned int pages_swapped_out; unsigned int pages_dirtied; unsigned int ref_count; unsigned short shadow_depth; unsigned char external_pager; unsigned char share_mode; /* * XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX * DO NOT EXTEND THIS DATA STRUCTURE. * IT IS NOW ABANDONED AND REPLACED WITH vm_region_extended_info BELOW. * XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX */ }; #define VM_REGION_EXTENDED_INFO_COUNT__legacy \ ((mach_msg_type_number_t) \ (sizeof (struct vm_region_extended_info__legacy) / \ sizeof (natural_t))) #endif /* MACH_KERNEL_PRIVATE */ #define VM_REGION_EXTENDED_INFO 13 struct vm_region_extended_info { vm_prot_t protection; unsigned int user_tag; unsigned int pages_resident; unsigned int pages_shared_now_private; unsigned int pages_swapped_out; unsigned int pages_dirtied; unsigned int ref_count; unsigned short shadow_depth; unsigned char external_pager; unsigned char share_mode; unsigned int pages_reusable; }; typedef struct vm_region_extended_info *vm_region_extended_info_t; typedef struct vm_region_extended_info vm_region_extended_info_data_t; #define VM_REGION_EXTENDED_INFO_COUNT \ ((mach_msg_type_number_t) \ (sizeof (vm_region_extended_info_data_t) / sizeof (natural_t))) #define VM_REGION_TOP_INFO 12 struct vm_region_top_info { unsigned int obj_id; unsigned int ref_count; unsigned int private_pages_resident; unsigned int shared_pages_resident; unsigned char share_mode; }; typedef struct vm_region_top_info *vm_region_top_info_t; typedef struct vm_region_top_info vm_region_top_info_data_t; #define VM_REGION_TOP_INFO_COUNT \ ((mach_msg_type_number_t) \ (sizeof(vm_region_top_info_data_t) / sizeof(natural_t))) /* * vm_region_submap_info will return information on a submap or object. * The user supplies a nesting level on the call. When a walk of the * user's map is done and a submap is encountered, the nesting count is * checked. If the nesting count is greater than 1 the submap is entered and * the offset relative to the address in the base map is examined. If the * nesting count is zero, the information on the submap is returned. * The caller may thus learn about a submap and its contents by judicious * choice of the base map address and nesting count. The nesting count * allows penetration of recursively mapped submaps. If a submap is * encountered as a mapped entry of another submap, the caller may bump * the nesting count and call vm_region_recurse again on the target address * range. The "is_submap" field tells the caller whether or not a submap * has been encountered. * * Object only fields are filled in through a walking of the object shadow * chain (where one is present), and a walking of the resident page queue. * */ struct vm_region_submap_info { vm_prot_t protection; /* present access protection */ vm_prot_t max_protection; /* max avail through vm_prot */ vm_inherit_t inheritance;/* behavior of map/obj on fork */ uint32_t offset; /* offset into object/map */ unsigned int user_tag; /* user tag on map entry */ unsigned int pages_resident; /* only valid for objects */ unsigned int pages_shared_now_private; /* only for objects */ unsigned int pages_swapped_out; /* only for objects */ unsigned int pages_dirtied; /* only for objects */ unsigned int ref_count; /* obj/map mappers, etc */ unsigned short shadow_depth; /* only for obj */ unsigned char external_pager; /* only for obj */ unsigned char share_mode; /* see enumeration */ boolean_t is_submap; /* submap vs obj */ vm_behavior_t behavior; /* access behavior hint */ vm32_object_id_t object_id; /* obj/map name, not a handle */ unsigned short user_wired_count; }; typedef struct vm_region_submap_info *vm_region_submap_info_t; typedef struct vm_region_submap_info vm_region_submap_info_data_t; #define VM_REGION_SUBMAP_INFO_COUNT \ ((mach_msg_type_number_t) \ (sizeof(vm_region_submap_info_data_t) / sizeof(natural_t))) struct vm_region_submap_info_64 { vm_prot_t protection; /* present access protection */ vm_prot_t max_protection; /* max avail through vm_prot */ vm_inherit_t inheritance;/* behavior of map/obj on fork */ memory_object_offset_t offset; /* offset into object/map */ unsigned int user_tag; /* user tag on map entry */ unsigned int pages_resident; /* only valid for objects */ unsigned int pages_shared_now_private; /* only for objects */ unsigned int pages_swapped_out; /* only for objects */ unsigned int pages_dirtied; /* only for objects */ unsigned int ref_count; /* obj/map mappers, etc */ unsigned short shadow_depth; /* only for obj */ unsigned char external_pager; /* only for obj */ unsigned char share_mode; /* see enumeration */ boolean_t is_submap; /* submap vs obj */ vm_behavior_t behavior; /* access behavior hint */ vm32_object_id_t object_id; /* obj/map name, not a handle */ unsigned short user_wired_count; unsigned int pages_reusable; vm_object_id_t object_id_full; }; typedef struct vm_region_submap_info_64 *vm_region_submap_info_64_t; typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t; #define VM_REGION_SUBMAP_INFO_V2_SIZE \ (sizeof (vm_region_submap_info_data_64_t)) #define VM_REGION_SUBMAP_INFO_V1_SIZE \ (VM_REGION_SUBMAP_INFO_V2_SIZE - \ sizeof (vm_object_id_t) /* object_id_full */ ) #define VM_REGION_SUBMAP_INFO_V0_SIZE \ (VM_REGION_SUBMAP_INFO_V1_SIZE - \ sizeof (unsigned int) /* pages_reusable */ ) #define VM_REGION_SUBMAP_INFO_V2_COUNT_64 \ ((mach_msg_type_number_t) \ (VM_REGION_SUBMAP_INFO_V2_SIZE / sizeof (natural_t))) #define VM_REGION_SUBMAP_INFO_V1_COUNT_64 \ ((mach_msg_type_number_t) \ (VM_REGION_SUBMAP_INFO_V1_SIZE / sizeof (natural_t))) #define VM_REGION_SUBMAP_INFO_V0_COUNT_64 \ ((mach_msg_type_number_t) \ (VM_REGION_SUBMAP_INFO_V0_SIZE / sizeof (natural_t))) /* set this to the latest version */ #define VM_REGION_SUBMAP_INFO_COUNT_64 VM_REGION_SUBMAP_INFO_V2_COUNT_64 struct vm_region_submap_short_info_64 { vm_prot_t protection; /* present access protection */ vm_prot_t max_protection; /* max avail through vm_prot */ vm_inherit_t inheritance;/* behavior of map/obj on fork */ memory_object_offset_t offset; /* offset into object/map */ unsigned int user_tag; /* user tag on map entry */ unsigned int ref_count; /* obj/map mappers, etc */ unsigned short shadow_depth; /* only for obj */ unsigned char external_pager; /* only for obj */ unsigned char share_mode; /* see enumeration */ boolean_t is_submap; /* submap vs obj */ vm_behavior_t behavior; /* access behavior hint */ vm32_object_id_t object_id; /* obj/map name, not a handle */ unsigned short user_wired_count; }; typedef struct vm_region_submap_short_info_64 *vm_region_submap_short_info_64_t; typedef struct vm_region_submap_short_info_64 vm_region_submap_short_info_data_64_t; #define VM_REGION_SUBMAP_SHORT_INFO_COUNT_64 \ ((mach_msg_type_number_t) \ (sizeof (vm_region_submap_short_info_data_64_t) / sizeof (natural_t))) struct mach_vm_read_entry { mach_vm_address_t address; mach_vm_size_t size; }; struct vm_read_entry { vm_address_t address; vm_size_t size; }; #ifdef VM32_SUPPORT struct vm32_read_entry { vm32_address_t address; vm32_size_t size; }; #endif #define VM_MAP_ENTRY_MAX (256) typedef struct mach_vm_read_entry mach_vm_read_entry_t[VM_MAP_ENTRY_MAX]; typedef struct vm_read_entry vm_read_entry_t[VM_MAP_ENTRY_MAX]; #ifdef VM32_SUPPORT typedef struct vm32_read_entry vm32_read_entry_t[VM_MAP_ENTRY_MAX]; #endif #pragma pack(pop) #define VM_PAGE_INFO_MAX typedef int *vm_page_info_t; typedef int vm_page_info_data_t[VM_PAGE_INFO_MAX]; typedef int vm_page_info_flavor_t; #define VM_PAGE_INFO_BASIC 1 struct vm_page_info_basic { int disposition; int ref_count; vm_object_id_t object_id; memory_object_offset_t offset; int depth; int __pad; /* pad to 64-bit boundary */ }; typedef struct vm_page_info_basic *vm_page_info_basic_t; typedef struct vm_page_info_basic vm_page_info_basic_data_t; #define VM_PAGE_INFO_BASIC_COUNT ((mach_msg_type_number_t) \ (sizeof(vm_page_info_basic_data_t)/sizeof(int))) #endif /*_MACH_VM_REGION_H_*/ |