Struct capsules_extra::crc::CrcDriver

source ·
pub struct CrcDriver<'a, C: Crc<'a>> { /* private fields */ }
Expand description

Struct that holds the state of the Crc driver and implements the Driver trait for use by processes through the system call interface.

Implementations§

source§

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

source

pub fn new( crc: &'a C, crc_buffer: &'static mut [u8], grant: Grant<App, UpcallCount<1>, AllowRoCount<{ ro_allow::COUNT }>, AllowRwCount<0>>, ) -> CrcDriver<'a, C>

Create a Crc driver

The argument crc_unit must implement the abstract Crc hardware interface. The argument apps should be an empty kernel Grant, and will be used to track application requests.

§Example
capsules::crc::Crc::new(&sam4l::crccu::CrcCU, board_kernel.create_grant(&grant_cap));

Trait Implementations§

source§

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

source§

fn input_done( &self, result: Result<(), ErrorCode>, buffer: SubSliceMut<'static, u8>, )

Called when the current data chunk has been processed by the CRC engine. Further data may be supplied when this callback is received.
source§

fn crc_done(&self, result: Result<CrcOutput, ErrorCode>)

Called when the CRC computation is finished.
source§

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

Processes can use the Crc system call driver to compute Crc redundancy checks over process memory.

At a high level, the client first provides a callback for the result of computations through the subscribe system call and allows the driver access to the buffer over-which to compute. Then, it initiates a Crc computation using the command system call. See function-specific comments for details.

source§

fn command( &self, command_num: usize, algorithm_id: usize, length: usize, process_id: ProcessId, ) -> CommandReturn

The allow syscall for this driver supports the single allow_num zero, which is used to provide a buffer over which to compute a Crc computation. The command system call for this driver return meta-data about the driver and kicks off Crc computations returned through callbacks.

§Command Numbers
  • 0: Returns non-zero to indicate the driver is present.

  • 1: Requests that a Crc be computed over the buffer previously provided by allow. If none was provided, this command will return INVAL.

    This command’s driver-specific argument indicates what Crc algorithm to perform, as listed below. If an invalid algorithm specifier is provided, this command will return INVAL.

    If a callback was not previously registered with subscribe, this command will return INVAL.

    If a computation has already been requested by this application but the callback has not yet been invoked to receive the result, this command will return BUSY.

    When Ok(()) is returned, this means the request has been queued and the callback will be invoked when the Crc computation is complete.

§Algorithm

The Crc algorithms supported by this driver are listed below. In the values used to identify polynomials, more-significant bits correspond to higher-order terms, and the most significant bit is omitted because it always equals one. All algorithms listed here consume each input byte from most-significant bit to least-significant.

  • 0: Crc-32 This algorithm is used in Ethernet and many other applications. It uses polynomial 0x04C11DB7 and it bit-reverses and then bit-inverts the output.

  • 1: Crc-32C This algorithm uses polynomial 0x1EDC6F41 (due to Castagnoli) and it bit-reverses and then bit-inverts the output. It may be equivalent to various Crc functions using the same name.

  • 2: Crc-16CCITT This algorithm uses polynomial 0x1021 and does no post-processing on the output value. The sixteen-bit Crc result is placed in the low-order bits of the returned result value. That is, result values will always be of the form 0x0000xxxx for this algorithm. It can be performed purely in hardware on the SAM4L.

source§

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

Request to allocate a capsule’s grant for a specific process. Read more
source§

fn allow_userspace_readable( &self, app: ProcessId, which: usize, slice: ReadWriteProcessBuffer, ) -> Result<ReadWriteProcessBuffer, (ReadWriteProcessBuffer, 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. Read more

Auto Trait Implementations§

§

impl<'a, C> !Freeze for CrcDriver<'a, C>

§

impl<'a, C> !RefUnwindSafe for CrcDriver<'a, C>

§

impl<'a, C> !Send for CrcDriver<'a, C>

§

impl<'a, C> !Sync for CrcDriver<'a, C>

§

impl<'a, C> Unpin for CrcDriver<'a, C>

§

impl<'a, C> !UnwindSafe for CrcDriver<'a, C>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.