Device Drivers Part 1
Device Drivers Part 1
Device Drivers, Part 1: Linux Device Drivers for Your Girl Friend - LINUX For You
Subscribe to Print Edition Search
HOME
REVIEWS
HOW-TOS
CODING
INTERVIEWS
FEATURES
OVERVIEW
BLOGS
SERIES
IT ADMIN
Device Drivers, Part 1: Linux Device Drivers for Your Girl Friend
By Anil Kumar Pugalia on November 1, 2010 in Concepts, Developers, Overview 30 Comments and 0 Reactions
Search for:
Search
This series on Linux device drivers aims to present the usually technical topic in a way that is more interesting to a wider cross-section of readers.
After a week of hard work, we finally got our driver working, were Pugs first words when he met his girlfriend, Shweta. Why? What was your driver up to? Was he sick? And what hard work did you do? asked Shweta. Confused, Pugs responded, What are you talking about? Now it was Shwetas turn to look puzzled, as she replied, Why ask me? You tell me which of your drivers are you talking about? When understanding dawned on him, Pugs groaned, Ah cmon! Not my car drivers I am talking about a device driver on my computer. I know about car and bus drivers, pilots, and even screwdrivers; but what is this device driver? queried Shweta, puzzled. That was all it took to launch Pugs into a passionate explanation of device drivers for the newbie in particular, Linux device drivers, which he had been working on for many years.
Follow
+2,394
www.linuxforu.com/2010/11/understanding-linux-device-drivers/
1/8
7/17/13
Device Drivers, Part 1: Linux Device Drivers for Your Girl Friend - LINUX For You
Find us on Facebook
Popular
Comments
Tag cloud
Device controllers are typically connected to the CPU through their respectively named buses (collection of physical lines) for example, the PCI bus, the IDE bus, etc. In todays embedded world, we encounter more micro-controllers than CPUs; these are the CPU plus various device controllers built onto a single chip. This effective embedding of device controllers primarily reduces cost and space, making it suitable for embedded systems. In such cases, the buses are integrated into the chip itself. Does this change anything for the drivers, or more generically, on the software front? The answer is, not much except that the bus drivers corresponding to the embedded device controllers are now developed under the architecture-specific umbrella.
The device-specific portion of a device driver remains the same across all operating systems, and is more about understanding and decoding the device data sheets than software programming. A data sheet for a device is a document with technical details of the device, including its operation, performance, programming, etc. in short a device user manual. Later, I shall show some examples of decoding data sheets as well. However, the OS-specific portion is the one that is tightly coupled with the OS mechanisms of user interfaces, and thus differentiates a Linux device driver from a Windows device driver and from a MacOS device driver.
www.linuxforu.com/2010/11/understanding-linux-device-drivers/
2/8
7/17/13
Device Drivers, Part 1: Linux Device Drivers for Your Girl Friend - LINUX For You
Verticals
In Linux, a device driver provides a system call interface to the user; this is the boundary line between the so-called kernel space and user-space of Linux, as shown in Figure 2. Figure 3 provides further classification.
Based on the OS-specific interface of a driver, in Linux, a driver is broadly classified into three verticals: Packet-oriented or the network vertical Block-oriented or the storage vertical Byte-oriented or the character vertical The CPU vertical and memory vertical, taken together with the other three verticals, give the complete overview of the Linux kernel, like any textbook definition of an OS: An OS performs 5 management functions: CPU/process, memory, network, storage, device I/O. Though these two verticals could be classified as device drivers, where CPU and memory are the respective devices, they are treated differently, for many reasons. These are the core functionalities of any OS, be it a micro-kernel or a monolithic kernel. More often than not, adding code in these areas is mainly a Linux porting effort, which is typically done for a new CPU or architecture. Moreover, the code in these two verticals cannot be loaded or unloaded on the fly, unlike the other three verticals. Henceforth, when we talk about Linux device drivers, we mean to talk only about the latter three verticals in Figure 3. Lets get a little deeper into these three verticals. The network vertical consists of two parts: a) the network protocol stack, and b)the network interface card (NIC) device drivers, or simply network device drivers, which could be for Ethernet, Wi-Fi, or any other network horizontals. Storage, again, consists of two parts: a) File-system drivers, to decode the various formats on different partitions, and b) Block device drivers for various storage (hardware) protocols, i.e., horizontals like IDE, SCSI, MTD, etc. With this, you may wonder if that is the only set of devices for which you need drivers (or for which Linux has drivers). Hold on a moment; you certainly need drivers for the whole lot of devices that interface with the system, and Linux does have drivers for them. However, their byte-oriented cessibility puts all of them under the character vertical this is, in reality, the majority bucket. In fact, because of the vast number of drivers in this vertical, character drivers have been further sub-classified so you have tty drivers, input drivers, console drivers, framebuffer drivers, sound drivers, etc. The typical horizontals here would be RS232, PS/2, VGA, I2C, I2S, SPI, etc.
Multiple-vertical drivers
One final note on the complete picture (placement of all the drivers in the Linux driver ecosystem): the horizontals like USB, PCI, etc, span below multiple verticals. Why is that? Simple you already know that you can have a USB Wi-Fi dongle, a USB pen drive, and a USBto-serial converter all are USB, but come under three different verticals! In Linux, bus drivers or the horizontals, are often split into two parts, or even two drivers: a)
www.linuxforu.com/2010/11/understanding-linux-device-drivers/
3/8
7/17/13
Device Drivers, Part 1: Linux Device Drivers for Your Girl Friend - LINUX For You
device controller-specific, and b) an abstraction layer over that for the verticals to interface, commonly called cores. A classic example would be the USB controller drivers ohci, ehci, etc., and the USB abstraction, usbcore.
Summing up
So, to conclude, a device driver is a piece of software that drives a device, though there are so many classifications. In case it drives only another piece of software, we call it just a driver. Examples are file-system drivers, usbcore, etc. Hence, all device drivers are drivers, but all drivers are not device drivers. Hey, Pugs, hold on; were getting late for class, and you know what kind of trouble we can get into. Lets continue from here, later, exclaimed Shweta. Jumping up, Pugs finished his explanation: Okay. This is the basic theory about device drivers. If youre interested, later, I can show you the code, and all that we have been doing for the various kinds of drivers. And they hurried towards their classroom.
Related Posts:
Device Drivers, Part 4: Linux Character Drivers Device Drivers, Part 11: USB Drivers in Linux Device Drivers, Part 6: Decoding Character Device File Operations Device Drivers, Part 5: Character Device Files Creation & Operations Device Drivers, Part 13: Data Transfer to and from USB Devices
Tags: bus, bus drivers, device controllers, device drivers, display controllers, hard disk controllers, hardware protocols, LFY November 2010, linux device drivers, Linux Device Drivers Series, software device driver, software programming
Previous Post
Next Post
What's this?
Don't Get Alzheimer's: Here's What May Cause It Newsmax Health 9 Things You Can Do Today to Boost Your Retirement Income Citi Women & Co. One Crazy Night: Watch 'This is Not Happening' Now Comedy Central 6 Simple Tips to Help You Lose Belly Fat Stack
What it Takes to be an Open Source Expert 1 comment PHP Development: A Smart Career Move 4 comments A Simple guide to building your own Linux Kernel 1 comment
Share
20 days ago
anil_pugalia
> Abhishek
Share
18 days ago
www.linuxforu.com/2010/11/understanding-linux-device-drivers/
4/8
7/17/13
abhis hek
Device Drivers, Part 1: Linux Device Drivers for Your Girl Friend - LINUX For You
> anil_pugalia
Reply
15 days ago
anil_pugalia
> abhishek
Share
15 days ago
abhis hek
> anil_pugalia
12 days ago
you mean to say an application calls open which is mapped to device drivers struct { .open () .close() } how is the applications open calling or connecting with device file
Reply Share
anil_pugalia
> abhishek
9 days ago
E rwan
3 months ago
Being a guy, as my girlfriend works on GPUs and knows all of this much better than me or most of you, I think the title should be "Device Drivers, Part 1: Linux Device Drivers for Your Boy Friend". In other words, this title is utterly sexist and should be changed.
1
Reply
Share
> Erwan
2 months ago
The author assumes that the first article being introductory in nature is for the beginners. So there is no question of differentiating between the people as men or women. He has lined up other advanced driver explanations for those who want to learn more. And author himself has received several awards in his erstwhile organization Intel(at least 11 awards) for his contributions to the embedded domain. And he is an Entrepreneur too. The author is constantly engaged in sharing thoughts with the other experts and together they keep developing innovative solutions. Author explains the concepts of drivers with the narration of pugs and sweta in the backdrop just to make drivers interesting to learn for even those who are total novices to kernel. (BTW Pugs is the college nickname of the author !) Author is enthusiastic in imparting knowledge to all. He mixes fun with teaching and makes the complicated concepts available for consumption for the beginners and then the complicated concepts begin to build on the candidates and they are hugely benefited in the process.
I can vouch for the above fact as I have attended his training sessions.
Reply Share
anil_pugalia
> Erwan
2 months ago
Writing an article doesn't mean that world's all guys & gals fall into this bucket. That's just *a* perspective. There could be hundred & thousands of other perspectives, which we mere mortals would never be able to put down all together. So, what a big deal dude - all this sexist and ... stuff. Moreover, these articles are not meant for sexism but for learning the fun way.
Reply E rwan Share
> anil_pugalia
2 months ago
"Moreover, these articles are not meant for sexism but for learning the
www.linuxforu.com/2010/11/understanding-linux-device-drivers/ 5/8
7/17/13
Device Drivers, Part 1: Linux Device Drivers for Your Girl Friend - LINUX For You "Moreover, these articles are not meant for sexism but for learning the fun way."
Exactly! Then this one does not have to be sexist :), yet it sadly contributes to the overall nasty atmosphere concerning women and computers. Sorry for my rough first comment, but ordinary (and, in many cases, not intended) sexism is a real problem is the computer science community.
Reply Share
anil_pugalia
> Erwan
2 months ago
Madhan
I hope you do believe, that there are people existing around of all varieties. It is just that you have come across a different set than what I have generally come across. And, a writer typically is bound to write from his own experiences in his own perspective - that doesn't mean that everyone in this world are like that - it is just one of the perspectives. And hence, I do not even see a need or reason to talk about or bring out sexism in such technical scenarios.
Reply Share
3 months ago
good :)
Reply
Share
Malles h
4 months ago
anil_pugalia
> Mallesh
4 months ago
s as
7 months ago
Hi Anil, Its very good article to read and clearly explained. Great work !
A amir
-- Satheesaran
Reply
Share
8 months ago
Hi Anil, I have worked on MCU ranging 8051 to cortex M3. but all on window with c/c++.
But now I want to work on linux & mcu.Can you guide how/where to start
Reply Share
anil_pugalia
> Aamir
8 months ago
Start with this first article & exercise all the 24 set of the series. That should be a good starter.
1
Reply
Share
11 months ago
nicely explained
1
Reply
Share
A nil P ugalia
11 months ago
Thanks
Reply ravi
11 months ago
Hi Anil , This is Ravi From Bangalore, could me plz tell me how to learn linux device driver ! already i have work early not form scorch on wards, plz send me good data and site also ! " [email protected]" , this is my id!
www.linuxforu.com/2010/11/understanding-linux-device-drivers/ 6/8
7/17/13
Device Drivers, Part 1: Linux Device Drivers for Your Girl Friend - LINUX For You
Thanks Ravi
Reply Share
A nil P ugalia
> ravi
11 months ago
Joe
Then, start from scratch :). Essential Linux Drivers is one good book to start with.
Reply Share
a year ago
Good job. I have noticed mistake: on Figure 2, instead of "Micro-controller" must be "User space"
Reply Share
anil_pugalia 1 Dileep
> Joe
a year ago
You are perfectly correct. But we realized that only after it went to print. :(
Reply
Reply
Share
a year ago
anil_pugalia
> Dileep
8 months ago
S urjaGain
2 years ago
Thanks for this article. The Related Posts section at the end of the article doesn't really show related device driver posts. I hope there is some way you can display links to the other articles of this series in related posts so we can continue on with it. Also I know this will take time but ultimately we wish to see all the articles of this series published online on this website. Thank you once again.
Reply Share
Mod
LINUX For Y ou
> SurjaGain
2 years ago
@SurjaGain here's the links where all the articles in the series are listed http://www.linuxforu.com/tag/l... - Everything till the November 2011 article (i.e. Parts 1-12) is online. As for things showing up under related posts, well, that depends on this WP plugin - http://wordpress.org/extend/pl... - and it only produces posts that are older than the current post under "Related posts". That's why, while it cant show the future parts in a series of articles, in future parts of the series it does show the parts from the past.
Reply
Share
Chank ey P at hak
2 years ago
Reply
Share
Gues t
8 months ago
Thanks.
anil_pugalia
> Guest
8 months ago
r
C o m m e n t fe e d
Su b s cri b e vi a e m a i l
Reviews
How-Tos
Coding
Interviews
Features
Overview
Blogs
www.linuxforu.com/2010/11/understanding-linux-device-drivers/
7/8
7/17/13
Device Drivers, Part 1: Linux Device Drivers for Your Girl Friend - LINUX For You
For You & Me Developers Sysadmins Open Gurus CXOs Columns
Search
Popular tags
Linux , ubuntu, Java, MySQL, Google, python, Fedora, Android, PHP, C, html, w eb applications , India, Microsoft, unix , Window s , Red Hat, Oracle, Security , Apache, xml, LFY April 2012, FOSS, GNOME, http, JavaScript, LFY June 2011, open source, RAM, operating systems
All published articles are released under Creative Commons Attribution-NonCommercial 3.0 Unported License, unless otherw ise noted. LINUX For You is pow ered by WordPress, w hich gladly sits on top of a CentOS-based LEMP stack.
www.linuxforu.com/2010/11/understanding-linux-device-drivers/
8/8