1#![expect(non_camel_case_types)]
8#![no_std]
9pub use vm_object_bindings::VmObject;
10pub use zx_types::{zx_status_t, zx_vaddr_t as vaddr_t};
11pub type fbl_RefPtr = core::ffi::c_void;
12pub type VmAspace = core::ffi::c_void;
13pub type MultiPageRequest = core::ffi::c_void;
14
15#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)]
16#[repr(C, align(8))]
17pub struct __BindgenOpaqueArray8<T>(pub T);
18impl<T: Copy + Default, const N: usize> Default for __BindgenOpaqueArray8<[T; N]> {
19 fn default() -> Self {
20 Self([<T as Default>::default(); N])
21 }
22}
23pub const VMAR_FLAG_COMPACT: u32 = 1;
24pub const VMAR_FLAG_SPECIFIC: u32 = 2;
25pub const VMAR_FLAG_SPECIFIC_OVERWRITE: u32 = 4;
26pub const VMAR_FLAG_CAN_MAP_SPECIFIC: u32 = 8;
27pub const VMAR_FLAG_CAN_MAP_READ: u32 = 16;
28pub const VMAR_FLAG_CAN_MAP_WRITE: u32 = 32;
29pub const VMAR_FLAG_CAN_MAP_EXECUTE: u32 = 64;
30pub const VMAR_FLAG_REQUIRE_NON_RESIZABLE: u32 = 128;
31pub const VMAR_FLAG_ALLOW_FAULTS: u32 = 256;
32pub const VMAR_FLAG_OFFSET_IS_UPPER_LIMIT: u32 = 512;
33pub const VMAR_FLAG_DEBUG_DYNAMIC_KERNEL_MAPPING: u32 = 1024;
34pub const VMAR_FLAG_FAULT_BEYOND_STREAM_SIZE: u32 = 2048;
35pub const VMAR_CAN_RWX_FLAGS: u32 = 112;
36pub type uint = ::core::ffi::c_uint;
37pub type arch_mmu_flags_t = u8;
38#[repr(u8)]
39#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
40pub enum VmAddressRegionOpChildren {
41 Yes = 0,
42 No = 1,
43}
44unsafe extern "C" {
45 pub fn cpp_vm_address_region_or_mapping_state(
46 region_or_mapping: *mut VmAddressRegionOrMapping,
47 ) -> *mut ::core::ffi::c_void;
48}
49unsafe extern "C" {
50 pub fn cpp_vm_address_region_state(vmar: *mut VmAddressRegion) -> *mut ::core::ffi::c_void;
51}
52unsafe extern "C" {
53 pub fn cpp_vm_mapping_state(mapping: *mut VmMapping) -> *mut ::core::ffi::c_void;
54}
55#[repr(C)]
56#[repr(align(8))]
57#[derive(Debug, Copy, Clone)]
58pub struct VmAddressRegionOrMapping {
59 pub _bindgen_opaque_blob: __BindgenOpaqueArray8<[u8; 48usize]>,
60}
61#[repr(u8)]
62#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
63pub enum VmAddressRegionOrMapping_MemoryPriority {
64 DEFAULT = 0,
65 HIGH = 1,
66}
67#[repr(u8)]
68#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
69pub enum VmAddressRegionOrMapping_LifeCycleState {
70 NOT_READY = 0,
71 ALIVE = 1,
72 DEAD = 2,
73}
74pub type VmMappingProtectionRanges = __BindgenOpaqueArray8<[u8; 8usize]>;
75unsafe extern "C" {
76 pub fn cpp_vm_address_region_destruct(vmar: *mut VmAddressRegion);
77}
78unsafe extern "C" {
79 pub fn cpp_vm_address_region_subregions_find_region(
80 vmar: *const VmAddressRegion,
81 addr: vaddr_t,
82 ) -> *mut VmAddressRegionOrMapping;
83}
84unsafe extern "C" {
85 pub fn cpp_vm_address_region_subregions_include_or_higher(
86 vmar: *const VmAddressRegion,
87 base: vaddr_t,
88 ) -> *mut VmAddressRegionOrMapping;
89}
90unsafe extern "C" {
91 pub fn cpp_vm_address_region_subregions_insert_region(
92 vmar: *mut VmAddressRegion,
93 region: *mut VmAddressRegionOrMapping,
94 ) -> zx_status_t;
95}
96unsafe extern "C" {
97 pub fn cpp_vm_address_region_subregions_size_slow(vmar: *const VmAddressRegion) -> usize;
98}
99unsafe extern "C" {
100 pub fn cpp_vm_address_region_subregions_remove_region(
101 vmar: *mut VmAddressRegion,
102 region: *mut VmAddressRegionOrMapping,
103 );
104}
105unsafe extern "C" {
106 pub fn cpp_vm_address_region_subregions_is_empty(vmar: *const VmAddressRegion) -> bool;
107}
108unsafe extern "C" {
109 pub fn cpp_vm_address_region_subregions_front(
110 vmar: *mut VmAddressRegion,
111 ) -> *mut VmAddressRegionOrMapping;
112}
113unsafe extern "C" {
114 pub fn cpp_vm_address_region_subregions_for_each(
115 vmar: *const VmAddressRegion,
116 cb: ::core::option::Option<
117 unsafe extern "C" fn(
118 arg1: *mut VmAddressRegionOrMapping,
119 arg2: *mut ::core::ffi::c_void,
120 ),
121 >,
122 ctx: *mut ::core::ffi::c_void,
123 );
124}
125unsafe extern "C" {
126 pub fn cpp_vm_mapping_rest_protection_ranges(
127 mapping: *mut VmMapping,
128 ) -> *mut VmMappingProtectionRanges;
129}
130unsafe extern "C" {
131 pub fn cpp_vm_mapping_rest_protection_ranges_const(
132 mapping: *const VmMapping,
133 ) -> *const VmMappingProtectionRanges;
134}
135unsafe extern "C" {
136 pub fn cpp_vm_address_region_commit_high_memory_priority(vmar: *mut VmAddressRegion);
137}
138#[repr(C)]
139#[repr(align(8))]
140#[derive(Debug, Copy, Clone)]
141pub struct VmAddressRegion {
142 pub _bindgen_opaque_blob: __BindgenOpaqueArray8<[u8; 96usize]>,
143}
144#[repr(i32)]
145#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
146pub enum VmAddressRegion_RangeOpType {
147 Commit = 0,
148 Decommit = 1,
149 MapRange = 2,
150 Zero = 3,
151 DontNeed = 4,
152 AlwaysNeed = 5,
153 Prefetch = 6,
154}
155unsafe extern "C" {
156 pub fn cpp_vm_mapping_destruct(mapping: *mut VmMapping);
157}
158unsafe extern "C" {
159 pub fn cpp_vm_mapping_force_writable(
160 mapping: *mut VmMapping,
161 out_mapping: *mut *mut VmMapping,
162 ) -> zx_status_t;
163}
164#[repr(C)]
165#[repr(align(8))]
166#[derive(Debug, Copy, Clone)]
167pub struct VmMapping {
168 pub _bindgen_opaque_blob: __BindgenOpaqueArray8<[u8; 88usize]>,
169}
170#[repr(u8)]
171#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
172pub enum VmMapping_Mergeable {
173 YES = 1,
174 NO = 0,
175}
176#[repr(C)]
177#[derive(Debug, Copy, Clone)]
178pub struct VmMapping_FlagsRange {
179 pub mmu_flags: arch_mmu_flags_t,
180 pub __bindgen_padding_0: [u8; 7usize],
181 pub region_top: u64,
182}
183#[repr(u8)]
184#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
185pub enum VmMapping_UnmapOptions {
186 kNone = 0,
187 OnlyHasZeroPages = 1,
188 Harvest = 2,
189}
190#[repr(u8)]
191#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
192pub enum VmMapping_DestroyUnmap {
193 No = 0,
194 Yes = 1,
195}
196#[repr(u8)]
197#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
198pub enum VmMapping_DestroyRemoveFromParent {
199 No = 0,
200 Yes = 1,
201}
202#[repr(u8)]
203#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
204pub enum VmMapping_ActivateInsertRegions {
205 No = 0,
206 Yes = 1,
207}
208#[repr(u8)]
209#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
210pub enum VmAddressRegionEnumeratorType {
211 VmarsAndMappings = 0,
212 MappingsOnly = 1,
213}
214#[repr(C)]
215#[repr(align(8))]
216#[derive(Debug, Copy, Clone)]
217pub struct CppVmAddressRegionEnumerator {
218 pub _bindgen_opaque_blob: __BindgenOpaqueArray8<[u8; 80usize]>,
219}
220pub type VmMappingProtectionRangesCursor = __BindgenOpaqueArray8<[u8; 16usize]>;
221unsafe extern "C" {
222 pub fn cpp_vm_address_region_construct_root(
223 slot: *mut u8,
224 aspace: *mut VmAspace,
225 base: vaddr_t,
226 size: usize,
227 vmar_flags: u32,
228 );
229}
230unsafe extern "C" {
231 pub fn cpp_vm_address_region_construct_child(
232 slot: *mut u8,
233 parent: *mut VmAddressRegion,
234 base: vaddr_t,
235 size: usize,
236 vmar_flags: u32,
237 name: *const ::core::ffi::c_char,
238 );
239}
240unsafe extern "C" {
241 pub fn cpp_vm_address_region_construct_kernel_root(slot: *mut u8, kernel_aspace: *mut VmAspace);
242}
243unsafe extern "C" {
244 pub fn cpp_vm_address_region_or_mapping_lock_is_held(
245 region_or_mapping: *const VmAddressRegionOrMapping,
246 ) -> bool;
247}
248unsafe extern "C" {
249 pub fn cpp_vm_address_region_or_mapping_region_lock_is_held(
250 region_or_mapping: *const VmAddressRegionOrMapping,
251 ) -> bool;
252}
253unsafe extern "C" {
254 pub fn cpp_vm_address_region_or_mapping_as_vm_address_region(
255 region_or_mapping: *mut VmAddressRegionOrMapping,
256 ) -> *mut VmAddressRegion;
257}
258unsafe extern "C" {
259 pub fn cpp_vm_address_region_or_mapping_as_vm_mapping(
260 region_or_mapping: *mut VmAddressRegionOrMapping,
261 ) -> *mut VmMapping;
262}
263unsafe extern "C" {
264 pub fn cpp_vm_address_region_set_memory_priority(
265 vmar: *mut VmAddressRegion,
266 priority: VmAddressRegionOrMapping_MemoryPriority,
267 ) -> zx_status_t;
268}
269unsafe extern "C" {
270 pub fn cpp_vm_address_region_set_memory_priority_locked(
271 vmar: *mut VmAddressRegion,
272 priority: VmAddressRegionOrMapping_MemoryPriority,
273 ) -> zx_status_t;
274}
275unsafe extern "C" {
276 pub fn cpp_vm_address_region_unmap(
277 vmar: *mut VmAddressRegion,
278 base: vaddr_t,
279 size: usize,
280 op_children: VmAddressRegionOpChildren,
281 ) -> zx_status_t;
282}
283unsafe extern "C" {
284 pub fn cpp_vm_address_region_protect(
285 vmar: *mut VmAddressRegion,
286 base: vaddr_t,
287 size: usize,
288 new_arch_mmu_flags: arch_mmu_flags_t,
289 op_children: VmAddressRegionOpChildren,
290 ) -> zx_status_t;
291}
292unsafe extern "C" {
293 pub fn cpp_vm_address_region_range_op(
294 vmar: *mut VmAddressRegion,
295 op: VmAddressRegion_RangeOpType,
296 base: vaddr_t,
297 len: usize,
298 op_children: VmAddressRegionOpChildren,
299 buffer: *mut ::core::ffi::c_void,
300 buffer_size: usize,
301 ) -> zx_status_t;
302}
303unsafe extern "C" {
304 pub fn cpp_vm_address_region_reserve_space(
305 vmar: *mut VmAddressRegion,
306 name: *const ::core::ffi::c_char,
307 base: usize,
308 size: usize,
309 arch_mmu_flags: arch_mmu_flags_t,
310 ) -> zx_status_t;
311}
312unsafe extern "C" {
313 pub fn cpp_vm_address_region_create_sub_vmar(
314 vmar: *mut VmAddressRegion,
315 offset: usize,
316 size: usize,
317 align_pow2: u8,
318 vmar_flags: u32,
319 name: *const ::core::ffi::c_char,
320 out_status: *mut zx_status_t,
321 ) -> *mut VmAddressRegion;
322}
323unsafe extern "C" {
324 pub fn cpp_vm_address_region_create_vm_mapping(
325 vmar: *mut VmAddressRegion,
326 mapping_offset: usize,
327 size: usize,
328 align_pow2: u8,
329 vmar_flags: u32,
330 vmo: *const VmObject,
331 vmo_offset: u64,
332 arch_mmu_flags: arch_mmu_flags_t,
333 name: *const ::core::ffi::c_char,
334 out_base: *mut vaddr_t,
335 out_status: *mut zx_status_t,
336 ) -> *mut VmMapping;
337}
338unsafe extern "C" {
339 pub fn cpp_vm_address_region_enumerator_construct(
340 out: *mut u8,
341 type_: VmAddressRegionEnumeratorType,
342 vmar: *mut VmAddressRegion,
343 min_addr: vaddr_t,
344 max_addr: vaddr_t,
345 );
346}
347unsafe extern "C" {
348 pub fn cpp_vm_address_region_enumerator_destroy(enumerator: *mut CppVmAddressRegionEnumerator);
349}
350unsafe extern "C" {
351 pub fn cpp_vm_address_region_enumerator_next(
352 enumerator: *mut CppVmAddressRegionEnumerator,
353 out_depth: *mut uint,
354 ) -> *mut VmAddressRegionOrMapping;
355}
356unsafe extern "C" {
357 pub fn cpp_vm_address_region_enumerator_pause(enumerator: *mut CppVmAddressRegionEnumerator);
358}
359unsafe extern "C" {
360 pub fn cpp_vm_address_region_enumerator_resume(enumerator: *mut CppVmAddressRegionEnumerator);
361}
362unsafe extern "C" {
363 pub fn cpp_vm_mapping_construct(
364 slot: *mut u8,
365 parent: *mut VmAddressRegion,
366 private_clone: bool,
367 base: vaddr_t,
368 size: usize,
369 vmar_flags: u32,
370 vmo: *mut VmObject,
371 vmo_offset: u64,
372 arch_mmu_flags: arch_mmu_flags_t,
373 mergeable: bool,
374 );
375}
376unsafe extern "C" {
377 pub fn cpp_vm_mapping_construct_with_ranges(
378 slot: *mut u8,
379 parent: *mut VmAddressRegion,
380 private_clone: bool,
381 base: vaddr_t,
382 size: usize,
383 vmar_flags: u32,
384 vmo: *mut VmObject,
385 vmo_offset: u64,
386 first_mmu_flags: arch_mmu_flags_t,
387 ranges: *mut VmMappingProtectionRanges,
388 mergeable: bool,
389 );
390}
391unsafe extern "C" {
392 pub fn cpp_vm_mapping_map_range(
393 mapping: *mut VmMapping,
394 offset: usize,
395 len: usize,
396 commit: bool,
397 ignore_existing: bool,
398 ) -> zx_status_t;
399}
400unsafe extern "C" {
401 pub fn cpp_vm_mapping_debug_unmap(
402 mapping: *mut VmMapping,
403 base: vaddr_t,
404 size: usize,
405 ) -> zx_status_t;
406}
407unsafe extern "C" {
408 pub fn cpp_vm_mapping_mark_mergeable(mapping: *mut VmMapping);
409}
410unsafe extern "C" {
411 pub fn cpp_vm_mapping_protection_ranges_is_empty(
412 ranges: *const VmMappingProtectionRanges,
413 ) -> bool;
414}
415unsafe extern "C" {
416 pub fn cpp_vm_mapping_protection_ranges_clear(ranges: *mut VmMappingProtectionRanges);
417}
418unsafe extern "C" {
419 pub fn cpp_vm_mapping_protection_ranges_begin(
420 ranges: *const VmMappingProtectionRanges,
421 out_cursor: *mut u8,
422 );
423}
424unsafe extern "C" {
425 pub fn cpp_vm_mapping_protection_ranges_end(
426 ranges: *const VmMappingProtectionRanges,
427 out_cursor: *mut u8,
428 );
429}
430unsafe extern "C" {
431 pub fn cpp_vm_mapping_protection_ranges_upper_bound(
432 ranges: *const VmMappingProtectionRanges,
433 key: vaddr_t,
434 out_cursor: *mut u8,
435 );
436}
437unsafe extern "C" {
438 pub fn cpp_vm_mapping_protection_ranges_lower_bound(
439 ranges: *const VmMappingProtectionRanges,
440 key: vaddr_t,
441 out_cursor: *mut u8,
442 );
443}
444unsafe extern "C" {
445 pub fn cpp_vm_mapping_protection_ranges_find(
446 ranges: *const VmMappingProtectionRanges,
447 key: vaddr_t,
448 out_cursor: *mut u8,
449 );
450}
451unsafe extern "C" {
452 pub fn cpp_vm_mapping_protection_ranges_insert(
453 ranges: *mut VmMappingProtectionRanges,
454 key: vaddr_t,
455 flags: arch_mmu_flags_t,
456 out_cursor: *mut u8,
457 );
458}
459unsafe extern "C" {
460 pub fn cpp_vm_mapping_protection_ranges_insert_hint(
461 ranges: *mut VmMappingProtectionRanges,
462 hint: *const VmMappingProtectionRangesCursor,
463 key: vaddr_t,
464 flags: arch_mmu_flags_t,
465 out_cursor: *mut u8,
466 );
467}
468unsafe extern "C" {
469 pub fn cpp_vm_mapping_protection_ranges_update(
470 ranges: *mut VmMappingProtectionRanges,
471 cursor: *const VmMappingProtectionRangesCursor,
472 flags: arch_mmu_flags_t,
473 );
474}
475unsafe extern "C" {
476 pub fn cpp_vm_mapping_protection_ranges_erase(
477 ranges: *mut VmMappingProtectionRanges,
478 cursor: *const VmMappingProtectionRangesCursor,
479 out_cursor: *mut u8,
480 );
481}
482unsafe extern "C" {
483 pub fn cpp_vm_mapping_protection_ranges_cursor_is_valid(
484 cursor: *const VmMappingProtectionRangesCursor,
485 ) -> bool;
486}
487unsafe extern "C" {
488 pub fn cpp_vm_mapping_protection_ranges_cursor_get(
489 cursor: *const VmMappingProtectionRangesCursor,
490 out_key: *mut vaddr_t,
491 out_flags: *mut arch_mmu_flags_t,
492 );
493}
494unsafe extern "C" {
495 pub fn cpp_vm_mapping_protection_ranges_cursor_next(
496 cursor: *mut VmMappingProtectionRangesCursor,
497 );
498}
499unsafe extern "C" {
500 pub fn cpp_vm_mapping_protection_ranges_cursor_prev(
501 cursor: *mut VmMappingProtectionRangesCursor,
502 );
503}
504unsafe extern "C" {
505 pub fn cpp_vm_mapping_page_fault_locked(
506 mapping: *mut VmMapping,
507 va: vaddr_t,
508 pf_flags: u32,
509 additional_pages: usize,
510 page_request: *mut MultiPageRequest,
511 out_mapped: *mut u32,
512 ) -> zx_status_t;
513}