Hi,
Nice to talk to you, every expert.
These days, I am developing my own USBSTOR driver, which will replace the Windows native USBSTOR.sys.
Two methods:
1st. filter driver
2nd. bus driver + disk.sys(for the LUN PDO)
I have the following questions:
For filter driver case:
disk.sys
|
usbstor.sys
|
usbhub.sys
|
usbehci.sys
|
P C I Bus
|
Hardware
- I develop a filter driver, which will hook the SRBs, when I install this filter driver as lower filter driver of disk.sys, the SRBs could be hooked in IRP_MJ_SCSI routin.
but when I install this filter dirver as a upper filter driver of USBSTOR.sys, the SRBs could not hooked in IRP_MJ_SCSI, why?
I think both filter driver(disk.sys lower ftiler and usbstor.sys upper filter) should hook the SRBs in their IRP_MJ_SCSI routin, because the IRPs is route from top to bottom. - USBSTOR.SYS is the BOT(BULK ONLY transfer, two bulk pipe used) protocol driver for USB mass storage device, it must follow the “CBW->data(in or out)->CSW” sequence.
But nowadsys, for USB3.0 mass storage device, there is a new protocol named UAS(USB attached SCSI, four bulk pipe used), which different from BOT, so the USBSTOR.sys could not used for UAS device.
So I have the qeustion, if the filter method could be used for UAS device?
I think compare to the second method “bus driver + disk driver(for LUN PDO)”, this method is more easy. Because you just need to deveop your own filter drivers, and don’t need to consider the creation of LUN PDO, loading the Disk.sys, and any other issues.
But I am wonder, the USBSTOR.sys only process for BOT case, when the device is UAS, how to route the IRP receive by lower filter of Disk.sys or uppter filter of USBSTOR.sys to the lower filter of USBSTOR.sys, by pass the USBSTOR.sys? And in the lower filter of usbstor.sys I could do some thing compitable to UAS.
If it is ok, so when the device is BOT, just let the IRPs route like the following:
disk.sys
|
lower filter of disk.sys or upper filter of usbstor.sys
|
usbstor.sys
|
lower filter of usbstor.sys
|
usbhub.sys
|
usbehci.sys
|
P C I Bus
|
Hardware
when the device is UAS, IRPs route like the following:
disk.sys
|
lower filter of disk.sys or upper filter of usbstor.sys
|
| (usbstor.sys is bypass)
|
lower filter of usbstor.sys
|
usbhub.sys
|
usbehci.sys
|
P C I Bus
|
Hardware
- I hear someone tell me, you should use upper filter driver of USBSTOR.SYS but not the lower filter driver of Disk.sys, his reason is that upper filter driver of USBSTOR.sys could queue the irps it received from upper level driver(in this case, the upper level driver is disk.sys, but I can not receive the IRP_MJ_SCSI from it, in question 1 ), but the lower filter driver of disk.sys could not queue the irps(while the lower filter driver of disk.sys could receive the IRP_MJ_SCSI from the upper level driver disk.sys)
Is his reason right, and if both the fitler driver could receive the IRP_MJ_SCSI, which is more suitable?
For bus driver+ disk.sys driver(For LUN PDO)
In windows, the native driver USBSTOR.sys act as the software bus driver, it create the PDO for every LUN.
I get a sample driver, some body maybe familiar with it.
I have the followint questions:
- I use the Enum.exe to trigger the PDO creation, I want to know, when and where is correct to create the PDO for LUN? Pls give me the detail.
- after I create a PDO, Pnp manager send a series of IRPs such as device IDs, compatible IDs , text, location, and so on. Because I want to load the Disk.sys driver for this PDO, so I return the compatible ID “USBSTOR\Disk”, using this method, the pnp manager load the Disk.sys for this PDO(is this method right?), and the PDO is listed in the “Disk drive” category in the Device manager tool, but it with the exclemation, which means the driver load unsuccessfully.
The bus driver print that: pnp start for the PDO, then the pnp remove for the PDO.
Any one could tell me ,what should I do to make this driver load successfully? - is this bus driver + disk.sys driver(for LUN PDO) method feasible for UAS driver?
4.Ones the disk.sys driver is loaded successfully, I think ,the bus driver could receive the SRBs from the DISK.SYS in this bus driver IRP_MJ_SCSI routin, is it right? - In fact, even though the disk.sys driver loading failed, but in the bus driver, I recevie a SRB SRB_FUNCTION_CLAIM_DEVICE, does it means, bus driver could receive the SRBs from the upper leverl disk.sys and what should I do for this SRB?
thank you,
Any suggestion is appreciated,
jeff