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

📄 synth-new-host.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
📖 第 1 页 / 共 3 页
字号:
CLASS="LITERAL">eth0</TT>. This is not actually usedinternally, but can be accessed by user-initialization scripts thatprovide some sort of interrupt monitoring facility (typically via the<TTCLASS="LITERAL">interrupt</TT> <AHREF="synth-new-host.html#SYNTH-NEW-HOST-HOOKS">hook</A>). It is possible for asingle device to allocate multiple interrupt vectors, but thesynthetic target supports a maximum of 32 such vectors.    </P><P><BCLASS="COMMAND">synth::interrupt_get_max</B> returns the highestinterrupt vector that has been allocated, or <TTCLASS="LITERAL">0</TT> ifthere have been no calls to<BCLASS="COMMAND">synth::interrupt_allocate</B>.<BCLASS="COMMAND">synth::interrupt_get_devicename</B> returns the stringthat was passed to <BCLASS="COMMAND">synth::interrupt_allocate</B> whenthe vector was allocated.    </P><P><BCLASS="COMMAND">synth::interrupt_raise</B> can be called any time afterinitialization. The argument should be the vector returned by<BCLASS="COMMAND">synth::interrupt_allocate</B> for this device. It willactivate the normal eCos interrupt handling mechanism so, subject tointerrupts being enabled and this particular interrupt not beingmasked out, the appropriate ISR will run.    </P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>At this time it is not possible for a device to allocate a specificinterrupt vector. The order in which interrupt vectors are assigned todevices effectively depends on the order in which the eCos devices getinitialized, and that may change if the eCos application is rebuilt. Afuture extension may allow devices to allocate specific vectors, thusmaking things more deterministic. However that will introduce newproblems, in particular the code will have to start worrying aboutrequests for vectors that have already been allocated.    </P></BLOCKQUOTE></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="SYNTH-NEW-HOST-ARGS"></A><H2>Flags and Command Line Arguments</H2><P>The generic I/O auxiliary code will process the standard command linearguments, and will set various flag variables accordingly. Some ofthese should be checked by device-specific scripts.    </P><P></P><DIVCLASS="VARIABLELIST"><DL><DT><TTCLASS="VARNAME">synth::flag_gui</TT></DT><DD><P>This is set when the I/O auxiliary is operating in graphical moderather than text mode. Some functionality such as filters and the GUIlayout are only available in graphical mode.        </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    if { $synth::flag_gui } {        &#8230;    }</PRE></TD></TR></TABLE></DD><DT><TTCLASS="VARNAME">synth::flag_verbose</TT></DT><DD><P>The user has requested additional information during startup. Eachdevice driver can decide how much additional information, if any,should be produced.         </P></DD><DT><TTCLASS="VARNAME">synth::flag_keep_going</TT></DT><DD><P>The user has specified <TTCLASS="OPTION">-k</TT> or<TTCLASS="OPTION">--keep-going</TT>, so even if an error occurs the I/Oauxiliary and the various device driver scripts should continue runningif at all possible. Diagnostics should still be generated.        </P></DD></DL></DIV><P>Some scripts may want to support additional command line arguments.This facility should be used with care since there is no way toprevent two different scripts from trying to use the same argument.The following Tcl procedures are available:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">synth::argv_defined &lt;name&gt;synth::argv_get_value &lt;name&gt;</PRE></TD></TR></TABLE><P><BCLASS="COMMAND">synth::argv_defined</B> returns a boolean to indicatewhether or not a particular argument is present. If the argument isthe name part of a name/value pair, an <TTCLASS="LITERAL">=</TT> charactershould be appended. Typical uses might be:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    if { [synth::argv_defined "-o13"] } {        &#8230;    }    if { [synth::argv_defined "-mark="] } {        &#8230;    }</PRE></TD></TR></TABLE><P>The first call checks for a flag <TTCLASS="LITERAL">-o13</TT> or<TTCLASS="LITERAL">--o13</TT> - the code treats options with single anddouble hyphens interchangeably. The second call checks for an argumentof the form <TTCLASS="LITERAL">-mark=&lt;value&gt;</TT> or a pair ofarguments <TTCLASS="LITERAL">-mark &lt;value&gt;</TT>. The value part of aname/value pair can be obtained using<BCLASS="COMMAND">synth::argv_get_value</B>;    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    variable speed 1    if { [synth::argv_defined "-mark="] } {        set mark [synth::argv_get_value "-mark="]        if { ![string is integer $mark] || ($mark &#60; 1) || ($mark &#62; 9) } {            &lt;issue diagnostic&gt;        } else {            set speed $mark        }    }</PRE></TD></TR></TABLE><P><BCLASS="COMMAND">synth::argv_get_value</B> should only be used after asuccessful call to <BCLASS="COMMAND">synth::argv_defined</B>.At present there is no support for some advanced forms of command lineargument processing. For example it is not possible to repeat acertain option such as <TTCLASS="OPTION">-v</TT> or<TTCLASS="OPTION">--verbose</TT>, with each occurrence increasing the levelof verbosity.     </P><P>If a script is going to have its own set of command-line argumentsthen it should give appropriate details if the user specifies<TTCLASS="OPTION">--help</TT>. This involves a hook function:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">namespace eval my_device {    proc help_hook { } {        puts " -o13          : activate the omega 13 device"        puts " -mark &lt;speed&gt; : set speed. Valid values are 1 to 9."    }    synth::hook_add "help" my_device::help_hook}</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="SYNTH-NEW-HOST-TDF"></A><H2>The Target Definition File</H2><P>Most device scripts will want to check entries in the targetdefinition file for run-time configuration information. The Tclprocedures for this are as follows:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">synth::tdf_has_device &lt;name&gt;synth::tdf_get_devicessynth::tdf_has_option &lt;devname&gt; &lt;option&gt;synth::tdf_get_option &lt;devname&gt; &lt;option&gt;synth::tdf_get_options &lt;devname&gt; &lt;option&gt;synth::tdf_get_all_options &lt;devname&gt;</PRE></TD></TR></TABLE><P><BCLASS="COMMAND">synth::tdf_has_device</B> can be used to check whetheror not the target definition file had an entry<TTCLASS="LITERAL">synth_device&nbsp;&lt;name&gt;</TT>. Usually the namewill match the type of device, so the<TTCLASS="FILENAME">console.tcl</TT> script will look for a targetdefinition file entry <TTCLASS="LITERAL">console</TT>.<BCLASS="COMMAND">synth::tdf_get_devices</B> returns a list of alldevice entries in the target definition file.    </P><P>Once it is known that the target definition file has an entry for acertain device, it is possible to check for options within the entry.<BCLASS="COMMAND">synth::tdf_has_option</B> just checks for the presence,returning a boolean:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    if { [synth::tdf_has_option "console" "appearance"] } {        &#8230;    }</PRE></TD></TR></TABLE><P><BCLASS="COMMAND">synth::tdf_get_option</B> returns a list of all thearguments for a given option. For example, if the target definitionfile contains an entry:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">synth_device console {    appearance -foreground white -background black    filter trace {^TRACE:.*} -foreground HotPink1 -hide 1    filter xyzzy {.*xyzzy.*} -foreground PapayaWhip}</PRE></TD></TR></TABLE><P>A call<BCLASS="COMMAND">synth::tdf_get_option&nbsp;console&nbsp;appearance</B>will return the list <TTCLASS="LITERAL">{-foreground white -backgroundblack}</TT>. This list can be manipulated using standard Tcl routinessuch as <BCLASS="COMMAND">llength</B> and <BCLASS="COMMAND">lindex</B>. Someoptions can occur multiple times in one entry, for example<TTCLASS="OPTION">filter</TT> in the <TTCLASS="LITERAL">console</TT> entry.<BCLASS="COMMAND">synth::tdf_get_options</B> returns a list of lists,with one entry for each option occurrence.<BCLASS="COMMAND">synth::tdf_get_all_options</B> returns a list of listsof all options. This time each entry will include the option name aswell.    </P><P>The I/O auxiliary will not issue warnings about entries in the targetdefinition file for devices which were not loaded, unless the<TTCLASS="OPTION">-v</TT> or <TTCLASS="OPTION">--verbose</TT> command lineargument was used. This makes it easier to use a single targetdefinition file for different applications. However the auxiliary willissue warnings about options within an entry that were ignored,because often these indicate a typing mistake of some sort. Hence ascript should always call <BCLASS="COMMAND">synth::tdf_has_option</B>,<BCLASS="COMMAND">synth:;tdf_get_option</B> or<BCLASS="COMMAND">synth::tdf_get_options</B> for all valid options, evenif some of the options preclude the use of others.    </P></DIV><DIVCLASS="REFSECT1"><ANAME="SYNTH-NEW-HOST-HOOKS"></A><H2>Hooks</H2><P>Some scripts may want to take action when particular events occur, forexample when the eCos application has exited and there is no need forfurther I/O. This is supported using hooks:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">namespace eval my_device {    &#8230;    proc handle_ecos_exit { arg_list } {        &#8230;    }    synth::hook_add "ecos_exit" my_device::handle_ecos_exit}</PRE></TD></TR></TABLE><P>It is possible for device scripts to add their own hooks and call allfunctions registered for those hooks. A typical use for this is byuser initialization scripts that want to monitor some types of I/O.The available Tcl procedures for manipulating hooks are:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">synth::hook_define &lt;name&gt;synth::hook_defined &lt;name&gt;synth::hook_add &lt;name&gt; &lt;function&gt;synth::hook_call &lt;name&gt; &lt;args&gt;</PRE></TD></TR></TABLE><P><BCLASS="COMMAND">synth::hook_define</B> creates a new hook with thespecified name. This hook must not already exist.<BCLASS="COMMAND">synth::hook_defined</B> can be used to check for theexistence of a hook. <BCLASS="COMMAND">synth::hook_add</B> allows otherscripts to register a callback function for this hook, and<BCLASS="COMMAND">synth::hook_call</B> allows the owner script to invokeall such callback functions. A hook must already be defined before acallback can be attached. Therefore typically device scripts will onlyuse standard hooks and their own hooks, not hooks created by someother device, because the order of device initialization is notsufficiently defined. User scripts run from<TTCLASS="FILENAME">mainrc.tcl</TT> can use any hooks that have beendefined.    </P><P><BCLASS="COMMAND">synth::hook_call</B> takes an arbitrary list ofarguments, for example:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    synth::hook_call "ethernet_rx" "eth0" $packet</PRE></TD></TR></TABLE><P>The callback function will always be invoked with a single argument,a list of the arguments that were passed to<BCLASS="COMMAND">synth::hook_call</B>:     </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    proc rx_callback { arg_list } {        set device [lindex $arg_list 0]        set packet [lindex $arg_list 1]    }</PRE></TD></TR></TABLE

⌨️ 快捷键说明

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