= Frequently Asked Questions = [[TracNav(CT)]] In this section we describe and resolve several issues that someone who is working with drivers programming will have. [[PageOutline(2, Overview, inline)]] == What is a Linux Device Driver? == The purpose of a device driver is to handle requests made by the kernel regarding a particular device. The Linux kernel architecture is flexible enough to add new modules into a running kernel using the module insertion facility. There is a well-defined and consistent interface for the kernel to make these requests. Since, the device-specific code in device drivers and their interface to the kernel is consistent, adding a new device driver is easier. There are two ways a Linux driver can reside in Linux kernel: * Built in Drivers: These are precompiled drivers existing in the kernel normally, they reside in "/lib/modules/2.4.20-8/kernel/drivers" directory. * Loadable modules: The kernel modules can be loaded using module insertion facility. This is available using insmod command. == Why do we need Device driver? == Computer contains different hardware to perform different functions as per user requests. Such as CD player, Mouse, Floppy disks, Display, Keyboard, Wireless network card and so on. All these hardware needs to have some short of mechanism to translate user actions into the desired functions. For example when user click types some thing from key board the system must show the keystrokes on display (if he is using any word document ,text document or any other editor).So we can see that there are numbers of steps involved between user’s action and out put he gets on the screen. 1. Key strokes are converted in to proper electrical signals (bits / bytes).[[BR]] 2. These appropriate bytes are forwarded to the particular program.[[BR]] 3. Operating system plays a vital role here in the interaction of hardware (key board) and the display program (editor) it translates user requests into appropriate actions.[[BR]] Another example is detachable Wireless card. As soon as the wireless card is plugged in to the right slot of the computer, the operating system (device driver part written for this card ) takes care of different functions require to make the card available for user communication. The driver registers the device as if it is an integral part of the computer, then it sets different parameters (power, frequency, mode of operation and so on depending upon the card as well as driver)necessary for the card to communicate properly. Once the card is live it listens from other computers / Wireless Access point and forwards the packet (data packet / broadcast packet or any other payload depending upon the communication protocol established) to the kernel. Here the device driver does this task to forward the packet to the kernel (there is a lot of processing that takes place on the card itself at a hardware level before the packet id forwarded to the device driver). If user initiates the communication the entire procedure is reversed. Data travels from user program to kernel and from kernel to actual hardware and from there it travels using wireless medium. There are numerous example of device driver that we use daily life (If you are a computer geek) == What are different types of device drivers? == As we already have seen couple of examples it is advisable to classify device driver in different groups based on the way they communicate in terms of data capacity. * ''Character device driver'' * ''Block device drive'' * ''Network Device Driver'' '''Char Device drivers''': A character device driver handles I/O using a character at a time instead of buffer caches. Because of their flexibility in handling I/O, many drivers are character drivers. Examples are Line Printer drivers, terminal drivers. '''Block Device drivers''': A block device driver performs I/O by using file system block-sized buffers from a buffer cache supplied by the kernel. The kernel provides the device driver support interfaces that copy data between the buffer cache and the process address space. Examples are Disk drives. '''Network Device drivers''': A network device driver attaches a network subsystem to a network interface, prepares the network interface for operation and governs the transmission and reception of network frames over the network interface. Examples are Ethernet Card, Wireless LAN card. '''Pseudo Device drivers''': Pseudo drivers can be written for virtual devices like terminals. The pseudo drivers can be written as char drivers or network drivers. '''Differences and similarities among these drivers''' The interfaces and the architecture of Char and Block drivers is very similar and only differ in the driver APIs provided by the kernel. ----