Device driver
Encyclopedia
In computing, a device driver or software driver is a computer program
Computer program
A computer program is a sequence of instructions written to perform a specified task with a computer. A computer requires programs to function, typically executing the program's instructions in a central processor. The program has an executable form that the computer can use directly to execute...

 allowing higher-level computer programs to interact with a hardware device.

A driver typically communicates with the device
Peripheral
A peripheral is a device attached to a host computer, but not part of it, and is more or less dependent on the host. It expands the host's capabilities, but does not form part of the core computer architecture....

 through the computer bus
Computer bus
In computer architecture, a bus is a subsystem that transfers data between components inside a computer, or between computers.Early computer buses were literally parallel electrical wires with multiple connections, but the term is now used for any physical arrangement that provides the same...

 or communications subsystem to which the hardware connects. When a calling program invokes a routine
Subroutine
In computer science, a subroutine is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code....

 in the driver, the driver issues commands to the device. Once the device sends data back to the driver, the driver may invoke routines in the original calling program. Drivers are hardware-dependent and operating-system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

-specific. They usually provide the interrupt
Interrupt
In computing, an interrupt is an asynchronous signal indicating the need for attention or a synchronous event in software indicating the need for a change in execution....

 handling required for any necessary asynchronous time-dependent hardware interface.

Purpose

A device driver simplifies programming by acting as translator between a hardware device and the applications or operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

s that use it. Programmers can write the higher-level application code independently of whatever specific hardware device.

Design

Device drivers can be abstracted into logical and physical layer
Physical layer
The physical layer or layer 1 is the first and lowest layer in the seven-layer OSI model of computer networking. The implementation of this layer is often termed PHY....

s. Logical layers process data for a class of devices such as Ethernet
Ethernet
Ethernet is a family of computer networking technologies for local area networks commercially introduced in 1980. Standardized in IEEE 802.3, Ethernet has largely replaced competing wired LAN technologies....

 ports or disk drives. Physical layers communicate with specific device instances. For example, a serial port
Serial port
In computing, a serial port is a serial communication physical interface through which information transfers in or out one bit at a time...

 needs to handle standard communication protocols such as XON/XOFF that are common for all serial port hardware. This would be managed by a serial port logical layer. However, the physical layer needs to communicate with a particular serial port chip. 16550 UART
16550 UART
The 16550 UART is an integrated circuit designed for implementing the interface for serial communications...

 hardware differs from PL-011. The physical layer addresses these chip-specific variations. Conventionally, OS requests go to the logical layer first. In turn, the logical layer calls upon the physical layer to implement OS requests in terms understandable by the hardware. Inversely, when a hardware device needs to respond to the OS, it uses the physical layer to speak to the logical layer.

In Linux
Linux kernel
The Linux kernel is an operating system kernel used by the Linux family of Unix-like operating systems. It is one of the most prominent examples of free and open source software....

 environments, programmers can build device drivers either as parts of the kernel
Linux kernel
The Linux kernel is an operating system kernel used by the Linux family of Unix-like operating systems. It is one of the most prominent examples of free and open source software....

 or separately as loadable module
Loadable Kernel Module
In computing, a loadable kernel module is an object file that contains code to extend the running kernel, or so-called base kernel, of an operating system...

s. Makedev includes a list of the devices in Linux: ttyS (terminal), lp (parallel port
Parallel port
A parallel port is a type of interface found on computers for connecting various peripherals. In computing, a parallel port is a parallel communication physical interface. It is also known as a printer port or Centronics port...

), hd (disk), loop (loopback disk device), sound (these include mixer
Sound card mixer
A sound card mixer is the analog part of a sound card that routes and mixes sound signals. This circuit receives inputs from both external connectors and the sound card's digital-to-analog converters...

, sequencer
Music sequencer
The music sequencer is a device or computer software to record, edit, play back the music, by handling note and performance information in several forms, typically :...

, dsp
Digital signal processor
A digital signal processor is a specialized microprocessor with an architecture optimized for the fast operational needs of digital signal processing.-Typical characteristics:...

, and audio)...

The Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 .sys files and Linux .ko modules contain loadable device drivers. The advantage of loadable device drivers is that they can be loaded only when necessary and then unloaded, thus saving kernel memory.

Development

Writing a device driver requires an in-depth understanding of how the hardware and the software of a given platform function. Drivers operate in a highly privilege
Privilege (Computing)
In computing, privilege is defined as the delegation of authority over a computer system. A privilege is a permission to perform an action. Examples of various privileges include the ability to create a file in a directory, or to read or delete a file, access a device, or have read or write...

d environment and can cause disaster if they get things wrong. In contrast, most user-level software on modern operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

s can be stopped without greatly affecting the rest of the system. Even drivers executing in user mode can crash a system if the device is erroneously programmed. These factors make it more difficult and dangerous to diagnose problems.

Thus the task of writing drivers usually falls to software engineer
Software engineer
A software engineer is an engineer who applies the principles of software engineering to the design, development, testing, and evaluation of the software and systems that make computers or anything containing software, such as computer chips, work.- Overview :...

s who work for hardware-development companies. This is because they have better information than most outsiders about the design of their hardware. Moreover, it was traditionally considered in the hardware manufacturer's interest to guarantee that their clients can use their hardware in an optimum way. Typically, the logical device driver (LDD) is written by the operating system vendor, while the physical device driver (PDD) is implemented by the device vendor. But in recent years non-vendors have written numerous device drivers, mainly for use with free and open source
Free and open source software
Free and open-source software or free/libre/open-source software is software that is liberally licensed to grant users the right to use, study, change, and improve its design through the availability of its source code...

 operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

s. In such cases, it is important that the hardware manufacturer provides information on how the device communicates. Although this information can instead be learned by reverse engineering
Reverse engineering
Reverse engineering is the process of discovering the technological principles of a device, object, or system through analysis of its structure, function, and operation...

, this is much more difficult with hardware than it is with software.

Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

 has attempted to reduce system instability due to poorly written device drivers by creating a new framework for driver development, called Windows Driver Foundation
Windows Driver Foundation
Windows Driver Foundation is a set of Microsoft tools that aid in the creation of device drivers for Windows 2000 and later versions of Windows....

 (WDF). This includes User-Mode Driver Framework (UMDF) that encourages development of certain types of drivers — primarily those that implement a message-based protocol for communicating with their devices — as user mode drivers. If such drivers malfunction, they do not cause system instability. The Kernel-Mode Driver Framework (KMDF) model continues to allow development of kernel-mode device drivers, but attempts to provide standard implementations of functions that are well known to cause problems, including cancellation of I/O operations, power management, and plug and play device support.

Apple has an open-source framework for developing drivers on Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

 called the I/O Kit
I/O Kit
The I/O Kit is an open-source framework in the XNU kernel that helps developers code device drivers for Apple's Mac OS X and iOS operating systems...

.

Kernel-mode vs user-mode

Device drivers, particularly on Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 platforms, can run in kernel-mode
CPU modes
CPU modes are operating modes for the central processing unit of some computer architectures that place restrictions on the type and scope of operations that can be performed by certain processes being run by the CPU...

 (Ring 0 on x86 CPUs
Ring (computer security)
In computer science, hierarchical protection domains, often called protection rings, are a mechanism to protect data and functionality from faults and malicious behaviour . This approach is diametrically opposite to that of capability-based security.Computer operating systems provide different...

) or in user-mode
User space
A conventional computer operating system usually segregates virtual memory into kernel space and user space. Kernel space is strictly reserved for running the kernel, kernel extensions, and most device drivers...

 (Ring 3 on x86 CPUs). The primary benefit of running a driver in user mode is improved stability, since a poorly written user mode device driver cannot crash the system by overwriting kernel memory. On the other hand, user/kernel-mode transitions usually impose a considerable performance overhead, thereby prohibiting user mode-drivers for low latency and high throughput requirements.

Kernel space can be accessed by user module only through the use of system calls.
End user programs like the UNIX shell or other GUI based applications are part of the user space. These applications interact with hardware through kernel supported functions.

Applications

Because of the diversity of hardware
Hardware
Hardware is a general term for equipment such as keys, locks, hinges, latches, handles, wire, chains, plumbing supplies, tools, utensils, cutlery and machine parts. Household hardware is typically sold in hardware stores....

 and operating systems, drivers operate in many different environments. Drivers may interface
Interface (computer science)
In the field of computer science, an interface is a tool and concept that refers to a point of interaction between components, and is applicable at the level of both hardware and software...

 with:
  • printers
    Computer printer
    In computing, a printer is a peripheral which produces a text or graphics of documents stored in electronic form, usually on physical print media such as paper or transparencies. Many printers are primarily used as local peripherals, and are attached by a printer cable or, in most new printers, a...

  • video adapters
    Video card
    A video card, Graphics Card, or Graphics adapter is an expansion card which generates output images to a display. Most video cards offer various functions such as accelerated rendering of 3D scenes and 2D graphics, MPEG-2/MPEG-4 decoding, TV output, or the ability to connect multiple monitors...

  • network cards
  • sound card
    Sound card
    A sound card is an internal computer expansion card that facilitates the input and output of audio signals to and from a computer under control of computer programs. The term sound card is also applied to external audio interfaces that use software to generate sound, as opposed to using hardware...

    s
  • local buses
    Computer bus
    In computer architecture, a bus is a subsystem that transfers data between components inside a computer, or between computers.Early computer buses were literally parallel electrical wires with multiple connections, but the term is now used for any physical arrangement that provides the same...

     of various sorts — in particular, for bus mastering
    Bus mastering
    In computing, bus mastering is a feature supported by many bus architectures that enables a device connected to the bus to initiate transactions...

     on modern systems
  • low-bandwidth
    Bandwidth (computing)
    In computer networking and computer science, bandwidth, network bandwidth, data bandwidth, or digital bandwidth is a measure of available or consumed data communication resources expressed in bits/second or multiples of it .Note that in textbooks on wireless communications, modem data transmission,...

     I/O
    Input/output
    In computing, input/output, or I/O, refers to the communication between an information processing system , and the outside world, possibly a human, or another information processing system. Inputs are the signals or data received by the system, and outputs are the signals or data sent from it...

     buses of various sorts (for pointing device
    Pointing device
    A pointing device is an input interface that allows a user to input spatial data to a computer...

    s such as mice, keyboard
    Computer keyboard
    In computing, a keyboard is a typewriter-style keyboard, which uses an arrangement of buttons or keys, to act as mechanical levers or electronic switches...

    s, USB
    Universal Serial Bus
    USB is an industry standard developed in the mid-1990s that defines the cables, connectors and protocols used in a bus for connection, communication and power supply between computers and electronic devices....

    , etc.)
  • computer storage
    Computer storage
    Computer data storage, often called storage or memory, refers to computer components and recording media that retain digital data. Data storage is one of the core functions and fundamental components of computers....

     devices such as hard disk, CD-ROM
    CD-ROM
    A CD-ROM is a pre-pressed compact disc that contains data accessible to, but not writable by, a computer for data storage and music playback. The 1985 “Yellow Book” standard developed by Sony and Philips adapted the format to hold any form of binary data....

     and floppy disk
    Floppy disk
    A floppy disk is a disk storage medium composed of a disk of thin and flexible magnetic storage medium, sealed in a rectangular plastic carrier lined with fabric that removes dust particles...

     buses (ATA, SATA
    Serial ATA
    Serial ATA is a computer bus interface for connecting host bus adapters to mass storage devices such as hard disk drives and optical drives...

    , SCSI
    SCSI
    Small Computer System Interface is a set of standards for physically connecting and transferring data between computers and peripheral devices. The SCSI standards define commands, protocols, and electrical and optical interfaces. SCSI is most commonly used for hard disks and tape drives, but it...

    )
  • implementing support for different file system
    File system
    A file system is a means to organize data expected to be retained after a program terminates by providing procedures to store, retrieve and update data, as well as manage the available space on the device which contain it. A file system organizes data in an efficient manner and is tuned to the...

    s
  • image scanner
    Image scanner
    In computing, an image scanner—often abbreviated to just scanner—is a device that optically scans images, printed text, handwriting, or an object, and converts it to a digital image. Common examples found in offices are variations of the desktop scanner where the document is placed on a glass...

    s
  • digital camera
    Digital camera
    A digital camera is a camera that takes video or still photographs, or both, digitally by recording images via an electronic image sensor. It is the main device used in the field of digital photography...

    s


Common levels of abstraction for device drivers include:
  • for hardware:
    • interfacing directly
    • writing to or reading from a device control register
      Device control register
      A device control register is a register that resides in an element of a System-on-a-chip and allows to configure, control and probe this element....

    • using some higher-level interface (e.g. Video BIOS
      Video BIOS
      Video BIOS is the BIOS of a graphics card in a computer.Much the way the system BIOS provides a set of functions that are used by software programs to access the system hardware, the video BIOS provides a set of video-related functions that are used by programs to access the video hardware...

      )
    • using another lower-level device driver (e.g. file system drivers using disk drivers)
    • simulating work with hardware, while doing something entirely different
  • for software:
    • allowing the operating system direct access to hardware resources
    • implementing only primitives
    • implementing an interface for non-driver software (e.g. TWAIN
      TWAIN
      TWAIN is a standard software protocol and applications programming interface that regulates communication between software applications and imaging devices such as scanners and digital cameras....

      )
    • implementing a language, sometimes quite high-level (e.g. PostScript
      PostScript
      PostScript is a dynamically typed concatenative programming language created by John Warnock and Charles Geschke in 1982. It is best known for its use as a page description language in the electronic and desktop publishing areas. Adobe PostScript 3 is also the worldwide printing and imaging...

      )


Choosing and installing the correct device drivers for given hardware is often a key component of computer system configuration.

Virtual device drivers

Virtual device drivers represent a particular variant of device drivers. They are used to emulate a hardware device, particularly in virtualization
Virtual machine
A virtual machine is a "completely isolated guest operating system installation within a normal host operating system". Modern virtual machines are implemented with either software emulation or hardware virtualization or both together.-VM Definitions:A virtual machine is a software...

 environments, for example when a DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

 program is run on a Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 computer or when a guest operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

 is run on, for example, a Xen
Xen
Xen is a virtual-machine monitor providing services that allow multiple computer operating systems to execute on the same computer hardware concurrently....

 host. Instead of enabling the guest operating system to dialog with hardware, virtual device drivers take the opposite role and emulate a piece of hardware, so that the guest operating system and its drivers running inside a virtual machine
Virtual machine
A virtual machine is a "completely isolated guest operating system installation within a normal host operating system". Modern virtual machines are implemented with either software emulation or hardware virtualization or both together.-VM Definitions:A virtual machine is a software...

 can have the illusion of accessing real hardware. Attempts by the guest operating system to access the hardware are routed to the virtual device driver in the host operating system as e.g. function calls. The virtual device driver can also send simulated processor-level events like interrupt
Interrupt
In computing, an interrupt is an asynchronous signal indicating the need for attention or a synchronous event in software indicating the need for a change in execution....

s into the virtual machine.

Virtual devices may also operate in a non-virtualized environment. For example a virtual network adapter is used with a virtual private network
Virtual private network
A virtual private network is a network that uses primarily public telecommunication infrastructure, such as the Internet, to provide remote offices or traveling users access to a central organizational network....

, while a virtual disk device is used with iSCSI
ISCSI
In computing, iSCSI , is an abbreviation of Internet Small Computer System Interface, an Internet Protocol -based storage networking standard for linking data storage facilities. By carrying SCSI commands over IP networks, iSCSI is used to facilitate data transfers over intranets and to manage...

.
The best example for virtual device drivers can be "Daemon Tools"

Open drivers

  • Printers: CUPS
  • RAIDs: CCISS (Compaq Command Interface for SCSI-3 Support)
  • Scanners: SANE
    Scanner Access Now Easy
    Scanner Access Now Easy is an application programming interface that provides standardized access to any raster image scanner hardware ....

  • Video: Vidix
    Vidix
    VIDIX is a portable programming interface for Unix-like operating systems that allows video card drivers running in user space to directly access the framebuffer through Direct Graphics Access extension to the X Window System.-History:Nick Kurshev, the author of VIDIX, writes that his motivation...

    , Direct Rendering Infrastructure
    Direct Rendering Infrastructure
    In computing, the Direct Rendering Infrastructure is an interface and a free software implementation used in the X Window System to securely allow user applications to access the video hardware without requiring data to be passed through the X server. Its primary application is to provide...



Solaris descriptions of commonly-used device drivers
  • fas: Fast/wide SCSI controller
  • hme: Fast (10/100 Mbit/s) Ethernet
  • isp: Differential SCSI controllers and the SunSwift card
  • glm: (Gigabaud Link Module) UltraSCSI controllers
  • scsi: Small Computer Serial Interface (SCSI) devices
  • sf: soc+ or social Fiber Channel Arbitrated Loop (FCAL)
  • soc: SPARC Storage Array (SSA) controllers
  • social: Serial optical controllers for FCAL (soc+)

APIs

  • Windows Display Driver Model
    Windows Display Driver Model
    Windows Display Driver Model is the graphic driver architecture for video card drivers running Microsoft Windows versions beginning with Windows Vista....

     (WDDM) – the graphic display driver architecture for Windows Vista
    Windows Vista
    Windows Vista is an operating system released in several variations developed by Microsoft for use on personal computers, including home and business desktops, laptops, tablet PCs, and media center PCs...

  • Windows Driver Foundation
    Windows Driver Foundation
    Windows Driver Foundation is a set of Microsoft tools that aid in the creation of device drivers for Windows 2000 and later versions of Windows....

     (WDF)
  • Windows Driver Model
    Windows Driver Model
    In computing, the Windows Driver Model — also known at one point as the Win32 Driver Model — is a framework for device drivers that was introduced with Windows 98 and Windows 2000 to replace VxD, which was used on older versions of Windows such as Windows 95 and Windows 3.1, as well...

     (WDM)
  • Network Driver Interface Specification
    Network Driver Interface Specification
    The Network Driver Interface Specification is an application programming interface for network interface cards . It was jointly developed by Microsoft and 3Com Corporation, and is mostly used in Microsoft Windows, but the open-source NDISwrapper and Project Evil driver wrapper projects allow...

     (NDIS) – a standard network card
    Network card
    A network interface controller is a computer hardware component that connects a computer to a computer network....

     driver API
  • Advanced Linux Sound Architecture (ALSA) – the standard Linux sound-driver interface
  • Scanner Access Now Easy
    Scanner Access Now Easy
    Scanner Access Now Easy is an application programming interface that provides standardized access to any raster image scanner hardware ....

     (SANE) – a public-domain interface to raster-image scanner-hardware
  • I/O Kit
    I/O Kit
    The I/O Kit is an open-source framework in the XNU kernel that helps developers code device drivers for Apple's Mac OS X and iOS operating systems...

     – an open-source framework from Apple
    Apple Computer
    Apple Inc. is an American multinational corporation that designs and markets consumer electronics, computer software, and personal computers. The company's best-known hardware products include the Macintosh line of computers, the iPod, the iPhone and the iPad...

     for developing Mac OS X
    Mac OS X
    Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

     device drivers
  • Installable File System
    Installable File System
    The Installable File System is a filesystem API in IBM OS/2 and Microsoft Windows that enables the operating system to recognize and load drivers for file systems...

     (IFS) – a filesystem API
    Filesystem API
    A file system API is an application programming interface through which a utility or user program requests services of a file system. An operating system may provide abstractions for accessing different file systems transparently....

     for IBM OS/2 and Microsoft Windows NT
  • Open Data-Link Interface
    Open Data-Link Interface
    The Open Data-Link Interface , developed by Apple and Novell, serves the same function as Microsoft and 3COM's Network Driver Interface Specification . Originally, ODI was written for NetWare and Macintosh environments. Like NDIS, ODI provides rules that establish a vendor-neutral interface between...

     (ODI) – a network card API similar to NDIS
  • Uniform Driver Interface
    Uniform Driver Interface
    The Uniform Driver Interface is a defunct project developed by several companies to define a portable interface for device drivers....

     (UDI) – a cross-platform driver interface project
  • Dynax Driver Framework (dxd) – C++ open source cross-platform driver framework for KMDF and IOKit

Identifiers

A device on the PCI or USB bus is identified by two ID's which consist of 4 numbers and/or letters A to F. The vendor ID identifies the vendor of the device. The device ID identifies a specific device from that manufacturer/vendor.

A PCI device has often an ID pair for the main chip of the device, and also a subsystem ID pair which identifies the vendor, which may be different from the chip manufacturer.

See also

  • Class driver
    Class driver
    In computing, a class driver is a type of hardware device driver that can operate a large number of different devices of a broadly similar type....

  • Device driver synthesis and verification
    Device driver synthesis and verification
    The device driver is a program which allows the software or higher-level computer programs to interact with a hardware device. These software components act as a link between the devices and the operating systems, communicating with each of these systems and executing commands...

  • Firmware
    Firmware
    In electronic systems and computing, firmware is a term often used to denote the fixed, usually rather small, programs and/or data structures that internally control various electronic devices...

  • Interrupt
    Interrupt
    In computing, an interrupt is an asynchronous signal indicating the need for attention or a synchronous event in software indicating the need for a change in execution....

  • Loadable kernel module
    Loadable Kernel Module
    In computing, a loadable kernel module is an object file that contains code to extend the running kernel, or so-called base kernel, of an operating system...

  • Makedev
  • Open-source hardware
  • Printer driver
    Printer driver
    In computers, a printer driver or a print processor is a piece of software that converts the data to be printed to the form specific to a printer...

  • udev
    Udev
    udev is the device manager for the Linux kernel. Primarily, it manages device nodes in /dev. It is the successor of devfs and hotplug, which means that it handles the /dev directory and all user space actions when adding/removing devices, including firmware load.-History:udev was new in Linux...


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK