[][src]Trait kernel::platform::Platform

pub trait Platform {
    fn with_driver<F, R>(&self, driver_num: usize, f: F) -> R
    where
        F: FnOnce(Option<&dyn Driver>) -> R
; }

Interface for individual boards.

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

This example is not tested
struct Hail {
    console: &'static capsules::console::Console<'static>,
    ipc: kernel::ipc::IPC,
    dac: &'static capsules::dac::Dac<'static>,
}

impl Platform for Hail {
    fn with_driver<F, R>(&self, driver_num: usize, f: F) -> R
    where
        F: FnOnce(Option<&dyn kernel::Driver>) -> 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

fn with_driver<F, R>(&self, driver_num: usize, f: F) -> R where
    F: FnOnce(Option<&dyn Driver>) -> R, 

Platform-specific mapping of syscall numbers to objects that implement the Driver methods for that syscall.

Loading content...

Implementors

Loading content...