User guide
MOTOROLA MPC184/MPC185 Security Co-Processor Software User’s Guide 7
PRELIMINARY—SUBJECT TO CHANGE WITHOUT NOTICE
User Interface
The code used to request and release a channel and EU is as follows:
.
.
if (status = ioctl(device, IOCTL_RESERVE_CHANNEL_STATIC, &channel)) {
printf("IOCTL_RESERVE_CHANNEL_STATIC failed 0x%04x\n", status);
return status;
}
chan_st1 = channel; /* save the channel number */
channel = (channel << 8) | CHA_DES;
if (status = ioctl(device, IOCTL_ASSIGN_CHA, &channel)) {
printf("IOCTL_ASSIGN_CHA failed 0x%04x\n", status);
return status;
}
.
.
.
if (status = ioctl(device, IOCTL_RELEASE_CHANNEL, &chan_st1))
printf("IOCTL_RELEASE_CHANNEL failed 0x%04x\n", status);
.
.
3.3 Error Handling
Due to the asynchronous nature of the device/driver, there are two main 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 drivers, 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.
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:
AESA_CRYPT_REQ aesdynReq;
.
.
/* AES with dynamic aescriptor */
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) {










