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

📄 ds sw.htm

📁 What is this ``device driver stuff anyway? Here s a very short introduction to the concept.
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<html><head><title>Data Structures That the Autoconfiguration Software Uses</title>

<meta name="ROBOTS" content="NOFOLLOW">
<meta name="DESCRIPTION" content="Writing Device Drivers Tutorial: DIGITAL UNIX Version 4.0B documentation set">
<meta name="AUTHOR" content="Copyright (c) Digital Equipment Corporation 1996. All Rights Reserved."></head>
<body>
<a name="DeviceAutoconfig"></a>
<p></p><hr><p align="center">
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><img src="DS%20sw_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="DS%20sw_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut23.html"><img src="DS%20sw_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<img src="DS%20sw_files/BLANK.GIF" border="0">
<a href="#BusStruct"><img src="DS%20sw_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/drivertut25.html"><img src="DS%20sw_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="DS%20sw_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="DS%20sw_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h1>17&nbsp;&nbsp;&nbsp;&nbsp;Data Structures That the Autoconfiguration Software Uses</h1>
<p>
<a name="nx_id_703"></a>
Autoconfiguration is a process that determines what hardware actually
exists during the current instance of the running kernel at static
configuration time.
<a name="nx_id_704"></a>
The autoconfiguration software creates
a configuration tree that represents the current system configuration.
In creating this configuration tree, the autoconfiguration software uses
the following data structures:
</p><ul>
<p></p><li>
<tt>bus</tt>
<p></p></li><li>
<tt>controller</tt>
<p></p></li><li>
<tt>device</tt>
<p></p></li><li>
<tt>driver</tt>
<p></p></li><li>
<tt>port</tt>
</li></ul><p>
The following sections describe each of these data structures except the
<tt>driver</tt>
structure.
<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.
<a name="BusStruct"></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="DS%20sw_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="DS%20sw_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#DeviceAutoconfig"><img src="DS%20sw_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<img src="DS%20sw_files/BLANK.GIF" border="0">
<a href="#busmbox"><img src="DS%20sw_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/drivertut25.html"><img src="DS%20sw_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="DS%20sw_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="DS%20sw_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h2>
17.1&nbsp;&nbsp;&nbsp;&nbsp;The bus Structure
</h2>
<p>
The
<tt>bus</tt>
structure represents an instance of a bus entity.
A bus is a real or imagined entity to which other buses or
controllers are logically attached.
All systems have at least one bus, the system bus, even though the bus
may not actually exist physically.
The term
<em>controller</em>
here refers both to devices that control slave
devices (for example, disk or tape controllers) and to devices that
stand alone (for example, terminal or network controllers).
Bus adapter driver writers create
<tt>bus</tt>
structures by calling the
<tt>create_bus_struct</tt>
interface and passing to it a filled-in
<tt>bus_config</tt>
structure.
The discussion of how to use the
<tt>create_bus_struct</tt>
interface and how to fill in the
<tt>bus_config</tt>
structure is beyond the scope of this book.
However, the descriptions of the
<tt>bus</tt>
structure are presented here.
</p><p>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut24.html#TblBusStructMembers">Table 17-1</a>
lists the members of the
<tt>bus</tt>
structure along with their associated data types.
</p><p>
<a name="TblBusStructMembers"></a>
</p><h3>
Table 17-1: Members of the bus Structure
</h3>
<a name="nx_id_705"></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>bus_mbox</tt>
</td>
<td align="left" valign="top">
<tt>u_long *</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>bus_hd</tt>
</td>
<td align="left" valign="top">
<tt>struct bus *</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>nxt_bus</tt>
</td>
<td align="left" valign="top">
<tt>struct bus *</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>ctlr_list</tt>
</td>
<td align="left" valign="top">
<tt>struct controller *</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>bus_list</tt>
</td>
<td align="left" valign="top">
<tt>struct bus *</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>bus_type</tt>
</td>
<td align="left" valign="top">
<tt>int</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>bus_name</tt>
</td>
<td align="left" valign="top">
<tt>char *</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>bus_num</tt>
</td>
<td align="left" valign="top">
<tt>int</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>slot</tt>
</td>
<td align="left" valign="top">
<tt>int</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>connect_bus</tt>
</td>
<td align="left" valign="top">
<tt>char *</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>connect_num</tt>
</td>
<td align="left" valign="top">
<tt>int</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>confl1</tt>
</td>
<td align="left" valign="top">
<tt>int (*confl1)()</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>confl2</tt>
</td>
<td align="left" valign="top">
<tt>int (*confl2)()</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>pname</tt>
</td>
<td align="left" valign="top">
<tt>char *</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>port</tt>
</td>
<td align="left" valign="top">
<tt>struct port *</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>alive</tt>
</td>
<td align="left" valign="top">
<tt>int</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>framework</tt>
</td>
<td align="left" valign="top">
<tt>struct bus_framework *</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>driver_name</tt>
</td>
<td align="left" valign="top">
<tt>char *</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>bus_bridge_dma</tt>
</td>
<td align="left" valign="top">
<tt>void *</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>private</tt>
</td>
<td align="left" valign="top">
<tt>void * [8]</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>conn_priv</tt>
</td>
<td align="left" valign="top">
<tt>void * [8]</tt>
</td>
</tr>
<tr>
<td align="left" valign="top">
<tt>rsvd</tt>
</td>
<td align="left" valign="top">
<tt>void * [7]</tt>
</td>
</tr>
</tbody></table><p>
</p><p>
The following sections discuss all of these members.
<a name="busmbox"></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="DS%20sw_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="DS%20sw_files/TOC.GIF" alt="[Contents]" border="0"></a>
<a href="#DeviceAutoconfig"><img src="DS%20sw_files/REW.GIF" alt="[Previous Chapter]" border="0"></a>
<a href="#BusStruct"><img src="DS%20sw_files/PREV.GIF" alt="[Previous Section]" border="0"></a>
<a href="#busbus_hdetal"><img src="DS%20sw_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/drivertut25.html"><img src="DS%20sw_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="DS%20sw_files/INDEX.GIF" alt="[Index]" border="0"></a>
<a href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><img src="DS%20sw_files/HELP.GIF" alt="[Help]" border="0"></a>
</p><p></p><hr><p>
</p><h3>
17.1.1&nbsp;&nbsp;&nbsp;&nbsp;The bus_mbox Member
</h3>
<p>
The
<tt>bus_mbox</tt>
member specifies
a pointer to the mailbox data structure for hardware platforms that
access I/O space through hardware mailboxes.
The bus adapter code sets this member.
As the adapter code probes the buses, the first bus that has a mailbox
allocates the initial software mailbox data structure and sets its
<tt>bus_mbox</tt>
pointer to that data structure.
As the adapter code continues to probe for buses and controllers,
the
<tt>MBOX_GET</tt>
macro allocates the
<tt>ctlr_mbox</tt>
members for devices accessed by mailboxes.
Typically, this macro is called in the controller configuration
interface after the
<tt>controller</tt>
data structure has been found, but before probing the controller.
The following code fragment gives an idea of the tasks that occur prior
to calling the
<tt>MBOX_GET</tt>
macro:
</p><p>
</p><p>
</p><pre>config_con(name, node, bus)
{
   register struct controller *ctlr;

   if((ctlr = get_ctlr(name, node, bus-&gt;bus_name, bus-&gt;bus_num)) ||
          /* other wildcards here */
      (ctlr = get_ctlr(name, -1, "*", -99))) {
<br>.<br>.<br>.<br>
       }

/***************************************************
 * Found the controller                            *
 ***************************************************/

           int savebusnum;
           char *savebusname;
           int saveslot;

⌨️ 快捷键说明

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