LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Creating Driver (http://www.linuxquestions.org/questions/linux-kernel-70/creating-driver-4175423555/)

demon007 08-23-2012 03:21 AM

Creating Driver
 
Hello Guys,
I am new to system programming and wanted to write some small drivers like of keyboard and mouse

I am not able to figure out from where to start and what should I read to write it.

Please help me with it.

Thank You

mennohellinga 08-23-2012 03:54 AM

You want to look into 'linux kernel module programming', which is a nontrivial task for actual hardware drivers. This howto from The Linux Documentation Project explains it.
If you want to write some small and easy drivers, it would be easier to write a kernel from scratch, using James Molloy's Kernel Development Tutorial.

sundialsvcs 08-23-2012 08:16 AM

"Use the Source, Luke!"

If you install the kernel source packages for your distro, you'll find the source-code for literally hundreds of device drivers. If one of these is not exactly what you need, it will be "damm close." And so, that is the proper place to start. Find existing tested source-code that is 99.9% of what you're looking for, and tweak it.

jlinkels 08-23-2012 08:23 AM

No one should start touching device drivers without reading this book: http://lwn.net/Kernel/LDD3/ For some reason I still don't understand this excellent source is freely available.

Furthermore a rich source of information is http://www.comedi.org.

jlinkels

demon007 08-25-2012 11:28 AM

Thankx for all your replies.

Actually I dont want to design the driver for a specific device. I want to just design a driver to learn how a driver(for eg keyboard) is working and how it is created. So from where should I start for it??

sundialsvcs 08-28-2012 08:00 AM

Quote:

Originally Posted by demon007 (Post 4764013)
don't want to design the driver for a specific device. I want to just design a driver to learn how a driver(for eg keyboard) is working and how it is created. So from where should I start for it??

"Use the Source, Luke." The best way to learn how to write a driver is to follow the path that others use to write their drivers: they study what has already been successfully done for their particular distro, find the closest match from existing work, and tweak it. That's the important power of open-source: you don't have to start from the beginning on anything, so no one does.

Do bear in mind that the Linux kernel has evolved considerably over time, so, although books are fine, the documentation directory that comes with the kernel tree, and the kernel itself, should be your primary reference. Once you've got the essential concepts and ideas straight in your head.


All times are GMT -5. The time now is 08:05 PM.