📄 int.c
字号:
/*++
Copyright (c) 2000 Microsoft Corporation. All rights reserved.
File: int.c
Developed for Toshiba by Elisa Research Inc., CA
http://www.elisaresearch.com
(510) 770-4920
Abstract:
This routine handles interupt processing.
Note:
Currently, there are not all of interrupt handlers have
been implemented.
Author:
A. Wang
Environment:
Kernel mode
Revision History:
01/07/97 awang Initial of Toshiba ATM 155 Device Driver.
--*/
#include "precomp.h"
#pragma hdrstop
#define MODULE_NUMBER MODULE_INT
VOID
TbAtm155EnableInterrupt(
IN NDIS_HANDLE MiniportAdapterContext
)
/*++
Routine Description:
This routine will enable the 155 PCI controller interrupts.
Arguments:
MiniportAdapterContext - This is a pointer to our miniport block.
Return Value:
--*/
{
PADAPTER_BLOCK pAdapter = (PADAPTER_BLOCK)MiniportAdapterContext;
PHARDWARE_INFO pHwInfo = pAdapter->HardwareInfo;
//
// Let's clear the flag first.
//
TBATM155_WRITE_PORT(
&pHwInfo->TbAtm155_SAR->Intr_Enb,
pHwInfo->InterruptMask);
HW_CLEAR_FLAG(pHwInfo, fHARDWARE_INFO_INTERRUPTS_DISABLED);
}
VOID
TbAtm155DisableInterrupt(
IN NDIS_HANDLE MiniportAdapterContext
)
/*++
Routine Description:
This routine will disable the 155 PCI controller interrupts.
Arguments:
MiniportAdapterContext - This is a pointer to our miniport block.
Return Value:
--*/
{
PADAPTER_BLOCK pAdapter = (PADAPTER_BLOCK)MiniportAdapterContext;
PHARDWARE_INFO pHwInfo = pAdapter->HardwareInfo;
TBATM155_WRITE_PORT(&pHwInfo->TbAtm155_SAR->Intr_Enb, 0);
//
// Let's Set the flag.
//
HW_SET_FLAG(pHwInfo, fHARDWARE_INFO_INTERRUPTS_DISABLED);
}
VOID
tbAtm155ErrorInterrupt(
IN PADAPTER_BLOCK pAdapter
)
/*++
Routine Description:
This routine will process error interrupts.
Arguments:
pAdapter - Pointer to the adapter block.
InterruptStatus - This contains the error interrupts
that we need to process.
Return Value:
None.
--*/
{
PHARDWARE_INFO pHwInfo = pAdapter->HardwareInfo;
ULONG InterruptStatus = pHwInfo->InterruptStatus;
DBGPRINT(DBG_COMP_INT, DBG_LEVEL_INFO,
("==>tbAtm155ErrorInterrupt\n"));
IF_DBG(DBG_COMP_INT, DBG_LEVEL_ERR)
{
DBGPRINT(DBG_COMP_INT, DBG_LEVEL_ERR,
("Error Interrupt\n"));
DBGPRINT(DBG_COMP_INT, DBG_LEVEL_ERR,
("InterruptStatus: 0x%x\n", InterruptStatus));
DBGPRINT(DBG_COMP_INT, DBG_LEVEL_ERR,
("pHwInfo: 0x%x\n", pHwInfo));
DBGPRINT(DBG_COMP_INT, DBG_LEVEL_ERR,
("pSar: 0x%x\n", pHwInfo->SarInfo));
DBGPRINT(DBG_COMP_INT, DBG_LEVEL_ERR,
("pXmitDmaQ: 0x%x\n", &pHwInfo->SarInfo->XmitDmaQ));
DBGPRINT(DBG_COMP_INT, DBG_LEVEL_ERR,
("pRecvDmaQ: 0x%x\n", &pHwInfo->SarInfo->RecvDmaQ));
DBGPRINT(DBG_COMP_INT, DBG_LEVEL_ERR,
("pVc [head]: 0x%x\n", pAdapter->ActiveVcList.Flink));
}
//
// This will cause the adapter to be reset.
//
ADAPTER_SET_FLAG(pAdapter, fADAPTER_HARDWARE_FAILURE);
#if DBG
DbgPrint("TBATM155: Adapter %p, Flags %x: error interrupt!\n",
pAdapter, pAdapter->Flags);
DbgBreakPoint();
#endif
if ((InterruptStatus & TBATM155_INT_TX_FATAL_ERR) == TBATM155_INT_TX_FATAL_ERR)
{
DBGPRINT(DBG_COMP_INT, DBG_LEVEL_ERR,
("InterruptStatus & TBATM155_INT_TX_FATAL_ERR\n"));
pAdapter->TxFatalError++;
}
if ((InterruptStatus & TBATM155_INT_PCI_FATAL_ERR) == TBATM155_INT_PCI_FATAL_ERR)
{
DBGPRINT(DBG_COMP_INT, DBG_LEVEL_ERR,
("InterruptStatus & TBATM155_INT_PCI_FATAL_ERR\n"));
pAdapter->PciErrorCount++;
}
if ((InterruptStatus & TBATM155_INT_TX_FREE_SLOT_UNFL) == TBATM155_INT_TX_FREE_SLOT_UNFL)
{
DBGPRINT(DBG_COMP_INT, DBG_LEVEL_ERR,
("InterruptStatus & TBATM155_INT_TX_FREE_SLOT_UNFL\n"));
pAdapter->TxFreeSlotUnflCount++;
}
if ((InterruptStatus & TBATM155_INT_RX_FREE_SLOT_OVFL) == TBATM155_INT_RX_FREE_SLOT_OVFL)
{
DBGPRINT(DBG_COMP_INT, DBG_LEVEL_ERR,
("InterruptStatus & TBATM155_INT_RX_FREE_SLOT_OVFL\n"));
pAdapter->RxFreeSlotOvflCount++;
}
DBGPRINT(DBG_COMP_INT, DBG_LEVEL_INFO,
("<==tbAtm155ErrorInterrupt\n"));
}
VOID
TbAtm155ISR(
OUT PBOOLEAN InterruptRecognized,
OUT PBOOLEAN QueueDpc,
IN PVOID MiniportAdapterContext
)
/*++
Routine Description:
This routine will service interrupts for the TbAtm155.
All we need to do is determine if the interrupt that was generated
belongs to us and whether or not it needs a DPC queued to service
it.
Arguments:
InterruptRecognized - TRUE if the interrupt belongs to the
TbAtm155.
QueueDpc - TRUE if we need our
MiniportInterruptHandler called.
MiniportAdapterContext - Pointer to our adapter block.
Return Value:
None.
--*/
{
PADAPTER_BLOCK pAdapter = (PADAPTER_BLOCK)MiniportAdapterContext;
PHARDWARE_INFO pHwInfo = pAdapter->HardwareInfo;
ULONG InterruptStatus;
if (HW_TEST_FLAG(pHwInfo, fHARDWARE_INFO_INTERRUPTS_DISABLED))
{
*InterruptRecognized = FALSE;
*QueueDpc = FALSE;
return;
}
//
// Read the current interrupt status from the 155 PCI registers.
// By reading the Int_Status (Interrupt Status) register we don't ACK
// any of the interrupts we just determine if we need to queue
// a DPC.
//
TBATM155_READ_PORT(&pHwInfo->TbAtm155_SAR->Intr_Status, &InterruptStatus);
if (0 == InterruptStatus)
{
//
// No interrupts belong to us!
//
*InterruptRecognized = FALSE;
*QueueDpc = FALSE;
return;
}
//
// The interrupt is ours, we need to make sure we don't
// get any more til we are done.
//
TBATM155_WRITE_PORT(&pHwInfo->TbAtm155_SAR->Intr_Enb, 0);
HW_SET_FLAG(pHwInfo, fHARDWARE_INFO_INTERRUPTS_DISABLED);
//
// Do the rest in a dpc.
//
*InterruptRecognized = TRUE;
*QueueDpc = TRUE;
}
VOID
TbAtm155HandleInterrupt(
IN NDIS_HANDLE MiniportAdapterContext
)
/*++
Routine Description:
This is the workhorse routine. It will loop processing interrupts
until there are none left or it's spent too much time...
Arguments:
MiniportAdapterContext - Pointer to the adapter block.
Return Value:
None.
--*/
{
//
// Pointer to the adapter block.
//
PADAPTER_BLOCK pAdapter = (PADAPTER_BLOCK)MiniportAdapterContext;
//
// Pointer to our hardware information.
//
PHARDWARE_INFO pHwInfo = pAdapter->HardwareInfo;
//
// Pointer to the SAR information.
//
PSAR_INFO pSar = pHwInfo->SarInfo;
//
// Interrupt status codes to process.
//
ULONG InterruptStatus;
//
// Number of times we have looped through the interrupt status's.
//
UINT InterruptCount;
//
// This is set to TRUE if the adapter has received
// (and indicated) any packets.
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -