pub trait SyscallDriverLookup {
// Required method
fn with_driver<F, R>(&self, driver_num: usize, f: F) -> R
where F: FnOnce(Option<&dyn SyscallDriver>) -> R;
}
Expand description
Configure the system call dispatch mapping.
Each board should define a struct which implements this trait. This trait is the core for how syscall dispatching is handled, and the implementation is responsible for dispatching to drivers for each system call number.
§Example
ⓘ
struct Hail {
console: &'static capsules::console::Console<'static>,
ipc: kernel::ipc::IPC,
dac: &'static capsules::dac::Dac<'static>,
}
impl SyscallDriverLookup for Hail {
fn with_driver<F, R>(&self, driver_num: usize, f: F) -> R
where
F: FnOnce(Option<&dyn kernel::SyscallDriver>) -> R,
{
match driver_num {
capsules::console::DRIVER_NUM => f(Some(self.console)),
kernel::ipc::DRIVER_NUM => f(Some(&self.ipc)),
capsules::dac::DRIVER_NUM => f(Some(self.dac)),
_ => f(None),
}
}
}
Required Methods§
Sourcefn with_driver<F, R>(&self, driver_num: usize, f: F) -> R
fn with_driver<F, R>(&self, driver_num: usize, f: F) -> R
Platform-specific mapping of syscall numbers to objects that implement the Driver methods for that syscall.
An implementation
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.