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

📄 sec2_request.c

📁 freescale ppc sec2加解密单元驱动
💻 C
📖 第 1 页 / 共 3 页
字号:
  }}#endif/********************************************************************************//* Function Name: sec2_CompleteRequest                                         *//* Purpose: 中断处理结束后,向FWD队列中添加的任务                                  *//* Input: channel - 需要处理的通道号                               *//*        status - 该通道状态,错误或者正确          bDoNotify - 传下来的TRUE或者FALSE          pRegs  - 寄存器内的值,保存寄存器状态                       *//* Output: none                     *//* Return: SEC2_Success if success, otherwise error code              *//********************************************************************************/int sec2_CompleteRequest(int channel, int status){    register GENERIC_REQ    *req = (GENERIC_REQ *)NULL; /*20060920*/    if (Sec2_ChannelAssignments[channel].pReq != NULL)      req = Sec2_ChannelAssignments[channel].pReq;    else      return -1;    ((GENERIC_REQ*)req)->status = status;    /*Sec2_ChannelAssignments[channel].pReq = NULL;*/    #if PKHA_OUTPUT_SHIFT    /* This is here as a workaround for completing PKHA */    for (i = 0; i < MAX_DPDS; i++)      if (Sec2_ChannelAssignments[channel].Dpds[i] != NULL)        if ((Sec2_ChannelAssignments[channel].Dpds[i]->header & 0xf8) == 0x00000080) /* PKHA? */          fixPKHAresult(Sec2_ChannelAssignments[channel].Dpds[i]);    #endif                    /* Walk through the request's descriptor list. For any DPD that was in use, */    /* if they used scatter lists, we have to return the free elements to the   */    /* fragment pool. So check for scattered pointers, and unmap them           */    #if PKHA_OUTPUT_SHIFT       for (i = 0; i < MAX_DPDS; i++)      if (Sec2_ChannelAssignments[channel].Dpds[i] != NULL)        for (j = 0; j < NUM_DPD_FLDS; j++)          if (Sec2_ChannelAssignments[channel].Dpds[i]->fld[j].len & PTRTYPE_JBIT)            UnmapScatterFragments((void *)Sec2_ChannelAssignments[channel].Dpds[i]->fld[j].ptr);    #endif       /* Change the assignment state.  This is the last thing to be done       since the channel becomes immediately available when you set it       to FREE (dynamic) or ASSIGNED (static).    */       if (Sec2_ChannelAssignments[channel].assignment != CHANNEL_FREE)    {        Sec2_ChannelAssignments[channel].ownerTaskId = 0;        sec2_FreeChannels++;        Sec2_ChannelAssignments[channel].assignment = CHANNEL_FREE;    }    return status;}/*轮询上送的缓存队列,只要标志置上,一直处理*/void sec2_complete_handle(void){    int loopCnt;    GENERIC_REQ         *pReq;            /*如果取出标志置上的项*/    for(loopCnt = 0; loopCnt < SEC2_FWD_QUEUE_DEPTH; loopCnt ++)    {        if (SEC2_PKT_USED_FLAG == gpSec2_FwdQueueTop->used)        {            pReq = gpSec2_FwdQueueTop->pReq;            	        gpSec2_FwdQueueTop->requestingTaskId = 0;            gpSec2_FwdQueueTop->pReq = (GENERIC_REQ *)NULL;            gpSec2_FwdQueueTop->used = SEC2_PKT_UNUSED_FLAG;            gpSec2_FwdQueueTop = gpSec2_FwdQueueTop->next;            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);                }            }                                            }        else        {            break;        }    }    gpDrvSec2End->rxFwdFlag = 0;        /*此时唤醒通道任务,是否可以释放通道*/    Sec2_ScheduleChannelAssignment();	}/*******************************************************功能:队列资源查询函数*           yuhongtao*           2007-04-24********************************************************/void show_sec2_rx_queue(void){      int i;	SEC2_FWD_QUEUE *queue_item = NULL;	int cnt = 0;	int oldLevel;		oldLevel = intLock();	taskLock();	printf("queue top addr: %x\n",gpSec2_FwdQueueTop);	printf("queue bottom addr: %x\n",gpSec2_FwdQueueBottom);	printf("add fwd queue flag: %d\n",gpDrvSec2End->rxFwdFlag);	queue_item = gpSec2_FwdQueueTop;	for (i = 0; i < SEC2_FWD_QUEUE_DEPTH; i++)	{		if (queue_item->used == SEC2_PKT_USED_FLAG)		{			printf("offset = %d,seq = %d,taskId = %x,preq = %x\n",queue_item->num,				                                                     cnt,				                                                     queue_item->requestingTaskId,				                                                     queue_item->pReq);			cnt++;		}		queue_item = queue_item->next;	}	taskUnlock();	intUnlock(oldLevel);}void show_sec2_tx_queue(void){      int i;	int cnt = 0;	QUEUE_ENTRY *queue_item = NULL;	unsigned char usedflag = 0;	int oldLevel;		oldLevel = intLock();	printf("sec2 free_channels: %d\n",sec2_FreeChannels);	printf("channel 0 status:%d,taskId:%x,pReq:%x\n",Sec2_ChannelAssignments[0].assignment,		                                     Sec2_ChannelAssignments[0].ownerTaskId,		                                     Sec2_ChannelAssignments[0].pReq);	printf("channel 1 status:%d,taskId:%x,pReq:%x\n",Sec2_ChannelAssignments[1].assignment,		                                     Sec2_ChannelAssignments[1].ownerTaskId,		                                     Sec2_ChannelAssignments[1].pReq);	printf("channel 2 status:%d,taskId:%x,pReq:%x\n",Sec2_ChannelAssignments[2].assignment,		                                     Sec2_ChannelAssignments[2].ownerTaskId,		                                     Sec2_ChannelAssignments[2].pReq);	printf("channel 3 status:%d,taskId:%x,pReq:%x\n",Sec2_ChannelAssignments[3].assignment,		                                     Sec2_ChannelAssignments[3].ownerTaskId,		                                     Sec2_ChannelAssignments[3].pReq);	printf("queue top addr: %x\n",sec2_ProcessQueueTop);	printf("queue bottom addr: %x\n",sec2_ProcessQueueBottom);	printf("queue depth: %d\n",sec2_QueueEntryDepth);	queue_item = &sec2_Queue[0];	for (i = 0; i < SEC2_HANDLE_QUEUE_DEPTH ; i++)	{		if ((!usedflag) && (i >= sec2_QueueEntryDepth))		{		      usedflag = 1;			printf("-----------------------------------------------------------\n");		}				{			printf("seq = %d,taskId = %x,preq = %x\n",cnt,				                                                     queue_item->requestingTaskId,				                                                     queue_item->pReq);			cnt++;		}		queue_item = queue_item->next;	}	intUnlock(oldLevel);}int sec2_GetStatus(SEC2_STATUS_REQ *pStatus, int callingTaskId){    int i;    pStatus->sec2_ChaAssignmentStatusRegister[0] = *(volatile unsigned long *)(sec2_ChaAssignmentStatusRegister);     pStatus->sec2_ChaAssignmentStatusRegister[1] = *(volatile unsigned long *)(sec2_ChaAssignmentStatusRegister + 1);     pStatus->sec2_InterruptControlRegister[0]    = *(volatile unsigned long *)(sec2_InterruptControlRegister);    pStatus->sec2_InterruptControlRegister[1]    = *(volatile unsigned long *)(sec2_InterruptControlRegister + 1);        pStatus->sec2_InterruptStatusRegister[0]     = *(volatile unsigned long *)(sec2_InterruptStatusRegister);     pStatus->sec2_InterruptStatusRegister[1]     = *(volatile unsigned long *)(sec2_InterruptStatusRegister + 1);     pStatus->sec2_IdRegister                     = *(volatile unsigned long *)(sec2_IdRegister);          for (i = 0; i < SEC2_NUM_CHANNELS; i++)    {      pStatus->ChannelStatusRegister[i][0] = *(volatile unsigned long *)(sec2_ChannelPointerStatusRegister[i]);        pStatus->ChannelStatusRegister[i][1] = *(volatile unsigned long *)(sec2_ChannelPointerStatusRegister[i] + 1);      }        for (i = 0; i < SEC2_NUM_CHANNELS; i++)    {      pStatus->ChannelConfigurationRegister[i][0] = *(volatile unsigned long *)(sec2_ChannelConfigRegister[i]);       pStatus->ChannelConfigurationRegister[i][1] = *(volatile unsigned long *)(sec2_ChannelConfigRegister[i] + 1);     }                        for (i = 0; i < NUM_CHAS; i++)    {      pStatus->CHAInterruptStatusRegister[i][0] = *(volatile unsigned long *)(Sec2ChaInterruptStatusRegister[i]);       pStatus->CHAInterruptStatusRegister[i][1] = *(volatile unsigned long *)(Sec2ChaInterruptStatusRegister[i] + 1);     }            pStatus->QueueEntryDepth = sec2_QueueEntryDepth;                 pStatus->sec2_FreeChannels    = (unsigned long)sec2_FreeChannels;    pStatus->sec2_FreeRngas       = sec2_FreeRngas;         pStatus->sec2_FreeAfhas       = sec2_FreeAfhas;             pStatus->sec2_FreeDesas       = sec2_FreeDesas;             pStatus->sec2_FreeMdhas       = sec2_FreeMdhas;             pStatus->sec2_FreePkhas       = sec2_FreePkhas;    pStatus->sec2_FreeAesas       = sec2_FreeAesas;         pStatus->sec2_FreeKeas        = sec2_FreeKeas;           pStatus->sec2_BlockSize       = sec2_BlockSize;    return SEC2_SUCCESS;}void sec2_CopyRegsToStatus(SEC2_STATUS_REQ *pStatus, SEC2_DEVICE_REGS *pRegs){    int     channel, cha;    /* Build up the driver status structure.  It will be passed back by       the notify on error routine    */    pStatus->sec2_InterruptStatusRegister[0] = pRegs->IntStatus[0];    pStatus->sec2_InterruptStatusRegister[1] = pRegs->IntStatus[1];    pStatus->sec2_ChaAssignmentStatusRegister[0] = pRegs->ChaAssignmentStatus[0];    pStatus->sec2_ChaAssignmentStatusRegister[1] = pRegs->ChaAssignmentStatus[1];    for (channel=0; channel<SEC2_NUM_CHANNELS; channel++)    {        pStatus->ChannelStatusRegister[channel][0] = pRegs->ChannelError[channel][0];        pStatus->ChannelStatusRegister[channel][1] = pRegs->ChannelError[channel][1];    }    for (cha=0; cha<NUM_CHAS; cha++)    {        pStatus->CHAInterruptStatusRegister[cha][0] = pRegs->ChaError[cha][0];        pStatus->CHAInterruptStatusRegister[cha][1] = pRegs->ChaError[cha][1];    }}	#if 0            if (((GENERIC_REQ *)req)->notifyFlags & NOTIFY_IS_PID)            {#ifdef VXWORKS                kill((long)((GENERIC_REQ*)req)->notify, SIGUSR1);#endif            }            else            {                if ((((GENERIC_REQ*)req)->notify) != NULL)                    (((GENERIC_REQ*)req)->notify)(((GENERIC_REQ*)req)->pNotifyCtx);            }        }   }   else    {            if (((GENERIC_REQ *)req)->notifyFlags & NOTIFY_ERROR_IS_PID)            {#ifdef __KERNEL__                send_sig(SIGUSR2, find_task_by_pid((long)((GENERIC_REQ *)req)->notify_on_error), 0);#endif#ifdef VXWORKS                kill((long)((GENERIC_REQ*)req)->notify_on_error, SIGUSR2);#endif            }             else            {            /* else this is an error notifier... */            SEC2Dump(DBGTXT_SVCRQ, ("CompleteReqest(): error notifier in process\n"));                if ((((GENERIC_REQ*)req)->notify_on_error) != NULL)                {                    /* first, do the error context save */                    ((GENERIC_REQ*)req)->ctxNotifyOnErr.errorcode = ((GENERIC_REQ*)req)->status;                    if (pRegs == NULL)                        memset(&(((GENERIC_REQ*)req)->ctxNotifyOnErr.driverstatus),0,sizeof(SEC2_STATUS_REQ));                    else                        sec2_CopyRegsToStatus(&(((GENERIC_REQ*)req)->ctxNotifyOnErr.driverstatus), pRegs);                    ((GENERIC_REQ*)req)->ctxNotifyOnErr.request = req;                    /* now call the handler */                    SEC2Dump(DBGTXT_SVCRQ, ("sec2_CompleteRequest(): calling error notifier with context\n"));                      (((GENERIC_REQ*)req)->notify_on_error)(&(((GENERIC_REQ*)req)->ctxNotifyOnErr));                }     }            #endif

⌨️ 快捷键说明

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