801 lines
27 KiB
C
801 lines
27 KiB
C
/******************************************************************************
|
|
|
|
� 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) */
|
|
/*****************************/
|