Device Drivers 1

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Device Drivers 1 as PDF for free.

More details

  • Words: 482
  • Pages: 14
What is a Device • Any peripheral such as a graphics display , disk driver, terminal, or printer is a device. • A device is usually considered to be piece of hardware that you can connect to your computer system and that you wish to manipulate by sending command and data.

Device Drivers User Space

User Program

Rest of the Operating System Kernel Space

Hardware Devices

Printer Driver

Scanner Driver

CD-ROM Driver

Printer Controller

Scanner Controller

CD-ROM Controller

Classes of Devices • Character Devices • Block Devices • Network Devices

Character Devices • Accessed as a stream of bytes (like a file) • Such drivers at least implement open, close, read and write system calls • Examples: – /dev/console (Text Console) – /dev/ttyS0 (Serial Ports) – /dev/lp0 (Line Printers)

Block Devices • Block devices also accessed by filesystem nodes in the /dev directory • Block device can host a filesystem such as a disk • Block devices can be accessed only as multiple of blocks, where block is generally as 1KB or another power of 2

Network Devices • Any network interconnection is made through the interface (device), that is able to exchange data with other hosts. • Transactions made using an Interface • Interface can be hardware or software • Interface is incharge of sending and receiving data packets • Network Interface isn’t easily mapped to a node in the filesystem • Though UNIX will map it as eth0

Linux Kernel Internals

Split view of kernel

Linux Device Driver • Distinct Black Boxes • And they make a particular piece of H/W, respond to a well-defined internal programming interface • They hide completely the details of how the device works

Contd… • A ‘C’ program that controls a device • They stand between kernel and peripherals, translating requests for work into activities by hardware.

Device Drivers • A device controller has: – Control registers – Status registers – Data buffers

• This structure changes from device to device – A mouse driver should know how far the mouse has moved and which buttons are pressed – A disk driver should know about sectors, tracks, cylinders, heads, arm motion, motor drives, head settling times, …

• Each I/O device need some device specific code for controlling it. – This code is called device driver.

Remember “Write Kernel Code to access the hardware, but don’t force particular policies on the user, since different users have different needs”

I/O Software Layers User Space

User Level I/O Software Device Independent Operating System Software

Kernel Space

Device Drivers Interrupt Handlers Hardware

Kernel Modules Vs Applications • Applications performs a single task from beginning to end, A module regisres itself in order to serve future requests. • Application call functions resolves external references using appropriate lib functions during link stage, whereas modules are linked only to kernel, and only functions it can call are exported by kernel.

Related Documents

Device Drivers
November 2019 41
Device Drivers 1
November 2019 18
Linux Device Drivers
May 2020 11