Are there any way to get the VEN & DEV ID of specified PCI device?

Dear all,
I am developing a windows driver (for windows XP sp2), which may driving two diffrence/similar PCI bus device. Now the problem is how can I determine which type of device I am driving now? I think I can make sure it via detecting the VEN&DEV ID of the specified device in my driver. But I don’t know how to do this. I am check the structure CM_PARTIAL_RESOURCE_DESCRIPTOR (which be used in IRP_MJ_PNP dispach routine) and found nothing…
Can any one give me a tips,Thank a lot.
Yours,
Gamma Folk

>

Dear all,
I am developing a windows driver (for windows XP sp2), which
may
driving two diffrence/similar PCI bus device. Now the problem is how
can I
determine which type of device I am driving now? I think I can make
sure it
via detecting the VEN&DEV ID of the specified device in my driver. But
I don’t
know how to do this. I am check the structure
CM_PARTIAL_RESOURCE_DESCRIPTOR
(which be used in IRP_MJ_PNP dispach routine) and found nothing…
Can any one give me a tips,Thank a lot.

In your inf file you can have different install sections for each
device, and they can add a registry key to identify the device added
which your driver can then read on adddevice. Have a look in cdrom.inf
(or probably just about any inf file) for an example.

Also you could use IoGetDeviceProperty with maybe
DevicePropertyHardwareID or DevicePropertyCompatibleIDs and parse the
output of that.

I think the first idea would be better as it involves less parsing of
strings which may not necessarily be ‘future proof’ for future versions
of windows.

James

Alternatively, read the PCI config space of your device:

http://support.microsoft.com/kb/253232

Good luck,

Ilya Faenson
Rockville MD USA

Thank James Harper. Thank Ilya faenson, you both are helpful.
They are the just I needed. Thank you very much.

Yours ,
Gamma Folk

Let me amplify this a little bit. I believe that your driver shouldn’t be
written in such a way that it has any code within that IDs the specific
device. It should, instead, be driven by a set of registry keys that change
specific aspects of its behavior.

Then, in your INF, you set the “behavior switches” for each version of your
device. Then, if a new version of the device comes out, or if somebody
integrates your device into a new subsystem, you might not need to change
the driver at all. Just put in a new INF section with the right behavior
switches.


Jake Oshins
Hyper-V I/O Architect
Windows Kernel Group

This post implies no warranties and confers no rights.


“James Harper” wrote in message
news:xxxxx@ntdev…
>>
>> Dear all,
>> I am developing a windows driver (for windows XP sp2), which
> may
>> driving two diffrence/similar PCI bus device. Now the problem is how
> can I
>> determine which type of device I am driving now? I think I can make
> sure it
>> via detecting the VEN&DEV ID of the specified device in my driver. But
> I don’t
>> know how to do this. I am check the structure
> CM_PARTIAL_RESOURCE_DESCRIPTOR
>> (which be used in IRP_MJ_PNP dispach routine) and found nothing…
>> Can any one give me a tips,Thank a lot.
>
> In your inf file you can have different install sections for each
> device, and they can add a registry key to identify the device added
> which your driver can then read on adddevice. Have a look in cdrom.inf
> (or probably just about any inf file) for an example.
>
> Also you could use IoGetDeviceProperty with maybe
> DevicePropertyHardwareID or DevicePropertyCompatibleIDs and parse the
> output of that.
>
> I think the first idea would be better as it involves less parsing of
> strings which may not necessarily be ‘future proof’ for future versions
> of windows.
>
> James
>

Thank Jake Oshins, does you means that I would write different driver for each driver? Yes, I thank it is a good way(and perhaps the right way), thank you very much.

>

Thank Jake Oshins, does you means that I would write different driver
for each
driver? Yes, I thank it is a good way(and perhaps the right way),
thank you
very much.

I think only if the devices are actually substantially different. If
there is only a small difference (eg DEV_ID 0001 and DEV_ID 0002 have
slightly different timing requirements for a reset operation) then you
use the inf file to write a registry setting to indicate that.

I can’t remember if you can write such entries in text mode setup
though…

James

Hi James,

I have the same problem. I have a driver which supports two devices and
I use IoGetDeviceProperty to get the HardwareID and parse them to get
the VendorID and Device ID.

But the INF solution seems to be much more clean. Can you explain a
bit further on how to identify the regsitry key that you added in the INF
file in AddDevice? Is it through DriverObject->HardwareDatabase?

Regards,
Shan

In your inf file you can have different install sections for each
device, and they can add a registry key to identify the device added
which your driver can then read on adddevice. Have a look in cdrom.inf
(or probably just about any inf file) for an example.

Also you could use IoGetDeviceProperty with maybe
DevicePropertyHardwareID or DevicePropertyCompatibleIDs and parse the
output of that.

I think the first idea would be better as it involves less parsing of
strings which may not necessarily be ‘future proof’ for future versions
of windows.

James

xxxxx@gmail.com wrote:

I have the same problem. I have a driver which supports two devices and
I use IoGetDeviceProperty to get the HardwareID and parse them to get
the VendorID and Device ID.

But the INF solution seems to be much more clean. Can you explain a
bit further on how to identify the regsitry key that you added in the INF
file in AddDevice? Is it through DriverObject->HardwareDatabase?

IoOpenDeviceRegistryKey. You can choose whether to open the
device-specific hardware key (in Enum) or the driver key (in Services).


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

> I use IoGetDeviceProperty to get the HardwareID and parse them to get

the VendorID and Device ID.

Is there any need to parse? Why not compare the whole ID string to the hardcoded value in general?

Compatible IDs also help a lot.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

> I use IoGetDeviceProperty to get the HardwareID and parse them to get

the VendorID and Device ID.

Is there any need to parse? Why not compare the whole ID string to the hardcoded
value in general?

Compatible IDs also help a lot.
Yes you are right. I can just do a memcmp with the hardcoded value.:slight_smile:

IoOpenDeviceRegistryKey. You can choose whether to open the
device-specific hardware key (in Enum) or the driver key (in Services).

Thanks Tim. Will try this as well.