⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 building dd.htm

📁 What is this ``device driver stuff anyway? Here s a very short introduction to the concept.
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<html><head><title>Building a Device Driver</title>

<meta name="ROBOTS" content="NOFOLLOW">
<meta name="DESCRIPTION" content="Writing Device Drivers Tutorial: DIGITAL UNIX Version 4.0B documentation set">
<meta name="AUTHOR" content="Copyright (c) Digital Equipment Corporation 1996. All Rights Reserved."></head>
<body>
<a name="ConfigModuleDynamicDrv"></a>
<p></p><hr><p align="center">
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><img src="building%20DD_files/BOOKSHELF.GIF" alt="[Return to Library]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><img src="building%20DD_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut18.html"><img src="building%20DD_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<img src="building%20DD_files/BLANK.GIF" border="0">
<a href="#ProduceSingleBinaryModule"><img src="building%20DD_files/NEXT.GIF" alt="[Next Section]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut20.html"><img src="building%20DD_files/FF.GIF" alt="[Next Chapter]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><img src="building%20DD_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="building%20DD_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h1>14&nbsp;&nbsp;&nbsp;&nbsp;Building a Device Driver</h1>
<p>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut17.html#DevDriverKitDelivery">Chapter 12</a>
presents an overview of the device driver kits delivery process.
The overview includes summary descriptions of the tasks performed during the
device driver development phase, the device driver kit development
phase, and the device driver installation phase.
This chapter discusses in more detail how to build a device driver so
that you can test it with the appropriate utilities prior to creating
the device driver kit.
Building a device driver involves the following tasks that driver writers
perform during the device driver development phase:
</p><ul>
<p></p><li>
Produce the single binary module
<p></p></li><li>
Statically configure a single binary module (the driver product)
<p></p></li><li>
Dynamically configure a single binary module (the driver product)
</li></ul><p>
</p><p>
The device driver writers at EasyDriver Incorporated need to statically and
dynamically configure their driver products (single binary modules) into
the kernel in order to
test them with the appropriate Digital UNIX utilities. 
</p><p>
The following sections describe the steps associated with each of these
tasks.
</p><blockquote><p align="center"><font size="+1"><strong>Note</strong></font></p><p>
The steps described in the following sections assume that you are
superuser and that you are running the
<tt>/genvmunix</tt>
kernel.
</p></blockquote><p>
<a name="ProduceSingleBinaryModule"></a>
</p><p></p><hr><p align="center">
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><img src="building%20DD_files/BOOKSHELF.GIF" alt="[Return to Library]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><img src="building%20DD_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ConfigModuleDynamicDrv"><img src="building%20DD_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<img src="building%20DD_files/BLANK.GIF" border="0">
<a href="#CreDirContainDrvProdFiles"><img src="building%20DD_files/NEXT.GIF" alt="[Next Section]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut20.html"><img src="building%20DD_files/FF.GIF" alt="[Next Chapter]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><img src="building%20DD_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="building%20DD_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h2>
14.1&nbsp;&nbsp;&nbsp;&nbsp;Producing the Single Binary Module
</h2>
<p>
<a name="nx_id_593"></a>
Before you can statically or dynamically configure a device driver into
the kernel, you must produce the single binary module.
A single binary module is the executable image of a device driver that
can be statically or dynamically configured into the kernel.
A single binary module has a file extension of
<tt>.mod</tt>.
To produce the single binary module associated with a device driver
product, you perform the following steps:
</p><ul>
<p></p><li>
Step 1: Create a directory to contain driver product files
<p></p></li><li>
Step 2: Copy driver product files 
<p></p></li><li>
Step 3: Create a
<tt>files</tt>
file fragment
<p></p></li><li>
Step 4: Create a
<tt>BINARY.list</tt>
file
<p></p></li><li>
Step 5: Create a
<tt>sysconfigtab</tt>
file fragment
<p></p></li><li>
Step 6: Run the
<tt>sourceconfig</tt>
program
<p></p></li><li>
Step 7: Run the
<tt>make</tt>
program
<p></p></li><li>
Step 8: Create a kernel configuration development area
<p></p></li><li>
Step 9: Run the
<tt>sysconfigdb</tt>
utility
</li></ul><p>
</p><p>
The following sections discuss each of these steps, using as an example
the driver build environment practiced at EasyDriver Incorporated.
<a name="CreDirContainDrvProdFiles"></a>
</p><p></p><hr><p align="center">
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><img src="building%20DD_files/BOOKSHELF.GIF" alt="[Return to Library]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><img src="building%20DD_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ConfigModuleDynamicDrv"><img src="building%20DD_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#ProduceSingleBinaryModule"><img src="building%20DD_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#CopyDrvProdFiles"><img src="building%20DD_files/NEXT.GIF" alt="[Next Section]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut20.html"><img src="building%20DD_files/FF.GIF" alt="[Next Chapter]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><img src="building%20DD_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="building%20DD_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
14.1.1&nbsp;&nbsp;&nbsp;&nbsp;Step 1: Create a Directory to Contain Driver Product Files
</h3>
<p>
<a name="nx_id_594"></a>
Use the
<tt>mkdir</tt>
command to create a directory to contain the driver product files: 
</p><p>
</p><pre># mkdir /usr/sys/io/ESA100 <a name="co_id_89_rtn_1"></a><a href="#co_id_89_1"><strong>[1]</strong></a>
</pre>
<p>
</p><ol>
<p></p><li>
<a name="co_id_89_1"></a>
Shows that the driver writer at EasyDriver Incorporated creates the directory
called
<tt>/usr/sys/io/ESA100</tt>
to contain the files related to the
<tt>/dev/none</tt>
driver product.
Note that the driver writer at EasyDriver Incorporated performs the work at the
superuser prompt.
<p>
When you create your directory, replace
<tt>ESA100</tt>
with a product directory that reflects a name specific to your company.
<a href="#co_id_89_rtn_1">[Return to example]</a>
</p></li></ol><p>
<a name="CopyDrvProdFiles"></a>
</p><p></p><hr><p align="center">
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><img src="building%20DD_files/BOOKSHELF.GIF" alt="[Return to Library]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><img src="building%20DD_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ConfigModuleDynamicDrv"><img src="building%20DD_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#CreDirContainDrvProdFiles"><img src="building%20DD_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#CrefilesFileFragforSingBinMod"><img src="building%20DD_files/NEXT.GIF" alt="[Next Section]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut20.html"><img src="building%20DD_files/FF.GIF" alt="[Next Chapter]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><img src="building%20DD_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="building%20DD_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
14.1.2&nbsp;&nbsp;&nbsp;&nbsp;Step 2: Copy Driver Product Files
</h3>
<p>
<a name="nx_id_595"></a>
Use the
<tt>cp</tt>
command to copy the driver product files to the directory you created in
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut19.html#CreDirContainDrvProdFiles">Section 14.1.1</a>
(Step 1): 
</p><p>
</p><pre># cd /usr/sys/io/ESA100 <a name="co_id_90_rtn_1"></a><a href="#co_id_90_1"><strong>[1]</strong></a>

# cp /usr/sys/mydevelopment/none.c . <a name="co_id_90_rtn_2"></a><a href="#co_id_90_2"><strong>[2]</strong></a>

# cp /usr/sys/mydevelopment/nonereg.h . <a name="co_id_90_rtn_3"></a><a href="#co_id_90_3"><strong>[3]</strong></a>
</pre>
<p>
</p><ol>
<p></p><li>
<a name="co_id_90_1"></a>
Shows that the driver writer at EasyDriver Incorporated changes to the
<tt>/usr/sys/io/ESA100</tt>
directory. 
<p>
You should change to the directory where you will copy the files for
your driver product.
<a href="#co_id_90_rtn_1">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_90_2"></a>
Shows that the driver writer at EasyDriver Incorporated copies the
<tt>none.c</tt>
file (the source file for the
<tt>/dev/none</tt>
driver product) to the
<tt>/usr/sys/io/ESA100</tt>
directory.
The
<tt>/usr/sys/mydevelopment</tt>
directory is where the driver writer initially created the
<tt>none.c</tt>
file.
<p>
You should copy the source file associated with your driver product to the
directory you specified in
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut19.html#CreDirContainDrvProdFiles">Section 14.1.1</a>
(Step 1). 
</p><p>
You should have implemented the device driver's
<tt>configure</tt>
interface to follow the single binary module model (that is, your driver
handles static and dynamic configuration).
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut10.html#ImplConfigureRtn">Chapter 6</a>
describes how to implement a
<tt>configure</tt>
interface that follows the single binary module model.
<a href="#co_id_90_rtn_2">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_90_3"></a>
Shows that the driver writer at EasyDriver Incorporated copies the
<tt>nonereg.h</tt>
file
(the device register header file for the
<tt>/dev/none</tt>
driver product) to the
<tt>/usr/sys/io/ESA100</tt>
directory.
The
<tt>/usr/sys/mydevelopment</tt>
directory is where the driver writer initially created
the
<tt>nonereg.h</tt>
file.
<p>
You should copy the device register header file (and any other header or
source files) associated with your driver product to the
directory you specified in
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut19.html#CreDirContainDrvProdFiles">Section 14.1.1</a>
(Step 1). 
<a href="#co_id_90_rtn_3">[Return to example]</a>
</p></li></ol><p>
<a name="CrefilesFileFragforSingBinMod"></a>
</p><p></p><hr><p align="center">
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><img src="building%20DD_files/BOOKSHELF.GIF" alt="[Return to Library]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><img src="building%20DD_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ConfigModuleDynamicDrv"><img src="building%20DD_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#CopyDrvProdFiles"><img src="building%20DD_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#CreBINARYdotlistFileSingBinMod"><img src="building%20DD_files/NEXT.GIF" alt="[Next Section]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut20.html"><img src="building%20DD_files/FF.GIF" alt="[Next Chapter]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><img src="building%20DD_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="building%20DD_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
14.1.3&nbsp;&nbsp;&nbsp;&nbsp;Step 3: Create a files File Fragment
</h3>
<p>
<a name="nx_id_596"></a>
<a name="nx_id_597"></a>
Use an editor such as
<tt>vi</tt>
to create a
<tt>files</tt>
file fragment: 
</p><p>
</p><pre># pwd <a name="co_id_91_rtn_1"></a><a href="#co_id_91_1"><strong>[1]</strong></a>
/usr/sys/io/ESA100

# vi files <a name="co_id_91_rtn_2"></a><a href="#co_id_91_2"><strong>[2]</strong></a>
</pre>
<p>
</p><ol>
<p></p><li>
<a name="co_id_91_1"></a>
Shows that the driver writer at EasyDriver Incorporated uses the
<tt>pwd</tt>
command to make sure the working directory is the one created in
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut19.html#CreDirContainDrvProdFiles">Section 14.1.1</a>
(Step 1). 
The
<tt>pwd</tt>
command displays
<tt>/usr/sys/io/ESA100</tt>,
the directory created in Step 1.
<p>
You should also check that you are in the directory that you created in
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut19.html#CreDirContainDrvProdFiles">Section 14.1.1</a>
(Step 1).
<a href="#co_id_91_rtn_1">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_91_2"></a>
Shows that the driver writer at EasyDriver Incorporated uses the
<tt>vi</tt>
editor to create the
<tt>files</tt>
file fragment.
<p>
You can use
<tt>vi</tt>
or another editor to create your
<tt>files</tt>
file fragment.
<a href="#co_id_91_rtn_2">[Return to example]</a>
</p></li></ol><p>
</p><p>
The following example shows the contents of the
<tt>files</tt>
file fragment that the driver writer at EasyDriver Incorporated creates:
</p><p>
</p><pre># This is the files file fragment for the /dev/none driver
# used to produce the single binary module.
#
MODULE/STATIC/none       standard Binary <a name="co_id_92_rtn_1"></a><a href="#co_id_92_1"><strong>[1]</strong></a>

io/ESA100/none.c         module   none <a name="co_id_92_rtn_2"></a><a href="#co_id_92_2"><strong>[2]</strong></a>
</pre>
<p>
</p><ol>
<p></p><li>
<a name="co_id_92_1"></a>
Shows the
<tt>files</tt>
file fragment syntax typically specified to produce a single binary
module.
<ul>
<p></p><li>
<tt>MODULE</tt>
<p>
The keyword that identifies a module.
A module is a collection of one or more objects.
In the case of device drivers, these objects are the source files
(with
<tt>.c</tt>
extensions) that make up the driver.
</p><p>
These objects are linked together to produce a single binary module.
The module mechanism achieves the goal of producing a single binary
module that represents the executable for device drivers that can be statically
or dynamically configured into the kernel.
</p><p></p></li><li>
<tt>STATIC</tt>
<p>
The keyword that indicates this module is to be statically
configured into the kernel.
A module with this keyword is a group-linked object.
A group-linked object has a
<tt>configure</tt>
interface and a filled-in
<tt>cfg_subsys_attr_t</tt>
structure.
</p><p>
For example, the
<tt>/dev/none</tt>
driver product's
<tt>configure</tt>
interface is called
<tt>none_configure</tt>
and its filled-in
<tt>cfg_subsys_attr_t</tt>
structure is called
<tt>none_attributes</tt>.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut10.html#SetUpConfigureRelDecl">Section 6.3</a>
shows how to set up the
<tt>cfg_subsys_attr_t</tt>
structure for the
<tt>/dev/none</tt>
driver.
</p><p></p></li><li>
<tt>none</tt>
<p>
The name of the module, which in this case is the driver name.
The driver writer at EasyDriver Incorporated specifies the name
<tt>none</tt>
for the
<tt>/dev/none</tt>
driver product.
Replace the name
<tt>none</tt>
with the name of your device driver product.
</p><p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -