📄 introduction to device drivers.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0091)http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html -->
<HTML><HEAD><TITLE>Introduction to Device Drivers</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content=NOFOLLOW name=ROBOTS>
<META
content="Writing Device Drivers Tutorial: DIGITAL UNIX Version 4.0B documentation set"
name=DESCRIPTION>
<META
content="Copyright (c) Digital Equipment Corporation 1996. All Rights Reserved."
name=AUTHOR>
<META content="MSHTML 6.00.2900.3059" name=GENERATOR></HEAD>
<BODY><A name=IntrotoDevDrv></A>
<P>
<HR>
<P align=center><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><IMG
alt="[Return to Library]"
src="Introduction to Device Drivers_files/BOOKSHELF.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><IMG
alt=[Contents] src="Introduction to Device Drivers_files/TOC.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut2.html"><IMG
alt="[Previous Chapter]" src="Introduction to Device Drivers_files/REW.gif"
border=0></A> <IMG src="Introduction to Device Drivers_files/BLANK.gif"
border=0> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#purpof_devdrv"><IMG
alt="[Next Section]" src="Introduction to Device Drivers_files/NEXT.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut4.html"><IMG
alt="[Next Chapter]" src="Introduction to Device Drivers_files/FF.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><IMG
alt=[Index] src="Introduction to Device Drivers_files/INDEX.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Introduction to Device Drivers_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H1>1 Introduction to Device Drivers</H1>
<P>This chapter presents an overview of device drivers by discussing:
<UL>
<P>
<LI>The purpose of a device driver
<P></P>
<LI>The types of device drivers
<P></P>
<LI>Single binary module
<P></P>
<LI>When a device driver is called
<P></P>
<LI>Device driver configuration
<P></P>
<LI>The place of a device driver in the Digital UNIX operating system </LI></UL>
<P>The chapter concludes with an example of how a device driver in Digital UNIX
reads a single character. <A name=purpof_devdrv></A>
<P>
<HR>
<P align=center><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><IMG
alt="[Return to Library]"
src="Introduction to Device Drivers_files/BOOKSHELF.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><IMG
alt=[Contents] src="Introduction to Device Drivers_files/TOC.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#IntrotoDevDrv"><IMG
alt="[Previous Chapter]" src="Introduction to Device Drivers_files/REW.gif"
border=0></A> <IMG src="Introduction to Device Drivers_files/BLANK.gif"
border=0> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#typesof_devdrv"><IMG
alt="[Next Section]" src="Introduction to Device Drivers_files/NEXT.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut4.html"><IMG
alt="[Next Chapter]" src="Introduction to Device Drivers_files/FF.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><IMG
alt=[Index] src="Introduction to Device Drivers_files/INDEX.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Introduction to Device Drivers_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H2>1.1 Purpose of a Device Driver </H2>
<P>The purpose of a device driver is to handle requests made by the kernel with
regard to a particular type of device. <A name=nx_id_0></A>There is a
well-defined and consistent interface for the kernel to make these requests. By
isolating device-specific code in device drivers and by having a consistent
interface to the kernel, adding a new device is easier. <A
name=typesof_devdrv></A>
<P>
<HR>
<P align=center><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><IMG
alt="[Return to Library]"
src="Introduction to Device Drivers_files/BOOKSHELF.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><IMG
alt=[Contents] src="Introduction to Device Drivers_files/TOC.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#IntrotoDevDrv"><IMG
alt="[Previous Chapter]" src="Introduction to Device Drivers_files/REW.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#purpof_devdrv"><IMG
alt="[Previous Section]" src="Introduction to Device Drivers_files/PREV.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#block_devdrv"><IMG
alt="[Next Section]" src="Introduction to Device Drivers_files/NEXT.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut4.html"><IMG
alt="[Next Chapter]" src="Introduction to Device Drivers_files/FF.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><IMG
alt=[Index] src="Introduction to Device Drivers_files/INDEX.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Introduction to Device Drivers_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H2>1.2 Types of Device Drivers </H2>
<P><A name=nx_id_1></A>A device driver is a software module that resides within
the Digital UNIX kernel and is the software interface to a hardware device or
devices. <A name=nx_id_2></A>A hardware device is a peripheral, such as a disk
controller, tape controller, or network controller device. In general, there is
one device driver for each type of hardware device. Device drivers can be
classified as:
<UL>
<P>
<LI>Block device drivers
<P></P>
<LI>Character device drivers (including terminal drivers)
<P></P>
<LI>Network device drivers
<P></P>
<LI>Pseudodevice drivers </LI></UL>
<P>The following sections briefly discuss each type.
<BLOCKQUOTE>
<P align=center><FONT size=+1><STRONG>Note</STRONG></FONT>
<P>This book does not discuss how to write STREAMS device drivers. However,
<CITE>Writing Device Drivers: Reference</CITE> contains reference pages for
kernel interfaces that STREAMS device drivers use. See the <CITE>Network
Programmer's Guide</CITE> for information on STREAMS programming frameworks
and other information related to STREAMS. </P></BLOCKQUOTE>
<P><A name=block_devdrv></A>
<P>
<HR>
<P align=center><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><IMG
alt="[Return to Library]"
src="Introduction to Device Drivers_files/BOOKSHELF.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><IMG
alt=[Contents] src="Introduction to Device Drivers_files/TOC.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#IntrotoDevDrv"><IMG
alt="[Previous Chapter]" src="Introduction to Device Drivers_files/REW.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#typesof_devdrv"><IMG
alt="[Previous Section]" src="Introduction to Device Drivers_files/PREV.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#char_devdrv"><IMG
alt="[Next Section]" src="Introduction to Device Drivers_files/NEXT.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut4.html"><IMG
alt="[Next Chapter]" src="Introduction to Device Drivers_files/FF.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><IMG
alt=[Index] src="Introduction to Device Drivers_files/INDEX.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Introduction to Device Drivers_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H3>1.2.1 Block Device Driver </H3>
<P><A name=nx_id_3></A>A block device driver is a driver that performs I/O by
using file system block-sized buffers from a buffer cache supplied by the
kernel. The kernel also provides for the device driver support interfaces that
copy data between the buffer cache and the address space of a process.
<P>Block device drivers are particularly well-suited for disk drives, the most
common block devices. For block devices, all I/O occurs through the buffer
cache. <A name=nx_id_4></A><A name=char_devdrv></A>
<P>
<HR>
<P align=center><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><IMG
alt="[Return to Library]"
src="Introduction to Device Drivers_files/BOOKSHELF.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><IMG
alt=[Contents] src="Introduction to Device Drivers_files/TOC.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#IntrotoDevDrv"><IMG
alt="[Previous Chapter]" src="Introduction to Device Drivers_files/REW.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#block_devdrv"><IMG
alt="[Previous Section]" src="Introduction to Device Drivers_files/PREV.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#netwrk_devdrv"><IMG
alt="[Next Section]" src="Introduction to Device Drivers_files/NEXT.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut4.html"><IMG
alt="[Next Chapter]" src="Introduction to Device Drivers_files/FF.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><IMG
alt=[Index] src="Introduction to Device Drivers_files/INDEX.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Introduction to Device Drivers_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H3>1.2.2 Character Device Driver </H3>
<P><A name=nx_id_5></A>A character device driver does not handle I/O through the
buffer cache, so it is not tied to a single approach for handling I/O. You can
use a character device driver for a device such as a line printer that handles
one character at a time. However, character drivers are not limited to
performing I/O one character at a time (despite the name ``character'' driver).
For example, tape drivers frequently perform I/O in 10K chunks. You can also use
a character device driver when it is necessary to copy data directly to or from
a user process. <A name=nx_id_6></A>
<P>Because of their flexibility in handling I/O, many drivers are character
drivers. Line printers, interactive terminals, and graphics displays are
examples of devices that require character device drivers.
<P><A name=nx_id_7></A><A name=nx_id_8></A>A terminal device driver is actually
a character device driver that handles I/O character processing for a variety of
terminal devices. Like any character device, a terminal device can accept or
supply a stream of data based on a request from a user process. It cannot be
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -