简体   繁体   English

Linux用户空间PCI驱动程序

[英]Linux user space PCI driver

I'm trying to write a PCI device driver that runs in user space. 我正在尝试编写一个在用户空间中运行的PCI设备驱动程序。 Not my idea, what the client wants. 不是我的想法,客户想要什么。 Target is an embedded Linux board that will never have more than a single user. Target是一个嵌入式Linux主板,永远不会只有一个用户。 I'm an experienced C programmer and know Linux, just not familiar with Linux driver development. 我是一名经验丰富的C程序员,熟悉Linux,不熟悉Linux驱动程序开发。

Is this really a device driver or just a library? 这真的是设备驱动程序还是只是一个库? Do I need to use the typical calls pci_register_driver, etc. or can I just access the device using fopen, and using mmap and ioperm to get to it? 我是否需要使用典型的调用pci_register_driver等,或者我可以使用fopen访问设备,并使用mmap和ioperm来访问它?

Interrupts will be done using the MSI model. 中断将使用MSI模型完成。 Also need to handle DMA transfers. 还需要处理DMA传输。 The device will be streaming lots of data to the user. 该设备将向用户传输大量数据。

There's not much info out there on this subject, LDD3 only devotes a couple of pages to it, and there's nothing else that I could find here on SO. 关于这个问题没有太多信息,LDD3只投入了几页,而且我在这里找不到任何其他内容。

Thanks in advance! 提前致谢!

If there is no driver handling the PCI card it would be possible to access it using ioperm (or iopl - depending on the address) if only port accesses are required. 如果没有处理PCI卡的驱动程序,如果只需要端口访问,则可以使用ioperm(或iopl - 取决于地址)访问它。

Using DMA and interrupts is definitely impossible without a kernel-mode driver. 没有内核模式驱动程序,绝对不可能使用DMA和中断。

By googleing I found some text about something like a "generic kernel-mode driver" that allows writing user-mode drivers (including DMA and interrupts). 通过googleing,我发现了一些类似于“通用内核模式驱动程序”的文本,它允许编写用户模式驱动程序(包括DMA和中断)。

You should ask your customer which kind of kernel-mode drivers for accessing PCI cards is installed on the Linux board. 您应该询问客户Linux板上安装了哪种内核模式驱动程序来访问PCI卡。

There is now a proper way to do high performance userspace PCI drivers, called vfio. 现在有一种适当的方法来执行高性能用户空间PCI驱动程序,称为vfio。 There is not much documentation, but see the kernel docs http://lxr.free-electrons.com/source/Documentation/vfio.txt and the header file /usr/include/linux.vfio.h. 文档不多,但请参阅内核文档http://lxr.free-electrons.com/source/Documentation/vfio.txt和头文件/usr/include/linux.vfio.h。 It is available since Linux 3.6. 它从Linux 3.6开始提供。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM