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

📄 block dd interfaces.htm

📁 What is this ``device driver stuff anyway? Here s a very short introduction to the concept.
💻 HTM
📖 第 1 页 / 共 4 页
字号:
It tells the driver where the data comes from and goes to in memory. 
<a name="nx_id_496"></a>
<a name="Theb_blknoMember"></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_addrMember"><img src="block%20DD%20interfaces_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#Theb_bresidMember"><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.7&nbsp;&nbsp;&nbsp;&nbsp;The b_lblkno and b_blkno Members
</h3>
<p>
<a name="nx_id_497"></a>
<a name="nx_id_498"></a>
The
<tt>b_lblkno</tt>
member specifies
the logical block number.
The
<tt>b_blkno</tt>
member specifies
the block number on the partition of a disk or on the
file system.
The
<tt>b_blkno</tt>
member is set by the kernel and it indicates the starting block number
on the device where the I/O operation is to begin.
Device drivers use this member only with block devices.
For disk devices, this member is the block number relative to the start
of the partition.
<a name="nx_id_499"></a>
<a name="nx_id_500"></a>
<a name="Theb_bresidMember"></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_blknoMember"><img src="block%20DD%20interfaces_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#Theb_procMember"><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.8&nbsp;&nbsp;&nbsp;&nbsp;The b_resid and b_iodone Members
</h3>
<p>
<a name="nx_id_501"></a>
<a name="nx_id_502"></a>
The
<tt>b_resid</tt>
member specifies (in bytes) the data not transferred because of some error.
The
<tt>b_iodone</tt>
member specifies the interface called by
<tt>iodone</tt>.
The device driver calls
<tt>iodone</tt>
at the completion of an I/O operation.
The driver calls the
<tt>iodone</tt>
interface, which calls the interface pointed to by the
<tt>b_iodone</tt>
member.
The driver writer does not need to know anything about the interface
pointed to by this argument.
<a name="nx_id_503"></a>
<a name="Theb_procMember"></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_bresidMember"><img src="block%20DD%20interfaces_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#BufCacheMgmt"><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.9&nbsp;&nbsp;&nbsp;&nbsp;The b_proc Member
</h3>
<p>
<a name="nx_id_504"></a>
The
<tt>b_proc</tt>
member specifies
a pointer to the
<tt>proc</tt>
structure that represents the process performing the I/O.
A device driver might pass
<tt>b_proc</tt>
in a call to the
<tt>vtop</tt>
interface in order to translate a virtual address to a physical address.
<a name="BufCacheMgmt"></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_procMember"><img src="block%20DD%20interfaces_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#BufHeader"><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.4&nbsp;&nbsp;&nbsp;&nbsp;Using Buffer Cache Management
</h3>
<p>
<a name="nx_id_505"></a>
When the file system deals with regular files, directories, and block
devices, the I/O requests are serviced through the buffer cache system.
Because the buffer cache deals with fixed-size buffers, it is often
necessary to translate the user's request for I/O into buffer-size
pieces called blocks.
Only in the case where the size of the user's I/O matches a block and
aligns to a block boundary will the underlying request match the
user's size.
A large I/O request is broken down into many block requests, with
each block request going to the buffer cache system separately.
Both read and write requests smaller than a block force the file system
to request a read of the entire block and deal with the small read
or write in the buffer.
</p><p>
Regular files and directories go through an extra translation process to
map their logical block number into the physical blocks of the disk
device.
This mapping process itself can generate block requests to the buffer
cache system to deal with file extensions or to obtain or modify
indirect file system blocks.
</p><p>
Buffer reads and buffer writes do not necessarily cause I/O to occur.
In the case of buffer reads, the request can be satisfied by data
already in the cache.
On the other hand, buffer writes can modify or replace data in the
cache, but the physical write might be delayed.
Using a buffer cache enhances performance because
data that changes often in the cache does not
require a physical write for each change.
</p><p>
<a name="nx_id_506"></a>
<a name="nx_id_507"></a>
The nature of the buffer cache system's delayed physical I/O requires
that each buffer request, or each block read or write, be a self-contained
I/O request to the device driver's
<tt>strategy</tt>
interface.
The buffer cache system and the block device driver
<tt>strategy</tt>
interface cannot assume any particular process context; therefore, the
context of the process must be severed from the I/O request.
The buffer passed to the buffer interface has all of the context
necessary to perform the I/O.
<br>
<a name="BufHeader"></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="#BufCacheMgmt"><img src="block%20DD%20interfaces_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#SetUpStrategyRoutine"><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.5&nbsp;&nbsp;&nbsp;&nbsp;Buffer Cache Interface
</h3>
<p>
<a name="nx_id_508"></a>
<a name="nx_id_509"></a>
I/O requests come from a buffer cache interface as follows:
</p><p>
</p><pre>(*dsent[major](dev).d_strategy)(bp);
</pre>
<p>
The
<tt>dsent</tt>
table is referenced and the appropriate driver interface is called
through the block device's major number.
The driver's
<tt>strategy</tt>
interface is passed a pointer to a
<tt>buf</tt>
structure.
<a name="SetUpStrategyRoutine"></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="#BufHeader"><img src="block%20DD%20interfaces_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<img src="block%20DD%20interfaces_files/BLANK.GIF" border="0">
<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.6&nbsp;&nbsp;&nbsp;&nbsp;Setting Up the strategy Interface
</h3>
<p>
<a name="nx_id_510"></a>
The following code shows you how to set up a
<tt>strategy</tt>
interface, using the
<tt>/dev/xx</tt>
driver as an example:
</p><p>
</p><p>
</p><pre>xxstrategy(bp)
struct buf *bp; <a name="co_id_79_rtn_1"></a><a href="#co_id_79_1"><strong>[1]</strong></a>
{
</pre>
<p>
<br>
<tt>.</tt>
<br>
<tt>.</tt>
<br>
<tt>.</tt>
<br>
</p><p>
</p><ol>
<p></p><li>
<a name="co_id_79_1"></a>
Declares an argument that specifies
a pointer to a
<tt>buf</tt>
structure.
This structure describes the I/O operation to be performed.
<p>
See
<cite>Writing Device Drivers: Advanced Topics</cite>
for an example implementation of a
<tt>strategy</tt>
interface.
<a href="#co_id_79_rtn_1">[Return to example]</a>
</p></li></ol><p>
<!--Metrics Tag -->
 <!-- Updated April 22, 2003 --> 
<!-- SiteCatalyst code version: G.0. w/dev site filtering
Copyright 1997-2003 Omniture, Inc. More info available at
http://www.omniture.com --><script language="JavaScript"><!--
/* Specify the Report Suite ID(s) to track here */
var s_account="HPHQGlobal,hphqWWesg,hphqbcs,hphqtru64"
/* Dynamic Report Suite ID Selection Config */
var s_dynamicAccountSelection = true
var s_dynamicAccountList = "hphqwwtrash=dec.com,cpqcorp.net,hpqcorp.net"
/* You may give each page an identifying user friendly name in place of urls. */
var s_pageName="Tru64-" + document.title;
if ( location.pathname.indexOf('/docs' ) != -1 )         { s_pageName = "Tru64-docs-" + document.title; }

/* Regionally assigned variables. */
var s_server=""
var s_channel=""
var s_pageType=""
var s_prop1="Tru64 UNIX"
if ( location.pathname.indexOf('/docs' ) != -1 )         { s_prop1 = "Tru64 documentation"; }
var s_prop2 = "";

   if ( location.search.indexOf('?jumpid=' ) != -1 )
        {
        s_prop2=location.search.substring((location.search.indexOf('?jumpid=' )+8),(location.search.length));
        }
			else
		{ 
		if (location.search.toUpperCase().indexOf('?' ) != -1 )        {
		s_prop2=location.search.toUpperCase().substring((location.search.toUpperCase().indexOf('?' )+1),(location.search.length));
		}
		}
var s_prop6=""
var s_prop7="w1"
var s_prop8="en-us"
var s_prop9="enterprise"
var s_prop10="w1|en-us|enterprise"
var s_prop13="HPHQGlobal,hphqWWesg,hphqbcs,hphqtru64"


/************************ ADDITIONAL FEATURES ************************
     Plugins
*/
/************************** CONFIG SECTION **************************/
/* You may add or alter any code config here.                       */
var s_charSet=""
// Netscape 4.X on Unix uses EUC-JP instead of SHIFT-JIS
if ((navigator.appName.indexOf('Netscape')>=0)&&
    (parseInt(navigator.appVersion)<=4)&&
    (navigator.userAgent.toLowerCase().indexOf('win')<0)&&
    (navigator.userAgent.toLowerCase().indexOf('mac')<0)) {
	s_charSet="EUC-JP"
}
/* E-commerce Config */
var s_eVarCFG=""

/* Link Tracking Config */
var s_trackDownloadLinks=true
var s_trackExternalLinks=true
var s_trackInlineStats=true
var s_linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,doc,pdf,xls,cgi,dot,pot,ppt,wmv,cgi,asx,tar,rpm,gz,crypt,sh"
var s_linkInternalFilters="hp,compaq,javascript:"
var s_linkLeaveQueryString=true


/********* INSERT THE DOMAIN AND PATH TO YOUR CODE BELOW ************/
//--></script><script language="JavaScript" src="block%20DD%20interfaces_files/s_code.js"></script><img src="block%20DD%20interfaces_files/s5632840183750.gif" name="s_i_hphqglobal" border="0" height="1" width="1">
<!-- End SiteCatalyst code version: G.0. -->

<!--End Tag -->
</p></body></html>

⌨️ 快捷键说明

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