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

📄 kernel interfaces with dd.htm

📁 What is this ``device driver stuff anyway? Here s a very short introduction to the concept.
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<a href="#UsingKernRtnswithDrvs"><img src="kernel%20interfaces%20with%20DD_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#copydatakern_touser"><img src="kernel%20interfaces%20with%20DD_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#HardRelInter"><img src="kernel%20interfaces%20with%20DD_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/drivertut26.html"><img src="kernel%20interfaces%20with%20DD_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="kernel%20interfaces%20with%20DD_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="kernel%20interfaces%20with%20DD_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
18.2.5&nbsp;&nbsp;&nbsp;&nbsp;Moving Data Between User Virtual Space and System Virtual Space
</h3>
<p>
<a name="nx_id_829"></a>
To move data between user virtual space and system virtual space, call the
<tt>uiomove</tt>
interface.
The following code fragment shows a call to
<tt>uiomove</tt>:
</p><p>
</p><pre><br>.<br>.<br>.<br>
struct uio *uio;
register struct buf *bp;
int err;
int cnt;
unsigned tmp;
<br>.<br>.<br>.<br>
err = uiomove(&amp;tmp,cnt,uio); <a name="co_id_136_rtn_1"></a><a href="#co_id_136_1"><strong>[1]</strong></a>
<br>.<br>.<br>.<br>
</pre>
<p>
</p><ol>
<p></p><li>
<a name="co_id_136_1"></a>
<a name="nx_id_830"></a>
Shows that the
<tt>uiomove</tt>
interface takes three arguments:
<ul>
<p></p><li>
The first argument specifies
a pointer to the kernel buffer in system virtual space.
<p></p></li><li>
The second argument specifies
the number of bytes of data to be moved.
In this example, the number of bytes to be moved is stored
in the
<tt><var>cnt</var></tt>
variable.
<p></p></li><li>
The third argument specifies a pointer to a
<tt>uio</tt>
structure.
This structure describes the current position within a logical user
buffer in user virtual space.
</li></ul><p>
</p><p>
<a href="#co_id_136_rtn_1">[Return to example]</a>
</p></li></ol><p>
<a name="HardRelInter"></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="kernel%20interfaces%20with%20DD_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="kernel%20interfaces%20with%20DD_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#UsingKernRtnswithDrvs"><img src="kernel%20interfaces%20with%20DD_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#MoveDataBetwUserandSysSpace"><img src="kernel%20interfaces%20with%20DD_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#DelayCallInterMicro"><img src="kernel%20interfaces%20with%20DD_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/drivertut26.html"><img src="kernel%20interfaces%20with%20DD_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="kernel%20interfaces%20with%20DD_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="kernel%20interfaces%20with%20DD_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h2>
18.3&nbsp;&nbsp;&nbsp;&nbsp;Hardware-Related Interfaces
</h2>
<p>
<a name="nx_id_831"></a>
The hardware-related interfaces allow device drivers to perform the
following tasks related to the hardware:
</p><ul>
<p></p><li>
Delay the calling interface a specified number of microseconds
<p></p></li><li>
Set the interrupt priority mask
</li></ul><p>
The following sections describe the kernel interfaces that perform these tasks.
<a name="DelayCallInterMicro"></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="kernel%20interfaces%20with%20DD_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="kernel%20interfaces%20with%20DD_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#UsingKernRtnswithDrvs"><img src="kernel%20interfaces%20with%20DD_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#HardRelInter"><img src="kernel%20interfaces%20with%20DD_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#SetProcPriorityMask"><img src="kernel%20interfaces%20with%20DD_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/drivertut26.html"><img src="kernel%20interfaces%20with%20DD_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="kernel%20interfaces%20with%20DD_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="kernel%20interfaces%20with%20DD_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
18.3.1&nbsp;&nbsp;&nbsp;&nbsp;Delaying the Calling Interface a Specified Number of Microseconds
</h3>
<p>
To delay the calling interface a specified number of microseconds, call the
<tt>DELAY</tt>
interface.
The following code fragment shows a call to this interface:
</p><p>
</p><pre><br>.<br>.<br>.<br>
DELAY(10000) <a name="co_id_137_rtn_1"></a><a href="#co_id_137_1"><strong>[1]</strong></a>
<br>.<br>.<br>.<br>
</pre>
<p>
</p><ol>
<p></p><li>
<a name="co_id_137_1"></a>
<a name="nx_id_832"></a>
Shows that the
<tt>DELAY</tt>
interface takes one argument: the number of microseconds for the calling
process to spin.
<p>
The
<tt>DELAY</tt>
interface
delays the calling interface a specified number of microseconds.
<tt>DELAY</tt>
spins, waiting for the specified number of
microseconds to pass before continuing execution.
In the example, there is a 10000-microsecond (10-millisecond)
delay.
The range of delays is system dependent, due to its relation to the
granularity of the system clock.
The system defines
the number of clock ticks per second in the
<tt><var>hz</var></tt>
variable.
Specifying any value smaller than 1/hz to the
<tt>DELAY</tt>
interface results in an unpredictable delay.
For any delay value, the actual delay may vary by plus or
minus one clock tick.
</p><p>
Using the
<tt>DELAY</tt>
interface
is discouraged because the processor will be consumed for the
specified time interval and therefore is unavailable to service other processes.
In cases where device drivers need timing mechanisms, you should use the
<tt>sleep</tt>
and
<tt>timeout</tt>
interfaces instead of the
<tt>DELAY</tt>
interface.
The most common usage of the
<tt>DELAY</tt>
interface is in the system boot path.
Using
<tt>DELAY</tt>
in the boot path is often acceptable because there are no other
processes in contention for the processor.
<a href="#co_id_137_rtn_1">[Return to example]</a>
</p></li></ol><p>
<a name="SetProcPriorityMask"></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="kernel%20interfaces%20with%20DD_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="kernel%20interfaces%20with%20DD_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#UsingKernRtnswithDrvs"><img src="kernel%20interfaces%20with%20DD_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#DelayCallInterMicro"><img src="kernel%20interfaces%20with%20DD_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#KernRelInter"><img src="kernel%20interfaces%20with%20DD_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/drivertut26.html"><img src="kernel%20interfaces%20with%20DD_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="kernel%20interfaces%20with%20DD_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="kernel%20interfaces%20with%20DD_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
18.3.2&nbsp;&nbsp;&nbsp;&nbsp;Setting the Interrupt Priority Mask
</h3>
<p>
To set the interrupt priority level (IPL) mask to a specified level,
call one of the
<tt>spl</tt>
interfaces.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut25.html#tblsplinter">Table 18-1</a>
summarizes the uses for the different
<tt>spl</tt>
interfaces.
</p><p>
<a name="tblsplinter"></a>
</p><h3>
Table 18-1: Uses for spl Interfaces
</h3>
<table border="4" cellpadding="4">
<tbody><tr>
<td align="left" valign="top">
<strong>
spl Interface
</strong>
</td>
<td align="left" valign="top">
<strong>
Meaning
</strong>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>getspl</tt>
</td>
<td align="left" valign="top">
Gets the
<tt>spl</tt>
value.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>splbio</tt>
</td>
<td align="left" valign="top">
Masks all disk and tape controller interrupts.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>splclock</tt>
</td>
<td align="left" valign="top">
Masks all hardware clock interrupts.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>spldevhigh</tt>
</td>
<td align="left" valign="top">
Masks all device and software interrupts.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>splextreme</tt>
</td>
<td align="left" valign="top">
Blocks against all but halt interrupts.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>splhigh</tt>
</td>
<td align="left" valign="top">
Masks all interrupts except for realtime devices, machine checks, and halt
interrupts.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>splimp</tt>
</td>
<td align="left" valign="top">
Masks all Ethernet hardware interrupts.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>splnet</tt>
</td>
<td align="left" valign="top">
Masks all network software interrupts.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>splnone</tt>
</td>
<td align="left" valign="top">
Unmasks (enables) all interrupts.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>splsched</tt>
</td>
<td align="left" valign="top">
Masks all scheduling interrupts (usually the hardware clock).
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>splsoftclock</tt>
</td>
<td align="left" valign="top">
Masks all software clock interrupts.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>spltty</tt>
</td>
<td align="left" valign="top">
Masks all
<tt>tty</tt>
(terminal device) interrupts.
</td>
</tr>
<tr>
<td align="left" valign="top">

⌨️ 快捷键说明

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