1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="The eCos Component Writer's Guide"
20 HREF="cdl-guide.html"><LINK
22 TITLE="The CDL Language"
23 HREF="language.html"><LINK
25 TITLE="Values and Expressions"
26 HREF="language.values.html"><LINK
28 TITLE="Updating the ecos.db database"
29 HREF="language.database.html"></HEAD
40 SUMMARY="Header navigation table"
52 > Component Writer's Guide</TH
60 HREF="language.values.html"
68 >Chapter 3. The CDL Language</TD
74 HREF="language.database.html"
88 NAME="LANGUAGE.INTERFACE">Interfaces</H1
90 >For many configurability requirements, options provide sufficient
91 expressive power. However there are times when a higher level of
92 abstraction is appropriate. As an example, suppose that some package
93 relies on the presence of code that implements the standard kernel
94 scheduling interface. However the requirement is no more stringent
95 than this, so the constraint can be satisfied by the mlqueue
96 scheduler, the bitmap scheduler, or any additional schedulers that may
97 get implemented in future. A first attempt at expressing the
98 dependency might be:</P
106 CLASS="PROGRAMLISTING"
107 > requires CYGSEM_KERNEL_SCHED_MLQUEUE || CYGSEM_KERNEL_SCHED_BITMAP</PRE
112 >This constraint will work with the current release, but it is limited.
113 Suppose there is a new release of the kernel which adds another
114 scheduler such as a deadline scheduler, or suppose that there is a new
115 third party package which adds such a scheduler. The package
116 containing the limited constraint would now have to be updated and
117 another release made, with possible knock-on effects.</P
122 > interfaces provide an abstraction mechanism: constraints can be
123 expressed in terms of an abstract concept, for example
124 “scheduler”, rather than specific implementations such as
127 >CYGSEM_KERNEL_SCHED_MLQUEUE</TT
131 >CYGSEM_KERNEL_SCHED_BITMAP</TT
132 >. Basically an interface
133 is a calculated configuration option:</P
141 CLASS="PROGRAMLISTING"
142 >cdl_interface CYGINT_KERNEL_SCHEDULER {
143 display "Number of schedulers in this configuration"
150 >The individual schedulers can then implement this interface:</P
158 CLASS="PROGRAMLISTING"
159 >cdl_option CYGSEM_KERNEL_SCHED_MLQUEUE {
160 display "Multi-level queue scheduler"
162 implements CYGINT_KERNEL_SCHEDULER
166 cdl_option CYGSEM_KERNEL_SCHED_BITMAP {
167 display "Bitmap scheduler"
169 implements CYGINT_KERNEL_SCHEDULER
176 >Future schedulers can also implement this interface. The value of an
177 interface, for the purposes of expression evaluation, is the number of
178 active and enabled options which implement this interface. Packages
179 which rely on the presence of a scheduler can impose constraints such
188 CLASS="PROGRAMLISTING"
189 > requires CYGINT_KERNEL_SCHEDULER</PRE
194 >If none of the schedulers are enabled, or if the kernel package is not
197 >CYGINT_KERNEL_SCHEDULER</TT
202 >. If at least one scheduler is active and
203 enabled then the constraint will be satisfied.</P
205 >Because interfaces have a calculated value determined by the
206 implementors, the <SPAN
213 applicable and should not appear in the body of a <TT
217 command. Interfaces have the <TT
228 > flavors may be specified instead. A
232 > interface is disabled if there are no active
233 and enabled implementors, otherwise it is enabled. A
237 > interface is disabled if there are no
238 active and enabled implementors, otherwise it is enabled and has a
239 value corresponding to the number of these implementors. Other
240 properties such as <SPAN
246 > can be used as normal.</P
248 >Some component writers will not want to use interfaces in this way.
249 The reasoning is that their code will only have been tested with the
250 existing schedulers, so the <SPAN
253 > constraint needs to be
254 expressed in terms of those schedulers; it is possible that the
255 component will still work with a new scheduler, but there are no
256 guarantees. Other component writers may take a more optimistic view
257 and assume that their code will work with any scheduler until proven
258 otherwise. It is up to individual component writers to decide which
259 approach is most appropriate in any given case.</P
261 >One common use for interfaces is to describe the hardware
262 functionality provided by a given target. For example the <SPAN
266 scripts for a TCP/IP package might want to know whether or not the
267 target hardware has an ethernet interface. Generally it is not
268 necessary for the TCP/IP stack to know exactly which ethernet hardware
269 is present, since there should be a device driver which implements the
270 appropriate functionality. In <SPAN
273 > terms the device drivers should
274 implement an interface <TT
276 >CYGHWR_NET_DRIVERS</TT
281 > scripts for the TCP/IP stack can use this in appropriate
290 >Using the term <SPAN
296 > for this concept is
297 sometimes confusing, since the term has various other meanings as
298 well. In practice, it is often correct. If there is a configuration
299 option that implements a given <SPAN
302 > interface, then usually this
303 option will enable some code that provides a particular interface at
304 the C or C++ level. For example an ethernet device driver implements
310 >CYGHWR_NET_DRIVERS</TT
312 implements a set of C functions that can be used by the TCP/IP stack.
315 >CYGSEM_KERNEL_SCHED_MLQUEUE</TT
322 >CYGINT_KERNEL_SCHEDULER</TT
324 also provides the appropriate scheduling functions.</P
333 SUMMARY="Footer navigation table"
344 HREF="language.values.html"
353 HREF="cdl-guide.html"
362 HREF="language.database.html"
372 >Values and Expressions</TD