📄 introduction to device drivers.htm
字号:
other utilities. After you write your device driver you need to create a single
binary module (a file with a <TT>.mod</TT> extension) from the driver source
file (a file with a <TT>.c</TT> extension). After you create the single binary
module, you need to configure it into the kernel so that you can test it on a
running system. There are two methods of device driver configuration: static
configuration and dynamic configuration. Static configuration consists of the
tasks and tools necessary to link a device driver (single binary module)
directly into the kernel at kernel build time. Dynamic configuration consists of
the tasks and tools necessary to link a device driver (single binary module)
directly into the kernel at any point in time. <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut19.html#ConfigModuleDynamicDrv">Chapter
14</A> describes how to create a single binary module and then how to statically
and dynamically configure the single binary module (the device driver) into the
kernel.
<P>Do not confuse device driver configuration (static configuration and dynamic
configuration), which encompasses the tools and steps for configuring the driver
into the kernel, with autoconfiguration and configuration. Autoconfiguration is
a process that determines what hardware actually exists during the current
instance of the running kernel at static configuration time. The
autoconfiguration software (specifically, the bus's <TT>confl1</TT> interface)
calls the driver's <TT>probe</TT>, <TT>attach</TT>, and <TT>slave</TT>
interfaces. Thus, the driver's <TT>probe</TT>, <TT>attach</TT>, and
<TT>slave</TT> interfaces cooperate with the bus's <TT>confl1</TT> interface to
determine if devices exist and are functional on a given system.
<P>Configuration is a process associated with handling user-level requests to
the <TT>sysconfig</TT> utility to dynamically configure, unconfigure, query, and
reconfigure devices. The <TT>cfgmgr</TT> framework calls the driver's
<TT>configure</TT> interface as a result of these <TT>sysconfig</TT> utility
requests. The <TT>cfgmgr</TT> framework also calls the driver's
<TT>configure</TT> interface as a result of static configuration requests. Thus,
the driver's <TT>configure</TT> interface cooperates with the <TT>cfgmgr</TT>
framework to statically configure and to dynamically configure, unconfigure,
query, and reconfigure devices. The driver's <TT>configure</TT> interface also
cooperates with the <TT>cfgmgr</TT> framework to perform one-time initialization
tasks such as allocating memory, initializing data structures and variables, and
adding driver entry points to the <TT>dsent</TT> table. A driver's
<TT>configure</TT> interface should be implemented to handle static and dynamic
configuration. <BR><A name=placeof_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#DevDrvIntegationOver"><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#user_prog"><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.6 Place of a Device Driver in Digital UNIX </H2>
<P><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#placeof_drvinos">Figure
1-2</A> shows the place of a device driver in Digital UNIX relative to the
device:
<UL>
<P>
<LI>User program or utility
<P>A user program, or utility, makes calls on the kernel but never directly
calls a device driver.
<P></P>
<LI>Kernel
<P>The kernel runs in supervisor mode and does not communicate with a device
except through calls to a device driver.
<P></P>
<LI>Device driver
<P>A device driver communicates with a device by reading and writing through a
bus to peripheral device registers.
<P></P>
<LI>Bus
<P>The bus is the data path between the main processor and the device
controller. <A name=placeof_drvinos></A>
<H3>Figure 1-2: Place of a Device Driver in Digital UNIX</H3>
<P><IMG src="Introduction to Device Drivers_files/zk-0201U.gif">
<P><A name=nx_id_16></A>
<P></P>
<LI>Controller
<P>A controller is a physical interface for controlling one or more devices. A
controller connects to a bus.
<P></P>
<LI>Peripheral device
<P>A peripheral device is a device that can be connected to a controller, for
example, a disk or tape drive. Other devices (for example, the network) may be
integral to the controller. </P></LI></UL>
<P>
<P>The following sections describe these parts, with an emphasis on how a device
driver relates to them. <A name=user_prog></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#placeof_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#the_kernel"><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.1 User Program or Utility </H3>
<P>User programs, or utilities, make system calls on the kernel that result in
the kernel making requests of a device driver. <A name=nx_id_17></A>For example,
a user program can make a <TT>read</TT> system call, which calls the driver's
<TT>read</TT> interface. <A name=the_kernel></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#user_prog"><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_drvs"><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.2 Kernel </H3>
<P><A name=nx_id_18></A>The kernel makes requests to a device driver to perform
operations on a particular device. Some of these requests result directly from
user program requests. For example:
<UL>
<P>
<LI>Block I/O (open, strategy, close)
<P></P>
<LI>Character I/O (open, write, close) </LI></UL>
<P>
<P>Autoconfiguration requests, such as <TT>probe</TT> and <TT>attach</TT>, do
not result directly from a user program, but result from activities performed by
the kernel. At boot time, for example, the kernel (specifically, the bus code)
calls the driver's <TT>probe</TT> interface. Configuration requests, such as
configure, unconfigure, and query, result from a system manager's use of the
<TT>sysconfig</TT> utility.
<P>A device driver may call on kernel support interfaces to support such tasks
as:
<UL>
<P>
<LI>Sleeping and waking (process rescheduling)
<P></P>
<LI>Scheduling events
<P></P>
<LI>Managing the buffer cache
<P></P>
<LI>Moving or initializing data </LI></UL>
<P><A name=dev_drvs></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#the_kernel"><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#buses"><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.3 Device Driver </H3>
<P><A name=nx_id_19></A>A device driver, run as part of the kernel software,
manages each of the device controllers on the system. Often, one device driver
manages an entire set of identical device controller interfaces. With Digital
UNIX, you can statically configure more device drivers into the kernel than
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -