Device Drivers 1
Device Drivers 1
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
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.