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

📄 sec2_init.c

📁 freescale ppc sec2加解密单元驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
          return SEC2_ERROR;    }    if(SEC2_SUCCESS != sec2_channel_pktCnt_debug_init())    {          SEC2Dump(DBGTXT_INITDEV, ("SEC2DriverInit->init channel debug memory failed \n"));          sec2_init_mem_free();          ASSERT(0);          return SEC2_ERROR;    }    if(SEC2_SUCCESS != sec2_pktCnt_debug_init())    {          SEC2Dump(DBGTXT_INITDEV, ("SEC2DriverInit->init global debug memory failed \n"));          sec2_init_mem_free();          ASSERT(0);          return SEC2_ERROR;    }    /* reset all the CHA's */    SEC2Dump(DBGTXT_INITDEV, ("SEC2DriverInit->reset Reset Control Register %d\n", NUM_CHAS));    for (cha=0; cha<NUM_CHAS; cha++)    {        *(sec2_ChaResetControlRegister[cha])     = 0;        *(sec2_ChaResetControlRegister[cha] + 1) = CHA_SOFTWARE_RESET;         if (cha == CHA_DES)  /* is this cha des? ,掩去奇偶校验错误位*/        {            *(sec2_ChaInterruptControlRegister[cha])     = 0;            *(sec2_ChaInterruptControlRegister[cha] + 1) = CHA_DESA_KEY_PARITY_ERROR_DISABLE;        }        if (cha == CHA_PKHA) /* is this cha the pkha? 掩去非法地址错误位*/        {            *(sec2_ChaInterruptControlRegister[cha]) = 0;            *(sec2_ChaInterruptControlRegister[cha] + 1) = CHA_PKHA_ILLEGAL_ADDR_ERROR_DISABLE;        }    }    /* reset all the channels */    SEC2Dump(DBGTXT_INITDEV,             ("SEC2DriverInit->reset Crypto-Channel Configuration Registers %d\n",             SEC2_NUM_CHANNELS));	/*对通道的寄存器进行处理*/    for (channel=0; channel<SEC2_NUM_CHANNELS; channel++)    {        /* reset the channel & configure the channels */        *(sec2_ChannelConfigRegister[channel])     = CHANNEL_RESET;   /*重置通道*/        *(sec2_ChannelConfigRegister[channel] + 1) = 0;        /*打开通道中断*/        *(sec2_ChannelConfigRegister[channel])     = 0;        *(sec2_ChannelConfigRegister[channel] + 1) = CHANNEL_INTEN;  /*CDIE*/       #if 0         *(sec2_ChannelConfigRegister[channel])     = 0;        *(sec2_ChannelConfigRegister[channel] + 1) |= CHANNEL_GOLOBAL_INT_EN;  /*global int enable*/       #endif    }    /* Enable the main interrupt from SEC core at the controller/OS level */    if ( SEC2_SUCCESS != IOConnectInterrupt())    {          SEC2Dump(DBGTXT_INITDEV, ("SEC2DriverInit->interrupt connect failed \n"));          sec2_init_mem_free();          ASSERT(0);          return SEC2_ERROR;    }    /* 1 Unmask all "done" bits from all channels and accelerators */    /* 2 Unmask all error bits */    *(sec2_InterruptControlRegister) = (ALL_CHANNEL_INT_DONE_MASK | ALL_CHANNEL_INT_ERROR_MASK                                                                           |DONE_OVERFLOW | INTERNAL_TIME_OUT);    if( SEC2_SUCCESS != drv_Sec2RegisterDiag())    {          SEC2Dump(DBGTXT_INITDEV, ("SEC2DriverInit->diagnose init failed \n"));          sec2_init_mem_free();          ASSERT(0);          return SEC2_ERROR;    }    /* enable interrupts at the core level -- channels done and all errors */    SEC2Dump(DBGTXT_INITDEV, ("SEC2DriverInit->connect and enable interrupts\n"));    SEC2Dump(DBGTXT_INITDEV, ("SEC2DriverInit->return SEC2_SUCCESS!\n"));    return SEC2_SUCCESS;    }  /* end of DriverEntry *//*-----------------------------* sec2_InitChannelAssignment - 通道任务初始化*                     * Argument:*    IO_STATUS   -  int** Return:*    成功返回SEC2_SUCCESS,如果没有分配到内存返回SEC2_IO_MEMORY_ALLOCATE_ERROR** 输出 : 无*       * Modified history*------------------------------**/IO_STATUS sec2_InitChannelAssignment(int channel){    unsigned int count;    SEC2Dump(DBGTXT_INITDEV, ("sec2_InitChannelAssignment channel=%d\n", channel+1));    Sec2_ChannelAssignments[channel].assignment  = CHANNEL_FREE;    Sec2_ChannelAssignments[channel].ownerTaskId = 0;    Sec2_ChannelAssignments[channel].pReq = (GENERIC_REQ *)NULL; /*20060920*/    Sec2_ChannelAssignments[channel].pCurrReq    = (GENERIC_REQ *)NULL; /*20060920*/    Sec2_ChannelAssignments[channel].Dpds        = &Sec2_dpd[channel][0];    for (count=0; count < MAX_DPDS; count++)    {        Sec2_ChannelAssignments[channel].Dpds[count] = &sec2_Descriptors[channel][count];        if (Sec2_ChannelAssignments[channel].Dpds[count] == NULL)            return SEC2_IO_MEMORY_ALLOCATE_ERROR;    }    SEC2Dump(DBGTXT_INITDEV, ("InitChannelAssignment channel=%d done\n", channel+1));    return (SEC2_SUCCESS);}/*-----------------------------* Init_Drv_Ipsec_Queue - ipsec驱动的全局队列初始化*                         因为队列结构比较简单,所以不采用动态分配* Argument:*    void**Return:*    无** Return:*   * Modified history*------------------------------**/void Init_Drv_Ipsec_Queue(void){    int i;	    /*队列清零*/    memset(sec2_Queue, 0, SEC2_HANDLE_QUEUE_DEPTH * sizeof(QUEUE_ENTRY));    /*循环链队*/    for (i=0; i<SEC2_HANDLE_QUEUE_DEPTH-1;i++)        sec2_Queue[i].next = &sec2_Queue[i+1];    sec2_Queue[SEC2_HANDLE_QUEUE_DEPTH-1].next = &sec2_Queue[0];    for (i=1; i<SEC2_HANDLE_QUEUE_DEPTH;i++)        sec2_Queue[i].previous = &sec2_Queue[i-1];    sec2_Queue[0].previous = &sec2_Queue[SEC2_HANDLE_QUEUE_DEPTH-1];    sec2_ProcessQueueTop    = &sec2_Queue[0];    sec2_ProcessQueueBottom = &sec2_Queue[0];}/*-----------------------------* Init_Drv_Ipsec_Queue - ipsec驱动的全局队列初始化*                         因为队列结构比较简单,所以不采用动态分配* Argument:*    void**Return:*    无** Return:*   * Modified history*------------------------------**/int  Init_Drv_Fwd_Queue(void){    int loopCnt;        if ((SEC2_FWD_QUEUE *)NULL != gpSec2_fwd_Queue)        return OK;    else    {        gpSec2_fwd_Queue = (SEC2_FWD_QUEUE *)malloc (sizeof(SEC2_FWD_QUEUE) * (SEC2_FWD_QUEUE_DEPTH + 1));        if ((SEC2_FWD_QUEUE *)NULL == gpSec2_fwd_Queue)        {            return ERROR;        }    }        	/*队列清零*/    memset(gpSec2_fwd_Queue, 0, (SEC2_FWD_QUEUE_DEPTH + 1) * sizeof(SEC2_FWD_QUEUE));    /*循环链队*/    for (loopCnt = 0; loopCnt < (SEC2_FWD_QUEUE_DEPTH -1);loopCnt ++)    {        gpSec2_fwd_Queue[loopCnt].num = loopCnt;        gpSec2_fwd_Queue[loopCnt].next = gpSec2_fwd_Queue + loopCnt + 1;    }        gpSec2_fwd_Queue[SEC2_FWD_QUEUE_DEPTH-1].next = gpSec2_fwd_Queue;    gpSec2_fwd_Queue[SEC2_FWD_QUEUE_DEPTH-1].num = SEC2_FWD_QUEUE_DEPTH-1;            gpSec2_FwdQueueTop    = gpSec2_fwd_Queue;    gpSec2_FwdQueueBottom = gpSec2_fwd_Queue;    return OK;}void sec2_init_mem_free(void){    if(NULL != gpDrvSec2End)    {        free(gpDrvSec2End);    }    if(NULL != gpSec2_fwd_Queue)    {        free(gpSec2_fwd_Queue);    }	    if(NULL != pgsec2_channel_debug)    {        free(pgsec2_channel_debug);    }    if(NULL != pgsec2_global_debug)    {        free(pgsec2_global_debug);    }}int sec2_channel_pktCnt_debug_init(void){        if ((SEC2_CHANNEL_PKTCNT_DEBUG *)NULL != pgsec2_channel_debug)        return OK;    else    {        pgsec2_channel_debug = (SEC2_CHANNEL_PKTCNT_DEBUG *)malloc(sizeof(SEC2_CHANNEL_PKTCNT_DEBUG) * (SEC2_NUM_CHANNELS));        if ((SEC2_CHANNEL_PKTCNT_DEBUG *)NULL == pgsec2_channel_debug)        {            return ERROR;        }    }	memset(pgsec2_channel_debug, 0, sizeof(SEC2_CHANNEL_PKTCNT_DEBUG) * (SEC2_NUM_CHANNELS));    return OK;}int sec2_pktCnt_debug_init(void){    if ((SEC2_PKTCNT_DEBUG *)NULL != pgsec2_global_debug)        return OK;    else    {        pgsec2_global_debug = (SEC2_PKTCNT_DEBUG *)malloc(sizeof(SEC2_PKTCNT_DEBUG));        if ((SEC2_PKTCNT_DEBUG *)NULL == pgsec2_global_debug)        {            return ERROR;        }    }	memset(pgsec2_global_debug, 0, sizeof(SEC2_PKTCNT_DEBUG));    return OK;}

⌨️ 快捷键说明

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