阅读:1229回复:1
如何分配两个中断给驱动程序?
偶在写一个驱动程序,需要两个中断。俺在调试一个中断的时候,没有问题。
俺用的是ds2.5,他的wizard只能生成一个中断服务程序,我用了,没有问题,但我需要两个中断,我在inf文件中设置: IRQCONGIF=10 IRQCONFIG=11 在设备管理->系统中也都识别出来了,系统给驱动分配了两个中断,而且没有冲突。 在设备驱动中是这样处理的,所有ds2.5中生成的关于中断的语句,我都仿照着写了一便给另一个中断: m_Get_Data 是ds2.5生成的,m_Circle是我自己仿照写的: device.h 中 KInterrupt m_Get_Data; KInterrupt m_Circle; KDeferredCall m_DpcFor_Get_Data; KDeferredCall m_DpcFor_Circle; 。。。。。 。。。。。 BOOLEAN Isr_Get_Data(void); // COMMENT_ONLY BOOLEAN Isr_Circle(void); 。。。。。 。。。。。 MEMBER_ISR(CounterDevice, Isr_Get_Data); MEMBER_ISR(CounterDevice,Isr_Circle); 在device.cpp中的OnStartDevice中 NTSTATUS CounterDevice::OnStartDevice(KIrp I) { t << \"Entering CounterDevice::OnStartDevice\\n\"; NTSTATUS status = STATUS_SUCCESS; I.Information() = 0; // Get the list of raw resources from the IRP PCM_RESOURCE_LIST pResListRaw = I.AllocatedResources(); // Get the list of translated resources from the IRP PCM_RESOURCE_LIST pResListTranslated = I.TranslatedResources(); // Initialize and connect the interrupt status = m_Get_Data.InitializeAndConnect( pResListTranslated, LinkTo(Isr_Get_Data), this ); if (!NT_SUCCESS(status)) { Invalidate(); return status; } status = m_Circle.InitializeAndConnect( pResListTranslated, LinkTo(Isr_Circle), this ); if (!NT_SUCCESS(status)) { Invalidate(); return status; } // Setup the DPC to be used for interrupt processing m_DpcFor_Get_Data.Setup(LinkTo(DpcFor_Get_Data), this); m_DpcFor_Circle.Setup(LinkTo(DpcFor_Circle),this); // TODO: Add device-specific code to start your device. // The base class will handle completion return status; } 用SoftIce跟踪的时候,两个InitializeAndConnect都没有出错。 我觉的是资源分配有问题,两个InitializeAndConnect函数得到的参数都是一样的,他怎么知道如何把哪个中断分配给相应的ISR,也就是把中断10分配给m_Get_Data,把中断11分配给m_Circle。 问题是我也不知道怎么分配两个中断,有那为DX 知道吗,请不吝赐教。谢谢! |
|
最新喜欢:![]() |
沙发#
发布于:2003-05-19 22:10
已经解决了,看样子,坛子里没人做过两个中断的驱动,不过我也是头一回做,摸着石头过核。
对了,是这么解决的 InitializeAndConnect 里面还有个变量,是设置哪个中断号的,原来的默认为零,就省略了,我给加上就好了 status = m_Get_Data.InitializeAndConnect( pResListTranslated, LinkTo(Isr_Get_Data), this, 0 //这里呕 ); if (!NT_SUCCESS(status)) { Invalidate(); return status; } status = m_Circle.InitializeAndConnect( pResListTranslated, LinkTo(Isr_Circle), this, 1 //还有这里呕 ); if (!NT_SUCCESS(status)) { Invalidate(); return status; } 就OK 了! |
|