📄 synth.sgml
字号:
</para> <para>It should be noted that the console device is line-oriented, notcharacter-oriented. This means that outputting partial lines is notsupported, and some functions such as <function>fflush</function> and<function>setvbuf</function> will not operate as expected. Thislimitation prevents much possible confusion when using filters tocontrol the appearance of the text window, and has some performancebenefits - especially when the eCos application generates a great dealof output such as when tracing is enabled. For most applications thisis not a problem, but it is something that developers should be awareof. </para> <para>The console device is output-only, it does not provide any support forkeyboard input. If the application requires keyboard input then thatshould be handled by a separate eCos device package and matchinghost-side code. </para> </refsect1> <refsect1 id="synth-console-install"><title>Installation</title> <para>The eCos side of the console device is implemented by thearchitectural HAL itself, in the source file<filename>synth_diag.c</filename>, rather than in a separate devicepackage. Similarly the host-side implementation,<function>console.tcl</function>, is part of the architectural HAL'shost-side support. It gets installed automatically alongside the I/Oauxiliary itself, so no separate installation procedure is required. </para> </refsect1> <refsect1 id="synth-console-tdf"><title>Target Definition File</title> <para>The <link linkend="synth-running-tdf">target definition file</link>can contain a number of entries related to the console device. Theseare all optional, they only control the appearance of text output. Ifsuch control is desired then the relevant options should appear in thebody of a <command>synth_device</command> entry: </para> <programlisting>synth_device console { …}</programlisting> <para>The first option is <command>appearance</command>, used to control theappearance of any text generated by the eCos application that does notmatch one of the installed filters. This option takes the sameargument as any other filter, for example: </para> <programlisting>synth_device console { appearance -foreground white -background black …}</programlisting> <para>Any number of additional filters can be created with a<command>filter</command> option, for example: </para> <programlisting>synth_device console { … filter trace {^TRACE:.*} -foreground HotPink1 -hide 1 …}</programlisting> <para>The first argument gives the new filter a name which will be used inthe <link linkend="synth-gui-text">filters dialog</link>. Filter namesshould be unique. The second argument is a Tcl regular expression. Theconsole support will match each line of eCos output against thisregular expression, and if a match is found then the filter will beused for this line of text. The above example matches any line ofoutput that begins with <literal>TRACE:</literal>, which correspondsto the eCos infrastructure's tracing facilities. The remaining optionscontrol the desired appearance for matched text. If some eCos outputmatches the regular expressions for several different filters thenonly the first match will be used. </para> </refsect1> <refsect1 id="synth-console-target-config"><title>Target-side Configuration Options</title> <para>There are no target-side configuration options related to the consoledevice. </para> </refsect1> <refsect1 id="synth-console-arguments"><title>Command Line Arguments</title> <para>The console device does not use any command-line arguments. </para> </refsect1> <refsect1 id="synth-console-hooks"><title>Hooks</title> <para>The console device does not provide any hooks. </para> </refsect1> <refsect1><title>Additional Tcl Procedures</title> <para>The console device does not provide any additional Tcl procedures thatcan be used by other scripts. </para> </refsect1></refentry><!-- }}} --><!-- {{{ System calls --><refentry id="synth-syscalls"> <refmeta> <refentrytitle>System Calls</refentrytitle> </refmeta> <refnamediv> <refname>cyg_hal_sys_xyz</refname> <refpurpose>Access Linux system facilities</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcsynopsisinfo>#include <cyg/hal/hal_io.h> </funcsynopsisinfo> <funcprototype> <funcdef>int <function>cyg_hal_sys_xyzzy</function></funcdef> <varargs> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="synth-syscalls-description"><title>Description</title> <para>On a real embedded target eCos interacts with the hardware by peekingand poking various registers, manipulating special regions of memory,and so on. The synthetic target does not access hardware directly.Instead I/O and other operations are emulated by making appropriateLinux system calls. The HAL package exports a number of functionswhich allow other packages, or even application code, to make thesesame system calls. However this facility must be used with care: anycode which calls, for example, <function>cyg_hal_sys_write</function>will only ever run on the synthetic target; that functionality isobviously not provided on any real hardware because there is nounderlying Linux kernel to implement it. </para> <para>The synthetic target only provides a subset of the available systemcalls, specifically those calls which have proved useful to implementI/O emulation. This subset can be extended fairly easily if necessary.All of the available calls, plus associated data structures andmacros, are defined in the header file <filenameclass="headerfile">cyg/hal/hal_io.h</filename>. There is a simpleconvention: given a Linux system call such as<function>open</function>, the synthetic target will prefix<literal>cyg_hal_sys</literal> and provide a function with that name.The second argument to the <function>open</function> system call isa set of flags such as <constant>O_RDONLY</constant>, and the headerfile will define a matching constant<constant>CYG_HAL_SYS_O_RDONLY</constant>. There are also datastructures such as <structname>cyg_hal_sys_sigset_t</structname>,matching the Linux data structure <structname>sigset_t</structname>. </para> <para>In most cases the functions provided by the synthetic target behave asper the documentation for the Linux system calls, and section 2 of theLinux man pages can be consulted for more information. There is oneimportant difference: typically the documentation will say that afunction returns <literal>-1</literal> to indicate an error, with theactual error code held in <varname>errno</varname>; the actualunderlying system call and hence the<function>cyg_hal_sys_xyz</function> provided by eCos instead returnsa negative number to indicate an error, with the absolute value ofthat number corresponding to the error code; usually it is the Clibrary which handles this and manipulates errno, but of coursesynthetic target applications are not linked with that Linux library. </para> <para>However, there are some exceptions. The Linux kernel has evolved overthe years, and some of the original system call interfaces are nolonger appropriate. For example the original<function>select</function> system call has been superseded by<function>_newselect</function>, and that is what the<function>select</function> function in the C library actually uses.The old call is still available to preserve binary compatibility but,like the C library, eCos makes use of the new one because it providesthe appropriate functionality. In an attempt to reduce confusion theeCos function is called <function>cyg_hal_sys__newselect</function>,in other words it matches the official system call naming scheme. Theauthoritive source of information on such matters is the Linux kernelsources themselves, and especially its header files. </para> <para>eCos packages and applications should never<literal>#include</literal> Linux header files directly. For example,doing a <literal>#include </usr/include/fcntl.h></literal>to access additional macros or structure definitions, or alternativelymanipulating the header file search path, will lead to problemsbecause the Linux header files are likely to duplicate and clash withdefinitions in the eCos headers. Instead the appropriate functionalityshould be extracted from the Linux headers and moved into either<filename class="headerfile">cyg/hal/hal_io.h</filename> or intoapplication code, with suitable renaming to avoid clashes with eCosnames. Users should be aware that large-scale copying may involvelicensing complications. </para> <para>Adding more system calls is usually straightforward and involvesadding one or more lines to the platform-specific file in theappropriate platform HAL, for example<filename>syscall-i386-linux-1.0.S</filename>. However it is necessaryto do some research first about the exact interface implemented by thesystem call, because of issues such as old system calls that have beensuperseded. The required information can usually be found fairlyeasily by searching through the Linux kernel sources and possibly theGNU C library sources. </para> </refsect1></refentry><!-- }}} --><!-- {{{ New devices - target-side --><refentry id="synth-new-target"> <refmeta> <refentrytitle>Writing New Devices - target</refentrytitle> </refmeta> <refnamediv> <refname>Writing New Devices</refname> <refpurpose>extending the synthetic target, target-side</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcsynopsisinfo>#include <cyg/hal/hal_io.h> </funcsynopsisinfo> <funcprototype> <funcdef>int <function>synth_auxiliary_instantiate</function></funcdef> <paramdef>const char* <parameter>package</parameter></paramdef> <paramdef>const char* <parameter>version</parameter></paramdef> <paramdef>const char* <parameter>device</parameter></paramdef> <paramdef>const char* <parameter>instance</parameter></paramdef> <paramdef>const char* <parameter>data</parameter></paramdef> </funcprototype> <funcprototype> <funcdef>void <function>synth_auxiliary_xchgmsg</function></funcdef> <paramdef>int <parameter>device_id</parameter></paramdef> <paramdef>int <parameter>request</parameter></paramdef> <paramdef>int <parameter>arg1</parameter></paramdef> <paramdef>int <parameter>arg2</parameter></paramdef> <paramdef>const unsigned char* <parameter>txdata</parameter></paramdef> <paramdef>int <parameter>txlen</parameter></paramdef> <paramdef>int* <parameter>reply</parameter></paramdef> <paramdef>unsigned char* <parameter>rxdata</parameter></paramdef> <paramdef>int* <parameter>rxlen</parameter></paramdef> <paramdef>int <parameter>max_rxlen</parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="synth-new-target-description"><title>Description</title> <para>In some ways writing a device driver for the synthetic target is verysimilar to writing one for a real target. Obviously it has to providethe standard interface for that class of device, so for example anethernet device has to provide <function>can_send</function>,<function>send</function>, <function>recv</function> and similarfunctions. Many devices will involve interrupts, so the drivercontains ISR and DSR functions and will call<function>cyg_drv_interrupt_create</function>,<function>cyg_drv_interrupt_acknowledge</function>, and relatedfunctions. </para> <para>In other ways writing a device driver for the synthetic target is verydifferent. Usually the driver will not have any direct access to theunderlying hardware. In fact for s
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -