📄 ndisisr.c
字号:
/* Place the buffer back to the free list for use next
time.
*/
Free_DMA_Buffer( pBufInfo, pDma );
}
}
}
}
return( uiPacketCount != 0 );
} // ProcessReceive
/*
MiniportHandleInterrupt
Description:
This routine is used by NDIS for deferred interrupt processing. It
reads from the Interrupt Status Register any outstanding interrupts and
handles them.
Parameters:
NDIS_HANDLE hAdapaterContext
Handle to adapter context containing adapter information.
Return (None):
*/
VOID MiniportHandleInterrupt (
IN NDIS_HANDLE hAdapterContext )
{
ULONG IntEnable;
PNDIS_ADAPTER pAdapter = ( PNDIS_ADAPTER ) hAdapterContext;
PHARDWARE pHardware = &pAdapter->m_Hardware;
int port = MAIN_PORT;
#ifdef DEBUG_DRIVER_INTERRUPT
DbgPrint( "MiniportHandleInterrupt"NEWLINE );
#endif
do
{
// Get the interrupt bits and save them.
// Mask only interesting bits.
HardwareReadInterrupt( pHardware, &IntEnable );
if ( !IntEnable )
{
break;
}
#ifdef DEBUG_INTERRUPT
DbgPrint( " intr:%08x"NEWLINE, IntEnable );
#endif
HardwareAcknowledgeInterrupt( pHardware, IntEnable );
/* All packets have been sent. */
if ( ( IntEnable & INT_TX_EMPTY ) )
{
/* Also acknowledge transmit complete interrupt. */
HardwareAcknowledgeTransmit( pHardware );
TransmitDone( pAdapter );
#ifdef DEBUG_COUNTER
pHardware->m_nGood[ COUNT_GOOD_INT_TX ]++;
#endif
}
/* Do not need to process transmit complete as all transmitted
descriptors are freed.
*/
else
if ( ( IntEnable & INT_TX ) )
{
TransmitDone( pAdapter );
#ifdef DEBUG_COUNTER
pHardware->m_nGood[ COUNT_GOOD_INT_TX ]++;
#endif
}
if ( ( IntEnable & INT_RX ) )
{
// Receive the packet
ProcessReceive( pAdapter );
#ifdef RCV_UNTIL_NONE
// Acknowledge the interrupt
HardwareAcknowledgeReceive( pHardware );
#endif
#ifdef DEBUG_COUNTER
pHardware->m_nGood[ COUNT_GOOD_INT_RX ]++;
#endif
}
if ( ( IntEnable & INT_PHY ) )
{
SwitchGetLinkStatus( pHardware );
// Acknowledge the interrupt
HardwareAcknowledgeLink( pHardware );
}
if ( ( IntEnable & INT_RX_OVERRUN ) )
{
#ifdef DBG
DBG_PRINT( "Rx overrun"NEWLINE );
#endif
pHardware->m_cnCounter[ port ][ OID_COUNTER_RCV_NO_BUFFER ]++;
// Acknowledge the interrupt
HardwareAcknowledgeOverrun( pHardware );
HardwareResumeReceive( pHardware );
#ifdef DEBUG_COUNTER
pHardware->m_nGood[ COUNT_GOOD_INT_RX_OVERRUN ]++;
#endif
}
if ( ( IntEnable & INT_RX_STOPPED ) )
{
#ifdef DBG
DBG_PRINT( "Rx stopped"NEWLINE );
#endif
/* Receive just has been stopped. */
if ( 0 == pHardware->m_bReceiveStop ) {
pHardware->m_ulInterruptMask &= ~INT_RX_STOPPED;
}
else if ( pHardware->m_bReceiveStop > 1 ) {
if ( pHardware->m_bEnabled &&
( pHardware->m_dwReceiveConfig &
DMA_RX_CTRL_ENABLE ) ) {
#ifdef DBG
DBG_PRINT( "Rx disabled"NEWLINE );
#endif
HardwareStartReceive( pHardware );
}
else {
#ifdef DBG
DBG_PRINT( "Rx stop disabled:%d"NEWLINE,
pHardware->m_bReceiveStop );
#endif
pHardware->m_ulInterruptMask &= ~INT_RX_STOPPED;
pHardware->m_bReceiveStop = 0;
}
}
/* Receive just has been started. */
else {
pHardware->m_bReceiveStop++;
}
HardwareAcknowledgeInterrupt( pHardware, INT_RX_STOPPED );
break;
}
#ifdef DBG
if ( ( IntEnable & INT_TX_STOPPED ) )
{
ULONG dwData;
pHardware->m_ulInterruptMask &= ~INT_TX_STOPPED;
DBG_PRINT( "Tx stopped"NEWLINE );
HW_READ_DWORD( pHardware, REG_DMA_TX_CTRL, &dwData );
if ( !( dwData & DMA_TX_CTRL_ENABLE ) ) {
DBG_PRINT( "Tx disabled"NEWLINE );
}
HardwareAcknowledgeInterrupt( pHardware, INT_TX_STOPPED );
break;
}
#endif
} while ( 1 );
} // MiniportHandleInterrupt
/*
MiniportISR
Description:
This routine is used by NDIS for the hardware to check if the interrupt
is its own in the shared interrupt environment.
Parameters:
PBOOLEAN pbInterruptRecognized
Buffer to indicate the interrupt is recognized
PBOOLEAN pbQueueDpc
Buffer to indicate the deferred interrupt processing should be
scheduled.
PVOID pContext
Pointer to adapter information structure.
Return (None):
*/
VOID MiniportISR (
OUT PBOOLEAN pbInterruptRecognized,
OUT PBOOLEAN pbQueueDpc,
IN PVOID pContext )
{
PNDIS_ADAPTER pAdapter = ( PNDIS_ADAPTER ) pContext;
PHARDWARE pHardware = &pAdapter->m_Hardware;
ULONG ulIntStatus = 0;
HardwareReadInterrupt( pHardware, &ulIntStatus );
/* Hardware interrupts are disabled. */
ulIntStatus &= pHardware->m_ulInterruptSet;
/* Got interrupt and not already queued for interrupt handling. */
if ( ulIntStatus )
{
HardwareDisableInterrupt( pHardware );
*pbInterruptRecognized = TRUE;
*pbQueueDpc = TRUE;
}
else
{
// not our interrupt!
*pbInterruptRecognized = FALSE;
*pbQueueDpc = FALSE;
}
} // MiniportISR
/* -------------------------------------------------------------------------- */
/*
MiniportReturnPacket
Description:
This routine attempts to return to the receive free list the packet
passed to us by NDIS.
Parameters:
NDIS_HANDLE hAdapaterContext
Handle to adapter context containing adapter information.
PNDIS_PACKET pPacket
Pointer to NDIS packet.
Return (None):
*/
VOID MiniportReturnPacket (
IN NDIS_HANDLE hAdapterContext,
PNDIS_PACKET pPacket )
{
PNDIS_ADAPTER pAdapter = ( PNDIS_ADAPTER ) hAdapterContext;
PDMA_BUFFER pDma;
#ifdef DBG_
DBG_PRINT( "MiniportReturnPacket"NEWLINE );
#endif
#if 0
NDIS_SET_PACKET_STATUS( pPacket, NDIS_STATUS_SUCCESS );
#endif
/* Get the pointer to receive buffer. */
pDma = RESERVED( pPacket )->pDma;
#if 0
/* Adjust the buffer length. */
NdisAdjustBufferLength( pDma->pNdisBuffer, pDma->ulSize );
#endif
Free_DMA_Buffer( &pAdapter->m_RxBufInfo, pDma );
} // MiniportReturnPacket
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -