如何获取与 pci 设备相关的总线号列表?

如何获取与 pci 设备相关的总线号列表?

我正在尝试获取 Windows 系统上所有 PCI 相关总线的列表。我知道我可以使用 wmic 或 devcon 来获取所有设备的列表,但我该如何确定它们各自的总线呢?

编辑:最好不要使用第三方软件

此信息可通过注册表获取:

在此处输入图片描述

答案1

我最终使用一个简短的脚本使用 reg.exe 来查看注册表中的 PCI 设备列表。感谢您的所有建议。

编辑:这里是给大家的:https://gist.github.com/anonymous/c59b373ef320c9697710

答案2

Win32_PnPEntity在WMI 类中也可以找到相同的参数:

PS C:\Users\Administrator> (gwmi win32_pnpEntity -Filter 'manufacturer like "Red Hat%"')[5].getDeviceProperties().deviceproperties | ft keyName,data

keyName                                        data
-------                                        ----
DEVPKEY_Device_DeviceDesc                      Red Hat VirtIO Ethernet Adapter
DEVPKEY_Device_HardwareIds                     {PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00, PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4, PCI\VEN_1AF4&DEV_1000&CC_020000, PCI\VEN_1AF4&DEV_1000&CC_0200}
DEVPKEY_Device_CompatibleIds                   {PCI\VEN_1AF4&DEV_1000&REV_00, PCI\VEN_1AF4&DEV_1000, PCI\VEN_1AF4&CC_020000, PCI\VEN_1AF4&CC_0200...}
DEVPKEY_Device_Service                         netkvm
DEVPKEY_Device_Class                           Net
DEVPKEY_Device_ClassGuid                       {4D36E972-E325-11CE-BFC1-08002BE10318}
DEVPKEY_Device_Driver                          {4d36e972-e325-11ce-bfc1-08002be10318}\0006
DEVPKEY_Device_ConfigFlags                     0
DEVPKEY_Device_Manufacturer                    Red Hat, Inc.
DEVPKEY_Device_FriendlyName                    Red Hat VirtIO Ethernet Adapter #6
DEVPKEY_Device_LocationInfo                    PCI bus 0, device 17, function 0
DEVPKEY_Device_PDOName                         \Device\NTPNP_PCI0011
DEVPKEY_Device_Capabilities                    0
DEVPKEY_Device_BusTypeGuid                     {C8EBDFB0-B510-11D0-80E5-00A0C92542E3}
DEVPKEY_Device_LegacyBusType                   5
DEVPKEY_Device_BusNumber                       0
DEVPKEY_Device_EnumeratorName                  PCI
DEVPKEY_Device_Address                         1114112
DEVPKEY_Device_PowerData                       {56, 0, 0, 0...}
DEVPKEY_Device_RemovalPolicy                   1
DEVPKEY_Device_RemovalPolicyDefault            1
DEVPKEY_Device_InstallState                    0
DEVPKEY_Device_BaseContainerId                 {00000000-0000-0000-FFFF-FFFFFFFFFFFF}
DEVPKEY_NAME                                   Red Hat VirtIO Ethernet Adapter #6
DEVPKEY_Device_InstanceId                      PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&88
DEVPKEY_Device_DevNodeStatus                   25174026
DEVPKEY_Device_ProblemCode                     0
DEVPKEY_Device_Parent                          ACPI\PNP0A03\0
DEVPKEY_Device_Siblings                        {PCI\VEN_8086&DEV_1237&SUBSYS_00000000&REV_02\3&267a616a&0&00, PCI\VEN_8086&DEV_7000&SUBSYS_00000000&REV_00\3&267a616a&0&08, PCI\VEN_80EE&DEV_BEEF&SUBSYS_00000000&REV_00\3&267a616a&0&10, PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267a616a&0&18...}
DEVPKEY_Device_SafeRemovalRequired             False
DEVPKEY_Device_ContainerId                     {00000000-0000-0000-FFFF-FFFFFFFFFFFF}
DEVPKEY_Device_IsPresent                       True
DEVPKEY_Device_HasProblem                      False
{83DA6326-97A6-4088-9453-A1923F573B29} 15      True
DEVPKEY_Device_IsRebootRequired                False
DEVPKEY_Device_ReportedDeviceIdsHash           1342956424
DEVPKEY_Device_InLocalMachineContainer         True
DEVPKEY_Device_Stack                           {\Driver\netkvm, \Driver\pci}
{A8B865DD-2E3D-4094-AD97-E593A70C75D6} 26      False
{3464F7A4-2444-40B1-980A-E0903CB6D912} 10      2
DEVPKEY_PciDevice_DeviceType                   0
DEVPKEY_PciDevice_CurrentSpeedAndMode          0
DEVPKEY_PciDevice_BaseClass                    2
DEVPKEY_PciDevice_SubClass                     0
DEVPKEY_PciDevice_ProgIf                       0
DEVPKEY_PciDevice_InterruptSupport             1
DEVPKEY_PciDevice_BarTypes                     1
DEVPKEY_PciDevice_S0WakeupSupported            True
DEVPKEY_PciDevice_RequiresReservedMemoryRegion False
DEVPKEY_Device_BusReportedDeviceDesc           Ethernet Controller
DEVPKEY_Device_ConfigurationId                 oem2.inf:PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00,kvmnet6.ndi
{80497100-8C73-48B9-AAD9-CE387E19C56E} 6       6
{83DA6326-97A6-4088-9453-A1923F573B29} 3       oem2.inf:664f42767dbc5606:kvmnet6.ndi:100.74.104.14100:PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00
{83DA6326-97A6-4088-9453-A1923F573B29} 10      ACPI\PNP0A03\0
{83DA6326-97A6-4088-9453-A1923F573B29} 18      0
DEVPKEY_Device_InstallDate                     20190404180902.239000-420
DEVPKEY_Device_FirstInstallDate                20190404174841.372159-420
DEVPKEY_Device_LastArrivalDate                 20190416120950.133039-420
DEVPKEY_Device_LocationPaths                   {PCIROOT(0)#PCI(1100), ACPI(_SB_)#ACPI(PCI0)#PCI(1100)}
DEVPKEY_Device_DriverDate                      20170718170000.000000-420
DEVPKEY_Device_DriverVersion                   100.74.104.14100
DEVPKEY_Device_DriverDesc                      Red Hat VirtIO Ethernet Adapter
DEVPKEY_Device_DriverInfPath                   oem2.inf
DEVPKEY_Device_DriverInfSection                kvmnet6.ndi
DEVPKEY_Device_MatchingDeviceId                PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00
DEVPKEY_Device_DriverProvider                  Red Hat, Inc.
DEVPKEY_Device_DriverRank                      16711680
{F0E20F09-D97A-49A9-8046-BB6E22E6BB2E} 2       {1, 0, 0, 0...}

设备编号和功能编号可以在DEVPKEY_Device_LocationInfo和中找到DEVPKEY_Device_Address

PS C:\Users\Administrator> (gwmi Win32_Bus -Filter 'DeviceID like "PCI%"').GetRelated('Win32_PnPEntity').GetDeviceProperties('DEVPKEY_Device_Address').deviceProperties | ft DeviceID,keyName,{$_.data -shr 16},{$_.data -band 0xFFFF}

DeviceID                                                     keyName                $_.data -shr 16 $_.data -band 0xFFFF
--------                                                     -------                --------------- --------------------
PCI\VEN_8086&DEV_7000&SUBSYS_00000000&REV_00\3&267A616A&0&08 DEVPKEY_Device_Address               1                    0
PCI\VEN_80EE&DEV_CAFE&SUBSYS_00000000&REV_00\3&267A616A&0&20 DEVPKEY_Device_Address               4                    0
PCI\VEN_8086&DEV_2829&SUBSYS_00000000&REV_02\3&267A616A&0&68 DEVPKEY_Device_Address              13                    0
PCI\VEN_8086&DEV_1237&SUBSYS_00000000&REV_02\3&267A616A&0&00 DEVPKEY_Device_Address               0                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&18 DEVPKEY_Device_Address               3                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&40 DEVPKEY_Device_Address               8                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&48 DEVPKEY_Device_Address               9                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&50 DEVPKEY_Device_Address              10                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&80 DEVPKEY_Device_Address              16                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&88 DEVPKEY_Device_Address              17                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&90 DEVPKEY_Device_Address              18                    0
PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00\3&267A616A&0&98 DEVPKEY_Device_Address              19                    0
PCI\VEN_80EE&DEV_BEEF&SUBSYS_00000000&REV_00\3&267A616A&0&10 DEVPKEY_Device_Address               2                    0

答案3

听起来你需要类似 lspci 的东西,但适用于 Windows。如果是这样,请查看“SMI”和其他答案Windows 上的 lspci 等效项?

答案4

你也可以尝试这个:

  1. 打开设备管理器。(您可以在运行时输入 devmgmt.msc 来执行此操作)。
  2. 单击网络适配器。
  3. 选择您要调试的适配器。(如果只有一个,显然您将没有任何选择)。
  4. 右键单击您选择的适配器,然后单击“属性”。
  5. 单击“详细信息”选项卡。
  6. 在属性下拉框中,选择位置信息。这将在一个位置显示总线编号、设备编号和功能编号的值。

相关内容