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

📄 c-bkend2.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title>    Target Server Back End    </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-bkend.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-bkend.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-bkend1.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-bkend3.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="84559">2.2  &nbsp;&nbsp;Back-End Implementation</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84561"> </a>This section discusses several aspects of back-end implementation that are similar for both WDB and non-WDB back ends. </p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84562"> </a>It provides a description of the <b class="symbol_UC">FLAG_DESC </b>data structure and the <b class="routine"><i class="routine">bkendFlagsGet</i></b><b>(&nbsp;)</b> routine which is used to retrieve those flags so they can be sent to the back end.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84563"> </a>It also provides a prototype of the back-end initialization routine, with an explanation of the parameters passed to the back end by the target server and a description of the <b class="symbol_UC">TGT_OPS</b> and <b class="symbol_UC">BKEND_INFO</b> data structures (filled by the initialization routine).</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84564"> </a>This section also covers event notification requirements and methods, as well as issues relating to target-board rebooting.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84565"> </a>In addition, message logging facilities provided for WDB back ends are discussed. These facilities may be of interest to writers of non-WDB back ends as a source of sample target-server target-agent interactions.</li></ul></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84567">2.2.1  &nbsp;&nbsp;Attachment and Initialization</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84569"> </a>A target server can only use one back end at a time. The back end is attached when the target server is started. The <b class="command">-B</b> option specifies which back end to attach. For example, to use the back end named <b class="keyword">wdbserial</b>, select <b class="symbol_lc">wdbserial</b> in the target server initialization window, which invokes the target server with the following command:</p><dl class="margin"><dd><pre class="Code2"><b><a name="84571"></b><tt class="output">%</tt><b> tgtsvr ... -B wdbserial ...</a></b></pre></dl><dd><p class="Body"><a name="84573"> </a>Back ends are linked with the target server dynamically using DLLs. At run time, the target server searches <i class="textVariable">installDir</i><b class="file">/host/</b><i class="textVariable">hostType</i><b class="file">/lib/backend</b>, which contains a DLL for each available back end, and loads the specified back end.<sup><a href="#foot"><b class="FootnoteMarker">1</b></a></sup> The back end can have any name, but we recommend you choose names that are short, lower case, and suggest the connection strategy to which they refer. If the requested back end is not found, the attachment fails and the target server abandons its start-up sequence, exiting with an error condition.</p><dd><p class="Body"><a name="84577"> </a>Once the correct DLL is found, the target server asks if the back end handles special flags with the <b>(&nbsp;)</b>routine. If the back end exports this routine, the target server calls the routine and appends the returned flags array to its own array. When it finishes parsing the command line, the target server calls an initialization routine that attaches the back end. Besides initializing the back end, this routine fills in a table of function pointers (the <b class="symbol_UC">TGT_OPS</b> structure) used by the target server to call the back-end functions and a structure (the <b class="symbol_UC">BKEND_INFO</b> structure) which describes how the back end notifies the target server of asynchronous events. Finally, the initialization routine calls <b class="routine"><i class="routine">bkendTgtConnect</i></b><b>(&nbsp;)</b> to attach the target server to a specified target.</p></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/caution.gif"></td><td><hr><div class="CalloutCell"><a name="89214"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">CAUTION:  </font></b></a>The target server symbol table is not available until you attach the target.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84592">The Flag Parsing Routine</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84594"> </a>A back end can export a flag-parsing routine to handle any back-end specific command line parameters. if the loaded back end exports such a routine, the target server runs the routine to get a list of the parameters the back end needs to access. The parameters are contained in the <b class="symbol_UC">FLAG_DESC</b> structure (defined in <i class="textVariable">installDir</i><b class="file">/host/include/flagutil.h</b>). The target server adds the flags to its own array of recognized flags and parses its entire command line. </p></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/caution.gif"></td><td><hr><div class="CalloutCell"><a name="89224"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">CAUTION:  </font></b></a>The target server overrides its own flag description if a back end defines the same flag. Back ends should use flags that are different from the target server core flags.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout><dl class="margin"><dd><p class="Body"><a name="84606"> </a>The name of the flag-parsing routine is standardized so that the target server can find it. It is composed of the back-end file name (without extension) plus the word <b class="routine"><i class="routine">FlagsGet</i></b>. For our example back end, called <b class="keyword">mybkend</b>, the flag-parsing routine is <b class="routine"><i class="routine">mybkendFlagsGet</i></b><b>(&nbsp;)</b>, which is defined in <b class="file">mybkend.c</b>. </p><dd><p class="Body"><a name="84608"> </a>The back-end flag-parsing routine must match the following prototype:</p><dl class="margin"><dd><pre class="Code2"><b><a name="84609">FLAG_DESC * mybkendFlagsGet (void)</a></b></pre></dl><dd><p class="Body"><a name="88569"> </a>The returned value is a null-terminated <b class="symbol_UC">FLAG_DESC</b> structure array. This structure describes the arguments handled by the back end and is composed of five fields: </p><dl class="margin"><dd><pre class="Code2"><b><a name="88570">typedef struct flag_desc /* target server flag descriptions */     {     char *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flagName,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* verbose flag name */     char *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flagTerseName,&nbsp;&nbsp;&nbsp;&nbsp;/* abbreviated name of flag (or NULL) */     PARSE_RTN&nbsp;&nbsp;parseRoutine;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* flag processing routine */     int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;outputPtr;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* where to store the output result */     char *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flagHelp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* flag help string */     } FLAG_DESC;</a></b></pre></dl><dd><p class="Body"><a name="88571"> </a>When the target server parses its command line, it tries to match the current argument to the <b class="symbol_lc">flagname</b> or <b class="symbol_lc">flagtersename</b> field of each <b class="symbol_UC">FLAG_DESC</b> structure array element. If an element matches the command line argument, the target server executes the <b class="symbol_lc">parseRoutine</b> field of the matching element, giving three arguments: the remaining arguments number, the command line argument vector starting with the argument which caused the call to the routine, and the value stored in the <b class="symbol_lc">outputPtr</b> field. The provided routine interprets as many arguments as necessary, fills the provided location with the parsed value(s), and returns the number of parsed command line arguments. The parsing routine must match the following prototype:</p><dl class="margin"><dd><pre class="Code2"><b><a name="88602">/* flag processing routine definition */  typedef int (*PARSE_RTN) (int argc, char **argv, void * outputPtr)</a></b></pre></dl><dd><p class="Body"><a name="88616"> </a>Store your <b class="routine"><i class="routine">flagInt</i></b><b>(&nbsp;)</b><b class="routine"><i class="routine"> </i></b>routine in the <b class="file">libwpwr</b> shared library and declared it in <i class="textVariable">installDir</i><b class="file">/host/include/flagutil.h</b>.</p></dl><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/caution.gif"></td>

⌨️ 快捷键说明

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