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

📄 language.interface.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
字号:
<!-- Copyright (C) 2003 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 is obtained from the copyright holder.               --><HTML><HEAD><TITLE>Interfaces</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="The eCos Component Writer's Guide"HREF="cdl-guide.html"><LINKREL="UP"TITLE="The CDL Language"HREF="language.html"><LINKREL="PREVIOUS"TITLE="Values and Expressions"HREF="language.values.html"><LINKREL="NEXT"TITLE="Updating the ecos.db database"HREF="language.database.html"></HEAD><BODYCLASS="SECT1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">The <SPANCLASS="APPLICATION">eCos</SPAN> Component Writer's Guide</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="language.values.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 3. The CDL Language</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="language.database.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="LANGUAGE.INTERFACE">Interfaces</H1><P>For many configurability requirements, options provide sufficientexpressive power. However there are times when a higher level ofabstraction is appropriate. As an example, suppose that some packagerelies on the presence of code that implements the standard kernelscheduling interface. However the requirement is no more stringentthan this, so the constraint can be satisfied by the mlqueuescheduler, the bitmap scheduler, or any additional schedulers that mayget implemented in future. A first attempt at expressing thedependency might be:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires CYGSEM_KERNEL_SCHED_MLQUEUE || CYGSEM_KERNEL_SCHED_BITMAP</PRE></TD></TR></TABLE><P>This constraint will work with the current release, but it is limited.Suppose there is a new release of the kernel which adds anotherscheduler such as a deadline scheduler, or suppose that there is a newthird party package which adds such a scheduler. The packagecontaining the limited constraint would now have to be updated andanother release made, with possible knock-on effects.</P><P><SPANCLASS="APPLICATION">CDL</SPAN> interfaces provide an abstraction mechanism: constraints can beexpressed in terms of an abstract concept, for example&#8220;scheduler&#8221;, rather than specific implementations such as<TTCLASS="VARNAME">CYGSEM_KERNEL_SCHED_MLQUEUE</TT> and<TTCLASS="VARNAME">CYGSEM_KERNEL_SCHED_BITMAP</TT>. Basically an interfaceis a calculated configuration option:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_interface CYGINT_KERNEL_SCHEDULER {    display  "Number of schedulers in this configuration"    &#8230;}</PRE></TD></TR></TABLE><P>The individual schedulers can then implement this interface:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_option CYGSEM_KERNEL_SCHED_MLQUEUE {    display       "Multi-level queue scheduler"    default_value 1    implements    CYGINT_KERNEL_SCHEDULER    &#8230;}cdl_option CYGSEM_KERNEL_SCHED_BITMAP {    display       "Bitmap scheduler"    default_value 0    implements    CYGINT_KERNEL_SCHEDULER    &#8230;}</PRE></TD></TR></TABLE><P>Future schedulers can also implement this interface. The value of aninterface, for the purposes of expression evaluation, is the number ofactive and enabled options which implement this interface. Packageswhich rely on the presence of a scheduler can impose constraints suchas:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires CYGINT_KERNEL_SCHEDULER</PRE></TD></TR></TABLE><P>If none of the schedulers are enabled, or if the kernel package is notloaded, then <TTCLASS="VARNAME">CYGINT_KERNEL_SCHEDULER</TT> will evaluateto <TTCLASS="LITERAL">0</TT>. If at least one scheduler is active andenabled then the constraint will be satisfied.</P><P>Because interfaces have a calculated value determined by theimplementors, the <SPANCLASS="PROPERTY">default_value</SPAN> and <SPANCLASS="PROPERTY">calculated</SPAN> properties are notapplicable and should not appear in the body of a <TTCLASS="LITERAL">cdl_interface</TT>command. Interfaces have the <TTCLASS="LITERAL">data</TT> flavor bydefault, but the <TTCLASS="LITERAL">bool</TT> and<TTCLASS="LITERAL">booldata</TT> flavors may be specified instead. A<TTCLASS="LITERAL">bool</TT> interface is disabled if there are no activeand enabled implementors, otherwise it is enabled. A<TTCLASS="LITERAL">booldata</TT> interface is disabled if there are noactive and enabled implementors, otherwise it is enabled and has avalue corresponding to the number of these implementors. Otherproperties such as <SPANCLASS="PROPERTY">requires</SPAN> and <SPANCLASS="PROPERTY">compile</SPAN> can be used as normal.</P><P>Some component writers will not want to use interfaces in this way.The reasoning is that their code will only have been tested with theexisting schedulers, so the <SPANCLASS="PROPERTY">requires</SPAN> constraint needs to beexpressed in terms of those schedulers; it is possible that thecomponent will still work with a new scheduler, but there are noguarantees. Other component writers may take a more optimistic viewand assume that their code will work with any scheduler until provenotherwise. It is up to individual component writers to decide whichapproach is most appropriate in any given case.</P><P>One common use for interfaces is to describe the hardwarefunctionality provided by a given target. For example the <SPANCLASS="APPLICATION">CDL</SPAN>scripts for a TCP/IP package might want to know whether or not thetarget hardware has an ethernet interface. Generally it is notnecessary for the TCP/IP stack to know exactly which ethernet hardwareis present, since there should be a device driver which implements theappropriate functionality. In <SPANCLASS="APPLICATION">CDL</SPAN> terms the device drivers shouldimplement an interface <TTCLASS="VARNAME">CYGHWR_NET_DRIVERS</TT>, and the<SPANCLASS="APPLICATION">CDL</SPAN> scripts for the TCP/IP stack can use this in appropriateexpressions. </P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>Using the term <SPANCLASS="emphasis"><ICLASS="EMPHASIS">interface</I></SPAN> for this concept issometimes confusing, since the term has various other meanings aswell. In practice, it is often correct. If there is a configurationoption that implements a given <SPANCLASS="APPLICATION">CDL</SPAN> interface, then usually thisoption will enable some code that provides a particular interface atthe C or C++ level. For example an ethernet device driver implementsthe <SPANCLASS="APPLICATION">CDL</SPAN> interface <TTCLASS="VARNAME">CYGHWR_NET_DRIVERS</TT>, and alsoimplements a set of C functions that can be used by the TCP/IP stack.Similarly <TTCLASS="VARNAME">CYGSEM_KERNEL_SCHED_MLQUEUE</TT> implementsthe <SPANCLASS="APPLICATION">CDL</SPAN> interface <TTCLASS="VARNAME">CYGINT_KERNEL_SCHEDULER</TT> andalso provides the appropriate scheduling functions.</P></BLOCKQUOTE></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="language.values.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="cdl-guide.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="language.database.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Values and Expressions</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="language.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Updating the <SPANCLASS="DATABASE">ecos.db</SPAN> database</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

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