Skip to main content

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