📄 structure of device driver.htm
字号:
This bit represents the driver's software state.
<a href="#co_id_28_rtn_4">[Return to example]</a>
<p></p></li><li>
<a name="co_id_28_5"></a>
Declares the driver interfaces for the
<tt>/dev/none</tt>
driver.
The
<tt>nonecattach</tt>
and
<tt>noneintr</tt>
interfaces
are merely stubs.
These interfaces have no associated code but are declared here to
handle any future development.
<a href="#co_id_28_rtn_5">[Return to example]</a>
<p></p></li><li>
<a name="co_id_28_6"></a>
Declares an array of pointers to
<tt>controller</tt>
structures and calls it
<tt>noneinfo</tt>.
The
<tt>controller</tt>
structure represents an instance of a controller entity, one that
connects logically to a bus.
A controller can control devices that are directly connected or can
perform some other controlling operation, such as a network interface or
terminal controller operation.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut24.html#ControlStruct">Section 17.2</a>
describes the
<tt>controller</tt>
structure.
<p>
The
<tt>MAX_NNONE</tt>
constant is used to represent the maximum number of
<tt>NONE</tt>
controllers.
This number is used to size the array of pointers to
<tt>controller</tt>
structures.
<a href="#co_id_28_rtn_6">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_28_7"></a>
Declares and initializes the
<tt>driver</tt>
structure called
<tt>nonedriver</tt>.
This structure is used to connect the driver entry points and other
information to the Digital UNIX code.
This structure is used primarily during autoconfiguration.
Some members of this structure are not used by the
<tt>/dev/none</tt>
driver.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut8.html#driver_struct">Section 5.3</a>
describes the
<tt>driver</tt>
structure.
<p>
The value zero (0) indicates that the
<tt>/dev/none</tt>
driver does not make use of a specific member of the
<tt>driver</tt>
structure.
The following list describes those members initialized to a
nonzero value by the example driver:
</p><ul>
<p></p><li>
<tt>noneprobe</tt>,
the driver's
<tt>probe</tt>
interface
<p>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut11.html#ImplementTheProbeRtn">Section 7.1</a>
shows how to implement
<tt>noneprobe</tt>.
</p><p></p></li><li>
<tt>nonecattach</tt>,
the driver's
controller
<tt>attach</tt>
interface
<p>
The
<tt>NONE</tt>
device does not need an
<tt>attach</tt>
interface because it does not deal with any real hardware.
However,
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut11.html#SetUpattachRoutineforcontroller">Section 7.2.1</a>
provides a
<tt>nonecattach</tt>
interface stub for future expansion.
</p><p></p></li><li>
<tt>none</tt>,
the device name
<p></p></li><li>
<tt>noneinfo</tt>,
which references the array of pointers to the previously declared
<tt>controller</tt>
structures
<p>
You index this array with the controller number as specified in the
<tt>ctlr_num</tt>
member of the
<tt>controller</tt>
structure.
<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.
</p><p></p></li><li>
<tt>none_ctlr_unattach</tt>,
the driver's controller
<tt>unattach</tt>
interface
<p>
The
<tt>none_ctlr_unattach</tt>
interface removes the
<tt>controller</tt>
structure associated with specific
<tt>NONE</tt>
devices from the list of
<tt>controller</tt>
structures that it handles.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut11.html#SetUpattachRoutineforcontroller">Section 7.2.1</a>
shows how to implement
<tt>none_ctlr_unattach</tt>.
</p></li></ul><p>
<a href="#co_id_28_rtn_7">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_28_8"></a>
Declares an array of
<tt>softc</tt>
structures and calls it
<tt>none_softc</tt>.
Like
<tt>noneinfo</tt>,
the
<tt>none_softc</tt>
structure's size is the value represented by the
<tt>MAX_NNONE</tt>
constant.
The
<tt>softc</tt>
structure is found in many device drivers to allow driver
interfaces to share data.
The
<tt>none_softc</tt>
structure contains the following members:
<ul>
<p></p><li>
<tt>sc_openf</tt>
<p>
Stores a constant value that indicates that the
<tt>NONE</tt>
device is open.
This member is set by the
<tt>noneopen</tt>
and
<tt>noneclose</tt>
interfaces discussed in
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut14.html#DetermDevOpen">Section 10.1.2</a>
and
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut14.html#PerformCloseDevTasks">Section 10.2.2</a>,
respectively.
</p><p></p></li><li>
<tt>sc_count</tt>
<p>
Stores the count of characters.
This member is set by the
<tt>nonewrite</tt>
and
<tt>noneioctl</tt>
interfaces discussed in
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut12.html#CopyDataWriteRoutine">Section 8.2.2</a>
and
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut14.html#ImplementTheioctlRoutine">Section 10.3</a>,
respectively.
</p><p></p></li><li>
<tt>sc_state</tt>
<p>
Stores a constant value that indicates the state the driver is in.
This member is not currently used.
</p></li></ul><p>
<a href="#co_id_28_rtn_8">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_28_9"></a>
Declares a variable called
<tt><var>none_config</var></tt>
to store state flags that indicate whether
the
<tt>/dev/none</tt>
driver is dynamically configured into the kernel.
The
<tt><var>none_config</var></tt>
variable is initialized to the value
<tt>FALSE</tt>.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut10.html#ReserveMajorNumber">Section 6.6.5.2</a>
shows that
<tt>none_configure</tt>
sets
<tt><var>none_config</var></tt>
to the value
<tt>TRUE</tt>
to indicate that the
<tt>/dev/none</tt>
driver has been dynamically configured into the kernel.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut10.html#ImplCFG_OP_UNCONFIGURE">Section 6.7</a>
shows that
<tt>none_configure</tt>
sets
<tt><var>none_config</var></tt>
to the value
<tt>FALSE</tt>
to indicate that the
<tt>/dev/none</tt>
driver has been successfully unconfigured.
<a href="#co_id_28_rtn_9">[Return to example]</a>
<p></p></li><li>
<a name="co_id_28_10"></a>
Declares a variable called
<tt><var>none_devno</var></tt>
to store the major number associated with the
<tt>/dev/none</tt>
driver.
The
<tt><var>none_devno</var></tt>
variable is initialized to the value
<tt>NO_DEV</tt>
to indicate that no major number for the device has been assigned.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut10.html#ReserveMajorNumber">Section 6.6.5.2</a>
shows that
<tt>none_configure</tt>
sets
<tt><var>none_devno</var></tt>
to the major number.
<a href="#co_id_28_rtn_10">[Return to example]</a>
<p></p></li><li>
<a name="co_id_28_11"></a>
Declares a variable called
<tt><var>NNONE</var></tt>
and initializes it to the value 1.
The
<tt><var>NNONE</var></tt>
variable is the data value address for the
<tt>numunit</tt>
attribute field in the
<tt>none_attributes</tt>
table.
This constant represents the maximum number of controllers to create.
<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 declaration and initialization of the
<tt>none_attributes</tt>
table.
<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 that the
<tt>noneprobe</tt>
interface uses this constant to check the number of controllers probed
when the
<tt>/dev/none</tt>
driver is statically or dynamically configured.
It is the number of controllers probed by the
<tt>noneprobe</tt>
interface when the
<tt>/dev/none</tt>
driver is statically or dynamically configured.
<p>
<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 declaration and initialization of the
<tt>none_attributes</tt>
table.
<a href="#co_id_28_rtn_11">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_28_12"></a>
Declares a pointer to an array of IDs used to deregister the
interrupt handlers.
The
<tt>MAX_NNONE</tt>
constant represents the maximum number of
<tt>NONE</tt>
controllers.
This number sizes the array of
IDs.
Thus, there is one
ID
per
<tt>NONE</tt>
device.
<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 how
<tt>noneprobe</tt>
uses the
<tt><var>none_id_t</var></tt>
array.
<a href="#co_id_28_rtn_12">[Return to example]</a>
<p></p></li><li>
<a name="co_id_28_13"></a>
Declares a variable called
<tt><var>none_is_dynamic</var></tt>
and initializes it to the value zero (0).
This variable is used to control any differences in the tasks related to
static and dynamic configuration.
Thus, the
<tt>/dev/none</tt>
driver can be compiled to produce a single binary module (an executable
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -