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="CDL Language Specification"
23 HREF="reference.html"><LINK
26 HREF="ref.cdl-package.html"><LINK
29 HREF="ref.active-if.html"></HEAD
40 SUMMARY="Header navigation table"
52 > Component Writer's Guide</TH
60 HREF="ref.cdl-package.html"
74 HREF="ref.active-if.html"
85 NAME="REF.CDL-INTERFACE"><TT
99 > -- Define an interface, functionality that can be provided by
100 a number of different implementations.</DIV
102 CLASS="REFSYNOPSISDIV"
114 >cdl_interface <name> {
129 >An interface is a special type of calculated configuration option.
130 It provides an abstraction mechanism that is often useful in <SPAN
134 expressions. As an example, suppose that some package relies on the
135 presence of code that implements the standard kernel scheduling
136 interface. However the requirement is no more stringent than this, so
137 the constraint can be satisfied by the mlqueue scheduler, the bitmap
138 scheduler, or any additional schedulers that may get implemented in
139 future. A first attempt at expressing the dependency might be:</P
147 CLASS="PROGRAMLISTING"
148 > requires CYGSEM_KERNEL_SCHED_MLQUEUE || CYGSEM_KERNEL_SCHED_BITMAP</PRE
153 >This constraint is limited, it may need to be changed if a new
154 scheduler were to be added to the system. Interfaces provide a way of
155 expressing more general relationships:</P
163 CLASS="PROGRAMLISTING"
164 > requires CYGINT_KERNEL_SCHEDULER</PRE
171 >CYGINT_KERNEL_SCHEDULER</TT
179 > by both the mlqueue and bitmap
180 schedulers, and may be implemented by future schedulers as well. The
181 value of an interface is the number of implementors that are active
182 and enabled, so in a typical configuration only one scheduler will be
183 in use and the value of the interface will be <TT
187 all schedulers are disabled then the interface will have a value
194 > constraint will not be
197 >Some component writers may prefer to use the first <SPAN
201 constraint on the grounds that the code will only have been tested
202 with the mlqueue and bitmap schedulers and cannot be guaranteed to
203 work with any new schedulers. Other component writers may take a more
204 optimistic view and assume that their code will work with any
205 scheduler until proven otherwise.</P
207 >Interfaces must be defined in CDL scripts, just like options,
208 components and packages. This involves the command <TT
212 which takes two arguments, a name and a body. The name must be a valid
213 C preprocessor identifier: a sequence of upper or lower case letters,
214 digits or underscores, starting with a non-digit character;
215 identifiers beginning with an underscore should normally be avoided
216 because they may clash with system packages or with identifiers
217 reserved for use by the compiler. Within a single configuration, names
218 must be unique. If a configuration contained two packages which
219 defined the same entity <TT
221 >CYGIMP_SOME_OPTION</TT
223 references to that entity in a <SPAN
226 > property or any other
227 expression would be ambiguous. It is possible for a given name to be
228 used by two different packages if those packages should never be
229 loaded into a single configuration. For example, architectural HAL
230 packages are allowed to re-use names because a single configuration
231 cannot target two different architectures. For a recommended naming
233 HREF="package.contents.html"
234 >the Section called <I
235 >Package Contents and Layout</I
239 >The second argument to <TT
242 > is a body of properties,
243 typically surrounded by braces so that the Tcl interpreter treats it
244 as a single argument. This body will be processed by a recursive
245 invocation of the Tcl interpreter, extended with additional commands
246 for the various properties that are allowed inside a <TT
250 The valid properties are a subset of those for a <TT
261 HREF="ref.active-if.html"
269 >Allow additional control over the active state of this interface.</P
273 HREF="ref.compile.html"
281 >List the source files that should be built if this interface is active.</P
285 HREF="ref.define.html"
293 >Specify additional <TT
296 > symbols that should go
297 into the owning package's configuration header file.</P
301 HREF="ref.define-format.html"
309 >Control how the interface's value will appear in the configuration header
314 HREF="ref.define-proc.html"
322 >Use a fragment of Tcl code to output additional data to
323 configuration header files.</P
327 HREF="ref.description.html"
335 >Provide a textual description for this interface.</P
339 HREF="ref.display.html"
347 >Provide a short string describing this interface.</P
359 >The location of on-line documentation for this interface.</P
363 HREF="ref.flavor.html"
371 >Interfaces have the <TT
374 > flavor by default, but
375 they can also be given the <TT
382 > flavor when necessary. A
386 > interface is disabled if there are no active
387 and enabled implementors, otherwise it is enabled. A
391 > interface is also disabled if there are no
392 active and enabled implementors, otherwise it is enabled and the data
393 is a number corresponding to the number of these implementors.</P
397 HREF="ref.if-define.html"
405 >Output a common preprocessor construct to a configuration header file. </P
409 HREF="ref.implements.html"
417 >If this interface is active it provides one instance of a more general
422 HREF="ref.legal-values.html"
430 >Interfaces always have a small numerical value. The <SPAN
434 be used to apply additional constraints such as an upper limit.</P
446 >An additional custom build step associated with this option, resulting
447 in a target that should not go directly into a library.</P
451 HREF="ref.make-object.html"
459 >An additional custom build step associated with this option, resulting
460 in an object file that should go into a library.</P
464 HREF="ref.no-define.html"
472 >Suppress the normal generation of a preprocessor
476 > symbol in a configuration header file.</P
480 HREF="ref.parent.html"
488 >Control the location of this option in the configuration hierarchy. </P
492 HREF="ref.requires.html"
500 >List constraints that the configuration should satisfy if this option is
501 active and enabled.</P
506 >A number of properties are not applicable to interfaces:</P
514 HREF="ref.calculated.html"
522 >Interfaces are always calculated, based on the number of active and
523 enabled entities that implement the interface.</P
527 HREF="ref.default-value.html"
535 >Interface values are calculated so a <SPAN
544 >Interfaces are not containers, so they cannot hold other entities such
545 as options or components.</P
547 >A commonly used constraint on interface values takes the form:</P
555 CLASS="PROGRAMLISTING"
556 > requires CYGINT_KERNEL_SCHEDULER == 1</PRE
561 >This constraint specifies that there can be only one scheduler in the
562 system. In some circumstances it is possible for the configuration
563 tools to detect this pattern and act accordingly, so for example
564 enabling the bitmap scheduler would automatically disable the mlqueue
581 CLASS="PROGRAMLISTING"
582 >cdl_interface CYGINT_KERNEL_SCHEDULER {
583 display "Number of schedulers in this configuration"
584 requires 1 == CYGINT_KERNEL_SCHEDULER
599 HREF="ref.implements.html"
606 HREF="ref.cdl-option.html"
613 HREF="ref.cdl-component.html"
620 HREF="ref.cdl-package.html"
632 SUMMARY="Footer navigation table"
643 HREF="ref.cdl-package.html"
652 HREF="cdl-guide.html"
661 HREF="ref.active-if.html"
680 HREF="reference.html"