📄 configuration.sgml
字号:
restore the configuration. Default values on the other hand areentirely deterministic so there is no actual need for the valuesto be listed in the savefile. However, the default value can bevery useful information so it is provided in a comment.</PARA><PARA>Occasionally the user will want to do some experimentation,and temporarily switch an option from a user value back to a defaultor inferred one to see what the effect would be. This could be achievedby simply commenting out the user value. For instance, if the currentsavefile contains:</PARA><SCREEN> cdl_option CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT { # Flavor: bool user_value 1 # The inferred value should not be edited directly. inferred_value 0 # value_source user # Default value: 1 ... }; </SCREEN><PARA>then the inferred value could be restored by commenting outor removing the <literal>user_value</literal> line:</PARA><SCREEN> cdl_option CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT { # Flavor: bool # user_value 1 # The inferred value should not be edited directly. inferred_value 0 # value_source user # Default value: 1 ... }; </SCREEN><PARA>This is fine for simple values. However if the value is complicatedthen there is a problem: commenting out the <LITERAL>user_value</LITERAL> lineor lines means that the user value becomes invisible to the configuration system,so if the savefile is loaded and then regenerated the informationwill be lost. An alternative approach is to keep the <LITERAL>user_value</LITERAL> butexplicitly set the <LITERAL>value_source</LITERAL> line,for example:</PARA><SCREEN>cdl_option CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT { # Flavor: bool user_value 1 # The inferred value should not be edited directly. inferred_value 0 value_source inferred # Default value: 1 ... }; </SCREEN><PARA>In this case the configuration system will use the inferredvalue for the purposes of dependency analysis etc., even thougha user value is present. To restore the user value the <LITERAL>value_source</LITERAL> linecan be commented out again. If there is no explicit <LITERAL>value_source</LITERAL> thenthe configuration system will just use the highest priority one:the user value if it exists; otherwise the inferred value if itexists; otherwise the default value which always exists.</PARA><PARA>The default value for an option can be a simple constant,or it can be an expression involving other options. In the lattercase the expression will be listed, together with the values forall options referenced in the expression and the current resultof evaluating that expression. This is for informational purposesonly, the default value is always recalculated deterministicallywhen loading in a savefile.</PARA><SCREEN>cdl_option CYGBLD_GLOBAL_COMMAND_PREFIX { # Flavor: data # No user value, uncomment the following line to provide one. # user_value arm-elf # value_source default # Default value: CYGHWR_THUMB ? “thumb-elf” : “arm-elf” # CYGHWR_THUMB == 0 # --> arm-elf }; </SCREEN><PARA>For options with the data or booldata flavor, there are likelyto be constraints on the possible values. If the value is supposedto be a number in a given range and a user value of “<LITERAL>helloworld</LITERAL>” is provided instead then thereare likely to be compile-time failures. Component developers canspecify constraints on the legal values, and these will be listedin the savefile.</PARA><SCREEN> cdl_option X_TLOSS { # Flavor: data # No user value, uncomment the following line to provide one. # user_value 1.41484755040569E+16 # value_source default # Default value: 1.41484755040569E+16 # Legal values: 1 to 1e308 };</SCREEN><SCREEN>cdl_component CYGNUM_LIBM_COMPATIBILITY { # Flavor: booldata # No user value, uncomment the following line to provide one. # user_value 1 POSIX # value_source default # Default value: 1 POSIX # Legal values: “POSIX” “IEEE” “XOPEN” “SVID” ... };</SCREEN><PARA>In some cases the legal values list may be an expression involvingother options. If so then the current values of the referenced optionswill be listed, together with the result of evaluating the listexpression, just as for default value expressions.</PARA><PARA>If an illegal value is provided then this will result in aconflict, listed in the conflicts section of the savefile. For morecomplicated options a simple legal values list is not sufficientto allow the current value to be validated, and the configurationsystem will be unable to flag conflicts. This issue will be addressed infuture releases of the configuration system.</PARA><PARA>Following the value-related fields for a given option, any <EMPHASIS>requires</EMPHASIS> constraints belongingto this option will be listed. These constraints are only effectiveif the option is active and, for bool and booldata flavors, enabled.If some aspect of <productname>eCos</productname> functionality is inactive or disabled thenit cannot impose any constraints on the rest of the system. As usual,the full expression will be listed followed by the current valuesof all options that are referenced and the result of evaluatingthe expression:</PARA><SCREEN>cdl_option CYGSEM_LIBC_TIME_TIME_WORKING { ... # Requires: CYGPKG_DEVICES_WALLCLOCK # CYGPKG_DEVICES_WALLCLOCK == current # --> 1 };</SCREEN><PARA>When modifying the value of an option it is useful to knownot only what constraints the option imposes on the rest of thesystem but also what other options in the system depend in someway on this one. The savefile provides this information:</PARA><SCREEN>cdl_option CYGFUN_KERNEL_THREADS_TIMER { ... # The following properties are affected by this value # option CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT # Requires: CYGFUN_KERNEL_THREADS_TIMER # option CYGIMP_UITRON_STRICT_CONFORMANCE # Requires: CYGFUN_KERNEL_THREADS_TIMER # option CYGSEM_LIBC_TIME_CLOCK_WORKING # Requires: CYGFUN_KERNEL_THREADS_TIMER }; </SCREEN></SECT2><SECT2><TITLE>Tcl Syntax</TITLE><PARA><productname>eCos</productname> savefiles are implemented as Tcl scripts, and are readin by running the data through a standard Tcl interpreter that hasbeen extended with a small number of additional commands such as <LITERAL>cdl_option</LITERAL> and <LITERAL>cdl_configuration</LITERAL>.In many cases this is an implementation detail that can be safelyignored while editing a savefile: simply replacing a <LITERAL>1</LITERAL> witha <LITERAL>0</LITERAL> to disable some functionalityis not going to affect whether or not the savefile is still a validTcl script and can be processed by a Tcl interpreter. However, thereare more complicated cases where an understanding of Tcl syntaxis at least desirable, for example:</PARA><SCREEN>cdl_option CYGDAT_UITRON_MEMPOOLVAR_EXTERNS { # Flavor: data user_value \ “static char vpool1\[ 2000 \], \\ vpool2\[ 2000 \], \\ vpool3\[ 2000 \];” # value_source default # Default value: \ # “static char vpool1\[ 2000 \], \\ # vpool2\[ 2000 \], \\ # vpool3\[ 2000 \];” };</SCREEN><PARA>The backslash at the end of the <LITERAL>user_value</LITERAL> lineis processed by the Tcl interpreter as a line continuation character.The quote marks around the user data are also interpreted by theTcl interpreter and serve to turn the entire data field into a singleargument. The backslashes preceding the opening and closing squarebrackets prevent the Tcl interpreter from treating these charactersspecially, otherwise there would be an attempt at <EMPHASIS>commandsubstitution</EMPHASIS> as described below. The double backslashesat the end of each line of the data will be turned into a singlebackslash by the Tcl interpreter, rather than escaping the newlinecharacter, so that the actual data seen by the configuration systemis:</PARA><SCREEN>static char vpool1[ 2000 ], \ vpool2[ 2000 ], \ vpool3[ 2000 ];</SCREEN><PARA>This is of course the data that should end up in the µITRONconfiguration header file. The opening and closing braces surroundingthe entire body of the option data are also significant and causethis body to be passed as a single argument to the <command>cdl_option</command> command.The closing semicolon is optional in this example, but providesa small amount of additional robustness if the savefile is editedsuch that it is no longer a valid Tcl script. If the data containedany <LITERAL>$</LITERAL> characters thenthese would have to be treated specially as well, via a backslash escape.</PARA><PARA>In spite of what all the above might seem to suggest, Tclis actually a very simple yet powerful scripting language: the syntaxis defined by just eleven rules. On occasion this simplicity meansthat Tcl’s behaviour is subtly different from other languages,which can confuse newcomers.</PARA><PARA>When the Tcl interpreter is passed some data such as <LITERAL>putsHello</LITERAL>, it splits this data into a command and itsarguments. The command will be terminated by a newline or by a semicolon,unless one of the quoting mechanisms is used. The command and eachof its arguments are separated by white space. So in the followingexample:</PARA><SCREEN>puts Hello set x 42 </SCREEN><PARA>will result in two separate commands being executed. The firstcommand is <LITERAL>puts</LITERAL> and is passed asingle argument, <LITERAL>Hello</LITERAL>. The secondcommand is <LITERAL>set</LITERAL> and is passed twoarguments, <LITERAL>x</LITERAL> and <LITERAL>42</LITERAL>.The intervening newline character serves to terminate the firstcommand, and a semi-colon separator could be used instead: </PARA><programlisting>puts Hello;set x 42</programlisting><PARA>Any white space surrounding the semicolon is just ignoredbecause it does not serve to separate arguments.</PARA><PARA>Now consider the following:</PARA><SCREEN>set x Hello world</SCREEN><PARA>This is not valid Tcl. It is an attempt to invoke the <LITERAL>set</LITERAL> commandwith three arguments: <LITERAL>x</LITERAL>, <LITERAL>Hello</LITERAL>,and <LITERAL>world</LITERAL>. The <LITERAL>set</LITERAL> onlytakes two arguments, a variable name and a value, so it is necessaryto combine the data into a single argument by quoting:</PARA><PROGRAMLISTING>set x “Hello world”</PROGRAMLISTING><PARA>When the Tcl interpreter encounters the first quote characterit treats all subsequent data up to but not including the closingquote as part of the current argument. The quote marks are removedby the interpreter, so the second argument passed to the <LITERAL>set</LITERAL> commandis just <LITERAL>Hello world</LITERAL> without thequote characters. This can be significant in the context of <productname>eCos</productname> savefiles.For instance, consider the following configuration option:</PARA><SCREEN>cdl_option CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE { # Flavor: data # No user value, uncomment the following line to provide one. # user_value “\”/dev/ttydiag\”” # value_source default # Default value: “\”/dev/ttydiag\”” }; </SCREEN><PARA>The desired value of the configuration option should be avalid C string, complete with quote characters. If the savefilewas edited to: </PARA><SCREEN>cdl_option CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE { # Flavor: data user_value “/dev/ttydiag” # value_source default # Default value: “\”/dev/ttydiag\”” }; </SCREEN><PARA>then the Tcl interpreter would remove the quote marks whenthe savefile is read back in, so the option’s value wouldnot have any quote marks and would not be a valid C string. Theconfiguration system is not yet able to perform the required validationso the following <LITERAL>#define</LITERAL> wouldbe generated in the configuration header file:</PARA><PROGRAMLISTING>#define CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE /dev/ttydiag </PROGRAMLISTING><PARA>This is likely to cause a compile-time failure when building<productname>eCos</productname>.</PARA><PARA>A quoted argument continues until the closing quote characteris encountered, which means that it can span multiple lines. Thiscan also be encountered in <productname>eCos</productname> savefiles, for instance, in the <literal>CYGDAT_UITRON_MEMPOOLVAR_EXTERNS</literal> examplementioned earlier. Newline or semicolon characters do not terminatethe current command in such cases.</PARA><PARA>The Tcl interpreter supports much the same forms of backslashsubstitution as other common programming languages. Some backslashsequences su
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -