I am having problems sending SRB_FUNCTION_FLUSH and SRB_FUNCTION_SHUTDOWN request to a pci based Scsi device.
I have a driver filter that sits below the class Pnp driver, right above a scsi disk device. When I attempt to send a Flush or Shutdown SRB, I get an exception in ScsiportDispatchFdo. From my driver, the derived device object has a device instance name of the form ?pci\ven_…?.
The ScsiPortDispatchFdo uses the OriginalRequest field of the srb, which I have set as my Irp address. It appears that the ScsiportDispatchFdo code is using the OrignalRequest pointer as a private structure. It is definetely not an Irp.
If I access my scsi disk device object with the Device Instance name formed ?scsi\disk&ven…? everything works fine. The difference is that when IoCallDriverStackSafeDefault is called with this devObj, Scsiport dispatcher calls ScsiPortPdoScsi before ScsiPortDispatchFdo is called. Within ScsiPortPdoSci, the struct pointed to by the OriginalRequest field is generated.
What is the trick to make the scsiport dispatcher happy? Any tips would be very much appreciated.
Thanks
Despite on fact that your driver is pci base device it doesn’t get pci resources directly from pci bus driver. It gets such resources from SCSI port driver. And I don’t think you could reference your driver as a pci.… device but you could , as you mention, call as scsi.…
What is your exact problem?
Igor Sharovar
When I generate a SRB_FUNCTION_FLUSH srb from my driver and send it off to the scsi dispatcher, I get a crash in ScsiportDispatchFdo(). In the field, srb->OriginalRequest, I have set it to be my Irp. This is not what the code in ScsiportDispatchFdo() is expecting. It is expecting a pointer to private (scsi) structure.
So, either a) how can I replicate this private structure, or b) ??
Thanks
You are right. You should put your Irp in srb->OriginalRequest. At least sample of disk.sys indicates that.
Does your driver enable cache flushing in PORT_CONFIGURATION_INFORMATION structure?
You should also try to use a check build version of scsiport.sys.
Igor Sharovar
I don’t own the underlying scsiport, thus don’t control the cache enable. BTW Igor, thanks for your suggestion regarding trying with a checked build.
And yes, typically one needs to set srb->OriginalRequest to your irp. But in the case of the Flush, ScsiPortPdoScsi overwrites this field.
So I can understand better what is going on with this flush failure, does anyone know the contents of this srb->OriginalRequest private structure?
Thanks
> The ScsiPortDispatchFdo uses the OriginalRequest field of the srb, which I have set as my Irp
address. It appears that the ScsiportDispatchFdo code is using the OrignalRequest pointer as a
private structure. It is definetely not an Irp.
Yes, you must never touch this field.
Look at Disk/ClassPnP source in the WDK for a way to fill SRBs/IRPs.
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com