SlideShare a Scribd company logo
1 of 20
B . R A M A M U R T H Y
6/13/2013
1
Device Drivers
Introduction
6/13/2013
2
A device driver is computer program that allows a system
to interface with hardware devices.
Example driver: printer driver, bluetooth driver
Example devices: your USB stick, sensors: accelerometer
It is a translator between the operating system and
applications the use the devices and the devices.
A typical operating system has many device drivers built
into it.
A device driver converts general IO instructions into
device specific operations.
Device drivers operate in a privileged mode requires
careful design
Why Device Driver?
6/13/2013
3
A typical computing system (lap top, computer, cell
phone, PDA, Point of sale system) deals with a variety of
devices.
Making a hardware device work as expected is a
cumbersome task.
Instead adding this code every application, operating
system provides a single point interface for all devices by
hosting the device drivers.
Adding it under the operating systems provides the
protection and security needed for the device drivers
from malicious use.
The device drivers are essentially shared dynamically
linked libraries.
File abstraCtion
6/13/2013
4
 What do you with a device? {read, write}, {read
only}, {write only}
 Lets look at some examples: USB device, CD-ROM,
LED Display,
 What do you do with a file? open, close, read, write, ..
 File is an excellent abstraction for devices.
/dev partial listing
6/13/2013
5
 total 380
 lrwxrwxrwx 1 root 30 Mar 7 2004 allkmem -> ../devices/pseudo/mm@0:
 allkmem
 lrwxrwxrwx 1 root 27 Aug 15 2001 arp -> ../devices/pseudo/arp@0:arp
 lrwxrwxrwx 1 root 7 Aug 15 2001 audio -> sound/0
 lrwxrwxrwx 1 root 10 Aug 15 2001 audioctl -> sound/0ctl
 lrwxrwxrwx 1 root 11 Oct 4 03:06 bd.off -> /dev/term/b
 drwxr-xr-x 2 root 512 Aug 17 2001 cfg
 lrwxrwxrwx 1 root 31 Aug 15 2001 conslog -> ../devices/pseudo/log@0
 :conslog
 lrwxrwxrwx 1 root 30 Aug 15 2001 console -> ../devices/pseudo/cn@0:
 console
 drwxr-xr-x 2 root 512 Aug 15 2001 cua
 drwxr-xr-x 2 root 2048 Aug 31 2002 dsk
 lrwxrwxrwx 1 root 29 Aug 15 2001 dump -> ../devices/pseudo/dump@0:d
 ump
 lrwxrwxrwx 1 root 50 Aug 15 2001 ecpp0 -> ../devices/pci@1f,4000/eb
 us@1/ecpp@14,3043bc:ecpp0
 lrwxrwxrwx 1 root 8 Aug 15 2001 fb0 -> fbs/ffb0
 drwxr-xr-x 2 root 512 Aug 15 2001 fbs
 dr-xr-xr-x 2 root 528 Nov 9 11:51 fd
 lrwxrwxrwx 1 root 30 Apr 7 2002 fssnapctl -> ../devices/pseudo/
Device SPACE
6/13/2013
6
Typically there are multiple devices of the same type.
All the devices controlled by the same device driver is
given the same “major number”
A “minor number” distinguishes among the devices
of the same type.
Example: printers have a major number since
purpose is same, minor# is denote a specific printer
Examples from XINU
6/13/2013
7
 Take a look at files in the include directory:
 device.h
 tty.h
 uart.h
 Also in the system directory devtable.c, initialize.c
 Bottom line is this, for a device xyz:
1. Include a file in include directory: xyz.h
-- define the operations/functions for the device
2. Add a directory xyz
-- implement all functions each in its own file
3. Add an entry in the devtable.c for the device (note that this
has the “minor” device number along with other things)
Lets Analyze the XINU UART Driver
6/13/2013
8
 Starting point: uart.h in include directory
 uart directory functions
 system directory devtable.c, initialize.c
 Usage of the devices is through device table:
 Ex:
pdev = &devtab[i];
(pdevinit)(pdev);
UART Driver in EXINU
9
1. General device driver related files: device.h,
devtable.c
2. Uart files: uart.h defining the physical features of
the uart
3. All the files in the uart directory that implement
the operations related to the uart.
 uartControl.c uartInit.c uartIntr.c
 uartPutChar.c uartWrite.c uartGetChar.c uartRead.c
6/13/2013
Device Drivers
10
 On board devices are called internal peripherals
and one outside are called external peripherals
 UART Chip (internal)
 TTY (external)
 UART transceiverRS232D-9 connector 
laptop serial socket
 WRT54GL board and modifications
6/13/2013
Device drivers (contd.)
11
 Embedded processor interacts with a peripheral
device through a set of control and status registers.
 Registers are part of the peripheral device.
 Registers within a serial controller are different
from those in a timer.
 These devices are located in the memory space of
the processor or I/O space of the processor-- two
types: memory-mapped or I/O mapped
respectively.
6/13/2013
Device driver (contd.)
1. 1
2
 The keyword volatile should be used when declaring
pointers to device drivers.
 Bit patterns for testing, setting, clearing, toggling,
shifting bits, bitmasks, and bitfields.
 Struct overlays:
 In embedded systems featuring memory mapped IO
devices, it is common to overlay a C struct on to each
peripheral’s control and status registers.
 This will provide the offsets for the various registers from
the base address of the device.
6/13/2013
Device Driver Philosophy
13
 Hide the hardware completely: hardware abstraction
 If the device generates any interrupts include interrupt
controllers.
 Device driver presents a generic interface for applications
at higher level to access the devices: device.h
 Device drivers in embedded systems are different from
general purpose operating systems: See diagram in slide
#14
 Applications in general purpose systems accesses OS
(Operating Systems) which in turn accesses device
drivers.
 Applications in embedded systems can directly access
device drivers.
6/13/2013
14
General Purpose OS vs. Embedded
System
Application
process
Operating
System:
dev/xyz
Device
driver
Physical
Device
hardware
Application
process
Device
driver
Physical
Device
hardware
6/13/2013
Device Driver development steps
15
1. An interface to the control and status registers.
2. Variables to track the current state of the physical and
logical devices
-- Major and minor device number, device name
3. A routine to initialize the hardware to known state
4. An API for users of the device driver
-- Read, write, seek
5. Interrupts service routines
6/13/2013
Example: A serial device driver
16
 Read the text for explanation and general example of
a timer
 Now lets look at the UARTdriver of the embedded
xinu and WRT54GL.
 Study the tty driver that is a logical device that is
layered on top of the UART driver.
 Discuss how you would develop a device driver for a
framebuffer.. This was a lab2 last year.
6/13/2013
Shift Operators
6/13/2013
17
 << left shift
 >> right shift
Usage:
unsigned int x = 70707;
//x = 00000000 00000001 00010100 00110011
unsigned int y, z;
y = x << 2;
// y = 00000000 00000100 01010000 11001100
z = x >> 2;
//z = 00000000 00000000 01000101 00001100
Logic Operators
6/13/2013
18
 Bitwise & (AND)
 Bitwise inclusive | (OR)
 Bitwise exclusive ^ (XOR)
 Bitwise negation ~
Usage:
unsigned exp1 = 1;
unsigned exp2 = 4;
printf (“ %dn”, exp1 | exp2);
printf (“ %dn”, exp1 & exp2);
printf (“ %dn”, exp1 ^ exp2);
printf (“ %dn”, ~exp1);
Relevance of shift and logic operators
6/13/2013
19
Bitwise operations are necessary for much low-level
programming, such as writing to device drivers, low-
level graphics, communications protocol packet
assembly and decoding.
Device drivers use these operators to test the
presence or absence of a bit in a serial port or a
device input, for example. (checking for on or off)
Summary
20
 We studied the design and development of device
drivers.
 We analyzed the code for a sample UART driver.
6/13/2013

More Related Content

Similar to DeviceDriverNov18.ppt

101 4.3 control mounting and unmounting of filesystems
101 4.3 control mounting and unmounting of filesystems101 4.3 control mounting and unmounting of filesystems
101 4.3 control mounting and unmounting of filesystemsAcácio Oliveira
 
Operating System Case Study and I/O System
Operating System Case Study and I/O SystemOperating System Case Study and I/O System
Operating System Case Study and I/O Systemprakash ganesan
 
Operating system- Chapter 1.pptx to study
Operating system- Chapter 1.pptx to studyOperating system- Chapter 1.pptx to study
Operating system- Chapter 1.pptx to studymuhammadalam77863
 
computer System UNit Every thing
computer System UNit Every thingcomputer System UNit Every thing
computer System UNit Every thingAbdul Rehman
 
The Architecture of Intel Processor Graphics: Gen 11
The Architecture of Intel Processor Graphics: Gen 11The Architecture of Intel Processor Graphics: Gen 11
The Architecture of Intel Processor Graphics: Gen 11DESMOND YUEN
 
The Architecture of 11th Generation Intel® Processor Graphics
The Architecture of 11th Generation Intel® Processor GraphicsThe Architecture of 11th Generation Intel® Processor Graphics
The Architecture of 11th Generation Intel® Processor GraphicsIntel® Software
 
Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day Simone Onofri
 
Microprocessors and-microcontrollers (1)
Microprocessors and-microcontrollers (1)Microprocessors and-microcontrollers (1)
Microprocessors and-microcontrollers (1)Nagarjun singh
 
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptxFANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptxPannaBushratul
 
Automotive Grade Linux and systemd
Automotive Grade Linux and systemdAutomotive Grade Linux and systemd
Automotive Grade Linux and systemdAlison Chaiken
 
Computer technicians-quick-reference-guide
Computer technicians-quick-reference-guideComputer technicians-quick-reference-guide
Computer technicians-quick-reference-guideShathees Rao
 
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptxUNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptxLeahRachael
 
Module 5 embedded systems,8051
Module 5 embedded systems,8051Module 5 embedded systems,8051
Module 5 embedded systems,8051Deepak John
 

Similar to DeviceDriverNov18.ppt (20)

unit 5.pptx
unit 5.pptxunit 5.pptx
unit 5.pptx
 
Notes for LX0-101 Linux
Notes for LX0-101 Linux Notes for LX0-101 Linux
Notes for LX0-101 Linux
 
Unit 6
Unit 6Unit 6
Unit 6
 
101 4.3 control mounting and unmounting of filesystems
101 4.3 control mounting and unmounting of filesystems101 4.3 control mounting and unmounting of filesystems
101 4.3 control mounting and unmounting of filesystems
 
Operating System Case Study and I/O System
Operating System Case Study and I/O SystemOperating System Case Study and I/O System
Operating System Case Study and I/O System
 
Operating system- Chapter 1.pptx to study
Operating system- Chapter 1.pptx to studyOperating system- Chapter 1.pptx to study
Operating system- Chapter 1.pptx to study
 
computer System UNit Every thing
computer System UNit Every thingcomputer System UNit Every thing
computer System UNit Every thing
 
The Architecture of Intel Processor Graphics: Gen 11
The Architecture of Intel Processor Graphics: Gen 11The Architecture of Intel Processor Graphics: Gen 11
The Architecture of Intel Processor Graphics: Gen 11
 
The Architecture of 11th Generation Intel® Processor Graphics
The Architecture of 11th Generation Intel® Processor GraphicsThe Architecture of 11th Generation Intel® Processor Graphics
The Architecture of 11th Generation Intel® Processor Graphics
 
lecture1.pdf
lecture1.pdflecture1.pdf
lecture1.pdf
 
5638
56385638
5638
 
Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
 
02.Os Structure
02.Os Structure02.Os Structure
02.Os Structure
 
Backtrack Manual Part8
Backtrack Manual Part8Backtrack Manual Part8
Backtrack Manual Part8
 
Microprocessors and-microcontrollers (1)
Microprocessors and-microcontrollers (1)Microprocessors and-microcontrollers (1)
Microprocessors and-microcontrollers (1)
 
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptxFANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
 
Automotive Grade Linux and systemd
Automotive Grade Linux and systemdAutomotive Grade Linux and systemd
Automotive Grade Linux and systemd
 
Computer technicians-quick-reference-guide
Computer technicians-quick-reference-guideComputer technicians-quick-reference-guide
Computer technicians-quick-reference-guide
 
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptxUNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
UNIT 5- UNDERSTANDING THE SYSTEM DESIGN PROCESS.pptx
 
Module 5 embedded systems,8051
Module 5 embedded systems,8051Module 5 embedded systems,8051
Module 5 embedded systems,8051
 

More from TerrenceRamirez1

electricalhandtoolsandequipment-190615172106_(1).pptx
electricalhandtoolsandequipment-190615172106_(1).pptxelectricalhandtoolsandequipment-190615172106_(1).pptx
electricalhandtoolsandequipment-190615172106_(1).pptxTerrenceRamirez1
 
Aralingpanlipunamsuliraning_pangkapaligiran_week3.pptx
Aralingpanlipunamsuliraning_pangkapaligiran_week3.pptxAralingpanlipunamsuliraning_pangkapaligiran_week3.pptx
Aralingpanlipunamsuliraning_pangkapaligiran_week3.pptxTerrenceRamirez1
 
mgasinaunangkabihasnansaasya-160710045058.pptx
mgasinaunangkabihasnansaasya-160710045058.pptxmgasinaunangkabihasnansaasya-160710045058.pptx
mgasinaunangkabihasnansaasya-160710045058.pptxTerrenceRamirez1
 
AP8-Q3-W2dailylessonlogaralingpanlipunandocx
AP8-Q3-W2dailylessonlogaralingpanlipunandocxAP8-Q3-W2dailylessonlogaralingpanlipunandocx
AP8-Q3-W2dailylessonlogaralingpanlipunandocxTerrenceRamirez1
 
Power_Point_Presentation_in_Grades_8_and.pptx
Power_Point_Presentation_in_Grades_8_and.pptxPower_Point_Presentation_in_Grades_8_and.pptx
Power_Point_Presentation_in_Grades_8_and.pptxTerrenceRamirez1
 
occupationalsafetyandhelathrelatedissues.pptx
occupationalsafetyandhelathrelatedissues.pptxoccupationalsafetyandhelathrelatedissues.pptx
occupationalsafetyandhelathrelatedissues.pptxTerrenceRamirez1
 
introduction-to-computes types of computers
introduction-to-computes types of computersintroduction-to-computes types of computers
introduction-to-computes types of computersTerrenceRamirez1
 
TERRITORIAL_BORDER_CONFLICT.pptx
TERRITORIAL_BORDER_CONFLICT.pptxTERRITORIAL_BORDER_CONFLICT.pptx
TERRITORIAL_BORDER_CONFLICT.pptxTerrenceRamirez1
 
billiards refresher course POWER POINT.pptx
billiards refresher course POWER POINT.pptxbilliards refresher course POWER POINT.pptx
billiards refresher course POWER POINT.pptxTerrenceRamirez1
 
Q1-Arts10-Modules-2-4.pptx
Q1-Arts10-Modules-2-4.pptxQ1-Arts10-Modules-2-4.pptx
Q1-Arts10-Modules-2-4.pptxTerrenceRamirez1
 
REFRESHER BILLIARD VIDEO SHOTS AND FOULS.pptx
REFRESHER BILLIARD VIDEO SHOTS AND FOULS.pptxREFRESHER BILLIARD VIDEO SHOTS AND FOULS.pptx
REFRESHER BILLIARD VIDEO SHOTS AND FOULS.pptxTerrenceRamirez1
 
typesofcomputer topic 1.pptx
typesofcomputer topic 1.pptxtypesofcomputer topic 1.pptx
typesofcomputer topic 1.pptxTerrenceRamirez1
 
documents.pub_use-of-tools-in-pc-hardware-servicing-58a4683c45215.pptx
documents.pub_use-of-tools-in-pc-hardware-servicing-58a4683c45215.pptxdocuments.pub_use-of-tools-in-pc-hardware-servicing-58a4683c45215.pptx
documents.pub_use-of-tools-in-pc-hardware-servicing-58a4683c45215.pptxTerrenceRamirez1
 
training_and_more_-_hand_tools_11_-_hand_tool_use_and_selection_guidance.ppt
training_and_more_-_hand_tools_11_-_hand_tool_use_and_selection_guidance.ppttraining_and_more_-_hand_tools_11_-_hand_tool_use_and_selection_guidance.ppt
training_and_more_-_hand_tools_11_-_hand_tool_use_and_selection_guidance.pptTerrenceRamirez1
 

More from TerrenceRamirez1 (20)

electricalhandtoolsandequipment-190615172106_(1).pptx
electricalhandtoolsandequipment-190615172106_(1).pptxelectricalhandtoolsandequipment-190615172106_(1).pptx
electricalhandtoolsandequipment-190615172106_(1).pptx
 
Aralingpanlipunamsuliraning_pangkapaligiran_week3.pptx
Aralingpanlipunamsuliraning_pangkapaligiran_week3.pptxAralingpanlipunamsuliraning_pangkapaligiran_week3.pptx
Aralingpanlipunamsuliraning_pangkapaligiran_week3.pptx
 
mgasinaunangkabihasnansaasya-160710045058.pptx
mgasinaunangkabihasnansaasya-160710045058.pptxmgasinaunangkabihasnansaasya-160710045058.pptx
mgasinaunangkabihasnansaasya-160710045058.pptx
 
AP8-Q3-W2dailylessonlogaralingpanlipunandocx
AP8-Q3-W2dailylessonlogaralingpanlipunandocxAP8-Q3-W2dailylessonlogaralingpanlipunandocx
AP8-Q3-W2dailylessonlogaralingpanlipunandocx
 
Power_Point_Presentation_in_Grades_8_and.pptx
Power_Point_Presentation_in_Grades_8_and.pptxPower_Point_Presentation_in_Grades_8_and.pptx
Power_Point_Presentation_in_Grades_8_and.pptx
 
occupationalsafetyandhelathrelatedissues.pptx
occupationalsafetyandhelathrelatedissues.pptxoccupationalsafetyandhelathrelatedissues.pptx
occupationalsafetyandhelathrelatedissues.pptx
 
introduction-to-computes types of computers
introduction-to-computes types of computersintroduction-to-computes types of computers
introduction-to-computes types of computers
 
TERRITORIAL_BORDER_CONFLICT.pptx
TERRITORIAL_BORDER_CONFLICT.pptxTERRITORIAL_BORDER_CONFLICT.pptx
TERRITORIAL_BORDER_CONFLICT.pptx
 
billiards refresher course POWER POINT.pptx
billiards refresher course POWER POINT.pptxbilliards refresher course POWER POINT.pptx
billiards refresher course POWER POINT.pptx
 
conversion.ppt
conversion.pptconversion.ppt
conversion.ppt
 
Q1-Arts10-Modules-2-4.pptx
Q1-Arts10-Modules-2-4.pptxQ1-Arts10-Modules-2-4.pptx
Q1-Arts10-Modules-2-4.pptx
 
REFRESHER BILLIARD VIDEO SHOTS AND FOULS.pptx
REFRESHER BILLIARD VIDEO SHOTS AND FOULS.pptxREFRESHER BILLIARD VIDEO SHOTS AND FOULS.pptx
REFRESHER BILLIARD VIDEO SHOTS AND FOULS.pptx
 
typesofcomputer topic 1.pptx
typesofcomputer topic 1.pptxtypesofcomputer topic 1.pptx
typesofcomputer topic 1.pptx
 
migrasyon.pptx
migrasyon.pptxmigrasyon.pptx
migrasyon.pptx
 
wirings.pptx
wirings.pptxwirings.pptx
wirings.pptx
 
lesson1-160407043212.pptx
lesson1-160407043212.pptxlesson1-160407043212.pptx
lesson1-160407043212.pptx
 
lesson 1.pptx
lesson 1.pptxlesson 1.pptx
lesson 1.pptx
 
documents.pub_use-of-tools-in-pc-hardware-servicing-58a4683c45215.pptx
documents.pub_use-of-tools-in-pc-hardware-servicing-58a4683c45215.pptxdocuments.pub_use-of-tools-in-pc-hardware-servicing-58a4683c45215.pptx
documents.pub_use-of-tools-in-pc-hardware-servicing-58a4683c45215.pptx
 
