?? developing a device driver.htm
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0091)http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html -->
<HTML><HEAD><TITLE>Developing a Device Driver</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content=NOFOLLOW name=ROBOTS>
<META
content="Writing Device Drivers Tutorial: DIGITAL UNIX Version 4.0B documentation set"
name=DESCRIPTION>
<META
content="Copyright (c) Digital Equipment Corporation 1996. All Rights Reserved."
name=AUTHOR>
<META content="MSHTML 6.00.2900.3059" name=GENERATOR></HEAD>
<BODY><A name=DesSimple></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/drivertut4.html"><IMG
alt="[Previous Chapter]" src="Developing a Device Driver_files/REW.gif"
border=0></A> <IMG src="Developing a Device Driver_files/BLANK.gif" border=0> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#gather_info"><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>
<H1>2 Developing a Device Driver</H1>
<P>This chapter discusses how you develop a device driver. Included is a simple
example called <TT>/dev/none</TT>, which is written by a fictitious third-party
driver company called EasyDriver Incorporated. The <TT>/dev/none</TT> device
driver is a simple device driver that implements many of the character device
driver interfaces. Note, however, that the <TT>/dev/none</TT> driver does not
control a real hardware device.
<P><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut29.html#dev_drv_wrkshts">Appendix
C</A> provides worksheets to illustrate the kinds of information you need to
gather to make developing the device driver easier. These worksheets are filled
in for the <TT>/dev/none</TT> driver. <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut29.html#dev_drv_wrkshts">Appendix
C</A> also provides these same worksheets for use in developing your own device
drivers. If you use the worksheets for your driver development, consider
organizing them in a device driver project binder. This will make them available
to systems engineers who need to maintain the driver.
<P>Specifically, the chapter describes the following tasks associated with
developing any device driver:
<UL>
<P>
<LI>Gathering information
<P></P>
<LI>Designing the device driver
<P></P>
<LI>Understanding system data and address types that device drivers use
<P></P>
<LI>Specifying the method for registering device interrupt handlers
<P></P>
<LI>Specifying the method for identifying bus, controller, and device
information
<P></P>
<LI>Determining the structure allocation technique
<P></P>
<LI>Creating a device driver development environment </LI></UL>
<P><A name=gather_info></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> <IMG src="Developing a Device Driver_files/BLANK.gif" border=0> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#specinfo_abouthostsys"><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>
<H2>2.1 Gathering Information </H2>
<P>The first task in writing a device driver is to gather pertinent information
about the host system and the device for which you are writing the driver. You
need to:
<UL>
<P>
<LI>Specify information about the host system
<P></P>
<LI>Identify the conventions used in writing the driver
<P></P>
<LI>Specify characteristics of the device
<P></P>
<LI>Describe device usage
<P></P>
<LI>Provide a description of the device registers
<P></P>
<LI>Identify support in writing the driver </LI></UL>
<P>The following sections describe how you would fill out the worksheets
provided for each of these tasks, using the <TT>/dev/none</TT> device driver as
an example. <A name=specinfo_abouthostsys></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#gather_info"><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#SpecHostCPU"><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 Specifying Information About the Host System
</H3>
<P><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut29.html#hostsys_wkshtfordevnone">Figure
C-1</A> and <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut29.html#hostsys2_wkshtfordevnone">Figure
C-2</A> show the host system information associated with the <TT>/dev/none</TT>
driver. <A name=nx_id_33></A>As the worksheets show, you gather the following
information about the host system:
<UL>
<P>
<LI>The host CPU or CPUs your driver operates on
<P></P>
<LI>The operating system or systems your driver operates on
<P></P>
<LI>The bus or buses that your driver connects to </LI></UL>
<P><A name=SpecHostCPU></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#specinfo_abouthostsys"><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#SpecOperateSys"><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.1 Specifying the Host CPU or CPUs on Which Your
Driver Operates </H3>
<P>For example purposes, the <TT>/dev/none</TT> driver will be developed for use
on a DEC 3000 Model 500 AXP Workstation. (Note, however, that the
<TT>/dev/none</TT> device driver cannot run on this CPU because it does not
control an actual hardware device.) <A name=nx_id_34></A><A name=nx_id_35></A>
<P>The goal should always be to write any device driver to operate on more than
one CPU hardware platform, so you should be aware of any differences presented
by different CPU architectures. By identifying the hardware platforms you want
the driver to operate on, you can address any driver design decisions related to
the CPU hardware architecture. This identification can help you determine
whether one driver, with appropriate conditional compilation statements, can
handle the CPU hardware platforms you want the driver to operate on. You might
decide that it would be easier to write two device drivers.
<P><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut6.html#CPUIssues">Section
3.1</A> discusses some device driver design issues that are affected by CPU
architectures. <A name=SpecOperateSys></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
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -