1#![expect(non_camel_case_types)]
8#![expect(non_upper_case_globals)]
9#![no_std]
10use attribution_bindings::vm_AttributionCounts;
11use page_bindings::vm_page_t;
12use page_source_bindings::MultiPageRequest;
13use vm_page_list_bindings::VmPageSpliceList;
14pub use zx_types::zx_vmo_lock_state_t;
15use zx_types::{zx_paddr_t as paddr_t, zx_status_t};
16
17#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)]
18#[repr(C, align(8))]
19pub struct __BindgenOpaqueArray8<T>(pub T);
20impl<T: Copy + Default, const N: usize> Default for __BindgenOpaqueArray8<[T; N]> {
21 fn default() -> Self {
22 Self([<T as Default>::default(); N])
23 }
24}
25pub type arch_mmu_flags_t = u8;
26#[repr(C)]
27#[repr(align(8))]
28#[derive(Debug, Copy, Clone)]
29pub struct VmObjectChildObserver {
30 pub _bindgen_opaque_blob: __BindgenOpaqueArray8<[u8; 8usize]>,
31}
32#[repr(i32)]
33#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
34pub enum Resizability {
35 Resizable = 0,
36 NonResizable = 1,
37}
38#[repr(i32)]
39#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
40pub enum SnapshotType {
41 Full = 0,
42 Modified = 1,
43 OnWrite = 2,
44}
45#[repr(u8)]
46#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
47pub enum SupplyOptions {
48 PagerSupply = 0,
49 TransferData = 1,
50 PhysicalPageProvider = 2,
51}
52pub const VmObjectReadWriteOptions_None: VmObjectReadWriteOptions = 0;
53pub const VmObjectReadWriteOptions_TrimLength: VmObjectReadWriteOptions = 1;
54pub type VmObjectReadWriteOptions = u8;
55unsafe extern "C" {
56 pub fn cpp_vm_object_free(vmo: *mut VmObject);
57}
58#[repr(C)]
59#[repr(align(8))]
60#[derive(Debug, Copy, Clone)]
61pub struct VmObject {
62 pub _bindgen_opaque_blob: __BindgenOpaqueArray8<[u8; 128usize]>,
63}
64#[repr(u32)]
65#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
66pub enum VmObject_EvictionHint {
67 DontNeed = 0,
68 AlwaysNeed = 1,
69}
70#[repr(C)]
71#[derive(Debug, Copy, Clone)]
72pub struct VmObject_ChildListLock {
73 pub _base: __BindgenOpaqueArray8<[u8; 24usize]>,
74}
75#[repr(C)]
76#[derive(Debug, Copy, Clone)]
77pub struct VmObject_AllVmosLock {
78 pub _base: __BindgenOpaqueArray8<[u8; 24usize]>,
79}
80pub const VmObject_MAX_SIZE: u64 = 18446744073709486080;
81pub type cpp_vm_object_lookup_fn = ::core::option::Option<
82 unsafe extern "C" fn(ctx: *mut ::core::ffi::c_void, offset: u64, paddr: u64) -> zx_status_t,
83>;
84unsafe extern "C" {
85 pub fn cpp_vm_object_get_ref_counted(vmo: *const VmObject) -> *mut ::core::ffi::c_void;
86}
87unsafe extern "C" {
88 pub fn cpp_vm_object_decommit_range(vmo: *mut VmObject, offset: u64, len: u64) -> zx_status_t;
89}
90unsafe extern "C" {
91 pub fn cpp_vm_object_commit_range(vmo: *mut VmObject, offset: u64, len: u64) -> zx_status_t;
92}
93unsafe extern "C" {
94 pub fn cpp_vm_object_hint_range(
95 vmo: *mut VmObject,
96 offset: u64,
97 len: u64,
98 hint: VmObject_EvictionHint,
99 ) -> zx_status_t;
100}
101unsafe extern "C" {
102 pub fn cpp_vm_object_size_locked(vmo: *const VmObject) -> u64;
103}
104unsafe extern "C" {
105 pub fn cpp_vm_object_is_resizable(vmo: *const VmObject) -> bool;
106}
107unsafe extern "C" {
108 pub fn cpp_vm_object_is_contiguous(vmo: *const VmObject) -> bool;
109}
110unsafe extern "C" {
111 pub fn cpp_vm_object_is_stream_compatible(vmo: *const VmObject) -> bool;
112}
113unsafe extern "C" {
114 pub fn cpp_vm_object_lock(vmo: *const VmObject) -> *mut ::core::ffi::c_void;
115}
116unsafe extern "C" {
117 pub fn cpp_vm_object_resize(vmo: *mut VmObject, size: u64) -> zx_status_t;
118}
119unsafe extern "C" {
120 pub fn cpp_vm_object_write(
121 vmo: *mut VmObject,
122 ptr: *const ::core::ffi::c_void,
123 offset: u64,
124 len: usize,
125 ) -> zx_status_t;
126}
127unsafe extern "C" {
128 pub fn cpp_vm_object_set_name(
129 vmo: *mut VmObject,
130 name: *const ::core::ffi::c_char,
131 len: usize,
132 ) -> zx_status_t;
133}
134unsafe extern "C" {
135 pub fn cpp_vm_object_get_name(
136 vmo: *const VmObject,
137 out_name: *mut ::core::ffi::c_char,
138 len: usize,
139 );
140}
141unsafe extern "C" {
142 pub fn cpp_vm_object_set_child_observer(
143 vmo: *mut VmObject,
144 child_observer: *mut VmObjectChildObserver,
145 );
146}
147unsafe extern "C" {
148 pub fn cpp_vm_object_commit_range_pinned(
149 vmo: *mut VmObject,
150 offset: u64,
151 len: u64,
152 write: bool,
153 ) -> zx_status_t;
154}
155unsafe extern "C" {
156 pub fn cpp_vm_object_unpin(vmo: *mut VmObject, offset: u64, len: u64);
157}
158unsafe extern "C" {
159 pub fn cpp_vm_object_get_mapping_cache_policy(vmo: *const VmObject) -> arch_mmu_flags_t;
160}
161unsafe extern "C" {
162 pub fn cpp_vm_object_set_mapping_cache_policy(
163 vmo: *mut VmObject,
164 cache_policy: arch_mmu_flags_t,
165 ) -> zx_status_t;
166}
167unsafe extern "C" {
168 pub fn cpp_vm_object_create_clone(
169 vmo: *mut VmObject,
170 resizable: Resizability,
171 snapshot_type: SnapshotType,
172 offset: u64,
173 size: u64,
174 copy_name: bool,
175 out_status: *mut zx_status_t,
176 ) -> *mut VmObject;
177}
178unsafe extern "C" {
179 pub fn cpp_vm_object_get_page_blocking(
180 vmo: *mut VmObject,
181 offset: u64,
182 pf_flags: u32,
183 out_page: *mut *mut vm_page_t,
184 out_pa: *mut paddr_t,
185 ) -> zx_status_t;
186}
187unsafe extern "C" {
188 pub fn cpp_vm_object_create_child_slice(
189 vmo: *mut VmObject,
190 offset: u64,
191 size: u64,
192 copy_name: bool,
193 out_status: *mut zx_status_t,
194 ) -> *mut VmObject;
195}
196unsafe extern "C" {
197 pub fn cpp_vm_object_create_child_reference(
198 vmo: *mut VmObject,
199 resizable: Resizability,
200 offset: u64,
201 size: u64,
202 copy_name: bool,
203 out_first_child: *mut bool,
204 out_status: *mut zx_status_t,
205 ) -> *mut VmObject;
206}
207unsafe extern "C" {
208 pub fn cpp_vm_object_set_user_id(vmo: *mut VmObject, user_id: u64);
209}
210unsafe extern "C" {
211 pub fn cpp_vm_object_user_id(vmo: *const VmObject) -> u64;
212}
213unsafe extern "C" {
214 pub fn cpp_vm_object_parent_user_id(vmo: *const VmObject) -> u64;
215}
216unsafe extern "C" {
217 pub fn cpp_vm_object_num_children(vmo: *const VmObject) -> u32;
218}
219unsafe extern "C" {
220 pub fn cpp_vm_object_lookup(
221 vmo: *mut VmObject,
222 offset: u64,
223 len: u64,
224 ctx: *mut ::core::ffi::c_void,
225 callback: cpp_vm_object_lookup_fn,
226 ) -> zx_status_t;
227}
228unsafe extern "C" {
229 pub fn cpp_vm_object_lookup_contiguous(
230 vmo: *mut VmObject,
231 offset: u64,
232 len: u64,
233 out_paddr: *mut paddr_t,
234 ) -> zx_status_t;
235}
236unsafe extern "C" {
237 pub fn cpp_vm_object_get_page(
238 vmo: *mut VmObject,
239 offset: u64,
240 pf_flags: u32,
241 page_request: *mut MultiPageRequest,
242 out_page: *mut *mut vm_page_t,
243 out_pa: *mut paddr_t,
244 ) -> zx_status_t;
245}
246unsafe extern "C" {
247 pub fn cpp_vm_object_get_attributed_memory(
248 vmo: *const VmObject,
249 out_counts: *mut vm_AttributionCounts,
250 );
251}
252unsafe extern "C" {
253 pub fn cpp_vm_object_get_attributed_memory_in_reference_owner(
254 vmo: *const VmObject,
255 out_counts: *mut vm_AttributionCounts,
256 );
257}
258unsafe extern "C" {
259 pub fn cpp_vm_object_read(
260 vmo: *mut VmObject,
261 ptr: *mut ::core::ffi::c_void,
262 offset: u64,
263 len: usize,
264 ) -> zx_status_t;
265}
266unsafe extern "C" {
267 pub fn cpp_vm_object_zero_range(vmo: *mut VmObject, offset: u64, len: u64) -> zx_status_t;
268}
269unsafe extern "C" {
270 pub fn cpp_vm_object_dirty_pages(vmo: *mut VmObject, offset: u64, len: u64) -> zx_status_t;
271}
272unsafe extern "C" {
273 pub fn cpp_vm_object_writeback_begin(
274 vmo: *mut VmObject,
275 offset: u64,
276 len: u64,
277 is_zero_range: bool,
278 ) -> zx_status_t;
279}
280unsafe extern "C" {
281 pub fn cpp_vm_object_writeback_end(vmo: *mut VmObject, offset: u64, len: u64) -> zx_status_t;
282}
283unsafe extern "C" {
284 pub fn cpp_vm_object_reclamation_event_count(vmo: *const VmObject) -> u64;
285}
286unsafe extern "C" {
287 pub fn cpp_vm_object_detach_source(vmo: *mut VmObject);
288}
289unsafe extern "C" {
290 pub fn cpp_vm_object_get_attributed_memory_in_range(
291 vmo: *const VmObject,
292 offset: u64,
293 len: u64,
294 out_counts: *mut vm_AttributionCounts,
295 );
296}
297unsafe extern "C" {
298 pub fn cpp_vm_object_try_lock_range(vmo: *mut VmObject, offset: u64, len: u64) -> zx_status_t;
299}
300unsafe extern "C" {
301 pub fn cpp_vm_object_lock_range(
302 vmo: *mut VmObject,
303 offset: u64,
304 len: u64,
305 lock_state_out: *mut zx_vmo_lock_state_t,
306 ) -> zx_status_t;
307}
308unsafe extern "C" {
309 pub fn cpp_vm_object_unlock_range(vmo: *mut VmObject, offset: u64, len: u64) -> zx_status_t;
310}
311unsafe extern "C" {
312 pub fn cpp_vm_object_read_user(
313 vmo: *mut VmObject,
314 buffer: *mut ::core::ffi::c_void,
315 offset: u64,
316 size: usize,
317 options: u8,
318 out_actual: *mut usize,
319 ) -> zx_status_t;
320}
321unsafe extern "C" {
322 pub fn cpp_vm_object_write_user(
323 vmo: *mut VmObject,
324 buffer: *const ::core::ffi::c_void,
325 offset: u64,
326 size: usize,
327 options: u8,
328 on_bytes_transferred: ::core::option::Option<
329 unsafe extern "C" fn(ctx: *mut ::core::ffi::c_void, offset: u64, len: usize),
330 >,
331 on_bytes_transferred_ctx: *mut ::core::ffi::c_void,
332 out_actual: *mut usize,
333 ) -> zx_status_t;
334}
335unsafe extern "C" {
336 pub fn cpp_vm_object_take_pages(
337 vmo: *mut VmObject,
338 offset: u64,
339 len: u64,
340 pages: *mut VmPageSpliceList,
341 ) -> zx_status_t;
342}
343unsafe extern "C" {
344 pub fn cpp_vm_object_supply_pages(
345 vmo: *mut VmObject,
346 offset: u64,
347 len: u64,
348 pages: *mut VmPageSpliceList,
349 options: SupplyOptions,
350 ) -> zx_status_t;
351}
352unsafe extern "C" {
353 pub fn cpp_vm_object_is_paged(vmo: *const VmObject) -> bool;
354}