2 error handling – Freescale Semiconductor SEC2SWUG User Manual

Page 6

Advertising
background image

SEC 2.0 Reference Device Driver User’s Guide, Rev. 0

6

PRELIMINARY—SUBJECT TO CHANGE WITHOUT NOTICE

Freescale Semiconductor

User Interface

3.2 Error Handling

Due to the asynchronous nature of the device/driver, there are two primary sources of errors:

Syntax or logic. These are returned in the

status

member of the 'user request' argument and as a return

code from

ioctl

function. Errors of this type are detected by the driver, not by hardware.

Protocol/procedure. These errors are returned only in the

status

member of the user request argument.

Errors of this type are detected by hardware in the course of their execution.

Consequently, the end-user application needs two levels of error checking, the first one after the return from the

ioctl

function, and the second one after the completion of the request. The second level is possible only if the

request was done with at least the

notify_on_error

member of the user request structure. If the

notification/callback function has not been requested, this level of error will be lost.

A code example of the two levels of errors are as follows, using an AES request as an example:

AESA_CRYPT_REQ aesdynReq;

..

aesdynReq.opId = DPD_AESA_CBC_ENCRYPT_CRYPT;

aesdynReq.channel = 0;

aesdynReq.notify = (void *) notifAes;

aesdynReq.notify_on_error = (void *) notifAes;

aesdynReq.status = 0;

aesdynReq.inIvBytes = 16;

aesdynReq.inIvData = iv_in;

aesdynReq.keyBytes = 32;

aesdynReq.keyData = AesKey;

aesdynReq.inBytes = packet_length;

aesdynReq.inData = aesData;

aesdynReq.outData = aesResult;

aesdynReq.outIvBytes = 16;

aesdynReq.outIvData = iv_out;

aesdynReq.nextReq = 0;

status = Ioctl(device, IOCTL_PROC_REQ, &aesdynReq);

if (status != 0) {

printf ("Syntax-Logic Error in dynamic descriptor 0x%x\n", status); .

.

.

}.

Advertising