[][src]Module kernel::common::dynamic_deferred_call

Hardware-independent kernel interface for deferred calls

This allows any struct in the kernel which implements DynamicDeferredCallClient to set and receive deferred calls.

These can be used to implement long-running in-kernel algorithms or software devices that are supposed to work like hardware devices. Essentially, this allows the chip to handle more important interrupts, and lets a kernel component return the function call stack up to the scheduler, automatically being called again.

Usage

The dynamic_deferred_call_clients array size determines how many DeferredCallHandles may be registered with the instance. When no more slots are available, dynamic_deferred_call.register(some_client) will return None.

use kernel::common::dynamic_deferred_call::{
    DynamicDeferredCall,
    DynamicDeferredCallClient,
    DynamicDeferredCallClientState,
};

let dynamic_deferred_call_clients = unsafe { static_init!(
    [DynamicDeferredCallClientState; 2],
    Default::default()
) };
let dynamic_deferred_call = unsafe { static_init!(
    DynamicDeferredCall,
    DynamicDeferredCall::new(dynamic_deferred_call_clients)
) };
assert!(unsafe { DynamicDeferredCall::set_global_instance(dynamic_deferred_call) }, true);

// Here you can register custom capsules, etc.
// This could look like:
let some_capsule = unsafe { static_init!(
    SomeCapsule,
    SomeCapsule::new(dynamic_deferred_call)
) };
some_capsule.set_deferred_call_handle(
    dynamic_deferred_call.register(some_capsule).expect("no deferred call slot available")
);

Structs

DeferredCallHandle

Unique identifier for a deferred call registered with a DynamicDeferredCall

DynamicDeferredCall

Dynamic deferred call

DynamicDeferredCallClientState

Internal per-client state tracking for the DynamicDeferredCall

Traits

DynamicDeferredCallClient

Client for the DynamicDeferredCall