📄 block dd interfaces.htm
字号:
</tr>
<tr>
<td align="left" valign="top">
<tt>b_iodone</tt>
</td>
<td align="left" valign="top">
<tt>void (*b_iodone) ()</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>b_proc</tt>
</td>
<td align="left" valign="top">
<tt>struct proc *</tt>
</td>
</tr>
</tbody></table><p>
<cite>Writing Device Drivers: Reference</cite>
provides a reference page description of this data structure.
The following sections discuss all of these members.
<a name="Theb_flagsMember"></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="block%20DD%20interfaces_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="block%20DD%20interfaces_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ImplBlockDeviceRoutines"><img src="block%20DD%20interfaces_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#Understandbufmembers"><img src="block%20DD%20interfaces_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#Theb_forwMember"><img src="block%20DD%20interfaces_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/drivertut14.html"><img src="block%20DD%20interfaces_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="block%20DD%20interfaces_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="block%20DD%20interfaces_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
9.3.3.1 The b_flags Member
</h3>
<p>
The
<tt>b_flags</tt>
member specifies binary status flags.
These flags indicate how a request is to be handled and the current
status of the request.
<a name="nx_id_473"></a>
<a name="nx_id_474"></a>
<a name="nx_id_475"></a>
These status flags are defined in
<tt>buf.h</tt>
and get set by various parts of the kernel.
The flags supply the
device driver with information about the I/O operation.
</p><p>
The device driver can also send information back to the kernel by setting
<tt>b_flags</tt>.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut13.html#tblBinaryStatusFlags">Table 9-2</a>
lists the binary status flags applicable to device drivers.
</p><p>
<a name="tblBinaryStatusFlags"></a>
</p><h3>
Table 9-2: Binary Status Flags Applicable to Device Drivers
</h3>
<a name="nx_id_476"></a>
<table border="4" cellpadding="4">
<tbody><tr>
<td align="left" valign="top">
<strong>
Flag
</strong>
</td>
<td align="left" valign="top">
<strong>
Meaning
</strong>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>B_READ</tt>
</td>
<td align="left" valign="top">
This flag is set if the operation is read and cleared if the operation
is write.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>B_DONE</tt>
</td>
<td align="left" valign="top">
This flag is cleared when a request is passed to a driver
<tt>strategy</tt>
interface.
The device driver writer must call
<tt>iodone</tt>
to mark a buffer as completed.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>B_ERROR</tt>
</td>
<td align="left" valign="top">
This flag specifies that an error occurred on this data transfer.
Device drivers set this flag if an error occurs.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>B_BUSY</tt>
</td>
<td align="left" valign="top">
This flag indicates that the buffer is in use.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>B_PHYS</tt>
</td>
<td align="left" valign="top">
This flag indicates that the associated data is in user address space.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>B_WANTED</tt>
</td>
<td align="left" valign="top">
If this flag is set, it indicates that some process is waiting for this
buffer.
The device driver should issue a call to the
<tt>wakeup</tt>
interface when the buffer is freed by the current process.
The driver passes the address of the buffer as an argument to
<tt>wakeup</tt>.
</td>
</tr>
</tbody></table><p>
<a name="nx_id_477"></a>
<a name="nx_id_478"></a>
<a name="nx_id_479"></a>
<a name="nx_id_480"></a>
<a name="nx_id_481"></a>
<a name="nx_id_482"></a>
<a name="Theb_forwMember"></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="block%20DD%20interfaces_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="block%20DD%20interfaces_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ImplBlockDeviceRoutines"><img src="block%20DD%20interfaces_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#Theb_flagsMember"><img src="block%20DD%20interfaces_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#Theav_forwMember"><img src="block%20DD%20interfaces_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/drivertut14.html"><img src="block%20DD%20interfaces_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="block%20DD%20interfaces_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="block%20DD%20interfaces_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
9.3.3.2 The b_forw and b_back Members
</h3>
<p>
<a name="nx_id_483"></a>
<a name="nx_id_484"></a>
The
<tt>b_forw</tt>
and
<tt>b_back</tt>
members specify a file system buffer hash chain.
When the kernel performs an I/O operation on a buffer, the
<tt>buf</tt>
structures are not on any list.
Device driver writers sometimes use these members to link
<tt>buf</tt>
structures to lists.
<a name="Theav_forwMember"></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="block%20DD%20interfaces_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="block%20DD%20interfaces_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ImplBlockDeviceRoutines"><img src="block%20DD%20interfaces_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#Theb_forwMember"><img src="block%20DD%20interfaces_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#Theb_bcountMember"><img src="block%20DD%20interfaces_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/drivertut14.html"><img src="block%20DD%20interfaces_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="block%20DD%20interfaces_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="block%20DD%20interfaces_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
9.3.3.3 The av_forw and av_back Members
</h3>
<p>
<a name="nx_id_485"></a>
<a name="nx_id_486"></a>
The
<tt>av_forw</tt>
and
<tt>av_back</tt>
members specify the position on the free list if the
<tt>b_flags</tt>
member is not set to
<tt>B_BUSY</tt>.
<a name="nx_id_487"></a>
The kernel initializes these members.
However, when the driver gets use
of the
<tt>buf</tt>
structure, these members are available for local use by the device driver.
<a name="Theb_bcountMember"></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="block%20DD%20interfaces_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="block%20DD%20interfaces_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ImplBlockDeviceRoutines"><img src="block%20DD%20interfaces_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#Theav_forwMember"><img src="block%20DD%20interfaces_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#Theb_devMember"><img src="block%20DD%20interfaces_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/drivertut14.html"><img src="block%20DD%20interfaces_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="block%20DD%20interfaces_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="block%20DD%20interfaces_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
9.3.3.4 The b_bcount and b_error Members
</h3>
<p>
<a name="nx_id_488"></a>
The
<tt>b_bcount</tt>
member specifies
the size of the requested transfer (in bytes).
This member is initialized by the kernel as the result of an I/O
request.
The driver writer references this member to determine the size of the
I/O request.
This member is often used in the driver's
<tt>strategy</tt>
interface.
<a name="nx_id_489"></a>
</p><p>
The
<tt>b_error</tt>
member specifies
that an error occurred on this data transfer.
This member is set to an error code if the
<tt>b_flags</tt>
member bit was set.
The driver writer sets this member with the errors defined in the file
<tt>errno.h</tt>.
<a name="nx_id_490"></a>
<a name="nx_id_491"></a>
<a name="Theb_devMember"></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="block%20DD%20interfaces_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="block%20DD%20interfaces_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ImplBlockDeviceRoutines"><img src="block%20DD%20interfaces_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#Theb_bcountMember"><img src="block%20DD%20interfaces_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#Theb_addrMember"><img src="block%20DD%20interfaces_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/drivertut14.html"><img src="block%20DD%20interfaces_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="block%20DD%20interfaces_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="block%20DD%20interfaces_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
9.3.3.5 The b_dev Member
</h3>
<p>
<a name="nx_id_492"></a>
The
<tt>b_dev</tt>
member specifies
the special device to which the transfer is directed.
The data type for this member is
<tt>dev_t</tt>,
which maps to major and minor construction macros.
The device driver writer should not access
the
<tt>dev_t</tt>
bits directly.
Instead, the driver writer should use the
<tt>major</tt>
and
<tt>minor</tt>
interfaces to obtain the major and minor numbers for a special device.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut12.html#GetDevMajorNumb">Section 8.1.1.1</a>
and
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut12.html#GetDevMinorNumb">Section 8.1.1.2</a>
provide examples of how to call these interfaces.
</p><p>
A device driver writer can specify device special file information
(including major and minor numbers) in the
<tt>sysconfigtab</tt>
file fragment.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut18.html#ThesysconfigtabFileFragment">Section 13.4</a>
describes the
<tt>sysconfigtab</tt>
file fragment and
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut19.html#StaticConfigCresysconfigtab">Section 14.1.5</a>
describes the syntax used to populate a
<tt>sysconfigtab</tt>
file fragment.
<a name="nx_id_493"></a>
<a name="nx_id_494"></a>
<a name="Theb_addrMember"></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="block%20DD%20interfaces_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="block%20DD%20interfaces_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ImplBlockDeviceRoutines"><img src="block%20DD%20interfaces_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#Theb_devMember"><img src="block%20DD%20interfaces_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#Theb_blknoMember"><img src="block%20DD%20interfaces_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/drivertut14.html"><img src="block%20DD%20interfaces_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="block%20DD%20interfaces_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="block%20DD%20interfaces_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
9.3.3.6 The b_un.b_addr Member
</h3>
<p>
<a name="nx_id_495"></a>
The
<tt>b_un.b_addr</tt>
member specifies the address at which to pull or push the data.
This member is set by the kernel and is the main memory address where
the I/O occurs.
Driver writers use this member when their drivers need to perform DMA
operations.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -