3 points · by keeplight · 10y ago · 1 comment
I have a dillema about device drivers written for an embedded linux. So, as far as I know, a device driver lies in kernel space and it creates a node under the /dev file system, through which the user can access a physical device ( theoretically). Now, what exactly defines a device driver? I see this like layered structure. Starting from bottom, we have a physical device (GPS,GSM,or any kind of device connected to a board).An upper layer we have the core (those interfaces which implements the protocols like I2C,UART,and so on).An upper layer is so called the device driver which uses the sub-layer (core) to communicate with the physical device.Both the newly created device driver and the I2C, UART, SPI and so on, creates a node under /dev. Now, do we need to create a device driver which uses the core library as long as it exposes its data to user space ?I mean, in this case we can use an user space application which plays the role of the driver reading/writing to /dev/Ttyxx ?
Please give me a clear picture about device driver.
Thank you, Best Regards,
All that said, to answer your question in brief, you have the right idea - even within the device driver layer you have various levels of abstraction. Whether you ultimately choose a certain level of abstraction is really specific to what you would like to do. If you find that an existing kernel module that provides a easy to work with interface via a device node, just make a userspace tool or library to suit your needs, if not, create your own kernel module.