📄 introduction to device drivers.htm
字号:
there are physical devices in the hardware system. At boot time, the
autoconfiguration software determines which of the physical devices are
accessible and functional and can produce a correct run-time configuration for
that instance of the running kernel. Similarly, when a driver is dynamically
configured, the kernel performs the configuration sequence for each instance of
the physical device.
<P>As stated previously, the kernel makes requests of a driver by calling the
driver's standard entry points (such as the <TT>probe</TT>, <TT>attach</TT>,
<TT>open</TT>, <TT>read</TT>, <TT>write</TT>, <TT>close</TT> entry points). In
the case of I/O requests such as <TT>read</TT> and <TT>write</TT>, it is typical
that the device causes an interrupt upon completion of each I/O operation. Thus,
a <TT>write</TT> system call from a user program may result in several calls on
the <TT>interrupt</TT> entry point in addition to the original call on the
<TT>write</TT> entry point. This is the case when the write request is segmented
into several partial transfers at the driver level.
<P>Device drivers, in turn, make calls upon kernel support interfaces to perform
the tasks mentioned earlier.
<P>The device register offset definitions giving the layout of the control
registers for a device are part of the source for a device driver. Device
drivers, unlike the rest of the kernel, can access and modify these registers.
Digital UNIX provides generic CSR I/O access kernel interfaces that allow device
drivers to read from and write to these registers. <A name=buses></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#dev_drvs"><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#dev_contrler"><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.6.4 Bus </H3>
<P><A name=nx_id_20></A>When a device driver reads or writes to the hardware
registers of a controller, the data travels across a bus.
<P>A bus is a physical communication path and an access protocol between a
processor and its peripherals. A bus standard, with a predefined set of logic
signals, timings, and connectors, provides a means by which many types of device
interfaces (controllers) can be built and easily combined within a computer
system. <A name=nx_id_21></A>The term <EM>OPENbus</EM> refers to those buses
whose architectures and interfaces are publicly documented, allowing a vendor to
easily plug in hardware and software components. The TURBOchannel bus, the EISA
bus, the PCI bus, and the VMEbus, for example, can be classified as having
OPENbus architectures. <A name=nx_id_22></A><A name=nx_id_23></A><A
name=nx_id_24></A>
<P>Device driver writers must understand the bus that the device is connected
to. This book covers topics that all driver writers need to know regardless of
the bus. <A name=dev_contrler></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#buses"><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#periph_devs"><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.6.5 Device Controller </H3>
<P><A name=nx_id_25></A>A device controller is the hardware interface between
the computer and a peripheral device. Sometimes a controller handles several
devices. In other cases, a controller is integral to the device. <A
name=nx_id_26></A><A name=periph_devs></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#dev_contrler"><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#exofread_char"><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.6.6 Peripheral Device </H3>
<P><A name=nx_id_27></A>A peripheral device is hardware, such as a disk
controller, that connects to a computer system. It can be controlled by commands
from the computer and can send data to the computer and receive data from it. <A
name=nx_id_28></A>Examples of peripheral devices include:
<UL>
<P>
<LI>A data acquisition device, like a digitizer
<P></P>
<LI>A line printer
<P></P>
<LI>A disk or tape drive </LI></UL>
<P><A name=exofread_char></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#periph_devs"><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#areadreq_ismade"><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.7 Example of Reading a Character </H2>
<P><A name=nx_id_29></A>This section provides an example of how Digital UNIX
processes a read request of a single character in raw mode from a terminal. (Raw
mode returns single characters.) Although the example takes a simplified view of
character processing, it does show how control can pass from a user program to
the kernel to the device driver. It also shows that interrupt processing occurs
asynchronously from other device driver activity. <A name=nx_id_30></A>
<P><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#chardrv_interex">Figure
1-3</A> summarizes the flow of control between a user program, the kernel, the
device driver, and the hardware. The figure shows the following sequence of
events:
<UL>
<P>
<LI>A read request is made to the device driver (C-1 to C-3).
<P></P>
<LI>The character is captured by the hardware (I-4 and I-5).
<P></P>
<LI>The interrupt is generated (I-6).
<P></P>
<LI>The interrupt handler services the interrupt (I-7 to I-9).
<P></P>
<LI>The character is returned (C-10 to C-13). </LI></UL>
<P><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#chardrv_interex">Figure
1-3</A> provides a snapshot of the processing that occurs in the reading of a
single character. The following sections elaborate on this sequence. <A
name=chardrv_interex></A>
<H3>Figure 1-3: Simple Character Driver Interrupt Example</H3>
<P><IMG src="Introduction to Device Drivers_files/zk-0479U.gif">
<P><A name=nx_id_31></A><A name=areadreq_ismade></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#exofread_char"><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#acharcap_byhard"><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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -