0% found this document useful (0 votes)
129 views14 pages

Device Drivers 1

Any peripheral connected to a computer is considered a device. Device drivers allow the operating system to communicate with devices by translating requests between the OS and device hardware. There are three main classes of devices: character devices accessed as a stream of bytes, block devices which can host file systems accessed in blocks, and network devices which connect computers over a network. Device drivers act as software interfaces between the OS kernel and hardware devices, hiding device-specific details and allowing different users to access devices in different ways.

Uploaded by

api-3774180
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
129 views14 pages

Device Drivers 1

Any peripheral connected to a computer is considered a device. Device drivers allow the operating system to communicate with devices by translating requests between the OS and device hardware. There are three main classes of devices: character devices accessed as a stream of bytes, block devices which can host file systems accessed in blocks, and network devices which connect computers over a network. Device drivers act as software interfaces between the OS kernel and hardware devices, hiding device-specific details and allowing different users to access devices in different ways.

Uploaded by

api-3774180
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 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 User
Program Space

Rest of the Operating System


Kernel
Space
Printer Scanner CD-ROM
Driver Driver Driver

Printer Scanner CD-ROM


Hardware Controller Controller Controller

Devices
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.

You might also like