I'm working on a driver-like code for a PCI device which. The communication is done through a buffer, i.e. I write to a buffer and device grabs data from it. Device writes to a buffer and I grad data from it. Here is where the problem occurs. In order for a device to write to this buffer it needs to have its physical address (not virtual one). My boss told me it is possible to do it if I write a kernel module and allocate memory using kmalloc
.
Here are my questions.
How do I get access to this buffer from a user space, i.e. how do I pass a pointer to this buffer from a kernel space to a user space? Since all addresses in user space are virtual addresses, how do I convert a physical pointer to this buffer to a virtual one? As far as I understand I need to use ioctl
but I don't how.
Any help is appreciated.