📄 iolicomend.c
字号:
/* iOlicomEnd.c - END style Intel Olicom PCMCIA network interface driver *//* Copyright 1997-2002 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01r,15jan03,m_h unsupported for IPv601q,14jan02,dat Removing warnings from Diab compiler01p,20sep01,dat Removing ANSI errors, for diab compiler01o,28aug00,stv corrected the handling of EIOCSFLAGS ioctl (SPR# 29423).01n,11jun00,ham removed reference to etherLib.01m,16nov99,jpd fixed warnings caused by new definition of NULL.01l,01dec99,stv freed mBlk chain before returning ERROR (SPR #28492).01k,11nov99,cn removed unnecessary freeing of pDrvCtrl in iOlicomUnload (SPR# 28772).01j,16nov98,jpd claim buffers using malloc() not cacheDmaMalloc(). Fix bug parsing CIS. Improved efficiency. Tidied. Fix problem after (hard) PID7T reset.01i,29mar99,dat SPR 26119, documentation, usage of .bS/.bE01h,30sep98,dbt Adding missing code in poll receive routine.01g,22sep98,dat SPR 22325, System mode transition.01f,14may98,jgn disable RX stop interrupts, tidy comments (SPR #21202)01e,13may98,jgn fixed driver lock up on PID (SPR #21202)01d,11may98,jpd fixed incorrect parameters in strtok_r calls (SPR #21192).01c,09apr98,jpd made conditionally-compilable version for Brutus or PID. fixed fault in iOlicomRxIntHandle().01b,24mar98,jpd modified to work on Brutus, but not yet on both Brutus and PID.01a,16dec97,rlp modified if_oli.c to END style*//*This module implements the Olicom (Intel 82595TX) network interfacedriver. The physical device is a PCMCIA card. This driver also housescode to manage a Vadem PCMCIA Interface controller on the ARM PIDboard, which is strictly a subsystem in it's own right.This network interface driver does not include support for trailer protocolsor data chaining. However, buffer loaning has been implemented in an effort toboost performance.BOARD LAYOUTThe device resides on a PCMCIA card and is soft configured.No jumpering diagram is necessary.EXTERNAL INTERFACEThis driver provides the END external interface with the followingexceptions. The only external interface is the iOlicomEndLoad() routine.All of the paramters are passed as strings in a colon (:) separated listto the load function as an initString. The iOlicomEndLoad() function usesstrtok() to parse the string.The string contains the target specific parameters like this: "<io_baseA>:<attr_baseA>:<mem_baseA>:<io_baseB>:<attr_baseB>:<mem_baseB>: \ <ctrl_base>:<intVectA>:<intLevelA>:<intVectB>:<intLevelB>: \ <txBdNum>:<rxBdNum>:<pShMem>:<shMemSize>"TARGET-SPECIFIC PARAMETERS.iP "I/O base address A"This is the first parameter passed to the driver init string. Thisparameter indicates the base address of the PCMCIA I/O space for socketA..iP "Attribute base address A"This is the second parameter passed to the driver init string. Thisparameter indicates the base address of the PCMCIA attribute space forsocket A. On the PID board, this should be the offset of the beginningof the attribute space from the beginning of the memory space..iP "Memory base address A"This is the third parameter passed to the driver init string. Thisparameter indicates the base address of the PCMCIA memory space forsocket A..iP "I/O base address B"This is the fourth parameter passed to the driver init string. Thisparameter indicates the base address of the PCMCIA I/O space for socketB..iP "Attribute base address B"This is the fifth parameter passed to the driver init string. Thisparameter indicates the base address of the PCMCIA attribute space forsocket B. On the PID board, this should be the offset of the beginningof the attribute space from the beginning of the memory space..iP "Memory base address B"This is the sixth parameter passed to the driver init string. Thisparameter indicates the base address of the PCMCIA memory space forsocket B..iP "PCMCIA controller base address"This is the seventh parameter passed to the driver init string. Thisparameter indicates the base address of the Vadem PCMCIA controller..iP "interrupt vectors and levels"These are the eighth, ninth, tenth and eleventh parameters passed to thedriver init string.The mapping of IRQs generated at the Card/PCMCIA level to interruptlevels and vectors is system dependent. Furthermore the slot holdingthe PCMCIA card is not initially known. The interrupt levels andvectors for both socket A and socket B must be passed toiOlicomEndLoad(), allowing the driver to select the required parameterslater..iP "number of transmit and receive buffer descriptors"These are the twelfth and thirteenth parameters passed to the driverinit string.The number of transmit and receive buffer descriptors (BDs) used isconfigurable by the user upon attaching the driver. There must be aminimum of two transmit and two receive BDs, and there is a maximum oftwenty transmit and twenty receive BDs. If this parameter is "NULL" adefault value of 16 BDs will be used..iP "offset"This is the fourteenth parameter passed to the driver in the init string.This parameter defines the offset which is used to solve alignment problem..iP "base address of buffer pool"This is the fifteenth parameter passed to the driver in the init string.This parameter is used to notify the driver that space for the transmitand receive buffers need not be allocated, but should be taken from aprivate memory space provided by the user at the given address. Theuser should be aware that memory used for buffers must be 4-bytealigned but need not be non-cacheable. If this parameter is "NONE",space for buffers will be obtained by calling malloc() iniOlicomEndLoad()..iP "mem size of buffer pool"This is the sixteenth parameter passed to the driver in the init string.The memory size parameter specifies the size of the pre-allocated memoryregion. If memory base is specified as NONE (-1), the driver ignores thisparameter..iP "Ethernet address"This parameter is obtained from the Card Information Structure on theOlicom PCMCIA card..LPEXTERNAL SUPPORT REQUIREMENTSThis driver requires three external support function:.iP "void sysLanIntEnable (int level)" "" 9 -1This routine provides a target-specific interface for enabling Ethernetdevice interrupts at a specified interrupt level. This routine iscalled each time that the iOlicomStart() routine is called..iP "void sysLanIntDisable (int level)" "" 9 -1This routine provides a target-specific interface for disablingEthernet device interrupts. The driver calls this routine from theiOlicomStop() routine each time a unit is disabled..iP "void sysBusIntAck(void)" "" 9 -1This routine acknowledge the interrupt if it's necessary..LPSEE ALSO: muxLib, endLib.I "Intel 82595TX ISA/PCMCIA High Integration Ethernet Controller User Manual,".I "Vadem VG-468 PC Card Socket Controller Data Manual."*//* includes */#include "vxWorks.h"#include "iv.h"#include "taskLib.h"#include "lstLib.h"#include "memLib.h"#include "errno.h"#include "errnoLib.h"#include "intLib.h"#include "cacheLib.h"#include "netLib.h"#include "stdio.h"#include "stdlib.h"#include "logLib.h"#include "sysLib.h"#include "net/systm.h"#include "net/if_subr.h"#include "netinet/if_ether.h"#ifdef WR_IPV6#include "adv_net.h"#endif /*WR_IPV6*/#include "drv/end/iOlicomEnd.h" /* Common defines. */#include "etherMultiLib.h" /* multicast stuff. */#include "end.h" /* Common END structures. */#include "endLib.h"/* defines */#define RX_BD_SIZ sizeof(RX_BD)#define TX_BD_SIZ sizeof(TX_BD)#define LOG_MSG(X0, X1, X2, X3, X4, X5, X6) \ { \ if (_func_logMsg != NULL) \ _func_logMsg(X0, X1, X2, X3, X4, X5, X6); \ }#undef DEBUG#ifdef DEBUG#define LOCAL#define END_DEBUG_OFF 0x0000#define END_DEBUG_RX 0x0001#define END_DEBUG_TX 0x0002#define END_DEBUG_INT 0x0004#define END_DEBUG_POLL (END_DEBUG_POLL_RX | END_DEBUG_POLL_TX)#define END_DEBUG_POLL_RX 0x0008#define END_DEBUG_POLL_TX 0x0010#define END_DEBUG_LOAD 0x0020#define END_DEBUG_IOCTL 0x0040#define END_DEBUG_ADDR 0x0080#define END_DEBUG_ALL_FUNCS 0x0100#define END_DEBUG_LOAD_FAIL 0x0200#define END_DEBUG_POLL_REDIR 0x10000#define END_DEBUG_LOG_NVRAM 0x20000#define END_DEBUG_TUPLES 0x40000int oliDebug = END_DEBUG_LOAD_FAIL;#define END_LOG_MSG(FLG, X0, X1, X2, X3, X4, X5, X6) \ if (oliDebug & FLG) \ LOG_MSG(X0, X1, X2, X3, X4, X5, X6);#else /* DEBUG */#define END_LOG_MSG(DBG_SW, X0, X1, X2, X3, X4, X5, X6)#endif /* DEBUG *//* * 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) \ { \ 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; /* HELP: need a real routine */ \ }#endif /*SYS_INT_DISCONNECT*/#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_BUS_INT_ACK#define SYS_BUS_INT_ACK(pDrvCtrl) \ { \ IMPORT int sysBusIntAck(); \ sysBusIntAck (pDrvCtrl->ilevel); \ }#endif /*SYS_BUS_INT_ACK*//* A shortcut for getting the hardware address from the MIB II stuff. */#define END_HADDR(pEnd) \ ((pEnd)->mib2Tbl.ifPhysAddress.phyAddress)#define END_HADDR_LEN(pEnd) \ ((pEnd)->mib2Tbl.ifPhysAddress.addrLength)#ifndef PCMCIA_NO_VADEM/* Vadem access macros */#ifndef OLI_VADEM_READ#define OLI_VADEM_READ(index) \ iOlicomVademRead(pDrvCtrl->pcmcia.ctrlBase, index)#endif /* OLI_VADEM_READ */#ifndef OLI_VADEM_WRITE#define OLI_VADEM_WRITE(index,val) \ iOlicomVademWrite(pDrvCtrl->pcmcia.ctrlBase, index, val)#endif /* OLI_VADEM_WRITE */#ifndef OLI_VADEM_UNLOCK#define OLI_VADEM_UNLOCK() \ iOlicomVademUnlock(pDrvCtrl->pcmcia.ctrlBase)#endif /* OLI_VADEM_UNLOCK */#endif /* !PCMCIA_NO_VADEM *//* END_DEVICE flags access macros */#define DRV_FLAGS_SET(setBits) \ (pDrvCtrl->flags |= (setBits))#define DRV_FLAGS_ISSET(setBits) \ (pDrvCtrl->flags & (setBits))#define DRV_FLAGS_CLR(clrBits) \ (pDrvCtrl->flags &= ~(clrBits))#define DRV_FLAGS_GET() \ (pDrvCtrl->flags)#define NET_BUF_ALLOC() \ netClusterGet (pDrvCtrl->endObj.pNetPool, pDrvCtrl->clPoolId)#define NET_BUF_FREE(pBuf) \ netClFree (pDrvCtrl->endObj.pNetPool, (UINT8 *)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)/* globals */#ifdef DEBUG END_DEVICE * pDbgDrvCtrl;#endif/* local *//* forward static functions */LOCAL void iOlicomReset (END_DEVICE * pDrvCtrl);LOCAL void iOlicomInt (END_DEVICE * pDrvCtrl);LOCAL void iOlicomRxIntHandle (END_DEVICE * pDrvCtrl);LOCAL STATUS iOlicomRecv (END_DEVICE * pDrvCtrl, RX_BD * pData);LOCAL void iOlicomConfig (END_DEVICE * pDrvCtrl);LOCAL STATUS iOlicomAddrFilterSet (END_DEVICE * pDrvCtrl);LOCAL STATUS iOlicomInit (END_DEVICE * pDrvCtrl);LOCAL void iOlicomTxBdQueueClean (END_DEVICE * pDrvCtrl);LOCAL void iOlicomTxStart (END_DEVICE * pDrvCtrl);LOCAL void iOlicomTxRestart (END_DEVICE * pDrvCtrl);LOCAL RX_BD * iOlicomPacketGet (END_DEVICE * pDrvCtrl);LOCAL TX_BD * iOlicomTxBdGet (END_DEVICE * pDrvCtrl);LOCAL STATUS iOlicomPcmciaSetup (END_DEVICE * pDrvCtrl);LOCAL void iOlicomInitialiseSlot (END_DEVICE * pDrvCtrl, UINT socket);LOCAL void iOlicomShutdownSlot (END_DEVICE * pDrvCtrl, UINT socket);LOCAL UINT iOlicomPcmciaReadTuple (END_DEVICE * pDrvCtrl, UINT offset, UCHAR * buffer, UINT buflen);LOCAL UCHAR * iOlicomPcmciaFindTuple (END_DEVICE * pDrvCtrl, UINT tuple, UINT * offset, UCHAR * buffer, UINT buflen);LOCAL STATUS iOlicomReadCardAttributes (END_DEVICE * pDrvCtrl);LOCAL STATUS iOlicomCardInsertion (END_DEVICE * pDrvCtrl, UINT socket);LOCAL STATUS iOlicomInitialiseCard (END_DEVICE * pDrvCtrl);LOCAL STATUS iOlicomMapIOSpace (END_DEVICE * pDrvCtrl, UINT base, UINT range, int mapirq);#ifndef PCMCIA_NO_VADEMLOCAL void iOlicomMapMemory (END_DEVICE * pDrvCtrl, UINT socket, UINT window, UINT base, UINT range, UINT offset, MEMTYPE type);LOCAL UINT iOlicomVademRead (char * ctrlBase, UINT index);LOCAL void iOlicomVademWrite (char * ctrlBase, UINT index, UINT value);LOCAL void iOlicomVademUnlock (char * ctrlBase);#endif /* !PCMCIA_NO_VADEM *//* END Specific interfaces. *//* These are the only externally visible interfaces. */END_OBJ * iOlicomEndLoad (char * initString);void iOlicomIntHandle (END_DEVICE * pDrvCtrl);LOCAL STATUS iOlicomStart (END_DEVICE * pDrvCtrl);LOCAL STATUS iOlicomStop (END_DEVICE * pDrvCtrl);LOCAL STATUS iOlicomUnload ();LOCAL int iOlicomIoctl (END_DEVICE * pDrvCtrl, int cmd, char * data);LOCAL STATUS iOlicomSend (END_DEVICE * pDrvCtrl, M_BLK * pMblk);LOCAL STATUS iOlicomMCastAddrAdd (END_DEVICE * pDrvCtrl, char * pAddress);LOCAL STATUS iOlicomMCastAddrDel (END_DEVICE * pDrvCtrl, char * pAddress);LOCAL STATUS iOlicomMCastAddrGet (END_DEVICE * pDrvCtrl, MULTI_TABLE * pTable);LOCAL STATUS iOlicomPollSend (END_DEVICE * pDrvCtrl, M_BLK * pMblk);LOCAL STATUS iOlicomPollReceive (END_DEVICE * pDrvCtrl, M_BLK * pMblk);LOCAL STATUS iOlicomPollStart (END_DEVICE * pDrvCtrl);LOCAL STATUS iOlicomPollStop (END_DEVICE * pDrvCtrl);LOCAL STATUS iOlicomInitParse ();LOCAL STATUS iOlicomInitMem ();/* * Declare our function table. This is static across all driver * instances. */LOCAL NET_FUNCS iOlicomFuncTable = { (FUNCPTR) iOlicomStart, /* Function to start the device. */ (FUNCPTR) iOlicomStop, /* Function to stop the device. */ (FUNCPTR) iOlicomUnload, /* Unloading function for the driver. */ (FUNCPTR) iOlicomIoctl, /* Ioctl function for the driver. */ (FUNCPTR) iOlicomSend, /* Send function for the driver. */ (FUNCPTR) iOlicomMCastAddrAdd, /* Multicast address add fn for driver */ (FUNCPTR) iOlicomMCastAddrDel, /* Multicast address delete fn for driver. */ (FUNCPTR) iOlicomMCastAddrGet, /* Multicast table retrieve fn for driver. */ (FUNCPTR) iOlicomPollSend, /* Polling send function for driver. */ (FUNCPTR) iOlicomPollReceive, /* Polling receive function for driver. */ endEtherAddressForm,/* put address info into a NET_BUFFER */ endEtherPacketDataGet, /* get pointer to data in NET_BUFFER */ endEtherPacketAddrGet /* Get packet addresses. */ };/********************************************************************************* iOlicomEndLoad - initialize the driver and device** This routine initializes the driver and the device to the operational state.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -