original files of m241

This commit is contained in:
neelimap
2026-07-30 11:19:44 +05:30
parent 170c2b3f3a
commit afc7070c1f
12254 changed files with 7655111 additions and 0 deletions
@@ -0,0 +1,575 @@
/******************************************************************************
� 1995-2003, 2004, 2005-2010 Freescale Semiconductor, Inc.
All rights reserved.
This is proprietary source code of Freescale Semiconductor Inc.,
and its use is subject to the NetComm Device Drivers EULA.
The copyright notice above does not evidence any actual or intended
publication of such source code.
**************************************************************************/
/* Include the internal definitions of this module */
#include "sec_dcl.h"
#include "sec_dcl_api.h"
#include "sec_dcl_cmd.h"
/* Include the external interfaces of other modules */
#include "xx_ext.h"
#include "sec_ext.h"
#include "part_ext.h"
#include "error_ext.h"
#include "string_ext.h"
/* wind river start */
#ifdef SEC4_PREALLOC_DESC_BUF
#include "mem_ext.h"
#endif
/* wind river end */
#define __ERR_MODULE__ MODULE_SEC
static t_Error CheckInitParameters(t_SecDcl* p_SecDcl);
/* static t_Handle CreateDescObject(t_SecDcl* p_SecDcl,uint32_t length,uint32_t* p_Buffer);*/
/*******************************/
/* Initialization Unit (below) */
t_Handle SEC_DCL_Config(t_SecDclParam* p_Param)
{
t_SecDcl* p_SecDcl;
SANITY_CHECK_EXIT(p_Param,E_NULL_POINTER);
/* Allocate the driver structure */
/* ----------------------------- */
p_SecDcl = (t_SecDcl*)XX_Malloc(sizeof(t_SecDcl));
if (p_SecDcl == NULL)
{
REPORT_ERROR(MAJOR,E_NO_MEMORY,("SEC DCL driver"));
return (t_Handle)p_SecDcl;
}
memset(p_SecDcl,0,sizeof(t_SecDcl));
/* Allocate the driver parameters structure */
/* ---------------------------------------- */
p_SecDcl->p_DriverParam = (t_SecDclDriverParam*)XX_Malloc(sizeof(t_SecDclDriverParam));
if (p_SecDcl->p_DriverParam == NULL)
{
REPORT_ERROR(MAJOR,E_NO_MEMORY,("SEC DCL driver parameters"));
return (t_Handle)p_SecDcl;
}
memset(p_SecDcl->p_DriverParam,0,sizeof(t_SecDclDriverParam));
/* Configure the driver parameters */
/* ------------------------------- */
p_SecDcl->p_DriverParam->h_Sec = p_Param->h_Sec ;
p_SecDcl->p_DriverParam->memId = p_Param->memId ;
p_SecDcl->p_DriverParam->alignment = p_Param->alignment ;
p_SecDcl->p_DriverParam->prefixSize = p_Param->prefixSize ;
p_SecDcl->p_DriverParam->postfixSize = p_Param->postfixSize;
/* wind river start */
#ifdef SEC4_PREALLOC_DESC_BUF
p_SecDcl->p_DriverParam->noofBuf = p_Param->noofBuf ;
p_SecDcl->p_DriverParam->descSize = p_Param->descSize ;
p_SecDcl->p_DriverParam->descBufSize = p_Param->descBufSize;
#endif
/* wind river end */
return (t_Handle)p_SecDcl;
}
t_Error SEC_DCL_Init(t_Handle h_SecDcl)
{
t_SecDcl* p_SecDcl = (t_SecDcl*)h_SecDcl;
uint8_t majRevNum;
uint8_t minRevNum;
/* wind river start */
t_Error status;
/* wind river end */
SANITY_CHECK_EXIT(p_SecDcl,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecDcl->p_DriverParam,E_INVALID_STATE);
CHECK_INIT_PARAMETERS(p_SecDcl,CheckInitParameters);
majRevNum = SEC_GetMajRevNum(p_SecDcl->p_DriverParam->h_Sec);
minRevNum = SEC_GetMinRevNum(p_SecDcl->p_DriverParam->h_Sec);
if (majRevNum==1 && minRevNum==0)
REPORT_ERROR(MAJOR,E_NOT_SUPPORTED,("SEC version"));
p_SecDcl->ptrSize = SEC_GetPtrSize(p_SecDcl->p_DriverParam->h_Sec);
p_SecDcl->memId = p_SecDcl->p_DriverParam->memId ;
p_SecDcl->alignment = p_SecDcl->p_DriverParam->alignment ;
p_SecDcl->prefixSize = p_SecDcl->p_DriverParam->prefixSize ;
p_SecDcl->postfixSize = p_SecDcl->p_DriverParam->postfixSize;
/* wind river start */
#ifdef SEC4_PREALLOC_DESC_BUF
p_SecDcl->descSize = p_SecDcl->p_DriverParam->descSize ;
p_SecDcl->descBufSize = p_SecDcl->p_DriverParam->descBufSize;
p_SecDcl->noofBuf = p_SecDcl->p_DriverParam->noofBuf ;
#endif
/* wind river end */
XX_Free(p_SecDcl->p_DriverParam);
p_SecDcl->p_DriverParam = NULL;
/* wind river start */
#ifdef SEC4_PREALLOC_DESC_BUF
/* Initiate memory to be used for pre-allocated descriptor buffers, for increased performance */
#ifdef SEC4_USE_QI
status = MEM_InitSmart("DESC", &(p_SecDcl->h_SecMem), p_SecDcl->noofBuf, p_SecDcl->descSize,
p_SecDcl->prefixSize, p_SecDcl->postfixSize, p_SecDcl->alignment, p_SecDcl->memId, FALSE);
#else
status = MEM_Init("DESC", &(p_SecDcl->h_SecMem), p_SecDcl->noofBuf, p_SecDcl->descSize,
p_SecDcl->prefixSize, p_SecDcl->postfixSize, p_SecDcl->alignment);
#endif
if(E_OK != status)
{
return status;
}
status = MEM_InitSmart("SMRT", &(p_SecDcl->h_SecMemSmart), p_SecDcl->noofBuf, p_SecDcl->descBufSize,
p_SecDcl->prefixSize, p_SecDcl->postfixSize, p_SecDcl->alignment, p_SecDcl->memId, FALSE);
if(E_OK != status)
{
return status;
}
#endif
/* wind river end */
return E_OK;
}
t_Error SEC_DCL_Free(t_Handle h_SecDcl)
{
t_SecDcl* p_SecDcl = (t_SecDcl*)h_SecDcl;
SANITY_CHECK_EXIT(p_SecDcl,E_INVALID_HANDLE);
if (p_SecDcl->p_DriverParam)
XX_Free(p_SecDcl->p_DriverParam);
XX_Free(p_SecDcl);
return E_OK;
}
/* Initialization Unit (above) */
/*******************************/
/********************************/
/* Runtime Control Unit (below) */
t_Handle SEC_DCL_InitSeqJobDesc(t_Handle h_SecDcl,
t_SeqJobDescParam* p_JobDescParam)
{
t_SecDcl* p_SecDcl = (t_SecDcl*)h_SecDcl;
t_Desc* p_ShrDesc;
uint32_t length;
uint32_t buffer[MAX_DESC_LENGTH];
/* Using MAX_DESC_LENGTH instead of MaxJobDescLen in order to keep it simple */
SANITY_CHECK_EXIT(p_SecDcl,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_JobDescParam,E_NULL_POINTER);
p_ShrDesc = (t_Desc*)p_JobDescParam->h_ShrDesc;
SANITY_CHECK_EXIT(p_ShrDesc,E_INVALID_HANDLE);
/* Verify that casting from (uint8_t*) to (uint32_t*) can be applied safely */
ASSERT_COND((CAST_POINTER_TO_UINT64(p_ShrDesc->p_Buffer)%sizeof(uint32_t))==0);
length = InitSeqJobDesc(buffer,
p_SecDcl->ptrSize,
(uint32_t*)p_ShrDesc->p_Buffer,
p_JobDescParam->inputSeq.sgt,
p_JobDescParam->inputSeq.size,
p_JobDescParam->inputSeq.p_Data,
p_JobDescParam->outputSeq.sgt,
p_JobDescParam->outputSeq.size,
p_JobDescParam->outputSeq.p_Data);
return CreateDescObject(p_SecDcl,length,buffer);
}
t_Handle SEC_DCL_InitSplitKeyJobDesc(t_Handle h_SecDcl,
t_SplitKeyJobDescParam* p_JobDescParam)
{
t_SecDcl* p_SecDcl = (t_SecDcl*)h_SecDcl;
uint32_t length;
uint32_t buffer[MAX_DESC_LENGTH];
/* Using MAX_DESC_LENGTH instead of MaxJobDescLen in order to keep it simple */
SANITY_CHECK_EXIT(p_SecDcl,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_JobDescParam,E_NULL_POINTER);
length = InitSplitKeyJobDesc(buffer,
p_SecDcl->ptrSize,
p_JobDescParam->p_InputKey,
p_JobDescParam->p_OutputKey,
p_JobDescParam->hashAlg);
return CreateDescObject(p_SecDcl,length,buffer);
}
t_Handle SEC_DCL_InitIpsecEncapShrDesc(t_Handle h_SecDcl,
t_IpsecShrDescParam* p_ShrDescParam,
t_IpsecEncapParam* p_EncapParam)
{
t_SecDcl* p_SecDcl = (t_SecDcl*)h_SecDcl;
uint32_t length;
uint32_t buffer[MAX_DESC_LENGTH];
/* Using MAX_DESC_LENGTH instead of MaxJobDescLen in order to keep it simple */
SANITY_CHECK_EXIT(p_SecDcl,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_ShrDescParam,E_NULL_POINTER);
SANITY_CHECK_EXIT(p_EncapParam,E_NULL_POINTER);
length = InitIpsecEncapShrDesc(buffer,
p_SecDcl->ptrSize,
p_ShrDescParam->dataMoveSize,
p_ShrDescParam->cryptoKey.imm,
p_ShrDescParam->cryptoKey.size,
p_ShrDescParam->cryptoKey.p_Data,
p_ShrDescParam->authenKey.imm,
p_ShrDescParam->authenKey.size,
p_ShrDescParam->authenKey.p_Data,
p_ShrDescParam->cryptoAlg,
p_ShrDescParam->authenAlg,
p_EncapParam);
return CreateDescObject(p_SecDcl,length,buffer);
}
t_Handle SEC_DCL_InitIpsecDecapShrDesc(t_Handle h_SecDcl,
t_IpsecShrDescParam* p_ShrDescParam,
t_IpsecDecapParam* p_DecapParam)
{
t_SecDcl* p_SecDcl = (t_SecDcl*)h_SecDcl;
uint32_t length;
uint32_t buffer[MAX_DESC_LENGTH];
/* Using MAX_DESC_LENGTH instead of MaxShrDescLen in order to keep it simple */
SANITY_CHECK_EXIT(p_SecDcl,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_ShrDescParam,E_NULL_POINTER);
SANITY_CHECK_EXIT(p_DecapParam,E_NULL_POINTER);
length = InitIpsecDecapShrDesc(buffer,
p_SecDcl->ptrSize,
p_ShrDescParam->dataMoveSize,
p_ShrDescParam->cryptoKey.imm,
p_ShrDescParam->cryptoKey.size,
p_ShrDescParam->cryptoKey.p_Data,
p_ShrDescParam->authenKey.imm,
p_ShrDescParam->authenKey.size,
p_ShrDescParam->authenKey.p_Data,
p_ShrDescParam->cryptoAlg,
p_ShrDescParam->authenAlg,
p_DecapParam);
return CreateDescObject(p_SecDcl,length,buffer);
}
t_Handle SEC_DCL_InitDtlsEncapShrDesc(t_Handle h_SecDcl,
t_DtlsShrDescParam* p_ShrDescParam,
t_DtlsEncapParam* p_EncapParam)
{
t_SecDcl* p_SecDcl = (t_SecDcl*)h_SecDcl;
uint32_t length;
uint32_t buffer[MAX_DESC_LENGTH];
/* Using MAX_DESC_LENGTH instead of MaxShrDescLen in order to keep it simple */
SANITY_CHECK_EXIT(p_SecDcl,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_ShrDescParam,E_NULL_POINTER);
SANITY_CHECK_EXIT(p_EncapParam,E_NULL_POINTER);
length = InitDtlsEncapShrDesc(buffer,
p_SecDcl->ptrSize,
p_ShrDescParam->dataMoveSize,
p_ShrDescParam->cryptoKey.imm,
p_ShrDescParam->cryptoKey.size,
p_ShrDescParam->cryptoKey.p_Data,
p_ShrDescParam->authenKey.imm,
p_ShrDescParam->authenKey.size,
p_ShrDescParam->authenKey.p_Data,
p_ShrDescParam->cipherAlg,
p_EncapParam);
return CreateDescObject(p_SecDcl,length,buffer);
}
t_Handle SEC_DCL_InitDtlsDecapShrDesc(t_Handle h_SecDcl,
t_DtlsShrDescParam* p_ShrDescParam,
t_DtlsDecapParam* p_DecapParam)
{
t_SecDcl* p_SecDcl = (t_SecDcl*)h_SecDcl;
uint32_t length;
uint32_t buffer[MAX_DESC_LENGTH];
/* Using MAX_DESC_LENGTH instead of MaxShrDescLen in order to keep it simple */
SANITY_CHECK_EXIT(p_SecDcl,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_ShrDescParam,E_NULL_POINTER);
SANITY_CHECK_EXIT(p_DecapParam,E_NULL_POINTER);
length = InitDtlsDecapShrDesc(buffer,
p_SecDcl->ptrSize,
p_ShrDescParam->dataMoveSize,
p_ShrDescParam->cryptoKey.imm,
p_ShrDescParam->cryptoKey.size,
p_ShrDescParam->cryptoKey.p_Data,
p_ShrDescParam->authenKey.imm,
p_ShrDescParam->authenKey.size,
p_ShrDescParam->authenKey.p_Data,
p_ShrDescParam->cipherAlg,
p_DecapParam);
return CreateDescObject(p_SecDcl,length,buffer);
}
t_Handle SEC_DCL_InitMacsecEncapShrDesc(t_Handle h_SecDcl,
t_MacsecShrDescParam* p_ShrDescParam,
t_MacsecEncapParam* p_EncapParam)
{
t_SecDcl* p_SecDcl = (t_SecDcl*)h_SecDcl;
uint32_t length;
uint32_t buffer[MAX_DESC_LENGTH];
/* Using MAX_DESC_LENGTH instead of MaxShrDescLen in order to keep it simple */
SANITY_CHECK_EXIT(p_SecDcl,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_ShrDescParam,E_NULL_POINTER);
SANITY_CHECK_EXIT(p_EncapParam,E_NULL_POINTER);
length = InitMacsecEncapShrDesc(buffer,
p_SecDcl->ptrSize,
p_ShrDescParam->dataMoveSize,
p_ShrDescParam->cipherKey.imm,
p_ShrDescParam->cipherKey.size,
p_ShrDescParam->cipherKey.p_Data,
p_ShrDescParam->cipherAlg,
p_EncapParam);
return CreateDescObject(p_SecDcl,length,buffer);
}
t_Handle SEC_DCL_InitMacsecDecapShrDesc(t_Handle h_SecDcl,
t_MacsecShrDescParam* p_ShrDescParam,
t_MacsecDecapParam* p_DecapParam)
{
t_SecDcl* p_SecDcl = (t_SecDcl*)h_SecDcl;
uint32_t length;
uint32_t buffer[MAX_DESC_LENGTH];
/* Using MAX_DESC_LENGTH instead of MaxShrDescLen in order to keep it simple */
SANITY_CHECK_EXIT(p_SecDcl,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_ShrDescParam,E_NULL_POINTER);
SANITY_CHECK_EXIT(p_DecapParam,E_NULL_POINTER);
length = InitMacsecDecapShrDesc(buffer,
p_SecDcl->ptrSize,
p_ShrDescParam->dataMoveSize,
p_ShrDescParam->cipherKey.imm,
p_ShrDescParam->cipherKey.size,
p_ShrDescParam->cipherKey.p_Data,
p_ShrDescParam->cipherAlg,
p_DecapParam);
return CreateDescObject(p_SecDcl,length,buffer);
}
uint8_t* SEC_DCL_GetDescPrefix(t_Handle h_Desc)
{
t_Desc* p_Desc = (t_Desc*)h_Desc;
SANITY_CHECK_EXIT(p_Desc,E_INVALID_HANDLE);
return p_Desc->p_Prefix;
}
uint8_t* SEC_DCL_GetDescBuffer(t_Handle h_Desc)
{
t_Desc* p_Desc = (t_Desc*)h_Desc;
SANITY_CHECK_EXIT(p_Desc,E_INVALID_HANDLE);
return p_Desc->p_Buffer;
}
uint8_t* SEC_DCL_GetDescPostfix(t_Handle h_Desc)
{
t_Desc* p_Desc = (t_Desc*)h_Desc;
SANITY_CHECK_EXIT(p_Desc,E_INVALID_HANDLE);
return p_Desc->p_Postfix;
}
uint32_t SEC_DCL_GetBufferSize(t_Handle h_Desc)
{
t_Desc* p_Desc = (t_Desc*)h_Desc;
SANITY_CHECK_EXIT(p_Desc,E_INVALID_HANDLE);
return p_Desc->bufferSize;
}
void SEC_DCL_FreeDesc(t_Handle h_Desc)
{
t_Desc* p_Desc = (t_Desc*)h_Desc;
SANITY_CHECK_EXIT(p_Desc,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_Desc->p_Mem,E_INVALID_STATE);
/* wind river start */
#ifdef SEC4_PREALLOC_DESC_BUF
/* Use pre allocated buffer pools for increased performance */
/* Return to pre-allocated buffer pool*/
MEM_Put(p_Desc->h_SecMemSmart, p_Desc->p_Mem);
MEM_Put(p_Desc->h_SecMem, p_Desc);
#else
XX_FreeSmart(p_Desc->p_Mem);
#ifdef SEC4_USE_QI
XX_FreeSmart(p_Desc);
#else
XX_Free(p_Desc);
#endif
#endif
/* wind river end */
}
/* Runtime Control Unit (above) */
/********************************/
/*****************************/
/* Internal Routines (below) */
static t_Error CheckInitParameters(t_SecDcl* p_SecDcl)
{
if (p_SecDcl->p_DriverParam->h_Sec == NULL)
RETURN_ERROR(MAJOR,E_INVALID_HANDLE,("SEC object"));
if (p_SecDcl->p_DriverParam->alignment % sizeof(uint32_t))
RETURN_ERROR(MAJOR,E_INVALID_VALUE,("Descriptor buffer alignment must a multiple of %u",sizeof(uint32_t)));
if (!IN_RANGE(MIN_VAL_alignment,p_SecDcl->p_DriverParam->alignment,MAX_VAL_alignment))
RETURN_ERROR(MAJOR,E_NOT_IN_RANGE,("Descriptor buffer alignment must be between %u and %u",MIN_VAL_alignment,MAX_VAL_alignment));
return E_OK;
}
/* static */ /* wind river */
t_Handle CreateDescObject(t_SecDcl* p_SecDcl,uint32_t length,uint32_t* p_Buffer)
{
t_Desc* p_Desc;
int memId = p_SecDcl->memId ;
uint32_t alignment = p_SecDcl->alignment ;
uint32_t prefixSize = p_SecDcl->prefixSize ;
uint32_t postfixSize = p_SecDcl->postfixSize;
uint32_t bufferSize = length*sizeof(uint32_t);
uint32_t newAlignment = DIV_CEIL(prefixSize,alignment)*alignment;
/* [newAlignment >= prefixSize] AND [newAlignment == N*alignment] */
/* wind river start */
#ifdef SEC4_PREALLOC_DESC_BUF
t_Handle h_Mem;
/* Use pre allocated buffers for increased performance */
#ifdef SEC4_USE_QI
/* Allocate job descriptor objects from shared memory as well so that any core can release it
* E.g. shared descriptors */
p_Desc = MEM_Get(p_SecDcl->h_SecMemSmart);
h_Mem = p_SecDcl->h_SecMemSmart;
#else
p_Desc = MEM_Get(p_SecDcl->h_SecMem);
h_Mem = p_SecDcl->h_SecMem;
#endif /* #ifdef SEC4_USE_QI */
#else
#ifdef SEC4_USE_QI
/* Allocate job descriptor objects from shared memory as well so that any core can release it
* E.g. shared descriptors */
p_Desc = XX_MallocSmart(sizeof(t_Desc), memId, alignment);
#else
p_Desc = XX_Malloc(sizeof(t_Desc));
#endif /* #ifdef SEC4_USE_QI */
#endif /* #ifdef SEC4_PREALLOC_DESC_BUF */
/* wind river end */
if (p_Desc == NULL)
{
REPORT_ERROR(MAJOR,E_NO_MEMORY,("Descriptor object"));
return NULL;
}
/* wind river start */
#ifdef SEC4_PREALLOC_DESC_BUF
p_Desc->h_SecMem = h_Mem;
#endif /* #ifdef SEC4_PREALLOC_DESC_BUF */
/* wind river start */
#ifdef SEC4_PREALLOC_DESC_BUF
/* Use pre allocated buffers for increased performance */
p_Desc->p_Mem = MEM_Get(p_SecDcl->h_SecMemSmart);
h_Mem = p_SecDcl->h_SecMemSmart;
#else
p_Desc->p_Mem = XX_MallocSmart(newAlignment+bufferSize+postfixSize,memId,newAlignment);
#endif
/* wind river end */
if (p_Desc->p_Mem == NULL)
{
/* wind river start */
#ifdef SEC4_PREALLOC_DESC_BUF
MEM_Put(p_SecDcl->h_SecMem, p_Desc);
#else
XX_Free(p_Desc);
#endif
/* wind river end */
REPORT_ERROR(MAJOR,E_NO_MEMORY,("Descriptor buffer"));
return NULL;
}
/* wind river start */
#ifdef SEC4_PREALLOC_DESC_BUF
p_Desc->h_SecMemSmart = h_Mem;
#endif
/* wind river end */
p_Desc->p_Prefix = p_Desc->p_Mem+newAlignment-prefixSize;
p_Desc->p_Buffer = p_Desc->p_Mem+newAlignment;
p_Desc->p_Postfix = p_Desc->p_Mem+newAlignment+bufferSize;
p_Desc->bufferSize = bufferSize;
memcpy(p_Desc->p_Buffer,p_Buffer,bufferSize);
return (t_Handle)p_Desc;
}
/* Internal Routines (above) */
/*****************************/
@@ -0,0 +1,83 @@
/******************************************************************************
� 1995-2003, 2004, 2005-2010 Freescale Semiconductor, Inc.
All rights reserved.
This is proprietary source code of Freescale Semiconductor Inc.,
and its use is subject to the NetComm Device Drivers EULA.
The copyright notice above does not evidence any actual or intended
publication of such source code.
**************************************************************************/
#ifndef __SEC_DCL_H
#define __SEC_DCL_H
#include "sec_dcl_ext.h"
typedef struct t_SecDclDriverParam
{
t_Handle h_Sec ; /* SEC object */
int memId ; /* Memory partition ID */
uint32_t alignment ; /* Alignment of each descriptor buffer */
uint32_t prefixSize ; /* Size of data preceding each descriptor buffer */
uint32_t postfixSize; /* Size of data succeeding each descriptor buffer */
/* wind river start */
#ifdef SEC4_PREALLOC_DESC_BUF
uint32_t noofBuf ; /* Number of allocated descriptor objects */
uint32_t descSize ; /* Size of data for descriptor objects */
uint32_t descBufSize; /* Size of data for descriptor buffers */
#endif
/* wind river end */
}
t_SecDclDriverParam;
typedef struct t_SecDcl
{
t_SecDclDriverParam* p_DriverParam; /* Driver parameters */
uint32_t ptrSize ; /* SEC pointer size */
int memId ; /* Memory partition ID */
uint32_t alignment ; /* Alignment of each descriptor buffer */
uint32_t prefixSize ; /* Size of data preceding each descriptor buffer */
uint32_t postfixSize; /* Size of data succeeding each descriptor buffer */
/* wind river start */
#ifdef SEC4_PREALLOC_DESC_BUF
uint32_t noofBuf ; /* Number of allocated descriptor objects */
uint32_t descSize ; /* Size of data for descriptor objects */
uint32_t descBufSize; /* Size of data for descriptor buffers */
t_Handle h_SecMem ; /* Handle for pre-allocated memory for descriptor objects */
t_Handle h_SecMemSmart; /* Handle for pre-allocated memory for descriptor buffers */
#endif
/* wind river end */
}
t_SecDcl;
typedef struct t_Desc
{
uint8_t* p_Mem ; /* Pointer to allocated memory */
uint8_t* p_Prefix ; /* Pointer to data preceding the descriptor buffer */
uint8_t* p_Buffer ; /* Pointer to the descriptor buffer */
uint8_t* p_Postfix ; /* Pointer to data succeeding the descriptor buffer */
uint32_t bufferSize; /* Size of the descriptor buffer */
/* wind river start */
#ifdef SEC4_PREALLOC_DESC_BUF
t_Handle h_SecMem ; /* Handle for pre-allocated memory for descriptor objects */
t_Handle h_SecMemSmart; /* Handle for pre-allocated memory for descriptor buffers */
#endif
/* wind river end */
}
t_Desc;
/* wind river start */
t_Handle CreateDescObject(t_SecDcl* p_SecDcl,uint32_t length,uint32_t* p_Buffer);
/* wind river end */
#define MIN_VAL_alignment 4
#define MAX_VAL_alignment 256
#endif /* __SEC_DCL_H */
@@ -0,0 +1,774 @@
/******************************************************************************
� 1995-2003, 2004, 2005-2010 Freescale Semiconductor, Inc.
All rights reserved.
This is proprietary source code of Freescale Semiconductor Inc.,
and its use is subject to the NetComm Device Drivers EULA.
The copyright notice above does not evidence any actual or intended
publication of such source code.
**************************************************************************/
/* Include the internal definitions of this module */
#include "sec_dcl_api.h"
#include "sec_dcl_cmd.h"
/* Include the external interfaces of other modules */
#include "error_ext.h"
#include "string_ext.h"
#define EXIT_IF(cond) ASSERT_COND(!(cond))
#define KEY_IMM_IF(cond) (uint32_t)((cond)? KEY_IMM:0)
static inline uint32_t CalcSplitKeyCmdFlags(e_SplitKeyHashAlg hashAlg);
static inline uint32_t CalcIpsecCmdFlags(uint32_t initFlags,
e_IpsecCryptoAlg cryptoAlg,
e_IpsecAuthenAlg authenAlg);
static inline uint32_t CalcDtlsCmdFlags(uint32_t initFlags,
e_DtlsCipherAlg cipherAlg);
static inline uint32_t CalcMacsecCmdFlags(uint32_t initFlags,
e_MacsecCipherAlg cipherAlg);
static inline void InsertDataMoveCommands(t_DescHandle* p_DescHandle,
uint32_t dataMoveSize);
static inline void InsertNopCommands(t_DescHandle* p_DescHandle,
uint32_t numOfCommands);
uint32_t MaxJobDescLen()
{
return MAX_DESC_LENGTH;
}
uint32_t MaxShrDescLen(uint32_t ptrSize)
{
return MAX_DESC_LENGTH-1-ptrSize/sizeof(uint32_t);
}
uint32_t InitSeqJobDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t* p_ShrDesc,
bool inputSeqSgt,
uint32_t inputSeqSize,
uint8_t* p_InputSeqData,
bool outputSeqSgt,
uint32_t outputSeqSize,
uint8_t* p_OutputSeqData)
{
t_DescHandle descHandle = NewDescHandle(p_Desc,ptrSize);
uint32_t cmdFlags;
cmdFlags = JOB_DESC_HDR_REO|JOB_DESC_HDR_SHARE_DEFER;
CmdInsertJobDescRefShrHdr(&descHandle,cmdFlags,p_ShrDesc);
cmdFlags = (uint32_t)(outputSeqSgt? SEQ_OUT_PTR_SGT:NO_CMD_FLAGS);
CmdInsertSeqOutPtr(&descHandle,cmdFlags,outputSeqSize,p_OutputSeqData);
cmdFlags = (uint32_t)(inputSeqSgt? SEQ_IN_PTR_SGT:NO_CMD_FLAGS);
CmdInsertSeqInPtr(&descHandle,cmdFlags,inputSeqSize,p_InputSeqData);
CloseJobDescRefShr(&descHandle,p_ShrDesc);
return descHandle.nextIndex;
}
uint32_t InitSplitKeyJobDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint8_t* p_InputKey,
uint8_t* p_OutputKey,
e_SplitKeyHashAlg hashAlg)
{
t_DescHandle descHandle = NewDescHandle(p_Desc,ptrSize);
uint32_t inputSize [] = {16,20,28,32, 48, 64};
uint32_t outputSize[] = {32,40,64,64,128,128};
uint32_t cmdFlags;
uint32_t startIndex;
cmdFlags = JOB_DESC_HDR_SHARE_NEVER;
CmdInsertJobDescHdr(&descHandle,cmdFlags);
startIndex = descHandle.nextIndex;
cmdFlags = KEY_CLASS_2_DST_REGISTER;
CmdInsertKey(&descHandle,cmdFlags,inputSize[hashAlg],p_InputKey);
cmdFlags = CalcSplitKeyCmdFlags(hashAlg);
CmdInsertAlgOperation(&descHandle,cmdFlags);
/* FIFO load of 0 bytes in order to kickstart MDHA */
cmdFlags = FIFO_LOAD_CTYPE|FIFO_LOAD_CLASS_2_TYPE_MSG_L2|FIFO_LOAD_IMM;
CmdInsertAnything(&descHandle,cmdFlags);
cmdFlags = FIFO_STORE_CLASS_2_TYPE_MDHA_SPLIT_ECB_JKEK;
CmdInsertFifoStore(&descHandle,cmdFlags,outputSize[hashAlg],p_OutputKey);
CloseJobDesc(&descHandle,startIndex);
return descHandle.nextIndex;
}
uint32_t InitIpsecEncapShrDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t dataMoveSize,
bool cryptoKeyImm,
uint32_t cryptoKeySize,
uint8_t* p_CryptoKeyData,
bool authenKeyImm,
uint32_t authenKeySize,
uint8_t* p_AuthenKeyData,
e_IpsecCryptoAlg cryptoAlg,
e_IpsecAuthenAlg authenAlg,
t_IpsecEncapParam* p_Param)
{
t_DescHandle descHandle = NewDescHandle(p_Desc,ptrSize);
uint32_t cmdFlags;
uint32_t startIndex;
uint32_t jumpCmdIndex;
t_IpsecEncapPdb pdb;
memset(&pdb,0,sizeof(pdb));
pdb.nextHdr = p_Param->nextHdr ;
pdb.nhOffset = p_Param->nhOffset;
pdb.seqNum = p_Param->seqNum ;
pdb.spi = p_Param->spi ;
pdb.ipHdrLen = p_Param->ipHdrLen;
if (p_Param->copyDf)
pdb.nextHdr |= IPSEC_ENCAP_HMO_DFC;
if (p_Param->decTtl)
pdb.nextHdr |= IPSEC_ENCAP_HMO_DTTL;
if (p_Param->enCksm)
pdb.options |= IPSEC_ENCAP_OPTION_CKSM;
if (p_Param->copyDs)
pdb.options |= IPSEC_ENCAP_OPTION_DSC;
if (p_Param->randIv)
pdb.options |= IPSEC_ENCAP_OPTION_IVSRC;
if (p_Param->extSeqNum)
pdb.options |= IPSEC_ENCAP_OPTION_ESN;
switch (p_Param->ipsecVer)
{
case e_IPSEC_VER_4:
break;
case e_IPSEC_VER_6:
pdb.options |= IPSEC_ENCAP_OPTION_IPV6;
break;
}
switch (p_Param->ipsecHdr)
{
case e_IPSEC_HDR_NONE:
break;
case e_IPSEC_HDR_IN_FRAME:
pdb.options |= IPSEC_ENCAP_OPTION_INC;
break;
case e_IPSEC_HDR_IN_PARAM:
pdb.options |= IPSEC_ENCAP_OPTION_INC;
pdb.options |= IPSEC_ENCAP_OPTION_SRC;
break;
}
switch (p_Param->ipsecMode)
{
case e_IPSEC_MODE_TRANSPORT:
break;
case e_IPSEC_MODE_TUNNEL:
pdb.options |= IPSEC_ENCAP_OPTION_TUNNEL;
break;
}
switch (p_Param->ipsecType)
{
case e_IPSEC_TYPE_CBC:
memcpy((void*)pdb.alg.cbc.iv,p_Param->alg.cbc.iv,16);
break;
case e_IPSEC_TYPE_CTR:
pdb.alg.ctr.nonce = p_Param->alg.ctr.nonce ;
pdb.alg.ctr.initCount = p_Param->alg.ctr.initCount;
memcpy((void*)pdb.alg.ctr.iv,p_Param->alg.ctr.iv,8);
break;
case e_IPSEC_TYPE_CCM:
pdb.alg.ccm.salt = p_Param->alg.ccm.salt ;
pdb.alg.ccm.b0Flags = p_Param->alg.ccm.b0Flags ;
pdb.alg.ccm.ctrFlags = p_Param->alg.ccm.ctrFlags ;
pdb.alg.ccm.initCount = p_Param->alg.ccm.initCount;
memcpy((void*)pdb.alg.ccm.iv,p_Param->alg.ccm.iv,8);
break;
case e_IPSEC_TYPE_GCM:
pdb.alg.gcm.salt = p_Param->alg.gcm.salt;
memcpy((void*)pdb.alg.gcm.iv,p_Param->alg.gcm.iv,8);
break;
}
EXIT_IF(p_Param->ipsecMode==e_IPSEC_MODE_TUNNEL && p_Param->nhOffset!=0);
EXIT_IF(p_Param->extSeqNum==FALSE && p_Param->seqNum>=0x00000000FFFFFFFFLL);
EXIT_IF(p_Param->extSeqNum!=FALSE && p_Param->seqNum==0xFFFFFFFFFFFFFFFFLL);
EXIT_IF(p_Param->ipsecHdr==e_IPSEC_HDR_NONE && (p_Param->ipHdrLen!=0 || p_Param->p_IpHdr!=NULL));
EXIT_IF(p_Param->ipsecHdr==e_IPSEC_HDR_IN_FRAME && (p_Param->ipHdrLen==0 || p_Param->p_IpHdr!=NULL));
EXIT_IF(p_Param->ipsecHdr==e_IPSEC_HDR_IN_PARAM && (p_Param->ipHdrLen==0 || p_Param->p_IpHdr==NULL));
cmdFlags = SHR_DESC_HDR_SC|SHR_DESC_HDR_SHARE_SERIAL;
CmdInsertShrDescHdr(&descHandle,cmdFlags);
CmdInsertDataBlock(&descHandle,sizeof(pdb),(uint8_t*)&pdb);
if (p_Param->ipsecHdr == e_IPSEC_HDR_IN_PARAM)
CmdInsertDataBlock(&descHandle,p_Param->ipHdrLen,p_Param->p_IpHdr);
startIndex = descHandle.nextIndex;
if (dataMoveSize > 0)
InsertDataMoveCommands(&descHandle,dataMoveSize);
jumpCmdIndex = descHandle.nextIndex;
cmdFlags = JUMP_CLASS_BOTH|JUMP_SL_1|JUMP_TEST_ALL_MATCH|JUMP_COND_SL_1_SHRD;
CmdInsertLocalJump(&descHandle,cmdFlags);
cmdFlags = KEY_CLASS_2_DST_REGISTER|KEY_IMM_IF(authenKeyImm);
CmdInsertKey(&descHandle,cmdFlags,authenKeySize,p_AuthenKeyData);
cmdFlags = KEY_CLASS_1_DST_REGISTER|KEY_IMM_IF(cryptoKeyImm);
CmdInsertKey(&descHandle,cmdFlags,cryptoKeySize,p_CryptoKeyData);
CmdUpdateLocalJump(&descHandle,jumpCmdIndex);
cmdFlags = CalcIpsecCmdFlags(PCL_OP_TYPE_ENCAP_ID_IPSEC,cryptoAlg,authenAlg);
CmdInsertPclOperation(&descHandle,cmdFlags);
CloseShrDesc(&descHandle,startIndex);
return descHandle.nextIndex;
}
uint32_t InitIpsecDecapShrDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t dataMoveSize,
bool cryptoKeyImm,
uint32_t cryptoKeySize,
uint8_t* p_CryptoKeyData,
bool authenKeyImm,
uint32_t authenKeySize,
uint8_t* p_AuthenKeyData,
e_IpsecCryptoAlg cryptoAlg,
e_IpsecAuthenAlg authenAlg,
t_IpsecDecapParam* p_Param)
{
t_DescHandle descHandle = NewDescHandle(p_Desc,ptrSize);
uint32_t cmdFlags;
uint32_t startIndex;
uint32_t jumpCmdIndex;
t_IpsecDecapPdb pdb;
memset(&pdb,0,sizeof(pdb));
pdb.ipHdrLen = p_Param->ipHdrLen;
pdb.nhOffset = p_Param->nhOffset;
pdb.seqNum = p_Param->seqNum ;
if (p_Param->decTtl)
pdb.ipHdrLen |= IPSEC_DECAP_HMO_DTTL;
if (p_Param->copyDs)
pdb.ipHdrLen |= IPSEC_DECAP_HMO_DSC;
if (p_Param->enCksm)
pdb.options |= IPSEC_DECAP_OPTION_CKSM;
if (p_Param->extSeqNum)
pdb.options |= IPSEC_DECAP_OPTION_ESN;
if (p_Param->outFmt)
pdb.options |= IPSEC_DECAP_OPTION_FMT;
switch (p_Param->ipsecArs)
{
case e_IPSEC_ARS_0:
break;
case e_IPSEC_ARS_32:
pdb.options |= IPSEC_DECAP_OPTION_ARS32;
break;
case e_IPSEC_ARS_64:
pdb.options |= IPSEC_DECAP_OPTION_ARS64;
break;
}
switch (p_Param->ipsecVer)
{
case e_IPSEC_VER_4:
break;
case e_IPSEC_VER_6:
pdb.options |= IPSEC_DECAP_OPTION_IPV6;
break;
}
switch (p_Param->ipsecMode)
{
case e_IPSEC_MODE_TRANSPORT:
break;
case e_IPSEC_MODE_TUNNEL:
pdb.options |= IPSEC_DECAP_OPTION_TUNNEL;
break;
}
switch (p_Param->ipsecType)
{
case e_IPSEC_TYPE_CBC:
break;
case e_IPSEC_TYPE_CTR:
pdb.alg.ctr.salt = p_Param->alg.ctr.salt ;
pdb.alg.ctr.initCount = p_Param->alg.ctr.initCount;
break;
case e_IPSEC_TYPE_CCM:
pdb.alg.ccm.salt = p_Param->alg.ccm.salt ;
pdb.alg.ccm.ivFlags = p_Param->alg.ccm.ivFlags ;
pdb.alg.ccm.ctrFlags = p_Param->alg.ccm.ctrFlags ;
pdb.alg.ccm.initCount = p_Param->alg.ccm.initCount;
break;
case e_IPSEC_TYPE_GCM:
pdb.alg.gcm.salt = p_Param->alg.gcm.salt;
break;
}
EXIT_IF(p_Param->ipsecMode==e_IPSEC_MODE_TUNNEL && p_Param->nhOffset!=0);
EXIT_IF(p_Param->extSeqNum==FALSE && p_Param->seqNum>=0x00000000FFFFFFFFLL);
EXIT_IF(p_Param->extSeqNum!=FALSE && p_Param->seqNum==0xFFFFFFFFFFFFFFFFLL);
cmdFlags = SHR_DESC_HDR_SC|SHR_DESC_HDR_SHARE_SERIAL;
CmdInsertShrDescHdr(&descHandle,cmdFlags);
CmdInsertDataBlock(&descHandle,sizeof(pdb),(uint8_t*)&pdb);
startIndex = descHandle.nextIndex;
if (dataMoveSize > 0)
InsertDataMoveCommands(&descHandle,dataMoveSize);
jumpCmdIndex = descHandle.nextIndex;
cmdFlags = JUMP_CLASS_BOTH|JUMP_SL_1|JUMP_TEST_ALL_MATCH|JUMP_COND_SL_1_SHRD;
CmdInsertLocalJump(&descHandle,cmdFlags);
cmdFlags = KEY_CLASS_2_DST_REGISTER|KEY_IMM_IF(authenKeyImm);
CmdInsertKey(&descHandle,cmdFlags,authenKeySize,p_AuthenKeyData);
cmdFlags = KEY_CLASS_1_DST_REGISTER|KEY_IMM_IF(cryptoKeyImm);
CmdInsertKey(&descHandle,cmdFlags,cryptoKeySize,p_CryptoKeyData);
CmdUpdateLocalJump(&descHandle,jumpCmdIndex);
cmdFlags = CalcIpsecCmdFlags(PCL_OP_TYPE_DECAP_ID_IPSEC,cryptoAlg,authenAlg);
CmdInsertPclOperation(&descHandle,cmdFlags);
CloseShrDesc(&descHandle,startIndex);
return descHandle.nextIndex;
}
uint32_t InitDtlsEncapShrDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t dataMoveSize,
bool cryptoKeyImm,
uint32_t cryptoKeySize,
uint8_t* p_CryptoKeyData,
bool authenKeyImm,
uint32_t authenKeySize,
uint8_t* p_AuthenKeyData,
e_DtlsCipherAlg cipherAlg,
t_DtlsEncapParam* p_Param)
{
t_DescHandle descHandle = NewDescHandle(p_Desc,ptrSize);
uint32_t cmdFlags;
uint32_t startIndex;
uint32_t jumpCmdIndex;
t_DtlsEncapPdb pdb;
memset(&pdb,0,sizeof(pdb));
pdb.type = p_Param->type ;
pdb.version = p_Param->version;
pdb.epoch = p_Param->epoch ;
if (p_Param->wbIv)
pdb.options |= DTLS_ENCAP_OPTION_W_B;
if (p_Param->expIv)
pdb.options |= DTLS_ENCAP_OPTION_E_I;
pdb.seqNum1 = DTLS_ENCAP_SEQ_NUM_1(p_Param->seqNum);
pdb.seqNum2 = DTLS_ENCAP_SEQ_NUM_2(p_Param->seqNum);
memcpy((void*)pdb.iv,p_Param->iv,16);
EXIT_IF(p_Param->seqNum >= 0x0000FFFFFFFFFFFFLL);
cmdFlags = SHR_DESC_HDR_SC|SHR_DESC_HDR_SHARE_SERIAL;
CmdInsertShrDescHdr(&descHandle,cmdFlags);
CmdInsertDataBlock(&descHandle,sizeof(pdb),(uint8_t*)&pdb);
startIndex = descHandle.nextIndex;
if (dataMoveSize > 0)
InsertDataMoveCommands(&descHandle,dataMoveSize);
jumpCmdIndex = descHandle.nextIndex;
cmdFlags = JUMP_CLASS_BOTH|JUMP_SL_1|JUMP_TEST_ALL_MATCH|JUMP_COND_SL_1_SHRD;
CmdInsertLocalJump(&descHandle,cmdFlags);
cmdFlags = KEY_CLASS_2_DST_REGISTER|KEY_IMM_IF(authenKeyImm);
CmdInsertKey(&descHandle,cmdFlags,authenKeySize,p_AuthenKeyData);
cmdFlags = KEY_CLASS_1_DST_REGISTER|KEY_IMM_IF(cryptoKeyImm);
CmdInsertKey(&descHandle,cmdFlags,cryptoKeySize,p_CryptoKeyData);
CmdUpdateLocalJump(&descHandle,jumpCmdIndex);
cmdFlags = CalcDtlsCmdFlags(PCL_OP_TYPE_ENCAP_ID_DTLS,cipherAlg);
CmdInsertPclOperation(&descHandle,cmdFlags);
CloseShrDesc(&descHandle,startIndex);
return descHandle.nextIndex;
}
uint32_t InitDtlsDecapShrDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t dataMoveSize,
bool cryptoKeyImm,
uint32_t cryptoKeySize,
uint8_t* p_CryptoKeyData,
bool authenKeyImm,
uint32_t authenKeySize,
uint8_t* p_AuthenKeyData,
e_DtlsCipherAlg cipherAlg,
t_DtlsDecapParam* p_Param)
{
t_DescHandle descHandle = NewDescHandle(p_Desc,ptrSize);
uint32_t cmdFlags;
uint32_t startIndex;
uint32_t jumpCmdIndex;
t_DtlsDecapPdb pdb;
memset(&pdb,0,sizeof(pdb));
pdb.epoch = p_Param->epoch;
if (p_Param->wbIv)
pdb.options |= DTLS_DECAP_OPTION_W_B;
if (p_Param->expIv)
pdb.options |= DTLS_DECAP_OPTION_E_I;
pdb.seqNum1 = DTLS_DECAP_SEQ_NUM_1(p_Param->seqNum);
pdb.seqNum2 = DTLS_DECAP_SEQ_NUM_2(p_Param->seqNum);
memcpy((void*)pdb.iv,p_Param->iv,16);
switch (p_Param->dtlsArs)
{
case e_DTLS_ARS_0:
break;
case e_DTLS_ARS_32:
pdb.options |= DTLS_DECAP_OPTION_ARS32;
break;
case e_DTLS_ARS_64:
pdb.options |= DTLS_DECAP_OPTION_ARS64;
break;
}
EXIT_IF(p_Param->seqNum >= 0x0000FFFFFFFFFFFFLL);
cmdFlags = SHR_DESC_HDR_SC|SHR_DESC_HDR_SHARE_SERIAL;
CmdInsertShrDescHdr(&descHandle,cmdFlags);
CmdInsertDataBlock(&descHandle,sizeof(pdb),(uint8_t*)&pdb);
startIndex = descHandle.nextIndex;
if (dataMoveSize > 0)
InsertDataMoveCommands(&descHandle,dataMoveSize);
jumpCmdIndex = descHandle.nextIndex;
cmdFlags = JUMP_CLASS_BOTH|JUMP_SL_1|JUMP_TEST_ALL_MATCH|JUMP_COND_SL_1_SHRD;
CmdInsertLocalJump(&descHandle,cmdFlags);
cmdFlags = KEY_CLASS_2_DST_REGISTER|KEY_IMM_IF(authenKeyImm);
CmdInsertKey(&descHandle,cmdFlags,authenKeySize,p_AuthenKeyData);
cmdFlags = KEY_CLASS_1_DST_REGISTER|KEY_IMM_IF(cryptoKeyImm);
CmdInsertKey(&descHandle,cmdFlags,cryptoKeySize,p_CryptoKeyData);
CmdUpdateLocalJump(&descHandle,jumpCmdIndex);
cmdFlags = CalcDtlsCmdFlags(PCL_OP_TYPE_DECAP_ID_DTLS,cipherAlg);
CmdInsertPclOperation(&descHandle,cmdFlags);
CloseShrDesc(&descHandle,startIndex);
return descHandle.nextIndex;
}
uint32_t InitMacsecEncapShrDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t dataMoveSize,
bool cipherKeyImm,
uint32_t cipherKeySize,
uint8_t* p_CipherKeyData,
e_MacsecCipherAlg cipherAlg,
t_MacsecEncapParam* p_Param)
{
t_DescHandle descHandle = NewDescHandle(p_Desc,ptrSize);
uint32_t cmdFlags;
uint32_t startIndex;
uint32_t jumpCmdIndex;
t_MacsecEncapPdb pdb;
memset(&pdb,0,sizeof(pdb));
pdb.aadLength = p_Param->aadLength;
pdb.sci = p_Param->sci ;
pdb.etherType = p_Param->etherType;
pdb.tciAn = p_Param->tciAn ;
pdb.pn = p_Param->pn ;
cmdFlags = SHR_DESC_HDR_SC|SHR_DESC_HDR_SHARE_SERIAL;
CmdInsertShrDescHdr(&descHandle,cmdFlags);
CmdInsertDataBlock(&descHandle,sizeof(pdb),(uint8_t*)&pdb);
startIndex = descHandle.nextIndex;
if (dataMoveSize > 0)
InsertDataMoveCommands(&descHandle,dataMoveSize);
jumpCmdIndex = descHandle.nextIndex;
cmdFlags = JUMP_CLASS_1|JUMP_SL_1|JUMP_TEST_ALL_MATCH|JUMP_COND_SL_1_SHRD;
CmdInsertLocalJump(&descHandle,cmdFlags);
cmdFlags = KEY_CLASS_1_DST_REGISTER|KEY_IMM_IF(cipherKeyImm);
CmdInsertKey(&descHandle,cmdFlags,cipherKeySize,p_CipherKeyData);
CmdUpdateLocalJump(&descHandle,jumpCmdIndex);
cmdFlags = CalcMacsecCmdFlags(PCL_OP_TYPE_ENCAP_ID_MACSEC,cipherAlg);
CmdInsertPclOperation(&descHandle,cmdFlags);
CloseShrDesc(&descHandle,startIndex);
return descHandle.nextIndex;
}
uint32_t InitMacsecDecapShrDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t dataMoveSize,
bool cipherKeyImm,
uint32_t cipherKeySize,
uint8_t* p_CipherKeyData,
e_MacsecCipherAlg cipherAlg,
t_MacsecDecapParam* p_Param)
{
t_DescHandle descHandle = NewDescHandle(p_Desc,ptrSize);
uint32_t cmdFlags;
uint32_t startIndex;
uint32_t jumpCmdIndex;
t_MacsecDecapPdb pdb;
memset(&pdb,0,sizeof(pdb));
pdb.aadLength = p_Param->aadLength;
pdb.sci = p_Param->sci ;
pdb.arLen = p_Param->arLen ;
pdb.pn = p_Param->pn ;
if (p_Param->enAr)
pdb.options |= MACSEC_DECAP_OPTION_AR;
cmdFlags = SHR_DESC_HDR_SC|SHR_DESC_HDR_SHARE_SERIAL;
CmdInsertShrDescHdr(&descHandle,cmdFlags);
CmdInsertDataBlock(&descHandle,sizeof(pdb),(uint8_t*)&pdb);
startIndex = descHandle.nextIndex;
if (dataMoveSize > 0)
InsertDataMoveCommands(&descHandle,dataMoveSize);
jumpCmdIndex = descHandle.nextIndex;
cmdFlags = JUMP_CLASS_1|JUMP_SL_1|JUMP_TEST_ALL_MATCH|JUMP_COND_SL_1_SHRD;
CmdInsertLocalJump(&descHandle,cmdFlags);
cmdFlags = KEY_CLASS_1_DST_REGISTER|KEY_IMM_IF(cipherKeyImm);
CmdInsertKey(&descHandle,cmdFlags,cipherKeySize,p_CipherKeyData);
CmdUpdateLocalJump(&descHandle,jumpCmdIndex);
cmdFlags = CalcMacsecCmdFlags(PCL_OP_TYPE_DECAP_ID_MACSEC,cipherAlg);
CmdInsertPclOperation(&descHandle,cmdFlags);
CloseShrDesc(&descHandle,startIndex);
return descHandle.nextIndex;
}
static inline uint32_t CalcSplitKeyCmdFlags(e_SplitKeyHashAlg hashAlg)
{
uint32_t cmdFlags = ALG_OP_TYPE_CLASS_2|ALG_OP_AAI_MDS_SHA_HMAC|ALG_OP_AS_INIT|ALG_OP_DIR_DEC;
switch (hashAlg)
{
case e_SPLIT_KEY_HASH_ALG_MD5 : cmdFlags |= ALG_OP_ID_MD5 ; break;
case e_SPLIT_KEY_HASH_ALG_SHA1 : cmdFlags |= ALG_OP_ID_SHA1 ; break;
case e_SPLIT_KEY_HASH_ALG_SHA2_224: cmdFlags |= ALG_OP_ID_SHA2_224; break;
case e_SPLIT_KEY_HASH_ALG_SHA2_256: cmdFlags |= ALG_OP_ID_SHA2_256; break;
case e_SPLIT_KEY_HASH_ALG_SHA2_384: cmdFlags |= ALG_OP_ID_SHA2_384; break;
case e_SPLIT_KEY_HASH_ALG_SHA2_512: cmdFlags |= ALG_OP_ID_SHA2_512; break;
}
return cmdFlags;
}
static inline uint32_t CalcIpsecCmdFlags(uint32_t initFlags,
e_IpsecCryptoAlg cryptoAlg,
e_IpsecAuthenAlg authenAlg)
{
uint32_t cmdFlags = initFlags;
switch (cryptoAlg)
{
case e_IPSEC_CRYPTO_ALG_DES : cmdFlags |= PCL_OP_INFO_IPSEC_DES ; break;
case e_IPSEC_CRYPTO_ALG_3DES : cmdFlags |= PCL_OP_INFO_IPSEC_3DES ; break;
case e_IPSEC_CRYPTO_ALG_NULL_ENC : cmdFlags |= PCL_OP_INFO_IPSEC_NULL_ENC ; break;
case e_IPSEC_CRYPTO_ALG_AES_CBC : cmdFlags |= PCL_OP_INFO_IPSEC_AES_CBC ; break;
case e_IPSEC_CRYPTO_ALG_AES_CTR : cmdFlags |= PCL_OP_INFO_IPSEC_AES_CTR ; break;
case e_IPSEC_CRYPTO_ALG_AES_CCM8 : cmdFlags |= PCL_OP_INFO_IPSEC_AES_CCM8 ; break;
case e_IPSEC_CRYPTO_ALG_AES_CCM12: cmdFlags |= PCL_OP_INFO_IPSEC_AES_CCM12; break;
case e_IPSEC_CRYPTO_ALG_AES_CCM16: cmdFlags |= PCL_OP_INFO_IPSEC_AES_CCM16; break;
case e_IPSEC_CRYPTO_ALG_AES_GCM8 : cmdFlags |= PCL_OP_INFO_IPSEC_AES_GCM8 ; break;
case e_IPSEC_CRYPTO_ALG_AES_GCM12: cmdFlags |= PCL_OP_INFO_IPSEC_AES_GCM12; break;
case e_IPSEC_CRYPTO_ALG_AES_GCM16: cmdFlags |= PCL_OP_INFO_IPSEC_AES_GCM16; break;
case e_IPSEC_CRYPTO_ALG_AES_GMAC : cmdFlags |= PCL_OP_INFO_IPSEC_AES_GMAC ; break;
case e_IPSEC_CRYPTO_ALG_AES_XTS : cmdFlags |= PCL_OP_INFO_IPSEC_AES_XTS ; break;
}
switch (authenAlg)
{
case e_IPSEC_AUTHEN_ALG_AES_CCM_GCM : cmdFlags |= PCL_OP_INFO_IPSEC_AES_CCM_GCM ; break;
case e_IPSEC_AUTHEN_ALG_HMAC_MD5_96 : cmdFlags |= PCL_OP_INFO_IPSEC_HMAC_MD5_96 ; break;
case e_IPSEC_AUTHEN_ALG_HMAC_SHA1_96 : cmdFlags |= PCL_OP_INFO_IPSEC_HMAC_SHA1_96 ; break;
case e_IPSEC_AUTHEN_ALG_AES_XCBC_MAC_96 : cmdFlags |= PCL_OP_INFO_IPSEC_AES_XCBC_MAC_96 ; break;
case e_IPSEC_AUTHEN_ALG_HMAC_MD5_128 : cmdFlags |= PCL_OP_INFO_IPSEC_HMAC_MD5_128 ; break;
case e_IPSEC_AUTHEN_ALG_HMAC_SHA1_160 : cmdFlags |= PCL_OP_INFO_IPSEC_HMAC_SHA1_160 ; break;
case e_IPSEC_AUTHEN_ALG_AES_CMAC_96 : cmdFlags |= PCL_OP_INFO_IPSEC_AES_CMAC_96 ; break;
case e_IPSEC_AUTHEN_ALG_HMAC_SHA2_256_128: cmdFlags |= PCL_OP_INFO_IPSEC_HMAC_SHA2_256_128; break;
case e_IPSEC_AUTHEN_ALG_HMAC_SHA2_384_192: cmdFlags |= PCL_OP_INFO_IPSEC_HMAC_SHA2_384_192; break;
case e_IPSEC_AUTHEN_ALG_HMAC_SHA2_512_256: cmdFlags |= PCL_OP_INFO_IPSEC_HMAC_SHA2_512_256; break;
}
return cmdFlags;
}
static inline uint32_t CalcDtlsCmdFlags(uint32_t initFlags,
e_DtlsCipherAlg cipherAlg)
{
uint32_t cmdFlags = initFlags;
switch (cipherAlg)
{
case e_DTLS_CIPHER_ALG_RC4_40_MD5 : cmdFlags |= PCL_OP_INFO_DTLS_RC4_40_MD5 ; break;
case e_DTLS_CIPHER_ALG_RC4_128_MD5 : cmdFlags |= PCL_OP_INFO_DTLS_RC4_128_MD5 ; break;
case e_DTLS_CIPHER_ALG_RC4_128_SHA : cmdFlags |= PCL_OP_INFO_DTLS_RC4_128_SHA ; break;
case e_DTLS_CIPHER_ALG_DES40_CBC_SHA : cmdFlags |= PCL_OP_INFO_DTLS_DES40_CBC_SHA ; break;
case e_DTLS_CIPHER_ALG_DES_CBC_SHA : cmdFlags |= PCL_OP_INFO_DTLS_DES_CBC_SHA ; break;
case e_DTLS_CIPHER_ALG_3DES_EDE_CBC_SHA : cmdFlags |= PCL_OP_INFO_DTLS_3DES_EDE_CBC_SHA ; break;
case e_DTLS_CIPHER_ALG_DES_CBC_MD5 : cmdFlags |= PCL_OP_INFO_DTLS_DES_CBC_MD5 ; break;
case e_DTLS_CIPHER_ALG_3DES_EDE_CBC_MD5 : cmdFlags |= PCL_OP_INFO_DTLS_3DES_EDE_CBC_MD5 ; break;
case e_DTLS_CIPHER_ALG_RC4_40_SHA : cmdFlags |= PCL_OP_INFO_DTLS_RC4_40_SHA ; break;
case e_DTLS_CIPHER_ALG_DES40_CBC_MD5 : cmdFlags |= PCL_OP_INFO_DTLS_DES40_CBC_MD5 ; break;
case e_DTLS_CIPHER_ALG_AES_128_CBC_SHA : cmdFlags |= PCL_OP_INFO_DTLS_AES_128_CBC_SHA ; break;
case e_DTLS_CIPHER_ALG_AES_256_CBC_SHA : cmdFlags |= PCL_OP_INFO_DTLS_AES_256_CBC_SHA ; break;
case e_DTLS_CIPHER_ALG_AES_128_CBC_SHA_256 : cmdFlags |= PCL_OP_INFO_DTLS_AES_128_CBC_SHA_256 ; break;
case e_DTLS_CIPHER_ALG_AES_256_CBC_SHA_256 : cmdFlags |= PCL_OP_INFO_DTLS_AES_256_CBC_SHA_256 ; break;
case e_DTLS_CIPHER_ALG_AES_192_CBC_SHA_160 : cmdFlags |= PCL_OP_INFO_DTLS_AES_192_CBC_SHA_160 ; break;
case e_DTLS_CIPHER_ALG_AES_192_CBC_SHA_384 : cmdFlags |= PCL_OP_INFO_DTLS_AES_192_CBC_SHA_384 ; break;
case e_DTLS_CIPHER_ALG_AES_192_CBC_SHA_224 : cmdFlags |= PCL_OP_INFO_DTLS_AES_192_CBC_SHA_224 ; break;
case e_DTLS_CIPHER_ALG_AES_192_CBC_SHA_512 : cmdFlags |= PCL_OP_INFO_DTLS_AES_192_CBC_SHA_512 ; break;
case e_DTLS_CIPHER_ALG_AES_192_CBC_SHA_256 : cmdFlags |= PCL_OP_INFO_DTLS_AES_192_CBC_SHA_256 ; break;
case e_DTLS_CIPHER_ALG_3DES_EDE_CBC_SHA_160: cmdFlags |= PCL_OP_INFO_DTLS_3DES_EDE_CBC_SHA_160; break;
case e_DTLS_CIPHER_ALG_3DES_EDE_CBC_SHA_384: cmdFlags |= PCL_OP_INFO_DTLS_3DES_EDE_CBC_SHA_384; break;
case e_DTLS_CIPHER_ALG_3DES_EDE_CBC_SHA_224: cmdFlags |= PCL_OP_INFO_DTLS_3DES_EDE_CBC_SHA_224; break;
case e_DTLS_CIPHER_ALG_3DES_EDE_CBC_SHA_512: cmdFlags |= PCL_OP_INFO_DTLS_3DES_EDE_CBC_SHA_512; break;
case e_DTLS_CIPHER_ALG_3DES_EDE_CBC_SHA_256: cmdFlags |= PCL_OP_INFO_DTLS_3DES_EDE_CBC_SHA_256; break;
case e_DTLS_CIPHER_ALG_AES_256_CBC_SHA_160 : cmdFlags |= PCL_OP_INFO_DTLS_AES_256_CBC_SHA_160 ; break;
case e_DTLS_CIPHER_ALG_AES_256_CBC_SHA_384 : cmdFlags |= PCL_OP_INFO_DTLS_AES_256_CBC_SHA_384 ; break;
case e_DTLS_CIPHER_ALG_AES_256_CBC_SHA_224 : cmdFlags |= PCL_OP_INFO_DTLS_AES_256_CBC_SHA_224 ; break;
case e_DTLS_CIPHER_ALG_AES_256_CBC_SHA_512 : cmdFlags |= PCL_OP_INFO_DTLS_AES_256_CBC_SHA_512 ; break;
case e_DTLS_CIPHER_ALG_AES_128_CBC_SHA_160 : cmdFlags |= PCL_OP_INFO_DTLS_AES_128_CBC_SHA_160 ; break;
case e_DTLS_CIPHER_ALG_AES_128_CBC_SHA_384 : cmdFlags |= PCL_OP_INFO_DTLS_AES_128_CBC_SHA_384 ; break;
case e_DTLS_CIPHER_ALG_AES_128_CBC_SHA_224 : cmdFlags |= PCL_OP_INFO_DTLS_AES_128_CBC_SHA_224 ; break;
case e_DTLS_CIPHER_ALG_AES_128_CBC_SHA_512 : cmdFlags |= PCL_OP_INFO_DTLS_AES_128_CBC_SHA_512 ; break;
}
return cmdFlags;
}
static inline uint32_t CalcMacsecCmdFlags(uint32_t initFlags,
e_MacsecCipherAlg cipherAlg)
{
uint32_t cmdFlags = initFlags;
switch (cipherAlg)
{
case e_MACSEC_CIPHER_ALG_AES_GCM_16: cmdFlags |= PCL_OP_INFO_MACSEC_AES_GCM_16; break;
}
return cmdFlags;
}
static inline void InsertDataMoveCommands(t_DescHandle* p_DescHandle,
uint32_t dataMoveSize)
{
uint32_t cmdFlags;
cmdFlags = DCTRL_LOAD_AUTO_IFIFO_DISABLED;
CmdInsertDctrlLoad(p_DescHandle,cmdFlags);
cmdFlags = FIFO_LOAD_CLASS_BOTH_TYPE_MSG_L2_L1_F1;
CmdInsertFifoLoad(p_DescHandle,cmdFlags,dataMoveSize,NULL);
cmdFlags = DCTRL_LOAD_AUTO_IFIFO_ENABLED;
CmdInsertDctrlLoad(p_DescHandle,cmdFlags);
cmdFlags = MOVE_AUX_FLSH_SRC_IFIFO1_DST_OFIFO;
CmdInsertMove(p_DescHandle,cmdFlags,0,dataMoveSize);
cmdFlags = FIFO_STORE_CLASS_UNUSED_TYPE_MSG;
CmdInsertFifoStore(p_DescHandle,cmdFlags,dataMoveSize,NULL);
}
static inline void InsertNopCommands(t_DescHandle* p_DescHandle,
uint32_t numOfCommands)
{
uint32_t i;
uint32_t jumpCmdIndex;
for (i=0; i<numOfCommands; i++)
{
jumpCmdIndex = p_DescHandle->nextIndex;
CmdInsertLocalJump(p_DescHandle,0);
CmdUpdateLocalJump(p_DescHandle,jumpCmdIndex);
}
}
@@ -0,0 +1,156 @@
/******************************************************************************
© 1995-2003, 2004, 2005-2010 Freescale Semiconductor, Inc.
All rights reserved.
This is proprietary source code of Freescale Semiconductor Inc.,
and its use is subject to the NetComm Device Drivers EULA.
The copyright notice above does not evidence any actual or intended
publication of such source code.
**************************************************************************/
#ifndef __SEC_DCL_API_H
#define __SEC_DCL_API_H
/************************************************************************/
/* */
/* Description */
/* ----------- */
/* */
/* A set of complex routines, for creating: */
/* A protocol-specific Shared-Descriptor */
/* A Job-Descriptor referencing a Shared-Descriptor */
/* */
/* Calling Sequence: */
/* 1 * descLength = Init<TYPE>ShrDesc(p_ShrDesc,...) */
/* N * descLength = InitSeqJobDesc(p_Desc,p_ShrDesc,...) */
/* */
/* Notes: */
/* MaxJobDescLen returns the maximum length of a Job-Descriptor */
/* MaxShrDescLen returns the maximum length of a Shared-Descriptor */
/* All other routines create a Descriptor and return its length */
/* The Descriptor buffer should be allocated outside the routine */
/* The returned length indicates the number of 32-bit words used */
/* */
/************************************************************************/
#include "sec_dcl_ext.h"
uint32_t MaxJobDescLen();
uint32_t MaxShrDescLen(uint32_t ptrSize);
/************************************************/
/* Job-Descriptor Construction Routines (below) */
uint32_t InitSeqJobDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t* p_ShrDesc,
bool inputSeqSgt,
uint32_t inputSeqSize,
uint8_t* p_InputSeqData,
bool outputSeqSgt,
uint32_t outputSeqSize,
uint8_t* p_OutputSeqData);
uint32_t InitSplitKeyJobDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint8_t* p_InputKey,
uint8_t* p_OutputKey,
e_SplitKeyHashAlg hashAlg);
/* Job-Descriptor Construction Routines (above) */
/************************************************/
/***************************************************/
/* Shared-Descriptor Construction Routines (below) */
uint32_t InitIpsecEncapShrDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t dataMoveSize,
bool cryptoKeyImm,
uint32_t cryptoKeySize,
uint8_t* p_CryptoKeyData,
bool authenKeyImm,
uint32_t authenKeySize,
uint8_t* p_AuthenKeyData,
e_IpsecCryptoAlg cryptoAlg,
e_IpsecAuthenAlg authenAlg,
t_IpsecEncapParam* p_Param);
uint32_t InitIpsecDecapShrDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t dataMoveSize,
bool cryptoKeyImm,
uint32_t cryptoKeySize,
uint8_t* p_CryptoKeyData,
bool authenKeyImm,
uint32_t authenKeySize,
uint8_t* p_AuthenKeyData,
e_IpsecCryptoAlg cryptoAlg,
e_IpsecAuthenAlg authenAlg,
t_IpsecDecapParam* p_Param);
uint32_t InitDtlsEncapShrDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t dataMoveSize,
bool cryptoKeyImm,
uint32_t cryptoKeySize,
uint8_t* p_CryptoKeyData,
bool authenKeyImm,
uint32_t authenKeySize,
uint8_t* p_AuthenKeyData,
e_DtlsCipherAlg cipherAlg,
t_DtlsEncapParam* p_Param);
uint32_t InitDtlsDecapShrDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t dataMoveSize,
bool cryptoKeyImm,
uint32_t cryptoKeySize,
uint8_t* p_CryptoKeyData,
bool authenKeyImm,
uint32_t authenKeySize,
uint8_t* p_AuthenKeyData,
e_DtlsCipherAlg cipherAlg,
t_DtlsDecapParam* p_Param);
uint32_t InitMacsecEncapShrDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t dataMoveSize,
bool cipherKeyImm,
uint32_t cipherKeySize,
uint8_t* p_CipherKeyData,
e_MacsecCipherAlg cipherAlg,
t_MacsecEncapParam* p_Param);
uint32_t InitMacsecDecapShrDesc(uint32_t* p_Desc,
uint32_t ptrSize,
uint32_t dataMoveSize,
bool cipherKeyImm,
uint32_t cipherKeySize,
uint8_t* p_CipherKeyData,
e_MacsecCipherAlg cipherAlg,
t_MacsecDecapParam* p_Param);
/* Shared-Descriptor Construction Routines (above) */
/***************************************************/
#endif /* __SEC_DCL_API_H */
@@ -0,0 +1,945 @@
/******************************************************************************
� 1995-2003, 2004, 2005-2010 Freescale Semiconductor, Inc.
All rights reserved.
This is proprietary source code of Freescale Semiconductor Inc.,
and its use is subject to the NetComm Device Drivers EULA.
The copyright notice above does not evidence any actual or intended
publication of such source code.
**************************************************************************/
/* Include the internal definitions of this module */
#include "sec_dcl_cmd.h"
/* Include the external interfaces of other modules */
#include "error_ext.h"
#define FLAGS_MATCH(word,mask,flags) (((word)&(mask))==(flags))
static inline void WriteWord(t_DescHandle* p_DescHandle,uint32_t word);
static inline void WriteAddr(t_DescHandle* p_DescHandle,void* p_Addr);
static inline void WriteData(t_DescHandle* p_DescHandle,void* p_Data,uint32_t size);
t_DescHandle NewDescHandle(uint32_t* p_Buffer,uint32_t ptrSize)
{
t_DescHandle descHandle;
descHandle.p_Buffer = p_Buffer;
descHandle.nextIndex = 0;
descHandle.ptrLength = ptrSize/sizeof(uint32_t);
return descHandle;
}
void CmdInsertShrDescHdr(t_DescHandle* p_DescHandle,
uint32_t cmdFlags)
{
/* Calculate additional flags */
cmdFlags |= (uint32_t) SHR_DESC_HDR_CTYPE;
cmdFlags |= SHR_DESC_HDR_ONE;
cmdFlags &= ~SHR_DESC_HDR_ZRO;
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
}
void CmdInsertJobDescHdr(t_DescHandle* p_DescHandle,
uint32_t cmdFlags)
{
/* Calculate additional flags */
cmdFlags |= (uint32_t) JOB_DESC_HDR_CTYPE;
cmdFlags |= JOB_DESC_HDR_ONE;
cmdFlags &= ~JOB_DESC_HDR_ZRO;
cmdFlags &= ~JOB_DESC_HDR_SHR;
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
}
void CmdInsertJobDescRefShrHdr(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t* p_ShrDesc)
{
/* Assert input arguments */
ASSERT_COND(p_ShrDesc != NULL);
/* Calculate additional flags */
cmdFlags |= (uint32_t) JOB_DESC_HDR_CTYPE;
cmdFlags |= JOB_DESC_HDR_ONE;
cmdFlags &= ~JOB_DESC_HDR_ZRO;
cmdFlags |= JOB_DESC_HDR_SHR;
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
WriteAddr(p_DescHandle,p_ShrDesc);
}
void CmdInsertKey(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t length,
uint8_t* p_Data)
{
/* Assert input arguments */
if (FLAGS_MATCH(cmdFlags,KEY_IMM,KEY_IMM))
{
ASSERT_COND(p_Data != NULL);
ASSERT_COND(!FLAGS_MATCH(cmdFlags,KEY_SGT,KEY_SGT));
}
if (FLAGS_MATCH(cmdFlags,KEY_CLASS_DST_MASK,KEY_CLASS_1_DST_AFHA_SBOX))
{
ASSERT_COND(length == KEY_DST_AFHA_SBOX_LENGTH);
}
ASSERT_COND(IN_RANGE(MIN_KEY_LENGTH,length,MAX_KEY_LENGTH));
/* Calculate additional flags */
cmdFlags |= KEY_CTYPE;
cmdFlags |= KEY_SEQ(p_Data==NULL);
cmdFlags |= KEY_LENGTH(length);
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
if (p_Data)
{
if (FLAGS_MATCH(cmdFlags,KEY_IMM,KEY_IMM))
WriteData(p_DescHandle,p_Data,length);
else
WriteAddr(p_DescHandle,p_Data);
}
}
void CmdInsertLoad(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t offset,
uint32_t length,
uint8_t* p_Data)
{
bool length_in_words=FALSE; /* Interpeak. Bug correction */
/* Assert input arguments */
if (FLAGS_MATCH(cmdFlags,LOAD_IMM,LOAD_IMM))
{
ASSERT_COND(p_Data != NULL);
ASSERT_COND(!FLAGS_MATCH(cmdFlags,LOAD_SGT,LOAD_SGT));
}
if (FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_KEYSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_2_DST_KEYSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_DATASZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_2_DST_DATASZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_ICVSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_2_DST_ICVSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_DECO_DST_DLIODN ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_CCTRL ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_ICTRL ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_DECO_DST_DPOVRD ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_CLRW ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_DECO_DST_DMATH0 ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_DECO_DST_DMATH1 ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_DECO_DST_DMATH2 ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_DECO_DST_DMATH3 ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_AADSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_IVSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_ALTDSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_PKASZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_PKBSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_PKNSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_PKESZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_DECO_DST_DESCBUF) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_IFIFO ))
{
ASSERT_COND((length%4) == 0); /*length /= 4;*/ /*Interpeak. Bug correction*/
length_in_words = TRUE;
}
if (FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_KEYSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_2_DST_KEYSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_DATASZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_2_DST_DATASZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_ICVSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_2_DST_ICVSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_DECO_DST_DLIODN) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_CCTRL ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_ICTRL ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_DECO_DST_DPOVRD) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_CLRW ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_AADSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_IVSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_ALTDSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_PKASZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_PKBSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_PKNSZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_PKESZ ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_IDFNS ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_ODFNS ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_IFALT ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_IFIFO ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_DFIFO ) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_OFIFO ))
{
ASSERT_COND(FLAGS_MATCH(cmdFlags,LOAD_IMM,LOAD_IMM));
}
if (FLAGS_MATCH(cmdFlags,LOAD_IMM,LOAD_IMM))
{
if (FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_1_DST_CTX) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_2_DST_CTX))
{
ASSERT_COND((offset%8) == 0);
}
else
{
ASSERT_COND(offset == 0);
}
if (FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_DFIFO) ||
FLAGS_MATCH(cmdFlags,LOAD_CLASS_DST_MASK,LOAD_CLASS_NONE_DST_OFIFO))
{
ASSERT_COND(length>=1 && length<=8);
}
else
{
ASSERT_COND(length==4 || length==8);
}
}
ASSERT_COND(IN_RANGE(MIN_LOAD_OFFSET,offset,MAX_LOAD_OFFSET));
ASSERT_COND(IN_RANGE(MIN_LOAD_LENGTH,length,MAX_LOAD_LENGTH));
/* Calculate additional flags */
cmdFlags |= LOAD_CTYPE;
cmdFlags |= LOAD_SEQ(p_Data==NULL);
cmdFlags |= LOAD_OFFSET(offset);
if(length_in_words==TRUE) /* Interpeak. Bug correction*/
cmdFlags |= LOAD_LENGTH(length/4);
else
cmdFlags |= LOAD_LENGTH(length);
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
if (p_Data)
{
if (FLAGS_MATCH(cmdFlags,LOAD_IMM,LOAD_IMM))
WriteData(p_DescHandle,p_Data,length);
else
WriteAddr(p_DescHandle,p_Data);
}
}
void CmdInsertDctrlLoad(t_DescHandle* p_DescHandle,
uint32_t cmdFlags)
{
/* Calculate additional flags */
cmdFlags |= DCTRL_LOAD_CTYPE;
cmdFlags |= DCTRL_LOAD_CLASS_DECO_IMM_DST_REG;
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
}
void CmdInsertFifoLoad(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t length,
uint8_t* p_Data)
{
/* Assert input arguments */
if (FLAGS_MATCH(cmdFlags,FIFO_LOAD_IMM,FIFO_LOAD_IMM))
{
ASSERT_COND(p_Data != NULL);
ASSERT_COND(!FLAGS_MATCH(cmdFlags,FIFO_LOAD_SGT,FIFO_LOAD_SGT));
}
if (FLAGS_MATCH(cmdFlags,FIFO_LOAD_CLASS_TYPE_MASK,FIFO_LOAD_CLASS_SKIP_TYPE_UNUSED))
{
ASSERT_COND(p_Data == NULL);
}
if (!(FLAGS_MATCH(cmdFlags,FIFO_LOAD_VLF, FIFO_LOAD_VLF))) /* wind river added */
{
ASSERT_COND(IN_RANGE(MIN_FIFO_LOAD_LENGTH,length,MAX_FIFO_LOAD_LENGTH));
}
/* Calculate additional flags */
cmdFlags |= FIFO_LOAD_CTYPE;
cmdFlags |= FIFO_LOAD_SEQ(p_Data==NULL);
if (length > MAX_NOT_EXT_LENGTH)
{
cmdFlags |= FIFO_LOAD_EXT;
cmdFlags &= ~FIFO_LOAD_LENGTH(~0);
}
else
{
cmdFlags &= ~FIFO_LOAD_EXT;
cmdFlags |= FIFO_LOAD_LENGTH(length);
}
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
if (p_Data)
{
if (FLAGS_MATCH(cmdFlags,FIFO_LOAD_IMM,FIFO_LOAD_IMM))
WriteData(p_DescHandle,p_Data,length);
else
WriteAddr(p_DescHandle,p_Data);
}
if (length > MAX_NOT_EXT_LENGTH)
WriteWord(p_DescHandle,length);
}
void CmdInsertBitFifoLoad(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t length,
uint8_t* p_Data)
{
/* Assert input arguments */
if (FLAGS_MATCH(cmdFlags,BIT_FIFO_LOAD_IMM,BIT_FIFO_LOAD_IMM))
{
ASSERT_COND(p_Data != NULL);
ASSERT_COND(!FLAGS_MATCH(cmdFlags,BIT_FIFO_LOAD_SGT,BIT_FIFO_LOAD_SGT));
}
ASSERT_COND(IN_RANGE(MIN_BIT_FIFO_LOAD_LENGTH,length,MAX_BIT_FIFO_LOAD_LENGTH));
/* Calculate additional flags */
cmdFlags |= BIT_FIFO_LOAD_CTYPE;
cmdFlags |= BIT_FIFO_LOAD_SEQ(p_Data==NULL);
cmdFlags |= BIT_FIFO_LOAD_BIT_LENGTH(length);
if (length > MAX_NOT_EXT_LENGTH)
{
cmdFlags |= BIT_FIFO_LOAD_EXT;
cmdFlags &= ~BIT_FIFO_LOAD_BYTE_LENGTH(~0);
}
else
{
cmdFlags &= ~BIT_FIFO_LOAD_EXT;
cmdFlags |= BIT_FIFO_LOAD_BYTE_LENGTH(length);
}
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
if (p_Data)
{
if (FLAGS_MATCH(cmdFlags,BIT_FIFO_LOAD_IMM,BIT_FIFO_LOAD_IMM))
WriteData(p_DescHandle,p_Data,DIV_CEIL(length,8));
else
WriteAddr(p_DescHandle,p_Data);
}
if (length > MAX_NOT_EXT_LENGTH)
WriteWord(p_DescHandle,length/8);
}
void CmdInsertStore(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t offset,
uint32_t length,
uint8_t* p_Data)
{
/* Assert input arguments */
if (FLAGS_MATCH(cmdFlags,STORE_IMM,STORE_IMM))
{
ASSERT_COND(offset == 0);
ASSERT_COND(p_Data != NULL);
ASSERT_COND(!FLAGS_MATCH(cmdFlags,STORE_SGT,STORE_SGT));
ASSERT_COND(FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_UNUSED_SRC_UNUSED));
}
if (FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_1_SRC_MODE ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_2_SRC_MODE ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_DECO_SRC_DJQCR ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_1_SRC_KEYSZ ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_2_SRC_KEYSZ ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_DECO_SRC_DDAR ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_1_SRC_DATASZ ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_2_SRC_DATASZ ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_DECO_SRC_DSTAT ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_1_SRC_ICVSZ ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_2_SRC_ICVSZ ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_NONE_SRC_CCTRL ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_NONE_SRC_ICTRL ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_NONE_SRC_CLRW ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_DECO_SRC_DMATH0) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_NONE_SRC_STAT ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_DECO_SRC_DMATH1) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_DECO_SRC_DMATH2) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_1_SRC_AADSZR ) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_DECO_SRC_DMATH3) ||
FLAGS_MATCH(cmdFlags,STORE_CLASS_SRC_MASK,STORE_CLASS_1_SRC_IVSZ ))
{
ASSERT_COND((length%4) == 0); length /= 4;
}
ASSERT_COND(IN_RANGE(MIN_STORE_OFFSET,offset,MAX_STORE_OFFSET));
ASSERT_COND(IN_RANGE(MIN_STORE_LENGTH,length,MAX_STORE_LENGTH));
/* Calculate additional flags */
cmdFlags |= STORE_CTYPE;
cmdFlags |= STORE_SEQ(p_Data==NULL);
cmdFlags |= STORE_OFFSET(offset);
cmdFlags |= STORE_LENGTH(length);
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
if (p_Data)
{
if (FLAGS_MATCH(cmdFlags,STORE_IMM,STORE_IMM))
WriteData(p_DescHandle,p_Data,length);
else
WriteAddr(p_DescHandle,p_Data);
}
}
void CmdInsertDescbufStore(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t offset,
uint32_t length,
uint8_t* p_Data)
{
/* Assert input arguments */
if (FLAGS_MATCH(cmdFlags,DESCBUF_STORE_CLASS_SRC_MASK,DESCBUF_STORE_CLASS_DECO_SRC_0))
{
ASSERT_COND(offset == 0);
}
if (FLAGS_MATCH(cmdFlags,DESCBUF_STORE_CLASS_SRC_MASK,DESCBUF_STORE_CLASS_DECO_SRC_1) ||
FLAGS_MATCH(cmdFlags,DESCBUF_STORE_CLASS_SRC_MASK,DESCBUF_STORE_CLASS_DECO_SRC_2))
{
ASSERT_COND(p_Data == NULL);
}
ASSERT_COND((length%4) == 0); length /= 4;
ASSERT_COND((offset%4) == 0); offset /= 4;
ASSERT_COND(IN_RANGE(MIN_DESCBUF_STORE_OFFSET,offset,MAX_DESCBUF_STORE_OFFSET));
ASSERT_COND(IN_RANGE(MIN_DESCBUF_STORE_LENGTH,length,MAX_DESCBUF_STORE_LENGTH));
/* Calculate additional flags */
cmdFlags |= DESCBUF_STORE_CTYPE;
cmdFlags |= DESCBUF_STORE_SEQ(p_Data!=NULL && FLAGS_MATCH(cmdFlags,DESCBUF_STORE_CLASS_SRC_MASK,DESCBUF_STORE_CLASS_DECO_SRC_0));
cmdFlags |= DESCBUF_STORE_OFFSET(offset);
cmdFlags |= DESCBUF_STORE_LENGTH(length);
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
if (p_Data)
WriteAddr(p_DescHandle,p_Data);
}
void CmdInsertFifoStore(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t length,
uint8_t* p_Data)
{
if (FLAGS_MATCH(cmdFlags,FIFO_STORE_CLASS_TYPE_MASK,FIFO_STORE_CLASS_UNUSED_TYPE_SKIP))
{
ASSERT_COND(p_Data == NULL);
}
ASSERT_COND(IN_RANGE(MIN_FIFO_STORE_LENGTH,length,MAX_FIFO_STORE_LENGTH));
/* Calculate additional flags */
cmdFlags |= FIFO_STORE_CTYPE;
cmdFlags |= FIFO_STORE_SEQ(p_Data==NULL);
if (length > MAX_NOT_EXT_LENGTH)
{
cmdFlags |= FIFO_STORE_EXT;
cmdFlags &= ~FIFO_STORE_LENGTH(~0);
}
else
{
cmdFlags &= ~FIFO_STORE_EXT;
cmdFlags |= FIFO_STORE_LENGTH(length);
}
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
if (p_Data)
WriteAddr(p_DescHandle,p_Data);
if (length > MAX_NOT_EXT_LENGTH)
WriteWord(p_DescHandle,length);
}
void CmdInsertRngFifoStore(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t length,
uint8_t* p_Data)
{
if (FLAGS_MATCH(cmdFlags,RNG_FIFO_STORE_TYPE_MASK,RNG_FIFO_STORE_TYPE_OFIFO))
{
ASSERT_COND(p_Data == NULL);
}
ASSERT_COND(IN_RANGE(MIN_RNG_FIFO_STORE_LENGTH,length,MAX_RNG_FIFO_STORE_LENGTH));
/* Calculate additional flags */
cmdFlags |= RNG_FIFO_STORE_CTYPE;
cmdFlags |= RNG_FIFO_STORE_SEQ(p_Data!=NULL && FLAGS_MATCH(cmdFlags,RNG_FIFO_STORE_TYPE_MASK,RNG_FIFO_STORE_TYPE_OFIFO));
cmdFlags |= RNG_FIFO_STORE_LENGTH(length);
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
if (p_Data)
WriteAddr(p_DescHandle,p_Data);
}
void CmdInsertMove(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t offset,
uint32_t length)
{
/* Assert input arguments */
if (FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_NONE_SRC_OFIFO_DST_IFIFO1 ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_LAST_SRC_OFIFO_DST_IFIFO1 ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_FLSH_SRC_OFIFO_DST_IFIFO1 ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_BOTH_SRC_OFIFO_DST_IFIFO1 ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_NONE_SRC_OFIFO_DST_IFIFO2 ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_LAST_SRC_OFIFO_DST_IFIFO2 ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_FLSH_SRC_OFIFO_DST_IFIFO2 ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_BOTH_SRC_OFIFO_DST_IFIFO2 ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_OFIFO_DST_PKHA_A))
{
ASSERT_COND(offset == 0);
}
if (FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_CTX1_DST_OFIFO ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_CTX2_DST_OFIFO ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_DESCBUF_DST_OFIFO ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_MATHREG0_DST_OFIFO ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_MATHREG1_DST_OFIFO ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_MATHREG2_DST_OFIFO ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_MATHREG3_DST_OFIFO ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_IFIFO1_DST_CTX1 ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_IFIFO1_DST_CTX2 ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_IFIFO1_DST_DESCBUF ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_IFIFO1_DST_MATHREG0) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_IFIFO1_DST_MATHREG1) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_IFIFO1_DST_MATHREG2) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_IFIFO1_DST_MATHREG3) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_IFIFO1_DST_KEY1 ) ||
FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_IFIFO1_DST_KEY2 ))
{
ASSERT_COND((offset%4) == 0);
}
if (!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_00B_SRC_CTX1_DST_DESCBUF) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_16B_SRC_CTX1_DST_DESCBUF) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_32B_SRC_CTX1_DST_DESCBUF) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_48B_SRC_CTX1_DST_DESCBUF) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_00B_SRC_CTX2_DST_DESCBUF) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_16B_SRC_CTX2_DST_DESCBUF) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_32B_SRC_CTX2_DST_DESCBUF) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_48B_SRC_CTX2_DST_DESCBUF) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_OFIFO_DST_DESCBUF ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_00B_SRC_DESCBUF_DST_CTX1) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_16B_SRC_DESCBUF_DST_CTX1) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_32B_SRC_DESCBUF_DST_CTX1) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_48B_SRC_DESCBUF_DST_CTX1) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_00B_SRC_DESCBUF_DST_CTX2) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_16B_SRC_DESCBUF_DST_CTX2) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_32B_SRC_DESCBUF_DST_CTX2) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_OFFSET_48B_SRC_DESCBUF_DST_CTX2) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_DESCBUF_DST_OFIFO ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_DESCBUF_DST_MATHREG0) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_DESCBUF_DST_MATHREG1) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_DESCBUF_DST_MATHREG2) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_DESCBUF_DST_MATHREG3) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_NONE_SRC_DESCBUF_DST_IFIFO1 ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_LAST_SRC_DESCBUF_DST_IFIFO1 ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_FLSH_SRC_DESCBUF_DST_IFIFO1 ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_BOTH_SRC_DESCBUF_DST_IFIFO1 ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_NONE_SRC_DESCBUF_DST_IFIFO2 ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_LAST_SRC_DESCBUF_DST_IFIFO2 ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_FLSH_SRC_DESCBUF_DST_IFIFO2 ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_BOTH_SRC_DESCBUF_DST_IFIFO2 ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_DESCBUF_DST_PKHA_A ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_DESCBUF_DST_KEY1 ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_DESCBUF_DST_KEY2 ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_MATHREG0_DST_DESCBUF) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_MATHREG1_DST_DESCBUF) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_MATHREG2_DST_DESCBUF) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_MATHREG3_DST_DESCBUF) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_SRC_DST_MASK,MOVE_AUX_UNUSED_SRC_IFIFO1_DST_DESCBUF ) &&
/* Wind River fix start */
/* offset is treated as additional 8 length bits in case of src=IFIFO and dst=OFIFO */
!FLAGS_MATCH(cmdFlags,MOVE_AUX_FLSH_C2A_SRC_IFIFO2_DST_OFIFO,MOVE_AUX_FLSH_C2A_SRC_IFIFO2_DST_OFIFO ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_FLSH_C1A_SRC_IFIFO2_DST_OFIFO,MOVE_AUX_FLSH_C1A_SRC_IFIFO2_DST_OFIFO ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_NONE_SRC_IFIFO1_DST_OFIFO,MOVE_AUX_NONE_SRC_IFIFO1_DST_OFIFO ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_FLSH_SRC_IFIFO1_DST_OFIFO,MOVE_AUX_FLSH_SRC_IFIFO1_DST_OFIFO ))
/* Wind River fix end */
{
ASSERT_COND(offset <= 128);
}
/* Wind River fix start */
if(!FLAGS_MATCH(cmdFlags,MOVE_AUX_FLSH_C2A_SRC_IFIFO2_DST_OFIFO,MOVE_AUX_FLSH_C2A_SRC_IFIFO2_DST_OFIFO) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_FLSH_C1A_SRC_IFIFO2_DST_OFIFO,MOVE_AUX_FLSH_C1A_SRC_IFIFO2_DST_OFIFO) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_NONE_SRC_IFIFO1_DST_OFIFO,MOVE_AUX_NONE_SRC_IFIFO1_DST_OFIFO ) &&
!FLAGS_MATCH(cmdFlags,MOVE_AUX_FLSH_SRC_IFIFO1_DST_OFIFO,MOVE_AUX_FLSH_SRC_IFIFO1_DST_OFIFO ))
{
/* These assert is not applicable when offset is treated as 8 additional length bits */
ASSERT_COND(IN_RANGE(MIN_MOVE_OFFSET,offset,MAX_MOVE_OFFSET));
ASSERT_COND(IN_RANGE(MIN_MOVE_LENGTH,length,MAX_MOVE_LENGTH));
}
else
{
ASSERT_COND(IN_RANGE(MIN_MOVE_LENGTH, (length | MOVE_OFFSET(offset)), UINT16_MAX));
}
/* Wind River fix end */
/* Calculate additional flags */
cmdFlags |= MOVE_CTYPE;
cmdFlags |= MOVE_OFFSET(offset);
cmdFlags |= MOVE_LENGTH(length);
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
}
void CmdInsertAlgOperation(t_DescHandle* p_DescHandle,
uint32_t cmdFlags)
{
/* Calculate additional flags */
cmdFlags |= (uint32_t) ALG_OP_CTYPE;
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
}
void CmdInsertPclOperation(t_DescHandle* p_DescHandle,
uint32_t cmdFlags)
{
/* Calculate additional flags */
cmdFlags |= (uint32_t) PCL_OP_CTYPE;
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
}
void CmdInsertPkhaOperation(t_DescHandle* p_DescHandle,
uint32_t cmdFlags)
{
/* Calculate additional flags */
cmdFlags |= (uint32_t) PKHA_OP_CTYPE;
cmdFlags |= PKHA_OP_TYPE;
cmdFlags |= PKHA_OP_ID;
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
}
void CmdInsertLocalJump(t_DescHandle* p_DescHandle,
uint32_t cmdFlags)
{
/* Calculate additional flags */
cmdFlags |= (uint32_t) JUMP_CTYPE;
cmdFlags |= JUMP_TYPE_LOCAL;
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
}
void CmdUpdateLocalJump(t_DescHandle* p_DescHandle,
uint32_t jumpCmdIndex)
{
/* Read the Jump command */
uint32_t cmdFlags = GET_UINT32(p_DescHandle->p_Buffer[jumpCmdIndex]);
/* Assert input arguments */
ASSERT_COND(p_DescHandle->nextIndex > jumpCmdIndex);
/* Update the Jump command */
cmdFlags |= JUMP_LOCAL_OFFSET(p_DescHandle->nextIndex-jumpCmdIndex);
/* Reinsert the Jump command */
WRITE_UINT32(p_DescHandle->p_Buffer[jumpCmdIndex],cmdFlags);
}
void CmdInsertNonLocalJump(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t* p_JumpAddr)
{
/* Assert input arguments */
ASSERT_COND(p_JumpAddr != NULL);
/* Calculate additional flags */
cmdFlags |= (uint32_t) JUMP_CTYPE;
cmdFlags |= JUMP_TYPE_NON_LOCAL;
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
WriteAddr(p_DescHandle,p_JumpAddr);
}
void CmdInsertHaltWithTestStatus(t_DescHandle* p_DescHandle,
uint32_t cmdFlags)
{
/* Assert input arguments */
ASSERT_COND(FLAGS_MATCH(cmdFlags,JUMP_SL_MASK,JUMP_SL_0));
/* Calculate additional flags */
cmdFlags |= (uint32_t) JUMP_CTYPE;
cmdFlags |= JUMP_TYPE_HALT_TEST_STATUS;
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
}
void CmdInsertHaltWithUserStatus(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t status)
{
/* Calculate additional flags */
cmdFlags |= (uint32_t) JUMP_CTYPE;
cmdFlags |= JUMP_TYPE_HALT_USER_STATUS;
cmdFlags |= JUMP_HALT_USER_STATUS(status);
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
}
void CmdInsertMath(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t length0,
uint32_t length1,
uint8_t* p_Data0,
uint8_t* p_Data1)
{
/* Assert input arguments */
if (length0 > 0)
{
ASSERT_COND(p_Data0 != NULL);
ASSERT_COND(FLAGS_MATCH(cmdFlags,MATH_SRC0_MASK,MATH_SRC0_IMM));
}
else
{
ASSERT_COND(p_Data0 == NULL);
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_SRC0_MASK,MATH_SRC0_IMM));
}
if (length1 > 0)
{
ASSERT_COND(p_Data1 != NULL);
ASSERT_COND(FLAGS_MATCH(cmdFlags,MATH_SRC1_MASK,MATH_SRC1_IMM));
}
else
{
ASSERT_COND(p_Data1 == NULL);
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_SRC1_MASK,MATH_SRC1_IMM));
}
if (FLAGS_MATCH(cmdFlags,MATH_FUNC_MASK,MATH_FUNC_SHIFT_L))
{
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_DST_MASK,MATH_DST_NONE));
}
if (FLAGS_MATCH(cmdFlags,MATH_FUNC_MASK,MATH_FUNC_SHIFT_R))
{
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_DST_MASK,MATH_DST_NONE));
}
if (FLAGS_MATCH(cmdFlags,MATH_FUNC_MASK,MATH_FUNC_SHLD))
{
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_DST_MASK,MATH_DST_IMM ));
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_DST_MASK,MATH_DST_SIL ));
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_DST_MASK,MATH_DST_SOL ));
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_DST_MASK,MATH_DST_VSIL));
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_DST_MASK,MATH_DST_VSOL));
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_DST_MASK,MATH_DST_NONE));
}
if (FLAGS_MATCH(cmdFlags,MATH_LEN_MASK,MATH_LEN_8_BYTE))
{
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_DST_MASK,MATH_DST_SIL ));
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_DST_MASK,MATH_DST_SOL ));
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_DST_MASK,MATH_DST_VSIL));
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_DST_MASK,MATH_DST_VSOL));
}
if (length0>0 && length1>0)
{
ASSERT_COND(length0 <= 4);
ASSERT_COND(length1 <= 4);
ASSERT_COND(!FLAGS_MATCH(cmdFlags,MATH_LEN_MASK,MATH_LEN_8_BYTE));
}
/* Calculate additional flags */
cmdFlags |= (uint32_t) MATH_CTYPE;
cmdFlags |= MATH_IFB(FLAGS_MATCH(cmdFlags,MATH_LEN_MASK,MATH_LEN_8_BYTE) && length0>0 && length0<=4 && length1==0);
cmdFlags |= MATH_IFB(FLAGS_MATCH(cmdFlags,MATH_LEN_MASK,MATH_LEN_8_BYTE) && length1>0 && length1<=4 && length0==0);
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
if (p_Data0)
WriteData(p_DescHandle,p_Data0,length0);
if (p_Data1)
WriteData(p_DescHandle,p_Data1,length1);
}
void CmdInsertSeqInPtr(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t length,
uint8_t* p_Data)
{
/* Assert input arguments */
ASSERT_COND(IN_RANGE(MIN_SEQ_IN_PTR_LENGTH,length,MAX_SEQ_IN_PTR_LENGTH));
/* Calculate additional flags */
cmdFlags |= (uint32_t) SEQ_IN_PTR_CTYPE;
if (length > MAX_NOT_EXT_LENGTH)
{
cmdFlags |= SEQ_IN_PTR_EXT;
cmdFlags &= ~SEQ_IN_PTR_LENGTH(~0);
}
else
{
cmdFlags &= ~SEQ_IN_PTR_EXT;
cmdFlags |= SEQ_IN_PTR_LENGTH(length);
}
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
if (p_Data)
WriteAddr(p_DescHandle,p_Data);
if (length > MAX_NOT_EXT_LENGTH)
WriteWord(p_DescHandle,length);
}
void CmdInsertSeqOutPtr(t_DescHandle* p_DescHandle,
uint32_t cmdFlags,
uint32_t length,
uint8_t* p_Data)
{
/* Assert input arguments */
ASSERT_COND(IN_RANGE(MIN_SEQ_OUT_PTR_LENGTH,length,MAX_SEQ_OUT_PTR_LENGTH));
/* Calculate additional flags */
cmdFlags |= (uint32_t) SEQ_OUT_PTR_CTYPE;
if (length > MAX_NOT_EXT_LENGTH)
{
cmdFlags |= SEQ_OUT_PTR_EXT;
cmdFlags &= ~SEQ_OUT_PTR_LENGTH(~0);
}
else
{
cmdFlags &= ~SEQ_OUT_PTR_EXT;
cmdFlags |= SEQ_OUT_PTR_LENGTH(length);
}
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
if (p_Data)
WriteAddr(p_DescHandle,p_Data);
if (length > MAX_NOT_EXT_LENGTH)
WriteWord(p_DescHandle,length);
}
void CmdInsertAnything(t_DescHandle* p_DescHandle,
uint32_t cmdFlags)
{
/* Insert the command */
WriteWord(p_DescHandle,cmdFlags);
}
void CmdInsertDataBlock(t_DescHandle* p_DescHandle,
uint32_t length,
uint8_t* p_Data)
{
/* Assert input arguments */
ASSERT_COND(length != 0);
ASSERT_COND(p_Data != NULL);
/* Insert the command */
WriteData(p_DescHandle,p_Data,length);
}
void CloseShrDesc(t_DescHandle* p_DescHandle,uint32_t startIndex)
{
/* Read the Header command */
uint32_t cmdFlags = GET_UINT32(p_DescHandle->p_Buffer[0]);
/* Assert input arguments */
ASSERT_COND(p_DescHandle->nextIndex >= startIndex+1);
ASSERT_COND(p_DescHandle->nextIndex <= MAX_DESC_LENGTH-1-p_DescHandle->ptrLength);
/* Update the Header command */
cmdFlags |= SHR_DESC_HDR_START_INDEX(startIndex);
cmdFlags |= SHR_DESC_HDR_LENGTH_SET(p_DescHandle->nextIndex);
/* Reinsert the Header command */
WRITE_UINT32(p_DescHandle->p_Buffer[0],cmdFlags);
}
void CloseJobDesc(t_DescHandle* p_DescHandle,uint32_t startIndex)
{
/* Read the Header command */
uint32_t cmdFlags = GET_UINT32(p_DescHandle->p_Buffer[0]);
/* Assert input arguments */
ASSERT_COND(p_DescHandle->nextIndex >= startIndex+1);
ASSERT_COND(p_DescHandle->nextIndex <= MAX_DESC_LENGTH);
/* Update the Header command */
cmdFlags |= JOB_DESC_HDR_START_INDEX(startIndex);
cmdFlags |= JOB_DESC_HDR_LENGTH_SET(p_DescHandle->nextIndex);
/* Reinsert the Header command */
WRITE_UINT32(p_DescHandle->p_Buffer[0],cmdFlags);
}
void CloseJobDescRefShr(t_DescHandle* p_DescHandle,uint32_t* p_ShrDesc)
{
/* Read the Header command */
uint32_t cmdFlags = GET_UINT32(p_DescHandle->p_Buffer[0]);
/* Read the Shared-Descriptor Header command */
uint32_t shrDescCmdFlags = GET_UINT32(p_ShrDesc[0]);
/* Assert input arguments */
ASSERT_COND(p_DescHandle->nextIndex >= MIN_DESC_LENGTH);
ASSERT_COND(p_DescHandle->nextIndex <= MAX_DESC_LENGTH);
/* Update the Header command */
cmdFlags |= JOB_DESC_HDR_SHR_DESC_LENGTH(SHR_DESC_HDR_LENGTH_GET(shrDescCmdFlags));
cmdFlags |= JOB_DESC_HDR_LENGTH_SET(p_DescHandle->nextIndex);
/* Reinsert the Header command */
WRITE_UINT32(p_DescHandle->p_Buffer[0],cmdFlags);
}
static inline void WriteWord(t_DescHandle* p_DescHandle,uint32_t word)
{
ASSERT_COND(p_DescHandle->nextIndex+1 <= MAX_DESC_LENGTH);
WRITE_UINT32(p_DescHandle->p_Buffer[p_DescHandle->nextIndex],word);
p_DescHandle->nextIndex += 1;
}
static inline void WriteAddr(t_DescHandle* p_DescHandle,void* p_Addr)
{
uint32_t i,j;
ASSERT_COND(p_DescHandle->nextIndex+p_DescHandle->ptrLength <= MAX_DESC_LENGTH);
/* Interpeak start */
p_Addr = XX_VirtToPhys(p_Addr);
/* Interpeak end */
for (i=0; i<p_DescHandle->ptrLength-sizeof(void*)/sizeof(uint32_t); i++)
WRITE_UINT32(p_DescHandle->p_Buffer[p_DescHandle->nextIndex+i],0);
for (j=i; j<p_DescHandle->ptrLength; j++)
WRITE_UINT32(p_DescHandle->p_Buffer[p_DescHandle->nextIndex+j],((uint32_t*)&p_Addr)[j-i]);
p_DescHandle->nextIndex += p_DescHandle->ptrLength;
}
static inline void WriteData(t_DescHandle* p_DescHandle,void* p_Data,uint32_t size)
{
ASSERT_COND(p_DescHandle->nextIndex+DIV_CEIL(size,sizeof(uint32_t)) <= MAX_DESC_LENGTH);
COPY_BLOCK(p_DescHandle->p_Buffer+p_DescHandle->nextIndex,p_Data,size);
p_DescHandle->nextIndex += DIV_CEIL(size,sizeof(uint32_t));
}
@@ -0,0 +1,800 @@
/******************************************************************************
� 1995-2003, 2004, 2005-2010 Freescale Semiconductor, Inc.
All rights reserved.
This is proprietary source code of Freescale Semiconductor Inc.,
and its use is subject to the NetComm Device Drivers EULA.
The copyright notice above does not evidence any actual or intended
publication of such source code.
**************************************************************************/
/* Include the internal definitions of this module */
#include "sec.h"
/* Include the external interfaces of other modules */
#include "xx_ext.h"
#include "part_ext.h"
#include "error_ext.h"
#include "string_ext.h"
#define __ERR_MODULE__ MODULE_SEC
static t_Error CheckInitParameters(t_Sec* p_Sec);
static void InitRegs(t_Sec* p_Sec);
static void PrintCcbJobStatus (t_SecJobStatus* p_JobStatus);
static void PrintJhuJobStatus (t_SecJobStatus* p_JobStatus);
static void PrintDecoJobStatus(t_SecJobStatus* p_JobStatus);
static void PrintJqJobStatus (t_SecJobStatus* p_JobStatus);
static void PrintJhtJobStatus (t_SecJobStatus* p_JobStatus);
static void DumpGenRegs (t_SecGenRegs * p_Regs,char* p_Title);
static void DumpStatRegs(t_SecStatRegs* p_Regs,char* p_Title);
/*******************************/
/* Initialization Unit (below) */
t_Handle SEC_Config(t_SecParam* p_Param)
{
t_Sec* p_Sec;
SANITY_CHECK_EXIT(p_Param,E_NULL_POINTER);
/* Allocate the driver structure */
p_Sec = (t_Sec*)XX_Malloc(sizeof(t_Sec));
if (p_Sec == NULL)
{
REPORT_ERROR(MAJOR,E_NO_MEMORY,("Driver"));
return (t_Handle)p_Sec;
}
memset(p_Sec,0,sizeof(t_Sec));
/* Allocate the driver parameters structure */
p_Sec->p_DriverParam = (t_SecDriverParam*)XX_Malloc(sizeof(t_SecDriverParam));
if (p_Sec->p_DriverParam == NULL)
{
REPORT_ERROR(MAJOR,E_NO_MEMORY,("Driver parameters"));
return (t_Handle)p_Sec;
}
memset(p_Sec->p_DriverParam,0,sizeof(t_SecDriverParam));
/* Configure the driver parameters */
p_Sec->p_DriverParam->guestId = p_Param->guestId ;
p_Sec->p_DriverParam->baseAddr = p_Param->baseAddr;
p_Sec->p_DriverParam->softReset = DEFAULT_softReset;
p_Sec->p_DriverParam->addrSpace = DEFAULT_addrSpace;
return (t_Handle)p_Sec;
}
t_Error SEC_Init(t_Handle h_Sec)
{
t_Sec* p_Sec = (t_Sec*)h_Sec;
SANITY_CHECK_EXIT(p_Sec,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_Sec->p_DriverParam,E_INVALID_STATE);
CHECK_INIT_PARAMETERS(p_Sec,CheckInitParameters);
p_Sec->p_MemMap = CAST_UINT64_TO_POINTER(p_Sec->p_DriverParam->baseAddr);
if (p_Sec->p_DriverParam->guestId == NCSW_MASTER_ID)
InitRegs(p_Sec);
XX_Free(p_Sec->p_DriverParam);
p_Sec->p_DriverParam = NULL;
if (SEC_GetPtrSize(h_Sec) < sizeof(void*))
RETURN_ERROR(MAJOR,E_CONFLICT,("SEC address space is smaller than this core's address space"));
return E_OK;
}
t_Error SEC_Free(t_Handle h_Sec)
{
t_Sec* p_Sec = (t_Sec*)h_Sec;
SANITY_CHECK_EXIT(p_Sec,E_INVALID_HANDLE);
if (p_Sec->p_DriverParam)
XX_Free(p_Sec->p_DriverParam);
XX_Free(p_Sec);
return E_OK;
}
/* Initialization Unit (above) */
/*******************************/
/***************************************/
/* Advanced Configuration Unit (below) */
t_Error SEC_ConfigSoftReset(t_Handle h_Sec,
e_SecSoftReset softReset)
{
t_Sec* p_Sec = (t_Sec*)h_Sec;
SANITY_CHECK_EXIT(p_Sec,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_Sec->p_DriverParam,E_INVALID_STATE);
if (p_Sec->p_DriverParam->guestId != NCSW_MASTER_ID)
RETURN_ERROR(MAJOR,E_INVALID_OPERATION,("Only the Master user can configure the Soft-Reset mode"));
p_Sec->p_DriverParam->softReset = softReset;
return E_OK;
}
t_Error SEC_ConfigAddrSpace(t_Handle h_Sec,
e_SecAddrSpace addrSpace)
{
t_Sec* p_Sec = (t_Sec*)h_Sec;
SANITY_CHECK_EXIT(p_Sec,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_Sec->p_DriverParam,E_INVALID_STATE);
if (p_Sec->p_DriverParam->guestId != NCSW_MASTER_ID)
RETURN_ERROR(MAJOR,E_INVALID_OPERATION,("Only the Master user can configure the Address-Space mode"));
p_Sec->p_DriverParam->addrSpace = addrSpace;
return E_OK;
}
/* Advanced Configuration Unit (above) */
/***************************************/
/********************************/
/* Runtime Control Unit (below) */
uint32_t SEC_GetPtrSize(t_Handle h_Sec)
{
t_Sec* p_Sec = (t_Sec*)h_Sec;
uint32_t mcfgr;
SANITY_CHECK_EXIT(p_Sec,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_Sec->p_DriverParam==NULL,E_INVALID_STATE);
mcfgr = GET_UINT32(p_Sec->p_MemMap->gen.mcfgr);
if ((mcfgr & MCFGR_PS) == MCFGR_PS)
return sizeof(uint64_t);
else
return sizeof(uint32_t);
}
uint32_t SEC_GetBurstSize(t_Handle h_Sec)
{
t_Sec* p_Sec = (t_Sec*)h_Sec;
uint32_t mcfgr;
SANITY_CHECK_EXIT(p_Sec,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_Sec->p_DriverParam==NULL,E_INVALID_STATE);
mcfgr = GET_UINT32(p_Sec->p_MemMap->gen.mcfgr);
if ((mcfgr & MCFGR_BURST) == MCFGR_BURST)
return 64;
else
return 32;
}
uint16_t SEC_GetIpIdNum(t_Handle h_Sec)
{
t_Sec* p_Sec = (t_Sec*)h_Sec;
uint64_t secvidr;
SANITY_CHECK_EXIT(p_Sec,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_Sec->p_DriverParam==NULL,E_INVALID_STATE);
secvidr = SEC_GET_UINT64_HI_LO(p_Sec->p_MemMap->stat.secvidr);
return (uint16_t)SECVIDR_IP_ID(secvidr);
}
uint8_t SEC_GetMajRevNum(t_Handle h_Sec)
{
t_Sec* p_Sec = (t_Sec*)h_Sec;
uint64_t secvidr;
SANITY_CHECK_EXIT(p_Sec,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_Sec->p_DriverParam==NULL,E_INVALID_STATE);
secvidr = SEC_GET_UINT64_HI_LO(p_Sec->p_MemMap->stat.secvidr);
return (uint8_t)SECVIDR_MAJ_REV(secvidr);
}
uint8_t SEC_GetMinRevNum(t_Handle h_Sec)
{
t_Sec* p_Sec = (t_Sec*)h_Sec;
uint64_t secvidr;
SANITY_CHECK_EXIT(p_Sec,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_Sec->p_DriverParam==NULL,E_INVALID_STATE);
secvidr = SEC_GET_UINT64_HI_LO(p_Sec->p_MemMap->stat.secvidr);
return (uint8_t)SECVIDR_MIN_REV(secvidr);
}
t_Error SEC_InitJqLiodnReg(t_Handle h_Sec,
uint8_t jobQueueId,
uint16_t seqLiodnVal,
uint16_t nonSeqLiodnVal,
bool allowMtdJobs)
{
t_Sec* p_Sec = (t_Sec*)h_Sec;
uint64_t jqliodnr = 0;
SANITY_CHECK_EXIT(p_Sec,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_Sec->p_DriverParam==NULL,E_INVALID_STATE);
SANITY_CHECK_EXIT(jobQueueId<SEC_TOTAL_NUM_OF_JQS,E_INVALID_ID);
jqliodnr |= JQLIODNR_LCK;
jqliodnr |= allowMtdJobs? JQLIODNR_AMTD:0;
jqliodnr |= JQLIODNR_NSLIODN(nonSeqLiodnVal);
jqliodnr |= JQLIODNR_SLIODN (seqLiodnVal );
switch (jobQueueId)
{
case 0:
SEC_WRITE_UINT64_LO_HI(p_Sec->p_MemMap->gen.jq0liodnr,jqliodnr);
break;
case 1:
SEC_WRITE_UINT64_LO_HI(p_Sec->p_MemMap->gen.jq1liodnr,jqliodnr);
break;
case 2:
SEC_WRITE_UINT64_LO_HI(p_Sec->p_MemMap->gen.jq2liodnr,jqliodnr);
break;
case 3:
SEC_WRITE_UINT64_LO_HI(p_Sec->p_MemMap->gen.jq3liodnr,jqliodnr);
break;
}
return E_OK;
}
uint64_t SEC_CalcByteSwapFlags(e_SecByteSwap byteSwap,
uint64_t swap1In4,
uint64_t swap2In4,
uint64_t swap4In8,
uint64_t swap8In16)
{
switch (byteSwap)
{
case e_SEC_BYTE_SWAP_NONE : break ;
case e_SEC_BYTE_SWAP_1_IN_2 : return swap1In4|swap2In4 ;
case e_SEC_BYTE_SWAP_1_IN_4 : return swap1In4 ;
case e_SEC_BYTE_SWAP_1_IN_8 : return swap1In4| swap4In8 ;
case e_SEC_BYTE_SWAP_1_IN_16: return swap1In4| swap4In8|swap8In16;
case e_SEC_BYTE_SWAP_2_IN_4 : return swap2In4 ;
case e_SEC_BYTE_SWAP_2_IN_8 : return swap2In4|swap4In8 ;
case e_SEC_BYTE_SWAP_2_IN_16: return swap2In4|swap4In8|swap8In16;
case e_SEC_BYTE_SWAP_4_IN_8 : return swap4In8 ;
case e_SEC_BYTE_SWAP_4_IN_16: return swap4In8|swap8In16;
case e_SEC_BYTE_SWAP_8_IN_16: return swap8In16;
}
return 0;
}
t_SecJobStatus SEC_DecodeJobStatus(uint32_t jobStatus)
{
t_SecJobStatus decodedJobStatus;
decodedJobStatus.sourceId = (uint8_t)OSTAR_SSRC(jobStatus);
switch (decodedJobStatus.sourceId)
{
case SEC_JOB_STATUS_SOURCE_NONE:
break;
case SEC_JOB_STATUS_SOURCE_CCB:
decodedJobStatus.details.ccbDetails.jump = (bool )OSTAR_CCB_JMP (jobStatus);
decodedJobStatus.details.ccbDetails.descIndex = (uint8_t)OSTAR_CCB_DESC_INDEX(jobStatus);
decodedJobStatus.details.ccbDetails.algorithm = (uint8_t)OSTAR_CCB_ALGORITHM (jobStatus);
decodedJobStatus.details.ccbDetails.descError = (uint8_t)OSTAR_CCB_DESC_ERROR(jobStatus);
break;
case SEC_JOB_STATUS_SOURCE_JHU:
decodedJobStatus.details.jhuDetails.jump = (bool )OSTAR_JHU_JMP (jobStatus);
decodedJobStatus.details.jhuDetails.descIndex = (uint8_t)OSTAR_JHU_DESC_INDEX(jobStatus);
decodedJobStatus.details.jhuDetails.status = (uint8_t)OSTAR_JHU_STATUS (jobStatus);
break;
case SEC_JOB_STATUS_SOURCE_DECO:
decodedJobStatus.details.decoDetails.jump = (bool )OSTAR_DECO_JMP (jobStatus);
decodedJobStatus.details.decoDetails.descIndex = (uint8_t)OSTAR_DECO_DESC_INDEX(jobStatus);
decodedJobStatus.details.decoDetails.descError = (uint8_t)OSTAR_DECO_DESC_ERROR(jobStatus);
break;
case SEC_JOB_STATUS_SOURCE_JQ:
decodedJobStatus.details.jqDetails.numOfDars = (uint8_t)OSTAR_JQ_NADDR (jobStatus);
decodedJobStatus.details.jqDetails.descError = (uint8_t)OSTAR_JQ_DESC_ERROR(jobStatus);
break;
case SEC_JOB_STATUS_SOURCE_JHT:
decodedJobStatus.details.jhtDetails.jump = (bool )OSTAR_JHT_JMP (jobStatus);
decodedJobStatus.details.jhtDetails.descIndex = (uint8_t)OSTAR_JHT_DESC_INDEX(jobStatus);
decodedJobStatus.details.jhtDetails.condCodes = (uint8_t)OSTAR_JHT_COND_CODES(jobStatus);
break;
}
return decodedJobStatus;
}
#if (DEBUG_ERRORS > 0)
void SEC_PrintJobStatus(uint32_t jobStatus)
{
t_SecJobStatus decodedJobStatus = SEC_DecodeJobStatus(jobStatus);
switch (decodedJobStatus.sourceId)
{
case SEC_JOB_STATUS_SOURCE_NONE:
break;
case SEC_JOB_STATUS_SOURCE_CCB:
PrintCcbJobStatus(&decodedJobStatus);
break;
case SEC_JOB_STATUS_SOURCE_JHU:
PrintJhuJobStatus(&decodedJobStatus);
break;
case SEC_JOB_STATUS_SOURCE_DECO:
PrintDecoJobStatus(&decodedJobStatus);
break;
case SEC_JOB_STATUS_SOURCE_JQ:
PrintJqJobStatus(&decodedJobStatus);
break;
case SEC_JOB_STATUS_SOURCE_JHT:
PrintJhtJobStatus(&decodedJobStatus);
break;
}
}
void SEC_DumpRegisters(t_Handle h_Sec)
{
t_Sec* p_Sec = (t_Sec*)h_Sec;
SANITY_CHECK_EXIT(p_Sec,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_Sec->p_DriverParam==NULL,E_INVALID_STATE);
DumpGenRegs (&p_Sec->p_MemMap->gen ,"General Registers");
DumpStatRegs(&p_Sec->p_MemMap->stat,"Status Registers" );
}
#endif /* (DEBUG_ERRORS > 0) */
/* Runtime Control Unit (above) */
/********************************/
/*****************************/
/* Internal Routines (below) */
static t_Error CheckInitParameters(t_Sec* p_Sec)
{
if (p_Sec->p_DriverParam->baseAddr == 0)
RETURN_ERROR(MAJOR,E_INVALID_VALUE,("Base address"));
return E_OK;
}
static void InitRegs(t_Sec* p_Sec)
{
uint32_t mcfgr = GET_UINT32(p_Sec->p_MemMap->gen.mcfgr);
if (p_Sec->p_DriverParam->softReset == e_SEC_SOFT_RESET_ON_INIT)
{
mcfgr |= MCFGR_SWRST;
WRITE_UINT32(p_Sec->p_MemMap->gen.mcfgr,mcfgr);
mcfgr |= MCFGR_DMA_RST;
WRITE_UINT32(p_Sec->p_MemMap->gen.mcfgr,mcfgr);
do mcfgr = GET_UINT32(p_Sec->p_MemMap->gen.mcfgr);
while ((p_Sec->p_MemMap->gen.mcfgr & MCFGR_DMA_RST) == MCFGR_DMA_RST);
do mcfgr = GET_UINT32(p_Sec->p_MemMap->gen.mcfgr);
while ((p_Sec->p_MemMap->gen.mcfgr & MCFGR_SWRST) == MCFGR_SWRST);
}
if (p_Sec->p_DriverParam->addrSpace == e_SEC_ADDR_SPACE_64_BIT)
mcfgr |= MCFGR_PS;
WRITE_UINT32(p_Sec->p_MemMap->gen.mcfgr,mcfgr);
}
#if (DEBUG_ERRORS > 0)
#include "debug_ext.h"
static void PrintCcbJobStatus(t_SecJobStatus* p_JobStatus)
{
XX_Print("Source = Cryptographic Control Block\n");
if (p_JobStatus->details.ccbDetails.jump)
XX_Print("The descriptor made a jump to another descriptor\n");
XX_Print("Index into the failing descriptor = %u\n",p_JobStatus->details.ccbDetails.descIndex);
switch (p_JobStatus->details.ccbDetails.algorithm)
{
case SEC_CCB_ALGORITHM_AES:
XX_Print("Algorithm that generated the error = AES\n");
break;
case SEC_CCB_ALGORITHM_DES_3DES:
XX_Print("Algorithm that generated the error = DES or 3DES\n");
break;
case SEC_CCB_ALGORITHM_ARC4:
XX_Print("Algorithm that generated the error = ARC4\n");
break;
case SEC_CCB_ALGORITHM_MD5_SHA:
XX_Print("Algorithm that generated the error = MD5 or SHA\n");
break;
case SEC_CCB_ALGORITHM_RNG:
XX_Print("Algorithm that generated the error = RNG\n");
break;
case SEC_CCB_ALGORITHM_SNOW_F8:
XX_Print("Algorithm that generated the error = SNOW f8\n");
break;
case SEC_CCB_ALGORITHM_KASUMI_F8_F9:
XX_Print("Algorithm that generated the error = Kasumi f8 / f9\n");
break;
case SEC_CCB_ALGORITHM_PUBLIC_KEY:
XX_Print("Algorithm that generated the error = Public Key\n");
break;
case SEC_CCB_ALGORITHM_CRC:
XX_Print("Algorithm that generated the error = CRC\n");
break;
case SEC_CCB_ALGORITHM_SNOW_F9:
XX_Print("Algorithm that generated the error = SNOW f9\n");
break;
}
switch (p_JobStatus->details.ccbDetails.descError)
{
case SEC_CCB_DESC_ERROR_NONE:
break;
case SEC_CCB_DESC_ERROR_MODE:
XX_Print("Descriptor error = Mode error\n");
break;
case SEC_CCB_DESC_ERROR_DATA_SIZE:
XX_Print("Descriptor error = Data size error\n");
break;
case SEC_CCB_DESC_ERROR_KEY_SIZE:
XX_Print("Descriptor error = Key size error\n");
break;
case SEC_CCB_DESC_ERROR_PKHA_A_MEM_SIZE:
XX_Print("Descriptor error = PKHA A memory size error\n");
break;
case SEC_CCB_DESC_ERROR_PKHA_B_MEM_SIZE:
XX_Print("Descriptor error = PKHA B memory size error\n");
break;
case SEC_CCB_DESC_ERROR_DATA_OUT_OF_SEQ:
XX_Print("Descriptor error = Data arrived out of sequence error\n");
break;
case SEC_CCB_DESC_ERROR_PKHA_DIV_BY_ZERO:
XX_Print("Descriptor error = PKHA divide-by-zero error\n");
break;
case SEC_CCB_DESC_ERROR_PKHA_MODULES_EVEN:
XX_Print("Descriptor error = PKHA modulus even error\n");
break;
case SEC_CCB_DESC_ERROR_DES_KEY_PARITY:
XX_Print("Descriptor error = DES key parity error\n");
break;
case SEC_CCB_DESC_ERROR_ICV_CHECK:
XX_Print("Descriptor error = ICV check failed\n");
break;
case SEC_CCB_DESC_ERROR_HARDWARE:
XX_Print("Descriptor error = Hardware error\n");
break;
case SEC_CCB_DESC_ERROR_CCM_AAD_SIZE:
XX_Print("Descriptor error = Unsupported CCM AAD size\n");
break;
case SEC_CCB_DESC_ERROR_CHA_NOT_RESET:
XX_Print("Descriptor error = Class 1 CHA not reset\n");
break;
case SEC_CCB_DESC_ERROR_CHA_COMB_SELECTED:
XX_Print("Descriptor error = Invalid CHA combination selected\n");
break;
case SEC_CCB_DESC_ERROR_CHA_SELECTED:
XX_Print("Descriptor error = Invalid CHA selected\n");
break;
}
}
void PrintJhuJobStatus(t_SecJobStatus* p_JobStatus)
{
XX_Print("Source = Jump Halt User\n");
if (p_JobStatus->details.jhuDetails.jump)
XX_Print("The descriptor made a jump to another descriptor\n");
XX_Print("Index into the failing descriptor = %u\n",p_JobStatus->details.jhuDetails.descIndex);
XX_Print("User status field from Jump command = %u\n",p_JobStatus->details.jhuDetails.status);
}
static void PrintDecoJobStatus(t_SecJobStatus* p_JobStatus)
{
XX_Print("Source = Descriptor Controller\n");
if (p_JobStatus->details.decoDetails.jump)
XX_Print("The descriptor made a jump to another descriptor\n");
XX_Print("Index into the failing descriptor = %u\n",p_JobStatus->details.decoDetails.descIndex);
switch (p_JobStatus->details.decoDetails.descError)
{
case SEC_DECO_DESC_ERROR_NONE:
break;
case SEC_DECO_DESC_ERROR_SGT_LENGTH:
XX_Print("Descriptor error = SGT length error\n");
break;
case SEC_DECO_DESC_ERROR_JQ_CONTROL:
XX_Print("Descriptor error = JQ control error\n");
break;
case SEC_DECO_DESC_ERROR_CMD:
XX_Print("Descriptor error = Invalid command\n");
break;
case SEC_DECO_DESC_ERROR_KEY_CMD:
XX_Print("Descriptor error = Invalid Key command\n");
break;
case SEC_DECO_DESC_ERROR_LOAD_CMD:
XX_Print("Descriptor error = Invalid Load command\n");
break;
case SEC_DECO_DESC_ERROR_STORE_CMD:
XX_Print("Descriptor error = Invalid Store command\n");
break;
case SEC_DECO_DESC_ERROR_OPERATION_CMD:
XX_Print("Descriptor error = Invalid Operation command\n");
break;
case SEC_DECO_DESC_ERROR_FIFO_LOAD_CMD:
XX_Print("Descriptor error = Invalid Fifo-Load command\n");
break;
case SEC_DECO_DESC_ERROR_FIFO_STORE_CMD:
XX_Print("Descriptor error = Invalid Fifo-Store command\n");
break;
case SEC_DECO_DESC_ERROR_MOVE_CMD:
XX_Print("Descriptor error = Invalid Move command\n");
break;
case SEC_DECO_DESC_ERROR_JUMP_CMD:
XX_Print("Descriptor error = Invalid Jump command\n");
break;
case SEC_DECO_DESC_ERROR_MATH_CMD:
XX_Print("Descriptor error = Invalid Math command\n");
break;
case SEC_DECO_DESC_ERROR_SIGNED_HASH_CMD:
XX_Print("Descriptor error = Invalid Signed-Hash command\n");
break;
case SEC_DECO_DESC_ERROR_SEQUENCE_CMD:
XX_Print("Descriptor error = Invalid Sequence command\n");
break;
case SEC_DECO_DESC_ERROR_SKIP_DATA_TYPE:
XX_Print("Descriptor error = Skip data type invalid\n");
break;
case SEC_DECO_DESC_ERROR_SHARED_HEADER:
XX_Print("Descriptor error = Shared header error\n");
break;
case SEC_DECO_DESC_ERROR_HEADER:
XX_Print("Descriptor error = Header error\n");
break;
case SEC_DECO_DESC_ERROR_BURSTER:
XX_Print("Descriptor error = Burster error\n");
break;
case SEC_DECO_DESC_ERROR_CONTEXT_REG_LEN:
XX_Print("Descriptor error = Context register length error\n");
break;
case SEC_DECO_DESC_ERROR_DMA:
XX_Print("Descriptor error = DMA error\n");
break;
case SEC_DECO_DESC_ERROR_JQ_RESET:
XX_Print("Descriptor error = Job failed due to job queue reset\n");
break;
case SEC_DECO_DESC_ERROR_FAIL_MODE:
XX_Print("Descriptor error = Job failed due to fail mode\n");
break;
case SEC_DECO_DESC_ERROR_WATCHDOG_TIMEOUT:
XX_Print("Descriptor error = Watchdog timer timeout error\n");
break;
case SEC_DECO_DESC_ERROR_KEY_COPY:
XX_Print("Descriptor error = Key copy failure\n");
break;
case SEC_DECO_DESC_ERROR_DATA_COPY:
XX_Print("Descriptor error = Data copy failure\n");
break;
case SEC_DECO_DESC_ERROR_LIODN:
XX_Print("Descriptor error = LIODN error\n");
break;
case SEC_DECO_DESC_ERROR_RESET:
XX_Print("Descriptor error = Reset initiated via the DRR\n");
break;
case SEC_DECO_DESC_ERROR_NONCE:
XX_Print("Descriptor error = Nonce error\n");
break;
case SEC_DECO_DESC_ERROR_META_DATA_SIZE:
XX_Print("Descriptor error = Meta data too large\n");
break;
case SEC_DECO_DESC_ERROR_DNR:
XX_Print("Descriptor error = DNR (do not run) error\n");
break;
case SEC_DECO_DESC_ERROR_PROTOCOL_CMD:
XX_Print("Descriptor error = Undefined protocol command\n");
break;
case SEC_DECO_DESC_ERROR_PDB_SETTIGS:
XX_Print("Descriptor error = Invalid setting in PDB\n");
break;
case SEC_DECO_DESC_ERROR_LATE:
XX_Print("Descriptor error = Anti-replay late error\n");
break;
case SEC_DECO_DESC_ERROR_REPLAY:
XX_Print("Descriptor error = Anti-replay replay error\n");
break;
case SEC_DECO_DESC_ERROR_SEQ_NUM_OVERFLOW:
XX_Print("Descriptor error = Sequence number overflow\n");
break;
case SEC_DECO_DESC_ERROR_SIGVER_SIGNATURE:
XX_Print("Descriptor error = Sigver invalid signature\n");
break;
case SEC_DECO_DESC_ERROR_DSA_SIGN:
XX_Print("Descriptor error = DSA sign illegal test descriptor\n");
break;
case SEC_DECO_DESC_ERROR_PROTOCOL_FORMAT:
XX_Print("Descriptor error = Protocol format error\n");
break;
case SEC_DECO_DESC_ERROR_PROTOCOL_SIZE:
XX_Print("Descriptor error = Protocol size error\n");
break;
case SEC_DECO_DESC_ERROR_BLOB_MODE:
XX_Print("Descriptor error = Undefined blob mode\n");
break;
case SEC_DECO_DESC_ERROR_BLOB_SEC_MEM_MODE:
XX_Print("Descriptor error = Secure memory blob mode error\n");
break;
case SEC_DECO_DESC_ERROR_BLOB_KEY_SIZE:
XX_Print("Descriptor error = Black blob key or input size error\n");
break;
case SEC_DECO_DESC_ERROR_BLOB_KEY_DEST:
XX_Print("Descriptor error = Invalid key destination\n");
break;
case SEC_DECO_DESC_ERROR_BLOB_TRST_SEC_MODE:
XX_Print("Descriptor error = Trusted/Secure mode error\n");
break;
case SEC_DECO_DESC_ERROR_TTL_OR_HOP_LIMIT:
XX_Print("Descriptor error = IPsec TTL or hop limit field 0\n");
break;
case SEC_DECO_DESC_ERROR_3GPP_HFN:
XX_Print("Descriptor error = 3GPP HFN matches or exceeds threshold\n");
break;
}
}
void PrintJqJobStatus(t_SecJobStatus* p_JobStatus)
{
XX_Print("Source = Job Queue\n");
XX_Print("Number of descriptor addresses requested = %u\n",p_JobStatus->details.jqDetails.numOfDars);
switch (p_JobStatus->details.jqDetails.descError)
{
case SEC_JQ_DESC_ERROR_NONE:
break;
case SEC_JQ_DESC_ERROR_READ_DESC_ADDR:
XX_Print("Descriptor error = Error reading the descriptor address\n");
break;
case SEC_JQ_DESC_ERROR_READ_DESC:
XX_Print("Descriptor error = Error reading the descriptor\n");
break;
}
}
void PrintJhtJobStatus(t_SecJobStatus* p_JobStatus)
{
XX_Print("Source = Jump Halt Test\n");
if (p_JobStatus->details.jhtDetails.jump)
XX_Print("The descriptor made a jump to another descriptor\n");
XX_Print("Index into the failing descriptor = %u\n",p_JobStatus->details.jhtDetails.descIndex);
if (p_JobStatus->details.jhtDetails.condCodes & SEC_JHT_ERROR_PKHA_IS_ZERO)
XX_Print("The result of a PKHA operation is zero\n");
if (p_JobStatus->details.jhtDetails.condCodes & SEC_JHT_ERROR_PKHA_GCD_ONE)
XX_Print("The greatest common divisor of two numbers is one\n");
if (p_JobStatus->details.jhtDetails.condCodes & SEC_JHT_ERROR_PKHA_IS_PRIME)
XX_Print("The given number is probably prime\n");
if (p_JobStatus->details.jhtDetails.condCodes & SEC_JHT_ERROR_MATH_N)
XX_Print("The result is negative\n");
if (p_JobStatus->details.jhtDetails.condCodes & SEC_JHT_ERROR_MATH_Z)
XX_Print("The result of a math operation is zero\n");
if (p_JobStatus->details.jhtDetails.condCodes & SEC_JHT_ERROR_MATH_C)
XX_Print("The math operation resulted in a carry or borrow\n");
if (p_JobStatus->details.jhtDetails.condCodes & SEC_JHT_ERROR_MATH_NV)
XX_Print("A combination of the sign bit and overflow\n");
}
static void DumpGenRegs(t_SecGenRegs* p_Regs,char* p_Title)
{
DECLARE_DUMP;
DUMP_TITLE(p_Regs,(p_Title));
DUMP_VAR(p_Regs,mcfgr );
DUMP_VAR(p_Regs,jq0liodnr );
DUMP_VAR(p_Regs,jq1liodnr );
DUMP_VAR(p_Regs,jq2liodnr );
DUMP_VAR(p_Regs,jq3liodnr );
DUMP_VAR(p_Regs,rticaliodnr);
DUMP_VAR(p_Regs,rticbliodnr);
DUMP_VAR(p_Regs,rticcliodnr);
DUMP_VAR(p_Regs,rticdliodnr);
DUMP_VAR(p_Regs,decoreqr );
DUMP_VAR(p_Regs,deco0liodnr);
DUMP_VAR(p_Regs,deco1liodnr);
DUMP_VAR(p_Regs,deco2liodnr);
DUMP_VAR(p_Regs,deco3liodnr);
DUMP_VAR(p_Regs,deco4liodnr);
DUMP_VAR(p_Regs,decoavlr );
DUMP_VAR(p_Regs,decorstr );
DUMP_ARR(p_Regs,jdkekr );
DUMP_ARR(p_Regs,tdkekr );
DUMP_ARR(p_Regs,tdskr );
DUMP_VAR(p_Regs,sknr );
}
static void DumpStatRegs(t_SecStatRegs* p_Regs,char* p_Title)
{
DECLARE_DUMP;
DUMP_TITLE(p_Regs,(p_Title));
DUMP_VAR(p_Regs,req_deq );
DUMP_VAR(p_Regs,ob_enc_req );
DUMP_VAR(p_Regs,ib_dec_req );
DUMP_VAR(p_Regs,ob_encrypt );
DUMP_VAR(p_Regs,ob_protect );
DUMP_VAR(p_Regs,ib_decrypt );
DUMP_VAR(p_Regs,ib_validated);
DUMP_VAR(p_Regs,crnr );
DUMP_VAR(p_Regs,ctpr );
DUMP_VAR(p_Regs,far );
DUMP_VAR(p_Regs,falr );
DUMP_VAR(p_Regs,fadr );
DUMP_VAR(p_Regs,sstar );
DUMP_VAR(p_Regs,rvidr );
DUMP_VAR(p_Regs,ccbvidr );
DUMP_VAR(p_Regs,chavidr );
DUMP_VAR(p_Regs,chanumr );
DUMP_VAR(p_Regs,secvidr );
}
#endif /* (DEBUG_ERRORS > 0) */
/* Internal Routines (above) */
/*****************************/
@@ -0,0 +1,42 @@
/******************************************************************************
© 1995-2003, 2004, 2005-2010 Freescale Semiconductor, Inc.
All rights reserved.
This is proprietary source code of Freescale Semiconductor Inc.,
and its use is subject to the NetComm Device Drivers EULA.
The copyright notice above does not evidence any actual or intended
publication of such source code.
**************************************************************************/
#ifndef __SEC_H
#define __SEC_H
#include "sec_ext.h"
#include "sec_regs.h"
typedef struct t_SecDriverParam
{
uint32_t guestId ; /* Guest ID */
uint64_t baseAddr ; /* Base address */
e_SecSoftReset softReset; /* Soft reset */
e_SecAddrSpace addrSpace; /* Address space */
}
t_SecDriverParam;
typedef struct t_Sec
{
t_SecDriverParam* p_DriverParam; /* Driver parameters */
t_SecGenMemMap* p_MemMap ; /* Memory-mapped registers */
}
t_Sec;
#define DEFAULT_softReset e_SEC_SOFT_RESET_ON_INIT
#define DEFAULT_addrSpace e_SEC_ADDR_SPACE_64_BIT
#endif /* __SEC_H */
@@ -0,0 +1,612 @@
/******************************************************************************
� 1995-2003, 2004, 2005-2010 Freescale Semiconductor, Inc.
All rights reserved.
This is proprietary source code of Freescale Semiconductor Inc.,
and its use is subject to the NetComm Device Drivers EULA.
The copyright notice above does not evidence any actual or intended
publication of such source code.
**************************************************************************/
/* Include the internal definitions of this module */
#include "sec_jq.h"
/* Include the external interfaces of other modules */
#include "xx_ext.h"
#include "part_ext.h"
#include "error_ext.h"
#include "string_ext.h"
/* wind river start */
/* Needed for memory barrier during job dequeueing */
#include <vxAtomicLib.h>
/* wind river end */
#define __ERR_MODULE__ MODULE_SEC
static t_Error CheckInitParameters(t_SecJq* p_SecJq);
static t_Error InitRings(t_SecJq* p_SecJq);
static t_Error InitIntrs(t_SecJq* p_SecJq);
static t_Error InitLiodn(t_SecJq* p_SecJq);
static void InitRegs(t_SecJq* p_SecJq);
static void Isr(t_Handle h_SecJq);
static void DumpJqRegs (t_SecJqRegs * p_Regs,char* p_Title);
static void DumpStatRegs(t_SecStatRegs* p_Regs,char* p_Title);
/*******************************/
/* Initialization Unit (below) */
t_Handle SEC_JQ_Config(t_SecJqParam* p_Param)
{
t_SecJq* p_SecJq;
SANITY_CHECK_EXIT(p_Param,E_NULL_POINTER);
/* Allocate the driver structure */
/* windriver start */
/* p_SecJq = (t_SecJq*)XX_Malloc(sizeof(t_SecJq)); */
p_SecJq = (t_SecJq*)XX_MallocSmart(sizeof(t_SecJq), p_Param->memId, 1);
/* windriver end */
if (p_SecJq == NULL)
{
REPORT_ERROR(MAJOR,E_NO_MEMORY,("Driver"));
return (t_Handle)p_SecJq;
}
memset(p_SecJq,0,sizeof(t_SecJq));
/* Allocate the driver parameters structure */
p_SecJq->p_DriverParam = (t_SecJqDriverParam*)XX_Malloc(sizeof(t_SecJqDriverParam));
if (p_SecJq->p_DriverParam == NULL)
{
REPORT_ERROR(MAJOR,E_NO_MEMORY,("Driver parameters"));
return (t_Handle)p_SecJq;
}
memset(p_SecJq->p_DriverParam,0,sizeof(t_SecJqDriverParam));
/* Configure the driver parameters */
p_SecJq->p_DriverParam->h_Sec = p_Param->h_Sec ;
p_SecJq->p_DriverParam->baseAddr = p_Param->baseAddr ;
p_SecJq->p_DriverParam->jobQueueId = p_Param->jobQueueId ;
p_SecJq->p_DriverParam->seqLiodnVal = p_Param->seqLiodnVal ;
p_SecJq->p_DriverParam->nonSeqLiodnVal = p_Param->nonSeqLiodnVal;
p_SecJq->p_DriverParam->allowMtdJobs = DEFAULT_allowMtdJobs ;
p_SecJq->p_DriverParam->inputRingLen = DEFAULT_inputRingLen ;
p_SecJq->p_DriverParam->inputRingMemId = DEFAULT_inputRingMemId ;
p_SecJq->p_DriverParam->outputRingLen = DEFAULT_outputRingLen ;
p_SecJq->p_DriverParam->outputRingMemId = DEFAULT_outputRingMemId;
p_SecJq->p_DriverParam->intrJobCountThr = DEFAULT_intrJobCountThr;
p_SecJq->p_DriverParam->intrTicCountThr = DEFAULT_intrTicCountThr;
p_SecJq->p_DriverParam->icdByteSwap = DEFAULT_icdByteSwap ;
p_SecJq->p_DriverParam->ocdByteSwap = DEFAULT_ocdByteSwap ;
p_SecJq->p_DriverParam->imdByteSwap = DEFAULT_imdByteSwap ;
p_SecJq->p_DriverParam->omdByteSwap = DEFAULT_omdByteSwap ;
p_SecJq->p_DriverParam->f_Cbr = p_Param->f_Cbr ;
p_SecJq->p_DriverParam->h_App = p_Param->h_App ;
p_SecJq->p_DriverParam->irq = p_Param->irq ;
return (t_Handle)p_SecJq;
}
t_Error SEC_JQ_Init(t_Handle h_SecJq)
{
t_SecJq* p_SecJq = (t_SecJq*)h_SecJq;
t_Error errCode;
SANITY_CHECK_EXIT(p_SecJq,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecJq->p_DriverParam,E_INVALID_STATE);
CHECK_INIT_PARAMETERS(p_SecJq,CheckInitParameters);
p_SecJq->p_MemMap = CAST_UINT64_TO_POINTER(p_SecJq->p_DriverParam->baseAddr);
p_SecJq->secPtrLength = SEC_GetPtrSize(p_SecJq->p_DriverParam->h_Sec)/sizeof(uint32_t);
p_SecJq->corePtrLength = sizeof(void*)/sizeof(uint32_t);
p_SecJq->f_Cbr = p_SecJq->p_DriverParam->f_Cbr;
p_SecJq->h_App = p_SecJq->p_DriverParam->h_App;
errCode = InitRings(p_SecJq);
if (errCode != E_OK)
RETURN_ERROR(MAJOR,errCode,NO_MSG);
errCode = InitIntrs(p_SecJq);
if (errCode != E_OK)
RETURN_ERROR(MAJOR,errCode,NO_MSG);
errCode = InitLiodn(p_SecJq);
if (errCode != E_OK)
RETURN_ERROR(MAJOR,errCode,NO_MSG);
InitRegs(p_SecJq);
XX_Free(p_SecJq->p_DriverParam);
p_SecJq->p_DriverParam = NULL;
return E_OK;
}
t_Error SEC_JQ_Free(t_Handle h_SecJq)
{
t_SecJq* p_SecJq = (t_SecJq*)h_SecJq;
SANITY_CHECK_EXIT(p_SecJq,E_INVALID_HANDLE);
if (p_SecJq->p_DriverParam)
XX_Free(p_SecJq->p_DriverParam);
if (p_SecJq->inputRing.p_BaseAddr)
XX_FreeSmart(p_SecJq->inputRing.p_BaseAddr);
if (p_SecJq->outputRing.p_BaseAddr)
XX_FreeSmart(p_SecJq->outputRing.p_BaseAddr);
XX_Free(p_SecJq);
return E_OK;
}
/* Initialization Unit (above) */
/*******************************/
/***************************************/
/* Advanced Configuration Unit (below) */
t_Error SEC_JQ_ConfigAllowMtdJobs(t_Handle h_SecJq,
bool allowMtdJobs)
{
t_SecJq* p_SecJq = (t_SecJq*)h_SecJq;
SANITY_CHECK_EXIT(p_SecJq,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecJq->p_DriverParam,E_INVALID_STATE);
p_SecJq->p_DriverParam->allowMtdJobs = allowMtdJobs;
return E_OK;
}
t_Error SEC_JQ_ConfigInputRing(t_Handle h_SecJq,
t_SecJqRingParam* p_RingParam)
{
t_SecJq* p_SecJq = (t_SecJq*)h_SecJq;
SANITY_CHECK_EXIT(p_SecJq,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecJq->p_DriverParam,E_INVALID_STATE);
SANITY_CHECK_EXIT(p_RingParam,E_NULL_POINTER);
p_SecJq->p_DriverParam->inputRingLen = p_RingParam->len ;
p_SecJq->p_DriverParam->inputRingMemId = p_RingParam->memId;
return E_OK;
}
t_Error SEC_JQ_ConfigOutputRing(t_Handle h_SecJq,
t_SecJqRingParam* p_RingParam)
{
t_SecJq* p_SecJq = (t_SecJq*)h_SecJq;
SANITY_CHECK_EXIT(p_SecJq,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecJq->p_DriverParam,E_INVALID_STATE);
SANITY_CHECK_EXIT(p_RingParam,E_NULL_POINTER);
p_SecJq->p_DriverParam->outputRingLen = p_RingParam->len ;
p_SecJq->p_DriverParam->outputRingMemId = p_RingParam->memId;
return E_OK;
}
t_Error SEC_JQ_ConfigInterrupts(t_Handle h_SecJq,
t_SecJqIntrParam* p_IntrParam)
{
t_SecJq* p_SecJq = (t_SecJq*)h_SecJq;
SANITY_CHECK_EXIT(p_SecJq,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecJq->p_DriverParam,E_INVALID_STATE);
SANITY_CHECK_EXIT(p_IntrParam,E_NULL_POINTER);
p_SecJq->p_DriverParam->intrJobCountThr = p_IntrParam->jobCountThr;
p_SecJq->p_DriverParam->intrTicCountThr = p_IntrParam->ticCountThr;
return E_OK;
}
t_Error SEC_JQ_ConfigByteSwap(t_Handle h_SecJq,
t_SecJqByteSwapParam* p_ByteSwapParam)
{
t_SecJq* p_SecJq = (t_SecJq*)h_SecJq;
SANITY_CHECK_EXIT(p_SecJq,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecJq->p_DriverParam,E_INVALID_STATE);
SANITY_CHECK_EXIT(p_ByteSwapParam,E_NULL_POINTER);
p_SecJq->p_DriverParam->icdByteSwap = p_ByteSwapParam->icd;
p_SecJq->p_DriverParam->ocdByteSwap = p_ByteSwapParam->ocd;
p_SecJq->p_DriverParam->imdByteSwap = p_ByteSwapParam->imd;
p_SecJq->p_DriverParam->omdByteSwap = p_ByteSwapParam->omd;
return E_OK;
}
/* Advanced Configuration Unit (above) */
/***************************************/
/********************************/
/* Runtime Control Unit (below) */
t_Error SEC_JQ_Enqueue(t_Handle h_SecJq,
void* p_JobDesc,
t_Handle h_Context)
{
t_SecJq* p_SecJq = (t_SecJq*)h_SecJq;
uint32_t secPtrLength;
uint32_t corePtrLength;
uint32_t* p_BaseAddr;
uint32_t numOfEntries;
uint32_t nextEntryIndex;
uint32_t* p_JobDescAddr;
uint32_t* p_JobDescRing;
uint32_t i,j;
SANITY_CHECK_EXIT(p_SecJq,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecJq->p_DriverParam==NULL,E_INVALID_STATE);
SANITY_CHECK_EXIT(p_JobDesc,E_NULL_POINTER);
secPtrLength = p_SecJq->secPtrLength;
corePtrLength = p_SecJq->corePtrLength;
p_BaseAddr = p_SecJq->inputRing.p_BaseAddr;
numOfEntries = p_SecJq->inputRing.numOfEntries;
nextEntryIndex = p_SecJq->inputRing.nextEntryIndex;
p_JobDescAddr = (uint32_t*)&p_JobDesc;
if (GET_UINT32(p_SecJq->p_MemMap->jq.irsar) != 0)
{
p_JobDescRing = p_BaseAddr+nextEntryIndex;
for (i=0; i<secPtrLength-corePtrLength; i++)
WRITE_UINT32(p_JobDescRing[i],0);
for (j=i; j<secPtrLength; j++)
WRITE_UINT32(p_JobDescRing[j],XX_VirtToPhys(p_JobDescAddr[j-i])); /* Interpeak: TODO: Make it generic for all ptr sizes */
/* This is ok for secPtrLength=2, corePtrLength=1 */
((t_Handle*)p_JobDesc)[-1] = h_Context;
WRITE_UINT32(p_SecJq->p_MemMap->jq.irjar,1);
nextEntryIndex = (nextEntryIndex+secPtrLength)%numOfEntries;
}
else
RETURN_ERROR(MAJOR,E_FULL,("Input ring"));
p_SecJq->inputRing.nextEntryIndex = nextEntryIndex;
return E_OK;
}
t_Error SEC_JQ_Dequeue(t_Handle h_SecJq)
{
t_SecJq* p_SecJq = (t_SecJq*)h_SecJq;
void* p_JobDesc;
t_Handle h_Context;
uint32_t secPtrLength;
uint32_t corePtrLength;
uint32_t* p_BaseAddr;
uint32_t numOfEntries;
uint32_t nextEntryIndex;
uint32_t* p_JobDescAddr;
uint32_t* p_JobDescRing;
uint32_t i,j;
SANITY_CHECK_EXIT(p_SecJq,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecJq->p_DriverParam==NULL,E_INVALID_STATE);
secPtrLength = p_SecJq->secPtrLength;
corePtrLength = p_SecJq->corePtrLength;
p_BaseAddr = p_SecJq->outputRing.p_BaseAddr;
numOfEntries = p_SecJq->outputRing.numOfEntries;
nextEntryIndex = p_SecJq->outputRing.nextEntryIndex;
p_JobDescAddr = (uint32_t*)&p_JobDesc;
/* wind river start */
/* Memory barrier due to errors for optimized code */
VX_MEM_BARRIER_RW();
/* wind river end */
while (GET_UINT32(p_SecJq->p_MemMap->jq.orsfr) != 0)
{
p_JobDescRing = p_BaseAddr+nextEntryIndex;
for (i=0; i<secPtrLength-corePtrLength; i++)
ASSERT_COND(GET_UINT32(p_JobDescRing[i])==0);
#if 1 /* wind river start*/
/* corePtrLength = 1, secPtrLength = 2 TODO: Make it work for all cases */
*p_JobDescAddr = CAST_POINTER_TO_UINT32(XX_PhysToVirt(GET_UINT64(*p_JobDescRing)));
#else
for (j=i; j<secPtrLength; j++)
p_JobDescAddr[j-i] = GET_UINT32(p_JobDescRing[j]);
#endif /* wind river end*/
h_Context = ((t_Handle*)p_JobDesc)[-1];
p_SecJq->f_Cbr(p_SecJq->h_App,p_JobDesc,h_Context,GET_UINT32(p_JobDescRing[secPtrLength]));
WRITE_UINT32(p_SecJq->p_MemMap->jq.orjrr,1);
/* wind river start */
/* Optimized code might not let the write to ORJRR complete before reading ORSFR */
VX_MEM_BARRIER_RW();
/* wind river end */
nextEntryIndex = (nextEntryIndex+secPtrLength+1)%numOfEntries;
}
p_SecJq->outputRing.nextEntryIndex = nextEntryIndex;
return E_OK;
}
#if (DEBUG_ERRORS > 0)
void SEC_JQ_DumpRegisters(t_Handle h_SecJq)
{
t_SecJq* p_SecJq = (t_SecJq*)h_SecJq;
SANITY_CHECK_EXIT(p_SecJq,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecJq->p_DriverParam==NULL,E_INVALID_STATE);
DumpJqRegs (&p_SecJq->p_MemMap->jq ,"JQ Registers" );
DumpStatRegs(&p_SecJq->p_MemMap->stat,"Status Registers");
}
#endif /* (DEBUG_ERRORS > 0) */
/* Runtime Control Unit (above) */
/********************************/
/*****************************/
/* Internal Routines (below) */
#define CHECK_RANGE(par,msg) if (!IN_RANGE(MIN_VAL_##par,p_SecJq->p_DriverParam->par,MAX_VAL_##par)) \
RETURN_ERROR(MAJOR,E_NOT_IN_RANGE,("%s must be between %d-%d",msg,MIN_VAL_##par,MAX_VAL_##par))
static t_Error CheckInitParameters(t_SecJq* p_SecJq)
{
if (p_SecJq->p_DriverParam->h_Sec == NULL)
RETURN_ERROR(MAJOR,E_INVALID_HANDLE,("SEC object"));
if (p_SecJq->p_DriverParam->baseAddr == 0)
RETURN_ERROR(MAJOR,E_INVALID_VALUE,("Base address"));
CHECK_RANGE(seqLiodnVal ,"Sequential LIODN value" );
CHECK_RANGE(nonSeqLiodnVal,"Non-sequential LIODN value" );
CHECK_RANGE(inputRingLen ,"Input ring number of entries" );
CHECK_RANGE(outputRingLen ,"Output ring number of entries");
if (p_SecJq->p_DriverParam->irq != NO_IRQ)
{
if ((p_SecJq->p_DriverParam->intrJobCountThr==1) ^
(p_SecJq->p_DriverParam->intrTicCountThr==0))
RETURN_ERROR(MAJOR,E_CONFLICT,("Interrupt thresholds"));
CHECK_RANGE(intrJobCountThr,"Interrupt job-count threshold");
#ifndef __GNUC__ /* TODO: Why doesn't this compile with Gnu??? */
CHECK_RANGE(intrTicCountThr,"Interrupt tic-count threshold");
#endif
}
return E_OK;
}
static t_Error InitRings(t_SecJq* p_SecJq)
{
uint32_t inputRingLen = p_SecJq->p_DriverParam->inputRingLen ;
int inputRingMemId = p_SecJq->p_DriverParam->inputRingMemId ;
uint32_t outputRingLen = p_SecJq->p_DriverParam->outputRingLen ;
int outputRingMemId = p_SecJq->p_DriverParam->outputRingMemId;
uint32_t sizeOfRing;
sizeOfRing = inputRingLen*(p_SecJq->secPtrLength+0)*sizeof(uint32_t);
p_SecJq->inputRing.p_BaseAddr = (uint32_t*)XX_MallocSmart(sizeOfRing,inputRingMemId,sizeof(uint32_t));
if (p_SecJq->inputRing.p_BaseAddr == NULL)
RETURN_ERROR(MAJOR,E_NO_MEMORY,("Input ring"));
p_SecJq->inputRing.numOfEntries = sizeOfRing/sizeof(uint32_t);
sizeOfRing = outputRingLen*(p_SecJq->secPtrLength+1)*sizeof(uint32_t);
p_SecJq->outputRing.p_BaseAddr = (uint32_t*)XX_MallocSmart(sizeOfRing,outputRingMemId,sizeof(uint32_t));
if (p_SecJq->outputRing.p_BaseAddr == NULL)
RETURN_ERROR(MAJOR,E_NO_MEMORY,("Output ring"));
p_SecJq->outputRing.numOfEntries = sizeOfRing/sizeof(uint32_t);
return E_OK;
}
static t_Error InitIntrs(t_SecJq* p_SecJq)
{
t_Error errCode;
int irq = p_SecJq->p_DriverParam->irq;
if (irq != NO_IRQ)
{
errCode = XX_SetIntr(irq,Isr,p_SecJq);
if (errCode != E_OK)
RETURN_ERROR(MAJOR,errCode,NO_MSG);
errCode = XX_EnableIntr(irq);
if (errCode != E_OK)
RETURN_ERROR(MAJOR,errCode,NO_MSG);
}
return E_OK;
}
static t_Error InitLiodn(t_SecJq* p_SecJq)
{
t_Error errCode;
t_Handle h_Sec = p_SecJq->p_DriverParam->h_Sec ;
uint8_t jobQueueId = p_SecJq->p_DriverParam->jobQueueId ;
uint16_t seqLiodnVal = p_SecJq->p_DriverParam->seqLiodnVal ;
uint16_t nonSeqLiodnVal = p_SecJq->p_DriverParam->nonSeqLiodnVal;
bool allowMtdJobs = p_SecJq->p_DriverParam->allowMtdJobs ;
errCode = SEC_InitJqLiodnReg(h_Sec,jobQueueId,seqLiodnVal,nonSeqLiodnVal,allowMtdJobs);
if (errCode != E_OK)
RETURN_ERROR(MAJOR,errCode,NO_MSG);
return E_OK;
}
static void InitRegs(t_SecJq* p_SecJq)
{
uint64_t irbar = 0;
uint32_t irsr = 0;
uint64_t orbar = 0;
uint32_t orsr = 0;
uint64_t cfgr = 0;
uint32_t intrJobCountThr = p_SecJq->p_DriverParam->intrJobCountThr;
uint32_t intrTicCountThr = p_SecJq->p_DriverParam->intrTicCountThr;
e_SecByteSwap icdByteSwap = p_SecJq->p_DriverParam->icdByteSwap ;
e_SecByteSwap ocdByteSwap = p_SecJq->p_DriverParam->ocdByteSwap ;
e_SecByteSwap imdByteSwap = p_SecJq->p_DriverParam->imdByteSwap ;
e_SecByteSwap omdByteSwap = p_SecJq->p_DriverParam->omdByteSwap ;
irbar = CAST_POINTER_TO_UINT64(p_SecJq->inputRing.p_BaseAddr);
irbar = XX_VirtToPhys(CAST_UINT64_TO_POINTER(irbar)); /* Interpeak */
SEC_WRITE_UINT64_HI_LO(p_SecJq->p_MemMap->jq.irbar,irbar);
irsr = p_SecJq->p_DriverParam->inputRingLen;
WRITE_UINT32(p_SecJq->p_MemMap->jq.irsr,irsr);
orbar = CAST_POINTER_TO_UINT64(p_SecJq->outputRing.p_BaseAddr);
orbar = XX_VirtToPhys(CAST_UINT64_TO_POINTER(orbar)); /* Interpeak */
SEC_WRITE_UINT64_HI_LO(p_SecJq->p_MemMap->jq.orbar,orbar);
orsr = p_SecJq->p_DriverParam->outputRingLen;
WRITE_UINT32(p_SecJq->p_MemMap->jq.orsr,orsr);
cfgr |= SEC_CalcByteSwapFlags(icdByteSwap,CFGR_CBSI,CFGR_CHWSI,CFGR_CWSI,CFGR_CDWSI);
cfgr |= SEC_CalcByteSwapFlags(ocdByteSwap,CFGR_CBSO,CFGR_CHWSO,CFGR_CWSO,CFGR_CDWSO);
cfgr |= SEC_CalcByteSwapFlags(imdByteSwap,CFGR_MBSI,CFGR_MHWSI,CFGR_MWSI,CFGR_MDWSI);
cfgr |= SEC_CalcByteSwapFlags(omdByteSwap,CFGR_MBSO,CFGR_MHWSO,CFGR_MWSO,CFGR_MDWSO);
if (p_SecJq->p_DriverParam->irq == NO_IRQ)
{
/* Disable interrupts */
cfgr |= CFGR_IMSK;
}
else if (intrJobCountThr==1 || intrTicCountThr==0)
{
/* Enable interrupts */
}
else
{
/* Enable interrupt-coalescing */
cfgr |= CFGR_ICEN;
cfgr |= CFGR_ICDCT(intrJobCountThr );
cfgr |= CFGR_ICTT (intrTicCountThr/SEC_JQ_INTR_TIC_COUNT_THR_UNITS);
}
SEC_WRITE_UINT64_HI_LO(p_SecJq->p_MemMap->jq.cfgr,cfgr);
}
static void Isr(t_Handle h_SecJq)
{
t_SecJq* p_SecJq = (t_SecJq*)h_SecJq;
uint32_t istar;
istar = GET_UINT32(p_SecJq->p_MemMap->jq.istar);
ASSERT_COND(ISTAR_ERR_TYPE(istar)==0);
WRITE_UINT32(p_SecJq->p_MemMap->jq.istar,istar);
SEC_JQ_Dequeue(p_SecJq);
}
#if (DEBUG_ERRORS > 0)
#include "debug_ext.h"
static void DumpJqRegs(t_SecJqRegs* p_Regs,char* p_Title)
{
DECLARE_DUMP;
DUMP_TITLE(p_Regs,(p_Title));
DUMP_VAR(p_Regs,irbar);
DUMP_VAR(p_Regs,irsr );
DUMP_VAR(p_Regs,irsar);
DUMP_VAR(p_Regs,irjar);
DUMP_VAR(p_Regs,orbar);
DUMP_VAR(p_Regs,orsr );
DUMP_VAR(p_Regs,orjrr);
DUMP_VAR(p_Regs,orsfr);
DUMP_VAR(p_Regs,ostar);
DUMP_VAR(p_Regs,istar);
DUMP_VAR(p_Regs,cfgr );
DUMP_VAR(p_Regs,irrir);
DUMP_VAR(p_Regs,orwir);
DUMP_VAR(p_Regs,cmdr );
}
static void DumpStatRegs(t_SecStatRegs* p_Regs,char* p_Title)
{
DECLARE_DUMP;
DUMP_TITLE(p_Regs,(p_Title));
DUMP_VAR(p_Regs,req_deq );
DUMP_VAR(p_Regs,ob_enc_req );
DUMP_VAR(p_Regs,ib_dec_req );
DUMP_VAR(p_Regs,ob_encrypt );
DUMP_VAR(p_Regs,ob_protect );
DUMP_VAR(p_Regs,ib_decrypt );
DUMP_VAR(p_Regs,ib_validated);
DUMP_VAR(p_Regs,crnr );
DUMP_VAR(p_Regs,ctpr );
DUMP_VAR(p_Regs,far );
DUMP_VAR(p_Regs,falr );
DUMP_VAR(p_Regs,fadr );
DUMP_VAR(p_Regs,sstar );
DUMP_VAR(p_Regs,rvidr );
DUMP_VAR(p_Regs,ccbvidr );
DUMP_VAR(p_Regs,chavidr );
DUMP_VAR(p_Regs,chanumr );
DUMP_VAR(p_Regs,secvidr );
}
#endif /* (DEBUG_ERRORS > 0) */
/* Internal Routines (above) */
/*****************************/
@@ -0,0 +1,98 @@
/******************************************************************************
© 1995-2003, 2004, 2005-2010 Freescale Semiconductor, Inc.
All rights reserved.
This is proprietary source code of Freescale Semiconductor Inc.,
and its use is subject to the NetComm Device Drivers EULA.
The copyright notice above does not evidence any actual or intended
publication of such source code.
**************************************************************************/
#ifndef __SEC_JQ_H
#define __SEC_JQ_H
#include "sec_jq_ext.h"
#include "sec_regs.h"
typedef struct t_SecJqDriverParam
{
t_Handle h_Sec ; /* SEC object */
uint64_t baseAddr ; /* Base address */
uint8_t jobQueueId ; /* Job queue ID */
uint16_t seqLiodnVal ; /* Sequential LIODN value */
uint16_t nonSeqLiodnVal ; /* Non-sequential LIODN value */
bool allowMtdJobs ; /* Allow MTD jobs */
uint32_t inputRingLen ; /* Input ring number of entries */
int inputRingMemId ; /* Input ring memory partition ID */
uint32_t outputRingLen ; /* Output ring number of entries */
int outputRingMemId; /* Output ring memory partition ID */
uint32_t intrJobCountThr; /* Interrupt job-count threshold */
uint32_t intrTicCountThr; /* Interrupt tic-count threshold */
e_SecByteSwap icdByteSwap ; /* Input control data byte swap */
e_SecByteSwap ocdByteSwap ; /* Output control data byte swap */
e_SecByteSwap imdByteSwap ; /* Input message data byte swap */
e_SecByteSwap omdByteSwap ; /* Output message data byte swap */
t_SecJqCbr* f_Cbr ; /* Callback routine */
t_Handle h_App ; /* Application */
int irq ; /* IRQ */
}
t_SecJqDriverParam;
typedef struct t_SecJqRing
{
uint32_t* p_BaseAddr ; /* Base address */
uint32_t numOfEntries ; /* Number of 32-bit entries */
uint32_t nextEntryIndex; /* Next 32-bit entry index */
}
t_SecJqRing;
typedef struct t_SecJq
{
t_SecJqDriverParam* p_DriverParam; /* Driver parameters */
t_SecJqMemMap* p_MemMap ; /* Memory-mapped registers */
uint32_t secPtrLength ; /* SEC pointer length in 32-bit units */
uint32_t corePtrLength; /* Core pointer length in 32-bit units */
t_SecJqRing inputRing ; /* Input ring parameters */
t_SecJqRing outputRing; /* Output ring parameters */
t_SecJqCbr* f_Cbr; /* Callback routine */
t_Handle h_App; /* Application */
}
t_SecJq;
#define DEFAULT_allowMtdJobs FALSE
#define DEFAULT_inputRingLen 256
#define DEFAULT_inputRingMemId 0
#define DEFAULT_outputRingLen 256
#define DEFAULT_outputRingMemId 0
#define DEFAULT_intrJobCountThr 1
#define DEFAULT_intrTicCountThr 0
#define DEFAULT_icdByteSwap e_SEC_BYTE_SWAP_NONE
#define DEFAULT_ocdByteSwap e_SEC_BYTE_SWAP_NONE
#define DEFAULT_imdByteSwap e_SEC_BYTE_SWAP_NONE
#define DEFAULT_omdByteSwap e_SEC_BYTE_SWAP_NONE
#define MIN_VAL_seqLiodnVal 0x0000
#define MAX_VAL_seqLiodnVal 0x0FFF
#define MIN_VAL_nonSeqLiodnVal 0x0000
#define MAX_VAL_nonSeqLiodnVal 0x0FFF
#define MIN_VAL_inputRingLen 1
#define MAX_VAL_inputRingLen 1023
#define MIN_VAL_outputRingLen 1
#define MAX_VAL_outputRingLen 1023
#define MIN_VAL_intrJobCountThr 1
#define MAX_VAL_intrJobCountThr 255
#define MIN_VAL_intrTicCountThr 0
#define MAX_VAL_intrTicCountThr 4194240 //(65535*SEC_JQ_INTR_TIC_COUNT_THR_UNITS)
#endif /* __SEC_JQ_H */
@@ -0,0 +1,414 @@
/******************************************************************************
© 1995-2003, 2004, 2005-2010 Freescale Semiconductor, Inc.
All rights reserved.
This is proprietary source code of Freescale Semiconductor Inc.,
and its use is subject to the NetComm Device Drivers EULA.
The copyright notice above does not evidence any actual or intended
publication of such source code.
**************************************************************************/
/* Include the internal definitions of this module */
#include "sec_qi.h"
/* Include the external interfaces of other modules */
#include "xx_ext.h"
#include "part_ext.h"
#include "error_ext.h"
#include "string_ext.h"
#define __ERR_MODULE__ MODULE_SEC
static t_Error CheckInitParameters(t_SecQi* p_SecQi);
static void InitRegs(t_SecQi* p_SecQi);
static void DumpQiRegs (t_SecQiRegs * p_Regs,char* p_Title);
static void DumpStatRegs(t_SecStatRegs* p_Regs,char* p_Title);
/*******************************/
/* Initialization Unit (below) */
t_Handle SEC_QI_Config(t_SecQiParam* p_Param)
{
t_SecQi* p_SecQi;
SANITY_CHECK_EXIT(p_Param,E_NULL_POINTER);
/* Allocate the driver structure */
p_SecQi = (t_SecQi*)XX_Malloc(sizeof(t_SecQi));
if (p_SecQi == NULL)
{
REPORT_ERROR(MAJOR,E_NO_MEMORY,("Driver"));
return (t_Handle)p_SecQi;
}
memset(p_SecQi,0,sizeof(t_SecQi));
/* Allocate the driver parameters structure */
p_SecQi->p_DriverParam = (t_SecQiDriverParam*)XX_Malloc(sizeof(t_SecQiDriverParam));
if (p_SecQi->p_DriverParam == NULL)
{
REPORT_ERROR(MAJOR,E_NO_MEMORY,("Driver parameters"));
return (t_Handle)p_SecQi;
}
memset(p_SecQi->p_DriverParam,0,sizeof(t_SecQiDriverParam));
/* Configure the driver parameters */
p_SecQi->p_DriverParam->h_Sec = p_Param->h_Sec ;
p_SecQi->p_DriverParam->baseAddr = p_Param->baseAddr ;
p_SecQi->p_DriverParam->seqLiodnBase = p_Param->seqLiodnBase ;
p_SecQi->p_DriverParam->nonSeqLiodnBase = p_Param->nonSeqLiodnBase;
p_SecQi->p_DriverParam->nonSeqLiodnMask = p_Param->nonSeqLiodnMask;
p_SecQi->p_DriverParam->stopOnError = DEFAULT_stopOnError ;
p_SecQi->p_DriverParam->enqFrameColor = DEFAULT_enqFrameColor ;
p_SecQi->p_DriverParam->deqFrameCount = DEFAULT_deqFrameCount ;
p_SecQi->p_DriverParam->deqScheduling = DEFAULT_deqScheduling ;
p_SecQi->p_DriverParam->deqByteCountThr = DEFAULT_deqByteCountThr ;
p_SecQi->p_DriverParam->deqSpfCountThr = DEFAULT_deqSpfCountThr ;
p_SecQi->p_DriverParam->icdByteSwap = DEFAULT_icdByteSwap ;
p_SecQi->p_DriverParam->ocdByteSwap = DEFAULT_ocdByteSwap ;
p_SecQi->p_DriverParam->imdByteSwap = DEFAULT_imdByteSwap ;
p_SecQi->p_DriverParam->omdByteSwap = DEFAULT_omdByteSwap ;
return (t_Handle)p_SecQi;
}
t_Error SEC_QI_Init(t_Handle h_SecQi)
{
t_SecQi* p_SecQi = (t_SecQi*)h_SecQi;
SANITY_CHECK_EXIT(p_SecQi,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecQi->p_DriverParam,E_INVALID_STATE);
CHECK_INIT_PARAMETERS(p_SecQi,CheckInitParameters);
p_SecQi->p_MemMap = CAST_UINT64_TO_POINTER(p_SecQi->p_DriverParam->baseAddr);
InitRegs(p_SecQi);
XX_Free(p_SecQi->p_DriverParam);
p_SecQi->p_DriverParam = NULL;
return E_OK;
}
t_Error SEC_QI_Free(t_Handle h_SecQi)
{
t_SecQi* p_SecQi = (t_SecQi*)h_SecQi;
SANITY_CHECK_EXIT(p_SecQi,E_INVALID_HANDLE);
if (p_SecQi->p_DriverParam)
XX_Free(p_SecQi->p_DriverParam);
XX_Free(p_SecQi);
return E_OK;
}
/* Initialization Unit (above) */
/*******************************/
/***************************************/
/* Advanced Configuration Unit (below) */
t_Error SEC_QI_ConfigStopOnError(t_Handle h_SecQi,
bool stopOnError)
{
t_SecQi* p_SecQi = (t_SecQi*)h_SecQi;
SANITY_CHECK_EXIT(p_SecQi,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecQi->p_DriverParam,E_INVALID_STATE);
p_SecQi->p_DriverParam->stopOnError = stopOnError;
return E_OK;
}
t_Error SEC_QI_ConfigCommands(t_Handle h_SecQi,
t_SecQiCmdParam* p_CmdParam)
{
t_SecQi* p_SecQi = (t_SecQi*)h_SecQi;
SANITY_CHECK_EXIT(p_SecQi,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecQi->p_DriverParam,E_INVALID_STATE);
SANITY_CHECK_EXIT(p_CmdParam,E_NULL_POINTER);
p_SecQi->p_DriverParam->enqFrameColor = p_CmdParam->enqFrameColor ;
p_SecQi->p_DriverParam->deqFrameCount = p_CmdParam->deqFrameCount ;
p_SecQi->p_DriverParam->deqScheduling = p_CmdParam->deqScheduling ;
p_SecQi->p_DriverParam->deqByteCountThr = p_CmdParam->deqByteCountThr;
p_SecQi->p_DriverParam->deqSpfCountThr = p_CmdParam->deqSpfCountThr ;
return E_OK;
}
t_Error SEC_QI_ConfigByteSwap(t_Handle h_SecQi,
t_SecQiByteSwapParam* p_ByteSwapParam)
{
t_SecQi* p_SecQi = (t_SecQi*)h_SecQi;
SANITY_CHECK_EXIT(p_SecQi,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecQi->p_DriverParam,E_INVALID_STATE);
SANITY_CHECK_EXIT(p_ByteSwapParam,E_NULL_POINTER);
p_SecQi->p_DriverParam->icdByteSwap = p_ByteSwapParam->icd;
p_SecQi->p_DriverParam->ocdByteSwap = p_ByteSwapParam->ocd;
p_SecQi->p_DriverParam->imdByteSwap = p_ByteSwapParam->imd;
p_SecQi->p_DriverParam->omdByteSwap = p_ByteSwapParam->omd;
return E_OK;
}
/* Advanced Configuration Unit (above) */
/***************************************/
/********************************/
/* Runtime Control Unit (below) */
t_Error SEC_QI_Enable(t_Handle h_SecQi)
{
t_SecQi* p_SecQi = (t_SecQi*)h_SecQi;
uint64_t ctlr;
SANITY_CHECK_EXIT(p_SecQi,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecQi->p_DriverParam==NULL,E_INVALID_STATE);
ctlr = SEC_GET_UINT64_HI_LO(p_SecQi->p_MemMap->qi.ctlr);
ctlr |= CTLR_DQEN;
SEC_WRITE_UINT64_HI_LO(p_SecQi->p_MemMap->qi.ctlr,ctlr);
return E_OK;
}
t_Error SEC_QI_Disable(t_Handle h_SecQi)
{
t_SecQi* p_SecQi = (t_SecQi*)h_SecQi;
uint64_t ctlr;
uint32_t star;
SANITY_CHECK_EXIT(p_SecQi,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecQi->p_DriverParam==NULL,E_INVALID_STATE);
ctlr = SEC_GET_UINT64_HI_LO(p_SecQi->p_MemMap->qi.ctlr);
ctlr |= CTLR_STOP;
SEC_WRITE_UINT64_HI_LO(p_SecQi->p_MemMap->qi.ctlr,ctlr);
do star = GET_UINT32(p_SecQi->p_MemMap->qi.star);
while (!STAR_STOPPED(star));
ctlr = SEC_GET_UINT64_HI_LO(p_SecQi->p_MemMap->qi.ctlr);
ctlr |= CTLR_STOP;
ctlr &= ~CTLR_DQEN;
SEC_WRITE_UINT64_HI_LO(p_SecQi->p_MemMap->qi.ctlr,ctlr);
return E_OK;
}
t_Error SEC_QI_RetrieveErrors(t_Handle h_SecQi,
uint8_t* p_ErrorFlags)
{
t_SecQi* p_SecQi = (t_SecQi*)h_SecQi;
uint32_t star;
SANITY_CHECK_EXIT(p_SecQi,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecQi->p_DriverParam==NULL,E_INVALID_STATE);
SANITY_CHECK_EXIT(p_ErrorFlags,E_NULL_POINTER);
star = GET_UINT32(p_SecQi->p_MemMap->qi.star); /* Read error indication bits */
WRITE_UINT32(p_SecQi->p_MemMap->qi.star,star); /* Clear error indication bits */
*p_ErrorFlags = (uint8_t)STAR_ERRORS(star);
return E_OK;
}
t_Error SEC_QI_RetrieveJobStatus(t_Handle h_SecQi,
t_SecQiJobStatus* p_JobStatus)
{
t_SecQi* p_SecQi = (t_SecQi*)h_SecQi;
uint64_t jbsstar;
SANITY_CHECK_EXIT(p_SecQi,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecQi->p_DriverParam==NULL,E_INVALID_STATE);
SANITY_CHECK_EXIT(p_JobStatus,E_NULL_POINTER);
jbsstar = SEC_GET_UINT64_HI_LO(p_SecQi->p_MemMap->qi.jbsstar);
p_JobStatus->done = (uint16_t)JBSSTAR_DONE (jbsstar);
p_JobStatus->exec = (uint16_t)JBSSTAR_EXEC (jbsstar);
p_JobStatus->inUse = (uint16_t)JBSSTAR_IN_USE(jbsstar);
return E_OK;
}
#if (DEBUG_ERRORS > 0)
void SEC_QI_DumpRegisters(t_Handle h_SecQi)
{
t_SecQi* p_SecQi = (t_SecQi*)h_SecQi;
SANITY_CHECK_EXIT(p_SecQi,E_INVALID_HANDLE);
SANITY_CHECK_EXIT(p_SecQi->p_DriverParam==NULL,E_INVALID_STATE);
DumpQiRegs (&p_SecQi->p_MemMap->qi ,"QI Registers" );
DumpStatRegs(&p_SecQi->p_MemMap->stat,"Status Registers");
}
#endif /* (DEBUG_ERRORS > 0) */
/* Runtime Control Unit (above) */
/********************************/
/*****************************/
/* Internal Routines (below) */
#define CHECK_RANGE(par,msg) if (!IN_RANGE(MIN_VAL_##par,p_SecQi->p_DriverParam->par,MAX_VAL_##par)) \
RETURN_ERROR(MAJOR,E_NOT_IN_RANGE,("%s must be between %d-%d",msg,MIN_VAL_##par,MAX_VAL_##par))
static t_Error CheckInitParameters(t_SecQi* p_SecQi)
{
if (p_SecQi->p_DriverParam->h_Sec == NULL)
RETURN_ERROR(MAJOR,E_INVALID_HANDLE,("SEC object"));
if (p_SecQi->p_DriverParam->baseAddr == 0)
RETURN_ERROR(MAJOR,E_INVALID_VALUE,("Base address"));
CHECK_RANGE(seqLiodnBase ,"Sequential LIODN base" );
CHECK_RANGE(nonSeqLiodnBase,"Non-sequential LIODN base" );
CHECK_RANGE(nonSeqLiodnMask,"Non-sequential LIODN offset mask" );
CHECK_RANGE(deqByteCountThr,"Dequeue byte-count threshold" );
CHECK_RANGE(deqSpfCountThr ,"Dequeue subportal-frame-count threshold");
return E_OK;
}
static void InitRegs(t_SecQi* p_SecQi)
{
uint64_t ctlr = 0;
uint64_t eqcr = 0;
uint64_t dqcr = 0;
uint64_t lcr = 0;
uint16_t seqLiodnBase = p_SecQi->p_DriverParam->seqLiodnBase ;
uint16_t nonSeqLiodnBase = p_SecQi->p_DriverParam->nonSeqLiodnBase;
uint16_t nonSeqLiodnMask = p_SecQi->p_DriverParam->nonSeqLiodnMask;
bool stopOnError = p_SecQi->p_DriverParam->stopOnError ;
e_SecQiFrameColor enqFrameColor = p_SecQi->p_DriverParam->enqFrameColor ;
e_SecQiFrameCount deqFrameCount = p_SecQi->p_DriverParam->deqFrameCount ;
e_SecQiScheduling deqScheduling = p_SecQi->p_DriverParam->deqScheduling ;
uint32_t deqByteCountThr = p_SecQi->p_DriverParam->deqByteCountThr;
uint32_t deqSpfCountThr = p_SecQi->p_DriverParam->deqSpfCountThr ;
e_SecByteSwap icdByteSwap = p_SecQi->p_DriverParam->icdByteSwap ;
e_SecByteSwap ocdByteSwap = p_SecQi->p_DriverParam->ocdByteSwap ;
e_SecByteSwap imdByteSwap = p_SecQi->p_DriverParam->imdByteSwap ;
e_SecByteSwap omdByteSwap = p_SecQi->p_DriverParam->omdByteSwap ;
ctlr |= SEC_CalcByteSwapFlags(icdByteSwap,CTLR_CBSI,CTLR_CHWSI,CTLR_CWSI,CTLR_CDWSI);
ctlr |= SEC_CalcByteSwapFlags(ocdByteSwap,CTLR_CBSO,CTLR_CHWSO,CTLR_CWSO,CTLR_CDWSO);
ctlr |= SEC_CalcByteSwapFlags(imdByteSwap,CTLR_MBSI,CTLR_MHWSI,CTLR_MWSI,CTLR_MDWSI);
ctlr |= SEC_CalcByteSwapFlags(omdByteSwap,CTLR_MBSO,CTLR_MHWSO,CTLR_MWSO,CTLR_MDWSO);
ctlr |= stopOnError? CTLR_SOE:0;
SEC_WRITE_UINT64_HI_LO(p_SecQi->p_MemMap->qi.ctlr,ctlr);
eqcr |= EQCR_CFCOLOR(enqFrameColor);
SEC_WRITE_UINT64_HI_LO(p_SecQi->p_MemMap->qi.eqcr,eqcr);
dqcr |= DQCR_SPFCNT(deqSpfCountThr );
dqcr |= DQCR_CBCNT (deqByteCountThr);
dqcr |= DQCR_FCNT (deqFrameCount );
dqcr |= DQCR_CVERB (deqScheduling );
SEC_WRITE_UINT64_HI_LO(p_SecQi->p_MemMap->qi.dqcr,dqcr);
lcr |= LCR_NSLOM (nonSeqLiodnMask);
lcr |= LCR_NSLIODNB(nonSeqLiodnBase);
lcr |= LCR_SLIODNB (seqLiodnBase );
SEC_WRITE_UINT64_HI_LO(p_SecQi->p_MemMap->qi.lcr,lcr);
}
#if (DEBUG_ERRORS > 0)
#include "debug_ext.h"
static void DumpQiRegs(t_SecQiRegs* p_Regs,char* p_Title)
{
DECLARE_DUMP;
DUMP_TITLE(p_Regs,(p_Title));
DUMP_VAR(p_Regs,ctlr );
DUMP_VAR(p_Regs,star );
DUMP_VAR(p_Regs,dqcr );
DUMP_VAR(p_Regs,eqcr );
DUMP_VAR(p_Regs,lcr );
DUMP_ARR(p_Regs,idpr_phr );
DUMP_ARR(p_Regs,lr_isr );
DUMP_ARR(p_Regs,ifdhr_ifdlr);
DUMP_ARR(p_Regs,ofdhr_ofdlr);
DUMP_ARR(p_Regs,cfdhr_cfdlr);
DUMP_VAR(p_Regs,jbsstar );
DUMP_VAR(p_Regs,spstar );
}
static void DumpStatRegs(t_SecStatRegs* p_Regs,char* p_Title)
{
DECLARE_DUMP;
DUMP_TITLE(p_Regs,(p_Title));
DUMP_VAR(p_Regs,req_deq );
DUMP_VAR(p_Regs,ob_enc_req );
DUMP_VAR(p_Regs,ib_dec_req );
DUMP_VAR(p_Regs,ob_encrypt );
DUMP_VAR(p_Regs,ob_protect );
DUMP_VAR(p_Regs,ib_decrypt );
DUMP_VAR(p_Regs,ib_validated);
DUMP_VAR(p_Regs,crnr );
DUMP_VAR(p_Regs,ctpr );
DUMP_VAR(p_Regs,far );
DUMP_VAR(p_Regs,falr );
DUMP_VAR(p_Regs,fadr );
DUMP_VAR(p_Regs,sstar );
DUMP_VAR(p_Regs,rvidr );
DUMP_VAR(p_Regs,ccbvidr );
DUMP_VAR(p_Regs,chavidr );
DUMP_VAR(p_Regs,chanumr );
DUMP_VAR(p_Regs,secvidr );
}
#endif /* (DEBUG_ERRORS > 0) */
/* Internal Routines (above) */
/*****************************/
@@ -0,0 +1,73 @@
/******************************************************************************
© 1995-2003, 2004, 2005-2010 Freescale Semiconductor, Inc.
All rights reserved.
This is proprietary source code of Freescale Semiconductor Inc.,
and its use is subject to the NetComm Device Drivers EULA.
The copyright notice above does not evidence any actual or intended
publication of such source code.
**************************************************************************/
#ifndef __SEC_QI_H
#define __SEC_QI_H
#include "sec_qi_ext.h"
#include "sec_regs.h"
typedef struct t_SecQiDriverParam
{
t_Handle h_Sec ; /* SEC object */
uint64_t baseAddr ; /* Base address */
uint16_t seqLiodnBase ; /* Sequential LIODN base */
uint16_t nonSeqLiodnBase; /* Non-sequential LIODN base */
uint16_t nonSeqLiodnMask; /* Non-sequential LIODN offset mask */
bool stopOnError ; /* Stop on error */
e_SecQiFrameColor enqFrameColor ; /* Enqueue frame color */
e_SecQiFrameCount deqFrameCount ; /* Dequeue frame count */
e_SecQiScheduling deqScheduling ; /* Dequeue scheduling */
uint32_t deqByteCountThr; /* Dequeue byte-count threshold */
uint32_t deqSpfCountThr ; /* Dequeue subportal-frame-count threshold */
e_SecByteSwap icdByteSwap ; /* Input control data byte swap */
e_SecByteSwap ocdByteSwap ; /* Output control data byte swap */
e_SecByteSwap imdByteSwap ; /* Input message data byte swap */
e_SecByteSwap omdByteSwap ; /* Output message data byte swap */
}
t_SecQiDriverParam;
typedef struct t_SecQi
{
t_SecQiDriverParam* p_DriverParam; /* Driver parameters */
t_SecQiMemMap* p_MemMap ; /* Memory-mapped registers */
}
t_SecQi;
#define DEFAULT_stopOnError FALSE
#define DEFAULT_enqFrameColor e_SEC_QI_FRAME_COLOR_OVERRIDE
#define DEFAULT_deqFrameCount e_SEC_QI_FRAME_COUNT_MAXIMUM_3
#define DEFAULT_deqScheduling e_SEC_QI_SCHEDULING_PRI_WITH_IC
#define DEFAULT_deqByteCountThr 65535
#define DEFAULT_deqSpfCountThr 4
#define DEFAULT_icdByteSwap e_SEC_BYTE_SWAP_NONE
#define DEFAULT_ocdByteSwap e_SEC_BYTE_SWAP_NONE
#define DEFAULT_imdByteSwap e_SEC_BYTE_SWAP_NONE
#define DEFAULT_omdByteSwap e_SEC_BYTE_SWAP_NONE
#define MIN_VAL_seqLiodnBase 0x0000
#define MAX_VAL_seqLiodnBase 0x0FFF
#define MIN_VAL_nonSeqLiodnBase 0x0000
#define MAX_VAL_nonSeqLiodnBase 0x0FFF
#define MIN_VAL_nonSeqLiodnMask 0x0000
#define MAX_VAL_nonSeqLiodnMask 0x03FF
#define MIN_VAL_deqByteCountThr 1
#define MAX_VAL_deqByteCountThr 65535
#define MIN_VAL_deqSpfCountThr 1
#define MAX_VAL_deqSpfCountThr 7
#endif /* __SEC_QI_H */
File diff suppressed because it is too large Load Diff