📄 lan91c111end.c
字号:
address = strtoul (tok, NULL, 16);
pDrvCtrl->IOBase = (UINT)address;
#if DUMP_BANKS
myIOBase = pDrvCtrl->IOBase;
#endif
/* Interrupt vector. */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
pDrvCtrl->ivec = (UINT)strtoul(tok,NULL,16);
/* Interrupt level. */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
pDrvCtrl->ilevel = (UINT)strtoul (tok,NULL,16);
/* Caller supplied alignment offset. */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
pDrvCtrl->offset = (UINT)strtoul (tok,NULL,16);
/* Config string */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
pDrvCtrl->InitConfigVal = (UINT)strtoul (tok, NULL, 16);
pDrvCtrl->userNetAddrOverRide = FALSE;
/* MAC Address[0] */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
goto parse_exit;
address = strtoul (tok, NULL, 16);
if (address != 0) pDrvCtrl->userNetAddrOverRide = TRUE;
pDrvCtrl->userNetAddr.Address[0] = (unsigned char)address;
/* MAC Address[1] */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
address = strtoul (tok, NULL, 16);
if (address != 0) pDrvCtrl->userNetAddrOverRide = TRUE;
pDrvCtrl->userNetAddr.Address[1] = (unsigned char)address;
/* MAC Address[2] */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
address = strtoul (tok, NULL, 16);
if (address != 0) pDrvCtrl->userNetAddrOverRide = TRUE;
pDrvCtrl->userNetAddr.Address[2] = (unsigned char)address;
/* MAC Address[3] */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
address = strtoul (tok, NULL, 16);
if (address != 0) pDrvCtrl->userNetAddrOverRide = TRUE;
pDrvCtrl->userNetAddr.Address[3] = (unsigned char)address;
/* MAC Address[4] */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
address = strtoul (tok, NULL, 16);
if (address != 0) pDrvCtrl->userNetAddrOverRide = TRUE;
pDrvCtrl->userNetAddr.Address[4] = (unsigned char)address;
/* MAC Address[5] */
tok = strtok_r (NULL, ":", &pHolder);
if (tok == NULL)
return ERROR;
address = strtoul (tok, NULL, 16);
if (address != 0) pDrvCtrl->userNetAddrOverRide = TRUE;
pDrvCtrl->userNetAddr.Address[5] = (unsigned char)address;
DRV_LOG(DRV_DEBUG_LOAD, "MAC Addr : %2x:%2x:%2x:%2x:%2x:%2x\n",
pDrvCtrl->userNetAddr.Address[0],
pDrvCtrl->userNetAddr.Address[1],
pDrvCtrl->userNetAddr.Address[2],
pDrvCtrl->userNetAddr.Address[3],
pDrvCtrl->userNetAddr.Address[4],
pDrvCtrl->userNetAddr.Address[5])
parse_exit:
DRV_LOG (DRV_DEBUG_LOAD, "Processed all arugments\n", 1, 2, 3, 4, 5, 6);
return OK;
}
/*******************************************************************************
* lan91c111MemInit - initialize memory for the chip
*
* This routine is highly specific to the device.
*
* RETURNS: OK or ERROR.
*/
STATUS lan91c111MemInit(
LAN91C111END_DEVICE * pDrvCtrl /* device to be initialized */
)
{
DRV_LOG (DRV_DEBUG_LOAD, "lan91c111MemInit: called\n", 1, 2, 3, 4, 5, 6);
pDrvCtrl->numFrames = 128;
/* Allocate space for the NET_POOL */
if ((pDrvCtrl->endObj.pNetPool = malloc (sizeof(NET_POOL))) == NULL)
return (ERROR);
/* Calculate the total memory for all the M-Blks and CL-Blks. */
lan91c111MclBlkConfig.mBlkNum = pDrvCtrl->numFrames*2;
lan91c111ClDescTbl[0].clNum = pDrvCtrl->numFrames;
lan91c111MclBlkConfig.clBlkNum = lan91c111ClDescTbl[0].clNum;
lan91c111MclBlkConfig.memSize = (lan91c111MclBlkConfig.mBlkNum *
(MSIZE + sizeof (long))) +
(lan91c111MclBlkConfig.clBlkNum *
(CL_BLK_SZ + sizeof(long)));
if ((lan91c111MclBlkConfig.memArea = (char *) memalign (sizeof(long),
lan91c111MclBlkConfig.memSize))
== NULL)
return (ERROR);
/* Calculate the memory size of all the clusters. */
lan91c111ClDescTbl[0].memSize = (lan91c111ClDescTbl[0].clNum *
(LAN91C111_BUFSIZE + 8)) + sizeof(int);
/* Allocate the memory for the clusters from cache safe memory. */
lan91c111ClDescTbl[0].memArea =
(char *) cacheDmaMalloc (lan91c111ClDescTbl[0].memSize);
if ((int)lan91c111ClDescTbl[0].memArea == NULL)
{
DRV_LOG (DRV_DEBUG_LOAD, "lan91c111MemInit: system memory unavailable\n",
1, 2, 3, 4, 5, 6);
return (ERROR);
}
/* Initialize the memory pool. */
if (netPoolInit(pDrvCtrl->endObj.pNetPool, &lan91c111MclBlkConfig,
&lan91c111ClDescTbl[0], lan91c111ClDescTblNumEnt,
NULL) == ERROR)
{
DRV_LOG (DRV_DEBUG_LOAD, "lan91c111MemInit: Could not init buffering\n",
1, 2, 3, 4, 5, 6);
return (ERROR);
}
/* Store a reference to the cluster pool */
if ((pDrvCtrl->pClPoolId = netClPoolIdGet (pDrvCtrl->endObj.pNetPool,
sizeof (TX_PKT), FALSE))
== NULL)
return (ERROR);
/*
* If you need clusters to store received packets into then get them
* here ahead of time.
*/
pDrvCtrl->pTxBase = (TX_PKT *)calloc(TX_PACKETS * sizeof(TX_PKT),1);
pDrvCtrl->pTxReadIndex = pDrvCtrl->pTxBase;
pDrvCtrl->pTxWriteIndex = pDrvCtrl->pTxBase;
pDrvCtrl->pRxBase = (RX_PKT *)calloc(RX_PACKETS * sizeof(RX_PKT),1);
pDrvCtrl->pRxReadIndex = pDrvCtrl->pRxBase;
pDrvCtrl->pRxWriteIndex = pDrvCtrl->pRxBase;
pDrvCtrl->sendBuf = (unsigned char *)calloc(2048, 1);
#if PING_DEBUG
debugTxBuf = pDrvCtrl->sendBuf;
#endif
DRV_LOG (DRV_DEBUG_LOAD, "lan91c111MemInit: Memory setup complete\n",
1, 2, 3, 4, 5, 6);
return OK;
}
/*******************************************************************************
* lan91c111Start - start the device
*
* This function calls BSP functions to connect interrupts and start the
* device running in interrupt mode.
*
* RETURNS: OK or ERROR
*
*/
STATUS lan91c111Start(
END_OBJ * pEnd /* device ID */
)
{
LAN91C111END_DEVICE *pDrvCtrl = (LAN91C111END_DEVICE *)pEnd;
SYS_INT_ENABLE (pDrvCtrl);
#if 0
logMsg("lan91c111Start: iLev = %x, iVector = %x\n", pDrvCtrl->ilevel, pDrvCtrl->ivec, 3,4,5,6);
#endif
return (OK);
}
/*******************************************************************************
* lan91c111Int - handle controller interrupt
*
* This routine is called at interrupt level in response to an interrupt from
* the controller.
*
* RETURNS: N/A.
*/
void lan91c111Int(
LAN91C111END_DEVICE * pDrvCtrl /* device to be initialized */
)
{
LAN91C111END_DEVICE *Adapter = pDrvCtrl;
/*-----------------3/15/01 3:07PM-------------------
* Short Cut for Bank Select Values
* --------------------------------------------------*/
UINT IOBase;
UINT IntrPort;
UINT MmuPort;
UINT DataPort;
UINT RxFifoPort;
UINT PtrPort;
/*-----------------3/15/01 3:07PM-------------------
* s for saving Bank Select, Pack Num, Ptr Reg
* --------------------------------------------------*/
USHORT SavedBank;
USHORT SavedPtr;
USHORT SavedPnr;
USHORT tempWord;
UCHAR IntrSts, IntMask;
USHORT FifoPort;
USHORT Count;
/*-----------------3/15/01 3:06PM-------------------
* Used in Rx Interrupt Processing
* --------------------------------------------------*/
USHORT Pointer;
USHORT PacketStatus;
USHORT PacketRange;
int i;
UINT16 len;
char *usr_buf, *ReadBuffer, *pData;
/*-----------------3/15/01 3:06PM-------------------
* Used in Tx Interrupt Processing
* --------------------------------------------------*/
UCHAR PacketNumber;
/*-----------------3/15/01 3:13PM-------------------
* Used in EPH Interrupt Processing
* --------------------------------------------------*/
USHORT EphStatus;
/*-----------------3/15/01 3:11PM-------------------
* Used in MDINT
* --------------------------------------------------*/
USHORT DefaultVal;
/* logMsg(" => ISR ",1,2,3,4,5,6); */
DRV_LOG (DRV_DEBUG_INT, "----------- START ISR -------------\n",
1, 2, 3, 4, 5, 6);
#if 1
/*-----------------3/16/01 4:40PM-------------------
* DisableInterrupt is not called in NT driver code.
* However it is done here because EnableInterrupt is
* called just before exit from this ISR
* --------------------------------------------------*/
/* lan91c111DisableInterrupt(pDrvCtrl);*/
IOBase = Adapter->IOBase;
IntrPort = IOBase + BANK2_INT_STS;
MmuPort = IOBase;
DataPort = IOBase + BANK2_DATA1;
RxFifoPort = IOBase + BANK2_RX_FIFO;
PtrPort = IOBase + BANK2_PTR;
/* read original Bank Select so it can be restored later */
SYS_IN_SHORT (IOBase + BANK_SELECT, (USHORT *) &SavedBank);
SYS_OUT_SHORT(IOBase + BANK_SELECT, (USHORT) 2);
/* read original Pointer register so it can be restored later */
SYS_IN_SHORT (IOBase + BANK2_PTR, (USHORT *) &SavedPtr);
SYS_IN_SHORT (IOBase + BANK2_PNR, (USHORT *) &SavedPnr);
while(1)
{
SYS_IN_SHORT( IntrPort, &tempWord);
IntrSts = LOBYTE(tempWord);
IntMask = HIBYTE(tempWord);
IntrSts &=IntMask;
if(!IntrSts)
{
DRV_LOG (DRV_DEBUG_INT, "lan91c111Int: Got weird status %x\n",IntrSts, 2, 3, 4, 5, 6);
tempWord = tempWord & ( 0xff00 | ~IntMask);
SYS_OUT_SHORT(IntrPort, tempWord);
goto lan91c111IntExit;
}
/* Check to see if there is something to recieve */
DRV_LOG (DRV_DEBUG_INT, "lan91c111Int: IntrSts = %x\n",IntrSts, 2, 3, 4, 5, 6);
if(IntrSts & INT_EARLY_RX)
{
sysOutByte(IOBase + BANK2_INT_STS, INT_EARLY_RX);lan91c111Delay();
DRV_LOG (DRV_DEBUG_INT, "lan91c111Int: Early Receive",1, 2, 3, 4, 5, 6);
}
else if(IntrSts & INT_RX_CMP)/* start : RX_INT */
{
DRV_LOG (DRV_DEBUG_INT, " RX \n",1, 2, 3, 4, 5, 6);
SYS_IN_SHORT(IOBase + BANK2_FIFOS, &FifoPort);
while(!(FifoPort & FIFO_RX_EMPTY))
{
SYS_OUT_SHORT(PtrPort, (USHORT) (PTR_RCV | PTR_AUTO | PTR_READ));
Count = PTR_WAIT;
while(Count--)
SYS_IN_SHORT(PtrPort, (PUSHORT) &Pointer);
SYS_IN_SHORT(DataPort, (USHORT *) &PacketStatus);
SYS_IN_SHORT(DataPort, (USHORT *) &PacketRange);
DRV_LOG(DRV_DEBUG_RX," RX_DIR packetRange = %d\n",PacketRange,2,3,4,5,6);
if(PacketStatus & RFS_LONG)
{
if((PacketRange - FRAME_OVERHEAD) <= MAX_FRAME_SIZE)
{
PacketStatus &= ~RFS_LONG;
}
else
{
DRV_LOG (DRV_DEBUG_ERR, "\nlan91c111Int: invalid length received\n",1, 2, 3, 4, 5, 6);
END_ERR_ADD (&pDrvCtrl->endObj, MIB2_IN_ERRS, +1);
SYS_IN_SHORT(IOBase + BANK2_FIFOS, &FifoPort);
continue;
}
}
if(PacketStatus & RFS_ERROR)
{
if(PacketStatus & RFS_ALIGN)
;
if(PacketStatus & RFS_CRC)
;
SYS_OUT_SHORT(MmuPort, (USHORT) CMD_REM_REL_TOP);
do
{
SYS_IN_SHORT(MmuPort, (PUSHORT) &tempWord);
} while (tempWord & MMUCMD_BUSY);
DRV_LOG (DRV_DEBUG_ERR, "\nlan91c111Int: Alignment Err or CRC Err received\n",
1, 2, 3, 4, 5, 6);
END_ERR_ADD (&pDrvCtrl->endObj, MIB2_IN_ERRS, +1);
SYS_IN_SHORT(IOBase + BANK2_FIFOS, &FifoPort);
continue;
}
PacketRange -= FRAME_OVERHEAD;
/* => Pramod, Odd Byte, RevB */
if ((9 == Adapter->ChipID) && (1 == Adapter->ChipRev))
{
if (PacketStatus & RFS_ODD)
PacketRange++;
}
else
PacketRange++; /* for 91C111 Rev A bug for not identifying the ODD packets. */
/* <= Pramod, Odd Byte, RevB */
len = PacketRange;
if((pData = (UCHAR *) netClusterGet (pDrvCtrl->endObj.pNetPool,pDrvCtrl->pClPoolId)) == NULL)
{
DRV_LOG (DRV_DEBUG_ERR, "\nlan91c111Int: Could not obtain cluster\n",1, 2, 3, 4, 5, 6);
END_ERR_ADD (&pDrvCtrl->endObj, MIB2_IN_ERRS, +1);
SYS_OUT_SHORT(MmuPort, (USHORT) CMD_REM_REL_TOP);
do
{
SYS_IN_SHORT(MmuPort, (PUSHORT) &tempWord);
} while (tempWord & MMUCMD_BUSY);
/* goto lan91c111RxDone;*/
break;
}
usr_buf = ReadBuffer = pData + pDrvCtrl->offset;
for(i = 0; i < ((PacketRange + 3) >> 2); i++)
SYS_IN_LONG(DataPort, (ULONG *)( usr_buf + i*4));
#if 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -