CryptoCell PAL DMA related APIs

nRF5 SDK v17.1.0

Data Structures

struct SaSi_PalDmaBlockInfo_t

Macros

#define SET_WORD_LE

Functions

uint32_t SaSi_PalDmaBufferMap (uint8_t *pDataBuffer, uint32_t buffSize, SaSi_PalDmaBufferDirection_t copyDirection, uint32_t *pNumOfBlocks, SaSi_PalDmaBlockInfo_t *pDmaBlockList, SaSi_PalDmaBufferHandle *dmaBuffHandle)
This function is called by the ARM TrustZone CryptoCell TEE runtime library before the HW is used. It maps a given data buffer (virtual address) for ARM TrustZone CryptoCell TEE HW DMA use (physical address), and returns the list of one or more DMA-able (physical) blocks. It may lock the buffer for ARM TrustZone CryptoCell TEE HW use. Once it is called, only ARM TrustZone CryptoCell TEE HW access to the buffer is allowed, until it is unmapped. If the data buffer was already mapped by the Secure OS prior to calling the ARM TrustZone CryptoCell TEE runtime library, this API does not have to perform any actual mapping operation, but only return the list of DMA-able blocks. More...
uint32_t SaSi_PalDmaBufferUnmap (uint8_t *pDataBuffer, uint32_t buffSize, SaSi_PalDmaBufferDirection_t copyDirection, uint32_t numOfBlocks, SaSi_PalDmaBlockInfo_t *pDmaBlockList, SaSi_PalDmaBufferHandle dmaBuffHandle)
This function is called by the ARM TrustZone CryptoCell TEE runtime library after the HW is used. It unmaps a given buffer, and frees its associated resources, if needed. It may unlock the buffer and flush it for CPU use. Once it is called, ARM TrustZone CryptoCell TEE HW does not require access to this buffer anymore. If the data buffer was already mapped by the Secure OS prior to calling the ARM TrustZone CryptoCell TEE runtime library, this API does not have to perform any un-mapping operation, and the actual un-mapping can be done by the Secure OS outside the context of the ARM TrustZone CryptoCell TEE runtime library. More...
uint32_t SaSi_PalDmaContigBufferAllocate (uint32_t buffSize, uint8_t **ppVirtBuffAddr)
Allocates a DMA-contiguous buffer for CPU use, and returns its virtual address. Before passing the buffer to the ARM TrustZone CryptoCell TEE HW, SaSi_PalDmaBufferMap should be called. More...
uint32_t SaSi_PalDmaContigBufferFree (uint32_t buffSize, uint8_t *pVirtBuffAddr)
Frees resources previously allocated by SaSi_PalDmaContigBufferAllocate . More...
uint32_t SaSi_PalIsDmaBufferContiguous (uint8_t *pDataBuffer, uint32_t buffSize)
Checks whether the buffer is guaranteed to be a single contiguous DMA block. More...
SaSiDmaAddr_t SaSi_PalMapVirtualToPhysical (uint8_t *pVirtualAddr)
Maps virtual address to physical address. More...

Detailed Description

Macro Definition Documentation

#define SET_WORD_LE

Defintion for big to little endian.

Function Documentation

uint32_t SaSi_PalDmaBufferMap ( uint8_t * pDataBuffer ,
uint32_t buffSize ,
SaSi_PalDmaBufferDirection_t copyDirection ,
uint32_t * pNumOfBlocks ,
SaSi_PalDmaBlockInfo_t * pDmaBlockList ,
SaSi_PalDmaBufferHandle * dmaBuffHandle
)

This function is called by the ARM TrustZone CryptoCell TEE runtime library before the HW is used. It maps a given data buffer (virtual address) for ARM TrustZone CryptoCell TEE HW DMA use (physical address), and returns the list of one or more DMA-able (physical) blocks. It may lock the buffer for ARM TrustZone CryptoCell TEE HW use. Once it is called, only ARM TrustZone CryptoCell TEE HW access to the buffer is allowed, until it is unmapped. If the data buffer was already mapped by the Secure OS prior to calling the ARM TrustZone CryptoCell TEE runtime library, this API does not have to perform any actual mapping operation, but only return the list of DMA-able blocks.

Returns
A non-zero value in case of failure.
Parameters
[in] pDataBuffer Address of the buffer to map.
[in] buffSize Buffer size in bytes.
[in] copyDirection Copy direction of the buffer, according to SaSi_PalDmaBufferDirection_t ,
  • TO_DEVICE - the original buffer is the input to the operation, and this function should copy it to the temp buffer, prior to the activating the HW on the temp buffer.
  • FROM_DEVICE - not relevant for this API.
  • BI_DIRECTION - used when the crypto operation is "in-place", meaning the result of encryption or decryption is written over the original data at the same address. Should be treated by this API same as TO_DEVICE.
[in,out] pNumOfBlocks Maximum numOfBlocks to fill, as output the actual number.
[out] pDmaBlockList List of DMA-able blocks that the buffer maps to.
[out] dmaBuffHandle A handle to the mapped buffer private resources.
uint32_t SaSi_PalDmaBufferUnmap ( uint8_t * pDataBuffer ,
uint32_t buffSize ,
SaSi_PalDmaBufferDirection_t copyDirection ,
uint32_t numOfBlocks ,
SaSi_PalDmaBlockInfo_t * pDmaBlockList ,
SaSi_PalDmaBufferHandle dmaBuffHandle
)

This function is called by the ARM TrustZone CryptoCell TEE runtime library after the HW is used. It unmaps a given buffer, and frees its associated resources, if needed. It may unlock the buffer and flush it for CPU use. Once it is called, ARM TrustZone CryptoCell TEE HW does not require access to this buffer anymore. If the data buffer was already mapped by the Secure OS prior to calling the ARM TrustZone CryptoCell TEE runtime library, this API does not have to perform any un-mapping operation, and the actual un-mapping can be done by the Secure OS outside the context of the ARM TrustZone CryptoCell TEE runtime library.

Returns
A non-zero value in case of failure.
Parameters
[in] pDataBuffer Address of the buffer to unmap.
[in] buffSize Buffer size in bytes.
[in] copyDirection Copy direction of the buffer, according to SaSi_PalDmaBufferDirection_t
  • TO_DEVICE - not relevant for this API.
  • FROM_DEVICE - the temp buffer holds the output of the HW, and this API should copy it to the actual output buffer.
  • BI_DIRECTION - used when the crypto operation is "in-place", meaning the result of encryption or decryption is written over the original data at the same address. Should be treated by this API same as FROM_DEVICE.
[in] numOfBlocks Number of DMA-able blocks that the buffer maps to.
[in] pDmaBlockList List of DMA-able blocks that the buffer maps to.
[in] dmaBuffHandle A handle to the mapped buffer private resources.
uint32_t SaSi_PalDmaContigBufferAllocate ( uint32_t buffSize ,
uint8_t ** ppVirtBuffAddr
)

Allocates a DMA-contiguous buffer for CPU use, and returns its virtual address. Before passing the buffer to the ARM TrustZone CryptoCell TEE HW, SaSi_PalDmaBufferMap should be called.

Note
The returned address must be aligned to 32 bits.
Returns
A non-zero value in case of failure.
Parameters
[in] buffSize Buffer size in bytes.
[out] ppVirtBuffAddr Virtual address of the allocated buffer.
uint32_t SaSi_PalDmaContigBufferFree ( uint32_t buffSize ,
uint8_t * pVirtBuffAddr
)

Frees resources previously allocated by SaSi_PalDmaContigBufferAllocate .

Returns
A non-zero value in case of failure.
Parameters
[in] buffSize Buffer size in Bytes.
[in] pVirtBuffAddr Virtual address of the buffer to free.
uint32_t SaSi_PalIsDmaBufferContiguous ( uint8_t * pDataBuffer ,
uint32_t buffSize
)

Checks whether the buffer is guaranteed to be a single contiguous DMA block.

Returns
Returns TRUE if the buffer is guaranteed to be a single contiguous DMA block, and FALSE otherwise.
Parameters
[in] pDataBuffer User buffer address.
[in] buffSize User buffer size.
SaSiDmaAddr_t SaSi_PalMapVirtualToPhysical ( uint8_t * pVirtualAddr )

Maps virtual address to physical address.

Returns
Physical address.
Parameters
[in] pVirtualAddr Pointer to virtual address.