从SMBIOS了解段组、总线、设备和功能号

20

目标

我想通过编程的方式找出特定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.00000:04:02.20000:05:03.0的设备。通过手动检查,我了解到以下信息:
  1. 卡片0000:03:00.0位于第一插槽。PCI桥似乎是0000:00:02.0
  2. 卡片0000:04:00.0位于第二插槽。PCI桥似乎是0000:00:02.2
  3. 卡片0000:05:00.0位于第三插槽。PCI桥似乎是0000:00:03.0
所以这里出现了一个模式。从SMBIOS结构来看,总线号是插入卡片的编号,但设备/功能号与相应的PCI桥相同。
这个模式只是巧合还是有什么原因呢?这是一块华硕主板,带有AMI BIOS。我读到一些BIOS不能提供有关其插槽的准确信息,所以我想知道我能实现多少普适性。
任何提示或指向参考文档的指针也将不胜感激。

C2H5OH:你找到答案了吗? - Cooldharma06
我尝试过的方法似乎有效,但我只在三个主板上测试过。由于我不再需要在该项目上工作,因此我没有进一步调查。 - C2H5OH
1个回答

1
你可能会发现lspci命令很有用。以下是一个示例输出:
# lspci -v -t
-[0000:00]-+-00.0  Intel Corporation 5500 I/O Hub to ESI Port
           +-01.0-[01]--+-00.0  Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet
           |            \-00.1  Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet
           +-03.0-[02]--+-00.0  Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet
           |            \-00.1  Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet
           +-07.0-[04]----00.0  LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator]
           +-09.0-[05]----00.0  LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator]
           +-14.0  Intel Corporation 7500/5520/5500/X58 I/O Hub System Management Registers
           +-14.1  Intel Corporation 7500/5520/5500/X58 I/O Hub GPIO and Scratch Pad Registers
           +-14.2  Intel Corporation 7500/5520/5500/X58 I/O Hub Control Status and RAS Registers
           +-1a.0  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #4
           +-1a.1  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #5
           +-1a.7  Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #2
           +-1c.0-[03]----00.0  LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator]
           +-1d.0  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1
           +-1d.1  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2
           +-1d.7  Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1
           +-1e.0-[06]----03.0  Matrox Electronics Systems Ltd. MGA G200eW WPCM450
           +-1f.0  Intel Corporation 82801IB (ICH9) LPC Interface Controller
           \-1f.2  Intel Corporation 82801IB (ICH9) 2 port SATA Controller [IDE mode]

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接