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

📄 motfcc2end.c

📁 MPC8560 for vxwork BSP
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Flag Macros */#define MOT_FCC_FLAG_CLEAR(clearBits)       \    (pDrvCtrl->flags &= ~(clearBits))#define MOT_FCC_FLAG_SET(setBits)           \    (pDrvCtrl->flags |= (setBits))#define MOT_FCC_FLAG_GET()                  \    (pDrvCtrl->flags)#define MOT_FCC_FLAG_ISSET(setBits)         \    (pDrvCtrl->flags & (setBits))#define MOT_FCC_USR_FLAG_ISSET(setBits)     \    (pDrvCtrl->userFlags & (setBits))#define END_FLAGS_ISSET(setBits)             \    ((&pDrvCtrl->endObj)->flags & (setBits))/* some BDs definitions *//* * Since we now use linkBufPool, there is no cluster pool pointer overhead. * MII_ETH_MAX_PCK_SZ is 1518. linkBufPool imposes a cluster alignment of * NETBUF_ALIGN (64 bytes), however the fcc only requires MOT_FCC_BUF_ALIGN * (32 bytes): the RX buffer descriptor start address must be a multiple * of 32, and the MRBLR, maximum receive buffer length register in the * parameter RAM, must also be a multiple of 32. */#define XXX_FCC_MAX_CL_LEN  (MII_ETH_MAX_PCK_SZ)#define MOT_FCC_MAX_CL_LEN     ROUND_UP (XXX_FCC_MAX_CL_LEN, MOT_FCC_BUF_ALIGN)#define MOT_FCC_RX_CL_SZ       (MOT_FCC_MAX_CL_LEN)#define MOT_FCC_TX_CL_SZ       (MOT_FCC_MAX_CL_LEN)/* read/write macros to access internal memory */#define MOT_FCC_REG_LONG_WR(regAddr, regVal)                \    MOT_FCC_LONG_WR ((UINT32 *) (regAddr), (regVal));#define MOT_FCC_REG_LONG_RD(regAddr, regVal)                \    MOT_FCC_LONG_RD ((UINT32 *) (regAddr), (regVal));#define MOT_FCC_REG_WORD_WR(regAddr, regVal)                \    MOT_FCC_WORD_WR ((UINT16 *) (regAddr), (regVal));#define MOT_FCC_REG_WORD_RD(regAddr, regVal)                \    MOT_FCC_WORD_RD ((UINT16 *) (regAddr), (regVal));#define END_HADDR(pEnd)                                     \        ((pEnd).mib2Tbl.ifPhysAddress.phyAddress)#define END_HADDR_LEN(pEnd)                                 \        ((pEnd).mib2Tbl.ifPhysAddress.addrLength)/* locals *//* Function declarations not in any header files *//* forward function declarations */LOCAL STATUS    motFccInitParse (DRV_CTRL * pDrvCtrl, char *initString);LOCAL STATUS    motFccInitMem (DRV_CTRL *pDrvCtrl);_WRS_FASTTEXTLOCAL STATUS    motFccSend (DRV_CTRL *pDrvCtrl, M_BLK *pMblk);LOCAL STATUS    motFccPhyPreInit (DRV_CTRL * pDrvCtrl);LOCAL STATUS    motFccRbdInit (DRV_CTRL * pDrvCtrl);LOCAL STATUS    motFccTbdInit (DRV_CTRL * pDrvCtrl);LOCAL STATUS    motFccFpsmrValSet (DRV_CTRL * pDrvCtrl);LOCAL STATUS    motFccHashTblPopulate (DRV_CTRL * pDrvCtrl);LOCAL STATUS    motFccHashTblAdd (DRV_CTRL * pDrvCtrl, UCHAR * pAddr);LOCAL STATUS    motFccIramInit (DRV_CTRL * pDrvCtrl);LOCAL STATUS    motFccPramInit (DRV_CTRL * pDrvCtrl);LOCAL STATUS    motFccCpcrCommand (DRV_CTRL * pDrvCtrl, UINT8 command);_WRS_FASTTEXTLOCAL int       motFccTbdClean (DRV_CTRL * pDrvCtrl);_WRS_FASTTEXTLOCAL void      motFccInt (DRV_CTRL * pDrvCtrl);_WRS_FASTTEXTLOCAL UINT32    motFccHandleRXFrames(DRV_CTRL *pDrvCtrl, int * pMaxRxFrames);LOCAL STATUS    motFccMiiRead (DRV_CTRL * pDrvCtrl, UINT8 phyAddr,                   UINT8 regAddr, UINT16 *retVal);LOCAL STATUS    motFccMiiWrite (DRV_CTRL * pDrvCtrl, UINT8 phyAddr,                UINT8 regAddr, UINT16 writeData);LOCAL STATUS    motFccAddrSet (DRV_CTRL * pDrvCtrl, UCHAR * pAddr,                   UINT32 offset);LOCAL void      motFccPhyLSCInt (DRV_CTRL *pDrvCtrl);LOCAL STATUS    motFccPktTransmit (DRV_CTRL *, M_BLK *);LOCAL STATUS    motFccPktCopyTransmit (DRV_CTRL *, M_BLK *);LOCAL void      motFccHandleLSCJob (DRV_CTRL *);LOCAL STATUS    motFccTbdFree (DRV_CTRL *);LOCAL STATUS    motFccRbdFree (DRV_CTRL *);/* END Specific interfaces. */END_OBJ *       motFccEndLoad (char *initString);LOCAL STATUS    motFccStart (DRV_CTRL * pDrvCtrl);LOCAL STATUS    motFccUnload (DRV_CTRL * pDrvCtrl);LOCAL STATUS    motFccMemFree (DRV_CTRL * pDrvCtrl);LOCAL STATUS    motFccStop (DRV_CTRL * pDrvCtrl);LOCAL STATUS    motFccIoctl (DRV_CTRL * pDrvCtrl, int cmd, caddr_t data);LOCAL STATUS    motFccMCastAddrAdd (DRV_CTRL * pDrvCtrl, UCHAR * pAddress);LOCAL STATUS    motFccMCastAddrDel (DRV_CTRL * pDrvCtrl, UCHAR * pAddress);LOCAL STATUS    motFccMCastAddrGet (DRV_CTRL * pDrvCtrl,                                        MULTI_TABLE *pTable);LOCAL STATUS    motFccPollSend (DRV_CTRL * pDrvCtrl, M_BLK_ID pMblk);LOCAL STATUS    motFccPollReceive (DRV_CTRL * pDrvCtrl, M_BLK_ID pMblk);LOCAL STATUS    motFccPollStart (DRV_CTRL * pDrvCtrl);LOCAL STATUS    motFccPollStop (DRV_CTRL * pDrvCtrl);/* globals */#ifdef MOT_FCC_DBG#undef  MOT_FCC_STAT_MONITOR#define MOT_FCC_STAT_MONITORvoid motFccIramShow (DRV_CTRL *);void motFccPramShow (DRV_CTRL *);void motFccEramShow (DRV_CTRL *);void motFccDrvShow (DRV_CTRL *);void motFccMiiShow (DRV_CTRL *);void motFccMibShow (DRV_CTRL *);#define MOT_FCC_DBG_OFF         0x0000#define MOT_FCC_DBG_RX          0x0001#define MOT_FCC_DBG_TX          0x0002#define MOT_FCC_DBG_POLL        0x0004#define MOT_FCC_DBG_MII         0x0008#define MOT_FCC_DBG_LOAD        0x0010#define MOT_FCC_DBG_IOCTL       0x0020#define MOT_FCC_DBG_INT         0x0040#define MOT_FCC_DBG_START       0x0080#define MOT_FCC_DBG_INT_RX_ERR  0x0100#define MOT_FCC_DBG_INT_TX_ERR  0x0200#define MOT_FCC_DBG_TRACE       0x0400#define MOT_FCC_DBG_TRACE_RX    0x0800#define MOT_FCC_DBG_TRACE_TX    0x1000#define MOT_FCC_DBG_RX_ERR      0x2000#define MOT_FCC_DBG_TX_ERR      0x4000#define MOT_FCC_DBG_MONITOR     0x8000#define MOT_FCC_DBG_ANY         0xffff#define MOT_FCC_LOG(FLG, X0, X1, X2, X3, X4, X5, X6)	\    {							\    if (motFccEndDbg & FLG)				\        logMsg (X0, (int)(X1), (int)(X2), (int)(X3),	\		(int)(X4), (int)(X5), (int)(X6));	\    }FUNCPTR _func_netJobAdd;FUNCPTR _func_txRestart;FUNCPTR _func_error;/* global debug level flag */UINT32 motFccEndDbg = MOT_FCC_DBG_MONITOR;DRV_CTRL * fcc2DrvCtrlDbg;#else /* MOT_FCC_DBG */#define MOT_FCC_LOG(FLG, X0, X1, X2, X3, X4, X5, X6)#endif#ifdef MOT_FCC_STAT_MONITOR#define MOT_FCC_STAT_INCR(i) (i++)#else#define MOT_FCC_STAT_INCR(i)#endif#ifdef MOT_FCC_DBGLOCAL const char    *speedStr[2] = {"10","100"};LOCAL const char     *linkStr[2] = {"Down","Up"};LOCAL const char   *duplexStr[2] = {"Half","Full"};#endifLOCAL const char *pIfDescrStr = "Motorola FCC Ethernet Enhanced Network Driver 2.1";/* * Define the device function table.  This is static across all driver * instances. */LOCAL NET_FUNCS netFccFuncs =    {    (FUNCPTR) motFccStart,          /* start func. */    (FUNCPTR) motFccStop,           /* stop func. */    (FUNCPTR) motFccUnload,         /* unload func. */    (FUNCPTR) motFccIoctl,          /* ioctl func. */    (FUNCPTR) motFccSend,           /* send func. */    (FUNCPTR) motFccMCastAddrAdd,   /* multicast add func. */    (FUNCPTR) motFccMCastAddrDel,   /* multicast delete func. */    (FUNCPTR) motFccMCastAddrGet,   /* multicast get func. */    (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 */    };/********************************************************************************* motFccEndLoad - 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:** "<unit><immrVal>:<fccNum>:<bdBase>:<bdSize>:<bufBase>:<bufSize>:<fifoTxBase>:* <fifoRxBase>:<tbdNum>:<rbdNum>:<phyAddr>:<phyDefMode>:<phyAnOrderTbl>:* <userFlags>:<function table>(:<maxRxFrames>)"** 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 attempts 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 uses cacheDmaMalloc() to obtain* some  cache-safe memory.  The attributes of this memory is checked,* and if the memory is not write coherent, this routine aborts and* returns NULL.** RETURNS: an END object pointer, or NULL on error.** SEE ALSO: ifLib,* \tb MPC8260 PowerQUICC II User's Manual */END_OBJ* motFcc2EndLoad    (    char *initString    )    {    DRV_CTRL * pDrvCtrl;		   /* pointer to DRV_CTRL structure */    UCHAR      enetAddr[MOT_FCC_ADDR_LEN]; /* ethernet address */    int        retVal;    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;    /* get memory for the phyInfo structure */    if ((pDrvCtrl->phyInfo = calloc (sizeof (PHY_INFO), 1)) == NULL)        {        /* Release DrvCtrl resources */        free (pDrvCtrl);        return NULL;        }    /* set up function pointers */    pDrvCtrl->netJobAdd    = (FUNCPTR) netJobAdd;    pDrvCtrl->muxTxRestart = (FUNCPTR) muxTxRestart;    pDrvCtrl->muxError     = (FUNCPTR) muxError;#ifdef MOT_FCC_DBG    fcc2DrvCtrlDbg = pDrvCtrl;    /* get memory for the drivers stats structure */    if ((pDrvCtrl->Stats = calloc (sizeof (FCC_DRIVER_STATS), 1)) == NULL)	{	free (pDrvCtrl->phyInfo);	free (pDrvCtrl);	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. Note that MOT_FCC_MAX_DEVS     * is a misleading name; it's actually the maximum unit number.     * For now we leave it, rather than risk breaking multiple BSPs.     */    if (pDrvCtrl->unit < 0 || pDrvCtrl->unit > MOT_FCC_MAX_DEVS)        goto errorExit;    /* memory initialization */    if (motFccInitMem (pDrvCtrl) == ERROR)        goto errorExit;    /* get our ethernet hardware address */    SYS_FCC_ENET_ADDR_GET (enetAddr);    /* init miiPhy functions */    if ( pDrvCtrl->motFccFuncs != NULL )        {        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;        }    else        {        pDrvCtrl->hbFailFunc    = NULL;        pDrvCtrl->intDiscFunc   = NULL;        pDrvCtrl->phyInitFunc   = NULL;        pDrvCtrl->phyDuplexFunc = NULL;        pDrvCtrl->phySpeedFunc  = NULL;        }    /* init dpram functions */    if (pDrvCtrl->motFccFuncs->dpramFree == NULL)        pDrvCtrl->dpramFreeFunc = (FUNCPTR) m82xxDpramFree;    else        pDrvCtrl->dpramFreeFunc = pDrvCtrl->motFccFuncs->dpramFree;

⌨️ 快捷键说明

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