Struct capsules::crc::Crc [] [src]

pub struct Crc<'a, C: CRC + 'a> {
    crc_unit: &'a C,
    apps: Grant<App>,
    serving_app: Cell<Option<AppId>>,
}

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

Fields

Methods

impl<'a, C: CRC> Crc<'a, C>
[src]

[src]

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, kernel::Grant::create()),

[src]

Trait Implementations

impl<'a, C: CRC> Driver for Crc<'a, C>
[src]

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.

[src]

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.

[src]

The subscribe syscall supports the single subscribe_number zero, which is used to provide a callback that will receive the result of a CRC computation. The signature of the callback is

fn callback(status, result);

where

  • status is indicates whether the computation succeeded. The status EBUSY indicates the unit is already busy. The status ESIZE indicates the provided buffer is too large for the unit to handle.

  • result is the result of the CRC computation when status == EBUSY.

[src]

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: Returns the CRC unit's version value. This is provided in order to be complete, but has limited utility as no consistent semantics are specified.

  • 2: Requests that a CRC be computed over the buffer previously provided by allow. If none was provided, this command will return EINVAL.

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

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

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

    When SUCCESS 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: SAM4L-16 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, and the high-order bits will all be set. That is, result values will always be of the form 0xFFFFxxxx for this algorithm. It can be performed purely in hardware on the SAM4L.

  • 3: SAM4L-32 This algorithm uses the same polynomial as CRC-32, but does no post-processing on the output value. It can be perfomed purely in hardware on the SAM4L.

  • 4: SAM4L-32C This algorithm uses the same polynomial as CRC-32C, but does no post-processing on the output value. It can be performed purely in hardware on the SAM4L.

impl<'a, C: CRC> Client for Crc<'a, C>
[src]

[src]

Receive the successful result of a CRC calculation