📄 motfcc2end.c
字号:
if (pDrvCtrl->motFccFuncs->dpramFccMalloc == NULL) pDrvCtrl->dpramFccMallocFunc = (FUNCPTR) m82xxDpramFccMalloc; else pDrvCtrl->dpramFccMallocFunc = pDrvCtrl->motFccFuncs->dpramFccMalloc; if (pDrvCtrl->motFccFuncs->dpramFccFree == NULL) pDrvCtrl->dpramFccFreeFunc = (FUNCPTR) m82xxDpramFccFree; else pDrvCtrl->dpramFccFreeFunc = pDrvCtrl->motFccFuncs->dpramFccFree; /* initialize some flags */ pDrvCtrl->intrConnect = FALSE; MOT_FCC_LOG (MOT_FCC_DBG_START, "User Flags\n" "\tZero Copy : TRUE\n" "\tDPRAM ALLOC : %s\n" "\tDATA on LOCAL BUS : %s\n" "\tBDs on LOCAL BUS : %s\n", (pDrvCtrl->userFlags&MOT_FCC_USR_DPRAM_ALOC) ? "TRUE":"FALSE", (pDrvCtrl->userFlags&MOT_FCC_USR_BUF_LBUS) ? "TRUE":"FALSE", (pDrvCtrl->userFlags&MOT_FCC_USR_BD_LBUS) ? "TRUE":"FALSE", 4,5,6); MOT_FCC_LOG (MOT_FCC_DBG_START, "Buffer Management\n" "\tBuffer Base : 0x%08x\n" "\tBuffer Size : 0x%08x\n" "\tDescriptor Base : 0x%08x\n" "\tDescriptor Size : 0x%08x\n", (int)pDrvCtrl->pBufBase, pDrvCtrl->bufSize, (int)pDrvCtrl->pBdBase, pDrvCtrl->bdSize, 5,6); /* store the internal ram base address */ pDrvCtrl->fccIramAddr = (UINT32) M8260_FGMR1 (pDrvCtrl->immrVal) + ((pDrvCtrl->fccNum - 1) * M8260_FCC_IRAM_GAP); pDrvCtrl->fccReg = (FCC_REG_T *)pDrvCtrl->fccIramAddr; /* store the parameter ram base address */ pDrvCtrl->fccPramAddr = (UINT32) M8260_FCC1_BASE (pDrvCtrl->immrVal) + ((pDrvCtrl->fccNum - 1) * M8260_FCC_DPRAM_GAP); pDrvCtrl->fccPar = (FCC_PARAM_T *) pDrvCtrl->fccPramAddr; pDrvCtrl->fccEthPar = &pDrvCtrl->fccPar->prot.e; /* endObj initializations */ if (END_OBJ_INIT (&pDrvCtrl->endObj, NULL, MOT_FCC_DEV_NAME, pDrvCtrl->unit, &netFccFuncs, (char *) pIfDescrStr) == ERROR) goto errorExit; pDrvCtrl->phyInfo->phySpeed = MOT_FCC_10MBS; if (endM2Init(&pDrvCtrl->endObj, M2_ifType_ethernet_csmacd, (u_char *) &enetAddr[0], MOT_FCC_ADDR_LEN, ETHERMTU, pDrvCtrl->phyInfo->phySpeed, IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST) == ERROR) goto errorExit; /* Allocate DPRAM memory for the riptr, tiptr & pad */ pDrvCtrl->riPtr = (void *) pDrvCtrl->dpramFccMallocFunc (32,32); if (pDrvCtrl->riPtr == NULL) goto errorExit; pDrvCtrl->tiPtr = (void *) pDrvCtrl->dpramFccMallocFunc (32,32); if (pDrvCtrl->tiPtr == NULL) goto errorExit; pDrvCtrl->padPtr = (void *) pDrvCtrl->dpramFccMallocFunc (32,32); if (pDrvCtrl->padPtr == NULL) goto errorExit; /* connect the interrupt handler */ SYS_FCC_INT_CONNECT (pDrvCtrl, motFccInt, (int) pDrvCtrl, retVal); if (retVal == ERROR) goto errorExit; pDrvCtrl->rxTxHandling = FALSE; pDrvCtrl->state = MOT_FCC_STATE_LOADED; 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 */ ) { int retVal; if (pDrvCtrl == NULL) return (ERROR); if (pDrvCtrl->state & MOT_FCC_STATE_LOADED) { /* must stop the device before unloading it */ if ((pDrvCtrl->state & MOT_FCC_STATE_RUNNING) == MOT_FCC_STATE_RUNNING) motFccStop(pDrvCtrl); /* disconnect the interrupt handler */ SYS_FCC_INT_DISCONNECT (pDrvCtrl, motFccInt, (int)pDrvCtrl, retVal); if ( retVal == ERROR ) MOT_FCC_LOG (MOT_FCC_DBG_LOAD, "motfcc%d : cannot disconnect interrupt!\n", pDrvCtrl->unit, 0,0,0,0,0); /* OK even if pMib2Tbl is still zero ... */ endM2Free (&pDrvCtrl->endObj); /* free misc resources - should be safe even if just partly init'ed */ END_OBJECT_UNLOAD (&pDrvCtrl->endObj); pDrvCtrl->state = MOT_FCC_STATE_NOT_LOADED; } /* * The device is now stopped and its interrupts are disabled. It is * also disassociated from any protocols or timers. * * At this time all netPool resources associated with descriptors * will be returned to the pools they came from. */ /* * For END_NET_POOL_INIT type pools, it's only safe to free * the net pool if all of the tuples are returned. */ if (pDrvCtrl->initType == END_NET_POOL_INIT && pDrvCtrl->endObj.pNetPool != NULL && pDrvCtrl->endObj.pNetPool->pPoolStat->mTypes[MT_FREE] != pDrvCtrl->endObj.pNetPool->mBlkCnt) return ERROR; if (motFccMemFree (pDrvCtrl) != OK) return ERROR; /* Indicate to MUX that pDrvCtrl is already (or will be) freed */ return (EALREADY); }/********************************************************************************* motFccMemFree - Free the driver's memory** RETURNS: OK or ERROR*/LOCAL STATUS motFccMemFree ( DRV_CTRL *pDrvCtrl /* pointer to DRV_CTRL structure */ ) { int ix; M_BLK_ID pMblk; FCC_PARAM_T * pParam; FCC_ETH_PARAM_T * pEthPar; /* get to the beginning of the parameter area */ pParam = pDrvCtrl->fccPar; pEthPar = pDrvCtrl->fccEthPar; if (!pDrvCtrl->rxTxHandling) { /* Remove and free all mBlk chains associated with transmit queue */ if (pDrvCtrl->tBufList) { for (ix = 0; ix < pDrvCtrl->tbdNum; ix++) { if ((pMblk = pDrvCtrl->tBufList[ix]) != NULL) netMblkClChainFree (pMblk); } if (pDrvCtrl->pTxPollMblk) netTupleFree(pDrvCtrl->pTxPollMblk); free (pDrvCtrl->tBufList); pDrvCtrl->tBufList = NULL; } /* Free Tuples in receive descriptors */ if (pDrvCtrl->pMblkList) { for (ix = 0; ix < pDrvCtrl->rbdNum; ix++) { pMblk = pDrvCtrl->pMblkList[ix]; netTupleFree (pMblk); } free (pDrvCtrl->pMblkList); pDrvCtrl->pMblkList = NULL; } if ((MOT_FCC_FLAG_ISSET (MOT_FCC_OWN_BD_MEM)) && (pDrvCtrl->pRawBdBase != NULL)) { cacheDmaFree (pDrvCtrl->pRawBdBase); pDrvCtrl->pRawBdBase = NULL; } else { /* release from the DPRAM pool */ pDrvCtrl->dpramFreeFunc ((void *) pDrvCtrl->pBdBase); pDrvCtrl->pBdBase = NULL; } if (pDrvCtrl->phyInfo != NULL) { free (pDrvCtrl->phyInfo); pDrvCtrl->phyInfo = NULL; }#if defined (MOT_FCC_DBG) || defined (MOT_FCC_STAT_MONITOR) if (pDrvCtrl == fcc2DrvCtrlDbg) fcc2DrvCtrlDbg = NULL; if (pDrvCtrl->Stats) { free (pDrvCtrl->Stats); pDrvCtrl->Stats = NULL; }#endif /* MOT_FCC_DBG or MOT_FCC_STAT_MONITOR */ /* free allocated DPRAM memory if necessary */ if (pDrvCtrl->riPtr != NULL) { pDrvCtrl->dpramFccFreeFunc (pDrvCtrl->riPtr); pParam->riptr = 0; pDrvCtrl->riPtr = NULL; } if (pDrvCtrl->tiPtr != NULL) { pDrvCtrl->dpramFccFreeFunc (pDrvCtrl->tiPtr); pParam->tiptr = 0; pDrvCtrl->tiPtr = NULL; } if (pDrvCtrl->padPtr != NULL) { pDrvCtrl->dpramFccFreeFunc (pDrvCtrl->padPtr); pEthPar->pad_ptr = 0; pDrvCtrl->padPtr = NULL; } if (pDrvCtrl->endObj.pNetPool != NULL) { if (pDrvCtrl->initType == END_NET_POOL_INIT) { /* We checked earlier that all M_BLKs were returned. */ if (pDrvCtrl->pMBlkArea != NULL) { free (pDrvCtrl->pMBlkArea); pDrvCtrl->pMBlkArea = NULL; } /* * Note, the following doesn't free the cluster memory, which * we don't own: it was passed by the BSP. */ netPoolDelete (pDrvCtrl->endObj.pNetPool); } else { /* Schedule the pool to be freed */ netPoolRelease (pDrvCtrl->endObj.pNetPool, NET_REL_IN_TASK); } pDrvCtrl->endObj.pNetPool = NULL; } free (pDrvCtrl); } else { if ((NET_JOB_ADD ((FUNCPTR) motFccMemFree, (int) pDrvCtrl, 0,0,0,0)) == ERROR) { logMsg("The netJobRing is full.\n",0,0,0,0,0,0); } } return (OK); }/********************************************************************************* motFccInitParse - parse parameter values from initString** This routine parses parameter values from initString and stores them in* the related files 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 token */ /* unit number */ tok = strtok_r (initString, ":", &holder); if (tok == NULL) return ERROR; pDrvCtrl->unit = (int) strtoul (tok, NULL, 16); /* internal RAM base address */ tok = strtok_r (NULL, ":", &holder); if (tok == NULL) return ERROR; pDrvCtrl->immrVal = (UINT32) strtoul (tok, NULL, 16); /* fcc number */ tok = strtok_r (NULL, ":", &holder); if (tok == NULL) return ERROR; pDrvCtrl->fccNum = (UINT8) strtoul (tok, NULL, 16);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -