Device Driver Architecture Overview
Device drivers are software modules that can be plugged into an OS to handle a particular device. Operating System takes help from device drivers to handle all I/O devices. There are various types of device drivers for I/O devices such as keyboards,printers, CD/DVD etc.
Device Drivers can be programmed for Character devices or Block devices. A Character Device is a device whose driver communicates by sending and receiving single characters (bytes, octets). Example - serial ports, parallel ports, sound cards, keyboard. A Block Device is a device whose driver communicates by sending entire blocks of data. Example - hard disks, USB cameras, Disk-On-Key.
Overview of how an application in user space interacts with the device via Device Drivers:
An operating system's virtual memory is segregated into user space(swappable paged memory) and kernel space(unswappable paged memory).This separation provides memory and hardware protection from malicious or errant software behaviour.Whenever a user space application needs an access to the resources or services of the kernel it does so by using system calls. Each system call invoked by the user space application is handled by its corresponding SCR (system call routine). Handling each system call invocation by the application creates an overhead in the kernel, as it requires switching from user mode to kernel mode and vice-verse, therefore some of the frequently used system calls are handled by the libraries which are present in the user – space.
In every operating system there exists an I/O space, size of which depends on the device it is connected to, it varies from 512 Bytes to 4K. I/O space consists of ports like ethernet port , wifi port etc. where the device is connected.
An application which needs to access the devices in I/O space shall do it using device drivers via intermediate buffers(kernel buffer) present in the kernel space. It does so by using VFS(Virtual File System) which keeps the device file as an inode.
Memory
is divided into 3 Sections :
1. User Space (Swappable Paged Memory) , Size of Pages=4k
2.
Kernel Space (Umswappable Paged Memory) , Size of Pages=4k
3.
IO Space (Block Memory) in this the Size depends upon the Hardware it
is connected with (512bytes,1k,2k,4k)
In
IO Space the Hardware Devices are connecte with the System through
the ports . So whenever the devices are connected in IO space , it
leads to the Creation of an Application in the US which will further
make the System Call and the System Call Routine (SCR) will execute ,
the application interacts with SCR , the application access the files
with the help of Virtual File system , for execution of the kernel
code all Switching between the user Space and the Kernel Space takes
place , those system calls which are very frequent are kept in the
User Space in the form of Libraries, with the help of SCR a
connection is established between the application and the Kernel
buffer and with this kernel buffer , the link is generated between
the the kernel and the hardware device.
Brief:
Whenever
we connect any Hardwarwe Device to the system , with the help of
ports , it requires driver . Whenever a new device is connected a
Hardware interrupt is generated and that interrupt goes to the
Interrupt Vector Table (IVT), which cotains the list of all the
Hardware interrupts , these interrupts are generated by all the
hardware connected to the system , the IVT futher has 3 Columns -Interrupt Id , Interrupt Argument , pointer to Interrupt Servie
Routine , which if further connected with the Device Table (Consists
the list of Available Device Driver ), for example – if we connect
a Pendrive with the system it will check the USB driver in the Device
Table , if its there in the Table , it will load it into the kernel ,
futher is checks the USB Storage Driver and if prersent ,loads into
the kernel , Software interrupts are generated and futher the
Requirements are checked with the Firmware of the Device and the
Drivers are loaded according to the Device Requirement and a
connection is established .
p { margin-bottom: 0.25cm; line-height: 120%; }
Another
Overview of the Device Drivers
Kernel overview:
The kernel manages
the system resources, including file systems, processes, and physical
devices. The kernel provides applications with system services such
as I/O management, virtual memory, and scheduling. The kernel
coordinates interactions of all user processes and system resources.
The kernel assigns priorities, services resource requests, and
services hardware interrupts and exceptions. The kernel schedules and
switches threads, pages memory, and swaps processes.
Difference between
Kernel Modules and User Programss
1.Kernel space and
user space have their own memory address spaces
2.Code that runs in
kernel space has greater privilege than code that runs in user space
3.A user program
typically executes sequentially and performs a single task from
beginning to end.A kernel module does not execute sequentially.
4.Kernel modules,
including device drivers, have no maine routine.device driver is a
kernel module that forms a software interface to an input/output
(I/O) device
5.Kernel modules do
not link in the same libraries that user programs link in.
Device Driver:-
A device driver is a
loadable kernel module that manages data transfers between a device
and the OS. Loadable modules are loaded at boot time or by request
and are unloaded by request. A device driver is a collection of C
routines and data structures that can be accessed by other kernel
modules.A device driver is a loadable kernel module that manages data
transfers between a device and the OS. Loadable modules are loaded at
boot time or by request and are unloaded by request. A device driver
is a collection of C routines and data structures that can be
accessed by other kernel modules. These routines must use standard
interfaces called entry points.Through the use of entry points, the
calling modules are shielded from the internal details of the driver.
Character device
driver:-
Character device
drivers normally perform I/O in a byte stream. Examples of devices
using character drivers include tape drives and serial ports.
It looks like you're new here. If you want to get involved, click one of these buttons!