training_and_more_-_hand_tools_11_-_hand_tool_use_and_selection_guidance.ppt
training_and_more_-_hand_tools_11_-_hand_tool_use_and_selection_guidance.ppttraining_and_more_-_hand_tools_11_-_hand_tool_use_and_selection_guidance.ppt
training_and_more_-_hand_tools_11_-_hand_tool_use_and_selection_guidance.ppt
 
percent composition.pptx
percent composition.pptxpercent composition.pptx
percent composition.pptx
 

Recently uploaded

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

DeviceDriverNov18.ppt

  • 1. B . R A M A M U R T H Y 6/13/2013 1 Device Drivers
  • 2. Introduction 6/13/2013 2 A device driver is computer program that allows a system to interface with hardware devices. Example driver: printer driver, bluetooth driver Example devices: your USB stick, sensors: accelerometer It is a translator between the operating system and applications the use the devices and the devices. A typical operating system has many device drivers built into it. A device driver converts general IO instructions into device specific operations. Device drivers operate in a privileged mode requires careful design
  • 3. Why Device Driver? 6/13/2013 3 A typical computing system (lap top, computer, cell phone, PDA, Point of sale system) deals with a variety of devices. Making a hardware device work as expected is a cumbersome task. Instead adding this code every application, operating system provides a single point interface for all devices by hosting the device drivers. Adding it under the operating systems provides the protection and security needed for the device drivers from malicious use. The device drivers are essentially shared dynamically linked libraries.
  • 4. File abstraCtion 6/13/2013 4  What do you with a device? {read, write}, {read only}, {write only}  Lets look at some examples: USB device, CD-ROM, LED Display,  What do you do with a file? open, close, read, write, ..  File is an excellent abstraction for devices.
  • 5. /dev partial listing 6/13/2013 5  total 380  lrwxrwxrwx 1 root 30 Mar 7 2004 allkmem -> ../devices/pseudo/mm@0:  allkmem  lrwxrwxrwx 1 root 27 Aug 15 2001 arp -> ../devices/pseudo/arp@0:arp  lrwxrwxrwx 1 root 7 Aug 15 2001 audio -> sound/0  lrwxrwxrwx 1 root 10 Aug 15 2001 audioctl -> sound/0ctl  lrwxrwxrwx 1 root 11 Oct 4 03:06 bd.off -> /dev/term/b  drwxr-xr-x 2 root 512 Aug 17 2001 cfg  lrwxrwxrwx 1 root 31 Aug 15 2001 conslog -> ../devices/pseudo/log@0  :conslog  lrwxrwxrwx 1 root 30 Aug 15 2001 console -> ../devices/pseudo/cn@0:  console  drwxr-xr-x 2 root 512 Aug 15 2001 cua  drwxr-xr-x 2 root 2048 Aug 31 2002 dsk  lrwxrwxrwx 1 root 29 Aug 15 2001 dump -> ../devices/pseudo/dump@0:d  ump  lrwxrwxrwx 1 root 50 Aug 15 2001 ecpp0 -> ../devices/pci@1f,4000/eb  us@1/ecpp@14,3043bc:ecpp0  lrwxrwxrwx 1 root 8 Aug 15 2001 fb0 -> fbs/ffb0  drwxr-xr-x 2 root 512 Aug 15 2001 fbs  dr-xr-xr-x 2 root 528 Nov 9 11:51 fd  lrwxrwxrwx 1 root 30 Apr 7 2002 fssnapctl -> ../devices/pseudo/
  • 6. Device SPACE 6/13/2013 6 Typically there are multiple devices of the same type. All the devices controlled by the same device driver is given the same “major number” A “minor number” distinguishes among the devices of the same type. Example: printers have a major number since purpose is same, minor# is denote a specific printer
  • 7. Examples from XINU 6/13/2013 7  Take a look at files in the include directory:  device.h  tty.h  uart.h  Also in the system directory devtable.c, initialize.c  Bottom line is this, for a device xyz: 1. Include a file in include directory: xyz.h -- define the operations/functions for the device 2. Add a directory xyz -- implement all functions each in its own file 3. Add an entry in the devtable.c for the device (note that this has the “minor” device number along with other things)
  • 8. Lets Analyze the XINU UART Driver 6/13/2013 8  Starting point: uart.h in include directory  uart directory functions  system directory devtable.c, initialize.c  Usage of the devices is through device table:  Ex: pdev = &devtab[i]; (pdevinit)(pdev);
  • 9. UART Driver in EXINU 9 1. General device driver related files: device.h, devtable.c 2. Uart files: uart.h defining the physical features of the uart 3. All the files in the uart directory that implement the operations related to the uart.  uartControl.c uartInit.c uartIntr.c  uartPutChar.c uartWrite.c uartGetChar.c uartRead.c 6/13/2013
  • 10. Device Drivers 10  On board devices are called internal peripherals and one outside are called external peripherals  UART Chip (internal)  TTY (external)  UART transceiverRS232D-9 connector  laptop serial socket  WRT54GL board and modifications 6/13/2013
  • 11. Device drivers (contd.) 11  Embedded processor interacts with a peripheral device through a set of control and status registers.  Registers are part of the peripheral device.  Registers within a serial controller are different from those in a timer.  These devices are located in the memory space of the processor or I/O space of the processor-- two types: memory-mapped or I/O mapped respectively. 6/13/2013
  • 12. Device driver (contd.) 1. 1 2  The keyword volatile should be used when declaring pointers to device drivers.  Bit patterns for testing, setting, clearing, toggling, shifting bits, bitmasks, and bitfields.  Struct overlays:  In embedded systems featuring memory mapped IO devices, it is common to overlay a C struct on to each peripheral’s control and status registers.  This will provide the offsets for the various registers from the base address of the device. 6/13/2013
  • 13. Device Driver Philosophy 13  Hide the hardware completely: hardware abstraction  If the device generates any interrupts include interrupt controllers.  Device driver presents a generic interface for applications at higher level to access the devices: device.h  Device drivers in embedded systems are different from general purpose operating systems: See diagram in slide #14  Applications in general purpose systems accesses OS (Operating Systems) which in turn accesses device drivers.  Applications in embedded systems can directly access device drivers. 6/13/2013
  • 14. 14 General Purpose OS vs. Embedded System Application process Operating System: dev/xyz Device driver Physical Device hardware Application process Device driver Physical Device hardware 6/13/2013
  • 15. Device Driver development steps 15 1. An interface to the control and status registers. 2. Variables to track the current state of the physical and logical devices -- Major and minor device number, device name 3. A routine to initialize the hardware to known state 4. An API for users of the device driver -- Read, write, seek 5. Interrupts service routines 6/13/2013
  • 16. Example: A serial device driver 16  Read the text for explanation and general example of a timer  Now lets look at the UARTdriver of the embedded xinu and WRT54GL.  Study the tty driver that is a logical device that is layered on top of the UART driver.  Discuss how you would develop a device driver for a framebuffer.. This was a lab2 last year. 6/13/2013
  • 17. Shift Operators 6/13/2013 17  << left shift  >> right shift Usage: unsigned int x = 70707; //x = 00000000 00000001 00010100 00110011 unsigned int y, z; y = x << 2; // y = 00000000 00000100 01010000 11001100 z = x >> 2; //z = 00000000 00000000 01000101 00001100
  • 18. Logic Operators 6/13/2013 18  Bitwise & (AND)  Bitwise inclusive | (OR)  Bitwise exclusive ^ (XOR)  Bitwise negation ~ Usage: unsigned exp1 = 1; unsigned exp2 = 4; printf (“ %dn”, exp1 | exp2); printf (“ %dn”, exp1 & exp2); printf (“ %dn”, exp1 ^ exp2); printf (“ %dn”, ~exp1);
  • 19. Relevance of shift and logic operators 6/13/2013 19 Bitwise operations are necessary for much low-level programming, such as writing to device drivers, low- level graphics, communications protocol packet assembly and decoding. Device drivers use these operators to test the presence or absence of a bit in a serial port or a device input, for example. (checking for on or off)
  • 20. Summary 20  We studied the design and development of device drivers.  We analyzed the code for a sample UART driver. 6/13/2013