我想在驱动收到PCI卡的中断时,用dpc里置事件有效,为什么已装载驱动就死机呢?
相关代码如下:
#pragma PAGEDCODE
NTSTATUS AddDevice(IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject)
{
.......
IoInitializeDpcRequest (fdo,DpcForIsr);
.......
}
VOID DpcForIsr(IN PKDPC Dpc, IN PDEVICE_OBJECT fdo,
IN PIRP Irp, IN PDEVICE_EXTENSION pdx)
{
KdPrint(("==============DpcForIsr!!!\n"));
KeSetEvent(pdx->m_pEvent,IO_NO_INCREMENT,FALSE);
ObDereferenceObject(pdx->m_pEvent);
}
BOOLEAN OnInterrupt(PKINTERRUPT InterruptObject, PDEVICE_EXTENSION pdx)
{
KdPrint(("OnInterrupt\n"));
ULONG dw = READ_PORT_ULONG((PULONG)0x9038);
if( dw & 0x00020000 )
{
READ_PORT_UCHAR((PUCHAR)0x901f);
WRITE_PORT_USHORT((PUSHORT)0x903a,(USHORT)0x003f);
}
IoRequestDpc(pdx->fdo, NULL, pdx);
return TRUE;
}
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!