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

📄 dec21x4xend.c

📁 Tornado 2.0.2 source code!vxworks的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
#define DRV_FLAGS_ISSET(setBits)                                        \	(pDrvCtrl->flags & (setBits))#define DRV_FLAGS_CLR(clrBits)                                          \	(pDrvCtrl->flags &= ~(clrBits))#define DRV_FLAGS_GET()                                                 \        (pDrvCtrl->flags)/* Cache macros */#define DEC_CACHE_INVALIDATE(address, len)                              \        CACHE_DRV_INVALIDATE (&pDrvCtrl->cacheFuncs, (address), (len))#define DEC_CACHE_VIRT_TO_PHYS(address)                                 \        CACHE_DRV_VIRT_TO_PHYS (&pDrvCtrl->cacheFuncs, (address))#define DEC_CACHE_PHYS_TO_VIRT(address)                                 \        CACHE_DRV_PHYS_TO_VIRT (&pDrvCtrl->cacheFuncs, (address))/* memory to PCI address translation macros */#define PCI_TO_MEM_PHYS(pciAdrs)                                        \	(((ULONG)(pciAdrs)) - (pDrvCtrl->pciMemBase))	#define MEM_TO_PCI_PHYS(memAdrs)                                        \	(((ULONG)(memAdrs)) + (pDrvCtrl->pciMemBase))#define DEC_VIRT_TO_PCI(vAdrs)                                          \	MEM_TO_PCI_PHYS (DEC_CACHE_VIRT_TO_PHYS (vAdrs))#define DEC_PCI_TO_VIRT(pciAdrs)                                        \	DEC_CACHE_PHYS_TO_VIRT (PCI_TO_MEM_PHYS (pciAdrs))/* * CSR access macros * * To optimize CSR accesses, redefine DEC_CSR_READ and * DEC_CSR_WRITE macros in a wrapper file. */#ifndef DEC_CSR_READ#define DEC_CSR_READ(csr)                                               \	dec21x4xCsrRead(pDrvCtrl->devAdrs, (csr))#endif /* DEC_CSR_READ */#ifndef DEC_CSR_WRITE#define DEC_CSR_WRITE(csr,val)                                          \	dec21x4xCsrWrite(pDrvCtrl->devAdrs, (csr), (val))#endif /* DEC_CSR_WRITE */#define DEC_CSR_UPDATE(csr,val)                                         \	DEC_CSR_WRITE((csr), DEC_CSR_READ(csr) | (val))    #define DEC_CSR_RESET(csr,val)                                          \	DEC_CSR_WRITE((csr), DEC_CSR_READ(csr) & ~(val))    #define DEC_SROM_CMD_WRITE(adrs,delay)                                  \	{                                                               \        DEC_CSR_WRITE(CSR9, CSR9_2114X_SR | CSR9_2114X_WR | (adrs));    \        NSDELAY (delay);                                                \        }#define DEC_SROM_CMD_READ()                                             \	((DEC_CSR_READ(CSR9) & 0x8) >> 3)/* * Special purpose macros * These macros can be redefined in a wrapper file if desired */#ifndef INITIAL_RESET#define DUMMY_BUFFER_SIZE  60#define INITIAL_RESET(pDrvCtrl) \        dec21x4xInitialReset(pDrvCtrl)#endif/* * Default macro definitions for BSP interface. * These macros can be redefined in a wrapper file, to generate * a new module with an optimized interface. *//* * For X86 arch, the intConnect/Disconnect defaults are pciIntConnect and * pciIntDisconnect.  For all others it is just intConnect and a dummy * disconnect function. * HELP: This needs to be fixed by porting pciIntLib to all architectures. */#if CPU_FAMILY == I80X86#ifndef SYS_INT_CONNECT#define SYS_INT_CONNECT(pDrvCtrl,rtn,arg,pResult)                       \    {                                                                   \    IMPORT STATUS pciIntConnect();                                      \    *pResult = pciIntConnect ((VOIDFUNCPTR *)INUM_TO_IVEC (pDrvCtrl->ivec),\			     (rtn), (int)(arg));                        \    }#endif /*SYS_INT_CONNECT*/#ifndef SYS_INT_DISCONNECT#define SYS_INT_DISCONNECT(pDrvCtrl,rtn,arg,pResult)                    \    {                                                                   \    IMPORT STATUS pciIntDisconnect();                                      \    *pResult = pciIntDisconnect ((VOIDFUNCPTR *)INUM_TO_IVEC (pDrvCtrl->ivec),\			     (rtn));		                        \    }#endif /*SYS_INT_DISCONNECT*/#else /* CPU_FAMILY == I80X86 */#ifndef SYS_INT_CONNECT#define SYS_INT_CONNECT(pDrvCtrl,rtn,arg,pResult)                       \    {                                                                   \    IMPORT STATUS intConnect();                                      \    *pResult = intConnect ((VOIDFUNCPTR *)INUM_TO_IVEC (pDrvCtrl->ivec),\			     (rtn), (int)(arg));                        \    }#endif /*SYS_INT_CONNECT*/#ifndef SYS_INT_DISCONNECT#define SYS_INT_DISCONNECT(pDrvCtrl,rtn,arg,pResult)                    \    {                                                                   \    *pResult = OK;							\    }#endif /*SYS_INT_DISCONNECT*/#endif /* CPU_FAMILY == I80X86 */#ifndef SYS_INT_ENABLE#define SYS_INT_ENABLE(pDrvCtrl)                                        \    {                                                                   \    IMPORT STATUS sysLanIntEnable();					\    sysLanIntEnable(pDrvCtrl->ilevel);					\    }#endif /*SYS_INT_ENABLE*/#ifndef SYS_INT_DISABLE#define SYS_INT_DISABLE(pDrvCtrl)                                       \    {                                                                   \    IMPORT STATUS sysLanIntDisable();					\    sysLanIntDisable(pDrvCtrl->ilevel);					\    }#endif /*SYS_INT_DISABLE*/#ifndef SYS_DEC21X4X_INIT#define SYS_DEC21X4X_INIT(pDrvCtrl,pResult)                             \    {                                                                   \    IMPORT STATUS sysDec21x4xInit();                                    \    *pResult = sysDec21x4xInit (pDrvCtrl);	                        \    }#endif /* SYS_DEC21X4X_INIT */#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)                                      \    {                                                                   \    M_BLK *pNext;                                                       \                                                                        \    pNext=pMblk;                                                        \    while (pNext)                                                       \        pNext=NET_MBLK_BUF_FREE (pNext);                                \    }    #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	DEC21X4X_DRV_CTRL#ifdef DRV_DEBUGDRV_CTRL	*pDrvCtrlDbg;#endif/* 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 */NET_POOL dec21x4xNetPool; /* forward declarations */LOCAL STATUS	dec21x4xInitParse (DRV_CTRL *pDrvCtrl, char *InitString);LOCAL STATUS	dec21x4xInitMem (DRV_CTRL *pDrvCtrl);LOCAL STATUS	dec21x4xIASetup (DRV_CTRL *pDrvCtrl);LOCAL void 	dec21x4xModeSet (DRV_CTRL *pDrvCtrl);LOCAL int	dec21x4xHashIndex (char *eAddr);LOCAL void 	dec21x4xInt (DRV_CTRL *pDrvCtrl);LOCAL STATUS 	dec21x4xRecv (DRV_CTRL *pDrvCtrl, DEC_RD *rmd);LOCAL STATUS 	dec21x4xChipReset (DRV_CTRL *pDrvCtrl);LOCAL void	dec21040AuiTpInit (DRV_CTRL *pDrvCtrl);LOCAL STATUS 	dec21x4xEnetAddrGet (DRV_CTRL *pDrvCtrl, char *enetAdrs);LOCAL STATUS 	dec21040EnetAddrGet (DRV_CTRL *pDrvCtrl, char *enetAdrs);LOCAL STATUS 	dec2114xEnetAddrGet (DRV_CTRL *pDrvCtrl, char *enetAdrs);LOCAL void	dec21x4xRestart (DRV_CTRL *pDrvCtrl);LOCAL DEC_TD *	dec21x4xTxDGet (DRV_CTRL *pDrvCtrl);LOCAL DEC_RD *	dec21x4xRxDGet (DRV_CTRL *pDrvCtrl);LOCAL void 	dec21x4xTxRingClean (DRV_CTRL *pDrvCtrl);LOCAL void 	dec21x4xRxIntHandle (DRV_CTRL *pDrvCtrl);LOCAL USHORT	dec2114xSromWordRead (DRV_CTRL *pDrvCtrl, UCHAR lineCnt);LOCAL STATUS 	dec21140MediaSelect (DRV_CTRL *pDrvCtrl, UINT *pCsr6Val);LOCAL STATUS 	dec21143MediaSelect (DRV_CTRL *pDrvCtrl, UINT *pCsr6Val);LOCAL void      dec21x4xInitialReset (DRV_CTRL *pDrvCtrl);LOCAL void	dec21x4xCsrWrite (ULONG devAdrs, int reg, ULONG value);LOCAL ULONG	dec21x4xCsrRead (ULONG devAdrs, int reg);/* externals */IMPORT STATUS	sysDec21x4xEnetAddrGet (int unit, char *enetAdrs);/* globals */FUNCPTR _func_dec2114xMediaSelect;VOIDFUNCPTR  _func_dec2114xIntAck;/* END Specific interfaces. */END_OBJ *	dec21x4xEndLoad (char *initString);LOCAL STATUS	dec21x4xUnload (DRV_CTRL *pDrvCtrl);LOCAL STATUS	dec21x4xStart (DRV_CTRL *pDrvCtrl);LOCAL STATUS	dec21x4xStop (DRV_CTRL *pDrvCtrl);LOCAL int	dec21x4xIoctl (DRV_CTRL *pDrvCtrl, int cmd, caddr_t data);LOCAL STATUS	dec21x4xSend (DRV_CTRL *pDrvCtrl, M_BLK *pMblk);LOCAL STATUS	dec21x4xMCastAddrAdd (DRV_CTRL *pDrvCtrl, char* pAddress);LOCAL STATUS	dec21x4xMCastAddrDel (DRV_CTRL *pDrvCtrl, char* pAddress);LOCAL STATUS	dec21x4xMCastAddrGet (DRV_CTRL *pDrvCtrl,                                       MULTI_TABLE *pTable);LOCAL STATUS	dec21x4xPollSend (DRV_CTRL *pDrvCtrl, M_BLK *pMblk);LOCAL STATUS	dec21x4xPollReceive (DRV_CTRL *pDrvCtrl, M_BLK *pMblk);LOCAL STATUS	dec21x4xPollStart (DRV_CTRL *pDrvCtrl);LOCAL STATUS	dec21x4xPollStop (DRV_CTRL *pDrvCtrl);/*  * Define the device function table.  This is static across all driver * instances. */LOCAL NET_FUNCS netFuncs =   {  (FUNCPTR)dec21x4xStart,	/* start func. */                   (FUNCPTR)dec21x4xStop,	/* stop func. */  (FUNCPTR)dec21x4xUnload,	/* unload func. */                  (FUNCPTR)dec21x4xIoctl,	/* ioctl func. */                   (FUNCPTR)dec21x4xSend,	/* send func. */                    (FUNCPTR)dec21x4xMCastAddrAdd,/* multicast add func. */           (FUNCPTR)dec21x4xMCastAddrDel,/* multicast delete func. */        (FUNCPTR)dec21x4xMCastAddrGet,/* multicast get fun. */            (FUNCPTR)dec21x4xPollSend,	/* polling send func. */            (FUNCPTR)dec21x4xPollReceive,	/* polling receive func. */         endEtherAddressForm,		/* put address info into a NET_BUFFER */  endEtherPacketDataGet,	/* get pointer to data in NET_BUFFER */  endEtherPacketAddrGet		/* Get packet addresses. */  };				/********************************************************************************* dec21x4xEndLoad - initialize the driver and device** This routine initializes the driver and the device to the operational state.* All of the device specific parameters are passed in the initString.** This routine can be called in two modes. If it is called with an empty, but* allocated string then it places the name of this device (i.e. dc) into the* initString and returns 0.** If the string is allocated then the routine attempts to perform its load* functionality.** RETURNS: An END object pointer or NULL on error or 0 and the name of the* device if the initString was NULL.*/END_OBJ * dec21x4xEndLoad    (    char *	initStr		/* String to be parse by the driver. */    )    {    DRV_CTRL *	pDrvCtrl;    char	eAdrs[EADDR_LEN];            /* ethernet address */    int		retVal;    char	bucket[sizeof(ULONG)];    DRV_LOG (DRV_DEBUG_LOAD, "Loading dc ...\n", 0, 0, 0, 0, 0, 0);    if (initStr == NULL)        return (NULL);        if (initStr[0] == NULL)        {        memcpy(initStr, (char *) DRV_NAME, DRV_NAME_LEN);        return (0);        }    /* Allocate a control structure for this device */    pDrvCtrl = calloc (sizeof(DRV_CTRL), 1);    if (pDrvCtrl == NULL)        {        LOG_MSG ("%s - Failed to allocate control structure\n",                (int) DRV_NAME, 0, 0, 0, 0, 0);         return (NULL);        }#ifdef DRV_DEBUG    pDrvCtrlDbg = pDrvCtrl;#endif    pDrvCtrl->flags = NULL;    pDrvCtrl->txCleaning = FALSE;    pDrvCtrl->rxHandling = FALSE;    pDrvCtrl->mediaCount = 0xff;    /* Parse InitString */    if (dec21x4xInitParse (pDrvCtrl, initStr) == ERROR)        {        LOG_MSG ("%s - Failed to parse initialization parameters\n",                (int) DRV_NAME, 0, 0, 0, 0, 0);        return (NULL);        }    /* callout to perform adapter init */     SYS_DEC21X4X_INIT (pDrvCtrl, &retVal);    if (retVal == ERROR)        {        LOG_MSG ("%s%d - Failed to perform adapter init \n", 		(int) DRV_NAME, pDrvCtrl->unit, 0, 0, 0, 0);        return (NULL);        }    /* Prevent transmission hanging up later on */    INITIAL_RESET(pDrvCtrl);    /* probe for memory-mapped CSR registers */    if (vxMemProbe ((char *) pDrvCtrl->devAdrs, VX_READ, 		sizeof(ULONG), &bucket[0]) != OK)	{	LOG_MSG ("%s%d - need MMU mapping for address %#x\n",		(int)DRV_NAME, pDrvCtrl->unit, (int)pDrvCtrl->devAdrs, 0, 0, 0);	return (NULL);	}     /* endObject Initializations */    if (END_OBJ_INIT (&pDrvCtrl->endObj, (DEV_OBJ*)pDrvCtrl, DRV_NAME,                      pDrvCtrl->unit, &netFuncs,                      "dec21x4x Enhanced Network Driver") == ERROR)        {        LOG_MSG ("%s%d - Failed to initialize END object\n",                (int) DRV_NAME, pDrvCtrl->unit, 0, 0, 0, 0);        return (NULL);        }    /* memory Initializations */    if (dec21x4xInitMem (pDrvCtrl) == ERROR)        goto error;    /* get Ethernet Address */    if (dec21x4xEnetAddrGet (pDrvCtrl, eAdrs) == ERROR)        {        LOG_MSG ("%s%d - Failed to read ethernet address\n",                (int) DRV_NAME, pDrvCtrl->unit, 0, 0, 0, 0);        goto error;        }    DRV_LOG (DRV_DEBUG_LOAD,             "ENET: %x:%x:%x:%x:%x:%x\n",             eAdrs[0], eAdrs[1], eAdrs[2], eAdrs[3], eAdrs[4], eAdrs[5]);        /* Initialize MIB-II entries */    if (END_MIB_INIT (&pDrvCtrl->endObj, M2_ifType_ethernet_csmacd,                      (UINT8*) eAdrs, EADDR_LEN,                       ETHERMTU, DEC_SPEED_DEF) == ERROR)        {        LOG_MSG ("%s%d - MIB-II initializations failed\n",                (int) DRV_NAME, pDrvCtrl->unit, 0, 0, 0, 0);        goto error;        }    /* Mark the device ready with default flags */    END_OBJ_READY (&pDrvCtrl->endObj,                   IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST);

⌨️ 快捷键说明

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