📄 supp static n dynamic config.htm
字号:
The following list describes how to interpret the elements in the
array:
<ul>
<p></p><li>
name
<p>
This element is the ASCII name of the attribute, for example,
<tt>Module_Config_Name</tt>,
<tt>Module_Type</tt>,
<tt>majnum</tt>,
<tt>dsflags</tt>,
and so forth.
</p><p></p></li><li>
type
<p>
This element is the data type associated with the name attribute, for
example,
<tt>CFG_ATTR_STRTYPE</tt>
and
<tt>CFG_ATTR_INTTYPE</tt>.
</p><p></p></li><li>
operation
<p>
This element is the operation or operations the
<tt>cfgmgr</tt>
framework can perform on the attribute, for
example,
<tt>CFG_OP_CONFIGURE</tt>
(configure)
and
<tt>CFG_OP_QUERY</tt>
(query), and so forth.
</p><p></p></li><li>
address
<p>
This element is the address of the data value associated with the name
attribute.
For example,
<tt><var>mcfgname</var></tt>
is the data value associated with the
<tt>Module_Config_Name</tt>
attribute.
</p><p></p></li><li>
minimum value
<p>
If the data type for the attribute is a string, this element is the
minimum length of the string value.
For example, the minimum length of the
<tt><var>mcfgname</var></tt>
data value is 2.
If the data type for the attribute is numeric, this element is the
minimum range of the numeric value.
For example, the minimum range of the
<tt><var>none_developer_debug</var></tt>
data value is zero (0).
</p><p></p></li><li>
maximum value
<p>
If the data type for the attribute is a string, this element is the
maximum length of the string value.
For example, the maximum length of the
<tt><var>mcfgname</var></tt>
data value is
<tt>CFG_ATTR_NAME_SZ</tt>.
If the data type for the attribute is numeric, this element is the
maximum range of the numeric value.
For example, the maximum range of the
<tt><var>none_developer_debug</var></tt>
data value is the value 1.
</p><p></p></li><li>
binary value size
<p>
This element is the binary data size.
For example, the binary data size for the
<tt><var>mcfgname</var></tt>
data value is
zero (0).
</p><p>
See
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut19.html#tblstanzaFieldsStaticDrv">Table 14-1</a>
for a description of the
<tt>Module_Config_Name</tt>,
<tt>Module_Type</tt>,
<tt>Device_Char_Major</tt>,
<tt>CMA_Option</tt>.
and
<tt>TC_Option</tt>
attribute fields.
</p></li></ul><p>
<a href="#co_id_33_rtn_9">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_33_10"></a>
Sets the array to device driver-related attribute fields that the
<tt>/dev/none</tt>
driver does not use.
The reason for setting unused attribute fields in the driver's
<tt>cfg_subsys_attr_t</tt>
array is to prevent the
<tt>cfgmgr</tt>
framework from printing error messages on the console terminal when the
driver is configured into the kernel.
Note that the address of the data value associated with each of these
attributes is
<tt>unused</tt>.
See
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut19.html#tblstanzaFieldsStaticDrv">Table 14-1</a>
for a description of the following attribute fields:
<ul>
<p></p><li>
<tt>Module_Path</tt>
<p></p></li><li>
<tt>Device_Subdir</tt>,
<tt>Device_Block_Subdir</tt>,
<tt>Device_Char_Subdir</tt>
<p></p></li><li>
<tt>Device_Major_Req</tt>,
<tt>Device_Block_Major</tt>,
<tt>Device_Block_Minor</tt>,
<tt>Device_Block_Files</tt>
<p></p></li><li>
<tt>Device_Char_Major</tt>,
<tt>Device_Char_Minor</tt>,
<tt>Device_Char_Files</tt>
<p></p></li><li>
<tt>Device_User</tt>,
<tt>Device_Group</tt>,
<tt>Device_Mode</tt>
<p></p></li><li>
<tt>EISA_Option</tt>,
<tt>ISA_Option</tt>,
<tt>PCI_Option</tt>
</li></ul><p>
<a href="#co_id_33_rtn_10">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_33_11"></a>
Sets the array to an attribute field used to produce runtime messages.
The
<tt>None_Developer_Debug</tt>
attribute is used with the
<tt>printf</tt>
interface to display runtime messages on the console terminal.
A device driver writer might want to define such an attribute to
collect detailed information relating to a driver problem.
When the attribute is set to 1 by the
<tt>cfgmgr</tt>
framework (through the
<tt>CFG_OP_RECONFIGURE</tt>
operation) or initialized in the boot path with any values defined in
the
<tt>/etc/sysconfigtab</tt>
database,
these messages appear on the console terminal.
This would occur if the driver writer set to the value 1 the
<tt>None_Developer_Debug</tt>
attribute in the
<tt>/etc/sysconfigtab</tt>
database.
These messages can provide the driver writer with configuration information
that relates to detailed bus configuration information.
<p>
The
<tt>None_Developer_Debug</tt>
attribute (or another attribute similar to it) is used for detailed
internal debugging of code by Digital personnel or someone who has a
source license.
</p><p>
Note that the
<tt>None_Developer_Debug</tt>
attribute's operations are query, reconfigure, and configure.
<a href="#co_id_33_rtn_11">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_33_12"></a>
Ends the array by specifying the null string.
<a href="#co_id_33_rtn_12">[Return to example]</a>
</li></ol><p>
</p><p>
As shown in
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut10.html#figFillinAttrsfordevnone">Figure 6-1</a>,
the
<tt>cfgmgr</tt>
framework fills in the attributes designated as
<tt>CFG_OP_CONFIGURE</tt>
specified in the
<tt>none_attributes</tt>
structure array.
As the figure shows, the
<tt>cfgmgr</tt>
framework:
</p><ol>
<p></p><li>
Gets the entries for the
<tt>/dev/none</tt>
driver from the
<tt>/etc/sysconfigtab</tt>
database by locating the
<tt>none</tt>:
entry.
<p>
The driver writers at EasyDriver Incorporated create a
<tt>sysconfigtab</tt>
file fragment for the
<tt>/dev/none</tt>
driver.
The
<tt>sysconfigdb</tt>
utility appends this
<tt>sysconfigtab</tt>
file fragment to the
<tt>/etc/sysconfigtab</tt>
database.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut18.html#ThesysconfigtabFileFragment">Section 13.4</a>
describes the
<tt>sysconfigtab</tt>
file fragment.
</p><p></p></li><li>
Fills in the
<tt><var>mcfgname</var></tt>
and
<tt><var>devmajor</var></tt>
data values with the associated values in the
<tt>/etc/sysconfigtab</tt>
database.
</li></ol><p>
</p><p>
To determine if
<tt>cfgmgr</tt>
initialized attributes correctly,
the
<tt>/dev/none</tt>
driver verifies each from the
<tt>cfg_attr_t</tt>
structure that
<tt>cfgmgr</tt>
passes into the
<tt>none_configure</tt>
interface's
<tt><var>indata</var></tt>
argument.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut10.html#Parsingthecfg_attr_tArray">Section 6.6.1</a>
shows how to parse the
<tt>cfg_attr_t</tt>
structure to check attributes.
</p><p>
<a name="figFillinAttrsfordevnone"></a>
</p><h3>Figure 6-1: The cfgmgr Framework Filling in Attributes for the /dev/none Driver</h3>
<p><img src="supp%20static%20n%20dynamic%20config_files/zk-1137U.gif"></p><p>
<a name="DefBusSpecNameConstinConfigure"></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%20static%20n%20dynamic%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%20static%20n%20dynamic%20config_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ImplConfigureRtn"><img src="supp%20static%20n%20dynamic%20config_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#SetUpConfigureRelDecl"><img src="supp%20static%20n%20dynamic%20config_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#SetUpConfigureRtn"><img src="supp%20static%20n%20dynamic%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/drivertut11.html"><img src="supp%20static%20n%20dynamic%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%20static%20n%20dynamic%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%20static%20n%20dynamic%20config_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h2>
6.4 Defining Bus-Specific Name Constants
</h2>
<p>
<a name="nx_id_304"></a>
<a name="nx_id_305"></a>
To write portable device drivers across multiple bus
architectures, you need to know that the
<tt>configure_driver</tt>
and
<tt>unconfigure_driver</tt>
interfaces take as an argument the bus name.
You define the bus names for the buses you want the driver to operate on
as constants that you pass to the previously listed interfaces.
The following code shows how the
<tt>/dev/none</tt>
driver defines the bus name:
</p><p>
</p><p>
</p><pre>#define DN_BUSNAME1 "DRIVER_WILDNAME <a name="co_id_34_rtn_1"></a><a href="#co_id_34_1"><strong>[1]</strong></a>
<p>
</p></pre>
<p>
</p><p>
</p><ol>
<p></p><li>
<a name="co_id_34_1"></a>
Defines a constant called
<tt>DN_BUSNAME1</tt>
that represents the name of the bus on which the driver operates.
You pass this constant to the
<tt>configure_driver</tt>
and
<tt>unconfigure_driver</tt>
interfaces.
Your goal should be to write one device driver that can operate on
multiple buses.
One way to handle multiple buses is to define the constant as a
wildcard.
One way to specify a wildcard is to use the
<tt>DRIVER_WILDNAME</tt>
constant, which signifies a wildcard character to the
<tt>configure_driver</tt>
and
<tt>unconfigure_driver</tt>
interfaces.
In other words, the wildcard character tells the
<tt>configure_driver</tt>
and
<tt>unconfigure_driver</tt>
interfaces that the driver can operate on any of the Digital-supported
buses.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut10.html#DetermineConfigState">Section 6.6.3</a>
shows how to call
<tt>configure_driver</tt>
and
<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 how to call the
<tt>unconfigure_driver</tt>
interfaces.
<p>
For VMEbus device drivers, you must specify
<tt>vba</tt>
as the definition for the bus name constant.
For example:
</p><p>
<tt>#define DN_BUSNAME1 vba</tt>
</p><p>
This is the only way the VMEbus autoconfiguration code determines that
the
<tt>controller</tt>
structure is associated with the VMEbus.
<a href="#co_id_34_rtn_1">[Return to example]</a>
</p></li></ol><p>
<a name="SetUpConfigureRtn"></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%20static%20n%20dynamic%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%20static%20n%20dynamic%20config_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#ImplConfigureRtn"><img src="supp%20static%20n%20dynamic%20config_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#DefBusSpecNameConstinConfigure"><img src="supp%20static%20n%20dynamic%20config_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#ImplCFG_OP_CONFIGURE"><img src="supp%20static%20n%20dynamic%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/drivertut11.html"><img src="supp%20static%20n%20dynamic%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%20static%20n%20dynamic%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%20static%20n%20dynamic%20config_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h2>
6.5 Setting Up the Configure Interface
</h2>
<p>
<a name="nx_id_306"></a>
A device driver's
<tt>configure</tt>
interface is called indirectly by the
<tt>cfgmgr</tt>
framework.
The
<tt>cfgmgr</tt>
framework is responsible for calling all single binary modules for
registration and integration into the kernel.
The
<tt>cfgmgr</tt>
framework requires that a single binary module has both an attributes
table and a
<tt>configure</tt>
interface before it (the single binary module) can be registered as part
of the
<tt>cfgmgr</tt>
framework and the Digital UNIX kernel.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut10.html#SetUpConfigureRelDecl">Section 6.3</a>
shows how to set up the attributes table.
</p><p>
The following code shows you how to set up a
<tt>configure</tt>
interface, using the
<tt>/dev/none</tt>
device driver as an example:
</p><p>
</p><p>
</p><pre><p>
</p><p>
none_configure(op, indata, indatalen, outdata, outdatalen)
cfg_op_t op; <a name="co_id_35_rtn_1"></a><a href="#co_id_35_1"><strong>[1]</strong></a>
cfg_attr_t *indata; <a name="co_id_35_rtn_2"></a><a href="#co_id_35_2"><strong>[2]</strong></a>
size_t indatalen; <a name="co_id_35_rtn_3"></a><a href="#co_id_35_3"><strong>[3]</strong></a>
cfg_attr_t *outdata; <a name="co_id_35_rtn_4"></a><a href="#co_id_35_4"><strong>[4]</strong></a>
size_t outdatalen; <a name="co_id_35_rtn_5"></a><a href="#co_id_35_5"><strong>[5]</strong></a>
{
int retval; <a name="co_id_35_rtn_6"></a><a href="#co_id_35_6"><strong>[6]</strong></a>
int i; <a name="co_id_35_rtn_7"></a><a href="#co_id_35_7"><strong>[7]</strong></a>
int driver_cfg_state; <a name="co_id_35_rtn_8"></a><a href="#co_id_35_8"><strong>[8]</strong></a>
</p><p>
</p><p>
#define MAX_DEVICE_CFG_ENTRIES 18 <a name="co_id_35_rtn_9"></a><a href="#co_id_35_9"><strong>[9]</strong></a>
</p><p>
</p><p>
#define NONE_DEBUG
#ifdef NONE_DEBUG
cfg_attr_t cfg_buf[MAX_DEVICE_CFG_ENTRIES]; <a name="co_id_35_rtn_10"></a><a href="#co_id_35_10"><strong>[10]</strong></a>
#endif /* NONE_DEBUG */
</p><p>
</p></pre>
<p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -