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

📄 dec21x40end.c

📁 操作系统vxworks平台下end设备的驱动程序,支持多种芯片,支持多种cpu
💻 C
📖 第 1 页 / 共 5 页
字号:
        DEC_MII_BIT_READ (&retVal); \        } while (0)#define DEC_MII_WTRISTATE           \        do {                        \        DEC_MII_BIT_WRITE(0x1);     \        DEC_MII_BIT_WRITE(0x0);     \        } while (0)#define DEC_MII_WRITE(data, bitCount)                \        do {                                         \        int i=(bitCount);                            \                                                     \        while (i--)                                  \            DEC_MII_BIT_WRITE (((data) >> i) & 0x1); \        } while (0)#define DEC_MII_READ(pData, bitCount) \        do {                          \        int i=(bitCount);             \                                      \        while (i--)                   \            {                         \            *(pData) <<= 1;           \            DEC_MII_BIT_READ (pData); \            }                         \        } while (0)/* * Default macro definitions for BSP interface. * These macros can be redefined in a wrapper file, to generate * a new module with an optimized interface. */#ifndef SYS_INT_CONNECT#define SYS_INT_CONNECT(pDrvCtrl,rtn,arg,pResult)                       \    do {                                                                \    int vector = pDrvCtrl->ivec;                                        \    if (!pDrvCtrl->intrConnect)                                         \        {                                                               \        pDrvCtrl->intrConnect = TRUE;                                   \       *pResult = (*dec21x40IntConnectRtn) (                            \                               (VOIDFUNCPTR *)INUM_TO_IVEC (vector),    \                                (rtn), (int)(arg));                     \        }                                                               \    } while (0)#endif /*SYS_INT_CONNECT*/ #ifndef SYS_INT_DISCONNECT#define SYS_INT_DISCONNECT(pDrvCtrl,rtn,arg,pResult)                    \    do {                                                                \    /* set pDrvCtrl->intrConnect to FALSE if appropriate */             \    *pResult = OK;							\    } while (0)#endif /*SYS_INT_DISCONNECT*/#ifndef SYS_INT_ENABLE#define SYS_INT_ENABLE(pDrvCtrl)                                        \    do {                                                                \    IMPORT void sysLanIntEnable();                                      \    sysLanIntEnable (pDrvCtrl->ilevel);                                 \    } while (0)#endif /*SYS_INT_ENABLE*/#ifndef SYS_INT_DISABLE#define SYS_INT_DISABLE(pDrvCtrl)                                       \    do {                                                                \    IMPORT void sysLanIntDisable();                                     \    sysLanIntDisable (pDrvCtrl->ilevel);                                \    } while (0)#endif /*SYS_INT_DISABLE*/#define	END_MIB_SPEED_SET(pEndObj, speed)                               \	((pEndObj)->mib2Tbl.ifSpeed=speed)#define NET_BUF_ALLOC()                                                 \    netClusterGet (pDrvCtrl->endObj.pNetPool, pDrvCtrl->clPoolId)#define NET_BUF_FREE(pBuf)                                              \    netClFree (pDrvCtrl->endObj.pNetPool, pBuf)#define	NET_MBLK_ALLOC()                                                \    mBlkGet (pDrvCtrl->endObj.pNetPool, M_DONTWAIT, MT_DATA)#define NET_MBLK_FREE(pMblk)                                            \    netMblkFree (pDrvCtrl->endObj.pNetPool, (M_BLK_ID)pMblk)#define	NET_CL_BLK_ALLOC()                                              \    clBlkGet (pDrvCtrl->endObj.pNetPool, M_DONTWAIT)#define NET_CL_BLK_FREE(pClblk)                                         \    clBlkFree (pDrvCtrl->endObj.pNetPool, (CL_BLK_ID)pClBlk)            #define NET_MBLK_BUF_FREE(pMblk)                                        \    netMblkClFree ((M_BLK_ID)pMblk)#define NET_MBLK_CHAIN_FREE(pMblk)                                      \    do {                                                                \    M_BLK *pNext;                                                       \                                                                        \    pNext=pMblk;                                                        \    while (pNext)                                                       \        pNext=NET_MBLK_BUF_FREE (pNext);                                \    } while (0)    #define NET_MBLK_CL_JOIN(pMblk, pClBlk)                              	\    netMblkClJoin ((pMblk), (pClBlk))#define NET_CL_BLK_JOIN(pClBlk, pBuf, len)                             	\    netClBlkJoin ((pClBlk), (pBuf), (len), NULL, 0, 0, 0)        #define	DRV_CTRL	DEC21X40_DRV_CTRL/* structure sizes */#define DRV_CTRL_SIZ		sizeof(DRV_CTRL)#define RD_SIZ			sizeof(DEC_RD)#define TD_SIZ			sizeof(DEC_TD)/* locals *//* Default network buffer configuration */int	dec21x40Loops = DEC_LOOPS_PER_NS;	/* spin loops per nsec */FUNCPTR	dec21x40IntConnectRtn = intConnect;/* constant data to set PHY control register */LOCAL const UINT dcForcePhyModes[] =     {    MII_CR_100 | MII_CR_FDX,	/* 100FD */    MII_CR_100,			/* 100HD */    MII_CR_FDX,			/* 10FD  */    0,				/* 10HD  */    -1    } ;/* forward declarations */LOCAL STATUS	dec21x40InitParse (DRV_CTRL *pDrvCtrl, char *InitString);LOCAL STATUS	dec21x40InitMem (DRV_CTRL *pDrvCtrl);LOCAL STATUS	dec21x40IASetup (DRV_CTRL *pDrvCtrl);LOCAL void 	dec21x40ModeSet (DRV_CTRL *pDrvCtrl);LOCAL int	dec21x40HashIndex (char *eAddr);LOCAL void 	dec21x40Int (DRV_CTRL *pDrvCtrl);LOCAL STATUS 	dec21x40Recv (DRV_CTRL *pDrvCtrl, DEC_RD *rmd);LOCAL STATUS 	dec21x40ChipReset (DRV_CTRL *pDrvCtrl);LOCAL void	dec21040AuiTpInit (DRV_CTRL *pDrvCtrl);LOCAL void 	dec21x40CsrWrite (DRV_CTRL *pDrvCtrl, int reg, ULONG value);LOCAL ULONG 	dec21x40CsrRead (DRV_CTRL *pDrvCtrl, int reg);LOCAL STATUS 	dec21x40EnetAddrGet (DRV_CTRL *pDrvCtrl, char *enetAdrs);LOCAL STATUS 	dec21040EnetAddrGet (DRV_CTRL *pDrvCtrl, char *enetAdrs);LOCAL STATUS 	dec21140EnetAddrGet (DRV_CTRL *pDrvCtrl, char *enetAdrs);LOCAL void	dec21x40Restart (DRV_CTRL *pDrvCtrl);LOCAL STATUS	dec21x40MediaChange (DRV_CTRL *pDrvCtrl);LOCAL DEC_TD *	dec21x40TxDGet (DRV_CTRL *pDrvCtrl);LOCAL DEC_RD *	dec21x40RxDGet (DRV_CTRL *pDrvCtrl);LOCAL void 	dec21x40TxRingClean (DRV_CTRL *pDrvCtrl);LOCAL void 	dec21x40RxIntHandle (DRV_CTRL *pDrvCtrl);LOCAL STATUS 	dec21140MediaSelect (DRV_CTRL *pDrvCtrl, UINT *pCsr6Val);LOCAL STATUS 	dec21143MediaSelect (DRV_CTRL *pDrvCtrl, UINT *pCsr6Val);LOCAL STATUS dec21145DecodeExt7InfoBlock ( DRV_CTRL *pDrvCtrl,                                           UCHAR * pInfoBlock);LOCAL STATUS 	dec21145MediaSelect (DRV_CTRL *pDrvCtrl, UINT *pCsr6Val);LOCAL STATUS 	dec21x40PhyPreInit  (DRV_CTRL *pDrvCtrl, UCHAR * pInfoBlock);LOCAL STATUS 	dec21x40MiiInit  (DRV_CTRL *pDrvCtrl, UINT *pCsr6Val,				  UCHAR * pInfoBlock);LOCAL STATUS dec21x40MiiRead ( DRV_CTRL *pDrvCtrl, UINT8 phyAdrs, UINT8 phyReg,              	               UINT16 *pRetVal);LOCAL STATUS dec21x40MiiWrite (DRV_CTRL *pDrvCtrl, UINT8 phyAdrs, UINT8 phyReg,                               USHORT data);LOCAL void dec21x40NanoDelay (UINT32 nsec);/* externals */IMPORT STATUS	sysDec21x40EnetAddrGet (int unit, char *enetAdrs);/* globals */USHORT		dec21140SromWordRead (DRV_CTRL *pDrvCtrl, UCHAR lineCnt);FUNCPTR		_func_dec21x40MediaSelect = (FUNCPTR) NULL;VOIDFUNCPTR	_func_dec2114xIntAck = (VOIDFUNCPTR) NULL;VOIDFUNCPTR	_func_dec21x40NanoDelay = dec21x40NanoDelay;#ifdef DRV_DEBUG_SHOW#include "netShow.h"IMPORT void netPoolShow (NET_POOL_ID);void decCsrShow (int inst);void decShow (int inst);#endif /* DRV_DEBUG_SHOW *//* END Specific interfaces. */END_OBJ *	dec21x40EndLoad (char *initString);LOCAL STATUS	dec21x40Unload (DRV_CTRL *pDrvCtrl);LOCAL STATUS	dec21x40Start (DRV_CTRL *pDrvCtrl);LOCAL STATUS	dec21x40Stop (DRV_CTRL *pDrvCtrl);LOCAL int	dec21x40Ioctl (DRV_CTRL *pDrvCtrl, int cmd, caddr_t data);LOCAL STATUS	dec21x40Send (DRV_CTRL *pDrvCtrl, M_BLK *pMblk);LOCAL STATUS	dec21x40MCastAddrAdd (DRV_CTRL *pDrvCtrl, char* pAddress);LOCAL STATUS	dec21x40MCastAddrDel (DRV_CTRL *pDrvCtrl, char* pAddress);LOCAL STATUS	dec21x40MCastAddrGet (DRV_CTRL *pDrvCtrl,                                       MULTI_TABLE *pTable);LOCAL STATUS	dec21x40PollSend (DRV_CTRL *pDrvCtrl, M_BLK *pMblk);LOCAL STATUS	dec21x40PollReceive (DRV_CTRL *pDrvCtrl, M_BLK *pMblk);LOCAL STATUS	dec21x40PollStart (DRV_CTRL *pDrvCtrl);LOCAL STATUS	dec21x40PollStop (DRV_CTRL *pDrvCtrl);/*  * Define the device function table.  This is static across all driver * instances. */LOCAL NET_FUNCS netFuncs =     {    (FUNCPTR)dec21x40Start,	/* start func. */                     (FUNCPTR)dec21x40Stop,	/* stop func. */    (FUNCPTR)dec21x40Unload,	/* unload func. */                    (FUNCPTR)dec21x40Ioctl,	/* ioctl func. */                     (FUNCPTR)dec21x40Send,	/* send func. */                      (FUNCPTR)dec21x40MCastAddrAdd,/* multicast add func. */             (FUNCPTR)dec21x40MCastAddrDel,/* multicast delete func. */          (FUNCPTR)dec21x40MCastAddrGet,/* multicast get fun. */              (FUNCPTR)dec21x40PollSend,	/* polling send func. */              (FUNCPTR)dec21x40PollReceive, /* polling receive func. */           endEtherAddressForm,	/* put address info into a NET_BUFFER */    endEtherPacketDataGet,	/* get pointer to data in NET_BUFFER */    endEtherPacketAddrGet	/* Get packet addresses. */    };				/******************************************************************************** endTok_r - get a token string (modified version)** This modified version can be used with optional parameters.  If the* parameter is not specified, this version returns NULL.  It does not* signify the end of the original string, but that the parameter is null.** .CS**    /@ required parameters @/**    string = endTok_r (initString, ":", &pLast);*    if (string == NULL)*        return ERROR;*    reqParam1 = strtoul (string);**    string = endTok_r (NULL, ":", &pLast);*    if (string == NULL)*        return ERROR;*    reqParam2 = strtoul (string);**    /@ optional parameters @/**    string = endTok_r (NULL, ":", &pLast);*    if (string != NULL)*        optParam1 = strtoul (string);**    string = endTok_r (NULL, ":", &pLast);*    if (string != NULL)*        optParam2 = strtoul (string);* .CE*/ char * endTok_r    (    char *       string,      /* string to break into tokens */    const char * separators,  /* the separators */    char **      ppLast               /* pointer to serve as string index */    )    {    if ((string == NULL) && ((string = *ppLast) == NULL))      return (NULL);    if ((*ppLast = strpbrk (string, separators)) != NULL)      *(*ppLast)++ = EOS;    /* Return NULL, if string is empty */    if (*string == EOS)      return NULL;    return (string);    }/***************************************************************************** dec21x40EndLoad - initialize the driver and device** This routine initializes the driver and the device to an operational state.* All of the device-specific parameters are passed in the <initStr>.* If this routine is called with an empty but allocated string, it puts the * name of this device (that is, "dc") into the <initStr> and returns 0.* If the string is allocated but not empty, this routine tries to load* the device.** RETURNS: An END object pointer or NULL on error.*/END_OBJ* dec21x40EndLoad    (    char* initStr		/* String to be parse by the driver. */    )    {    DRV_CTRL	*pDrvCtrl;    char	eAdrs[EADDR_LEN];            /* ethernet address */    if (initStr == NULL)        {        DRV_LOG (DRV_DEBUG_LOAD, "dec21x40EndLoad: NULL initStr\r\n",		 0,0,0,0,0,0);        return (NULL);        }        if (initStr[0] == '\0')        {        bcopy((char *)DRV_NAME, initStr, DRV_NAME_LEN);        return (0);        }    /* Allocate a control structure for this device */    pDrvCtrl = calloc (sizeof(DRV_CTRL), 1);    if (pDrvCtrl == NULL)        {        DRV_LOG (DRV_DEBUG_LOAD,"%s - Failed to allocate control structure\n",                  (int)DRV_NAME, 0,0,0,0,0 );         return (NULL);        }    pDrvCtrl->flags = 0;    pDrvCtrl->intrConnect = FALSE;    pDrvCtrl->mediaCount = 0xff;    pDrvCtrl->homePNAPhyValuesFound = FALSE;    pDrvCtrl->offset = 0;    if (dec21x40InitParse (pDrvCtrl, initStr) == ERROR)        {        DRV_LOG  (DRV_DEBUG_INIT, "%s - Failed to parse initialization"	"parameters\n",        (int)DRV_NAME,0,0,0,0,0);        return (NULL);        }    if (END_OBJ_INIT (&pDrvCtrl->endObj, (DEV_OBJ*)pDrvCtrl, DRV_NAME,                      pDrvCtrl->unit, &netFuncs,                      "dec21x40 Enhanced Network Driver") == ERROR)        {        DRV_LOG  (DRV_DEBUG_INIT, "%s%d - Failed to initialize END object\n",                  (int)DRV_NAME, pDrvCtrl->unit, 0,0,0,0);        return (NULL);        }    if (dec21x40InitMem (pDrvCtrl) == ERROR)        {        DRV_LOG (DRV_DEBUG_INIT, "dec21x40InitMem failed",0,0,0,0,0,0);        goto error;

⌨️ 快捷键说明

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