⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sec2_request.c

📁 freescale ppc sec2加解密单元驱动
💻 C
📖 第 1 页 / 共 3 页
字号:
                    if ((pRegs->ChannelError[channel][1] & CHANNEL_SCATTER_LENGTH_ERROR) ||                        (pRegs->ChannelError[channel][1] & CHANNEL_SCATTER_BOUND_ERROR) ||                        (pRegs->ChannelError[channel][1] & CHANNEL_GATHER_LENGTH_ERROR) ||                        (pRegs->ChannelError[channel][1] & CHANNEL_GATHER_BOUND_ERROR) ||                        (pRegs->ChannelError[channel][1] & CHANNEL_ZERO_SCATTER_LEN_ERROR))                        status[channel] = SEC2_SCATTER_LIST_ERROR;                                                    if (pRegs->ChannelError[channel][1] & CHANNEL_BUS_MASTER_ERROR)                        status[channel] = SEC2_BUS_MASTER_ERROR;                    if ((pRegs->ChannelError[channel][1] & CHANNEL_FETCH_FIFO_NEARMISS_ERROR) ||                        (pRegs->ChannelError[channel][1] & CHANNEL_FETCH_FIFO_OVERFLOW_ERROR))                        status[channel] = SEC2_FETCH_FIFO_OVERFLOW;                } /* if (valid interrupt) */            } /* for (channels) */        } /* if (cha int done) */     for (channel = 0; channel < SEC2_NUM_CHANNELS; channel++) /*20060920*/        {            if (bIsComplete[channel])                sec2_CompleteRequest(channel, status[channel]);        }			        /* schedule queued requests on any freed channels */        /*Sec2_ScheduleNext();*/}  /* End of Sec2_ProcessingComplete */void RemoveQueueEntry(QUEUE_ENTRY *entry){    if (sec2_QueueEntryDepth > 0)     {        sec2_QueueEntryDepth--;        entry->requestingTaskId = 0;        entry->pReq  = (GENERIC_REQ *)NULL;        entry->pDesc = (DPD_DETAILS_ENTRY *)NULL;        sec2_ProcessQueueTop = sec2_ProcessQueueTop->next;    }    return;} /* end of RemoveQueueEntry */#if 0void Sec2_ProcessFwdQueue(void){    register unsigned int channel;    int status;    IOLockChannelAssignment();    channel = 0;	/*如果sec2有通道空闲,将任务下发给通道*/    while (channel < SEC2_NUM_CHANNELS)    {        if (Sec2_ChannelAssignments[channel].assignment != CHANNEL_FREE)        {            channel++;            continue;        }        /* Is there anything queued up? */        if (sec2_QueueEntryDepth > 0)        {            if (Sec2_CheckChas(sec2_ProcessQueueTop->pReq->opId) != SEC2_SUCCESS)             {                SEC2Dump(DBGTXT_SETRQ, ("Sec2_ScheduleNext->Breaking Out Sec2_CheckChas fails 0x%lx\n", sec2_ProcessQueueTop->pReq->opId));                break;            }            Sec2_ChannelAssignments[channel].assignment = CHANNEL_DYNAMIC;            Sec2_ChannelAssignments[channel].pReq = sec2_ProcessQueueTop->pReq;            Sec2_ChannelAssignments[channel].ownerTaskId = sec2_ProcessQueueTop->requestingTaskId;            sec2_FreeChannels--;                                 SEC2Dump(DBGTXT_SETRQ, ("Sec2_ScheduleNext->sec2_FreeChannels 0x%x\n", sec2_FreeChannels));            status = sec2_RequestToDpd(Sec2_ChannelAssignments[channel].pReq, channel);             if (status != SEC2_SUCCESS)            {            /* Problem with request, return error to the application */                sec2_CompleteRequest(channel, status);                channel++;                continue;            }            else            {                /* write the address of the first DPD to the channel */                /* this starts hardware processing the request */                *(sec2_ChannelNextDescriptorRegister[channel]+1) = __vpa((unsigned long)(Sec2_ChannelAssignments[channel].Dpds[0]));                 RemoveQueueEntry(sec2_ProcessQueueTop);            }        }        else        {            break;        }        /* finished with this channel */        channel++;    }    IOUnLockChannelAssignment();}#endifint Sec2_ScheduleChannelAssignment(void){    int freeChannel;    GENERIC_REQ    *pReq;        for (freeChannel=0; freeChannel < SEC2_NUM_CHANNELS; freeChannel++)    {        if (Sec2_ChannelAssignments[freeChannel].assignment == CHANNEL_WAIT)        {            pReq = Sec2_ChannelAssignments[freeChannel].pReq;			 /*如果成功,释放通道                 sec2_CompleteRequest(freeChannel, SEC2_SUCCESS);*/                 Sec2_ChannelAssignments[freeChannel].pReq = (GENERIC_REQ *)NULL;                 Sec2_ChannelAssignments[freeChannel].ownerTaskId = 0;                 Sec2_ChannelAssignments[freeChannel].assignment   = CHANNEL_FREE;                		    sec2_FreeChannels++;		    #if 0                    if (SEC2_SUCCESS != Sec2_ScheduleQueue(freeChannel))                    {                         Sec2_ChannelAssignments[freeChannel].ownerTaskId = 0;                         Sec2_ChannelAssignments[freeChannel].assignment   = CHANNEL_FREE;		            sec2_FreeChannels++;                    }		   #endif					            if(SEC2_SUCCESS == ((GENERIC_REQ*)pReq)->status)            {                     /* callback*/                if(NULL != (((GENERIC_REQ*)pReq)->notify))                {                (((GENERIC_REQ*)pReq)->notify)(((GENERIC_REQ*)pReq)->pNotifyCtx);                }            }            else            {                if(NULL != (((GENERIC_REQ*)pReq)->notify_on_error))                {                /* error callback */                (((GENERIC_REQ*)pReq)->notify_on_error)((PSEC_NOTIFY_ON_ERROR_CTX)((GENERIC_REQ*)pReq)->ctxNotifyOnErr.request);                }            }   	                 #if 0            /*channel wait的状态下,尝试从这个通道读取req到fwd队列中*/            if(SEC2_SUCCESS != sec2_addfwdQueue(Sec2_ChannelAssignments[freeChannel].pReq,                                                                        Sec2_ChannelAssignments[freeChannel].ownerTaskId))            {                /*如果依然不成功,直接返回,通道仍是wait状态*/                 return SEC2_ERROR;            }            else            {                /*如果成功,释放通道*/                 sec2_CompleteRequest(freeChannel, SEC2_SUCCESS);                 Sec2_ChannelAssignments[freeChannel].pReq = (GENERIC_REQ *)NULL;            }	     #endif        }    }	if ((gpDrvSec2End->rxFwdFlag == 0) && (SEC2_PKT_USED_FLAG == gpSec2_FwdQueueTop->used))	{        if(fwdJobAdd ((FUNCPTR)sec2_complete_handle,0,0,0,0,0) != OK)        {            /*直接返回有点问题,增加一个计数*/            return SEC2_ERROR;        }        else        {            gpDrvSec2End->rxFwdFlag = 1;            return SEC2_SUCCESS;        }	}    return SEC2_SUCCESS;}/* does not return a status value -- all errors are returned to the requestingapplication through the request structure status value *//* this should only be called with channel assignments locked */#if 0void Sec2_ScheduleNext(void){    register unsigned int channel;    int status;    IOLockChannelAssignment();    channel = 0;	/*如果sec2有通道空闲,将任务下发给通道*/    while (channel < SEC2_NUM_CHANNELS)    {        if (Sec2_ChannelAssignments[channel].assignment != CHANNEL_FREE)        {            channel++;            continue;        }        /* Is there anything queued up? */        if (sec2_QueueEntryDepth > 0)        {            if (Sec2_CheckChas(sec2_ProcessQueueTop->pReq->opId) != SEC2_SUCCESS)             {                SEC2Dump(DBGTXT_SETRQ, ("Sec2_ScheduleNext->Breaking Out Sec2_CheckChas fails 0x%lx\n", sec2_ProcessQueueTop->pReq->opId));                break;            }            Sec2_ChannelAssignments[channel].assignment = CHANNEL_DYNAMIC;            Sec2_ChannelAssignments[channel].pReq = sec2_ProcessQueueTop->pReq;            Sec2_ChannelAssignments[channel].ownerTaskId = sec2_ProcessQueueTop->requestingTaskId;            sec2_FreeChannels--;                                 SEC2Dump(DBGTXT_SETRQ, ("Sec2_ScheduleNext->sec2_FreeChannels 0x%x\n", sec2_FreeChannels));            status = sec2_RequestToDpd(Sec2_ChannelAssignments[channel].pReq, channel);             if (status != SEC2_SUCCESS)            {            /* Problem with request, return error to the application */                sec2_CompleteRequest(channel, status);                channel++;                continue;            }            else            {                /* write the address of the first DPD to the channel */                /* this starts hardware processing the request */                *(sec2_ChannelNextDescriptorRegister[channel]+1) = __vpa((unsigned long)(Sec2_ChannelAssignments[channel].Dpds[0]));                 RemoveQueueEntry(sec2_ProcessQueueTop);            }        }        else        {            break;        }        /* finished with this channel */        channel++;    }    IOUnLockChannelAssignment();}#endifUINT32 sec2_queue_cnt = 0;int Sec2_ScheduleQueue(int channel){    int loopCnt = 0;    int status  = SEC2_ERROR;    if (sec2_QueueEntryDepth > 0)     {        sec2_queue_cnt++;        /*检查cha不合法,释放队列元素*/        while ((Sec2_CheckChas(sec2_ProcessQueueTop->pReq->opId) != SEC2_SUCCESS) &&  (loopCnt ++ < SEC2_HANDLE_QUEUE_DEPTH))        {            RemoveQueueEntry(sec2_ProcessQueueTop);        }        if (loopCnt  > SEC2_HANDLE_QUEUE_DEPTH)        {            return SEC2_ERROR;        }        Sec2_ChannelAssignments[channel].assignment = CHANNEL_DYNAMIC;        Sec2_ChannelAssignments[channel].pReq = sec2_ProcessQueueTop->pReq;        Sec2_ChannelAssignments[channel].ownerTaskId = sec2_ProcessQueueTop->requestingTaskId;        Sec2_ChannelAssignments[channel].pDesc = sec2_ProcessQueueTop->pDesc;        /*sec2_FreeChannels--;*/                         status = sec2_RequestToDpd(Sec2_ChannelAssignments[channel].pReq, channel,Sec2_ChannelAssignments[channel].pDesc);         if (status == SEC2_SUCCESS)        {            /* write the address of the first DPD to the channel */            /* this starts hardware processing the request */            *(sec2_ChannelNextDescriptorRegister[channel]+1) = __vpa((unsigned long)(Sec2_ChannelAssignments[channel].Dpds[0]));        }        RemoveQueueEntry(sec2_ProcessQueueTop);    }    return status;}/* As T2.0 is designed, output from PKHA will be "front loaded" in the output *//* buffer such that data starts at the zeroth element in the output buffer    *//* As long as the output and the modulus size match, this is fine. If the     *//* output is larger than the modulus, then we would normally expect the       *//* output to be at the far end of the buffer (leading zeros at the start)     *//* However, it puts the modulated output "up front". Normally, there's no     *//* reason for the output > modulus, but if it exists, this corrects for it    */#if PKHA_OUTPUT_SHIFTstatic void fixPKHAresult(SEC2_DPD *pkDesc){  int i;  unsigned long modlen, outlen, shift, *outbuf;  unsigned long *src, *dest;    modlen = (pkDesc->fld[0].len & 0xffff0000) >> 16;  outlen = (pkDesc->fld[4].len & 0xffff0000) >> 16;  outbuf = (unsigned long *)pkDesc->fld[4].ptr;    /* Check difference and save, if not different, exit */  if (outlen > modlen)    shift = (outlen - modlen)/4;  else    return;      dest = &outbuf[(outlen / 4) - 1];  src  = &outbuf[(modlen / 4) - 1];  for (i = 0; i < shift; i++)  {    *(dest--) = *(src);    *(src--)  = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -