[][src]Trait kernel::Platform

pub trait Platform {
    fn with_driver<F, R>(&self, driver_num: usize, f: F) -> R
    where
        F: FnOnce(Option<&dyn Driver>) -> R
; fn filter_syscall(
        &self,
        _process: &dyn ProcessType,
        _syscall: &Syscall
    ) -> Result<(), ReturnCode> { ... } }

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...

Provided methods

fn filter_syscall(
    &self,
    _process: &dyn ProcessType,
    _syscall: &Syscall
) -> Result<(), ReturnCode>

Check the platform-provided system call filter for all non-yield system calls. If the system call is allowed for the provided process then return Ok(()). Otherwise, return Err with a ReturnCode that will be returned to the calling application. The default implementation allows all system calls. This API should be considered unstable, and is likely to change in the future.

Loading content...

Implementors

Loading content...