Can driver remember calling application's buffer address?
I'm writing a driver for Fedora. It's mostly working but I need to add a feature. My question relates to private or shared memory. I realize a driver may have a type of global [kernel] memory, which will be common to all the code in the driver regardless of which user application called it. I'm wondering if a driver may also have some [kernel] memory that's unique to the user application calling it. And then, or course, I believe I already know the driver can carefully access the user application's own memory.
Specifically, I want the user application to pass a buffer address to the driver, just as it would during a read() call. But for this special call, that will be implemented using a cover function over ioctl, I want the driver to SAVE the address of that buffer. This is going to be an auxiliary status buffer. Then, later, when the user application calls read() with a read buffer address, I want to not only copy_to_user the read data into the read buffer, I *also* want to copy_to_user some auxiliary information into that auxiliary buffer. In order to do this, of course, the driver needs to remember that buffer address. Also, I believe this code may get executed for multiple calling user applications, so the memory where the driver saves the buffer address needs to be unique per the caller. I believe it may somehow need to tie into the file handle or something. I don't know. I haven't researched too deeply into this yet. I haven't come up with good search keywords to find the info efficiently. So I'm asking here to get a head start... Thanks. |
Accessing Specific Memory Locations in C
How can you access a memory location using C? their are many more links within that page that may lead you to a better understanding of what it is you need to know as well. keywords used to find the links and others I did not look at where "memory accessing addresses" memory: because that is what you are working with. accessing addresses: because that is what you need to do with the memory. you could also add what programming language you are using to narrow it down more. I hope that helps |
Quote:
|
I think that should be tied to the process id, but probably misunderstood
|
Quote:
|
Quote:
|
That's definitely an architecture to be preferred. When an application program makes a system-call that refers to a specific (of course ...) virtual address, there's a really good chance that the real-memory pages in question are already available. In any case, the driver will have to force those pages to be resident and locked for the duration, and will have to wait for this if need be. In this scenario, actual waiting is unlikely ... and, because the process/thread is stopped, interference with the application program is much less likely. The application programmer is much less likely to encounter a race-condition, so debugging is much easier.
The nicest way to do it (IMHO ...) is to create a virtual device structure, which the user-land process of course must "open," which gives you a convenient per-process kernel memory area in which to store things. Let the user-land process then "explicitly rendezvous with" the kernel in order to request, and to receive at that moment, anything that it needs to receive. |
Quote:
|
All times are GMT -5. The time now is 02:48 PM. |