Skip to main content

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