Trait SyscallDriver

Source
pub trait SyscallDriver {
    // Required method
    fn allocate_grant(&self, process_id: ProcessId) -> Result<(), Error>;

    // Provided methods
    fn command(
        &self,
        command_num: usize,
        r2: usize,
        r3: usize,
        process_id: ProcessId,
    ) -> CommandReturn { ... }
    fn allow_userspace_readable(
        &self,
        app: ProcessId,
        which: usize,
        slice: UserspaceReadableProcessBuffer,
    ) -> Result<UserspaceReadableProcessBuffer, (UserspaceReadableProcessBuffer, ErrorCode)> { ... }
}
Expand description

Trait for capsules implementing peripheral driver system calls specified in TRD104.

The kernel translates the values passed from userspace into Rust types and includes which process is making the call. All of these system calls perform very little synchronous work; long running computations or I/O should be split-phase, with an upcall indicating their completion.

The exact instances of each of these methods (which identifiers are valid and what they represents) are specific to the peripheral system call driver.

Note about subscribe, read-only allow, and read-write allow syscalls: those are handled entirely by the core kernel, and there is no corresponding function for capsules to implement.

Required Methods§

Source

fn allocate_grant(&self, process_id: ProcessId) -> Result<(), Error>

Request to allocate a capsule’s grant for a specific process.

The core kernel uses this function to instruct a capsule to ensure its grant (if it has one) is allocated for a specific process. The core kernel needs the capsule to initiate the allocation because only the capsule knows the type T (and therefore the size of T) that will be stored in the grant.

The typical implementation will look like:

fn allocate_grant(&self, processid: ProcessId) -> Result<(), kernel::process::Error> {
   self.apps.enter(processid, |_, _| {})
}

No default implementation is provided to help prevent accidentally forgetting to implement this function.

If a capsule fails to successfully implement this function, subscribe calls from userspace for the SyscallDriver may fail.

Provided Methods§

Source

fn command( &self, command_num: usize, r2: usize, r3: usize, process_id: ProcessId, ) -> CommandReturn

System call for a process to perform a short synchronous operation or start a long-running split-phase operation (whose completion is signaled with an upcall). Command 0 is a reserved command to detect if a peripheral system call driver is installed and must always return a CommandReturn::success.

Source

fn allow_userspace_readable( &self, app: ProcessId, which: usize, slice: UserspaceReadableProcessBuffer, ) -> Result<UserspaceReadableProcessBuffer, (UserspaceReadableProcessBuffer, ErrorCode)>

System call for a process to pass a buffer (a UserspaceReadableProcessBuffer) to the kernel that the kernel can either read or write. The kernel calls this method only after it checks that the entire buffer is within memory the process can both read and write.

This is different to allow_readwrite in that the app is allowed to read the buffer once it has been passed to the kernel. For more details on how this can be done safely see the userspace readable allow syscalls TRDXXX.

Implementors§

Source§

impl<const NUM_PROCS: u8> SyscallDriver for IPC<NUM_PROCS>

impl SyscallDriver for Console<'_>

impl<'a, A: Adc<'a> + AdcHighSpeed<'a>> SyscallDriver for AdcDedicated<'a, A>

impl<'a, A: Alarm<'a>> SyscallDriver for AlarmDriver<'a, A>

impl<'a, A: Alarm<'a>> SyscallDriver for ConsoleOrdered<'a, A>

impl<'a, I: I2CMaster<'a>> SyscallDriver for I2CMasterDriver<'a, I>

impl<'a, IP: InterruptPin<'a>> SyscallDriver for GPIO<'a, IP>

impl<'a, P: InterruptPin<'a>> SyscallDriver for Button<'a, P>

impl<'a, R: Rng<'a>> SyscallDriver for RngDriver<'a, R>

impl<'a, S: SpiMasterDevice<'a>> SyscallDriver for Spi<'a, S>

impl<'a, S: SpiSlaveDevice<'a>> SyscallDriver for SpiPeripheral<'a, S>

impl<'u, U: Transmit<'u>> SyscallDriver for LowLevelDebug<'u, U>

impl<L: Led, const NUM_LEDS: usize> SyscallDriver for LedDriver<'_, L, NUM_LEDS>

impl SyscallDriver for AppFlash<'_>

impl SyscallDriver for Dac<'_>

impl SyscallDriver for NineDof<'_>

impl SyscallDriver for Screen<'_>

impl SyscallDriver for Touch<'_>

impl<'a, A: AnalogComparator<'a>> SyscallDriver for AnalogComparator<'a, A>

impl<'a, A: Alarm<'a>> SyscallDriver for ThreadNetworkDriver<'a, A>

impl<'a, A: Alarm<'a>> SyscallDriver for SDCardDriver<'a, A>

impl<'a, B, A> SyscallDriver for BLE<'a, B, A>
where B: BleAdvertisementDriver<'a> + BleConfig, A: Alarm<'a>,

impl<'a, B: Buzzer<'a>> SyscallDriver for Buzzer<'a, B>

impl<'a, C> SyscallDriver for UsbSyscallDriver<'a, C>
where C: Client<'a>,

impl<'a, C: Crc<'a>> SyscallDriver for CrcDriver<'a, C>

impl<'a, DateTime: DateTime<'a>> SyscallDriver for DateTimeCapsule<'a, DateTime>

impl<'a, H: Digest<'a, L> + HmacSha256 + HmacSha384 + HmacSha512, const L: usize> SyscallDriver for HmacDriver<'a, H, L>

impl<'a, H: Digest<'a, L> + Sha256 + Sha384 + Sha512, const L: usize> SyscallDriver for ShaDriver<'a, H, L>

impl<'a, H: HumidityDriver<'a>> SyscallDriver for HumiditySensor<'a, H>

impl<'a, H: MoistureDriver<'a>> SyscallDriver for MoistureSensor<'a, H>

impl<'a, H: RainFallDriver<'a>> SyscallDriver for RainFallSensor<'a, H>

impl<'a, M: MacDevice<'a>> SyscallDriver for RadioDriver<'a, M>

impl<'a, P: Pin, A: Alarm<'a>, const NUM_DIGITS: usize> SyscallDriver for SevenSegmentDriver<'a, P, A, NUM_DIGITS>

impl<'a, R: Radio<'a>> SyscallDriver for RadioDriver<'a, R>

impl<'a, S: Screen<'a>> SyscallDriver for ScreenShared<'a, S>

impl<'a, S: SpiMasterDevice<'a>> SyscallDriver for L3gd20Spi<'a, S>

impl<'a, T: Distance<'a>> SyscallDriver for DistanceSensor<'a, T>

impl<'a, T: PressureDriver<'a>> SyscallDriver for PressureSensor<'a, T>

impl<'a, U: UsbHid<'a, [u8; 64]>> SyscallDriver for UsbHidDriver<'a, U>

impl<'a, V: KVPermissions<'a>> SyscallDriver for KVStoreDriver<'a, V>

impl<A: AES128<'static> + AES128Ctr + AES128CBC + AES128ECB + AES128CCM<'static> + AES128GCM<'static>> SyscallDriver for AesDriver<'static, A>

impl<Can: Can> SyscallDriver for CanCapsule<'_, Can>

impl<I: I2CDevice> SyscallDriver for LPS25HB<'_, I>

impl<I: I2CDevice> SyscallDriver for PCA9544A<'_, I>

impl<I: I2CDevice> SyscallDriver for TSL2561<'_, I>

impl<Port: Port> SyscallDriver for GPIOAsync<'_, Port>

impl<const NUM_PINS: usize> SyscallDriver for Pwm<'_, NUM_PINS>

impl<const SERVO_COUNT: usize> SyscallDriver for Servo<'_, SERVO_COUNT>