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

📄 programming-concepts-techniques.sgml

📁 eCos操作系统源码
💻 SGML
📖 第 1 页 / 共 3 页
字号:
<!-- {{{ Banner                         --><!-- =============================================================== --><!--                                                                 --><!--     programming-concepts-techniques.sgml                        --><!--                                                                 --><!--     eCos User Guide                                             --><!--                                                                 --><!-- =============================================================== --><!-- ####COPYRIGHTBEGIN####                                          --><!--                                                                 --><!-- =============================================================== --><!-- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.  --><!-- This material may be distributed only subject to the terms      --><!-- and conditions set forth in the Open Publication License, v1.0  --><!-- or later (the latest version is presently available at          --><!-- http://www.opencontent.org/openpub/)                            --><!-- Distribution of the work or derivative of the work in any       --><!-- standard (paper) book form is prohibited unless prior           --><!-- permission obtained from the copyright holder                   --><!-- =============================================================== --><!--                                                                 -->      <!-- ####COPYRIGHTEND####                                            --><!-- =============================================================== --><!-- #####DESCRIPTIONBEGIN####                                       --><!--                                                                 --><!-- ####DESCRIPTIONEND####                                          --><!-- =============================================================== --><!-- }}} --><PART id="ecos-programming-concepts-and-techniques"><TITLE><productname>eCos</productname> Programming Concepts and Techniques</TITLE><PARTINTRO id="programming-partintro"><PARA>Programming with <productname>eCos</productname> is somewhat different from programming      in more traditional environments. <productname>eCos</productname> is a configurable open      source system, and you are able to configure and build a system      specifically to meet the needs of your application. </PARA><PARA>Various different directory hierarchies are involved in      configuring and building the system: the <EMPHASIS>component	repository</EMPHASIS>, the <EMPHASIS>build tree</EMPHASIS>,      and the <EMPHASIS>install tree</EMPHASIS>. These directories      exist in addition to the ones used to develop      applications.</PARA></PARTINTRO><CHAPTER id="cdl-concepts"><TITLE>CDL Concepts</TITLE><SECT1 id="cdl-concepts-about"><TITLE>About this chapter</TITLE><PARA>This chapter serves as a brief introduction to the	concepts involved in <productname>eCos</productname> (Embedded Configurable Operating	System).  It describes the configuration architecture and the	underlying technology to a level required for the embedded	systems developer to configure <productname>eCos</productname>.  It does not describe in	detail aspects such as how to write reusable components for	<productname>eCos</productname>: this information is given in the <citetitle>Component	  Writer&rsquo;s Guide</citetitle>.</PARA><SECT2><TITLE>Background</TITLE><PARA>Software solutions for the embedded space place	  particularly stringent demands on the developer, typically	  represented as requirements for small memory footprint, high	  performance and robustness.  These demands are addressed in	  <productname>eCos</productname> by providing the ability to perform compile-time	  specialization: the developer can tailor the operating	  system to suit the needs of the application.  In order to	  make this process manageable, <productname>eCos</productname> is built in the context	  of a Configuration Infrastructure: a set of tools including	  a <application>Configuration Tool</application> and a formal	  description of the process of configuration by means of a	  <EMPHASIS>Component Definition Language</EMPHASIS>.</PARA></SECT2><SECT2><TITLE>Configurations</TITLE><PARA><productname>eCos</productname> is tailored at source level (that is, before	    compilation or assembly) in order to create an <productname>eCos</productname>	    <EMPHASIS>configuration</EMPHASIS>. In concrete terms, an	    <productname>eCos</productname> configuration takes the form of a configuration save	    file (with extension .ecc) and set of files used to build	    user applications (including, when built, a library file	    against which the application is linked). </PARA></SECT2></SECT1><SECT1 id="cdl-component-repository"><TITLE>Component Repository</TITLE><PARA><productname>eCos</productname> is shipped in source in the form of a	  <EMPHASIS>component repository</EMPHASIS> - a directory	  hierarchy that contains the sources and other files which	  are used to build a configuration. The component repository	  can be added to by, for example, downloading from the	  net.</PARA></SECT1><SECT1 id="cdl-component-definition-language"><TITLE>Component Definition Language</TITLE><PARA>Part of the component repository is a set of files	  containing a definition of its structure.  The form used for	  this purpose is the <EMPHASIS>Component Definition	    Language</EMPHASIS> (CDL).  CDL defines the relationships	  between components and other information used by tools such	  as the <productname>eCos</productname><APPLICATION>Configuration Tool</APPLICATION>.	  CDL is generally formulated by the writers of components: it	  is not necessary to write or understand CDL in order for the	  embedded systems developer to construct an <productname>eCos</productname>	  configuration. </PARA></SECT1><SECT1 id="cdl-packages"><TITLE>Packages</TITLE><PARA>The building blocks of an <productname>eCos</productname> configuration are called	  <EMPHASIS>packages</EMPHASIS>. Packages are the units of	  software distribution.  A set of core packages (such as	  kernel, C library and math library) is provided by Red Hat:	  additional third-party packages will be available in	  future.</PARA><PARA>A package may exist in one of a number of <EMPHASIS>versions</EMPHASIS>. The default version is the <EMPHASIS>current</EMPHASIS> version. Only one version of a given package may be present in the componentrepository at any given time.</PARA><PARA>Packages are organized in a tree hierarchy.  Each packageis either at the top-level or is the child of another package.</PARA><PARA>The <productname>eCos</productname> <application> Package Administration Tool</application> can be used to add or removepackages from the component repository.  The <productname>eCos</productname> <APPLICATION>Configuration Tool</APPLICATION> can be used to include or exclude packages from the configurationbeing built.</PARA></SECT1><SECT1 id="cdl-configuration-items"><TITLE>Configuration Items</TITLE><PARA><EMPHASIS>Configuration items</EMPHASIS> are the	  individual entities that form a configuration.  Each item	  corresponds to the setting of a C pre-processor macro (for	  example,	  <literal>CYGHWR_HAL_ARM_PID_GDB_BAUD</literal>). 	  The code of <productname>eCos</productname> itself is written to test such pre-processor	  macros so as to tailor the code.  User code can do	  likewise.</PARA><PARA>Configuration items come in the following flavors:</PARA><ITEMIZEDLIST><LISTITEM><PARA><EMPHASIS>None</EMPHASIS>: such entities serve only asplace holders in the hierarchy, allowing other entities to be groupedmore easily.</PARA></LISTITEM><LISTITEM><PARA><EMPHASIS>Boolean</EMPHASIS> entities are the most commonflavor; they correspond to units of functionality that can be eitherenabled or disabled.  If the entity is enabled then there will bea #define; code will check the setting using, for example, #ifdef</PARA></LISTITEM><LISTITEM><PARA><EMPHASIS>Data</EMPHASIS> entities encapsulate some arbitrarydata. Other properties such as a set or range of legal values canbe used to constrain the actual values, for example to an integeror floating point value within a certain range.</PARA></LISTITEM><LISTITEM><PARA><EMPHASIS>Booldata</EMPHASIS> entities combine the attributesof <EMPHASIS>Boolean</EMPHASIS> and <EMPHASIS>Data</EMPHASIS>: theycan be enabled or disabled and, if enabled, will hold a data value.</PARA></LISTITEM></ITEMIZEDLIST><PARA>Like packages, configuration items exist in a tree-based hierarchy:each configuration item has a parent which may be another configurationitem or a package.  Under some conditions (such as when packagesare added or removed from a configuration), items may be &ldquo;re-parented&rdquo; suchthat their position in the tree changes. </PARA><SECT2><TITLE>Expressions</TITLE><PARA>Expressions are relationships between CDL items.  There arethree types of expression in CDL:</PARA>	<table id="cdl-expressions">	  <title>CDL Expressions</title>	<tgroup cols="3">	  <thead>	  <row>	      <entry>Expression Type</entry>	      <entry>Result</entry>	      <entry>Common Use (see <xref linkend="table-configuration-properties">)</entry></row>	  </thead>	  <tbody>	    <row>	      <entry>Ordinary</entry>	      <entry>A single value</entry>	      <entry>legal_values property</entry>	    </row>	    <row>	      <entry>List</entry><entry>A range of		values (for example &ldquo;1 to 10&rdquo;)</entry>	      <entry>legal_values property </entry></row>	    <row>	      <entry>Goal</entry><entry>True or False</entry>	      <entry>requires and active_if properties</entry></row>	    </tbody>	  </tgroup>	</table>      </SECT2>      <SECT2>	<TITLE>Properties</TITLE><PARA>Each configuration item has a set of properties.  The followingtable describes the most commonly used:</PARA>	<table id="table-configuration-properties">	  <title>Configuration properties</title>	  <tgroup cols="2">	    <thead><row>		<entry><emphasis>Property</emphasis></entry><entry><emphasis>Use </emphasis></entry></row>	    </thead>	    <tbody>	      <row>		<entry>Flavor</entry>		<entry>The &ldquo;type&rdquo; of the item, as		  described above </entry></row>	      <row>		<entry>Enabled</entry><entry>Whether		  the item is enabled </entry></row>	      <row>		<entry>Current_value</entry><entry>The current value of the item </entry></row>	      <row>		<entry>Default_value</entry><entry>An ordinary expression defining the default value of the		    item</entry></row>	      <row>		<entry>Legal_values</entry><entry>A		  list expression defining the values the item may hold (for example,		  1 to10) </entry></row>	      <row>		<entry>Active_if</entry><entry>A		  goal expression denoting the requirement for this item to be active(see below: <emphasis>Inactive Items</emphasis>) </entry></row><row><entry>Requires</entry><entry>A goalexpression denoting requirements this item places on others (seebelow: <emphasis>Conflicts</emphasis>) </entry></row><row><entry>Calculated</entry><entry>Whetherthe item as non-modifiable </entry></row><row><entry>Macro</entry><entry>The correspondingC pre-processor macro </entry></row><row><entry>File</entry><entry>The C headerfile in which the macro is defined </entry></row><row><entry>URL</entry><entry>The URL ofa documentation page describing the item </entry></row><row><entry>Hardware</entry><entry>Indicatesthat a particular package is related to specific hardware</entry></row>	    </tbody>	  </tgroup>	</table><PARA>A complete description of properties is contained in the <citetitle>ComponentWriter&rsquo;s Guide</citetitle>.</PARA></SECT2><SECT2><TITLE>Inactive Items</TITLE><PARA>Descendants of an item that is disabled are inactive: theirvalues may not be changed.  Items may also become <EMPHASIS>inactive</EMPHASIS> ifan active_if expression is used to make the item dependenton an expression involving other items. </PARA></SECT2></SECT1><SECT1 id="cdl-conflicts"><TITLE>Conflicts</TITLE><PARA>Not all settings of configuration items will lead to a	  coherent configuration; for example, the use of a timeout	  facility might require the existence of timer support, so if	  the one is required the other cannot be removed.  Coherence	  is policed by means of consistency rules (in particular, the	  goal expressions that appear as CDL items	  <EMPHASIS>requires</EMPHASIS> and	  <EMPHASIS>active_if</EMPHASIS> attributes [see	  above]).  A violation of consistency rules creates a	  <EMPHASIS>conflict</EMPHASIS>, which must be resolved in	  order to ensure a consistent configuration. Conflict	  resolution can be performed manually or with the assistance	  of the <productname>eCos</productname> tools.  Conflicts come in the following	  flavors:</PARA><ITEMIZEDLIST><LISTITEM><PARA>An <EMPHASIS>unresolved</EMPHASIS> conflict means thatthere is a reference to an entity that is not yet in the currentconfiguration </PARA></LISTITEM><LISTITEM><PARA>An <EMPHASIS>illegal value</EMPHASIS> conflict is causedwhen a configuration item is set to a value that is not permitted(that is, a <EMPHASIS>legal_values</EMPHASIS> goal expressionis failing) </PARA></LISTITEM><LISTITEM><PARA>An <EMPHASIS>evaluation exception</EMPHASIS> conflictis caused when the evaluation of an expression would fail (for example,because of a division by zero) </PARA></LISTITEM><LISTITEM><PARA>An <EMPHASIS>unsatisfied goal</EMPHASIS> conflict is causedby a failing <EMPHASIS>requires</EMPHASIS> goal expression </PARA></LISTITEM><LISTITEM><PARA>A <EMPHASIS>bad data</EMPHASIS> conflict arises only rarely,and corresponds to badly constructed CDL.  Such a conflict can onlybe resolved by reference to the CDL writer.</PARA></LISTITEM></ITEMIZEDLIST></SECT1><SECT1 id="cdl-templates"><TITLE>Templates</TITLE><PARA>A <EMPHASIS>template</EMPHASIS> is a saved configuration	  - that is, a set of packages and configuration item	  settings.  Templates are provided with <productname>eCos</productname> to allow you to	  get started quickly by instantiating (copying) a saved	  configuration corresponding to one of a number of common	  scenarios; for example, a basic <productname>eCos</productname> configuration template	  is supplied that contains the infrastructure, kernel, C and	  math libraries, plus their support packages.</PARA></SECT1></CHAPTER><CHAPTER id="component-repo-and-working-dirs"><TITLE>The Component Repository and Working Directories</TITLE><PARA>Each of the file trees involved in <productname>eCos</productname> development has a

⌨️ 快捷键说明

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