Skip to main content

Crate fdf_sys

Crate fdf_sys 

Source

Structs§

DriverRegistration
The |DriverRegistration| is the ABI for drivers to expose themselves to the Driver Framework. The driver is loaded in as a shared library (also referred to as a DSO), and the global symbol __fuchsia_driver_registration__ is used by the Driver Framework to locate this DriverRegistration in the driver library. The framework will use this to initiate a FIDL based connection over the driver transport into the driver.
DriverRegistration_driver_registration_v1
fdf_arena
fdf_channel_call_args
fdf_channel_read
A bi-directional in-process message transport capable of sending arena-managed raw data bytes as well as handles from one side to the other.
fdf_dispatcher
fdf_dispatcher_shutdown_observer
Holds context for the observer which will be called when the dispatcher’s asynchronous shutdown has completed.
fdf_env_driver_shutdown_observer
Holds context for the observer which will be called when the asynchronous shutdown for all dispatchers owned by a driver has completed.
fdf_env_resume_requester
Holds context for the resume request which will be called when the runtime needs to be resumed.
fdf_env_stall_scanner
Holds context for the stall scanner which will be called when stall scanning should occur.
fdf_env_suspend_completer
Holds context for the suspend completion which will be called when the driver has completed suspending.
fdf_token
Holds context for a registered token which is waiting for an fdf handle to be transferred.

Constants§

DRIVER_REGISTRATION_VERSION_1
DRIVER_REGISTRATION_VERSION_MAX
FDF_CHANNEL_WAIT_OPTION_ALWAYS_ON
This flag indicates that the channel wait was scheduled on an always-on dispatcher.
FDF_CHANNEL_WAIT_OPTION_FORCE_ASYNC_CANCEL
This flag forces a channel wait to call its callback on cancellation, even if the wait starts on a synchronized dispatcher. This allows for safe cancellation of the wait from a different dispatcher than the one it started on.
FDF_DISPATCHER_OPTION_ALLOW_SYNC_CALLS
This flag indicates that the dispatcher may not share zircon threads with other drivers. Cannot be set in conjunction with FDF_DISPATCHER_OPTION_UNSYNCHRONIZED.
FDF_DISPATCHER_OPTION_NO_THREAD_MIGRATION
This flag indicates that the dispatcher must not have its thread migrated at runtime. It can only be used if the dispatcher’s scheduler role has the FDF_SCHEDULER_ROLE_OPTION_NO_SYNC_CALLS option set.
FDF_DISPATCHER_OPTION_SYNCHRONIZATION_MASK
FDF_DISPATCHER_OPTION_SYNCHRONIZED
This flag disallows parallel calls into callbacks set in the dispatcher.
FDF_DISPATCHER_OPTION_UNSYNCHRONIZED
This flag allows parallel calls into callbacks set in the dispatcher. Cannot be set in conjunction with FDF_DISPATCHER_OPTION_ALLOW_SYNC_CALLS.
FDF_SCHEDULER_ROLE_OPTION_NO_SYNC_CALLS
This flag will prevent any dispatchers from being created on the role that allow sync calls.

Functions§

fdf_arena_add_ref
Increments the reference count to the underlying runtime arena object. This is intended mostly for use with FFIs, such as for Rust, to enable more ergonomic use. Users in C should not need to call this, as the reference count will be properly managed with the fdf_channel_* and fdf_arena_drop_ref functions. Calls to this function must be balanced by corresponding calls to fdf_arena_drop_ref.
fdf_arena_allocate
Returns a pointer to allocated memory of size |bytes|. The memory is managed by the arena until it is freed by |fdf_arena_free|, or the arena is destroyed once every reference to the arena hss been destroyed using |fdf_arena_drop_ref|.
fdf_arena_contains
Returns whether the memory region consisting of [|ptr|, |ptr|+|num_bytes|) resides entirely within memory managed by the |arena|.
fdf_arena_create
Creates a FDF arena for allocating memory.
fdf_arena_drop_ref
Destroys the reference to the underlying runtime arena object. If there are no more references to the arena, all memory associated with the arena will be freed.
fdf_arena_free
Hints to the arena that the |ptr| previously allocated by |fdf_arena_allocate| may be reclaimed. Memory is not guaranteed to be reclaimed until |fdf_arena_drop_ref| is invoked. Asserts if the memory is not managed by the arena.
fdf_channel_call
fdf_channel_call() is like a combined fdf_channel_write(), fdf_channel_wait_async(), and fdf_channel_read(), with the addition of a feature where a transaction id at the front of the message payload bytes is used to match reply messages with send messages, enabling multiple calling threads to share a channel without any additional client-side bookkeeping.
fdf_channel_cancel_wait
Cancels any pending callback registered via |fdf_channel_wait_async|.
fdf_channel_create
Creates a FDF channel, a bi-directional in-process message transport capable of sending arena-managed raw data bytes as well as handles from one side to the other.
fdf_channel_read
Attempts to read the first message from the channel specified by |channel| into the |data| and |handles| buffers.
fdf_channel_wait_async
Begins asynchronously waiting for the channel set in |channel_read| to be readable. The |dispatcher| invokes the handler when the wait completes. Only one dispatcher can be registered at a time. The dispatcher will be considered unregistered immediately before the read handler is invoked.
fdf_channel_write
Attempts to write a message to the channel specified by |channel|.
fdf_dispatcher_create
Creates a dispatcher for performing asynchronous operations.
fdf_dispatcher_destroy
Informs the runtime that |dispatcher| may be destroyed.
fdf_dispatcher_downcast_async_dispatcher
Returns an unowned dispatcher provided an async dispatcher. If |async_dispatcher| was not retrieved via |fdf_dispatcher_get_async_dispatcher|, the call will result in a crash.
fdf_dispatcher_get_always_on_dispatcher
Returns the always-on dispatcher interface for the given dispatcher.
fdf_dispatcher_get_async_dispatcher
Returns the asynchronous dispatch interface.
fdf_dispatcher_get_current_dispatcher
Returns the current thread’s dispatcher. This will return NULL if not called from a dispatcher managed thread.
fdf_dispatcher_get_options
Returns the options set for this dispatcher.
fdf_dispatcher_register_wake_vector
Registers a wake vector. Callbacks for |signals| received on this handle while suspended, wake the driver and execute after the driver’s Resume hook, but before anything else.
fdf_dispatcher_seal
Removes an option set on the dispatcher during creation. The provided |option| parameter is removed from the |dispatcher| given. For example if the dispatcher was created with options that contained FDF_DISPATCHER_OPTION_ALLOW_SYNC_CALLS, calling this with that option will remove the ability of the dispatcher to make any more synchronous calls.
fdf_dispatcher_shutdown_async
Begins shutting down the dispatcher. Shutting down is an asynchronous operation.
fdf_dispatcher_unregister_wake_vector
Unregisters the signals on the given handle as wake vectors.
fdf_env_add_allowed_scheduler_role_for_driver
Adds an allowed scheduler role for the given driver.
fdf_env_destroy_all_dispatchers
Destroys all dispatchers in the process and blocks the current thread until each runtime dispatcher in the process is observed to have been destroyed.
fdf_env_dispatcher_create_with_owner
Same as |fdf_dispatcher_create| but allows setting the driver owner for the dispatcher.
fdf_env_dispatcher_dump
Dumps the state of the dispatcher to the INFO log.
fdf_env_dispatcher_get_dump_deprecated
DO NOT USE THIS. This is a temporary function added to debug https://fxbug.dev/42069837.
fdf_env_dispatcher_has_queued_tasks
Returns whether the dispatcher has any queued tasks.
fdf_env_driver_resume
Resumes the dispatchers owned by the driver. The runtime will move pending callbacks back to the main queue and start accepting new work.
fdf_env_driver_suspend
Asynchronously suspends the dispatchers owned by the driver. The runtime will stop accepting new work and drain existing work before calling the completer.
fdf_env_get_current_driver
Returns the driver on top of the the thread’s current call stack. Returns NULL if no drivers are on the stack.
fdf_env_get_driver_on_tid
Gets the opaque pointer uniquely associated with the driver currently running on the thread identified by |tid|.
fdf_env_get_scheduler_role_opts
Returns the currently set options for the scheduler role as a uint32_t bitmask.
fdf_env_get_thread_limit
Returns the current maximum number of threads which will be spawned for thread pool associated with the given scheduler role.
fdf_env_register_driver_entry
Notifies the runtime that we have entered a new driver context, such as via a Banjo call.
fdf_env_register_driver_exit
Notifies the runtime that we have exited the current driver context.
fdf_env_register_resume_requester
Registers for callbacks for when the driver needs to be resumed. The callback being triggered should eventually result in |fdf_env_driver_resume| being called.
fdf_env_register_stall_scanner
Registers a for callbacks for when stall scanning should occur.
fdf_env_reset
Resets the driver runtime to zero threads. This may only be called when there are no existing dispatchers.
fdf_env_scan_threads_for_stalls
Scans active thread pools for threads that are stalled on long running tasks and potentially spawn new threads to compensate.
fdf_env_scan_threads_for_stalls2
Scans active thread pools for threads that are stalled on long running tasks and potentially spawn new threads to compensate.
fdf_env_set_scheduler_role_opts
Sets the options for the given scheduler role. This can be used to enforce restrictions on the kinds of dispatchers that can be created on this scheduler role.
fdf_env_set_thread_limit
Sets the number of threads which will be spawned for thread pool associated with the given scheduler role. It cannot shrink the limit less to a value lower than the current number of threads in the thread pool.
fdf_env_shutdown_dispatchers_async
Asynchronously shuts down all dispatchers owned by |driver|. |observer| will be notified once shutdown completes. This is guaranteed to be after all the dispatcher’s shutdown observers have been called, and will be running on the thread of the final dispatcher which has been shutdown.
fdf_env_start
Start the driver runtime. This sets up the initial thread that the dispatchers run on.
fdf_handle_close
Closes a handle, causing the underlying object to be reclaimed by the runtime if no other handles to it exist.
fdf_testing_create_unmanaged_dispatcher
Creates a dispatcher on a unmanaged thread pool. This means that there are no background threads handling this dispatcher and so it has to be ran explicitly using the various run calls. See |fdf_env_dispatcher_create_with_owner| for more information about the parameters and return value.
fdf_testing_quit
Quits the unmanaged dispatcher pool if one has been created. Otherwise does nothing. Active invocations of |fdf_testing_run()| will eventually terminate upon completion of their current unit of work.
fdf_testing_reset_quit
Resets the quit state of the unmanaged dispatcher pool so that it can be restarted using |fdf_testing_run()|.
fdf_testing_run
Runs the unmanaged dispatcher pool on the current thread.
fdf_testing_run_until_idle
Runs the unmanaged dispatcher pool on the current thread. Dispatches events until there are none remaining, and then returns without waiting. This is useful for unit testing, because the behavior doesn’t depend on time.
fdf_testing_set_default_dispatcher
Sets the default driver dispatcher to be returned when the current thread does not have a driver associated with it. This is useful for tests that want to attach a dispatcher to their main test thread, so that they can use objects that contains a synchronization_checker. |dispatcher| should have been created using |fdf_testing_create_unmanaged_dispatcher|, or be a nullptr to remove an existing default.
fdf_token_receive
Receives the corresponding driver handle for |token| if it has been transferred.
fdf_token_register
Registers a token transfer handler for |token|.
fdf_token_transfer
Transfers the fdf handle to the owner of the channel peer of |token|.

Type Aliases§

fdf_arena_t
An arena which supports allocation of memory.
fdf_arena_tag_t
fdf_channel_call_args_t
fdf_channel_read_handler_t
Handles execution of asynchronous read operations.
fdf_channel_read_t
A bi-directional in-process message transport capable of sending arena-managed raw data bytes as well as handles from one side to the other.
fdf_dispatcher_shutdown_handler_t
Called when the asynchronous shutdown for |dispatcher| has completed.
fdf_dispatcher_shutdown_observer_t
Holds context for the observer which will be called when the dispatcher’s asynchronous shutdown has completed.
fdf_dispatcher_t
Dispatcher for performing asynchronous operations.
fdf_env_driver_shutdown_handler_t
Called when the asynchronous shutdown for all dispatchers owned by |driver| has completed.
fdf_env_driver_shutdown_observer_t
Holds context for the observer which will be called when the asynchronous shutdown for all dispatchers owned by a driver has completed.
fdf_env_resume_request
Called by the runtime to request to be resumed.
fdf_env_resume_requester_t
Holds context for the resume request which will be called when the runtime needs to be resumed.
fdf_env_stall_scan_begin
Called when stall scanning should begin.
fdf_env_stall_scanner_t
Holds context for the stall scanner which will be called when stall scanning should occur.
fdf_env_suspend_complete
Called by the runtime to signal completion of suspend.
fdf_env_suspend_completer_t
Holds context for the suspend completion which will be called when the driver has completed suspending.
fdf_handle_t
fdf_token_t
Tokens provide a mechanism for transferring FDF handles between drivers in the same process when a driver FIDL transport is not available. This is necessary as FDF handles cannot be transferred using the Zircon channel FIDL transport.
fdf_token_transfer_handler_t
Handles the transfer of the fdf handle.
fdf_txid_t