1#![expect(non_camel_case_types)]
8#![expect(non_upper_case_globals)]
9#![no_std]
10pub use compressor_bindings::VmCompressor;
11use discardable_vmo_tracker_bindings::DiscardableVmoTracker;
12use page_bindings::vm_page_t;
13use page_source_bindings::MultiPageRequest;
14pub use pmm_bindings::{PmmOptDelayReuse, VmPageDoublyLinkedList};
15use zx_types::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}
25#[repr(C)]
26#[derive(Debug, Copy, Clone)]
27pub struct VmCompressor_PageAndMetadata {
28 pub page: *mut vm_page_t,
29 pub metadata: u32,
30 pub __bindgen_padding_0: [u8; 4usize],
31}
32#[repr(C)]
33#[derive(Debug, Copy, Clone)]
34pub struct VmCompressor_FailTag {
35 pub src_page: VmCompressor_PageAndMetadata,
36}
37#[repr(C)]
38#[derive(Debug, Copy, Clone)]
39pub struct VmCompressor_ZeroTag {
40 pub __bindgen_padding_0: u8,
41 pub _address: u8,
42}
43pub const VmCompressor_State_Ready: VmCompressor_State = 0;
44pub const VmCompressor_State_Started: VmCompressor_State = 1;
45pub const VmCompressor_State_Compressed: VmCompressor_State = 2;
46pub const VmCompressor_State_Finalized: VmCompressor_State = 3;
47pub type VmCompressor_State = ::core::ffi::c_int;
48pub const VmCowPagesOptions_kNone: VmCowPagesOptions = 0;
49pub const VmCowPagesOptions_kUserPagerBackedRoot: VmCowPagesOptions = 1;
50pub const VmCowPagesOptions_kPageSourceRoot: VmCowPagesOptions = 2;
51pub const VmCowPagesOptions_kCannotDecommitZeroPages: VmCowPagesOptions = 4;
52pub const VmCowPagesOptions_kHidden: VmCowPagesOptions = 8;
53pub const VmCowPagesOptions_kInternalOnlyMask: VmCowPagesOptions = 8;
54pub type VmCowPagesOptions = u32;
55#[repr(C)]
56#[derive(Debug, Copy, Clone)]
57pub struct VmCowRange {
58 pub offset: u64,
59 pub len: u64,
60}
61#[repr(C)]
62#[derive(Debug, Copy, Clone)]
63pub struct VmCowReclaimSuccess {
64 pub type_: VmCowReclaimSuccess_Type,
65 pub __bindgen_padding_0: [u8; 7usize],
66 pub num_pages: u64,
67 pub num_loaned_pages: u64,
68}
69#[repr(u8)]
70#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
71pub enum VmCowReclaimSuccess_Type {
72 Evict = 0,
73 Discard = 1,
74 Compress = 2,
75}
76#[repr(u8)]
77#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
78pub enum VmCowReclaimFailure {
79 EvictAccessed = 0,
80 CompressAccessed = 1,
81 CompressFailed = 2,
82 IncorrectPage = 3,
83 Other = 4,
84}
85#[repr(u8)]
86#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
87pub enum PageSourceType {
88 Anonymous = 0,
89 Contiguous = 1,
90 UserPager = 2,
91}
92unsafe extern "C" {
93 pub fn cpp_vm_cow_pages_free(arg1: *mut VmCowPages);
94}
95#[repr(C)]
96#[repr(align(8))]
97#[derive(Debug, Copy, Clone)]
98pub struct VmCowPages {
99 pub _bindgen_opaque_blob: __BindgenOpaqueArray8<[u8; 192usize]>,
100}
101#[repr(u8)]
102#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
103pub enum VmCowPages_DirtyState {
104 Untracked = 0,
105 Clean = 1,
106 Dirty = 2,
107 AwaitingClean = 3,
108 NumStates = 4,
109}
110#[repr(u8)]
111#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
112pub enum VmCowPages_CanOverwriteSlot {
113 Empty = 0,
114 EmptyOrParent = 1,
115 ZeroMarkerOrInterval = 2,
116 PageOrRef = 3,
117}
118#[repr(u8)]
119#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
120pub enum VmCowPages_EvictionAction {
121 FollowHint = 0,
122 IgnoreHint = 1,
123}
124#[repr(C)]
125#[derive(Debug, Copy, Clone)]
126pub struct VmCowPages_RootListTag {
127 pub __bindgen_padding_0: u8,
128 pub _address: u8,
129}
130#[repr(C)]
131#[derive(Debug, Copy, Clone)]
132pub struct VmCowPages_CurListTag {
133 pub __bindgen_padding_0: u8,
134 pub _address: u8,
135}
136#[repr(C)]
137#[derive(Debug)]
138pub struct VmCowPages_TreeWalkCursor {
139 _unused: [u8; 0],
140}
141pub const VmCowPages_LifeCycle_Init: VmCowPages_LifeCycle = 0;
142pub const VmCowPages_LifeCycle_Alive: VmCowPages_LifeCycle = 1;
143pub const VmCowPages_LifeCycle_Dying: VmCowPages_LifeCycle = 2;
144pub const VmCowPages_LifeCycle_Dead: VmCowPages_LifeCycle = 3;
145pub type VmCowPages_LifeCycle = u8;
146#[repr(C)]
147#[repr(align(8))]
148#[derive(Debug, Copy, Clone)]
149pub struct VmCowPages_DeferredOps {
150 pub _bindgen_opaque_blob: __BindgenOpaqueArray8<[u8; 112usize]>,
151}
152#[repr(C)]
153#[repr(align(8))]
154#[derive(Debug, Copy, Clone)]
155pub struct PriorityChanger {
156 pub _bindgen_opaque_blob: __BindgenOpaqueArray8<[u8; 152usize]>,
157}
158pub const PriorityChanger_PriorityChangerState_CONSTRUCTED: PriorityChanger_PriorityChangerState =
159 0;
160pub const PriorityChanger_PriorityChangerState_READY_TO_CHANGE:
161 PriorityChanger_PriorityChangerState = 1;
162pub const PriorityChanger_PriorityChangerState_DONE: PriorityChanger_PriorityChangerState = 2;
163pub type PriorityChanger_PriorityChangerState = u8;
164pub type cpp_vm_cow_pages_lookup_readable_fn = ::core::option::Option<
165 unsafe extern "C" fn(ctx: *mut ::core::ffi::c_void, offset: u64, paddr: u64) -> zx_status_t,
166>;
167unsafe extern "C" {
168 pub fn cpp_vm_cow_pages_replace_page_with_loaned(
169 cow: *mut VmCowPages,
170 before_page: *mut vm_page_t,
171 offset: u64,
172 ) -> zx_status_t;
173}
174unsafe extern "C" {
175 pub fn cpp_vm_cow_pages_get_ref_counted(cow: *const VmCowPages) -> *mut ::core::ffi::c_void;
176}
177unsafe extern "C" {
178 pub fn cpp_vm_cow_pages_initialize_page_cache(level: u32);
179}
180unsafe extern "C" {
181 pub fn cpp_vm_cow_pages_should_delay_reuse_on_free(cow: *const VmCowPages) -> PmmOptDelayReuse;
182}
183unsafe extern "C" {
184 pub fn cpp_vm_cow_pages_debug_get_parent(cow: *mut VmCowPages) -> *mut VmCowPages;
185}
186unsafe extern "C" {
187 pub fn cpp_vm_cow_pages_dedup_zero_page(
188 cow: *mut VmCowPages,
189 page: *mut vm_page_t,
190 offset: u64,
191 ) -> bool;
192}
193unsafe extern "C" {
194 pub fn cpp_vm_cow_pages_evict_loaned_page(
195 cow: *mut VmCowPages,
196 page: *mut vm_page_t,
197 offset: u64,
198 ) -> zx_status_t;
199}
200unsafe extern "C" {
201 pub fn cpp_vm_cow_pages_debug_get_page(cow: *const VmCowPages, offset: u64) -> *mut vm_page_t;
202}
203unsafe extern "C" {
204 pub fn cpp_vm_cow_pages_debug_is_empty(cow: *const VmCowPages, offset: u64) -> bool;
205}
206unsafe extern "C" {
207 pub fn cpp_vm_cow_pages_debug_is_high_memory_priority(cow: *const VmCowPages) -> bool;
208}
209unsafe extern "C" {
210 pub fn cpp_vm_cow_pages_debug_get_discardable_tracker(
211 cow: *const VmCowPages,
212 ) -> *mut DiscardableVmoTracker;
213}
214unsafe extern "C" {
215 pub fn cpp_vm_cow_pages_reclaim_page(
216 cow: *mut VmCowPages,
217 page: *mut vm_page_t,
218 offset: u64,
219 eviction_action: VmCowPages_EvictionAction,
220 compressor: *mut VmCompressor,
221 out_success: *mut VmCowReclaimSuccess,
222 out_failure: *mut VmCowReclaimFailure,
223 ) -> bool;
224}
225unsafe extern "C" {
226 pub fn cpp_vm_cow_pages_debug_lookup_readable(
227 cow: *mut VmCowPages,
228 range: VmCowRange,
229 ctx: *mut ::core::ffi::c_void,
230 callback: cpp_vm_cow_pages_lookup_readable_fn,
231 ) -> zx_status_t;
232}
233unsafe extern "C" {
234 pub fn cpp_vm_cow_pages_get_lock(cow: *const VmCowPages) -> *mut ::core::ffi::c_void;
235}
236unsafe extern "C" {
237 pub fn cpp_vm_cow_pages_deferred_ops_construct(ops: *mut u8, cow: *mut VmCowPages);
238}
239unsafe extern "C" {
240 pub fn cpp_vm_cow_pages_deferred_ops_destroy(ops: *mut VmCowPages_DeferredOps);
241}
242unsafe extern "C" {
243 pub fn cpp_vm_cow_pages_add_new_pages_locked(
244 cow: *mut VmCowPages,
245 start_offset: u64,
246 pages: *mut VmPageDoublyLinkedList,
247 overwrite: VmCowPages_CanOverwriteSlot,
248 zero: bool,
249 deferred: *mut VmCowPages_DeferredOps,
250 ) -> zx_status_t;
251}
252unsafe extern "C" {
253 pub fn cpp_vm_cow_pages_zero_pages_locked(
254 cow: *mut VmCowPages,
255 range: VmCowRange,
256 dirty_track: bool,
257 deferred: *mut VmCowPages_DeferredOps,
258 page_request: *mut MultiPageRequest,
259 out_zeroed_bytes: *mut u64,
260 ) -> zx_status_t;
261}
262unsafe extern "C" {
263 pub fn cpp_vm_cow_pages_debug_get_populated_slots_count(cow: *const VmCowPages) -> u32;
264}
265unsafe extern "C" {
266 pub fn cpp_vm_cow_pages_debug_is_parent_content(cow: *const VmCowPages, offset: u64) -> bool;
267}
268unsafe extern "C" {
269 pub fn cpp_vm_cow_pages_can_borrow(cow: *const VmCowPages) -> bool;
270}
271unsafe extern "C" {
272 pub fn cpp_vm_cow_pages_can_evict(cow: *const VmCowPages) -> bool;
273}
274unsafe extern "C" {
275 pub fn cpp_vm_cow_pages_is_discardable(cow: *const VmCowPages) -> bool;
276}
277unsafe extern "C" {
278 pub fn cpp_vm_cow_pages_upgrade_from_raw(cow: *mut VmCowPages) -> *mut VmCowPages;
279}
280unsafe extern "C" {
281 pub fn cpp_priority_changer_construct(out: *mut u8, cow: *mut VmCowPages, delta: i64);
282}
283unsafe extern "C" {
284 pub fn cpp_priority_changer_destroy(pc: *mut PriorityChanger);
285}
286unsafe extern "C" {
287 pub fn cpp_priority_changer_prepare_may_not_already_be_high_priority(pc: *mut PriorityChanger);
288}
289unsafe extern "C" {
290 pub fn cpp_priority_changer_prepare_is_already_high_priority_locked(pc: *mut PriorityChanger);
291}
292unsafe extern "C" {
293 pub fn cpp_priority_changer_change_high_priority_count_locked(pc: *mut PriorityChanger);
294}
295unsafe extern "C" {
296 pub fn cpp_priority_changer_lock(pc: *const PriorityChanger) -> *mut ::core::ffi::c_void;
297}