从 PCI/PCIE 卡读取芯片 ID

发布于 2024-08-02 01:56:35 字数 527 浏览 5 评论 0原文

几个月前,我必须编写一个小工具来对 rtl8139 卡的 eeprom 进行编程。 它基本上是用于读取/写入 eeprom 的 rtl8139-diag 工具。

现在必须扩展该工具才能对 rtl8101 卡的 eeprom 进行编程。 这不是问题,因为 eeprom 的接口与 rtl8139 的接口类似。 实际上,唯一的区别是 eeprom 文件的内容。

我想要实现的是自动检测,检查给定端口地址处的卡是否是 rtl8139 或 rtl8101,并选择合适的 eeprom 转储。 我无法通过读取 eeprom 来确定这些芯片的差异,因为要编程的卡是“原始”的,并且 eeprom 内容基本上是 0xffff

我注意到,Linux 总是加载这些卡的合适驱动程序,无论 eeprom 的内容如何。 所以我想,我只需要读取卡的芯片 ID 即可。

我怎么做?

A few months ago I had to write a small tool to program the eeprom of a rtl8139-card. It's basically the rtl8139-diag tool stripped down to read/write the eeprom.

This tool has to be extend to be able to program the eeprom of rtl8101-cards now. This was not a problem, as the interface to the eeprom is similar to the one of the rtl8139. Actually, the only difference is the contents of the eeprom-file.

What I want to implement is an auto-detection that checks, if the card at the given port-address is an rtl8139 or rtl8101 and selects the fitting eeprom-dump. I cannot determine the difference of these chips by reading out the eeprom as the cards to be programmed are 'virgin' and the eeprom-contents is basically 0xffff.

I noticed, that Linux always loads the fitting driver for these cards, regardless of the contents of the eeprom. So I think, that I just have to read the chip-id of the card.

How do I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清晰传感 2024-08-09 01:56:35

我想您可能会发现 lspcilspci -vv 会对您有所帮助。 (您可能需要 root 权限。)

也就是说,如果 PCI id 在卡中设置,而不是从 eeprom 确定,您应该能够使用 lspci 获取卡的 PCI id 并确定您正在使用哪张卡。

-n 选项将为您提供原始数字,如果您正在编写脚本,这可能会更有帮助。

或者,您可以从 /sys/devices/pci*/*/device 和vendor 中读取以查找这些值。

I think you may find lspci or lspci -vv will help you. (You may need to be root.)

That is, if the PCI id is set in the card, and not determined from the eeprom, you should be able to use lspci to get the card's PCI id and determine which card you're working with.

The -n option will give you the raw numbers, which will probably be more helpful if you're scripting this.

Alternatively, you could read from /sys/devices/pci*/*/device and vendor to find those values.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文