📄 developing a device driver.htm
字号:
alt="[Previous Chapter]" src="Developing a Device Driver_files/REW.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#SpecHostCPU"><IMG
alt="[Previous Section]" src="Developing a Device Driver_files/PREV.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#SpecBus"><IMG
alt="[Next Section]" src="Developing a Device Driver_files/NEXT.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut6.html"><IMG
alt="[Next Chapter]" src="Developing a Device Driver_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="Developing a Device Driver_files/INDEX.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Developing a Device Driver_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H3>2.1.1.2 Specifying the Operating System or Systems on
Which Your Driver Operates </H3>
<P><A name=nx_id_36></A>The <TT>/dev/none</TT> driver will be developed for use
on the Digital UNIX operating system. This is an important consideration because
data structures and kernel interfaces differ among operating systems. For
example, device drivers developed for Digital UNIX systems initialize a
<TT>driver</TT> structure, while drivers developed for other versions of UNIX
systems would initialize a different structure. This identification can help you
determine the amount of work that is involved in porting an existing device
driver from some other UNIX operating system to the Digital UNIX operating
system.
<P><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut7.html#PortingDevDrvs">Section
4.1</A> provides information to help you understand the tasks involved in
porting from ULTRIX to Digital UNIX systems. <A name=SpecBus></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="Developing a Device Driver_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="Developing a Device Driver_files/TOC.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#DesSimple"><IMG
alt="[Previous Chapter]" src="Developing a Device Driver_files/REW.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#SpecOperateSys"><IMG
alt="[Previous Section]" src="Developing a Device Driver_files/PREV.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#identstand_devdrv"><IMG
alt="[Next Section]" src="Developing a Device Driver_files/NEXT.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut6.html"><IMG
alt="[Next Chapter]" src="Developing a Device Driver_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="Developing a Device Driver_files/INDEX.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Developing a Device Driver_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H3>2.1.1.3 Specifying the Bus or Buses to Which Your
Driver Connects </H3>
<P><A name=nx_id_37></A>You must identify the bus to which the device controller
is connected. Different buses require different approaches to writing the
driver. For example, a VMEbus device driver writer must know how to allocate the
VMEbus address space. This task is not applicable for drivers that operate on
other buses. On the other hand, you may want to write one device driver that
operates on several different bus architectures if these bus architectures
exhibit enough common features. For Digital-implemented buses (specifically, the
EISA, ISA, PCI, and TURBOchannel), you should be able to write one device driver
that operates on all of these buses by observing the design issues summarized in
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut6.html#BusIssues">Section
3.2</A>.
<P><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut29.html#hostsys2_wkshtfordevnone">Figure
C-2</A> shows that for example purposes the <TT>/dev/none</TT> driver operates
on the TURBOchannel bus. <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut11.html#MultipleBusIssues">Section
7.1.1</A> discusses multiple bus issues related to implementing a <TT>probe</TT>
interface. <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut11.html#SetUpProbeRtnHandleMultBuses">Section
7.1.4</A> discusses how to set up a <TT>probe</TT> interface to handle multiple
buses. <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut11.html#MultipleBusIssuesSlave">Section
7.4.1</A> discusses multiple bus issues related to implementing a <TT>slave</TT>
interface.
<P>Note that the worksheet shown in <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut29.html#hostsys2_wkshtfordevnone">Figure
C-2</A> provides a space for pseudodevice drivers. A pseudodevice driver, such
as the <TT>pty</TT> terminal driver, is structured like any other driver. The
difference is that a pseudodevice driver does not operate on a bus and does not
control a hardware device. <A name=nx_id_38></A>This book does not specifically
address pseudodevice drivers; however, <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut28.html#SrcListfordevexpseudo">Section
B.2</A> provides a source listing for an example pseudodevice driver called
<TT>/dev/edpseudo</TT>. <A name=nx_id_39></A><A name=identstand_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="Developing a Device Driver_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="Developing a Device Driver_files/TOC.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#DesSimple"><IMG
alt="[Previous Chapter]" src="Developing a Device Driver_files/REW.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#SpecBus"><IMG
alt="[Previous Section]" src="Developing a Device Driver_files/PREV.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#SpecNamingScheme"><IMG
alt="[Next Section]" src="Developing a Device Driver_files/NEXT.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut6.html"><IMG
alt="[Next Chapter]" src="Developing a Device Driver_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="Developing a Device Driver_files/INDEX.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Developing a Device Driver_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H3>2.1.2 Identifying the Standards Used in Writing the
Driver </H3>
<P><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut29.html#devdrvstand_wkshtfordevnone">Figure
C-3</A> and <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut29.html#devdrvstand2_wkshtfordevnone">Figure
C-4</A> show the device driver conventions worksheet for the <TT>/dev/none</TT>
driver. <A name=nx_id_40></A>As the worksheets show:
<UL>
<P>
<LI>You specify a naming scheme.
<P></P>
<LI>You choose an approach for writing comments and documentation. </LI></UL>
<P><A name=SpecNamingScheme></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="Developing a Device Driver_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="Developing a Device Driver_files/TOC.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#DesSimple"><IMG
alt="[Previous Chapter]" src="Developing a Device Driver_files/REW.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#identstand_devdrv"><IMG
alt="[Previous Section]" src="Developing a Device Driver_files/PREV.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#ChooseWrtngComments"><IMG
alt="[Next Section]" src="Developing a Device Driver_files/NEXT.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut6.html"><IMG
alt="[Next Chapter]" src="Developing a Device Driver_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="Developing a Device Driver_files/INDEX.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Developing a Device Driver_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H3>2.1.2.1 Specifying a Naming Scheme </H3>
<P><A name=nx_id_41></A>The <TT>/dev/none</TT> driver uses the name
<TT>none</TT> as the prefix for device driver interface names. Device driver
interfaces written for Digital UNIX can use the following naming conventions:
<UL>
<P>
<LI>A prefix that represents the name of some device. In this example, the
device is called <TT>none</TT>; therefore, each driver interface begins with
that prefix.
<P></P>
<LI>The name of the interface, for example, <TT>open</TT> and <TT>close</TT>.
Thus, the example driver has interface names such as <TT>noneopen</TT> and
<TT>noneclose</TT>. </LI></UL>
<P>
<P>The <TT>/dev/none</TT> driver uses the name <TT>none</TT> as the prefix for
data structures internal to the device driver. These structures include a data
structure (often referred to as a <TT>softc</TT> structure) to store
driver-specific information. <A name=nx_id_42></A>
<P>When using the CSR I/O access interfaces to read from and write to a device's
CSR addresses, you create device register offset names. You can also use the
prefix to create names for each of the device register offsets. Because the
<TT>/dev/none</TT> driver uses the CSR I/O access interfaces, it uses the name
<TT>none</TT> as the prefix to the device register offset name.
<P>The <TT>/dev/none</TT> driver uses the prefix <TT>DN</TT> for device driver
constant names. The prefix matches the first two characters in the driver name,
<TT>/dev/none</TT> (the letters D and N). These constants can represent values
or macros. For example, the constant <TT>DN_SIZE</TT> might represent the size
of the device register area.
<P>The previously described naming schemes are recommendations, not
requirements. The one naming requirement you must follow concerns the name of
the <TT>configure</TT> interface, which for the <TT>/dev/none</TT> driver is
<TT>none_configure</TT>. <A name=nx_id_43></A><A name=nx_id_44></A>This
interface is the configuration entry point called as a result of configuration
(both static and dynamic) requests. For the <TT>configure</TT> interface, the
underscore character (_) must follow the driver's name. This underscore
character in the name is a requirement of the configuration process for drivers
and is the Digital UNIX convention.
<P>Before choosing a naming scheme, you have to make sure that these names do
not conflict with other driver interface and structure names. To help you
determine what names are currently used by the system, run the <TT>nm</TT>
command on the kernel image file. This image file is usually called
<TT>/vmunix</TT>. (Note that you should not run the <TT>nm</TT> command on the
boot-link <TT>/sysconfigtab</TT> kernel image file.) If you follow the device
driver (kernel) kits delivery process described in <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut17.html#DevDriverKitDelivery">Chapter
12</A>, you should be particularly careful about choosing a naming scheme,
ensuring that it does not conflict with that of other third-party driver
vendors. <A name=nx_id_45></A><A name=nx_id_46></A>
<P>Third-party driver writers may need to specify controller and device
information in calls to the <TT>create_controller_struct</TT> and
<TT>create_device_struct</TT> interfaces. <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut10.html#UsingCreRtnstoRegContrlDevInfo">Section
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -