fdf_sys/
bindings.rs

1// Copyright 2024 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// Generated by sdk/lib/driver/runtime/rust/fdf_sys/bindgen.sh using bindgen 0.72.0
6
7#![allow(dead_code)]
8#![allow(non_camel_case_types)]
9#![allow(non_snake_case)]
10
11use libasync_sys::*;
12use zx_types::*;
13
14pub const DRIVER_REGISTRATION_VERSION_1: u32 = 1;
15pub const DRIVER_REGISTRATION_VERSION_MAX: u32 = 1;
16pub type fdf_handle_t = zx_handle_t;
17pub type fdf_txid_t = zx_txid_t;
18#[repr(C)]
19#[derive(Debug, Copy, Clone)]
20pub struct fdf_arena {
21    _unused: [u8; 0],
22}
23#[repr(C)]
24#[derive(Debug, Copy, Clone)]
25pub struct fdf_channel_call_args {
26    pub wr_arena: *mut fdf_arena,
27    pub wr_data: *mut ::core::ffi::c_void,
28    pub wr_num_bytes: u32,
29    pub wr_handles: *mut zx_handle_t,
30    pub wr_num_handles: u32,
31    pub rd_arena: *mut *mut fdf_arena,
32    pub rd_data: *mut *mut ::core::ffi::c_void,
33    pub rd_num_bytes: *mut u32,
34    pub rd_handles: *mut *mut zx_handle_t,
35    pub rd_num_handles: *mut u32,
36}
37#[allow(clippy::unnecessary_operation, clippy::identity_op)]
38const _: () = {
39    ["Size of fdf_channel_call_args"][::core::mem::size_of::<fdf_channel_call_args>() - 80usize];
40    ["Alignment of fdf_channel_call_args"]
41        [::core::mem::align_of::<fdf_channel_call_args>() - 8usize];
42    ["Offset of field: fdf_channel_call_args::wr_arena"]
43        [::core::mem::offset_of!(fdf_channel_call_args, wr_arena) - 0usize];
44    ["Offset of field: fdf_channel_call_args::wr_data"]
45        [::core::mem::offset_of!(fdf_channel_call_args, wr_data) - 8usize];
46    ["Offset of field: fdf_channel_call_args::wr_num_bytes"]
47        [::core::mem::offset_of!(fdf_channel_call_args, wr_num_bytes) - 16usize];
48    ["Offset of field: fdf_channel_call_args::wr_handles"]
49        [::core::mem::offset_of!(fdf_channel_call_args, wr_handles) - 24usize];
50    ["Offset of field: fdf_channel_call_args::wr_num_handles"]
51        [::core::mem::offset_of!(fdf_channel_call_args, wr_num_handles) - 32usize];
52    ["Offset of field: fdf_channel_call_args::rd_arena"]
53        [::core::mem::offset_of!(fdf_channel_call_args, rd_arena) - 40usize];
54    ["Offset of field: fdf_channel_call_args::rd_data"]
55        [::core::mem::offset_of!(fdf_channel_call_args, rd_data) - 48usize];
56    ["Offset of field: fdf_channel_call_args::rd_num_bytes"]
57        [::core::mem::offset_of!(fdf_channel_call_args, rd_num_bytes) - 56usize];
58    ["Offset of field: fdf_channel_call_args::rd_handles"]
59        [::core::mem::offset_of!(fdf_channel_call_args, rd_handles) - 64usize];
60    ["Offset of field: fdf_channel_call_args::rd_num_handles"]
61        [::core::mem::offset_of!(fdf_channel_call_args, rd_num_handles) - 72usize];
62};
63impl Default for fdf_channel_call_args {
64    fn default() -> Self {
65        let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
66        unsafe {
67            ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
68            s.assume_init()
69        }
70    }
71}
72pub type fdf_channel_call_args_t = fdf_channel_call_args;
73pub const FDF_DISPATCHER_OPTION_SYNCHRONIZED: u32 = 0;
74pub const FDF_DISPATCHER_OPTION_UNSYNCHRONIZED: u32 = 1;
75pub const FDF_DISPATCHER_OPTION_ALLOW_SYNC_CALLS: u32 = 2;
76pub const FDF_DISPATCHER_OPTION_SYNCHRONIZATION_MASK: u32 = 1;
77pub const FDF_CHANNEL_WAIT_OPTION_FORCE_ASYNC_CANCEL: u32 = 1;
78pub type fdf_arena_t = fdf_arena;
79pub type fdf_arena_tag_t = u32;
80unsafe extern "C" {
81    pub fn fdf_arena_create(
82        options: u32,
83        tag: fdf_arena_tag_t,
84        out_arena: *mut *mut fdf_arena_t,
85    ) -> zx_status_t;
86}
87unsafe extern "C" {
88    pub fn fdf_arena_allocate(arena: *mut fdf_arena_t, bytes: usize) -> *mut ::core::ffi::c_void;
89}
90unsafe extern "C" {
91    pub fn fdf_arena_free(arena: *mut fdf_arena_t, ptr: *mut ::core::ffi::c_void);
92}
93unsafe extern "C" {
94    pub fn fdf_arena_contains(
95        arena: *mut fdf_arena_t,
96        ptr: *const ::core::ffi::c_void,
97        num_bytes: usize,
98    ) -> bool;
99}
100unsafe extern "C" {
101    pub fn fdf_arena_add_ref(arena: *mut fdf_arena_t);
102}
103unsafe extern "C" {
104    pub fn fdf_arena_drop_ref(arena: *mut fdf_arena_t);
105}
106#[repr(C)]
107#[derive(Debug, Copy, Clone)]
108pub struct fdf_dispatcher {
109    _unused: [u8; 0],
110}
111pub type fdf_dispatcher_t = fdf_dispatcher;
112pub type fdf_dispatcher_shutdown_observer_t = fdf_dispatcher_shutdown_observer;
113pub type fdf_dispatcher_shutdown_handler_t = ::core::option::Option<
114    unsafe extern "C" fn(
115        dispatcher: *mut fdf_dispatcher_t,
116        observer: *mut fdf_dispatcher_shutdown_observer_t,
117    ),
118>;
119#[repr(C)]
120#[derive(Debug, Default, Copy, Clone)]
121pub struct fdf_dispatcher_shutdown_observer {
122    pub handler: fdf_dispatcher_shutdown_handler_t,
123}
124#[allow(clippy::unnecessary_operation, clippy::identity_op)]
125const _: () = {
126    ["Size of fdf_dispatcher_shutdown_observer"]
127        [::core::mem::size_of::<fdf_dispatcher_shutdown_observer>() - 8usize];
128    ["Alignment of fdf_dispatcher_shutdown_observer"]
129        [::core::mem::align_of::<fdf_dispatcher_shutdown_observer>() - 8usize];
130    ["Offset of field: fdf_dispatcher_shutdown_observer::handler"]
131        [::core::mem::offset_of!(fdf_dispatcher_shutdown_observer, handler) - 0usize];
132};
133unsafe extern "C" {
134    pub fn fdf_dispatcher_create(
135        options: u32,
136        name: *const ::core::ffi::c_char,
137        name_len: usize,
138        scheduler_role: *const ::core::ffi::c_char,
139        scheduler_role_len: usize,
140        observer: *mut fdf_dispatcher_shutdown_observer_t,
141        out_dispatcher: *mut *mut fdf_dispatcher_t,
142    ) -> zx_status_t;
143}
144unsafe extern "C" {
145    pub fn fdf_dispatcher_get_async_dispatcher(
146        dispatcher: *mut fdf_dispatcher_t,
147    ) -> *mut async_dispatcher_t;
148}
149unsafe extern "C" {
150    pub fn fdf_dispatcher_downcast_async_dispatcher(
151        async_dispatcher: *mut async_dispatcher_t,
152    ) -> *mut fdf_dispatcher_t;
153}
154unsafe extern "C" {
155    pub fn fdf_dispatcher_get_current_dispatcher() -> *mut fdf_dispatcher_t;
156}
157unsafe extern "C" {
158    pub fn fdf_dispatcher_get_options(dispatcher: *const fdf_dispatcher_t) -> u32;
159}
160unsafe extern "C" {
161    pub fn fdf_dispatcher_shutdown_async(dispatcher: *mut fdf_dispatcher_t);
162}
163unsafe extern "C" {
164    pub fn fdf_dispatcher_destroy(dispatcher: *mut fdf_dispatcher_t);
165}
166unsafe extern "C" {
167    pub fn fdf_dispatcher_seal(dispatcher: *mut fdf_dispatcher_t, option: u32) -> zx_status_t;
168}
169unsafe extern "C" {
170    pub fn fdf_handle_close(handle: fdf_handle_t);
171}
172unsafe extern "C" {
173    pub fn fdf_channel_create(
174        options: u32,
175        out0: *mut fdf_handle_t,
176        out1: *mut fdf_handle_t,
177    ) -> zx_status_t;
178}
179unsafe extern "C" {
180    pub fn fdf_channel_write(
181        channel: fdf_handle_t,
182        options: u32,
183        arena: *mut fdf_arena_t,
184        data: *mut ::core::ffi::c_void,
185        num_bytes: u32,
186        handles: *mut zx_handle_t,
187        num_handles: u32,
188    ) -> zx_status_t;
189}
190unsafe extern "C" {
191    pub fn fdf_channel_read(
192        channel: fdf_handle_t,
193        options: u32,
194        out_arena: *mut *mut fdf_arena_t,
195        out_data: *mut *mut ::core::ffi::c_void,
196        out_num_bytes: *mut u32,
197        out_handles: *mut *mut zx_handle_t,
198        out_num_handles: *mut u32,
199    ) -> zx_status_t;
200}
201unsafe extern "C" {
202    pub fn fdf_channel_wait_async(
203        dispatcher: *mut fdf_dispatcher,
204        channel_read: *mut fdf_channel_read,
205        options: u32,
206    ) -> zx_status_t;
207}
208unsafe extern "C" {
209    pub fn fdf_channel_cancel_wait(handle: fdf_handle_t) -> zx_status_t;
210}
211unsafe extern "C" {
212    pub fn fdf_channel_call(
213        handle: fdf_handle_t,
214        options: u32,
215        deadline: zx_time_t,
216        args: *const fdf_channel_call_args_t,
217    ) -> zx_status_t;
218}
219pub type fdf_channel_read_t = fdf_channel_read;
220pub type fdf_channel_read_handler_t = ::core::option::Option<
221    unsafe extern "C" fn(
222        dispatcher: *mut fdf_dispatcher_t,
223        read: *mut fdf_channel_read_t,
224        status: zx_status_t,
225    ),
226>;
227#[repr(C)]
228pub struct fdf_channel_read {
229    pub state: async_state_t,
230    pub handler: fdf_channel_read_handler_t,
231    pub channel: fdf_handle_t,
232    pub options: u32,
233}
234#[allow(clippy::unnecessary_operation, clippy::identity_op)]
235const _: () = {
236    ["Size of fdf_channel_read"][::core::mem::size_of::<fdf_channel_read>() - 32usize];
237    ["Alignment of fdf_channel_read"][::core::mem::align_of::<fdf_channel_read>() - 8usize];
238    ["Offset of field: fdf_channel_read::state"]
239        [::core::mem::offset_of!(fdf_channel_read, state) - 0usize];
240    ["Offset of field: fdf_channel_read::handler"]
241        [::core::mem::offset_of!(fdf_channel_read, handler) - 16usize];
242    ["Offset of field: fdf_channel_read::channel"]
243        [::core::mem::offset_of!(fdf_channel_read, channel) - 24usize];
244    ["Offset of field: fdf_channel_read::options"]
245        [::core::mem::offset_of!(fdf_channel_read, options) - 28usize];
246};
247impl Default for fdf_channel_read {
248    fn default() -> Self {
249        let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
250        unsafe {
251            ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
252            s.assume_init()
253        }
254    }
255}
256impl ::core::fmt::Debug for fdf_channel_read {
257    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
258        write!(f, "fdf_channel_read {{ handler: {:?} }}", self.handler)
259    }
260}
261pub type fdf_env_driver_shutdown_observer_t = fdf_env_driver_shutdown_observer;
262pub type fdf_env_driver_shutdown_handler_t = ::core::option::Option<
263    unsafe extern "C" fn(
264        driver: *const ::core::ffi::c_void,
265        observer: *mut fdf_env_driver_shutdown_observer_t,
266    ),
267>;
268#[repr(C)]
269#[derive(Debug, Default, Copy, Clone)]
270pub struct fdf_env_driver_shutdown_observer {
271    pub handler: fdf_env_driver_shutdown_handler_t,
272}
273#[allow(clippy::unnecessary_operation, clippy::identity_op)]
274const _: () = {
275    ["Size of fdf_env_driver_shutdown_observer"]
276        [::core::mem::size_of::<fdf_env_driver_shutdown_observer>() - 8usize];
277    ["Alignment of fdf_env_driver_shutdown_observer"]
278        [::core::mem::align_of::<fdf_env_driver_shutdown_observer>() - 8usize];
279    ["Offset of field: fdf_env_driver_shutdown_observer::handler"]
280        [::core::mem::offset_of!(fdf_env_driver_shutdown_observer, handler) - 0usize];
281};
282pub type fdf_env_stall_scanner_t = fdf_env_stall_scanner;
283pub type fdf_env_stall_scan_begin = ::core::option::Option<
284    unsafe extern "C" fn(scanner: *mut fdf_env_stall_scanner_t, duration: zx_duration_mono_t),
285>;
286#[repr(C)]
287#[derive(Debug, Default, Copy, Clone)]
288pub struct fdf_env_stall_scanner {
289    pub handler: fdf_env_stall_scan_begin,
290}
291#[allow(clippy::unnecessary_operation, clippy::identity_op)]
292const _: () = {
293    ["Size of fdf_env_stall_scanner"][::core::mem::size_of::<fdf_env_stall_scanner>() - 8usize];
294    ["Alignment of fdf_env_stall_scanner"]
295        [::core::mem::align_of::<fdf_env_stall_scanner>() - 8usize];
296    ["Offset of field: fdf_env_stall_scanner::handler"]
297        [::core::mem::offset_of!(fdf_env_stall_scanner, handler) - 0usize];
298};
299unsafe extern "C" {
300    pub fn fdf_env_start(options: u32) -> zx_status_t;
301}
302unsafe extern "C" {
303    pub fn fdf_env_reset();
304}
305unsafe extern "C" {
306    pub fn fdf_env_dispatcher_create_with_owner(
307        driver: *const ::core::ffi::c_void,
308        options: u32,
309        name: *const ::core::ffi::c_char,
310        name_len: usize,
311        scheduler_role: *const ::core::ffi::c_char,
312        scheduler_role_len: usize,
313        observer: *mut fdf_dispatcher_shutdown_observer_t,
314        out_dispatcher: *mut *mut fdf_dispatcher_t,
315    ) -> zx_status_t;
316}
317unsafe extern "C" {
318    pub fn fdf_env_dispatcher_dump(dispatcher: *mut fdf_dispatcher_t);
319}
320unsafe extern "C" {
321    pub fn fdf_env_dispatcher_get_dump_deprecated(
322        dispatcher: *mut fdf_dispatcher_t,
323        out_dump: *mut *mut ::core::ffi::c_char,
324    );
325}
326unsafe extern "C" {
327    pub fn fdf_env_shutdown_dispatchers_async(
328        driver: *const ::core::ffi::c_void,
329        observer: *mut fdf_env_driver_shutdown_observer_t,
330    ) -> zx_status_t;
331}
332unsafe extern "C" {
333    pub fn fdf_env_destroy_all_dispatchers();
334}
335unsafe extern "C" {
336    pub fn fdf_env_register_driver_entry(driver: *const ::core::ffi::c_void);
337}
338unsafe extern "C" {
339    pub fn fdf_env_register_driver_exit();
340}
341unsafe extern "C" {
342    pub fn fdf_env_get_current_driver() -> *const ::core::ffi::c_void;
343}
344unsafe extern "C" {
345    pub fn fdf_env_dispatcher_has_queued_tasks(dispatcher: *mut fdf_dispatcher_t) -> bool;
346}
347unsafe extern "C" {
348    pub fn fdf_env_get_thread_limit(
349        scheduler_role: *const ::core::ffi::c_char,
350        scheduler_role_len: usize,
351    ) -> u32;
352}
353unsafe extern "C" {
354    pub fn fdf_env_set_thread_limit(
355        scheduler_role: *const ::core::ffi::c_char,
356        scheduler_role_len: usize,
357        max_threads: u32,
358    ) -> zx_status_t;
359}
360unsafe extern "C" {
361    pub fn fdf_env_add_allowed_scheduler_role_for_driver(
362        driver: *const ::core::ffi::c_void,
363        role: *const ::core::ffi::c_char,
364        role_length: usize,
365    );
366}
367unsafe extern "C" {
368    pub fn fdf_env_get_driver_on_tid(
369        tid: zx_koid_t,
370        out_driver: *mut *const ::core::ffi::c_void,
371    ) -> zx_status_t;
372}
373unsafe extern "C" {
374    pub fn fdf_env_scan_threads_for_stalls();
375}
376unsafe extern "C" {
377    pub fn fdf_env_scan_threads_for_stalls2() -> zx_duration_mono_t;
378}
379unsafe extern "C" {
380    pub fn fdf_env_register_stall_scanner(scanner: *mut fdf_env_stall_scanner_t);
381}
382unsafe extern "C" {
383    pub fn fdf_testing_create_unmanaged_dispatcher(
384        driver: *const ::core::ffi::c_void,
385        options: u32,
386        name: *const ::core::ffi::c_char,
387        name_len: usize,
388        observer: *mut fdf_dispatcher_shutdown_observer_t,
389        out_dispatcher: *mut *mut fdf_dispatcher_t,
390    ) -> zx_status_t;
391}
392unsafe extern "C" {
393    pub fn fdf_testing_set_default_dispatcher(dispatcher: *mut fdf_dispatcher_t) -> zx_status_t;
394}
395unsafe extern "C" {
396    pub fn fdf_testing_run(deadline: zx_time_t, once: bool) -> zx_status_t;
397}
398unsafe extern "C" {
399    pub fn fdf_testing_run_until_idle() -> zx_status_t;
400}
401unsafe extern "C" {
402    pub fn fdf_testing_quit();
403}
404unsafe extern "C" {
405    pub fn fdf_testing_reset_quit() -> zx_status_t;
406}
407pub type fdf_token_t = fdf_token;
408pub type fdf_token_transfer_handler_t = ::core::option::Option<
409    unsafe extern "C" fn(
410        dispatcher: *mut fdf_dispatcher_t,
411        token: *mut fdf_token_t,
412        status: zx_status_t,
413        handle: fdf_handle_t,
414    ),
415>;
416#[repr(C)]
417#[derive(Debug, Default, Copy, Clone)]
418pub struct fdf_token {
419    pub handler: fdf_token_transfer_handler_t,
420}
421#[allow(clippy::unnecessary_operation, clippy::identity_op)]
422const _: () = {
423    ["Size of fdf_token"][::core::mem::size_of::<fdf_token>() - 8usize];
424    ["Alignment of fdf_token"][::core::mem::align_of::<fdf_token>() - 8usize];
425    ["Offset of field: fdf_token::handler"][::core::mem::offset_of!(fdf_token, handler) - 0usize];
426};
427unsafe extern "C" {
428    pub fn fdf_token_register(
429        token: zx_handle_t,
430        dispatcher: *mut fdf_dispatcher_t,
431        handler: *mut fdf_token_t,
432    ) -> zx_status_t;
433}
434unsafe extern "C" {
435    pub fn fdf_token_receive(token: zx_handle_t, handle: *mut fdf_handle_t) -> zx_status_t;
436}
437unsafe extern "C" {
438    pub fn fdf_token_transfer(token: zx_handle_t, handle: fdf_handle_t) -> zx_status_t;
439}
440#[repr(C)]
441#[derive(Debug, Default, Copy, Clone)]
442pub struct DriverRegistration {
443    pub version: u64,
444    pub v1: DriverRegistration_driver_registration_v1,
445}
446#[repr(C)]
447#[derive(Debug, Default, Copy, Clone)]
448pub struct DriverRegistration_driver_registration_v1 {
449    pub initialize: ::core::option::Option<
450        unsafe extern "C" fn(server_handle: fdf_handle_t) -> *mut ::core::ffi::c_void,
451    >,
452    pub destroy: ::core::option::Option<unsafe extern "C" fn(token: *mut ::core::ffi::c_void)>,
453}
454#[allow(clippy::unnecessary_operation, clippy::identity_op)]
455const _: () = {
456    ["Size of DriverRegistration_driver_registration_v1"]
457        [::core::mem::size_of::<DriverRegistration_driver_registration_v1>() - 16usize];
458    ["Alignment of DriverRegistration_driver_registration_v1"]
459        [::core::mem::align_of::<DriverRegistration_driver_registration_v1>() - 8usize];
460    ["Offset of field: DriverRegistration_driver_registration_v1::initialize"]
461        [::core::mem::offset_of!(DriverRegistration_driver_registration_v1, initialize) - 0usize];
462    ["Offset of field: DriverRegistration_driver_registration_v1::destroy"]
463        [::core::mem::offset_of!(DriverRegistration_driver_registration_v1, destroy) - 8usize];
464};
465#[allow(clippy::unnecessary_operation, clippy::identity_op)]
466const _: () = {
467    ["Size of DriverRegistration"][::core::mem::size_of::<DriverRegistration>() - 24usize];
468    ["Alignment of DriverRegistration"][::core::mem::align_of::<DriverRegistration>() - 8usize];
469    ["Offset of field: DriverRegistration::version"]
470        [::core::mem::offset_of!(DriverRegistration, version) - 0usize];
471    ["Offset of field: DriverRegistration::v1"]
472        [::core::mem::offset_of!(DriverRegistration, v1) - 8usize];
473};