• lspci详解


    lspci的作用

    lspci是一个Linux命令,用于列出系统中的PCI总线设备信息。PCI(Peripheral Component Interconnect)是一种常见的计算机总线标准,用于连接各种外部设备(如网卡、显卡、声卡等)到计算机主板上。

    通过运行lspci命令,可以查看系统中安装的PCI设备的详细信息,包括设备的厂商信息、设备ID、驱动程序信息等。lspci命令通常在终端中执行,不需要特殊的权限。

    以下是lspci命令的一些常用选项:

    -v:显示更详细的设备信息,包括设备的IRQ、I/O端口等。

    -nn:显示设备的厂商和设备ID。

    -k:显示设备对应的内核模块(驱动程序)信息。

    -s :仅显示指定PCI插槽的设备信息。

    通过`lspci`命令,您可以快速了解系统中安装的PCI设备,有助于识别设备、查找驱动程序以及进行系统调试和故障排除。

    1. root@velinux:~# lspci help
    2. Usage: lspci [<switches>]
    3. Basic display modes:
    4. -mm Produce machine-readable output (single -m for an obsolete format)
    5. -t Show bus tree
    6. Display options:
    7. -v Be verbose (-vv for very verbose)
    8. -k Show kernel drivers handling each device
    9. -x Show hex-dump of the standard part of the config space
    10. -xxx Show hex-dump of the whole config space (dangerous; root only)
    11. -xxxx Show hex-dump of the 4096-byte extended config space (root only)
    12. -b Bus-centric view (addresses and IRQ's as seen by the bus)
    13. -D Always show domain numbers
    14. Resolving of device ID's to names:
    15. -n Show numeric ID's
    16. -nn Show both textual and numeric ID's (names & numbers)
    17. -q Query the PCI ID database for unknown ID's via DNS
    18. -qq As above, but re-query locally cached entries
    19. -Q Query the PCI ID database for all ID's via DNS
    20. Selection of devices:
    21. -s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]] Show only devices in selected slots
    22. -d [<vendor>]:[<device>][:<class>] Show only devices with specified ID's
    23. Other options:
    24. -i Use specified ID database instead of /usr/share/misc/pci.ids.gz
    25. -p Look up kernel modules in a given file instead of default modules.pcimap
    26. -M Enable `bus mapping' mode (dangerous; root only)
    27. PCI access options:
    28. -A <method> Use the specified PCI access method (see `-A help' for a list)
    29. -O = Set PCI access parameter (see `-O help' for a list)
    30. -G Enable PCI access debugging
    31. -H <mode> Use direct hardware access (<mode> = 1 or 2)
    32. -F <file> Read PCI configuration dump from a given file

    lspci查看设备

    1. root@bsp:/home/bsp-server# lspci
    2. 00:00.0 Host bridge: Intel Corporation Sky Lake-E DMI3 Registers (rev 04)
    3. 00:04.0 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
    4. 00:04.1 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
    5. 00:04.2 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
    6. 00:04.3 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
    7. 00:04.4 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
    8. 00:04.5 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
    9. 00:04.6 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
    10. 00:04.7 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)

    以第一条为例子:

    00:00.0 Host bridge: Intel Corporation Sky Lake-E DMI3 Registers (rev 04)

    00:00.0表示连接到PCI总线0、插槽0、功能0的PCI设备。通常情况下,PCI设备的地址格式为<总线号>:<插槽号>.<功能号>,用于唯一标识系统中的PCI设备。

    • 0000:00:00.0 中的0000代表PCI域号,用于区分不同的PCI域。在大多数情况下,都是0000,在没有别的域的情况下不会显示出来

    可以通过lspci -D显示出来

    1. root@bsp:/home/bsp-server# lspci -d 14e4:168e -D
    2. 0000:12:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)
    3. 0000:12:00.1 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)

    Host bridge是主机桥接器,用于连接CPU和其他系统组件

    厂商是Intel Corporation

    设备类型是Sky Lake-E DMI3 Registers

    版本是04

    查看指定bdf设备,lspci -s

    1. root@bsp:/home/bsp-server# lspci -s 12:00.0
    2. 12:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)

    查看指定id的pci设备,lspci -d

    1. root@bsp:/home/bsp-server# lspci -d 14e4:168e
    2. 12:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)
    3. 12:00.1 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)

    lspci -v查看更加详细的信息

    最多4个v

    1. root@bsp:/home/bsp-server# lspci -s 12:00.0 -v
    2. 12:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)
    3. Subsystem: Hewlett-Packard Company Ethernet 10Gb 2-port 530SFP+ Adapter
    4. Physical Slot: 1
    5. Flags: bus master, fast devsel, latency 0, IRQ 26, NUMA node 0
    6. Memory at df800000 (64-bit, prefetchable) [size=8M]
    7. Memory at e0000000 (64-bit, prefetchable) [size=8M]
    8. Memory at e0810000 (64-bit, prefetchable) [size=64K]
    9. Expansion ROM at de400000 [virtual] [disabled] [size=512K]
    10. Capabilities: [48] Power Management version 3
    11. Capabilities: [50] Vital Product Data
    12. Capabilities: [58] MSI: Enable- Count=1/8 Maskable- 64bit+
    13. Capabilities: [a0] MSI-X: Enable+ Count=32 Masked-
    14. Capabilities: [ac] Express Endpoint, MSI 00
    15. Capabilities: [100] Advanced Error Reporting
    16. Capabilities: [13c] Device Serial Number b4-7a-f1-ff-fe-72-c3-40
    17. Capabilities: [150] Power Budgeting <?>
    18. Capabilities: [160] Virtual Channel
    19. Capabilities: [1b8] Alternative Routing-ID Interpretation (ARI)
    20. Capabilities: [220] Physical Resizable BAR
    21. Capabilities: [300] Secondary PCI Express
    22. Kernel driver in use: bnx2x
    23. Kernel modules: bnx2x

    查看ID信息,lspci -n

    1. root@bsp:/home/bsp-server# lspci -s 12:00.0 -n
    2. 12:00.0 0200: 14e4:168e (rev 10)
    3. root@bsp:/home/bsp-server# lspci -s 12:00.0 -nn
    4. 12:00.0 Ethernet controller [0200]: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet [14e4:168e] (rev 10)

    查看寄存器值,lspci -x

    最多可以使用4个x

    1.  root@bsp:/home/bsp-server# lspci -s 12:00.0 -x
    2. 12:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)
    3. 00: e4 14 8e 16 46 05 10 00 10 00 00 02 10 00 80 00
    4. 10: 0c 00 80 df 00 00 00 00 0c 00 00 e0 00 00 00 00
    5. 20: 0c 00 81 e0 00 00 00 00 00 00 00 00 3c 10 9d 33
    6. 30: 00 00 00 00 48 00 00 00 00 00 00 00 ff 01 00 00

    查看树目录结构,lspci -tv

    1. root@bsp:/home/bsp-server# lspci -tv
    2. -+-[0000:d7]-+-00.0-[d8]--
    3. | +-05.0 Intel Corporation Sky Lake-E VT-d
    4. | \-16.4 Intel Corporation Sky Lake-E M2PCI Registers
    5. +-[0000:ae]-+-00.0-[af]--
    6. | +-05.0 Intel Corporation Sky Lake-E VT-d

    这里只有读取pci设备,那怎么去写呢?

    那就是使用setpci,下一篇见

  • 相关阅读:
    更新andriod studio版本,项目编译报could not find org.junit.jupiter:junit-jupiter
    【MFC】Button控件美化(自绘)
    C#WPFPrism框架模块化应用实例
    道可云元宇宙每日资讯|中国移动启动算网大脑“天穹”全网试商用
    力扣第232题“用栈实现队列”
    机器学习 面试/笔试题(更新中)
    嵌入式linux系统中图片处理详解
    使用米联客FPGA开发板进行光口开发时遇到的问题总结
    【JVM笔记】异常处理字节码指令
    【PickerView案例12-info_plist-PCH文件介绍 Objective-C语言】
  • 原文地址:https://blog.csdn.net/weixin_38452632/article/details/136633239