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

📄 motfccend.c

📁 操作系统vxworks平台下end设备的驱动程序,支持多种芯片,支持多种cpu
💻 C
📖 第 1 页 / 共 5 页
字号:
errorExit:    motFccUnload (pDrvCtrl);    return NULL;    }/********************************************************************************* motFccUnload - unload a driver from the system** This routine unloads the driver pointed to by <pDrvCtrl> from the system.** RETURNS: OK, always.** SEE ALSO: motFccLoad()*/LOCAL STATUS motFccUnload    (    DRV_CTRL	*pDrvCtrl       /* pointer to DRV_CTRL structure */    )    {    FCC_PARAM_T	*pParam;    /* get to the beginning of the parameter area */    pParam = pDrvCtrl->fccPar;    MOT_FCC_LOG (MOT_FCC_DBG_LOAD, ("Unloading end..."), 1, 2, 3, 4, 5, 6);    if (pDrvCtrl == NULL)	return (ERROR);    pDrvCtrl->loaded = FALSE;    /* free allocated memory if necessary */    if ((MOT_FCC_FLAG_ISSET (MOT_FCC_OWN_BUF_MEM)) &&         (pDrvCtrl->pBufBase != NULL))        {	free (pDrvCtrl->pBufBase);        }    if ((MOT_FCC_FLAG_ISSET (MOT_FCC_OWN_BD_MEM)) &&         (pDrvCtrl->pBdBase != NULL))        {	cacheDmaFree (pDrvCtrl->pBdBase);        }    else if ((MOT_FCC_USR_FLAG_ISSET(MOT_FCC_USR_DPRAM_ALOC)) &&              (pDrvCtrl->pBdBase != NULL))	{	/*          * If pBdBase is not equal to NULL then it was allocated from the          * DPRAM pool          */	_func_m82xxDpramFree((void*)pDrvCtrl->pBdBase);	pDrvCtrl->pBdBase = NULL;	}    /* free allocated memory if necessary */    if ((pDrvCtrl->pMBlkArea) != NULL)	free (pDrvCtrl->pMBlkArea);    END_OBJECT_UNLOAD (&pDrvCtrl->endObj);    /* free the semaphores if necessary */    MOT_FCC_GRA_SEM_DELETE;    if ((char *) pDrvCtrl->phyInfo != NULL)	cfree ((char *) pDrvCtrl->phyInfo);    /* free allocated DPRAM memory if necessary */    if ((MOT_FCC_USR_FLAG_ISSET(MOT_FCC_USR_DPRAM_ALOC)) &&         (pParam->riptr != 0))        {        _func_m82xxDpramFccFree((void*)((ULONG)pParam->riptr));        pParam->riptr = 0;        }    if ((MOT_FCC_USR_FLAG_ISSET(MOT_FCC_USR_DPRAM_ALOC)) &&         (pParam->tiptr != 0))	{        _func_m82xxDpramFccFree((void*)((ULONG)pParam->tiptr));        pParam->tiptr = 0;	}    MOT_FCC_LOG (MOT_FCC_DBG_LOAD, ("motFccUnload... Done\n"), 				    1, 2, 3, 4, 5, 6);    return (OK);    }/********************************************************************************* motFccInitParse - parse parameter values from initString** This routine parses parameter values from initString and stores them in* the related fiels of the driver control structure.** RETURNS: OK or ERROR*/LOCAL STATUS motFccInitParse    (    DRV_CTRL *pDrvCtrl,      		/* pointer to DRV_CTRL structure */    char     *initString		/* parameter string */    )    {    char *  tok;		/* an initString token */    char *  holder = NULL;	/* points to initString fragment beyond tok */    tok = strtok_r (initString, ":", &holder);    if (tok == NULL)        {	return ERROR;        }    pDrvCtrl->unit = (int) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->immrVal = (UINT32) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->fccNum = (UINT32) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->pBdBase = (char *) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->bdSize = strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->pBufBase = (char *) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->bufSize = strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->fifoTxBase = (UINT32) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->fifoRxBase = (UINT32) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->tbdNum = (UINT16) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->rbdNum = (UINT16) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->phyInfo->phyAddr = (UINT8) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->phyInfo->phyDefMode = (UINT8) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->phyInfo->phyAnOrderTbl = (MII_AN_ORDER_TBL *) 					strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        {        return ERROR;        }    pDrvCtrl->userFlags = strtoul (tok, NULL, 16);    /* mblkMult is optional */    pDrvCtrl->mblkMult = 5;    tok = strtok_r (NULL, ":", &holder);    if (tok  != NULL)        pDrvCtrl->mblkMult = strtoul (tok, NULL, 16);    /* clMult is optional */    pDrvCtrl->clMult =  6;    tok = strtok_r (NULL, ":", &holder);    if (tok != NULL)        pDrvCtrl->clMult = strtoul (tok, NULL, 16);    /* txJobMsgQLen is optional */    pDrvCtrl->txJobMsgQLen = 128;    tok = strtok_r (NULL, ":", &holder);    if (tok != NULL)        pDrvCtrl->txJobMsgQLen = strtoul (tok, NULL, 16);    if (!pDrvCtrl->tbdNum || pDrvCtrl->tbdNum <= 2)	{	MOT_FCC_FLAG_SET (MOT_FCC_INV_TBD_NUM);	pDrvCtrl->tbdNum = MOT_FCC_TBD_DEF_NUM;	}    if (!pDrvCtrl->rbdNum || pDrvCtrl->rbdNum <= 2)	{	MOT_FCC_FLAG_SET (MOT_FCC_INV_RBD_NUM);	pDrvCtrl->rbdNum = MOT_FCC_RBD_DEF_NUM; 	}    MOT_FCC_LOG (MOT_FCC_DBG_LOAD,		 ("motFccEndParse: unit=%d immrVal=0x%x 		 bufBase=0x%x bufSize=0x%x,		 bdBase=0x%x bdSize=0x%x \n"),		 pDrvCtrl->unit, 		 (int) pDrvCtrl->immrVal,		 (int) pDrvCtrl->pBufBase,		 pDrvCtrl->bufSize,		 (int) pDrvCtrl->pBdBase,		 pDrvCtrl->bdSize);    MOT_FCC_LOG (MOT_FCC_DBG_LOAD,		 ("motFccEndParse: fifoTxBase=0x%x fifoRxBase=0x%x		 tbdNum=%d rbdNum=%d flags=0x%x fccNum=%d\n"),		 pDrvCtrl->fifoTxBase,		 pDrvCtrl->fifoRxBase,		 pDrvCtrl->tbdNum,		 pDrvCtrl->rbdNum,		 pDrvCtrl->userFlags,		 pDrvCtrl->fccNum);    MOT_FCC_LOG (MOT_FCC_DBG_LOAD,                 ("motFccEndParse: phyAddr=0x%x                   phyDefMode=0x%x orderTbl=0x%x \n"),                 pDrvCtrl->phyInfo->phyAddr,                 pDrvCtrl->phyInfo->phyDefMode,                 (int) pDrvCtrl->phyInfo->phyAnOrderTbl,                 0, 0, 0);    return (OK);    }/******************************************************************************** motFccInitMem - initialize memory** This routine initializes all the memory needed by the driver whose control* structure is passed in <pDrvCtrl>.** RETURNS: OK or ERROR*/LOCAL STATUS motFccInitMem     (    DRV_CTRL *pDrvCtrl    )    {    UINT32		bdMemSize,rbdMemSize,tbdMemSize;    UINT16		clNum;		/* a buffer number holder */    /* cluster blocks configuration */    M_CL_CONFIG	mclBlkConfig = {0, 0, NULL, 0};    /* cluster blocks config table */    CL_DESC		clDescTbl [] = { {MOT_FCC_MAX_CL_LEN, 0, NULL, 0} };    /* number of different clusters sizes in pool -- only 1 */    int		clDescTblNumEnt = 1;    /* initialize the netPool */    if ((pDrvCtrl->endObj.pNetPool = malloc (sizeof (NET_POOL))) == NULL)        {	return ERROR;        }    /*      * Establish the memory area that we will share with the device.  This     * area may be thought of as being divided into two parts: one is the      * buffer descriptors (BD) and the second one is for the data buffers.      * Since they have different requirements as far as cache are concerned,     * they may be addressed separately.     * We'll deal with the BDs area first.  If the caller has provided      * an area, then we assume it is non-cacheable and will not require      * the use of the special cache routines. If the caller has not provided      * an area, then we must obtain it from the system, using the cache      * savvy allocation routine.     */    switch ((int) pDrvCtrl->pBdBase)         {        case NONE :			     /* we must obtain it */	/* this driver can't handle write incoherent caches */	    if (!CACHE_DMA_IS_WRITE_COHERENT ())                 {	        MOT_FCC_LOG (MOT_FCC_DBG_LOAD,                             "motFccInitMem: shared memory not cache coherent\n",                            0,0,0,0,0,0);	        return ERROR;	        }	    rbdMemSize = MOT_FCC_RBD_SZ * pDrvCtrl->rbdNum;	    tbdMemSize = MOT_FCC_TBD_SZ * pDrvCtrl->tbdNum;	    bdMemSize = rbdMemSize + tbdMemSize + MOT_FCC_BD_ALIGN;	    pDrvCtrl->pBdBase = cacheDmaMalloc(bdMemSize);	    if (pDrvCtrl->pBdBase == NULL)                {                     /* no memory available */	        MOT_FCC_LOG (MOT_FCC_DBG_LOAD,                              "motFccInitMem: could not obtain memory\n",                             0,0,0,0,0,0);	        return ERROR;	        }	    pDrvCtrl->bdSize = bdMemSize;	    MOT_FCC_FLAG_SET (MOT_FCC_OWN_BD_MEM);	    pDrvCtrl->bdCacheFuncs = cacheDmaFuncs;	    break;        default :	       /* the user provided an area */

⌨️ 快捷键说明

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