Need help understanding how a device driver interacts with user space programs
I am having trouble understanding the way that a device driver interacts with user space. We are writing a char driver to send configuration information to a switch IC (ZL50408) in an embedded system, running uClinux on a NIOS2 processor.
Someone has contributed a large portion of the driver, but I am unsure of the way it operates. I know every driver has the init and cleanup/release functions, they work when we load the module, and we are able to access registers and read/set the values by placing code in the init function.
Once the module has been loaded, when are the other functions called? When a user space application attempts to write to the file in the /dev directory, I assume the write function specified in the file_operations structure is what is called?
The author of the driver has made two different file_operations structures
so I am confused how the kernel knows which one to use if there is only one entry in the /dev directory?
I am trying to write a user space application to test the driver, I simply want to write and read from a few registers. This is an example I found in a book and have been playing around with:
I am confused because the read function in our driver has 4 arguments:
Thanks, answers or hints to ANY of the above questions would be MUCH appreciated!!
Linux device driver programming can be a bit tricky. I would recommend you to read http://lwn.net/Kernel/LDD3/, or at least parts of it.
Now, about your questions, I would use the "ioctl" interface. For charachter device drivers this means a call that looks like:
You can find more infos and examples in Chapter 6 from the first link.
|All times are GMT -5. The time now is 01:31 AM.|