How can I get the PCI slot number?

Dear all:

I used a PCI card in my computer,and I wanted to get the PCI slot number through program.
[I know that this can be seen in device manager]

Addition:
There are two chips and a PCI standard PCI-to-PCI bridge in my card.
I want to get the handle of the PCI-to-PCI bridge in app also,
but how to determine the parameter ClassGuid[function is SetupDiGetClassDevs(LPGUID ClassGuid…)].
For chip it is easy,I can register a GUID in driver,but for PCI-to-PCI bridge,the driver pci.sys is offerd by MS.

Any help is appreciated.Thanks.

Best Regards
Zhou ChengJun

What do you want to do with the slot number? Many times it is wrong, the number reported by the hardware is not the same as the number printed on the motherboard itself. As for the handle to bridge, again what do want to accomplish once you pitentially ahve it? Pci.sys does not expose any ioctl or read or write support for user mode apps.

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@yahoo.com.cn
Sent: Tuesday, November 04, 2008 4:50 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] How can I get the PCI slot number?

Dear all:

I used a PCI card in my computer,and I wanted to get the PCI slot number through program.
[I know that this can be seen in device manager]

Addition:
There are two chips and a PCI standard PCI-to-PCI bridge in my card.
I want to get the handle of the PCI-to-PCI bridge in app also,
but how to determine the parameter ClassGuid[function is SetupDiGetClassDevs(LPGUID ClassGuid…)].
For chip it is easy,I can register a GUID in driver,but for PCI-to-PCI bridge,the driver pci.sys is offerd by MS.

Any help is appreciated.Thanks.

Best Regards
Zhou ChengJun


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

xxxxx@yahoo.com.cn wrote:

I used a PCI card in my computer,and I wanted to get the PCI slot number through program.
[I know that this can be seen in device manager]

Although I’m not sure it’s documented, you can get this (as far as the
system knows it) from the UINumber field in the
IRP_MN_QUERY_CAPABILITIES request.


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

>>What do you want to do with the slot number?

There are two cards in my computer.
One is a PCI card which have two chips and a PCI-to-PCI bridge,
another is a PCI-E card which have two same chips and a PCI-to-PCI Express bridge.
I want to distinguish which two chips is in PCI-E card from software layer.
[in app not in driver]

So I want to get the PCI slot number of all the chips and the two bridges.
If the chip’s PCI slot number is the same with the PCI-to-PCI Express bridge,
I can say that this chip is in PCI-E card.

In addition,is there a better method to distinguish
which two chips is in PCI-E card from software layer?

Any help is appreciated.Thanks.

Best Regards
Zhou ChengJun

UINumber relies on BIOS information and isn’t always provided. Relying on it won’t be a comprehensive solution.

Ideally there would be some clues in your driver to provide this. Otherwise, the BusNumber and Address capabilities can be queried from SetupDiGetDeviceRegistryProperty. If you know your device is multi-function, then you can figure out which ones share the same device number.

As Doron says, though, you should really not be using the address information for much. Bus number in particular can change over time, and you need to be prepared for that.

Dave

Thanks.
The BusNumber of the PCI-to-PCI Express bridge and the chips in the PCI-E card is not the same.
Only the the chip’s PCI slot number is the same with the PCI-to-PCI Express bridge if the chip is in the PCI-E card.
So is there a better method to distinguish
which two chips is in PCI-E card from software layer?

Any help is appreciated.Thanks.

Best Regards
Zhou ChengJun

xxxxx@yahoo.com.cn wrote:

The BusNumber of the PCI-to-PCI Express bridge and the chips in the PCI-E card is not the same.
Only the the chip’s PCI slot number is the same with the PCI-to-PCI Express bridge if the chip is in the PCI-E card.
So is there a better method to distinguish
which two chips is in PCI-E card from software layer?

Well, what’s the real problem here? I have been assuming that you are
talking about a quick hack for diagnostic use in a test lab somewhere,
in which case you should do whatever works. In real customer
situations, you aren’t likely to find a system that has both your PCI
version and your PCI-Express version in a single chassis, so this is not
something that you would ship in a commercial product anyway.


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

I understand what you’re trying to accomplish here, telling the difference
between the PCI and the PCIe versions of your parts. But why not just give
them separate Subsystem IDs and handle this the way that it was intended to
be handled? Set a registry key in your INF that varies based on Subsystem
IDs. Read the reg key in your driver.


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

This post implies no warranties and confers no rights.


wrote in message news:xxxxx@ntdev…
> Thanks.
> The BusNumber of the PCI-to-PCI Express bridge and the chips in the PCI-E
> card is not the same.
> Only the the chip’s PCI slot number is the same with the PCI-to-PCI
> Express bridge if the chip is in the PCI-E card.
> So is there a better method to distinguish
> which two chips is in PCI-E card from software layer?
>
> Any help is appreciated.Thanks.
>
> Best Regards
> Zhou ChengJun
>
>

>>But why not just give them separate Subsystem IDs and handle this the way that it was intended >>to be handled…

Thank you…
But I haven’t specify the Subsystem ID in advance.The cards is in used now.
Is there a way to distinguish which two chips is in PCI-E card from the point that one is use the PCI-to-PCI Express bridge and another is use the PCI-to-PCI bridge?

Any help is appreciated.Thanks.

Best Regards
Zhou ChengJun

xxxxx@yahoo.com.cn wrote:

>> But why not just give them separate Subsystem IDs and handle this the way that it was intended >>to be handled…

Thank you…
But I haven’t specify the Subsystem ID in advance.The cards is in used now.
Is there a way to distinguish which two chips is in PCI-E card from the point that one is use the PCI-to-PCI Express bridge and another is use the PCI-to-PCI bridge?

If all you want is to tell is the specific instance of your device PCI
or PCIe, maybe it is possible by looking at it’s config space
and compare?

–PA

Tim Roberts wrote:

Although I’m not sure it’s documented, you can get this (as far as the
system knows it) from the UINumber field in the
IRP_MN_QUERY_CAPABILITIES request.

Thanks.
I have tried this method to get the slot number of the chip in it’s driver.
But UINumber is 0xffffffff.
I just wondered how the device manager realized this?
[In device manager I can see the slot number if I have installed the driver]
It asked BIOS to get it?

Any help is appreciated.Thanks.

Best Regards
Zhou ChengJun