Why is the kernel driver model the way it is?
Hi,
I couldn't get to sleep last night, so I was thinking about this - to write a device driver, you need to INSMOD something into the kernel right? Well, why did they architecture it this way, instead of having a separate format for it, like Windows VxD or something? How does the insmodding work? A device driver would need the functionality to either write something TO the device, or read something FROM the device, right? Well, how exactly is it structured, i.e. how does the program hand the data to be written (for example) to the driver? And when something is read, how does it get it from the driver? Thanks a lot for your reply. |
Quote:
|
I think you are confusing the concept of loadable modules and passing data to/from the kernel/module. insmod or modprobe are used to load the kernel module (or rmmod, to unload it). Once the module is loaded into the kernel, it can serve it's function as a device driver. The device it writes to is probably some hardware, and it uses whatever means it needs to send & receive data to/from the device.
For communicating with the userspace side, the kernel provides all of the data, as arguments to the functions in the entry table. There are different collections of standard interfaces implemented by device drivers: character & block types, principally. These define a standard set of functions and arguments which your driver must provide and register upon loading. The kernel will dispatch to your driver functions according to the needs specified when a userspace application makes system calls. When appropriate, these functions will receive or send data, which may ultimately end up transferring to/from the userspace application (or maybe just to another driver; you don't need to care, the kernel figures it out). The link posted by jthill explains this quite well. --- rod. |
Quote:
http://tldp.org/LDP/lkmpg/2.6/html/lkmpg.html. Quote:
Quote:
|
Thanks so much for your reply.
Quote:
|
Have a look at the Documentation directory in the kernel sources for a description of how stuff works in the kernel.
The file pci.txt contains the details on how the bus probe works and how PCI id is used to load drivers. |
All times are GMT -5. The time now is 11:14 PM. |