📄 motfcc2end.c
字号:
(FUNCPTR) motFccMCastAddrAdd, /* multicast add func. */ (FUNCPTR) motFccMCastAddrDel, /* multicast delete func. */ (FUNCPTR) motFccMCastAddrGet, /* multicast get fun. */ (FUNCPTR) motFccPollSend, /* polling send func. */ (FUNCPTR) motFccPollReceive, /* polling receive func. */ endEtherAddressForm, /* put address info into a NET_BUFFER */ (FUNCPTR) endEtherPacketDataGet, /* get pointer to data in NET_BUFFER */ (FUNCPTR) endEtherPacketAddrGet /* Get packet addresses */ };/********************************************************************************* motFcc2EndLoad - initialize the driver and device** This routine initializes both driver and device to an operational state* using device specific parameters specified by <initString>.** The parameter string, <initString>, is an ordered list of parameters each* separated by a colon. The format of <initString> is:** "<immrVal>:<ivec>:<bufBase>:<bufSize>:<fifoTxBase>:<fifoRxBase>* :<tbdNum>:<rbdNum>:<phyAddr>:<phyDefMode>:<pAnOrderTbl>:<userFlags>"** The FCC shares a region of memory with the driver. The caller of this* routine can specify the address of this memory region, or can specify that* the driver must obtain this memory region from the system resources.** A default number of transmit/receive buffer descriptors of 32 can be* selected by passing zero in the parameters <tbdNum> and <rbdNum>.* In other cases, the number of buffers selected should be greater than two.** The <bufBase> parameter is used to inform the driver about the shared* memory region. If this parameter is set to the constant "NONE," then this* routine will attempt to allocate the shared memory from the system. Any* other value for this parameter is interpreted by this routine as the address* of the shared memory region to be used. The <bufSize> parameter is used* to check that this region is large enough with respect to the provided* values of both transmit/receive buffer descriptors.** If the caller provides the shared memory region, then the driver assumes* that this region does not require cache coherency operations, nor does it* require conversions between virtual and physical addresses.** If the caller indicates that this routine must allocate the shared memory* region, then this routine will use cacheDmaMalloc() to obtain* some cache-safe memory. The attributes of this memory will be checked,* and if the memory is not write coherent, this routine will abort and* return NULL.** RETURNS: an END object pointer, or NULL on error.** SEE ALSO: ifLib,* .I "MPC8260 Power QUICC II User's Manual"*/END_OBJ* motFcc2EndLoad ( char *initString ) { DRV_CTRL * pDrvCtrl = NULL; /* pointer to DRV_CTRL structure */ UCHAR enetAddr[MOT_FCC_ADDR_LEN]; /* ethernet address */ int retVal;#ifdef INTER_BOARDS_COMM char unitString[3]; UINT32 unit = 0;#endif /* INTER_BOARDS_COMM */ if (initString == NULL) return NULL; if (initString[0] == 0) { bcopy ((char *)MOT_FCC_DEV_NAME, (void *)initString,MOT_FCC_DEV_NAME_LEN); return NULL; } /* allocate the device structure */ pDrvCtrl = (DRV_CTRL *) calloc (sizeof (DRV_CTRL), 1); if (pDrvCtrl == NULL) return NULL;#ifdef INTER_BOARDS_COMM unitString[0] = initString[0]; unitString[1] = '\0'; unit = atoi (unitString); if (unit == INTER_BRDCOMM_UNIT) ibcDrvCtrl = pDrvCtrl; if (unit == MB_BRDCOMM_UNIT) mbcDrvCtrl = pDrvCtrl;#endif /* INTER_BOARDS_COMM */ /* get memory for the phyInfo structure */ if ((pDrvCtrl->phyInfo = calloc (sizeof (PHY_INFO), 1)) == NULL) return NULL; /* set up function pointers */ pDrvCtrl->netJobAdd = (FUNCPTR) netJobAdd; pDrvCtrl->muxTxRestart = (FUNCPTR) muxTxRestart; pDrvCtrl->muxError = (FUNCPTR) muxError;#ifdef MOT_FCC_DBG pDrvCtrlDbg = pDrvCtrl; /* get memory for the drivers stats structure */ if ((pDrvCtrl->Stats = calloc (sizeof (FCC_DRIVER_STATS), 1)) == NULL) return NULL; /* support unit test */ _func_netJobAdd = (FUNCPTR) netJobAdd; _func_txRestart = (FUNCPTR) muxTxRestart; _func_error = (FUNCPTR) muxError;#endif /* MOT_FCC_DBG */ /* Parse InitString */ if (motFccInitParse (pDrvCtrl, initString) == ERROR) goto errorExit; /* sanity check the unit number */ if (pDrvCtrl->unit < 0 ) goto errorExit; /* memory initialization */ if (motFccInitMem (pDrvCtrl) == ERROR) goto errorExit; /* get our ethernet hardware address */ SYS_FCC_ENET_ADDR_GET (enetAddr); /* init miiPhy fuctions */ if ( pDrvCtrl->motFccFuncs == NULL ) { pDrvCtrl->hbFailFunc = NULL; pDrvCtrl->intDiscFunc = NULL; pDrvCtrl->phyInitFunc = NULL; pDrvCtrl->phyDuplexFunc = NULL; pDrvCtrl->phySpeedFunc = NULL; } else { pDrvCtrl->hbFailFunc = pDrvCtrl->motFccFuncs->hbFail; pDrvCtrl->intDiscFunc = pDrvCtrl->motFccFuncs->intDisc; pDrvCtrl->phyInitFunc = pDrvCtrl->motFccFuncs->miiPhyInit; pDrvCtrl->phyDuplexFunc = pDrvCtrl->motFccFuncs->miiPhyDuplex; pDrvCtrl->phySpeedFunc = pDrvCtrl->motFccFuncs->miiPhySpeed; /* BSP call back to driver */ pDrvCtrl->motFccFuncs->miiPhyInt = (FUNCPTR) motFccPhyLSCInt; } /* init dpram functions */ if (pDrvCtrl->motFccFuncs->dpramFree == NULL) pDrvCtrl->dpramFreeFunc = (FUNCPTR) m82xxDpramFree; else pDrvCtrl->dpramFreeFunc = pDrvCtrl->motFccFuncs->dpramFree; 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; /* Set zeroBufFlag */ if (pDrvCtrl->userFlags & MOT_FCC_USR_NO_ZCOPY) pDrvCtrl->zeroBufFlag = FALSE; else pDrvCtrl->zeroBufFlag = TRUE; MOT_FCC_LOG (MOT_FCC_DBG_START, "User Flags\n" "\tZero Copy : %s\n" "\tDPRAM ALLOC : %s\n" "\tDATA on LOCAL BUS : %s\n" "\tBDs on LOCAL BUS : %s\n", (pDrvCtrl->userFlags&MOT_FCC_USR_NO_ZCOPY) ? (int)"FALSE":(int)"TRUE", (pDrvCtrl->userFlags&MOT_FCC_USR_DPRAM_ALOC) ? (int)"TRUE":(int)"FALSE", (pDrvCtrl->userFlags&MOT_FCC_USR_BUF_LBUS) ? (int)"TRUE":(int)"FALSE", (pDrvCtrl->userFlags&MOT_FCC_USR_BD_LBUS) ? (int)"TRUE":(int)"FALSE", 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; /* * create the synchronization semaphore for graceful transmit * command interrupts. */ if ((pDrvCtrl->graSem = semBCreate (SEM_Q_FIFO, SEM_EMPTY) )== NULL) goto errorExit; /* * 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 semTake. */ semGive (pDrvCtrl->graSem); /* endObj initializations */ if (END_OBJ_INIT (&pDrvCtrl->endObj, (DEV_OBJ*) pDrvCtrl, MOT_FCC_DEV_NAME, pDrvCtrl->unit, &netFccFuncs, (char *) pIfDescrStr) == ERROR) goto errorExit; pDrvCtrl->phyInfo->phySpeed = MOT_FCC_10MBS;#ifdef INCLUDE_RFC_2233 /* Initialize MIB-II entries (for RFC 2233 ifXTable) */ pDrvCtrl->endObj.pMib2Tbl = m2IfAlloc(M2_ifType_ethernet_csmacd, (UINT8*) enetAddr, 6, ETHERMTU, pDrvCtrl->phyInfo->phySpeed, MOT_FCC_DEV_NAME, pDrvCtrl->unit); if (pDrvCtrl->endObj.pMib2Tbl == NULL) { logMsg ("%s%d - MIB-II initializations failed\n", (int)MOT_FCC_DEV_NAME, pDrvCtrl->unit,0,0,0,0); goto errorExit; } /* * Set the RFC2233 flag bit in the END object flags field and * install the counter update routines. */ m2IfPktCountRtnInstall(pDrvCtrl->endObj.pMib2Tbl, m2If8023PacketCount); /* * Make a copy of the data in mib2Tbl struct as well. We do this * mainly for backward compatibility issues. There might be some * code that might be referencing the END pointer and might * possibly do lookups on the mib2Tbl, which will cause all sorts * of problems. */ bcopy ((char *)&pDrvCtrl->endObj.pMib2Tbl->m2Data.mibIfTbl, (char *)&pDrvCtrl->endObj.mib2Tbl, sizeof (M2_INTERFACETBL)); /* Mark the device ready */ END_OBJ_READY (&pDrvCtrl->endObj, IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST | END_MIB_2233);#else /* Old RFC 1213 mib2 interface */ 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; END_OBJ_READY (&pDrvCtrl->endObj, IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST);#endif /* INCLUDE_RFC_2233 */ /* 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->state = MOT_FCC_STATE_LOADED; return(&pDrvCtrl->endObj); errorExit: motFccUnload (pDrvCtrl); return NULL; }/********************************************************************************* motFccUnload - unload a driver from the system*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -