lspci源码

21 篇文章 244 订阅

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.
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

咸鱼弟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值