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

📄 drivertut7.html

📁 What is this ``device driver stuff anyway? Here s a very short introduction to the concept.
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<html><head><title>Porting Digital UNIX Device Drivers</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="PortUNIXDrvs"></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="drivertut7_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="drivertut7_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut6.html"><img src="drivertut7_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<img src="drivertut7_files/BLANK.GIF" border="0">
<a href="#PortingDevDrvs"><img src="drivertut7_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/drivertut8.html"><img src="drivertut7_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="drivertut7_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="drivertut7_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h1>4&nbsp;&nbsp;&nbsp;&nbsp;Porting Digital UNIX Device Drivers</h1>
<p>
This chapter discusses how you port device drivers from the ULTRIX
operating system to the Digital UNIX operating system.
The chapter also summarizes the issues you need to consider before you
decide to update existing Digital UNIX device
drivers to the current version of Digital UNIX.
<a name="PortingDevDrvs"></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="drivertut7_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="drivertut7_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#PortUNIXDrvs"><img src="drivertut7_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<img src="drivertut7_files/BLANK.GIF" border="0">
<a href="#WritingTestSuites"><img src="drivertut7_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/drivertut8.html"><img src="drivertut7_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="drivertut7_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="drivertut7_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h2>
4.1&nbsp;&nbsp;&nbsp;&nbsp;Porting ULTRIX Device Drivers to the Digital UNIX Operating System
</h2>
<p>
This section discusses the tasks you need to perform when porting device
drivers from the ULTRIX operating system (running on Digital hardware)
to the Digital UNIX operating system (also running on Digital hardware).
The section does not discuss how to port drivers running on other UNIX
operating systems, such as System V, or running on other hardware
platforms, such as Sun Microsystems.
Specifically, you need to:
</p><ul>
<p></p><li>
Write test suites
<p></p></li><li>
Check header files
<p></p></li><li>
Review device driver builds
<p></p></li><li>
Check driver interfaces
<p></p></li><li>
Check kernel interfaces
<p></p></li><li>
Check data structures
</li></ul><p>
These tasks are discussed in the following sections.
<a name="WritingTestSuites"></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="drivertut7_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="drivertut7_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#PortUNIXDrvs"><img src="drivertut7_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#PortingDevDrvs"><img src="drivertut7_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#CheckHeaderFiles"><img src="drivertut7_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/drivertut8.html"><img src="drivertut7_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="drivertut7_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="drivertut7_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
4.1.1&nbsp;&nbsp;&nbsp;&nbsp;Writing Test Suites
</h3>
<p>
<a name="nx_id_153"></a>
Porting a device driver
requires that you
understand the hardware device and the associated driver you want to
port.
One way to learn about the hardware device and its associated driver is
to run a test suite, if it exists, on the machine and the operating
system you are porting from (the source machine and the source
operating system).
If the test suite does not exist, you need to
write a full test suite for that device on the source machine and the
source operating system.
For example, if you port a device driver written for a Digital
CPU running the ULTRIX operating system, write the full test suite on
that Digital CPU. 
</p><p>
Write the test suite so that only minimal changes are necessary when
you move it to the Digital CPU running the Digital UNIX operating system
you are porting to (the target machine and the target operating system).
The test
suite represents a cross section of your users, and they should not have
to modify their applications to work with the ported driver.
You need
to have both the source machine and source operating system
and the target machine and target operating system
on a network or make them accessible through a common interface,
such as the Small Computer System Interface (SCSI).
</p><p>
After writing the test suite on the source machine,
move the driver and the test suite to the target machine.
Move only the
<tt>.c</tt>
and the
<tt>.h</tt>
files that were created for the driver.
Do not copy any header or binary executable files because these files on
the source machine will probably not be compatible on the target machine.
<a name="CheckHeaderFiles"></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="drivertut7_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="drivertut7_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#PortUNIXDrvs"><img src="drivertut7_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#WritingTestSuites"><img src="drivertut7_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#ReviewDrvConfiger"><img src="drivertut7_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/drivertut8.html"><img src="drivertut7_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="drivertut7_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="drivertut7_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
4.1.2&nbsp;&nbsp;&nbsp;&nbsp;Checking Header Files
</h3>
<p>
<a name="nx_id_154"></a>
Check the header files in the driver you want to port with
those in the Digital UNIX device drivers.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut8.html#inclfile_sect">Section 5.1</a>
provides information on the header files that Digital UNIX uses.
<cite>Writing Device Drivers: Reference</cite>
provides
reference page descriptions of the header files that
Digital UNIX device drivers use most frequently.
</p><p>
The following example summarizes the differences in the way header files
are included in device drivers on Digital UNIX and ULTRIX systems:
</p><p>
</p><p>
</p><pre><p>
</p></pre>
<p>
</p><p>
</p><p>
</p><pre>/* Header Files Included in Digital UNIX */ <a name="co_id_22_rtn_1"></a><a href="#co_id_22_1"><strong>[1]</strong></a>
#include &lt;sys/types.h&gt;
<p>
/* Header Files Included in ULTRIX */ <a href="#co_id_22_1"><strong>[1]</strong></a>
#include "../h/types.h"
</p></pre>
<p>
</p><p>
</p><ol>
<p></p><li>
<a name="co_id_22_1"></a>
Shows that drivers written for Digital UNIX use left (&lt;) and right
(&gt;) angle brackets, instead of the begin (") and end (") quotes used in
ULTRIX pathnames.
Note also that the location of the file has changed for Digital UNIX.
<a href="#co_id_22_rtn_1">[Return to example]</a>
</li></ol><p>
<a name="ReviewDrvConfiger"></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="drivertut7_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="drivertut7_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#PortUNIXDrvs"><img src="drivertut7_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#CheckHeaderFiles"><img src="drivertut7_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#CheckDriverInter"><img src="drivertut7_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/drivertut8.html"><img src="drivertut7_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="drivertut7_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="drivertut7_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
4.1.3&nbsp;&nbsp;&nbsp;&nbsp;Reviewing Device Driver Configuration
</h3>
<p>
<a name="nx_id_155"></a>
Digital UNIX supports static and dynamic
configuration of device drivers into the kernel.
The steps and tools that driver writers use to configure drivers into
the kernel are different than those used on ULTRIX systems.
The chapters in
Part 4
of this book describe device driver configuration on Digital UNIX.
<a name="CheckDriverInter"></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="drivertut7_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="drivertut7_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#PortUNIXDrvs"><img src="drivertut7_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#ReviewDrvConfiger"><img src="drivertut7_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#CheckKernelInter"><img src="drivertut7_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/drivertut8.html"><img src="drivertut7_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="drivertut7_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="drivertut7_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
4.1.4&nbsp;&nbsp;&nbsp;&nbsp;Checking Driver Interfaces
</h3>
<p>
<a name="nx_id_156"></a>
You need to compare the driver interfaces that ULTRIX device drivers
use with those that Digital UNIX device drivers use.
<cite>Writing Device Drivers: Reference</cite>
provides reference page descriptions of the driver
interfaces that Digital UNIX device drivers use.
Use this information to compare the interface's behavior, number and type of
arguments, return values, and so forth with its associated ULTRIX driver
interface. 
<a name="CheckKernelInter"></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="drivertut7_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="drivertut7_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#PortUNIXDrvs"><img src="drivertut7_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#CheckDriverInter"><img src="drivertut7_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#CheckDataStructs"><img src="drivertut7_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/drivertut8.html"><img src="drivertut7_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="drivertut7_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="drivertut7_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
4.1.5&nbsp;&nbsp;&nbsp;&nbsp;Checking Kernel Interfaces
</h3>
<p>
<a name="nx_id_157"></a>
You need to compare the kernel interfaces that ULTRIX device drivers
use with those that Digital UNIX device drivers use.
<cite>Writing Device Drivers: Reference</cite>
provides
reference page descriptions of the kernel interfaces that
Digital UNIX device drivers use.
Use this information to compare the interface's behavior, number and type of
arguments, return values, and so forth with its associated ULTRIX kernel
interface. 
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut7.html#tblDifferKernInter">Table 4-1</a>
lists some of these differences.
</p><p>
<br>
<a name="tblDifferKernInter"></a>
</p><h3>
Table 4-1: Highlights of Differences Between Digital UNIX and ULTRIX Kernel Interfaces
</h3>
<a name="nx_id_158"></a>
<table border="4" cellpadding="4">
<tbody><tr>
<td align="left" valign="top">
<strong>
Kernel Interface
</strong>
</td>
<td align="left" valign="top">
<strong>
Remarks
</strong>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>BADADDR</tt>
</td>
<td align="left" valign="top">
You can use
<tt>BADADDR</tt>
in device drivers that are statically configured into the kernel
on Digital UNIX.
However, you cannot use
<tt>BADADDR</tt>
if the driver is dynamically configured into the kernel.
If you implement the driver to be both statically and dynamically
configured, you can declare a variable
and use it to control the call to
<tt>BADADDR</tt>.
For an example of how
<tt>noneprobe</tt>
uses such a variable
(called
<tt><var>none_is_dynamic</var></tt>),
see
Section 7.1.8.
</td>
</tr>

⌨️ 快捷键说明

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