lspci源码

lspci

显示Linux系统的pci设备最简单的方法就是使用lspci命令,前提是要安装pciutils包(centos在最小化安装时不会自带该包,需要自己下载安装)

pciutils包的源码github地址为: https://github.com/pciutils/pciutils

从该项目的README文件可以知道,其主要提供三个命令:lspci、setpci和update-pciids。

  • lspci: displays detailed information about all PCI buses and devices.

  • setpci: allows to read from and write to PCI device configuration

registers. For example, you can adjust the latency timers with it.

CAUTION: There is a couple of dangerous points and caveats, please read

the manual page first!

  • update-pciids: download the current version of the pci.ids file.

update-pciids命令会从网上更新pci.ids文件,该文件包含着pci设备的vendor id和device id 与厂商名称、型号名称的对应关系,一旦更改该文件那么lspcishow出来的东西就会发生变化。

不同Linux发行版本的pci.ids文件的位置有所不同,比如centos一般在/usr/share/hwdata/pci.ids,而Debian一般在/usr/share/misc/pci.ids,lspci命令的路径一般在centos下的/usr/sbin/lspci,而在Debian下一般为/use/bin/lspci,update-pciids一般在/usr/sbin/update-pciids,这些路径如果是手动编译安装pciutils则可以自行定制,关于如何编译安装可参考pciutils-3.6.2。

同样,不同发行版本的pciutils也有差异,比如centos的update-pciids和Debian的 update-pciids是有区别的,最重要的区别在于其pci.ids更新的源不同

在Debian中:

#!/bin/sh

#URL="http://pci-ids.ucw.cz/pci.ids"

URL="http://pciids.sourceforge.net/v2.2/pci.ids"

FILE=/usr/share/misc/pci.ids

在centos中:

#!/bin/sh

"$1" = "-q" && quiet=true || quiet=false

set -e

SRC="http://pci-ids.ucw.cz/v2.2/pci.ids"

DEST=/usr/share/hwdata/pci.ids

在Linux的源码中也有一个名为include/linux/pci_ids.h的头文件,该文件的内容定义了各个pci设备vendor_id和device_id.

同样在qemu中也存在这么一个头文件,里面也是定义了各个pci设备vendor_id和device_id.

相关推荐
GeW8 分钟前
RHCE快速拿证全攻略:考点拆解+实验强化+时间规划,一次通关
linux
沸速存储1 小时前
AI 机器人靠哪些内存与存储驱动整机运行?
服务器·科技·嵌入式硬件·电脑
码农小韩1 小时前
Linux应用开发(八)——TCP/IP网络编程基础
linux·嵌入式软件开发·linux操作系统·嵌入式操作系统·linux网络编程·linux应用
迷途之人不知返1 小时前
【进程】-5-进程优先级
linux
fengyehongWorld2 小时前
Linux squid搭建基础代理服务器
linux·运维·服务器
木白CPP2 小时前
Linux DMA驱动详解(二)-----DMA的使用者
java·linux·运维
赵民勇2 小时前
systemd-socket-activate命令详解
linux·运维
Cx330❀3 小时前
【Linux网络】网络层 IP 协议:从网段划分到内核源码解析
大数据·linux·服务器·网络·tcp/ip·性能优化·langchain
企鹅的蚂蚁3 小时前
LubanCat RK3588 实时 Linux 开发(七):YT6801 PCIe 网卡驱动移植与 vermagic 排查
linux·rk3588·linux驱动·yt6801·pcie网卡·vermagic
DYWorker0013 小时前
Linux驱动子系统:DMA子系统 —— Consumer和Provider(006)
linux·驱动开发