SlideShare a Scribd company logo
1 of 2
Download to read offline
What is a device driver?
Device driver is a software program that makes a particular piece of
hardware to respond to a well-defined internal programming interface. The
programming interface means whenever hardware is connected to the
system, that interface will invoke the specific driver for a specific device.
The interface loads the driver into the kernel whenever needed and remove
it when it finished its work. There are some drivers which are in built to the
kernel and some are loaded when require. In general, device driver is a
software layer that lies between the applications and the actual device.
Application uses the hardware and driver provides an interface between the
application and the hardware.
Types of device drivers:
1. Character driver
2. Block driver
3. Network driver
Introduction to character driver.
A character device driver provides a communication interface to a device
that can be accessed as a stream of bytes. These drivers generally perform
open,read,write and close operations. Data can be read and written to the
device as a stream of bytes. Eg., Serial port device driver.
Loading driver into the kernel.
A module is inserted into the kernel at run time using command 'insmod
name.ko'. This calles a function specified in the macro module_init().
module_init() is a driver initialization entry point, which must be called at
module insertion time. The program loads the module code and data into
the kernel and links any unresolved symbol in the module to the symbol
table of the kernel.
Unloading driver from the kernel.
When the driver finishes its work or the device plugged out from the
system, we should run rmmod command to remove the driver from the
kernel. when system executes rmmod command,it calles a function
specified in the macro module_exit(). module_exit() is a driver exit entry
point which must be called when removing a module. Module removal
program may fails if the module is still in use by any other application.
Operations to be performed in initialization function.
Use function alloc_chrdev_region() to register our driver. Device drivers are
identified using Major number and minor number. The major number
specifies which driver to use and devices connected to the driver are
identified by the minor numbers. There is only one Major number given to
the driver and it is the highest available number. Minor number varies in
accordance to the devices connected to the driver and starts from 0. The
alloc_chrdev_region(dev_t *dev, unsigned int firstminor, unsigned int
count, char *name), on successful completion provides the major and
minor number, holds in the first argument dev, count is device numbers
requested, and name is our driver name, appears in /proc/devices.
Operations to be performed in cleanup function.
When driver finishes its work we should remove it from the kernel and for
this undone whatever we did in the initialization function. Unregister the
driver using function call unregister_chrdev_region(dev_t first, unsigned int
count), where first is the dev number obtained by the call
alloc_chrdev_region() and count is number of minor numbers we requested
for device in alloc_chrdev_region() call.

More Related Content

Viewers also liked

从动态说开去
从动态说开去从动态说开去
从动态说开去gowell
 
使用Lua提高开发效率
使用Lua提高开发效率使用Lua提高开发效率
使用Lua提高开发效率gowell
 
Logging introduce
Logging introduceLogging introduce
Logging introducegowell
 
Albin profile
Albin profileAlbin profile
Albin profileAlbin B
 
How to configure an environment to cross-compile applications for beagleboard-xM
How to configure an environment to cross-compile applications for beagleboard-xMHow to configure an environment to cross-compile applications for beagleboard-xM
How to configure an environment to cross-compile applications for beagleboard-xMDalton Valadares
 
Internet of Things Stack
Internet of Things StackInternet of Things Stack
Internet of Things StackPostscapes
 
Lua 语言介绍
Lua 语言介绍Lua 语言介绍
Lua 语言介绍gowell
 
Linux one page manual
Linux one page manualLinux one page manual
Linux one page manualguestcc3a6f
 
Impact of the Internet of Things on Manufacturers
Impact of the Internet of Things on ManufacturersImpact of the Internet of Things on Manufacturers
Impact of the Internet of Things on ManufacturersPTC
 
C Cross Compile for Linkit Smart 7688
C Cross Compile for Linkit Smart 7688C Cross Compile for Linkit Smart 7688
C Cross Compile for Linkit Smart 7688Nattapong Rodmuang
 
Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64Samsung Open Source Group
 

Viewers also liked (15)

Company profile
Company profileCompany profile
Company profile
 
从动态说开去
从动态说开去从动态说开去
从动态说开去
 
使用Lua提高开发效率
使用Lua提高开发效率使用Lua提高开发效率
使用Lua提高开发效率
 
Logging introduce
Logging introduceLogging introduce
Logging introduce
 
Albin profile
Albin profileAlbin profile
Albin profile
 
How to configure an environment to cross-compile applications for beagleboard-xM
How to configure an environment to cross-compile applications for beagleboard-xMHow to configure an environment to cross-compile applications for beagleboard-xM
How to configure an environment to cross-compile applications for beagleboard-xM
 
Internet of Things Stack
Internet of Things StackInternet of Things Stack
Internet of Things Stack
 
Gdb remote debugger
Gdb remote debuggerGdb remote debugger
Gdb remote debugger
 
Lua 语言介绍
Lua 语言介绍Lua 语言介绍
Lua 语言介绍
 
Driver_linux
Driver_linuxDriver_linux
Driver_linux
 
Linux one page manual
Linux one page manualLinux one page manual
Linux one page manual
 
ravi kumar
ravi kumarravi kumar
ravi kumar
 
Impact of the Internet of Things on Manufacturers
Impact of the Internet of Things on ManufacturersImpact of the Internet of Things on Manufacturers
Impact of the Internet of Things on Manufacturers
 
C Cross Compile for Linkit Smart 7688
C Cross Compile for Linkit Smart 7688C Cross Compile for Linkit Smart 7688
C Cross Compile for Linkit Smart 7688
 
Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64Tutorial: Cross-compiling Linux Kernels on x86_64
Tutorial: Cross-compiling Linux Kernels on x86_64
 

Recently uploaded

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
“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
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 

Recently uploaded (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
“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...
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 

What is a Device Driver?

  • 1. What is a device driver? Device driver is a software program that makes a particular piece of hardware to respond to a well-defined internal programming interface. The programming interface means whenever hardware is connected to the system, that interface will invoke the specific driver for a specific device. The interface loads the driver into the kernel whenever needed and remove it when it finished its work. There are some drivers which are in built to the kernel and some are loaded when require. In general, device driver is a software layer that lies between the applications and the actual device. Application uses the hardware and driver provides an interface between the application and the hardware. Types of device drivers: 1. Character driver 2. Block driver 3. Network driver Introduction to character driver. A character device driver provides a communication interface to a device that can be accessed as a stream of bytes. These drivers generally perform open,read,write and close operations. Data can be read and written to the device as a stream of bytes. Eg., Serial port device driver. Loading driver into the kernel. A module is inserted into the kernel at run time using command 'insmod name.ko'. This calles a function specified in the macro module_init(). module_init() is a driver initialization entry point, which must be called at module insertion time. The program loads the module code and data into the kernel and links any unresolved symbol in the module to the symbol table of the kernel. Unloading driver from the kernel. When the driver finishes its work or the device plugged out from the system, we should run rmmod command to remove the driver from the kernel. when system executes rmmod command,it calles a function specified in the macro module_exit(). module_exit() is a driver exit entry point which must be called when removing a module. Module removal program may fails if the module is still in use by any other application.
  • 2. Operations to be performed in initialization function. Use function alloc_chrdev_region() to register our driver. Device drivers are identified using Major number and minor number. The major number specifies which driver to use and devices connected to the driver are identified by the minor numbers. There is only one Major number given to the driver and it is the highest available number. Minor number varies in accordance to the devices connected to the driver and starts from 0. The alloc_chrdev_region(dev_t *dev, unsigned int firstminor, unsigned int count, char *name), on successful completion provides the major and minor number, holds in the first argument dev, count is device numbers requested, and name is our driver name, appears in /proc/devices. Operations to be performed in cleanup function. When driver finishes its work we should remove it from the kernel and for this undone whatever we did in the initialization function. Unregister the driver using function call unregister_chrdev_region(dev_t first, unsigned int count), where first is the dev number obtained by the call alloc_chrdev_region() and count is number of minor numbers we requested for device in alloc_chrdev_region() call.