📄 motfccend.c
字号:
MOT_FCC_LOG (MOT_FCC_DBG_LOAD, ("motFccEndLoad: pram=0x%x iram=0x%x \n "),
pDrvCtrl->fccPramAddr,
pDrvCtrl->fccIramAddr,
0, 0, 0, 0);
pDrvCtrl->fccPar = (FCC_PARAM_T *)pDrvCtrl->fccPramAddr;
pDrvCtrl->fccEthPar = &pDrvCtrl->fccPar->prot.e;
/*
* create the synchronization semaphore for graceful transmit
* command interrupts.
*/
MOT_FCC_GRA_SEM_CREATE;
/*
* Because we create EMPTY semaphore we need to give it here
* other wise the only time that it's given back is in the
* motFccInt() and if we have two NI in the bootrom like SCC
* and FCC the motFccStop() will be spin forever when it will
* try to do MOT_FCC_GRA_SEM_TAKE.
*/
MOT_FCC_GRA_SEM_GIVE;
/*
* endObj initializations,
* The second parameter is (DEV_OBJ*) pDrvCtrl in the original code.
*/
if (END_OBJ_INIT (&pDrvCtrl->endObj,
(DEV_OBJ*)&pDrvCtrl->endObj.devObject,
MOT_FCC_DEV_NAME,
pDrvCtrl->unit, &netFccFuncs,
"Motorola FCC Ethernet Enhanced Network Driver") == ERROR)
{
goto errorExit;
}
pDrvCtrl->phyInfo->phySpeed = MOT_FCC_100MBS;
if (END_MIB_INIT (&pDrvCtrl->endObj,
M2_ifType_ethernet_csmacd,
(u_char *) &enetAddr[0],
MOT_FCC_ADDR_LEN,
ETHERMTU,
pDrvCtrl->phyInfo->phySpeed) == ERROR)
{
goto errorExit;
}
/* Mark the device ready */
END_OBJ_READY (&pDrvCtrl->endObj, IFF_NOTRAILERS | IFF_MULTICAST |
IFF_BROADCAST);
MOT_FCC_LOG (MOT_FCC_DBG_LOAD, ("motFccEndLoad...done\n"),
1, 2, 3, 4, 5, 6);
return (&pDrvCtrl->endObj);
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, ("motFccUnload...\n"), 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,
("motFccInitParse: 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,
("motFccInitParse: 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,
("motFccInitParse: 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -