lspci详解

lspci详解本文介绍了 Linux 命令 lspci 的作用 包括列出系统中 PCI 设备的详细信息 查看设备 ID 驱动程序和使用常用选项 帮助用户诊断和管理硬件

大家好,欢迎来到IT知识分享网。

lspci的作用

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

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

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

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

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

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

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

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

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

lspci查看设备

root@bsp:/home/bsp-server# lspci 00:00.0 Host bridge: Intel Corporation Sky Lake-E DMI3 Registers (rev 04) 00:04.0 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04) 00:04.1 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04) 00:04.2 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04) 00:04.3 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04) 00:04.4 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04) 00:04.5 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04) 00:04.6 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04) 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显示出来

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

lspci详解

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

厂商是Intel Corporation

设备类型是Sky Lake-E DMI3 Registers

版本是04

查看指定bdf设备,lspci -s

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

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

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

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

最多4个v

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

查看ID信息,lspci -n

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

查看寄存器值,lspci -x

最多可以使用4个x

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

查看树目录结构,lspci -tv

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

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

那就是使用setpci,下一篇见

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/122439.html

(0)
上一篇 2025-10-16 18:10
下一篇 2025-10-16 18:20

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信