📄 supp static n dynamic config.htm
字号:
<tt>
<tt>CFG_ATTR_ESUBSYS</tt>
</tt>
</td>
<td align="left" valign="top">
The subsystem failed.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>
<tt>CFG_ATTR_ESMALL</tt>
</tt>
</td>
<td align="left" valign="top">
The value or size of the attribute you specified in the
<tt>name</tt>
member is too small.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>
<tt>CFG_ATTR_ELARGE</tt>
</tt>
</td>
<td align="left" valign="top">
The value or size of the attribute you specified in the
<tt>name</tt>
member is too large.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>
<tt>CFG_ATTR_ETYPE</tt>
</tt>
</td>
<td align="left" valign="top">
The data type that you specified for the attribute you specified in the
<tt>name</tt>
member is invalid or is a mismatch.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>
<tt>CFG_ATTR_EINDEX</tt>
</tt>
</td>
<td align="left" valign="top">
The index associated with the attribute that you specified in the
<tt>name</tt>
member is invalid.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>
<tt>CFG_ATTR_EMEM</tt>
</tt>
</td>
<td align="left" valign="top">
The
<tt>cfgmgr</tt>
framework could not allocate memory for the specified attribute.
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>
<tt>CFG_ATTR_ENOTNUMBER</tt>
</tt>
</td>
<td align="left" valign="top">
The attribute that you specified in the
member cannot be converted to a number.
</td>
</tr>
</tbody></table></p><p>
</p><p>
The
<tt>index</tt>
member stores
a value that scopes the target for indexed attributes.
</p><p>
The
<tt>attr</tt>
member specifies
a union of the possible attribute types used for storing values, kernel
locations, validation criteria, and disposal interfaces.
</p><p>
The
<tt>cfgmgr</tt>
framework uses the appropriate union element according to the attribute type.
For example, attributes of type
<tt>CFG_ATTR_ULONGTYPE</tt>
use the union element
<tt>num</tt>.
<a name="SetUpConfigureRelDecl"></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="#cfg_attrStruct"><img src="supp%20static%20n%20dynamic%20config_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#DefBusSpecNameConstinConfigure"><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.3 Setting Up Configure-Related Declarations and the cfg_subsys_attr_t Data Structure
</h2>
<p>
<a name="nx_id_302"></a>
<a name="nx_id_303"></a>
As part of implementing a device driver's
<tt>configure</tt>
interface you declare a number of variables and
initialize the
<tt>cfg_subsys_attr_t</tt>
data structure.
The following code shows the declaration of some typical variables and
the initialization of the
<tt>cfg_subsys_attr_t</tt>
structure for a
<tt>configure</tt>
interface, using the
<tt>/dev/none</tt>
device driver as an example.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut10.html#cfg_subsys_attr_tStruct">Section 6.1</a>
describes the members of the
<tt>cfg_subsys_attr_t</tt>
structure.
</p><p>
</p><p>
</p><pre>static int majnum = NO_DEV; <a name="co_id_33_rtn_1"></a><a href="#co_id_33_1"><strong>[1]</strong></a>
static int noneversion = 0; <a name="co_id_33_rtn_2"></a><a href="#co_id_33_2"><strong>[2]</strong></a>
static int none_developer_debug = 0; <a name="co_id_33_rtn_3"></a><a href="#co_id_33_3"><strong>[3]</strong></a>
static unsigned char mcfgname[CFG_ATTR_NAME_SZ] = ; <a name="co_id_33_rtn_4"></a><a href="#co_id_33_4"><strong>[4]</strong></a>
static unsigned char unused[300] = ; <a name="co_id_33_rtn_5"></a><a href="#co_id_33_5"><strong>[5]</strong></a>
static unsigned char cma_dd[120] = ; <a name="co_id_33_rtn_6"></a><a href="#co_id_33_6"><strong>[6]</strong></a>
static unsigned char tc_optiondata[300] = ; <a name="co_id_33_rtn_7"></a><a href="#co_id_33_7"><strong>[7]</strong></a>
cfg_subsys_attr_t none_attributes[] = { <a name="co_id_33_rtn_8"></a><a href="#co_id_33_8"><strong>[8]</strong></a>
{"Module_Config_Name", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE, <a name="co_id_33_rtn_9"></a><a href="#co_id_33_9"><strong>[9]</strong></a>
(caddr_t)mcfgname,2,CFG_ATTR_NAME_SZ,0},
{"CMA_Option", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)cma_dd,0,300,0},
{"numunit", CFG_ATTR_INTTYPE, CFG_OP_QUERY | CFG_OP_CONFIGURE,
(caddr_t)&NNONE,0,MAX_NNONE,0},
{"TC_Option", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)&tc_optiondata,0,300,0},
{"Module_Path", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"Device_Subdir", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"Device_Block_Subdir", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"Device_Char_Subdir", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"Device_Major_Req", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"Device_Block_Major", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"Device_Block_Minor", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"Device_Block_Files", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"Device_Char_Major", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"Device_Char_Minor", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"Device_Char_Files", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"Device_User", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"Device_Group", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"Device_Mode", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"EISA_Option", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"ISA_Option", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"VBA_Option", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0},
{"PCI_Option", CFG_ATTR_STRTYPE, CFG_OP_CONFIGURE,
(caddr_t)unused,0,300,0}, <a name="co_id_33_rtn_10"></a><a href="#co_id_33_10"><strong>[10]</strong></a>
{"majnum", CFG_ATTR_INTTYPE, CFG_OP_QUERY,
(caddr_t)&majnum,0,512,0},
{"version", CFG_ATTR_INTTYPE, CFG_OP_QUERY,
(caddr_t)&noneversion,0,9999999,0},
{"None_Developer_Debug", CFG_ATTR_INTTYPE, CFG_OP_QUERY |
CFG_OP_RECONFIGURE |
CFG_OP_CONFIGURE,
(caddr_t)&none_developer_debug,0,1,0}, <a name="co_id_33_rtn_11"></a><a href="#co_id_33_11"><strong>[11]</strong></a>
{,0,0,0,0,0,0} <a name="co_id_33_rtn_12"></a><a href="#co_id_33_12"><strong>[12]</strong></a>
};
</pre>
<p>
</p><p>
</p><ol>
<p></p><li>
<a name="co_id_33_1"></a>
Declares and initializes to the constant
<tt>NO_DEV</tt>
an integer variable called
<tt><var>majnum</var></tt>.
This variable is used to initialize the data value associated with the
<tt>majnum</tt>
attribute in the
<tt>none_attributes</tt>
table.
(The data value is the
<tt>addr</tt>
member of a
<tt>cfg_subsys_attr_t</tt>
structure.
Each element in the table is a
<tt>cfg_subsys_attr_t</tt>
structure.)
Because the
<tt>majnum</tt>
attribute's operation is
<tt>CFG_OP_QUERY</tt>,
the
<tt>cfgmgr</tt>
framework queries the value during a query operation.
This means the driver writer passed
<tt>CFG_OP_QUERY</tt>
to the
<tt><var>optype</var></tt>
argument of the driver's
<tt>configure</tt>
interface.
<a href="#co_id_33_rtn_1">[Return to example]</a>
<p></p></li><li>
<a name="co_id_33_2"></a>
Declares and initializes to the value zero (0) an integer variable
called
<tt><var>noneversion</var></tt>.
This variable is used to initialize the data value associated with the
<tt>version</tt>
attribute in the
<tt>none_attributes</tt>
table.
Because the
<tt>version</tt>
attribute's operation is
<tt>CFG_OP_QUERY</tt>,
the
<tt>cfgmgr</tt>
framework queries the value during a query operation.
This means the driver writer passed
<tt>CFG_OP_QUERY</tt>
to the
<tt><var>optype</var></tt>
argument of the driver's
<tt>configure</tt>
interface.
<a href="#co_id_33_rtn_2">[Return to example]</a>
<p></p></li><li>
<a name="co_id_33_3"></a>
Declares and initializes to the value zero (0) an integer variable called
<tt><var>none_developer_debug</var></tt>.
This variable is used to initialize the data value associated with the
<tt>None_Developer_Debug</tt>
attribute in the
<tt>none_attributes</tt>
table.
For this attribute, the possible operations are
<tt>CFG_OP_QUERY</tt>,
<tt>CFG_OP_RECONFIGURE</tt>,
or
<tt>CFG_OP_CONFIGURE</tt>.
The
<tt>CFG_OP_QUERY</tt>
operation indicates that the
<tt>cfgmgr</tt>
framework queries the value during a query operation.
This means the driver writer passed
<tt>CFG_OP_QUERY</tt>
to the
<tt><var>optype</var></tt>
argument of the driver's
<tt>configure</tt>
interface.
<p>
The
<tt>CFG_OP_RECONFIGURE</tt>
operation indicates that the
<tt>cfgmgr</tt>
framework reconfigures the value during a reconfigure operation.
This functionality allows a user to modify the attribute.
This means the driver writer passed
<tt>CFG_OP_RECONFIGURE</tt>
to the
<tt><var>optype</var></tt>
argument of the driver's
<tt>configure</tt>
interface.
</p><p>
The
<tt>CFG_OP_CONFIGURE</tt>
operation indicates that the
<tt>cfgmgr</tt>
framework obtains a data value for the attribute from the
<tt>/etc/sysconfigtab</tt>
database during a configure operation.
This means the driver writer passed
<tt>CFG_OP_CONFIGURE</tt>
to the
<tt><var>optype</var></tt>
argument of the driver's
<tt>configure</tt>
interface.
<a href="#co_id_33_rtn_3">[Return to example]</a>
</p><p></p></li><li>
<a name="co_id_33_4"></a>
Declares and initializes to the null string a character variable called
<tt><var>mcfgname</var></tt>.
The
<tt><var>mcfgname</var></tt>
variable is the address where the
<tt>cfgmgr</tt>
framework stores the driver name for the
<tt>Module_Config_Name</tt>
attribute.
<a href="#co_id_33_rtn_4">[Return to example]</a>
<p></p></li><li>
<a name="co_id_33_5"></a>
Declares and initializes to the null string a character variable called
<tt><var>unused</var></tt>.
The
<tt><var>unused</var></tt>
variable is the address where the
<tt>cfgmgr</tt>
framework stores the value for the attributes that the
<tt>/dev/none</tt>
driver does not use.
<a href="#co_id_33_rtn_5">[Return to example]</a>
<p></p></li><li>
<a name="co_id_33_6"></a>
Declares and initializes to the null string a character variable
called
<tt><var>cma_dd</var></tt>.
The
<tt><var>cma_dd</var></tt>
variable is the address where the
<tt>cfgmgr</tt>
framework stores the value for the
<tt>CMA_Option</tt>
attribute.
The
<tt>cfgmgr</tt>
framework obtains this value from the
<tt>/etc/sysconfigtab</tt>
database.
<a href="#co_id_33_rtn_6">[Return to example]</a>
<p></p></li><li>
<a name="co_id_33_7"></a>
Declares and initializes to the null string a character variable
called
<tt><var>tc_optiondata</var></tt>.
The
<tt><var>tc_optiondata</var></tt>
variable is the address where the
<tt>cfgmgr</tt>
framework stores the value for the
<tt>TC_Option</tt>
attribute.
The
<tt>cfgmgr</tt>
framework obtains this value from the
<tt>/etc/sysconfigtab</tt>
database.
<a href="#co_id_33_rtn_7">[Return to example]</a>
<p></p></li><li>
<a name="co_id_33_8"></a>
Declares an array of
<tt>cfg_subsys_attr_t</tt>
structures and calls it
<tt>none_attributes</tt>.
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut10.html#cfg_subsys_attr_tStruct">Section 6.1</a>
describes the members of the
<tt>cfg_subsys_attr_t</tt>
structure.
<a href="#co_id_33_rtn_8">[Return to example]</a>
<p></p></li><li>
<a name="co_id_33_9"></a>
Sets the array to the attribute fields associated with the
<tt>/dev/none</tt>
driver.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -