Skip to main content

vm_address_region_bindings/
vm_address_region_bindings.rs

1// Copyright 2026 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// This file is automatically generated by //zircon/kernel/vm:_kernel_bindgen_crate.vm-address-region-bindings.bindgen.
6
7#![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}
74unsafe extern "C" {
75    pub fn cpp_vm_address_region_free(vmar: *mut VmAddressRegion);
76}
77#[repr(C)]
78#[repr(align(8))]
79#[derive(Debug, Copy, Clone)]
80pub struct VmAddressRegion {
81    pub _bindgen_opaque_blob: __BindgenOpaqueArray8<[u8; 96usize]>,
82}
83#[repr(i32)]
84#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
85pub enum VmAddressRegion_RangeOpType {
86    Commit = 0,
87    Decommit = 1,
88    MapRange = 2,
89    Zero = 3,
90    DontNeed = 4,
91    AlwaysNeed = 5,
92    Prefetch = 6,
93}
94unsafe extern "C" {
95    pub fn cpp_vm_mapping_free(mapping: *mut VmMapping);
96}
97unsafe extern "C" {
98    pub fn cpp_vm_mapping_force_writable(
99        mapping: *mut VmMapping,
100        out_mapping: *mut *mut VmMapping,
101    ) -> zx_status_t;
102}
103#[repr(C)]
104#[repr(align(8))]
105#[derive(Debug, Copy, Clone)]
106pub struct VmMapping {
107    pub _bindgen_opaque_blob: __BindgenOpaqueArray8<[u8; 88usize]>,
108}
109#[repr(u8)]
110#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
111pub enum VmMapping_Mergeable {
112    YES = 1,
113    NO = 0,
114}
115#[repr(C)]
116#[derive(Debug, Copy, Clone)]
117pub struct VmMapping_FlagsRange {
118    pub mmu_flags: arch_mmu_flags_t,
119    pub __bindgen_padding_0: [u8; 7usize],
120    pub region_top: u64,
121}
122#[repr(u8)]
123#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
124pub enum VmMapping_UnmapOptions {
125    kNone = 0,
126    OnlyHasZeroPages = 1,
127    Harvest = 2,
128}
129#[repr(u8)]
130#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
131pub enum VmMapping_DestroyUnmap {
132    No = 0,
133    Yes = 1,
134}
135#[repr(u8)]
136#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
137pub enum VmMapping_DestroyRemoveFromParent {
138    No = 0,
139    Yes = 1,
140}
141#[repr(u8)]
142#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
143pub enum VmMapping_ActivateInsertRegions {
144    No = 0,
145    Yes = 1,
146}
147#[repr(u8)]
148#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
149pub enum VmAddressRegionEnumeratorType {
150    VmarsAndMappings = 0,
151    MappingsOnly = 1,
152}
153#[repr(C)]
154#[repr(align(8))]
155#[derive(Debug, Copy, Clone)]
156pub struct CppVmAddressRegionEnumerator {
157    pub _bindgen_opaque_blob: __BindgenOpaqueArray8<[u8; 80usize]>,
158}
159unsafe extern "C" {
160    pub fn cpp_vm_address_region_destroy(vmar: *mut VmAddressRegion) -> zx_status_t;
161}
162unsafe extern "C" {
163    pub fn cpp_vm_address_region_set_memory_priority(
164        vmar: *mut VmAddressRegion,
165        priority: VmAddressRegionOrMapping_MemoryPriority,
166    ) -> zx_status_t;
167}
168unsafe extern "C" {
169    pub fn cpp_vm_address_region_unmap(
170        vmar: *mut VmAddressRegion,
171        base: vaddr_t,
172        size: usize,
173        op_children: VmAddressRegionOpChildren,
174    ) -> zx_status_t;
175}
176unsafe extern "C" {
177    pub fn cpp_vm_address_region_protect(
178        vmar: *mut VmAddressRegion,
179        base: vaddr_t,
180        size: usize,
181        new_arch_mmu_flags: arch_mmu_flags_t,
182        op_children: VmAddressRegionOpChildren,
183    ) -> zx_status_t;
184}
185unsafe extern "C" {
186    pub fn cpp_vm_address_region_range_op(
187        vmar: *mut VmAddressRegion,
188        op: VmAddressRegion_RangeOpType,
189        base: vaddr_t,
190        len: usize,
191        op_children: VmAddressRegionOpChildren,
192        buffer: *mut ::core::ffi::c_void,
193        buffer_size: usize,
194    ) -> zx_status_t;
195}
196unsafe extern "C" {
197    pub fn cpp_vm_address_region_reserve_space(
198        vmar: *mut VmAddressRegion,
199        name: *const ::core::ffi::c_char,
200        base: usize,
201        size: usize,
202        arch_mmu_flags: arch_mmu_flags_t,
203    ) -> zx_status_t;
204}
205unsafe extern "C" {
206    pub fn cpp_vm_address_region_create_sub_vmar(
207        vmar: *mut VmAddressRegion,
208        offset: usize,
209        size: usize,
210        align_pow2: u8,
211        vmar_flags: u32,
212        name: *const ::core::ffi::c_char,
213        out_status: *mut zx_status_t,
214    ) -> *mut VmAddressRegion;
215}
216unsafe extern "C" {
217    pub fn cpp_vm_address_region_create_vm_mapping(
218        vmar: *mut VmAddressRegion,
219        mapping_offset: usize,
220        size: usize,
221        align_pow2: u8,
222        vmar_flags: u32,
223        vmo: *const VmObject,
224        vmo_offset: u64,
225        arch_mmu_flags: arch_mmu_flags_t,
226        name: *const ::core::ffi::c_char,
227        out_base: *mut vaddr_t,
228        out_status: *mut zx_status_t,
229    ) -> *mut VmMapping;
230}
231unsafe extern "C" {
232    pub fn cpp_vm_address_region_find_region(
233        vmar: *mut VmAddressRegion,
234        addr: vaddr_t,
235    ) -> *mut VmAddressRegionOrMapping;
236}
237unsafe extern "C" {
238    pub fn cpp_vm_address_region_find_region_locked(
239        vmar: *mut VmAddressRegion,
240        addr: vaddr_t,
241    ) -> *mut VmAddressRegionOrMapping;
242}
243unsafe extern "C" {
244    pub fn cpp_vm_address_region_enumerator_construct(
245        out: *mut u8,
246        type_: VmAddressRegionEnumeratorType,
247        vmar: *mut VmAddressRegion,
248        min_addr: vaddr_t,
249        max_addr: vaddr_t,
250    );
251}
252unsafe extern "C" {
253    pub fn cpp_vm_address_region_enumerator_destroy(enumerator: *mut CppVmAddressRegionEnumerator);
254}
255unsafe extern "C" {
256    pub fn cpp_vm_address_region_enumerator_next(
257        enumerator: *mut CppVmAddressRegionEnumerator,
258        out_depth: *mut uint,
259    ) -> *mut VmAddressRegionOrMapping;
260}
261unsafe extern "C" {
262    pub fn cpp_vm_address_region_enumerator_pause(enumerator: *mut CppVmAddressRegionEnumerator);
263}
264unsafe extern "C" {
265    pub fn cpp_vm_address_region_enumerator_resume(enumerator: *mut CppVmAddressRegionEnumerator);
266}
267unsafe extern "C" {
268    pub fn cpp_vm_mapping_destroy(mapping: *mut VmMapping) -> zx_status_t;
269}
270unsafe extern "C" {
271    pub fn cpp_vm_mapping_map_range(
272        mapping: *mut VmMapping,
273        offset: usize,
274        len: usize,
275        commit: bool,
276        ignore_existing: bool,
277    ) -> zx_status_t;
278}
279unsafe extern "C" {
280    pub fn cpp_vm_mapping_debug_unmap(
281        mapping: *mut VmMapping,
282        base: vaddr_t,
283        size: usize,
284    ) -> zx_status_t;
285}
286unsafe extern "C" {
287    pub fn cpp_vm_mapping_debug_protect(
288        mapping: *mut VmMapping,
289        base: vaddr_t,
290        size: usize,
291        new_arch_mmu_flags: arch_mmu_flags_t,
292    ) -> zx_status_t;
293}
294unsafe extern "C" {
295    pub fn cpp_vm_mapping_mark_mergeable(mapping: *mut VmMapping);
296}
297pub type cpp_vm_mapping_enumerate_protection_ranges_cb = ::core::option::Option<
298    unsafe extern "C" fn(
299        ctx: *mut ::core::ffi::c_void,
300        base: vaddr_t,
301        len: usize,
302        flags: arch_mmu_flags_t,
303    ) -> zx_status_t,
304>;
305unsafe extern "C" {
306    pub fn cpp_vm_mapping_enumerate_protection_ranges_locked(
307        mapping: *const VmMapping,
308        base: vaddr_t,
309        size: usize,
310        cb: cpp_vm_mapping_enumerate_protection_ranges_cb,
311        ctx: *mut ::core::ffi::c_void,
312    ) -> zx_status_t;
313}
314unsafe extern "C" {
315    pub fn cpp_vm_mapping_arch_mmu_flags_range_locked(
316        mapping: *const VmMapping,
317        offset: vaddr_t,
318    ) -> VmMapping_FlagsRange;
319}
320unsafe extern "C" {
321    pub fn cpp_vm_mapping_arch_mmu_flags_locked(
322        mapping: *const VmMapping,
323        offset: vaddr_t,
324    ) -> arch_mmu_flags_t;
325}
326unsafe extern "C" {
327    pub fn cpp_vm_mapping_page_fault_locked(
328        mapping: *mut VmMapping,
329        va: vaddr_t,
330        pf_flags: u32,
331        additional_pages: usize,
332        page_request: *mut MultiPageRequest,
333        out_mapped: *mut u32,
334    ) -> zx_status_t;
335}