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

FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
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
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 

Recently uploaded (20)

FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
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🔝
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
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
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 

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.