Hi all,
I am writing a WDM driver for my PCI device.
I am receiving a START_DEVICE IRP which I am sending it to the lower driver.
I have registered a IO complete rouitne.My registered function is getting called after the lower driver finishes its processing.
I get the stack location for my IRP and read the status as success.
But I found out that stack->Parameters.StartDevice.AllocatedResourcesTranslated
and stack->Parameters.StartDevice.AllocatedResources are both NULL.
Can I please know why this problem is occuring?
NOTE: My hardware has only one BAR0 resource and no interrupts.
I even used an application to read the config space. It shows BAR0 base address properly. I am using WDK 6001.18001 version on Server 2008 on a AMD64 board.
status = IoCallDriver(DevObj, Irp);
KeWaitForSingleObject(&Event);
< Here look for Your stack location >
And find nothing of use, because IoCompleteRequest () had already zeroed it out before it invoked your completion routine. Therefore, you should get all the data that you need *before* having passed IRP to a lower driver…
I can be totally wrong but i think is that StartDevice need to passed to lower driver first than only my driver should access it as stacks need to be started from bottom.
Even in the toaster example code is done like this. Please let me know what i am missing.
switch (stack->MinorFunction)
{
case IRP_MN_START_DEVICE:
status = ToasterSendIrpSynchronously(fdoData->NextLowerDriver, Irp);
if (NT_SUCCESS (status))
{
status = ToasterStartDevice (fdoData, Irp);
}
Regards,
Dhiren
xxxxx@hotmail.com wrote:
status = IoCallDriver(DevObj, Irp);
KeWaitForSingleObject(&Event);
< Here look for Your stack location >
And find nothing of use, because IoCompleteRequest () had already zeroed it out before it invoked your completion routine. Therefore, you should get all the data that you need *before* having passed IRP to a lower driver…
> And find nothing of use, because IoCompleteRequest () had already zeroed
it out before it invoked your completion routine. >Therefore, you should
get all the data that you need *before* having passed IRP to a lower
driver…
If this is the case then a lot of the drivers in the world are broken. I
strongly suggest that in cases like this you try it before asserting it,
just put a breakpoint in a completion routine and inspect the contents of
the current stack location. You’ll see that it is definitely not zeroed.
wrote in message news:xxxxx@ntdev… > status = IoCallDriver(DevObj, Irp); > KeWaitForSingleObject(&Event); > < Here look for Your stack location > > > And find nothing of use, because IoCompleteRequest () had already zeroed > it out before it invoked your completion routine. Therefore, you should > get all the data that you need before having passed IRP to a lower > driver… > > Anton Bassov >
If this is the case then a lot of the drivers in the world are broken. I strongly suggest that in cases like this >you try it before asserting it, just put a breakpoint in a completion routine and inspect the contents of the >current stack location. You’ll see that it is definitely not zeroed.
Please check http://www.osronline.com/showThread.cfm?link=111116 , and pay attention to post 44 - you will see a relevant part of IoCompleteRequest()'s implementation (the code was originally posted to MSFT NG by Elyas Yakub, so that I copy-pasted it). Please pay a special attention to ZeroIrpStackLocation( ) that get invoked before the completion routine…
Right, the I/O manager zeroes the stack location with the completion routine
in it before calling the completion routine. In this context this isn’t the
current stack location, it’s the previous one. See the
IoSetCompletionRoutine macro in wdm.h and pay close attention to where the
completion routine is set…
wrote in message news:xxxxx@ntdev… > Scott, > >> If this is the case then a lot of the drivers in the world are broken. I >> strongly suggest that in cases like this >you try it before asserting it, >> just put a breakpoint in a completion routine and inspect the contents of >> the >current stack location. You’ll see that it is definitely not zeroed. > > Please check http://www.osronline.com/showThread.cfm?link=111116 , and pay > attention to post 44 - you will see a relevant part of > IoCompleteRequest()'s implementation (the code was originally posted to > MSFT NG by Elyas Yakub, so that I copy-pasted it). Please pay a special > attention to ZeroIrpStackLocation( ) that get invoked before the > completion routine… > > Anton Bassov >
Actually, it is called the “next” I/O stack location but in the process of
completion processing I think Scott is using ‘previous’ to mean ‘in order of
completion’ (lifo) and not specifically being consistent with the “Current”
and “Next” terminology of WDM/NT. It is quite clearly documented that the
I/O Stack Location into which a driver places parameters for (and CRTN
pointer) the *next* lower driver will *not* be preserved or available to the
CRTN (or dispatch routine if processing synchronously). The parameters that
were made available to *your* driver *are* preserved and will be present in
the “Current” stack location.
-dave
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Scott Noone
Sent: Monday, April 14, 2008 10:27 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] pci resource allocation issue
Right, the I/O manager zeroes the stack location with the completion routine
in it before calling the completion routine. In this context this isn’t the
current stack location, it’s the previous one. See the
IoSetCompletionRoutine macro in wdm.h and pay close attention to where the
completion routine is set…
wrote in message news:xxxxx@ntdev… > Scott, > >> If this is the case then a lot of the drivers in the world are broken. I >> strongly suggest that in cases like this >you try it before asserting it,
>> just put a breakpoint in a completion routine and inspect the contents of
> attention to post 44 - you will see a relevant part of > IoCompleteRequest()'s implementation (the code was originally posted to > MSFT NG by Elyas Yakub, so that I copy-pasted it). Please pay a special > attention to ZeroIrpStackLocation( ) that get invoked before the > completion routine… > > Anton Bassov >
Right, during the unwind of completion processing what was the “next”
location on the dispatching side becomes the “previous” location.
Discussions like this one are why all of the major deities collectively
created the white board, it’s much easier to explain with pictures. It’s
also an example of why having source isn’t always helpful, based on the code
it’s easy to assume that it doesn’t work this way.
“David R. Cattley” wrote in message news:xxxxx@ntdev… > Actually, it is called the “next” I/O stack location but in the process of > completion processing I think Scott is using ‘previous’ to mean ‘in order > of > completion’ (lifo) and not specifically being consistent with the > “Current” > and “Next” terminology of WDM/NT. It is quite clearly documented that the > I/O Stack Location into which a driver places parameters for (and CRTN > pointer) the next lower driver will not be preserved or available to > the > CRTN (or dispatch routine if processing synchronously). The parameters > that > were made available to your driver are preserved and will be present > in > the “Current” stack location. > > -dave > > -----Original Message----- > From: xxxxx@lists.osr.com > [mailto:xxxxx@lists.osr.com] On Behalf Of Scott Noone > Sent: Monday, April 14, 2008 10:27 AM > To: Windows System Software Devs Interest List > Subject: Re:[ntdev] pci resource allocation issue > > Right, the I/O manager zeroes the stack location with the completion > routine > > in it before calling the completion routine. In this context this isn’t > the > current stack location, it’s the previous one. See the > IoSetCompletionRoutine macro in wdm.h and pay close attention to where the > completion routine is set… > > -scott > > – > Scott Noone > Software Engineer > OSR Open Systems Resources, Inc. > http://www.osronline.com > > > wrote in message news:xxxxx@ntdev… >> Scott, >> >>> If this is the case then a lot of the drivers in the world are broken. I >>> strongly suggest that in cases like this >you try it before asserting >>> it, > >>> just put a breakpoint in a completion routine and inspect the contents >>> of > >>> the >current stack location. You’ll see that it is definitely not >>> zeroed. >> >> Please check http://www.osronline.com/showThread.cfm?link=111116 , and >> pay > >> attention to post 44 - you will see a relevant part of >> IoCompleteRequest()'s implementation (the code was originally posted to >> MSFT NG by Elyas Yakub, so that I copy-pasted it). Please pay a special >> attention to ZeroIrpStackLocation( ) that get invoked before the >> completion routine… >> >> Anton Bassov >> > > > > — > NTDEV is sponsored by OSR > > For our schedule of WDF, WDM, debugging and other seminars visit: > http://www.osr.com/seminars > > To unsubscribe, visit the List Server section of OSR Online at > http://www.osronline.com/page.cfm?name=ListServer > >
If this is a PCI device w/out assigned resources, I am guessing you force installed your driver on a root enumerated device instead the PCI enumerated device. Send the output of
!devstack
To the list
d
-----Original Message----- From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com Sent: Monday, April 14, 2008 12:47 AM To: Windows System Software Devs Interest List Subject: [ntdev] pci resource allocation issue
Hi all, I am writing a WDM driver for my PCI device. I am receiving a START_DEVICE IRP which I am sending it to the lower driver. I have registered a IO complete rouitne.My registered function is getting called after the lower driver finishes its processing. I get the stack location for my IRP and read the status as success. But I found out that stack->Parameters.StartDevice.AllocatedResourcesTranslated and stack->Parameters.StartDevice.AllocatedResources are both NULL.
Can I please know why this problem is occuring?
NOTE: My hardware has only one BAR0 resource and no interrupts. I even used an application to read the config space. It shows BAR0 base address properly. I am using WDK 6001.18001 version on Server 2008 on a AMD64 board.
We have written our PCI driver on the similar lines of the example PCI driver given in the WDK example (src\general\pcidrv). The handling of the START_DEVICE IRP is done asynchrosously as in the WDK pcidrv example. We also tried the synchronous way of handling the START_DEVICE IRP. In both the approaches the “AllocatedResourceTranslated” and “AllocatedResource” as NULL.
[1] Is there anything extra that we need to do in AddDevice and DispatchPnP for a PCI enumerated device?
[2] For setting up the kernel debugger, we used bcdedit command on Server 2008 machine to enable the kernel debugging mode. When executed the command and the following message was given:
“C:\Users\Administrator>bcdedit /debug ON
The boot configuration data store could not be opened.
The requested system device cannot be found.”
Did you run bcdedit as an admin and in an elevated window? What is the value of the property returned from IoGetDeviceProperty(DevicePropertyEnumeratorName)? You can call this in your adddevice routine
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, April 16, 2008 3:35 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] pci resource allocation issue
We have written our PCI driver on the similar lines of the example PCI driver given in the WDK example (src\general\pcidrv). The handling of the START_DEVICE IRP is done asynchrosously as in the WDK pcidrv example. We also tried the synchronous way of handling the START_DEVICE IRP. In both the approaches the “AllocatedResourceTranslated” and “AllocatedResource” as NULL.
[1] Is there anything extra that we need to do in AddDevice and DispatchPnP for a PCI enumerated device?
[2] For setting up the kernel debugger, we used bcdedit command on Server 2008 machine to enable the kernel debugging mode. When executed the command and the following message was given:
“C:\Users\Administrator>bcdedit /debug ON
The boot configuration data store could not be opened.
The requested system device cannot be found.”
Yes, I had logged in as admin when I executed the bcdedit command.
I tried the IoGetDeviceProperty(DevicePropertyEnumeratorName) in my AddDevice function. It’s actually returning the enumerator name as PCI. If the device is PCI enumerated, shouldn’t the resources be allocated?
What is the output of !irp before you send it down the stack and in the completion routine?/
d
-----Original Message----- From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com Sent: Wednesday, April 16, 2008 9:28 AM To: Windows System Software Devs Interest List Subject: RE:[ntdev] pci resource allocation issue
Doron,
Yes, I had logged in as admin when I executed the bcdedit command.
I tried the IoGetDeviceProperty(DevicePropertyEnumeratorName) in my AddDevice function. It’s actually returning the enumerator name as PCI. If the device is PCI enumerated, shouldn’t the resources be allocated?