📄 interrup.c
字号:
// Programmer:桂凯 西安电子科技大学
//
// email:wwwguikai@21cn.com
// All right reserved
//
//
//
//
#include <ntddk.h>
#include <ndis.h>
#include <pci9052hw.h>
#include <pci9052sw.h>
BOOLEAN HandleInterrupt(PKINTERRUPT Interupt, PVOID ServiceContext)
{
BOOLEAN ourDeviceInterrupting = FALSE;
PDEVICE_EXTENSION devExt = (PDEVICE_EXTENSION)ServiceContext;
ULONG intRegister;
ULONG csrRegister;
PULONG port = (PULONG)devExt->PlxRegisterBaseAddr + INTCSR;
ULONG value[1] ;
// WRITE_PORT_ULONG( &port, value);
// DbgPrint("PCI9052: ISR entered\n");
/*
if(devExt->data_ready ==TRUE) // we have already fetch data from PCI9052 and the app didn't get it.
return(ourDeviceInterrupting);
*/
memcpy( value, port, 4);
if( value[0] & MY_INT_HAPPEN_MASK)
{
ourDeviceInterrupting = TRUE;
value[0] = value[0] & (~MY_INT_DISABLE); // disable pci9052 inta
value[0] = value[0] & (~MY_INT_CLR_STATUS); // clear status
value[0] = value[0] | (MY_INT_CLR_INT) ; // clear Local edge triggerable interrupt
memcpy( port, value, 4); // at this time, interupt is disabled
IoRequestDpc(devExt->DeviceObject, 0, NULL);
}
return(ourDeviceInterrupting);
}
VOID
DpcForIsr(PKDPC Dpc, PDEVICE_OBJECT DeviceObject, PIRP Unused, PVOID Context)
{
PDEVICE_EXTENSION devExt = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
PLIST_ENTRY entry;
PIRP irp;
PVOID baseVa;
ULONG mapRegsNeeded;
ULONG offset = 0x00000001;
PULONG port = (PULONG)devExt->PlxRegisterBaseAddr + INTCSR;
ULONG value[1] ;
ULONG X,Y;
if( devExt->MapedIoLocalSpace0BaseAddr != NULL)
{
memcpy( devExt->data, devExt->MapedIoLocalSpace0BaseAddr, 4); // save data to our pool
X=*(devExt->data)>>16;
Y=*(devExt->data)&0XFFF;
DbgPrint("X: 0x%x, Y: 0x %x \n",X,Y);
devExt->data_ready = TRUE;
// DbgPrint("------PCI9052 DPCforISR, int_counter = %08d \n",devExt->int_counter++ );
}
memcpy( value,port, 4);
value[0] = value[0] | (MY_INT_ENABLE);
memcpy( port, value, 4); // enable interrupt again
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -