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

📄 developing a device driver.htm

📁 What is this ``device driver stuff anyway? Here s a very short introduction to the concept.
💻 HTM
📖 第 1 页 / 共 5 页
字号:
6.6.4.3</A> shows how to call these interfaces to create the <TT>controller</TT> 
and <TT>device</TT> structures associated with your device drivers. If you are 
supporting Digital devices, you specify valid device definition keywords 
asssociated with these devices. These keywords represent the controllers and 
devices that Digital supports. See the <CITE>System Administration</CITE> guide 
(specifically, the section that discusses how to build the kernel to add support 
for a new device) for information on how to obtain the device definition 
keywords asssociated with Digital-supported devices. 
<P>If you are supporting non-Digital devices, you can select any string other 
than those already chosen by Digital to represent the device. However, without 
an exclusive naming scheme, your choices could conflict with those of other 
third-party driver vendors. To avoid these conflicts, you can select a string 
that includes the vendor and product names and, possibly, the version and 
release numbers. This type of naming scheme minimizes the potential for name 
conflicts. For example, the driver writers at EasyDriver Incorporated might 
specify <TT>edgd</TT> for an internally developed device. <A 
name=ChooseWrtngComments></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#SpecNamingScheme"><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#specchar_ofdev"><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.2&nbsp;&nbsp;&nbsp;&nbsp;Choosing an Approach for Writing Comments and 
Documentation </H3>
<P><A name=nx_id_47></A>The <TT>/dev/none</TT> driver takes two approaches to 
supplying comments in the driver code examples used in the book. In the first 
approach, the <TT>/dev/none</TT> driver contains no inline comments. Instead, 
the following convention is used: 
<P><PRE>int unit = minor(dev); <A name=co_id_2_rtn_1></A><A href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#co_id_2_1"><STRONG>[1]</STRONG></A>
</PRE>
<P>
<OL>
  <P>
  <LI><A name=co_id_2_1></A><A name=nx_id_48></A>A number appears after a line 
  of code in the <TT>/dev/none</TT> device driver example. Following the 
  example, a corresponding number appears that contains an explanation of the 
  associated line or lines. The device driver examples contained in Part 3 use 
  the first approach to make the source code easier to read. <A 
  href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut5.html#co_id_2_rtn_1">[Return 
  to example]</A> </LI></OL>
<P>In the second approach, the <TT>/dev/none</TT> device driver supplies 
appropriate inline comments. The source code listing in <A 
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut28.html#DevDrvSrcList">Appendix 
B</A> uses the second approach. 
<P>In addition to providing background information and detailed explanations of 
the <TT>/dev/none</TT> driver, this book also offers information on device 
driver concepts, kernel interfaces, data structures, and so forth. Your approach 
to writing device driver documentation may be different. <A 
name=specchar_ofdev></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#ChooseWrtngComments"><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#SpecWhetDevCapBlockIO"><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.3&nbsp;&nbsp;&nbsp;&nbsp;Specifying Characteristics of the Device </H3>
<P><A 
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut29.html#devcharac_wkshtfordevnone">Figure 
C-5</A> and <A 
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut29.html#devcharac2_wkshtfordevnone">Figure 
C-6</A> show the device characteristics for the <TT>NONE</TT> device associated 
with the <TT>/dev/none</TT> driver. <A name=nx_id_49></A>
<P>As the worksheets show, you specify the following characteristics associated 
with the device: 
<UL>
  <P>
  <LI>Whether the device is capable of block I/O 
  <P></P>
  <LI>Whether the device supports a file system 
  <P></P>
  <LI>Whether the device supports byte stream access 
  <P></P>
  <LI>Actions to take on interrupts 
  <P></P>
  <LI>How to reset the device 
  <P></P>
  <LI>Other device characteristics </LI></UL>
<P><A name=SpecWhetDevCapBlockIO></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#specchar_ofdev"><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#SpecWhetDevSuppFileSys"><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.3.1&nbsp;&nbsp;&nbsp;&nbsp;Specifying Whether the Device Is Capable of 
Block I/O </H3>
<P><A name=nx_id_50></A>If the device is capable of block I/O, then you would 
write a block device driver. A block device is one that stores data on its media 
in a standard way. For example, most disk drives store data in disk sectors 
(typically 512 bytes). <A name=nx_id_51></A>Tape drives sometimes store data in 
a standard-size tape record. 
<P>Typically, block devices are random access devices (that is, disks) because 
the file system does not always perform I/O to sequential disk sectors. Tape 
devices are typically sequential access devices and, therefore, not suitable for 
using as a block device. 
<P>The <TT>NONE</TT> device is not capable of handling blocks of data so the No 
box on the worksheet shown in <A 
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut29.html#devcharac_wkshtfordevnone">Figure 
C-5</A> is marked. <A name=SpecWhetDevSuppFileSys></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#SpecWhetDevCapBlockIO"><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#SpecWhetDevSuppByteStream"><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.3.2&nbsp;&nbsp;&nbsp;&nbsp;Specifying Whether the Device Supports a File 
System </H3>
<P><A name=nx_id_52></A>Most block devices can support file systems. If a block 
device supports a file system, it must be able to map between file system blocks 
and the underlying structure on the device. In Digital UNIX, this mapping is 
accomplished through partition tables. 
<P>The <TT>NONE</TT> device is not capable of supporting file systems, so the No 
box on the worksheet shown in <A 
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut29.html#devcharac_wkshtfordevnone">Figure 
C-5</A> is marked. <A name=SpecWhetDevSuppByteStream></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#SpecWhetDevSuppFileSys"><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#SpecActionsonInterrupts"><IMG 

⌨️ 快捷键说明

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