| 1 |
//! This module roughly corresponds to `mach/vm_region.h`. |
| 2 |
|
| 3 |
use boolean::boolean_t; |
| 4 |
use mem; |
| 5 |
use memory_object_types::{memory_object_offset_t, vm_object_id_t}; |
| 6 |
use message::mach_msg_type_number_t; |
| 7 |
use vm_behavior::vm_behavior_t; |
| 8 |
use vm_inherit::vm_inherit_t; |
| 9 |
use vm_prot::vm_prot_t; |
| 10 |
use vm_types::{mach_vm_address_t, mach_vm_size_t}; |
| 11 |
|
| 12 |
pub type vm32_object_id_t = u32; |
| 13 |
|
| 14 |
pub type vm_region_info_t = *mut ::libc::c_int; |
| 15 |
pub type vm_region_info_64_t = *mut ::libc::c_int; |
| 16 |
pub type vm_region_recurse_info_t = *mut ::libc::c_int; |
| 17 |
pub type vm_region_recurse_info_64_t = *mut ::libc::c_int; |
| 18 |
pub type vm_region_flavor_t = ::libc::c_int; |
| 19 |
pub type vm_region_info_data_t = [::libc::c_int; VM_REGION_INFO_MAX as usize]; |
| 20 |
|
| 21 |
pub type vm_region_basic_info_64_t = *mut vm_region_basic_info_64; |
| 22 |
pub type vm_region_basic_info_data_64_t = vm_region_basic_info_64; |
| 23 |
pub type vm_region_basic_info_t = *mut vm_region_basic_info; |
| 24 |
pub type vm_region_basic_info_data_t = vm_region_basic_info; |
| 25 |
pub type vm_region_extended_info_t = *mut vm_region_extended_info; |
| 26 |
pub type vm_region_extended_info_data_t = vm_region_extended_info; |
| 27 |
pub type vm_region_top_info_t = *mut vm_region_top_info; |
| 28 |
pub type vm_region_top_info_data_t = vm_region_top_info; |
| 29 |
pub type vm_region_submap_info_t = *mut vm_region_submap_info; |
| 30 |
pub type vm_region_submap_info_data_t = vm_region_submap_info; |
| 31 |
pub type vm_region_submap_info_64_t = *mut vm_region_submap_info_64; |
| 32 |
pub type vm_region_submap_info_data_64_t = vm_region_submap_info_64; |
| 33 |
pub type vm_region_submap_short_info_64_t = *mut vm_region_submap_short_info_64; |
| 34 |
pub type vm_region_submap_short_info_data_64_t = vm_region_submap_short_info_64; |
| 35 |
pub type vm_page_info_t = *mut ::libc::c_int; |
| 36 |
pub type vm_page_info_flavor_t = ::libc::c_int; |
| 37 |
pub type vm_page_info_basic_t = *mut vm_page_info_basic; |
| 38 |
pub type vm_page_info_basic_data_t = vm_page_info_basic; |
| 39 |
pub type mach_vm_read_entry_t = [mach_vm_read_entry; VM_MAP_ENTRY_MAX as usize]; |
| 40 |
|
| 41 |
pub const VM_REGION_INFO_MAX: ::libc::c_int = (1 << 10); |
| 42 |
pub const VM_MAP_ENTRY_MAX: ::libc::c_int = (1 << 8); |
| 43 |
|
| 44 |
pub const VM_PAGE_INFO_BASIC: vm_page_info_flavor_t = 1; |
| 45 |
|
| 46 |
pub const VM_REGION_BASIC_INFO_64: vm_region_flavor_t = 9; |
| 47 |
pub const VM_REGION_BASIC_INFO: vm_region_flavor_t = 10; |
| 48 |
pub const VM_REGION_EXTENDED_INFO: vm_region_flavor_t = 13; |
| 49 |
pub const VM_REGION_TOP_INFO: vm_region_flavor_t = 12; |
| 50 |
|
| 51 |
pub const SM_COW: ::libc::c_uchar = 1; |
| 52 |
pub const SM_PRIVATE: ::libc::c_uchar = 2; |
| 53 |
pub const SM_EMPTY: ::libc::c_uchar = 3; |
| 54 |
pub const SM_SHARED: ::libc::c_uchar = 4; |
| 55 |
pub const SM_TRUESHARED: ::libc::c_uchar = 5; |
| 56 |
pub const SM_PRIVATE_ALIASED: ::libc::c_uchar = 6; |
| 57 |
pub const SM_SHARED_ALIASED: ::libc::c_uchar = 7; |
| 58 |
|
| 59 |
#[repr(C, packed(4))] |
| 60 |
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)] |
| 61 |
pub struct vm_region_basic_info_64 { |
| 62 |
pub protection: vm_prot_t, |
| 63 |
pub max_protection: vm_prot_t, |
| 64 |
pub inheritance: vm_inherit_t, |
| 65 |
pub shared: boolean_t, |
| 66 |
pub reserved: boolean_t, |
| 67 |
pub offset: memory_object_offset_t, |
| 68 |
pub behavior: vm_behavior_t, |
| 69 |
pub user_wired_count: ::libc::c_ushort, |
| 70 |
} |
| 71 |
|
| 72 |
impl vm_region_basic_info_64 { |
| 73 |
pub fn count() -> mach_msg_type_number_t { |
| 74 |
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
#[repr(C)] |
| 79 |
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)] |
| 80 |
pub struct vm_region_basic_info { |
| 81 |
pub protection: vm_prot_t, |
| 82 |
pub max_protection: vm_prot_t, |
| 83 |
pub inheritance: vm_inherit_t, |
| 84 |
pub shared: boolean_t, |
| 85 |
pub reserved: boolean_t, |
| 86 |
pub offset: u32, |
| 87 |
pub behavior: vm_behavior_t, |
| 88 |
pub user_wired_count: ::libc::c_ushort, |
| 89 |
} |
| 90 |
|
| 91 |
impl vm_region_basic_info { |
| 92 |
pub fn count() -> mach_msg_type_number_t { |
| 93 |
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
#[repr(C)] |
| 98 |
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)] |
| 99 |
pub struct vm_region_extended_info { |
| 100 |
pub protection: vm_prot_t, |
| 101 |
pub user_tag: ::libc::c_uint, |
| 102 |
pub pages_resident: ::libc::c_uint, |
| 103 |
pub pages_shared_now_private: ::libc::c_uint, |
| 104 |
pub pages_swapped_out: ::libc::c_uint, |
| 105 |
pub pages_dirtied: ::libc::c_uint, |
| 106 |
pub ref_count: ::libc::c_uint, |
| 107 |
pub shadow_depth: ::libc::c_ushort, |
| 108 |
pub external_pager: ::libc::c_uchar, |
| 109 |
pub share_mode: ::libc::c_uchar, |
| 110 |
pub pages_reusable: ::libc::c_uint, |
| 111 |
} |
| 112 |
|
| 113 |
impl vm_region_extended_info { |
| 114 |
pub fn count() -> mach_msg_type_number_t { |
| 115 |
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
#[repr(C)] |
| 120 |
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)] |
| 121 |
pub struct vm_region_top_info { |
| 122 |
pub obj_id: ::libc::c_uint, |
| 123 |
pub ref_count: ::libc::c_uint, |
| 124 |
pub private_pages_resident: ::libc::c_uint, |
| 125 |
pub shared_pages_resident: ::libc::c_uint, |
| 126 |
pub share_mode: ::libc::c_uchar, |
| 127 |
} |
| 128 |
|
| 129 |
impl vm_region_top_info { |
| 130 |
pub fn count() -> mach_msg_type_number_t { |
| 131 |
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
#[repr(C)] |
| 136 |
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)] |
| 137 |
pub struct vm_region_submap_info { |
| 138 |
pub protection: vm_prot_t, |
| 139 |
pub max_protection: vm_prot_t, |
| 140 |
pub inheritance: vm_inherit_t, |
| 141 |
pub offset: u32, |
| 142 |
pub user_tag: ::libc::c_uint, |
| 143 |
pub pages_resident: ::libc::c_uint, |
| 144 |
pub pages_shared_now_private: ::libc::c_uint, |
| 145 |
pub pages_swapped_out: ::libc::c_uint, |
| 146 |
pub pages_dirtied: ::libc::c_uint, |
| 147 |
pub ref_count: ::libc::c_uint, |
| 148 |
pub shadow_depth: ::libc::c_ushort, |
| 149 |
pub external_pager: ::libc::c_uchar, |
| 150 |
pub share_mode: ::libc::c_uchar, |
| 151 |
pub is_submap: boolean_t, |
| 152 |
pub behavior: vm_behavior_t, |
| 153 |
pub object_id: vm32_object_id_t, |
| 154 |
pub user_wired_count: ::libc::c_ushort, |
| 155 |
} |
| 156 |
|
| 157 |
impl vm_region_submap_info { |
| 158 |
pub fn count() -> mach_msg_type_number_t { |
| 159 |
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t |
| 160 |
} |
| 161 |
} |
| 162 |
|
| 163 |
#[repr(C, packed(4))] |
| 164 |
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)] |
| 165 |
pub struct vm_region_submap_info_64 { |
| 166 |
pub protection: vm_prot_t, |
| 167 |
pub max_protection: vm_prot_t, |
| 168 |
pub inheritance: vm_inherit_t, |
| 169 |
pub offset: memory_object_offset_t, |
| 170 |
pub user_tag: ::libc::c_uint, |
| 171 |
pub pages_resident: ::libc::c_uint, |
| 172 |
pub pages_shared_now_private: ::libc::c_uint, |
| 173 |
pub pages_swapped_out: ::libc::c_uint, |
| 174 |
pub pages_dirtied: ::libc::c_uint, |
| 175 |
pub ref_count: ::libc::c_uint, |
| 176 |
pub shadow_depth: ::libc::c_ushort, |
| 177 |
pub external_pager: ::libc::c_uchar, |
| 178 |
pub share_mode: ::libc::c_uchar, |
| 179 |
pub is_submap: boolean_t, |
| 180 |
pub behavior: vm_behavior_t, |
| 181 |
pub object_id: vm32_object_id_t, |
| 182 |
pub user_wired_count: ::libc::c_ushort, |
| 183 |
pub pages_reusable: ::libc::c_uint, |
| 184 |
} |
| 185 |
|
| 186 |
impl vm_region_submap_info_64 { |
| 187 |
pub fn count() -> mach_msg_type_number_t { |
| 188 |
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
#[repr(C, packed(4))] |
| 193 |
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)] |
| 194 |
pub struct vm_region_submap_short_info_64 { |
| 195 |
pub protection: vm_prot_t, |
| 196 |
pub max_protection: vm_prot_t, |
| 197 |
pub inheritance: vm_inherit_t, |
| 198 |
pub offset: memory_object_offset_t, |
| 199 |
pub user_tag: ::libc::c_uint, |
| 200 |
pub ref_count: ::libc::c_uint, |
| 201 |
pub shadow_depth: ::libc::c_ushort, |
| 202 |
pub external_pager: ::libc::c_uchar, |
| 203 |
pub share_mode: ::libc::c_uchar, |
| 204 |
pub is_submap: boolean_t, |
| 205 |
pub behavior: vm_behavior_t, |
| 206 |
pub object_id: vm32_object_id_t, |
| 207 |
pub user_wired_count: ::libc::c_ushort, |
| 208 |
} |
| 209 |
|
| 210 |
impl vm_region_submap_short_info_64 { |
| 211 |
pub fn count() -> mach_msg_type_number_t { |
| 212 |
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t |
| 213 |
} |
| 214 |
} |
| 215 |
|
| 216 |
#[repr(C)] |
| 217 |
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)] |
| 218 |
pub struct vm_page_info_basic { |
| 219 |
pub disposition: ::libc::c_int, |
| 220 |
pub ref_count: ::libc::c_int, |
| 221 |
pub object_id: vm_object_id_t, |
| 222 |
pub offset: memory_object_offset_t, |
| 223 |
pub depth: ::libc::c_int, |
| 224 |
pub __pad: ::libc::c_int, |
| 225 |
} |
| 226 |
|
| 227 |
impl vm_page_info_basic { |
| 228 |
pub fn count() -> mach_msg_type_number_t { |
| 229 |
(mem::size_of::<Self>() / mem::size_of::<::libc::c_int>()) as mach_msg_type_number_t |
| 230 |
} |
| 231 |
} |
| 232 |
|
| 233 |
#[repr(C, packed(4))] |
| 234 |
#[derive(Copy, Clone, Debug, Default, Hash, PartialOrd, PartialEq, Eq, Ord)] |
| 235 |
pub struct mach_vm_read_entry { |
| 236 |
pub address: mach_vm_address_t, |
| 237 |
pub size: mach_vm_size_t, |
| 238 |
} |