Module kernel::deferred_call
source · Expand description
Hardware-independent kernel interface for deferred calls
This allows any struct in the kernel which implements DeferredCallClient to set and receive deferred calls, Tock’s version of software interrupts.
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 DEFCALLS
array size determines how many
DeferredCalls
may be registered. By default this is set to 32.
To support more deferred calls, this file would need to be modified
to use a larger variable for BITMASK (e.g. BITMASK could be a u64
and the array size increased to 64).
If more than 32 deferred calls are created, the kernel will panic
at the beginning of the kernel loop.
use kernel::deferred_call::{DeferredCall, DeferredCallClient};
use kernel::static_init;
struct SomeCapsule {
deferred_call: DeferredCall
}
impl SomeCapsule {
pub fn new() -> Self {
Self {
deferred_call: DeferredCall::new(),
}
}
}
impl DeferredCallClient for SomeCapsule {
fn handle_deferred_call(&self) {
// Your action here
}
fn register(&'static self) {
self.deferred_call.register(self);
}
}
// main.rs or your component must register the capsule with
// its deferred call.
// This should look like:
let some_capsule = unsafe { static_init!(SomeCapsule, SomeCapsule::new()) };
some_capsule.register();
Structs
Traits
- This trait should be implemented by clients which need to receive DeferredCalls