Trait kernel::Driver[][src]

pub trait Driver {
    fn subscribe(
        &self,
        subscribe_identifier: usize,
        upcall: Upcall,
        app_id: ProcessId
    ) -> Result<Upcall, (Upcall, ErrorCode)> { ... }
fn command(
        &self,
        which: usize,
        r2: usize,
        r3: usize,
        caller_id: ProcessId
    ) -> CommandReturn { ... }
fn allow_readwrite(
        &self,
        app: ProcessId,
        which: usize,
        slice: ReadWriteAppSlice
    ) -> Result<ReadWriteAppSlice, (ReadWriteAppSlice, ErrorCode)> { ... }
fn allow_readonly(
        &self,
        app: ProcessId,
        which: usize,
        slice: ReadOnlyAppSlice
    ) -> Result<ReadOnlyAppSlice, (ReadOnlyAppSlice, ErrorCode)> { ... } }
Expand description

Trait for capsules implemeting 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.

Provided methods

fn subscribe(
    &self,
    subscribe_identifier: usize,
    upcall: Upcall,
    app_id: ProcessId
) -> Result<Upcall, (Upcall, ErrorCode)>
[src]

System call for a process to provide an upcall function pointer to the kernel. Peripheral system call driver capsules invoke upcalls to indicate events have occurred. These events are typically triggered in response to command calls. For example, a command that sets a timer to fire in the future will cause an upcall to invoke after the command returns, when the timer expires, while a command to sample a sensor will cause an upcall to invoke when the sensor value is ready.

fn command(
    &self,
    which: usize,
    r2: usize,
    r3: usize,
    caller_id: ProcessId
) -> CommandReturn
[src]

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.

fn allow_readwrite(
    &self,
    app: ProcessId,
    which: usize,
    slice: ReadWriteAppSlice
) -> Result<ReadWriteAppSlice, (ReadWriteAppSlice, ErrorCode)>
[src]

System call for a process to pass a buffer (a ReadWriteAppSlice) 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.

fn allow_readonly(
    &self,
    app: ProcessId,
    which: usize,
    slice: ReadOnlyAppSlice
) -> Result<ReadOnlyAppSlice, (ReadOnlyAppSlice, ErrorCode)>
[src]

System call for a process to pass a read-only buffer (a ReadOnlyAppSlice) to the kernel that the kernel can read. The kernel calls this method only after it checks that that the entire buffer is within memory the process can read. This system call allows a process to pass read-only data (e.g., in flash) to the kernel.

Implementors

impl<const NUM_PROCS: usize> Driver for IPC<NUM_PROCS>[src]

fn subscribe(
    &self,
    subscribe_num: usize,
    upcall: Upcall,
    app_id: ProcessId
) -> Result<Upcall, (Upcall, ErrorCode)>
[src]

subscribe enables processes using IPC to register upcalls that fire when notify() is called.

fn command(
    &self,
    command_number: usize,
    target_id: usize,
    _: usize,
    appid: ProcessId
) -> CommandReturn
[src]

command is how notify() is implemented. Notifying an IPC service is done by setting client_or_svc to 0, and notifying an IPC client is done by setting client_or_svc to 1. In either case, the target_id is the same number as provided in a notify upcall or as returned by allow.

Returns INVAL if the other process doesn’t exist. Initiates a service discovery or notifies a client or service.

command_num

  • 0: Driver check, always returns Ok(())
  • 1: Perform discovery on the package name passed to allow_readonly. Returns the service descriptor if the service is found, otherwise returns an error.
  • 2: Notify a service previously discovered to have the service descriptor in target_id. Returns an error if target_id refers to an invalid service or the notify fails to enqueue.
  • 3: Notify a client with descriptor target_id, typically in response to a previous notify from the client. Returns an error if target_id refers to an invalid client or the notify fails to enqueue.

fn allow_readonly(
    &self,
    appid: ProcessId,
    subdriver: usize,
    slice: ReadOnlyAppSlice
) -> Result<ReadOnlyAppSlice, (ReadOnlyAppSlice, ErrorCode)>
[src]

allow_readonly with subdriver number 0 stores the provided buffer for service discovery. The buffer should contain the package name of a process that exports an IPC service.

fn allow_readwrite(
    &self,
    appid: ProcessId,
    target_id: usize,
    slice: ReadWriteAppSlice
) -> Result<ReadWriteAppSlice, (ReadWriteAppSlice, ErrorCode)>
[src]

allow_readwrite enables processes to discover IPC services on the platform or share buffers with existing services.

If allow is called with target_id >= 1, it is a share command where the application is explicitly sharing a slice with an IPC service (as specified by the target_id). allow() simply allows both processes to access the buffer, it does not signal the service.

target_id == 0 is currently unsupported and reserved for future use.