Linux中如何读取扩展PCIE配置空间?
我尝试过读取 /proc/bus/pci 目录下的用户空间 pci 条目并在驱动程序中调用内核空间 API pci_read_config_word() 。但似乎两者都只能读取pci基本配置空间,偏移量小于0x100。
我想读取的偏移量超出了0x100,谁能告诉我如何在Linux中做到这一点?如果在内核空间中完成,告诉调用哪个 API 将非常感激。非常感谢!
I've tried both reading userspace pci entry under /proc/bus/pci directory and calling kernel space API pci_read_config_word() in the driver. but it seems both can only read pci basic configuration space, offset less than 0x100.
The offset I want to read is beyond 0x100, could anyone tell me how to do it in Linux? if done in kernel space, telling which API to call would be very appreciated. Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
pci_read_config_word()
是正确的 API,但要访问扩展配置空间,您需要使用 MMCONFIG。这不是你设置的;如果可用,内核应选择自行使用 MMCONFIG。 看到类似的东西吗你在
/proc/iomem
中 ?另外,在内核日志中,您应该会看到一些有关 ACPI MCFG 表和 MMCONFIG 的行:当然,您的内核需要使用
CONFIG_PCI_MMCONFIG=y
构建。pci_read_config_word()
is the correct API, but to access extended configuration space you need to use MMCONFIG. This is not something you set up; the kernel should choose to use MMCONFIG by itself if available. Do you see anything likein
/proc/iomem
? Also in your kernel log, you should see some lines about the ACPI MCFG table and MMCONFIG:and of course your kernel needs to be built with
CONFIG_PCI_MMCONFIG=y
.我相信扩展配置空间对于非 root 用户是有限的,至少这是我在非 root 时执行
lspci
时面临的行为。您可以使用 sudo lspci -Qkxxxxnnv 查看所有 0xff0 (4080) 配置空间数据以及其他一些有用的内容。请参阅:PCI 配置空间
I believe that the extended configuration space is restricted for non-root users, at least that's the behaviour I face when executing
lspci
when not root. You can usesudo lspci -Qkxxxxnnv
to view all0xff0
(4080) configuration space data, and some other useful stuff.See: PCI Configuration Space