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

📄 supp device auto config.htm

📁 What is this ``device driver stuff anyway? Here s a very short introduction to the concept.
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<tr>
<td align="left" valign="top">
<tt>ih_id</tt>
</td>
<td align="left" valign="top">
<tt>ihandler_id_t</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>ih_bus</tt>
</td>
<td align="left" valign="top">
<tt>struct bus *</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>ih_bus_info</tt>
</td>
<td align="left" valign="top">
<tt>char *</tt>
</td>
</tr>
</tbody></table><p>
</p><p>
The
<tt>ih_id</tt>
member specifies
a unique ID.
Device drivers do not use this member.
</p><p>
<a name="nx_id_366"></a>
The
<tt>ih_bus</tt>
member specifies
a pointer to the
<tt>bus</tt>
structure associated with this device driver.
This member is needed because the interrupt dispatching methodology
requires that the bus be responsible for dispatching interrupts in a
bus-specific manner.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut24.html#BusStruct">Section 17.1</a>
describes the
<tt>bus</tt>
structure.
<a name="nx_id_367"></a>
</p><p>
The
<tt>ih_bus_info</tt>
member specifies
bus registration information.
Each bus type could have different mechanisms for registering
interrupt handlers on that bus.
Thus, the
<tt>ih_bus_info</tt>
member contains the bus-specific information needed to register the
interrupt handlers.
</p><p>
For example, on a TURBOchannel bus, the bus-specific information might
consist of:
</p><ul>
<p></p><li>
The name of the interrupt handler for the specified controller
<p></p></li><li>
A parameter passed to the interrupt handler
<p></p></li><li>
A driver type (that is, whether the driver handles a controller or a
bus)
<p></p></li><li>
A pointer to the
<tt>controller</tt>
structure associated with the controller for which an associated
interrupt will be written
</li></ul><p>
<a name="nx_id_368"></a>
</p><p>
Device driver writers set the
<tt>ih_bus_info</tt>
member to the filled-in
<tt>handler_intr_info</tt>
structure, which contains the bus-specific information.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut11.html#Thehandler_intr_infoStruct">Section 7.1.5.2</a>
describes the
<tt>handler_intr_info</tt>
structure.
</p><p>
Device driver writers pass the
<tt>ihandler_t</tt>
structure to the
<tt>handler_add</tt>
interface in the driver's
<tt>probe</tt>
interface to specify how interrupt handlers are to be registered with
the bus-specific interrupt dispatcher.
<a name="Thehandler_intr_infoStruct"></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="supp%20device%20auto%20config_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="supp%20device%20auto%20config_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ImplProbeRtn"><img src="supp%20device%20auto%20config_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#Theihandler_tStruct"><img src="supp%20device%20auto%20config_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#RegISIswithhandlerRtns"><img src="supp%20device%20auto%20config_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/drivertut12.html"><img src="supp%20device%20auto%20config_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="supp%20device%20auto%20config_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="supp%20device%20auto%20config_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
7.1.5.2&nbsp;&nbsp;&nbsp;&nbsp;The handler_intr_info Data Structure
</h3>
<p>
<a name="nx_id_369"></a>
<a name="nx_id_370"></a>
<a name="nx_id_371"></a>
The
<tt>handler_intr_info</tt>
structure contains interrupt handler information for device controllers
connected to a bus.
This generic structure makes device drivers more portable
across different buses because it contains all of the necessary
information to add an interrupt handler for any bus.
Device driver writers set the
<tt>ih_bus_info</tt>
member of the
<tt>ihandler_t</tt>
structure to the filled-in
<tt>handler_intr_info</tt>
structure, usually in the driver's
<tt>probe</tt>
interface.
<a name="nx_id_372"></a>
</p><p>
The
<tt>bus</tt>
and
<tt>controller</tt>
structures contain the bus- and controller-specific information that is
not provided in
<tt>handler_intr_info</tt>.
</p><p>
For VMEbus device drivers, you use the
<tt>vme_handler_info</tt>
structure instead of the
<tt>handler_intr_info</tt>
structure.
One of the members of the
<tt>vme_handler_info</tt>
structure is a
<tt>handler_intr_info</tt>
structure.
See
<cite>Writing VMEbus Device Drivers</cite>
for more information on the
<tt>vme_handler_info</tt>
structure.
</p><p>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut11.html#Tblhandler_intr_infoStructMembers">Table 7-2</a>
lists the members of the
<tt>handler_intr_info</tt>
structure along with their associated data types.
You typically set the members of this structure to appropriate values in
the driver's
<tt>probe</tt>
interface.
</p><p>
<a name="Tblhandler_intr_infoStructMembers"></a>
</p><h3>
Table 7-2: Members of the handler_intr_info Structure
</h3>
<a name="nx_id_373"></a>
<table border="4" cellpadding="4">
<tbody><tr>
<td align="left" valign="top">
<strong>
Member Name
</strong>
</td>
<td align="left" valign="top">
<strong>
Data Type
</strong>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>configuration_st</tt>
</td>
<td align="left" valign="top">
<tt>caddr_t</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>intr</tt>
</td>
<td align="left" valign="top">
<tt>int (*intr) ()</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>param</tt>
</td>
<td align="left" valign="top">
<tt>caddr_t</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>config_type</tt>
</td>
<td align="left" valign="top">
<tt>unsigned int</tt>
</td>
</tr>
</tbody></table><p>
</p><p>
The
<tt>configuration_st</tt>
member specifies
a pointer to the
<tt>bus</tt>
or
<tt>controller</tt>
structure for which an associated interrupt handler is written.
</p><p>
<a name="nx_id_374"></a>
</p><p>
The
<tt>intr</tt>
member specifies
the name of the interrupt handler for the specified bus or controller.
</p><p>
The
<tt>param</tt>
member specifies
a parameter that you want passed to the specified interrupt handler. 
</p><p>
The
<tt>config_type</tt>
member specifies
the driver type and whether the driver's interrupt handler
can handle shared interrupts.
If your device driver's interrupt handler cannot handle shared interrupts,
you set
this member to one of the following interrupt handler type bit values
defined in
<tt>handler.h</tt>:
<tt>CONTROLLER_CONFIG_TYPE</tt>
(the interrupt handler is for a controller)
or
<tt>ADAPTER_CONFIG_TYPE</tt>
(the interrupt handler is for a bus adapter).
If your device driver's interrupt handler can handle shared interrupts,
you set this
member to the bitwise inclusive OR of the interrupt handler type bit
value and the shared interrupt bit value
<tt>SHARED_INTR_CAPABLE</tt>.
<a name="nx_id_375"></a>
<a name="nx_id_376"></a>
<a name="nx_id_377"></a>
<a name="nx_id_378"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut11.html#RegISIswithhandlerRtns">Section 7.1.6</a>
shows you how to register an interrupt handler, using the
<tt>/dev/none</tt>
driver as an example.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut11.html#RegSharedISIswithhandlerRtns">Section 7.1.7</a>
shows you how to register a shared interrupt handler, using the
<tt>/dev/xx</tt>
driver as an example.
<a name="RegISIswithhandlerRtns"></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="supp%20device%20auto%20config_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="supp%20device%20auto%20config_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ImplProbeRtn"><img src="supp%20device%20auto%20config_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#Thehandler_intr_infoStruct"><img src="supp%20device%20auto%20config_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#RegSharedISIswithhandlerRtns"><img src="supp%20device%20auto%20config_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/drivertut12.html"><img src="supp%20device%20auto%20config_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="supp%20device%20auto%20config_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="supp%20device%20auto%20config_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
7.1.6&nbsp;&nbsp;&nbsp;&nbsp;Using the handler Interfaces to Register Interrupt Handlers
</h3>
<p>
<a name="nx_id_379"></a>
<a name="nx_id_380"></a>
To register a device driver's interrupt handlers, you perform the
following tasks:
</p><ul>
<p></p><li>
Declare instances of the
<tt>ihandler_t</tt>
and
<tt>handler_intr_info</tt>
data structures
<p></p></li><li>
Get the controller number associated with the controller for this
device
<p></p></li><li>
Get the I/O handle passed in by the bus configuration code
<p></p></li><li>
Set the members of the
<tt>ihandler_t</tt>
and
<tt>handler_intr_info</tt>
structures to appropriate values
<p></p></li><li>
Call the
<tt>handler_add</tt>
and
<tt>handler_enable</tt>
interfaces
</li></ul><p>
Your
<tt>probe</tt>
interface will probably perform most of these tasks and, possibly, some
additional ones.
The following code shows how to perform these tasks, using the
<tt>/dev/none</tt>
driver as an example:
</p><p>
<br>
<tt>.</tt>
<br>
<tt>.</tt>
<br>
<tt>.</tt>
<br>
</p><p>
</p><pre><p>
     ihandler_t handler;        <a name="co_id_52_rtn_1"></a><a href="#co_id_52_1"><strong>[1]</strong></a>
     struct handler_intr_info info;  <a name="co_id_52_rtn_2"></a><a href="#co_id_52_2"><strong>[2]</strong></a>
     int unit = ctlr-&gt;ctlr_num; <a name="co_id_52_rtn_3"></a><a href="#co_id_52_3"><strong>[3]</strong></a>
     register io_handle_t reg = bus_io_handle; <a name="co_id_52_rtn_4"></a><a href="#co_id_52_4"><strong>[4]</strong></a> 
</p><p>

     if( num_none &gt;= NNONE) <a name="co_id_52_rtn_5"></a><a href="#co_id_52_5"><strong>[5]</strong></a>
             return (0);
</p><p>

     handler.ih_bus = ctlr-&gt;bus_hd; <a name="co_id_52_rtn_6"></a><a href="#co_id_52_6"><strong>[6]</strong></a>
</p><p>
</p><p>
     info.configuration_st = (caddr_t)ctlr; <a name="co_id_52_rtn_7"></a><a href="#co_id_52_7"><strong>[7]</strong></a>
</p><p>
     info.config_type = CONTROLLER_CONFIG_TYPE; <a name="co_id_52_rtn_8"></a><a href="#co_id_52_8"><strong>[8]</strong></a>
</p><p>

⌨️ 快捷键说明

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