小编use*_*930的帖子

PCIe驱动程序 - 用户空间如何访问它?

我正在为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子系统,如音频,以太网等.

linux linux-device-driver linux-kernel pci-e userspace

6
推荐指数
1
解决办法
2551
查看次数

Using "extern C" on non function call related declarations

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: …

c c++ enums ioctl extern

5
推荐指数
1
解决办法
552
查看次数

PCIe - DMA:一致与流式内存

目前,我正在为 Linux 的 PCIe 驱动程序添加 DMA。当我阅读文档时,它通过使用 API 提到了一致或连贯的内存:

pci_set_consistent_dma_mask(...)
Run Code Online (Sandbox Code Playgroud)

但从来没有真正谈论过为什么要使用它或它的作用。似乎提到调用该函数以获得最佳实践和未来证明。我能收集到的最好结果是一致的 DMA 内存没有缓存效果,并且一旦正确设置(假设我正确读取),内存就会在设备(FPGA)和 CPU 之间写入,无需任何软件/驱动程序干预。所以我的问题是:

  1. 假设 PCIe 设备不需要一致的内存,那么为什么会有人使用它,或者在什么情况下使用一致的内存?
  2. 如果我使用一致的内存,那么我是否不需要在 PCIe 驱动程序中为 DMA 实现中断?如果为真,那么用户空间代码和设备如何知道传输已发生?
  3. 如果我连续传输很多小数据包,大约 50 字节,有时传输更大的数据包,大约 6 kB,哪种 DMA 内存更好:一致还是流式传输?

linux memory driver dma pci-e

3
推荐指数
1
解决办法
2139
查看次数

标签 统计

linux ×2

pci-e ×2

c ×1

c++ ×1

dma ×1

driver ×1

enums ×1

extern ×1

ioctl ×1

linux-device-driver ×1

linux-kernel ×1

memory ×1

userspace ×1