我正在为Linux编写PCIe驱动程序,目前没有DMA,并且需要知道从用户空间启用后如何读取和写入PCIe设备.
在驱动程序中,我在probe()中执行基础知识:
pci_enable_device();
pci_request_regions();
pci_iomap();
Run Code Online (Sandbox Code Playgroud)
但是,如何从用户空间访问此内存以进行读写?我是否将文件操作添加到PCIe驱动程序?来自pci_iomap的内存是否显示用户空间代码可以调用的位置:
open('mapped memory location');
mmap(...);
Run Code Online (Sandbox Code Playgroud)
如果是的话那么位置是什么?
注意: PCIe设备不会插入任何Linux子系统,如音频,以太网等.
I know questions regarding extern "C"
have been asked before but I am getting mixed signals and would like it if someone could point me to what the best practice is in the scenario below. I have written a driver for Linux and have several struct
defined as well as some _IO
, _IOR
, and _IOW
definitions for ioctl(...)
calls. None of my structures contain any functions, below is an example struct
, enum
and ioctl
that I use: …
目前,我正在为 Linux 的 PCIe 驱动程序添加 DMA。当我阅读文档时,它通过使用 API 提到了一致或连贯的内存:
pci_set_consistent_dma_mask(...)
Run Code Online (Sandbox Code Playgroud)
但从来没有真正谈论过为什么要使用它或它的作用。似乎提到调用该函数以获得最佳实践和未来证明。我能收集到的最好结果是一致的 DMA 内存没有缓存效果,并且一旦正确设置(假设我正确读取),内存就会在设备(FPGA)和 CPU 之间写入,无需任何软件/驱动程序干预。所以我的问题是: