User guide

12 MPC184/MPC185 Security Co-Processor Software User’s Guide MOTOROLA
PRELIMINARY—SUBJECT TO CHANGE WITHOUT NOTICE
Global Definitions Global Definitions
4.5 Miscellaneous Request Structures
4.5.1 MALLOC_REQ (Linux Only) Structure
This structure is used in Linux for allocation requests to the driver. In Linux the user memory space is
different than the kernel memory space. Due to this limitation, in order to send/receive requests to the kernel,
the user must request memory space from the kernel (malloc) and then perform a copy of the contents in
user memory to/from kernel memory. As with all mallocs, the user must free this memory. The
MALLOC_REQ
structure is used to facilitate this process.
unsigned long sz;
void *ptr;
char *to;
char *from;
sz
—contains the number of bytes to allocate. Zero means to use the default. A value of zero can be
used to avoid fragmentation.
ptr—pointer to the address that is to be returned by a call to malloc or a pointer to an address that
is to be freed when by a call to free.
to—pointer to the address that is the destination of the data during a copy memory request.
from—pointer to the address that is the source of the data during a copy memory request.
This request will be used by user applications running in ‘user space’ only.
User applications running in kernel space do not need to allocate memory using this function.
Following is an example of how to use this function:
DES_LOADCTX_CRYPT_REQ desencReq;
MALLOC_REQ mem;
.
.
/* copy iv data to kernel memory */
mem.sz = 8;
status = Ioctl(device, IOCTL_MALLOC, &mem);
desencReq.inIvData = mem.ptr;
mem.from = iv_in;
mem.to = mem.ptr;
status = Ioctl(device, IOCTL_COPYFROM, &mem);
/* copy key data to kernel memory */
mem.sz = 8;
status = Ioctl(device, IOCTL_MALLOC, &mem);
MPC18x_CANNOT_SETUP_BAR0_ERROR Error due to VxWorks not being able
to setup the base address in
pciGetBAR0()
–1008
MPC18x_VXWORKS_CANNOT_CREATE_QUEUE Error due to VxWorks not being able
to create the ISR queue in IOInitQs()
–1009
MPC18x_CANCELLED_REQUEST Error due to canceled request –1010
MPC18x_INVALID_ADDRESS Error due to a NULL request –1011
Table 5. Callback Error Status Return Code (continued)
Define Description Value