Abhishek Sagar
Abhishek Sagar

Reputation: 1326

Writing end to end linux device driver

I am looking forward to learn writing a typical linux device driver. Can anyone guide me how can i learn all the aspects of a typical linux device driver ? The examples i see on internet are way too simple, they just send a "hello world" msg from user space to kernel driver module, and echo back "hello". I want to touch almost all areas in a simple way, one would face in writing a real world driver. Would i need to have a real hardware to go forward to meet my requirement ? Cannot system's memory simulate the hardware peripheral and let me treat it as a hardware and control it vie kernel driver covering good set of operations ? Any examples/guidance for this ?

Upvotes: 0

Views: 745

Answers (2)

patraulea
patraulea

Reputation: 884

Sample drivers usually don't control real hardware. The QEMU answer mentioned here is a good exception I guess.

It depends what type of driver you want to focus on. Most classes of drivers distributed with the kernel have some simpler drivers you can learn from. Nbd for example is great for block subsystem and loop devices:

https://github.com/torvalds/linux/blob/c05c2ec96bb8b7310da1055c7b9d786a3ec6dc0c/drivers/block/nbd.c

Look at the smallest file sizes in a drivers/xyz directory and go up until the code is too complex.

Upvotes: 0

tisma
tisma

Reputation: 56

Take a look at the following example of network driver. It uses QEMU for development and testing.

http://www.codeproject.com/Articles/1087177/Linux-Ethernet-Driver-using-Qemu

Upvotes: 2

Related Questions