📄 supp device auto config.htm
字号:
</p><p>
info.intr = noneintr; <a name="co_id_52_rtn_9"></a><a href="#co_id_52_9"><strong>[9]</strong></a>
</p><p>
</p><p>
info.param = (caddr_t)unit; <a name="co_id_52_rtn_10"></a><a href="#co_id_52_10"><strong>[10]</strong></a>
</p><p>
handler.ih_bus_info = (char *)&info; <a name="co_id_52_rtn_11"></a><a href="#co_id_52_11"><strong>[11]</strong></a>
</p><p>
</p><p>
none_id_t[unit] = handler_add(&handler); <a name="co_id_52_rtn_12"></a><a href="#co_id_52_12"><strong>[12]</strong></a>
if (none_id_t[unit] == NULL) { <a name="co_id_52_rtn_13"></a><a href="#co_id_52_13"><strong>[13]</strong></a>
</p><p>
return(0);
}
</p><p>
if (handler_enable(none_id_t[unit]) != 0) { <a name="co_id_52_rtn_14"></a><a href="#co_id_52_14"><strong>[14]</strong></a>
handler_del(none_id_t[unit]);
return(0);
}
num_none++; <a name="co_id_52_rtn_15"></a><a href="#co_id_52_15"><strong>[15]</strong></a>
</p></pre>
<p>
<br>
<tt>.</tt>
<br>
<tt>.</tt>
<br>
<tt>.</tt>
<br>
</p><p>
</p><ol>
<p></p><li>
<a name="co_id_52_1"></a>
Declares an
<tt>ihandler_t</tt>
data structure called
<tt>handler</tt>
to contain information associated with the
<tt>/dev/none</tt>
device driver interrupt handling.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut11.html#Theihandler_tStruct">Section 7.1.5.1</a>
describes the
<tt>ihandler_t</tt>
structure.
The
<tt>noneprobe</tt>
interface initializes two members of this data structure.
<a href="#co_id_52_rtn_1">[Return to example]</a>
<p></p></li><li>
<a name="co_id_52_2"></a>
Declares a
<tt>handler_intr_info</tt>
data structure called
<tt>info</tt>.
The
<tt>handler_intr_info</tt>
structure contains interrupt handler information for device controllers
connected to a bus.
The
<tt>handler_intr_info</tt>
structure is a generic structure that contains interrupt handler
information
for buses connected to a device controller.
Use of the
<tt>handler_intr_info</tt>
structure makes the driver more portable across different bus
architectures.
<p>
The
<tt>/dev/none</tt>
device driver uses this interrupt handler structure to dynamically
register its interrupt handler.
<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.
<a href="#co_id_52_rtn_2">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_52_3"></a>
Declares a
<tt><var>unit</var></tt>
variable and initializes it to the controller number for this
controller.
This controller number identifies the specific
<tt>NONE</tt>
controller that is being probed.
<p>
The controller number is contained in the
<tt>ctlr_num</tt>
member of the
<tt>controller</tt>
structure associated with this
<tt>NONE</tt>
device.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut24.html#ctlrtype">Section 17.2.4</a>
describes the
<tt>ctlr_num</tt>
member.
<a href="#co_id_52_rtn_3">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_52_4"></a>
Declares a variable called
<tt><var>reg</var></tt>
and initializes it to the I/O handle passed to the driver's
<tt>probe</tt>
interface by the bus configuration code.
In this case, the I/O handle describes the system virtual address (SVA)
that corresponds to the base slot address (on a TURBOchannel bus) for the
<tt>NONE</tt>
device.
<a href="#co_id_52_rtn_4">[Return to example]</a>
<p></p></li><li>
<a name="co_id_52_5"></a>
If the number of controllers probed is greater than or equal to the
number of controllers the system is configured for, returns the value
zero (0) to indicate that the probe operation failed.
When the
<tt>noneprobe</tt>
interface is called the first time,
<tt><var>num_none</var></tt>
is zero (0).
Note that
<tt>NNONE</tt>
is set to one.
Customers of EasyDriver Incorporated can change this value by editing the
<tt>none:</tt>
entry in the
<tt>/etc/sysconfigtab</tt>
database.
<p>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut8.html#DeclSectdevnone">Section 5.2.1</a>
shows the declaration and initialization of the
<tt>NNONE</tt>
constant.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut10.html#SetUpConfigureRelDecl">Section 6.3</a>
shows the use of the
<tt>NNONE</tt>
constant with the
<tt>numunit</tt>
field in the
<tt>none_attributes</tt>
table.
<a href="#co_id_52_rtn_5">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_52_6"></a>
Registers the interrupt handlers by setting up the
<tt>ihandler_t</tt>
structure.
This line specifies the bus that this controller is attached to.
The
<tt>bus_hd</tt>
member of the
<tt>controller</tt>
structure contains a pointer to the
<tt>bus</tt>
structure that this controller is connected to.
After the initialization,
the
<tt>ih_bus</tt>
member of the
<tt>ihandler_t</tt>
structure
contains the pointer to the
<tt>bus</tt>
structure associated with the controller for this
<tt>NONE</tt>
device.
<a href="#co_id_52_rtn_6">[Return to example]</a>
<p></p></li><li>
<a name="co_id_52_7"></a>
Sets the
<tt>configuration_st</tt>
member of the
<tt>info</tt>
data structure to the pointer to the
<tt>controller</tt>
structure associated with this
<tt>NONE</tt>
device.
This
<tt>controller</tt>
structure is the one associated with the controller for which an associated
interrupt handler will be written.
<p>
This line also performs a type-casting operation that converts
<tt>ctlr</tt>
(which is of type pointer to a
<tt>controller</tt>
structure)
to be of type
<tt>caddr_t</tt>,
the type of the
<tt>configuration_st</tt>
member.
<a href="#co_id_52_rtn_7">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_52_8"></a>
Sets the
<tt>config_type</tt>
member of the
<tt>info</tt>
data structure to the constant
<tt>CONTROLLER_CONFIG_TYPE</tt>,
which identifies the
<tt>/dev/none</tt>
driver type as a controller (hardware) driver.
<a href="#co_id_52_rtn_8">[Return to example]</a>
<p></p></li><li>
<a name="co_id_52_9"></a>
Sets the
<tt>intr</tt>
member of the
<tt>info</tt>
data structure
to
<tt>noneintr</tt>,
the
<tt>/dev/none</tt>
device driver's interrupt handler.
<a href="#co_id_52_rtn_9">[Return to example]</a>
<p></p></li><li>
<a name="co_id_52_10"></a>
Sets the
<tt>param</tt>
member of the
<tt>info</tt>
data structure to the controller number for the
<tt>controller</tt>
structure associated with this
<tt>NONE</tt>
device.
<p>
This line also performs a type-casting operation that converts
<tt><var>unit</var></tt>
(which is of type
<tt>int</tt>)
to be of type
<tt>caddr_t</tt>,
the type of the
<tt>param</tt>
member.
<a href="#co_id_52_rtn_10">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_52_11"></a>
Sets the
<tt>ih_bus_info</tt>
member of the
<tt>handler</tt>
data structure to the address of the bus-specific information structure,
<tt>info</tt>.
<p>
This line also performs a type-casting operation that converts
<tt>info</tt>
(which is of type
<tt>ihandler_t</tt>)
to be of type
<tt>char *</tt>,
the type of the
<tt>ih_bus_info</tt>
member.
<a href="#co_id_52_rtn_11">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_52_12"></a>
Calls the
<tt>handler_add</tt>
interface and saves its return value for use later by the
<tt>handler_del</tt>
interface.
The
<tt>handler_add</tt>
interface registers a device driver's interrupt handler
and its associated
<tt>ihandler_t</tt>
data structure to the bus-specific interrupt-dispatching algorithm.
<p>
The
<tt>handler_add</tt>
interface takes one argument: a pointer to an
<tt>ihandler_t</tt>
data structure, which in the example is the initialized
structure called
<tt>handler</tt>.
</p><p>
This interface returns an opaque
<tt>ihandler_id_t</tt>
key, which is a unique number used to identify the interrupt handler
to be acted on by subsequent calls to
<tt>handler_del</tt>,
<tt>handler_disable</tt>,
and
<tt>handler_enable</tt>.
Note that this key is stored in the
<tt><var>none_id_t</var></tt>
array, which is discussed in
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut8.html#DeclSect">Section 5.2</a>.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut11.html#DeregisterISIswithhandlerRtns">Section 7.3.3</a>
shows how to call
<tt>handler_del</tt>
and
<tt>handler_disable</tt>.
<a href="#co_id_52_rtn_12">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_52_13"></a>
If the return value from
<tt>handler_add</tt>
equals NULL, returns a failure status to indicate that there are no
interrupt
handlers for the
<tt>/dev/none</tt>
driver.
<a href="#co_id_52_rtn_13">[Return to example]</a>
<p></p></li><li>
<a name="co_id_52_14"></a>
If the
<tt>handler_enable</tt>
interface returns a nonzero value, returns the value zero (0) to
indicate
that it could not enable a previously registered interrupt handler.
If the call to
<tt>handler_enable</tt>
succeeded, it marks that interrupts are enabled and can be dispatched to
the driver's interrupt handlers, as registered in a previous call to
<tt>handler_add</tt>.
<p>
The
<tt>handler_enable</tt>
interface takes one argument:
a pointer to the interrupt handler's entry in the interrupt table.
In this example, this ID is contained in the
<tt><var>none_id_t</var></tt>
array.
</p><p>
If the call to
<tt>handler_enable</tt>
failed, removes the previously registered interrupt handler by calling
<tt>handler_del</tt>
prior to returning an error status.
The
<tt>handler_del</tt>
interface deregisters a device driver's interrupt handler
from the bus-specific interrupt-dispatching algorithm.
</p><p>
The
<tt>handler_del</tt>
interface takes one argument:
a pointer to the interrupt handler's entry in the interrupt table.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -