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
crc_unit: &'a C
apps: Grant<App>
serving_app: Cell<Option<AppId>>
Methods
impl<'a, C: CRC> Crc<'a, C>
[src]
pub fn new(crc_unit: &'a C, apps: Grant<App>) -> Crc<'a, C>
[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()),
fn serve_waiting_apps(&self)
[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 allow
s 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.
fn allow(
&self,
appid: AppId,
allow_num: usize,
slice: AppSlice<Shared, u8>
) -> ReturnCode
[src]
&self,
appid: AppId,
allow_num: usize,
slice: AppSlice<Shared, u8>
) -> ReturnCode
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.
fn subscribe(&self, subscribe_num: usize, callback: Callback) -> ReturnCode
[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 statusEBUSY
indicates the unit is already busy. The statusESIZE
indicates the provided buffer is too large for the unit to handle.result
is the result of the CRC computation whenstatus == EBUSY
.
fn command(
&self,
command_num: usize,
algorithm: usize,
_: usize,
appid: AppId
) -> ReturnCode
[src]
&self,
command_num: usize,
algorithm: usize,
_: usize,
appid: AppId
) -> ReturnCode
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 present1
: 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 byallow
. If none was provided, this command will returnEINVAL
.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 returnEINVAL
.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 form0xFFFFxxxx
for this algorithm. It can be performed purely in hardware on the SAM4L.3: SAM4L-32
This algorithm uses the same polynomial asCRC-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 asCRC-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]
fn receive_result(&self, result: u32)
[src]
Receive the successful result of a CRC calculation