📄 lan91c111end.c
字号:
#ifndef SYS_OUT_LONG
#undef SYS_OUT_LONG
#endif
#define SYS_OUT_LONG(addr, value) sysOutLong(addr, value);lan91c111Delay()
#ifdef SYS_IN_BYTE
#undef SYS_IN_BYTE
#endif /*SYS_IN_BYTE*/
#define SYS_IN_BYTE(port,value_addr) (*value_addr = sysInByte(port));lan91c111Delay()
#ifndef SYS_IN_SHORT
#undef SYS_IN_SHORT
#endif /*SYS_IN_SHORT*/
#define SYS_IN_SHORT(port, value_addr) (*value_addr = sysInWord(port))
#ifndef SYS_IN_LONG
#undef SYS_IN_LONG
#endif
#define SYS_IN_LONG(port, value_addr) (*value_addr = sysInLong(port))
#ifndef SYS_ENET_ADDR_GET
#define SYS_ENET_ADDR_GET(pAddress) \
{ \
IMPORT unsigned char lnEnetAddr[]; \
bcopy ((char *)lnEnetAddr, (char *)(pAddress), 6); \
}
#endif /* SYS_ENET_ADDR_GET */
/* 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)
#define END_FLAGS_ISSET(pEnd, setBits) \
((pEnd)->flags & (setBits))
#define PING_DEBUG 0
#if PING_DEBUG
UINT RxBuff[25],TxBuff[25];
char* debugTxBuf;
#endif
/******************************************************/
#define POOL_FRAME_NUMS 100
/******************************************************/
/* typedefs */
/* The definition of the driver control structure */
typedef struct lan_device
{
END_OBJ endObj; /* The class we inherit from. */
int unit; /* unit number */
int ivec; /* interrupt vector */
int ilevel; /* interrupt level */
char* memBase; /* LANCE memory pool base */
char* memAdrs; /* LANCE memory pool base */
int memSize; /* LANCE memory pool size */
int memWidth; /* width of data port */
int offset;
long flags; /* Our local flags. */
UCHAR enetAddr[6]; /* ethernet address */
CACHE_FUNCS cacheFuncs; /* cache function pointers */
CL_POOL_ID pClPoolId;
END_ERR lastError; /* Last error passed to muxError */
BOOL errorHandling; /* task level error handling */
u_short errorStat; /* error status */
UINT InitConfigVal;
BOOL AllocPending;
UCHAR *sendBuf;
USHORT sendDatalen;
NETWORK_ADDRESS userNetAddr;
BOOLEAN userNetAddrOverRide;
int numFrames; /* Number of frames to allocate */
BOOL rxHandling;
RX_PKT *pRxBase; /* Rx ring buffer base */
RX_PKT *pRxReadIndex;
RX_PKT *pRxWriteIndex;
BOOL txHandling; /* tx task scheduled */
TX_PKT *pTxBase; /* Tx ring buffer base */
TX_PKT *pTxReadIndex;
TX_PKT *pTxWriteIndex;
BOOLEAN Sqet; /* Enable/disable SQET monitoring */
BOOLEAN Speed100; /* 100mb set (Smc91c100) */
USHORT Rcr; /* Updated Receive Control Register. */
USHORT EphStatus; /* Last status read. */
USHORT LinkStatusChange;
UINT TempPhyAddr; /* Store PHY addr 07/26/00 pg */
UINT PhyType; /* Strore PHY type 10/23/00 PG */
UINT IOBase; /* Base port */
USHORT ConfigReg; /* Config register to be output */
NETWORK_ADDRESS HardwareAddress; /* ROM Station address */
NETWORK_ADDRESS CurrentAddress; /* Current Station address */
UCHAR HashTable[8]; /* Multicast hash bits */
/*
* Add feature function variable here.
* By Shawn X.D. Meng March 24, 1997.
*/
BOOLEAN EarlyTransmit;
BOOLEAN EarlyTxStart;
BOOLEAN ETEN;
USHORT EarlyTxThreshold;
USHORT ETxThrshInc;
USHORT ETxThrshBase;
BOOLEAN EarlyReceive;
USHORT EarlyRxThreshold;
UCHAR Duplex;
BOOLEAN Auto_Negotiation;
BOOLEAN TxUnderRunFixed;
MULTICAST_TABLE MulticastTable;
USHORT LinkChange;
/*
* Added the Chip Rev Field, RevB of LAN91C111 ... ODD BYTE ISSUE
*
*/
USHORT ChipRev; /* Stores the Chip Revision number*/
USHORT ChipID; /* Stores the Chip ID */
} LAN91C111END_DEVICE;
UINT CurrentPhyAddr;
/*
* This will only work if there is only a single unit, for multiple
* unit device drivers these should be integrated into the END_DEVICE
* structure.
*/
M_CL_CONFIG lan91c111MclBlkConfig = /* network mbuf configuration table */
{
/*
no. mBlks no. clBlks memArea memSize
----------- ---------- ------- -------
*/
256, 128, NULL, 0
};
CL_DESC lan91c111ClDescTbl [] = /* network cluster pool configuration table */
{
/*
clusterSize num memArea memSize
----------- ---- ------- -------
*/
{LAN91C111_BUFSIZE, 0, NULL, 0}
};
int lan91c111ClDescTblNumEnt = (NELEMENTS(lan91c111ClDescTbl));
NET_POOL lan91c111CmpNetPool;
#define DUMP_BANKS 1
#if DUMP_BANKS
UINT myIOBase;
#endif
#define LAN91C111_MIN_FBUF (1536) /* min first buffer size */
/* DEBUG MACROS */
#undef DEBUG
#define DEBUG
#ifdef DEBUG
#define LOGMSG(x,a,b,c,d,e,f) \
if (lan91c111Debug) \
{ \
logMsg (x,a,b,c,d,e,f); \
}
#else
#define LOGMSG(x,a,b,c,d,e,f)
#endif /* ENDDEBUG */
#ifndef DRV_DEBUG
#define DRV_DEBUG
#endif
#ifdef DRV_DEBUG
#define DRV_DEBUG_OFF 0x0000
#define DRV_DEBUG_RX 0x0001
#define DRV_DEBUG_TX 0x0002
#define DRV_DEBUG_INT 0x0004
#define DRV_DEBUG_POLL (DRV_DEBUG_POLL_RX | DRV_DEBUG_POLL_TX)
#define DRV_DEBUG_POLL_RX 0x0008
#define DRV_DEBUG_POLL_TX 0x0010
#define DRV_DEBUG_LOAD 0x0020
#define DRV_DEBUG_IOCTL 0x0040
#define DRV_DEBUG_DEV 0x0080
#define DRV_DEBUG_ERR 0x0100
#define DRV_DEBUG_POLL_REDIR 0x10000
#define DRV_DEBUG_LOG_NVRAM 0x20000
#define DRV_DEBUG_STOP 0x40000
int lan91c111Debug=0x0;/* = DRV_DEBUG_LOAD|DRV_DEBUG_INT|DRV_DEBUG_TX|DRV_DEBUG_RX|DRV_DEBUG_ERR;*/
int lan91c111TxInts = 0;
#define DRV_LOG(FLG, X0, X1, X2, X3, X4, X5, X6) \
if (lan91c111Debug & FLG) \
logMsg(X0, X1, X2, X3, X4, X5, X6);
#define DRV_PRINT(FLG,X) \
if (lan91c111Debug & FLG) printf X;
#else /*DRV_DEBUG*/
#define DRV_LOG(DBG_SW, X0, X1, X2, X3, X4, X5, X6)
#define DRV_PRINT(DBG_SW,X)
#endif /*DRV_DEBUG*/
/* User defined Duplex Values - Used to manipulate init string */
#define CONFIG_DUP_DEFAULT 0
#define CONFIG_DUP_AUTO_NEG 1
#define CONFIG_DUP_FULL 2
#define CONFIG_DUP_HALF 3
/* User defined Speed Values - Used to manipulate init string */
#define CONFIG_SPEED_DEFAULT 0
#define CONFIG_SPEED_100 1
#define CONFIG_SPEED_10 2
#define CONFIG_SPEED_AUTO_NEG 3
/* User defined Transceiver Values - Used to manipulate init string */
#define CONFIG_TRANS_AUTO 0
#define CONFIG_TRANS_100 1
#define CONFIG_TRANS_10 2
#define CONFIG_TRANS_AUI 3
#define CONFIG_TRANS_BNC 4
static char _lan91c111End_c_date_code_[] = "082304";
void myDummyISR();
/* Function Prototypes */
/* Initialization, Send, Recv and Interrupt related */
LOCAL void lan91c111EnableInterrupt(LAN91C111END_DEVICE *pDrvCtrl);
END_OBJ* lan91c111Load( char* initString );
STATUS lan91c111InitParse ( LAN91C111END_DEVICE * pDrvCtrl, char * initString );
STATUS lan91c111MemInit ( LAN91C111END_DEVICE * pDrvCtrl );
STATUS lan91c111Start ( END_OBJ * pEnd );
LOCAL STATUS lan91c111Recv ( LAN91C111END_DEVICE *pDrvCtrl/*, char *, UINT */);
STATUS lan91c111Send(END_OBJ *pEnd,M_BLK_ID pMblk);
LOCAL void lan91c111HandleRcvInt ( LAN91C111END_DEVICE *pDrvCtrl );
#undef LOCAL
#define LOCAL
void lan91c111Int ( LAN91C111END_DEVICE * pDrvCtrl );
void lnc911intsts();
void lnc911LedSet(UCHAR val);
void lnc911reg();
void lnc911regSet(USHORT BANK, USHORT REG,USHORT val);
void lnc911memShow();
int ftpIsEnd(UINT *mbuf);
/* IOCTL, Multicast and Poll related */
LOCAL void lan91c111HandleError(LAN91C111END_DEVICE *pDrvCtrl, USHORT EphStatus);
LOCAL int lan91c111Ioctl ( END_OBJ * pEnd, int cmd, caddr_t data );
LOCAL STATUS lan91c111MCastAddrAdd ( END_OBJ *pEnd, char* pAddress );
LOCAL STATUS lan91c111MCastAddrDel ( END_OBJ *pEnd, char* pAddress );
LOCAL STATUS lan91c111MCastAddrGet ( END_OBJ *pEnd, MULTI_TABLE* pTable );
LOCAL void lan91c111Config ( LAN91C111END_DEVICE *pDrvCtrl );
LOCAL STATUS lan91c111PollStop ( LAN91C111END_DEVICE * pDrvCtrl );
LOCAL STATUS lan91c111PollStart ( LAN91C111END_DEVICE * pDrvCtrl );
/*LOCAL STATUS lan91c111PollRcv ( END_OBJ * pEnd, M_BLK_ID pMblk );
LOCAL STATUS lan91c111PollSend ( END_OBJ* pEnd, M_BLK_ID pMblk );
*/
/* Stop, Interrupt related */
LOCAL STATUS lan91c111Stop ( END_OBJ *pEnd );
LOCAL STATUS lan91c111Unload ( END_OBJ* pEnd );
LOCAL void lan91c111DisableInterrupt(LAN91C111END_DEVICE *pDrvCtrl);
/* Device Specific reset and programming APIs */
LOCAL STATUS ConfigureAdapter(LAN91C111END_DEVICE *Adapter);
LOCAL STATUS ConfigureIsa(LAN91C111END_DEVICE *Adapter) ;
LOCAL void MiniPortAutoNegotiation(LAN91C111END_DEVICE *Adapter);
LOCAL BOOLEAN AdapterVerify(LAN91C111END_DEVICE *Adapter);
LOCAL UINT DetectPHY(LAN91C111END_DEVICE *Adapter ,UINT IOBase);
LOCAL BOOLEAN DoRAMTest(LAN91C111END_DEVICE *Adapter);
LOCAL BOOLEAN AdapterReset(LAN91C111END_DEVICE *Adapter);
/*LOCAL void InitializeData(LAN91C111END_DEVICE *Adapter);*/
LOCAL BOOLEAN DoAllocate(LAN91C111END_DEVICE *pDrvCtrl);
LOCAL void lan91c111WriteToChip(LAN91C111END_DEVICE *pDrvCtrl);
LOCAL void EarlyTransmit(LAN91C111END_DEVICE *pDrvCtrl);
/* Device Specific - PHY programming */
LOCAL BOOLEAN ProgramPHY( LAN91C111END_DEVICE *Adapter );
LOCAL BOOLEAN ProgramNationalPHY( LAN91C111END_DEVICE *Adapter );
UINT ReadPhyRegister( UINT IOBase, UCHAR phyaddr, UCHAR phyreg);
VOID WritePhyRegister( UINT IOBase, UCHAR phyaddr, UCHAR phyreg, ULONG phyregdat );
LOCAL USHORT InputMDO( UINT IOAddress );
LOCAL VOID OutputMDO( UINT IOAddress, UCHAR lev );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -