目标
我想通过编程的方式找出特定PCIe设备连接到哪个物理插槽上。前提是我有一张卡的PCI-ID,可以确定它占据了一个插槽,解决方案是找出它连接的是哪个插槽。
请注意,我只对PCI Express总线感兴趣,尽管我认为设备识别/枚举过程与旧PCI相同。
尝试
SMBIOS包含有关可用主板插槽的信息。可以从Linux命令行检查此信息:
$ sudo dmidecode -t slot
# dmidecode 2.11
SMBIOS 2.7 present.
Handle 0x003A, DMI type 9, 17 bytes
System Slot Information
Designation: PCIEX16_1
Type: x16 PCI Express x16
Current Usage: In Use
Length: Short
ID: 1
Characteristics:
3.3 V is provided
Opening is shared
PME signal is supported
Bus Address: 0000:03:02.0
Handle 0x003B, DMI type 9, 17 bytes
System Slot Information
Designation: PCIEX16_2
Type: x8 PCI Express x8
Current Usage: In Use
Length: Short
ID: 2
Characteristics:
3.3 V is provided
Opening is shared
PME signal is supported
Bus Address: 0000:04:02.2
Handle 0x003C, DMI type 9, 17 bytes
System Slot Information
Designation: PCIEX16_3
Type: x16 PCI Express x16
Current Usage: In Use
Length: Short
ID: 3
Characteristics:
3.3 V is provided
Opening is shared
PME signal is supported
Bus Address: 0000:05:03.0
然而,在PCI总线(
lspci
)中,我找不到任何具有PCI ID 0000:03:02.0
、0000:04:02.2
或0000:05:03.0
的设备。通过手动检查,我了解到以下信息:
- 卡片
0000:03:00.0
位于第一插槽。PCI桥似乎是0000:00:02.0
- 卡片
0000:04:00.0
位于第二插槽。PCI桥似乎是0000:00:02.2
- 卡片
0000:05:00.0
位于第三插槽。PCI桥似乎是0000:00:03.0
这个模式只是巧合还是有什么原因呢?这是一块华硕主板,带有AMI BIOS。我读到一些BIOS不能提供有关其插槽的准确信息,所以我想知道我能实现多少普适性。
任何提示或指向参考文档的指针也将不胜感激。