📄 cs8950.c
字号:
);
}
//DumpRegisters();
//__emit(0xEEEEEEEE);
/* Enqueue the transmit descriptors to the chip */
WriteDWord(OpReg_TxDEQ, DescCount );
return;
}
//#define INTR_TYPE_RX 0x0001 // EDBG lib only cares about RX intrs, others handled internally
/***************************************************************************
*
* DumpRegisters():
*
***************************************************************************/
static void DumpRegisters(void)
{
volatile DWORD b32, b32b, *pb32;
volatile WORD b16;
volatile BYTE b8;
int i;
b32=ReadDWord( OpReg_RxCTL);
EdbgOutputDebugString("RxCTL (0x0000): 0x%x \r\n", b32);
b8=ReadByte( OpReg_TxCTL);
EdbgOutputDebugString("TxCTL (0x0004): 0x%x \r\n", b8);
b8=ReadByte( OpReg_TestCTL);
EdbgOutputDebugString("TestCTL (0x0008): 0x%x \r\n", b8);
b16=ReadWord( OpReg_MIICmd);
EdbgOutputDebugString("MIICmd (0x0010): 0x%x \r\n", b16);
b16=ReadWord( OpReg_MIIData);
EdbgOutputDebugString("MIIData (0x0014): 0x%x \r\n", b16);
b8=ReadByte( OpReg_MIISts);
EdbgOutputDebugString("MIISts (0x0018): 0x%x \r\n\r\n", b8);
b8=ReadByte( OpReg_SelfCTL);
EdbgOutputDebugString("SelfCTL (0x0020): 0x%x \r\n", b8);
b32=ReadDWord( OpReg_IntEn);
EdbgOutputDebugString("IntEn (0x0024): 0x%x \r\n", b32);
b32=ReadDWord( OpReg_IntStsP);
EdbgOutputDebugString("IntStsPreserve (0x0028): 0x%x \r\n", b32);
b32=ReadDWord( OpReg_IntStsC);
EdbgOutputDebugString("IntStsClear (0x002C): 0x%x \r\n\r\n", b32);
b32=ReadDWord( OpReg_GT);
EdbgOutputDebugString("GeneralTimer (0x0040): 0x%x \r\n\r\n", b32);
b32=ReadDWord( OpReg_FCT);
EdbgOutputDebugString("FlowCtlTimer (0x0044): 0x%x \r\n", b32);
b32=ReadDWord( OpReg_FCF);
EdbgOutputDebugString("FlowCtlFormat (0x0048): 0x%x \r\n\r\n", b32);
b32=ReadDWord( OpReg_FERMask);
EdbgOutputDebugString("FlowCtlFormat (0x0064): 0x%x \r\n", b32);
b16=ReadWord( OpReg_TxCollCnt);
EdbgOutputDebugString("TxCollCnt (0x0070): 0x%x \r\n", b16);
b16=ReadWord( OpReg_RxMissCnt);
EdbgOutputDebugString("RxMissCnt (0x0074): 0x%x \r\n", b16);
b16=ReadWord( OpReg_RxRuntCnt);
EdbgOutputDebugString("RxRuntCnt (0x0078): 0x%x \r\n\r\n", b16);
b16=ReadWord( OpReg_BMCTL);
EdbgOutputDebugString("BMCTL (0x0080): 0x%x \r\n", b16);
b8=ReadByte( OpReg_BMSts);
EdbgOutputDebugString("BusMasterSts (0x0084): 0x%x \r\n\r\n", b8);
b32=ReadDWord( OpReg_RxBCA);
EdbgOutputDebugString("RxBuffCurrAddr (0x0088): 0x%x \r\n", b32);
b32=ReadDWord( OpReg_TxBCA);
EdbgOutputDebugString("TxBuffCurrAddr (0x008c): 0x%x \r\n\r\n", b32);
b32=ReadDWord( OpReg_RxDBA);
EdbgOutputDebugString("RxDescQBaseAddr (0x0090): 0x%x \r\n", b32);
b16=ReadWord( OpReg_RxDBL);
EdbgOutputDebugString("RxDescQBaseLen (0x0094): 0x%x \r\n", b16);
b16=ReadWord( OpReg_RxDCL);
EdbgOutputDebugString("RxDescQCurrLen (0x0096): 0x%x \r\n", b16);
b32=ReadDWord( OpReg_RxDCA);
i= (b32 -(unsigned long)gCD.RxDescPhysAddr)/8;
EdbgOutputDebugString("RxDescCurrAddr (0x0098): 0x%x index=%d\r\n", b32, i);
b32=ReadDWord( OpReg_RxDEQ);
EdbgOutputDebugString("RxDescEnQ (0x009c): 0x%x \r\n\r\n", b32);
b32=ReadDWord( OpReg_RxSBA);
EdbgOutputDebugString("RxStsBaseAddr (0x00a0): 0x%x \r\n",b32);
b16=ReadWord( OpReg_RxSBL);
EdbgOutputDebugString("RxStsBaseLen (0x00a4): 0x%x \r\n", b16);
b16=ReadWord( OpReg_RxSCL);
EdbgOutputDebugString("RxStsCurrLen (0x00a6): 0x%x \r\n", b16);
b32=ReadDWord( OpReg_RxSCA);
i= (b32 -(unsigned long)gCD.RxStatPhysAddr)/8;
EdbgOutputDebugString("RxStsCurrAddr (0x00a8): 0x%x index=%d\r\n", b32, i);
b32=ReadDWord( OpReg_RxSEQ);
EdbgOutputDebugString("RxStsEnQ (0x00ac): 0x%x \r\n\r\n", b32);
b32=ReadDWord( OpReg_TxDBA);
EdbgOutputDebugString("TxDescQBaseAddr (0x00b0): 0x%x \r\n", b32);
b16=ReadWord( OpReg_TxDBL);
EdbgOutputDebugString("TxDescBaseLen (0x00b4): 0x%x \r\n", b16);
b16=ReadWord( OpReg_TxDCL);
EdbgOutputDebugString("TxDescQCurrLen (0x00b6): 0x%x \r\n", b16);
b32=ReadDWord( OpReg_TxDCA);
i= (b32 -(unsigned long)gCD.TxDescPhysAddr)/8;
EdbgOutputDebugString("TxDescCurrAddr (0x00b8): 0x%x index=%d\r\n", b32, i);
b32=ReadDWord( OpReg_TxDEQ);
EdbgOutputDebugString("TxDescEnQ (0x00bc): 0x%x \r\n\r\n", b32);
b32=ReadDWord( OpReg_TxSBA);
EdbgOutputDebugString("TxStsQBaseAddr (0x00c0): 0x%x \r\n", b32);
b16=ReadWord( OpReg_TxSBL);
EdbgOutputDebugString("TxStsQBaseLen (0x00c4): 0x%x \r\n", b16);
b16=ReadWord( OpReg_TxSCL);
EdbgOutputDebugString("TxStsQCurrLen (0x00c6): 0x%x \r\n", b16);
b32=ReadDWord( OpReg_TxSCA);
i= (b32 -(unsigned long)gCD.TxStatPhysAddr)/4;
EdbgOutputDebugString("TxStsCurrAddr (0x00c8): 0x%x index=%d \r\n\r\n", b32, i);
b32=ReadDWord( OpReg_RxBTH);
EdbgOutputDebugString("RxBuffTH (0x00d0): 0x%x \r\n", b32);
b32=ReadDWord( OpReg_TxBTH);
EdbgOutputDebugString("TxBuffTH (0x00d4): 0x%x \r\n", b32);
b32=ReadDWord( OpReg_RxSTH);
EdbgOutputDebugString("RxStsTH (0x00d8): 0x%x \r\n", b32);
b32=ReadDWord( OpReg_TxSTH);
EdbgOutputDebugString("TxStsTH (0x00dc): 0x%x \r\n", b32);
b32=ReadDWord( OpReg_RxDTH);
EdbgOutputDebugString("RxDescTH (0x00e0): 0x%x \r\n", b32);
b32=ReadDWord( OpReg_TxDTH);
EdbgOutputDebugString("TxDescTH (0x00e4): 0x%x \r\n\r\n", b32);
b32=ReadDWord( OpReg_MaxFL);
EdbgOutputDebugString("MaxFrameLen (0x00e8): 0x%x \r\n", b32);
b32=ReadDWord( OpReg_RxHLen);
EdbgOutputDebugString("RxHeaderLen (0x00ec): 0x%x \r\n", b32);
b32 = ReadDWord(OpReg_MacCfg0);
EdbgOutputDebugString("RxHeaderLen (0x0100): 0x%x \r\n", b32);
#if 0
pb32=(unsigned long *)gCD.pRxDesc;
EdbgOutputDebugString("\r\n\r\n******** Rx Descript Q address = 0x%x ***********\r\n", (unsigned long)gCD.pRxDesc);
for ( i=0; i<RXDESCCOUNT ;i++) {
b32=*pb32;
pb32++;
b32b=*pb32;
pb32++;
EdbgOutputDebugString(" Index %d: DW1=0x%x DW2=0x%x\r\n", i, b32, b32b);
}
pb32=(unsigned long *)gCD.pRxStat;
EdbgOutputDebugString("\r\n\r\n******** Rx Status Q address = 0x%x ***********\r\n", (unsigned long)gCD.pRxStat);
for ( i=0; i<RXSTATCOUNT ;i++) {
b32=*pb32;
pb32++;
b32b=*pb32;
pb32++;
EdbgOutputDebugString(" Index %d: DW1=0x%x DW2=0x%x\r\n", i, b32, b32b);
}
#endif // 0
pb32=(unsigned long *)gCD.pTxStat;
EdbgOutputDebugString("\r\n\r\n******** Tx Status Q address = 0x%x ***********\r\n", (unsigned long)gCD.pTxStat);
for ( i=0; i<TXSTATCOUNT ;i++) {
b32=*pb32;
pb32++;
EdbgOutputDebugString(" Index %d: 0x%x \r\n", i, b32);
}
pb32=(unsigned long *)gCD.pTxDesc;
EdbgOutputDebugString("\r\n\r\n******** Tx Descript Q address = 0x%x ***********\r\n", (unsigned long)gCD.pTxDesc);
for ( i=0; i<TXDESCCOUNT ;i++) {
b32=*pb32;
pb32++;
b32b=*pb32;
pb32++;
EdbgOutputDebugString(" Index %d: DW1=0x%x DW2=0x%x\r\n", i, b32, b32b);
}
#if 0
EdbgOutputDebugString("\r\n\r\n************* FIFO Rx Data ****************\r\n");
for ( pb32=(unsigned long *)&pCS8950Buffer->RxBuff[0]; pb32<(unsigned long *)&pCS8950Buffer->RxBuff[RXBUFFSIZE];pb32++) {
b32=*pb32;
EdbgOutputDebugString(" addr 0x%x: 0x%x \r\n", (unsigned long)pb32, b32);
}
EdbgOutputDebugString("\r\n\r\n************* FIFO Tx Data ****************\r\n");
for ( pb32=(unsigned long *)&pCS8950Buffer->TxBuff[0]; pb32<(unsigned long *)&pCS8950Buffer->TxBuff[RXBUFFSIZE];pb32++) {
b32=*pb32;
EdbgOutputDebugString(" addr 0x%x: 0x%x \r\n", (unsigned long)pb32, b32);
}
#endif // 0
#if 0
EdbgOutputDebugString("\r\n\r\n************* FIFO Rx Descript ****************\r\n");
for ( pb32=(unsigned long *)&pCS8950Buffer->RxDesc[0]; pb32<(unsigned long *)(&pCS8950Buffer->RxDesc[RXDESCCOUNT]);pb32++) {
b32=*pb32;
EdbgOutputDebugString(" addr 0x%x: 0x%x \r\n", (unsigned long)pb32, b32);
}
EdbgOutputDebugString("\r\n\r\n************* FIFO Rx Status ****************\r\n");
for ( pb32=(unsigned long *)&pCS8950Buffer->RxStat[0]; pb32<(unsigned long *)(&pCS8950Buffer->RxStat[RXSTATCOUNT]);pb32++) {
b32=*pb32;
EdbgOutputDebugString(" addr 0x%x: 0x%x \r\n", (unsigned long)pb32, b32);
}
#endif // 0
EdbgOutputDebugString("\r\n\r\n************* FIFO Tx Status ****************\r\n");
for ( pb32=(unsigned long *)&pCS8950Buffer->TxStat[0]; pb32<(unsigned long *)(&pCS8950Buffer->TxStat[TXSTATCOUNT]);pb32++) {
b32=*pb32;
EdbgOutputDebugString(" addr 0x%x: 0x%x \r\n", (unsigned long)pb32, b32);
}
EdbgOutputDebugString("\r\n\r\n************* FIFO Tx Descript ****************\r\n");
for ( pb32=(unsigned long *)&pCS8950Buffer->TxDesc[0]; pb32<(unsigned long *)(&pCS8950Buffer->TxDesc[TXDESCCOUNT]);pb32++) {
b32=*pb32;
EdbgOutputDebugString(" addr 0x%x: 0x%x \r\n", (unsigned long)pb32, b32);
}
}
////////////////////////////////////////////////////////////////////////////////
// CS8950EthCurrentFilter()
//
// Description:
//
// This function is used by VMINI to inform the underlying ethernet
// library on the filtering mode it requires.
//
// Arguments:
//
// pdwRequestedFilter :: The requested filter.
// Identical constants have been added in
// that mimics NDIS_PACKET_TYPE_XXX constants.
//
// Return Value:
//
// TRUE :: if we can set the filter.
// FALSE :: otherwise..
//
//
// Note:
//
// As a minimum to get vmini to work, we need to support
// PACKET_TYPE_DIRECTED
// PACKET_TYPE_BROADCAST
//
//
void CS8950EthCurrentPacketFilter(DWORD dwRequestedFilter)
{
//Do nothing. Just avoid warning.
DWORD i;
i=dwRequestedFilter;
} // CS8950EthCurrentPacketFilter()
////////////////////////////////////////////////////////////////////////////////
// CS8950EthMulticastList()
//
// Description:
//
// This function is used by VMINI to inform the underlying ethernet
// library on multicast addresses that winsock app is interested in.
//
// Arguments:
//
// pucMulticastAddressList :: Pointer to an array of multicast addresses.
// dwNoOfAddresses :: Number of addresses passed in to us.
//
// Return Value:
//
// TRUE :: if we can set the underlying edbg ethernet libary to start
// filtering on these multicast addresses.
//
// FALSE :: otherwise.
//
BOOL CS8950EthMulticastList(BYTE *pucMulticastAddressList, DWORD dwNoOfAddresses)
{
//
// This platform does support multicast.
//
DWORD i;
char ucMultiAddr[192];
EdbgOutputDebugString(
"OEMEthMulticastList():: No of Entries [%d]\r\n",
dwNoOfAddresses);
if (dwNoOfAddresses <= 0)
{
//
// VMINI passed an empty multicast list.
// Should be never happened.
// Return FALSE in case it happened.
EdbgOutputDebugString(
"Multicast list requeste [%d] <= 0 !!!\r\n",
dwNoOfAddresses);
return FALSE;
}
//
// We can check how many entries an adapter that are attached to
// can support.
// To make things simple, we just assume we can support minimum that
// vmini thinks we support (i.e. 32).
//
if (dwNoOfAddresses > 32)
{
//
// This should never happen, since VMINI is known to support
// 32 entries only...
//
EdbgOutputDebugString(
"Multicast list requeste [%d] > 32 !!!\r\n",
dwNoOfAddresses);
return FALSE;
}
//
// 32 entries, 6 bytes each..
//
memset(
ucMultiAddr,
0x00,
32 * 6);
//
// 6 bytes per entry..
//
memcpy(
ucMultiAddr,
pucMulticastAddressList,
dwNoOfAddresses * 6);
for (i = 0 ; i < dwNoOfAddresses ; i++)
{
EdbgOutputDebugString(
"[%d] : %x - %x - %x - %x - %x - %x\r\n",
i,
pucMulticastAddressList[6*i+0],
pucMulticastAddressList[6*i+1],
pucMulticastAddressList[6*i+2],
pucMulticastAddressList[6*i+3],
pucMulticastAddressList[6*i+4],
pucMulticastAddressList[6*i+5]);
}
//Enable all of multicast addresses on the chip.
//then Ethernet will receive all of the multicast packets.
CS8950MulticastAddAll();
return TRUE;
} // CS8950EthMulticastList()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -