阅读:837回复:0
为什么总是取不到正确的资源?
我正在给一块PCI板卡写WDM的驱动,PCI板卡采用的是pci2040芯片.但是我在IRP_MN_START_DEVICE中取板卡的资源的时候却总是取不对(本来应该是4个资源,1个中断和3个内存地址范围,但是我得到的总是12个资源,资源类型分别为:1,129,1,129,1,129,1,129,1,129,1,129.显然不对,但又不知道错在哪里?)我的代码如下:
NTSTATUS HandleStartDevice(IN PDEVICE_OBJECT fdo,IN PIRP pIrp) { ... //other rutines(such as ForwardAndWait...) pIrpStack=IoGetCurrentIrpStackLocation(pIrp); pResourceList=pIrpStack->Parameters.StartDevice.AllocatedResourcesTranslated; pPartialList=&pResourceList->List\\[0\\].PartialResourceList; //反斜杠应该没有的不过我不敲的话0不显示 pPartialDescriptor=pPartialList->PartialDescriptors; for(i=0;i<(int)pPartialList->Count;i++) { pPartialDescriptor=&pPartialList->PartialDescriptors\\[i\\]; DebugPrint(\"Partial Descriptor Type = %d\",pPartialDescriptor->Type); switch(pPartialDescriptor->Type) { case CmResourceTypeInterrupt: dx->IRQL=(KIRQL)pPartialDescriptor->u.Interrupt.Level; dx->InterruptVector=pPartialDescriptor->u.Interrupt.Vector; dx->InterruptAffinity=pPartialDescriptor->u.Interrupt.Affinity; break; case CmResourceTypeDma: break; case CmResourceTypePort: break; case CmResourceTypeMemory: dx->MemStartAddress=pPartialDescriptor->u.Memory.Start; dx->MemLength=pPartialDescriptor->u.Memory.Length; break; } } } [编辑 - 5/21/03 by derlupy] [编辑 - 5/21/03 by derlupy] [编辑 - 5/21/03 by derlupy] |
|