OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [libcdl/] [doc/] [language.sgml] - Blame information for rev 790

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
2
 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
33
34
 
35
36
The CDL Language
37
 
38
39
 
40
41
The &CDL; language is a key part of the &eCos; component framework.
42
All packages must come with at least one &CDL; script, to describe
43
that package to the framework. The information in that script includes
44
details of all the configuration options and how to build the package.
45
Implementing a new component or turning some existing code into an
46
&eCos; component always involves writing corresponding &CDL;. This
47
chapter provides a description of the &CDL; language. Detailed
48
information on specific parts of the language can be found in 
49
linkend="reference">.
50
51
 
52
53
54
 
55
56
Language Overview
57
58
A very simple &CDL; script would look like this:
59
60
61
cdl_package CYGPKG_ERROR {
62
    display       "Common error code support"
63
    compile       strerror.cxx
64
    include_dir   cyg/error
65
    description   "
66
        This package contains the common list of error and
67
        status codes. It is held centrally to allow
68
        packages to interchange error codes and status
69
        codes in a common way, rather than each package
70
        having its own conventions for error/status
71
        reporting. The error codes are modelled on the
72
        POSIX style naming e.g. EINVAL etc. This package
73
        also provides the standard strerror() function to
74
        convert error codes to textual representation."
75
}
76
77
78
This describes a single package, the error code package, which does
79
not have any sub-components or configuration options. The package has
80
an internal name, CYGPKG_ERROR, which can be
81
referenced in other &CDL; scripts using e.g.
82
requires CYGPKG_ERROR. There will also be a
83
#define for this symbol in a configuration header
84
file. In addition to the package name, this script provides a number
85
of properties for the package as a whole. The &display; property
86
provides a short description. The &description; property involves a
87
rather longer one, for when users need a bit more information. The
88
&compile; and &include-dir; properties list the consequences of this
89
package at build-time. The package appears to lack any on-line
90
documentation.
91
92
93
Packages could be even simpler than this. If the package only provides
94
an interface and there are no files to be compiled then there is no
95
need for a &compile; property. Alternatively if there are no exported
96
header files, or if the exported header files should go to the
97
top-level of the 
98
class="directory">install/include directory, then there is
99
no need for an &include-dir; property. Strictly speaking the
100
&description; and &display; properties are optional as well, although
101
application developers would not appreciate the resulting lack of
102
information about what the package is supposed to do.
103
104
105
However many packages tend to be a bit more complicated than the error
106
package, containing various sub-components and configuration options.
107
These are also defined in the &CDL; scripts and in much the same way
108
as the package. For example, the following excerpt comes from the
109
infrastructure package:
110
111
112
cdl_component CYGDBG_INFRA_DEBUG_TRACE_ASSERT_BUFFER {
113
    display       "Buffered tracing"
114
    default_value 1
115
    active_if     CYGDBG_USE_TRACING
116
    description   "
117
        An output module which buffers output from tracing and
118
        assertion events. The stored messages are output when an
119
        assert fires, or CYG_TRACE_PRINT() (defined in
120
        <cyg/infra/cyg_trac.h>) is called. Of course, there will
121
        only be stored messages if tracing per se (CYGDBG_USE_TRACING)
122
        is enabled above."
123
 
124
    cdl_option CYGDBG_INFRA_DEBUG_TRACE_BUFFER_SIZE {
125
        display       "Trace buffer size"
126
        flavor        data
127
        default_value 32
128
        legal_values  5 to 65535
129
        description   "
130
            The size of the trace buffer. This counts the number of
131
            trace records stored. When the buffer fills it either
132
            wraps, stops recording, or generates output."
133
    }
134
 
135
136
}
137
138
139
Like a &cdl-package;, a &cdl-component; has a name and a body. The
140
body contains various properties for that component, and may also
141
contain sub-components or options. Similarly a &cdl-option; has a
142
name and a body of properties. This example lists a number of
143
new properties: &default-value;, &active-if;, &flavor; and
144
&legal-values;. The meaning of most of these should be fairly obvious.
145
The next sections describe the various &CDL; commands and properties.
146
147
148
There is one additional and very important point: &CDL; is not a
149
completely new language; instead it is implemented as an extension of
150
the existing &Tcl; scripting language. The syntax of a &CDL; script is
151
&Tcl; syntax, which is described below. In addition some of the more
152
advanced facilities of &CDL; involve embedded fragments of &Tcl; code,
153
for example there is a &define-proc; property which specifies some
154
code that needs to be executed when the component framework generates
155
the configuration header files.
156
157
 
158
159
 
160
161
162
 
163
164
CDL Commands
165
166
There are four &CDL;-related commands which can occur at the top-level
167
of a &CDL; script: &cdl-package;, &cdl-component;, &cdl-option; and
168
&cdl-interface;. These correspond to the basic building blocks of the
169
language (CDL interfaces are described in 
170
linkend="language.interface">). All of these take the same basic form:
171
172
173
cdl_package <name> {
174
175
}
176
 
177
cdl_component <name> {
178
179
}
180
 
181
cdl_option <name> {
182
183
}
184
 
185
cdl_interface <name> {
186
187
}
188
189
190
The command is followed by a name and by a body of properties, the
191
latter enclosed in braces. Packages and components can contain other
192
entities, so the &cdl-package; and &cdl-component; can also have
193
nested commands in their bodies. All names must be unique within a
194
given configuration. If say the C library package and a TCP/IP stack
195
both defined an option with the same name then it would not be
196
possible to load both of them into a single configuration. There is a
197
naming convention which should
198
make accidental name clashes very unlikely.
199
200
201
It is possible for two packages to use the same name if there are no
202
reasonable circumstances under which both packages could be loaded at
203
the same time. One example would be architectural HAL packages: a
204
given &eCos; configuration can be used on only one processor, so the
205
architectural HAL packages CYGPKG_HAL_ARM and
206
CYGPKG_HAL_I386 can re-use option names; in fact
207
in some cases they are expected to.
208
209
210
Each package has one top-level &CDL; script, which is specified in the
211
packages 
212
linkend="language.database">ecos.db database
213
entry. Typically the name of this top-level script is related to
214
the package, so the kernel package uses
215
kernel.cdl, but this is just a convention. The
216
first command in the top-level script should be &cdl-package;, and the
217
name used should be the same as in the ecos.db
218
database. There should be only one &cdl-package; command per package.
219
220
221
The various &CDL; entities live in a hierarchy. For example the kernel
222
package contains a scheduling component, a synchronization primitives
223
component, and a number of others. The synchronization component
224
contains various options such as whether or not mutex priority
225
inheritance is enabled. There is no upper bound on how far components
226
can be nested, but it is rarely necessary to go more than three or
227
four levels deeper than the package level. Since the naming convention
228
incorporates bits of the hierarchy, this has the added advantage of
229
keeping the names down to a more manageable size.
230
231
232
The hierarchy serves two purposes. It allows options to be controlled
233
en masse, so disabling a component automatically disables all the
234
options below it in the hierarchy. It also permits a much simpler
235
representation of the configuration in the graphical configuration
236
tool, facilitating navigation and modification.
237
238
239
By default a package is placed at the top-level of the hierarchy, but
240
it is possible to override this using a &parent; property. For example
241
an architectural HAL package such as CYGPKG_HAL_SH
242
typically re-parents itself below CYGPKG_HAL, and a
243
platform HAL package would then re-parent itself below the
244
architectural HAL. This makes it a little bit easier for users to
245
navigate around the hierarchy. Components, options and interfaces can
246
also be re-parented, but this is less common.
247
248
249
All components, options and interfaces that are defined directly in
250
the top-level script will be placed below the package in the hierarchy.
251
Alternatively they can be nested in the body of the &cdl-package;
252
command. The following two script fragments are equivalent:
253
254
255
cdl_package CYGPKG_LIBC {
256
257
}
258
 
259
cdl_component CYGPKG_LIBC_STRING {
260
261
}
262
 
263
cdl_option CYGPKG_LIBC_CTYPE_INLINES {
264
265
}
266
267
268
and:
269
270
271
cdl_package CYGPKG_LIBC {
272
273
 
274
    cdl_component CYGPKG_LIBC_STRING {
275
276
    }
277
 
278
    cdl_option CYGPKG_LIBC_CTYPE_INLINES {
279
280
    }
281
}
282
283
284
If a script defines options both inside and outside the body of the
285
&cdl-package; then the ones inside will be processed first. Language
286
purists may argue that it would have been better if all contained
287
options and components had to go into the body, but in practice it is
288
often convenient to be able to skip this level of nesting and the
289
resulting behavior is still well-defined.
290
291
292
Components can also contain options and other &CDL; entities, in fact
293
that is what distinguishes them from options. These can be defined in
294
the body of the &cdl-component; command:
295
296
297
cdl_component CYGPKG_LIBC_STDIO {
298
 
299
    cdl_component CYGPKG_LIBC_STDIO_FLOATING_POINT {
300
301
    }
302
 
303
    cdl_option CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS {
304
305
    }
306
}
307
308
309
Nesting options inside the bodies of components like this is fine for
310
simple packages with only a limited number of configuration options,
311
but it becomes unsatisfactory as the number of options increases.
312
Instead it is possible to split the &CDL; data into multiple &CDL;
313
scripts, on a per-component basis. The &script; property should be
314
used for this. For example, in the case of the C library all
315
stdio-related configuration options could be put into
316
stdio.cdl, and the top-level CDL script
317
libc.cdl would contain the following:
318
319
320
cdl_package CYGPKG_LIBC {
321
322
 
323
    cdl_component CYGPKG_LIBC_STDIO {
324
325
        script stdio.cdl
326
    }
327
}
328
329
330
The CYGPKG_LIBC_STDIO_FLOATING_POINT component and
331
the CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS option
332
can then be placed at the top-level of stdio.cdl.
333
It is possible to have some options nested in the body of a
334
&cdl-component; command and other options in a separate file accessed
335
by the &script; property. In such a case the nested options would be
336
processed first, and then the other script would be read in. A script
337
specified by a &script; property should only define new options,
338
components or interfaces: it should not contain any additional
339
properties for the current component.
340
341
342
It is possible for a component's &CDL; script to have a sub-component
343
which also has a &script; property, and so on. In practice excessive
344
nesting like this is rarely useful. It is also possible to ignore the
345
&CDL; language support for constructing hierarchies automatically and
346
use the &parent; property explicitly for every single option and
347
component. Again this is not generally useful.
348
349
350
351
At the time of writing interfaces cannot act as containers. This may
352
change in a future version of the component framework. If the change
353
is made then interfaces would support the &script; property, just like
354
components.
355
356
357
 
358
359
 
360
361
362
 
363
364
 
365
366
CDL Properties
367
368
Each package, component, option, and interface has a body of
369
properties, which provide the component framework with information
370
about how to handle each option. For example there is a property for a
371
descriptive text message which can be displayed to a user who is
372
trying to figure out just what effect manipulating the option would
373
have on the target application. There is another property for the
374
default value, for example whether a particular option should be
375
enabled or disabled by default.
376
377
378
All of the properties are optional, it is legal to define a
379
configuration option which has an empty body. However some properties
380
are more optional than others: users will not appreciate having to
381
manipulate an option if they are not given any sort of description or
382
documentation. Other properties are intended only for very specific
383
purposes, for example &make-object; and &include-files;, and are used
384
only rarely.
385
386
387
Because different properties serve very different purposes, their
388
syntax is not as uniform as the top-level commands. Some properties
389
take no arguments at all. Other properties take a single argument such
390
as a description string, or a list of arguments such as a &compile;
391
property which specifies the file or files that should be compiled if
392
a given option is active and enabled. The &define-proc; property takes
393
as argument a snippet of &Tcl; code. The &active-if;, &calculated;,
394
&default-value;, &legal-values; and &requires; properties take various
395
expressions. Additional properties may be defined in future which take
396
new kinds of arguments.
397
398
399
All property parsing code supports options for every property,
400
although at present the majority of properties do not yet take any
401
options. Any initial arguments that begin with a hyphen character
402
- will be interpreted as an option, for example:
403
404
405
cdl_package CYGPKG_HAL_ARM {
406
407
    make -priority 1 {
408
409
    }
410
}
411
412
413
If the option involves additional data, as for the
414
-priority example above, then this can be written
415
as either -priority=1 or as
416
-priority 1. On occasion the option parsing
417
code can get in the way, for example:
418
419
420
cdl_option CYGNUM_LIBC_TIME_DST_DEFAULT_STATE {
421
422
    legal_values -1 to 1
423
    default_value -1
424
}
425
426
427
Neither the &legal-values; nor the &default-value; property will
428
accept -1 as a valid option, so this will result in
429
syntax errors when the &CDL; script is read in by the component
430
framework. To avoid problems, the option parsing code will recognize
431
the string -- and will not attempt to interpret any
432
subsequent arguments. Hence this option should be written as:
433
434
435
cdl_option CYGNUM_LIBC_TIME_DST_DEFAULT_STATE {
436
437
    legal_values  -- -1 to 1
438
    default_value -- -1
439
}
440
441
442
The property parsing code involves a recursive invocation of the Tcl
443
interpreter that is used to parse the top-level commands. This means
444
that some characters in the body of an option will be treated
445
specially. The # character can be used for
446
comments. The backslash character \, the
447
dollar character $, square brackets
448
[ and ], braces
449
{ and }, and the quote character
450
" may all receive special treatment. Most of the
451
time this is not a problem because these characters are not useful for
452
most properties. On occasion having a &Tcl; interpreter around
453
performing the parser can be very powerful. For more details of
454
how the presence of a &Tcl; interpreter can affect &CDL; scripts,
455
see .
456
457
458
Many of the properties can be used in any of &cdl-package;,
459
&cdl-component;, &cdl-option; or &cdl-interface;. Other properties are
460
more specific. The &script; property is only relevant to components.
461
The &define-header;, &hardware;, &include-dir;, &include-files;, and
462
&library; properties apply to a package as a whole, so can only occur
463
in the body of a &cdl-package; command. The &calculated;,
464
&default-value;, &legal-values; and &flavor; properties are not
465
relevant to packages, as will be explained later. The &calculated; and
466
&default-value; properties are also not relevant to interfaces.
467
468
469
This section lists the various properties, grouped by purpose. Each
470
property also has a full reference page in .
471
Properties related to values and expressions are described in more
472
detail in . Properties related to
473
header file generation and to the build process are described in
474
.
475
476
 
477
478
479
 
480
481
Information-providing Properties
482
483
Users can only be expected to manipulate configuration options
484
sensibly if they are given sufficient information about these options.
485
There are three properties which serve to explain an option in plain
486
text: the &display; property gives
487
a textual alias for an option, which is usually more comprehensible
488
than something like CYGPKG_LIBC_TIME_ZONES`; the
489
&description; property gives a
490
longer description, typically a paragraph or so; the 
491
linkend="ref.doc">&doc; property specifies the location of
492
additional on-line documentation related to a configuration option. In
493
the context of a graphical tool the &display; string will be the
494
primary way for users to identify configuration options; the
495
&description; paragraph will be visible whenever the option is
496
selected; the on-line documentation will only be accessed when the
497
user explicitly requests it.
498
499
500
cdl_package CYGPKG_UITRON {
501
    display       "uITRON compatibility layer"
502
    doc           ref/ecos-ref.a.html
503
    description   "
504
        eCos supports a uITRON Compatibility Layer, providing
505
        full Level S (Standard) compliance with Version 3.02 of
506
        the uITRON Standard, plus many Level E (Extended) features.
507
        uITRON is the premier Japanese embedded RTOS standard."
508
509
}
510
511
512
All three properties take a single argument. For &display; and
513
&description; this argument is just a string. For &doc; it should be a
514
pointer to a suitable HTML file, optionally including an anchor within
515
that page. If the directory layout
516
conventions are observed then the component framework will look
517
for the HTML file in the package's 
518
class="directory">doc sub-directory, otherwise the &doc;
519
filename will be treated as relative to the package's top-level directory.
520
521
522
 
523
524
525
 
526
527
The Configuration Hierarchy
528
529
There are two properties related to the hierarchical organization of
530
components and options: &parent; and
531
&script;.
532
533
534
The &parent; property can be used to move a &CDL; entity somewhere
535
else in the hierarchy. The most common use is for packages, to avoid
536
having all the packages appear at the top-level of the configuration
537
hierarchy. For example an architectural HAL package such as
538
CYGPKG_HAL_SH is placed below the common HAL
539
package CYGPKG_HAL using a &parent; property.
540
541
542
cdl_package CYGPKG_HAL_SH {
543
    display       "SH architecture"
544
    parent        CYGPKG_HAL
545
546
}
547
548
549
The &parent; property can also be used in the body of a
550
&cdl-component;, &cdl-option; or &cdl-interface;, but this is less
551
common. However care has to be taken since excessive re-parenting can
552
be confusing. Care also has to be taken when reparenting below some
553
other package that may not actually be loaded in a given
554
configuration, since the resulting behavior is undefined.
555
556
557
As a special case, if the parent is the empty string then the
558
&CDL; entity is placed at the root of the hierarchy. This is useful
559
for global preferences, default compiler flags, and other settings
560
that may affect every package.
561
562
563
The &script; property can only be used in the body of a
564
&cdl-component; command. The property takes a single filename as
565
argument, and this should be another &CDL; script containing
566
additional options, sub-components and interfaces that should go below
567
the current component in the hierarchy. If the 
568
linkend="package.hierarchy">directory layout conventions are
569
observed then the component framework will look for the specified file
570
relative to the cdl
571
subdirectory of the package, otherwise the filename will be treated as
572
relative to the package's top-level directory.
573
574
575
cdl_component CYGPKG_LIBC_STDIO {
576
    display       "Standard input/output functions"
577
    flavor        bool
578
    requires      CYGPKG_IO
579
    requires      CYGPKG_IO_SERIAL_HALDIAG
580
    default_value 1
581
    description   "
582
        This enables support for standard I/O functions from <stdio.h>."
583
 
584
    script        stdio.cdl
585
}
586
587
 
588
589
 
590
591
592
 
593
594
Value-related Properties
595
596
There are seven properties which are related to option values and
597
state: &flavor;,
598
&calculated;,
599
&default-value;,
600
&legal-values;,
601
&active-if;,
602
&implements;, and
603
&requires;. More detailed
604
information can be found in .
605
606
607
In the context of configurability, the concept of an option's value is
608
somewhat non-trivial. First an option may or may not be loaded: it is
609
possible to build a configuration which has the math library but not
610
the kernel; however the math library's &CDL; scripts still reference
611
kernel options, for example
612
CYGSEM_LIBM_THREAD_SAFE_COMPAT_MODE has a
613
&requires; constraint on
614
CYGVAR_KERNEL_THREADS_DATA. Even if an option is
615
loaded it may or may not be active, depending on what is happening
616
higher up in the hierarchy: if the C library's
617
CYGPKG_LIBC_STDIO component is disabled then some
618
other options such as CYGNUM_LIBC_STDIO_BUFSIZE
619
become irrelevant. In addition each option has both a boolean
620
enabled/disabled flag and a data part. For many options only the
621
boolean flag is of interest, while for others only the data part is of
622
interest. The &flavor; property can be used to control this:
623
624
625
626
flavor none
627
628
629
This flavor indicates that neither the boolean nor the data parts are
630
user-modifiable: the option is always enabled and the data is always
631
set to 1. The most common use for this is to have a
632
component that just acts as a placeholder in the hierarchy, allowing
633
various options to be grouped below it.
634
635
636
637
638
flavor bool
639
640
641
Only the boolean part of the option is user-modifiable. The data part
642
is fixed at 1.
643
644
645
646
647
flavor data
648
649
650
Only the data part of the option is user-modifiable. The boolean part
651
is fixed at enabled.
652
653
654
655
656
flavor booldata
657
658
659
Both the boolean and the data part of the option are user-modifiable.
660
661
662
663
664
665
For more details of &CDL; flavors and how a flavor affects expression
666
evaluation, and other consequences, see 
667
linkend="language.values">. The &flavor; property cannot be used for a
668
package because packages always have the booldata
669
flavor. Options and components have the bool flavor
670
by default, since most configuration choices are simple yes-or-no
671
choices. Interfaces have the data flavor by default.
672
673
674
The &calculated; property can be used for options which should not be
675
user-modifiable, but which instead are fixed by the target hardware or
676
determined from the current values of other options. In general
677
&calculated; options should be avoided, since they can be confusing to
678
users who need to figure out whether or not a particular option can
679
actually be changed. There are a number of valid uses for &calculated;
680
options, and quite a few invalid ones as well. The 
681
linkend="ref.calculated">reference packages should be consulted
682
for further details. The property takes an 
683
linkend="language.expression">ordinary &CDL; expression as
684
argument, for example:
685
686
687
# A constant on some target hardware, perhaps user-modifiable on other
688
# targets.
689
cdl_option CYGNUM_HAL_RTC_PERIOD {
690
    display       "Real-time clock period"
691
    flavor        data
692
    calculated    12500
693
}
694
695
696
The &calculated; property cannot be used for packages or interfaces.
697
The value of a package always corresponds to the version of that
698
package which is loaded, and this is under user control. Interfaces
699
are implicitly calculated, based on the number of active and enabled
700
implementors.
701
702
703
The &default-value; property is similar to &calculated;, but only
704
specifies a default value which users can modify. Again this property
705
is not relevant to packages or interfaces. A typical example would be:
706
707
708
cdl_option CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT {
709
    display       "Include GDB multi-threading debug support"
710
    requires      CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT
711
    default_value CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT
712
713
}
714
715
716
The &legal-values; property imposes a constraint on the possible
717
values of the data part of an option. Hence it is only applicable to
718
options with the data or
719
booldata flavors. It cannot be used for a package
720
since the only valid value for a package is its version number. The
721
arguments to the &legal-values; property should constitute a 
722
linkend="language.list-expression">&CDL; list expression.
723
724
725
cdl_option CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET {
726
    display       "Default Standard Time offset"
727
    flavor        data
728
    legal_values  -- -90000 to 90000
729
    default_value -- 0
730
731
}
732
733
734
The &active-if; property does not relate directly to an option's
735
value, but rather to its active state. Usually this is controlled via
736
the configuration hierarchy: if the
737
CYGPKG_LIBC_STDIO component is disabled then all
738
options below it are inactive and do not have any consequences.
739
In some cases the hierarchy does not provide sufficient control, for
740
example an option should only be active if two disjoint sets of
741
conditions are satisfied: the hierarchy could be used for one of these
742
conditions, and an additional &active-if; property could be used for
743
the other one. The arguments to &active-if; should constitute a
744
&CDL; goal expression.
745
746
747
# Do not provide extra semaphore debugging if there are no semaphores
748
cdl_option CYGDBG_KERNEL_INSTRUMENT_BINSEM {
749
    active_if CYGPKG_KERNEL_SYNCH
750
751
}
752
753
754
The &implements; property is related to the concept of 
755
linkend="language.interface">&CDL; interfaces. If an option is
756
active and enabled and it implements a particular interface then it
757
contributes 1 to that interface's value.
758
759
760
cdl_package CYGPKG_NET_EDB7XXX_ETH_DRIVERS {
761
    display       "Cirrus Logic ethernet driver"
762
    implements    CYGHWR_NET_DRIVERS
763
    implements    CYGHWR_NET_DRIVER_ETH0
764
765
}
766
767
768
The &requires; property is used to impose constraints on the user's
769
choices. For example it is unreasonable to expect the C library to
770
provide thread-safe implementations of certain functions if the
771
underlying kernel support has been disabled, or even if the kernel is
772
not being used at all.
773
774
775
cdl_option CYGSEM_LIBC_PER_THREAD_ERRNO {
776
    display       "Per-thread errno"
777
    doc           ref/ecos-ref.15.html
778
    requires      CYGVAR_KERNEL_THREADS_DATA
779
    default_value 1
780
781
}
782
783
784
The arguments to the &requires; property should be a 
785
linkend="language.goal-expression">&CDL; goal expression.
786
787
 
788
789
 
790
791
792
 
793
794
Generating the Configuration Header Files
795
796
When creating or updating a build tree the component framework will
797
also generate configuration header files, one per package. By default
798
it will generate a #define for each option,
799
component or interface that is active and enabled. For options with
800
the data or booldata flavors the
801
#define will use the option's data part, otherwise
802
it will use the constant 1. Typical output would
803
include:
804
805
806
#define CYGFUN_LIBC_TIME_POSIX 1
807
#define CYGNUM_LIBC_TIME_DST_DEFAULT_STATE -1
808
809
810
There are six properties which can be used to control the header file
811
generation process:
812
&define-header;,
813
&no-define;,
814
&define-format;,
815
&define;,
816
&if-define;, and
817
&define-proc;.
818
819
820
By default the component framework will generate a configuration
821
header file for each package based on the package's name: everything
822
up to and including the first underscore is discarded, the rest of the
823
name is lower-cased, and a .h suffix is appended.
824
For example the configuration header file for the kernel package
825
CYGPKG_KERNEL is 
826
class="headerfile">pkgconf/kernel.h. The &define-header;
827
property can be used to specify an alternative filename. This applies
828
to all the components and options within a package, so it can only be
829
used in the body of a &cdl-package; command. For example the following
830
specifies that the configuration header file for the SPARClite HAL
831
package is 
832
class="headerfile">pkgconf/hal_sparclite.h.
833
834
835
cdl_package CYGPKG_HAL_SPARCLITE {
836
    display "SPARClite architecture"
837
    parent        CYGPKG_HAL
838
    hardware
839
    define_header hal_sparclite.h
840
841
}
842
843
844
845
At present the main use for the &define-header; property is related
846
to hardware packages, see the reference
847
pages for more details.
848
849
850
851
The &no-define; property is used to suppress the generation of the
852
default #define. This can be useful if an option's
853
consequences are all related to the build process or to constraints,
854
and the option is never actually checked in any source code. It can
855
also be useful in conjunction with the &define;, &if-define; or
856
&define-proc; properties. The &no-define; property does not take any
857
arguments.
858
859
860
cdl_component CYG_HAL_STARTUP {
861
    display       "Startup type"
862
    flavor        data
863
    legal_values  { "RAM" "ROM" }
864
    default_value {"RAM"}
865
    no_define
866
    define -file system.h CYG_HAL_STARTUP
867
868
}
869
870
871
This example also illustrates the &define; property, which can be used
872
to generate a #define in addition to the default
873
one. It takes a single argument, the name of the symbol to be defined.
874
It also takes options to control the configuration header file in
875
which the symbol should be defined and the format to be used.
876
877
878
The &define-format; property can be used to control how the value part
879
of the default #define gets formatted. For example
880
a format string of  "0x%04x" could be used to
881
generate a four-digit hexadecimal number.
882
883
884
The &if-define; property is intended for use primarily to control
885
assertions, tracing, and similar functionality. It supports a specific
886
implementation model for these, allowing control at the grain of
887
packages or even individual source files. The 
888
linkend="ref.if-define">reference pages provide additional
889
information.
890
891
892
The &define-proc; property provides an escape mechanism for those
893
cases where something special has to happen at configuration header
894
file generation time. It takes a single argument, a fragment of &Tcl;
895
code, which gets executed when the header file is generated. This code
896
can output arbitrary data to the header file, or perform any other
897
actions that might be appropriate.
898
899
 
900
901
 
902
903
904
 
905
906
Controlling what gets Built
907
908
There are six properties which affect the build process:
909
&compile;,
910
&make;,
911
&make-object;,
912
&library;,
913
&include-dir;, and
914
&include-files;.
915
The last three apply to a package as a whole, and can only occur in
916
the body of a &cdl-package; command.
917
918
919
Most of the source files that go into a package should simply be
920
compiled with the appropriate compiler, selected by the target
921
architecture, and with the appropriate flags, with an additional set
922
defined by the target hardware and possible modifications on a
923
per-package basis. The resulting object files will go into the library
924
libtarget.a, which can then be linked against
925
application code. The &compile; property is used to list these source
926
files:
927
928
929
cdl_package CYGPKG_ERROR {
930
    display       "Common error code support"
931
    compile       strerror.cxx
932
    include_dir   cyg/error
933
934
}
935
936
937
The arguments to the &compile; property should be one or more source
938
files. Typically most of the sources will be needed for the package as
939
a whole, and hence they will be listed in one or more &compile;
940
properties in the body of the &cdl-package;. Some sources may be
941
specific to particular configuration options, in other words there is
942
no point in compiling them unless that option is enabled, in which
943
case the sources should be listed in a &compile; property in the
944
corresponding &cdl-option;, &cdl-component; or &cdl-interface; body.
945
946
947
Some packages may have more complicated build requirements, for
948
example they may involve a special target such as a linker script
949
which should not end up in the usual library, or they may involve
950
special build steps for generating an object file. The &make; and
951
&make-object; properties provide support for such requirements, for
952
example:
953
954
955
cdl_package CYGPKG_HAL_MN10300_AM33 {
956
    display       "MN10300 AM33 variant"
957
958
    make {
959
        <PREFIX>/lib/target.ld: <PACKAGE>/src/mn10300_am33.ld
960
        $(CC) -E -P -Wp,-MD,target.tmp -DEXTRAS=1 -xc $(INCLUDE_PATH) \
961
            $(CFLAGS) -o $@ $<
962
        @echo $@ ": \\" > $(notdir $@).deps
963
        @tail +2 target.tmp >> $(notdir $@).deps
964
        @echo >> $(notdir $@).deps
965
        @rm target.tmp
966
    }
967
}
968
969
970
For full details of custom build steps and the build process
971
generally, see .
972
973
974
By default all object files go into the library
975
libtarget.a. It is possible to override this at
976
the package level using the &library; property, but this should be
977
avoided since it complicates application development: instead of just
978
linking with a single library for all &eCos;-related packages, it
979
suddenly becomes necessary to link with several libraries.
980
981
982
The &include-dir; and &include-files; properties relate to a package's
983
exported header files. By default a package's header files will be
984
exported to the install/include
985
directory. This is the desired behavior for some packages like the C
986
library, since headers like 
987
class="headerfile">stdio.h should exist at that level.
988
However if all header files were to end up in that directory then
989
there would be a significant risk of a name clash. Instead it is
990
better for packages to specify some sub-directory for their exported
991
header files, for example:
992
993
994
cdl_package CYGPKG_INFRA {
995
    display       "Infrastructure"
996
    include_dir   cyg/infra
997
998
}
999
1000
1001
The various header files exported by the infrastructure, for example
1002
cyg_ass.h and 
1003
class="headerfile">cyg_trac.h will now end up in the
1004
install/include/cyg/infra
1005
sub-directory, where a name clash is very unlikely.
1006
1007
1008
For packages which follow the 
1009
linkend="package.hierarchy">directory layout conventions the
1010
component framework will assume that the package's
1011
include sub-directory contains
1012
all exported header files. If this is not the case, for example
1013
because the package is sufficiently simple that the layout convention
1014
is inappropriate, then the exported header files can be listed
1015
explicitly in an &include-files; property.
1016
1017
 
1018
1019
 
1020
1021
1022
 
1023
1024
Miscellaneous Properties
1025
1026
The &hardware; property is
1027
only relevant to packages. Some packages such as device drivers and
1028
HAL packages are hardware-specific, and generally it makes no sense to
1029
add such packages to a configuration unless the corresponding hardware
1030
is present on your target system. Typically hardware package selection
1031
happens automatically when you select your target. The &hardware;
1032
property should be used to identify a hardware-specific package, and
1033
does not take any arguments.
1034
1035
1036
cdl_package CYGPKG_HAL_MIPS {
1037
    display "MIPS architecture"
1038
    parent        CYGPKG_HAL
1039
    hardware
1040
    include_dir   cyg/hal
1041
    define_header hal_mips.h
1042
1043
}
1044
1045
1046
At present the &hardware; property is largely ignored by the component
1047
framework. This may change in future releases.
1048
1049
1050
 
1051
1052
 
1053
1054
 
1055
1056
1057
 
1058
1059
Option Naming Convention
1060
1061
All the options in a given configuration live in the same namespace.
1062
Furthermore it is not possible for two separate options to have the
1063
same name, because this would make any references to those options in
1064
&CDL; expressions ambiguous. A naming convention exists to avoid
1065
problems. It is recommended that component writers observe some or all
1066
of this convention to reduce the probability of name clashes with
1067
other packages.
1068
1069
1070
There is an important restriction on option names. Typically the
1071
component framework will output a #define for every
1072
active and enabled option, using the name as the symbol being defined.
1073
This requires that all names are valid C preprocessor symbols, a
1074
limitation that is enforced even for options which have the
1075
&no-define; property. Preprocessor symbols can be any sequence of
1076
lower case letters a-z, upper
1077
case letters, A-Z, the
1078
underscore character _, and the digits
1079
0-9. The first character must be
1080
a non-digit. Using an underscore as the first character is
1081
discouraged, because that may clash with reserved language
1082
identifiers. In addition there is a convention that preprocessor
1083
symbols only use upper case letters, and some component writers may
1084
wish to follow this convention.
1085
1086
1087
A typical option name could be something like
1088
CYGSEM_KERNEL_SCHED_BITMAP. This name consists of
1089
several different parts:
1090
1091
1092
1093
1094
The first few characters, in this case the three letters
1095
CYG, are used to identify the organization that
1096
produced the package. For historical reasons packages produced by Red
1097
Hat tend to use the prefix CYG rather than
1098
RHAT. Component writers should use their own
1099
prefix: even when cutting and pasting from an existing &CDL; script
1100
the prefix should be changed to something appropriate to their
1101
organization.
1102
1103
1104
It can be argued that a short prefix, often limited to upper case
1105
letters, is not sufficiently long to eliminate the possibility of
1106
name clashes. A longer prefix could be used, for example one based on
1107
internet domain names. However the C preprocessor has no concept of
1108
namespaces or import directives, so it would always
1109
be necessary to use the full option name in component source code
1110
which gets tedious - option names tend to be long enough as it is.
1111
There is a small increased risk of name clashes, but this risk is felt
1112
to be acceptable.
1113
1114
1115
1116
1117
The next three characters indicate the nature of the option, for
1118
example whether it affects the interface or just the implementation. A
1119
list of common tags is given below.
1120
1121
1122
1123
1124
The KERNEL_SCHED part indicates the location of the
1125
option within the overall hierarchy. In this case the option is part of
1126
the scheduling component of the kernel package. Having the hierarchy
1127
details as part of the option name can help in understanding
1128
configurable code and further reduces the probability of a name clash.
1129
1130
1131
1132
1133
The final part, BITMAP, identifies the option
1134
itself.
1135
1136
1137
1138
1139
The three-character tag is intended to provide some additional
1140
information about the nature of the option. There are a number of
1141
pre-defined tags. However for many options there is a choice:
1142
options related to the platform should normally use
1143
HWR, but numerical options should normally use
1144
NUM; a platform-related numerical option such as
1145
the size of an interrupt stack could therefore use either tag.
1146
There are no absolute rules, and it is left to component writers to
1147
interpret the following guidelines:
1148
1149
1150
1151
xxxARC_
1152
1153
The ARC tag is intended for options related
1154
to the processor architecture. Typically such options will only occur
1155
in architectural or variant HAL packages.
1156
1157
1158
1159
xxxHWR_
1160
1161
The HWR tag is intended for options related to
1162
the specific target board. Typically such options will only occur in
1163
platform HAL packages.
1164
1165
1166
1167
xxxPKG_
1168
1169
This tag is intended for packages or components, in other words
1170
options which extend the configuration hierarchy. Arguably a
1171
COM tag would be more appropriate for
1172
components, but this could be confusing because of the considerable
1173
number of computing terms that begin with com.
1174
1175
1176
1177
xxxGLO_
1178
1179
This is intended for global configuration options, especially
1180
preferences.
1181
1182
1183
1184
xxxDBG_
1185
1186
The DBG tag indicates that the option is in
1187
some way related to debugging, for example it may enable assertions in
1188
some part of the system.
1189
1190
1191
1192
xxxTST_
1193
1194
This tag is for testing-related options. Typically these do not
1195
affect actual application code, instead they control the interaction
1196
between target-side test cases and a host-side testing infrastructure.
1197
1198
1199
1200
xxxFUN_
1201
1202
This is for configuration options which affect the interface of a
1203
package. There are a number of related tag which are also
1204
interface-related. xxxFUN_ is intended primarily
1205
for options that control whether or not one or more functions are
1206
provided by the package, but can also be used if none of the other
1207
interface-related tags is applicable.
1208
1209
1210
1211
xxxVAR_
1212
1213
This is analogous to FUN but controls the presence
1214
or absence of one or more variables or objects.
1215
1216
1217
1218
xxxCLS_
1219
1220
The CLS tag is intended only for packages that
1221
provide an object-oriented interface, and controls the presence or
1222
absence of an entire class.
1223
1224
1225
1226
xxxMFN_
1227
1228
This is also for object-orientated interfaces, and indicates the
1229
presence or absence of a member function rather than an entire class.
1230
1231
1232
1233
xxxSEM_
1234
1235
A SEM option does not affect the interface (or if
1236
does affect the interface, this is incidental). Instead it is used for
1237
options which have a fundamental effect on the semantic behavior of a
1238
package. For example the choice of kernel schedulers is semantic in
1239
nature: it does not affect the interface, in particular the function
1240
cyg_thread_create exists irrespective of which
1241
scheduler has been selected. However it does have a major impact on
1242
the system's behavior.
1243
1244
1245
1246
xxxIMP_
1247
1248
IMP is for implementation options. These do not
1249
affect either the interface or the semantic behavior (with the
1250
possible exception of timing-related changes). A typical
1251
implementation option controls whether or not a particular function or
1252
set of functions should get inlined.
1253
1254
1255
1256
xxxNUM_
1257
1258
This tag is for numerical options, for example the number of
1259
scheduling priority levels.
1260
1261
1262
1263
xxxDAT_
1264
1265
This is for data items that are not numerical in nature, for example a
1266
device name.
1267
1268
1269
1270
xxxBLD_
1271
1272
The BLD tag indicates an option that affects
1273
the build process, for example compiler flag settings.
1274
1275
1276
1277
xxxINT_
1278
1279
This should normally be used for &CDL; interfaces, which is a language
1280
construct that is largely independent from the interface exported by a
1281
package via its header files. For more details of &CDL; interfaces
1282
see .
1283
1284
1285
1286
xxxPRI_
1287
1288
This tag is not normally used for configuration options. Instead
1289
it is used by &CDL; scripts to pass additional private information to
1290
the source code via the configuration header files, typically inside a
1291
&define-proc; property.
1292
1293
1294
1295
xxxSRC_
1296
1297
This tag is not normally used for configuration options. Instead
1298
it can be used by package source code to interact with such options,
1299
especially in the context of the &if-define; property.
1300
1301
1302
1303
 
1304
1305
There is one special case of a potential name clash that is worth
1306
mentioning here. When the component framework generates a
1307
configuration header file for a given package, by default it will use
1308
a name derived from the package name (the &define-header; property can
1309
be used to override this). The file name is constructed from the
1310
package name by removing everything up to and including the first
1311
underscore, converting the remainder of the name to lower case, and
1312
appending a .h suffix. For example the kernel
1313
package CYGPKG_KERNEL will involve a header file
1314
pkgconf/kernel.h. If a
1315
configuration contained some other package
1316
XYZPKG_KERNEL then this would attempt to use the
1317
same configuration header file, with unfortunate effects. Case
1318
sensitivity could introduce problems as well, so a package
1319
xyzpkg_kernel would involve the same problem. Even
1320
if the header file names preserved the case of the package name, not
1321
all file systems are case sensitive. There is no simple solution to
1322
this problem. Changing the names of the generated configuration header
1323
files would involve a major incompatible change to the interface, to
1324
solve a problem which is essentially hypothetical in nature.
1325
1326
 
1327
1328
 
1329
1330
1331
 
1332
1333
An Introduction to Tcl
1334
 
1335
1336
All &CDL; scripts are implemented as &Tcl; scripts, and are read in by
1337
running the data through a standard &Tcl; interpreter, extended with a
1338
small number of additional commands such as
1339
cdl_option and cdl_component.
1340
Often it is not necessary to know the full details of &Tcl; syntax.
1341
Instead it is possible to copy an existing script, perform some copy
1342
and paste operations, and make appropriate changes to names and to
1343
various properties. However there are also cases where an
1344
understanding of &Tcl; syntax is very desirable, for example:
1345
1346
 
1347
1348
cdl_option CYGDAT_UITRON_MEMPOOLFIXED_EXTERNS {
1349
    display       "Externs for initialization"
1350
    flavor        data
1351
    default_value {"static char fpool1[ 2000 ], \\\n\
1352
                                fpool2[ 2000 ], \\\n\
1353
                                fpool3[ 2000 ];"}
1354
1355
}
1356
1357
 
1358
1359
This causes the &cdl-option; command to be executed, which in turn
1360
evaluates its body in a recursive invocation of the &Tcl; interpreter.
1361
When the &default-value; property is encountered the braces around the
1362
value part are processed by the interpreter, stopping it from doing
1363
further processing of the braced contents (except for backslash
1364
processing at the end of a line, that is special). In particular it
1365
prevents command substitution for
1366
[ 2000 ]. A single argument will be
1367
passed to the &default-value; command which expects a &CDL;
1368
expression, so the expression parsing code is passed the following:
1369
1370
 
1371
1372
"static char fpool1[ 2000 ], \\\n fpool2[ 2000 ], \\\n fpool3[ 2000 ];"
1373
1374
 
1375
1376
The &CDL; expression parsing code will treat this as a simple string
1377
constant, as opposed to a more complicated expression involving other
1378
options and various operators. The string parsing code will perform
1379
the usual backslash substitutions so the actual default value will be:
1380
1381
1382
static char fpool1[ 2000 ], \
1383
 fpool2[ 2000 ], \
1384
 fpool3[ 2000 ];
1385
1386
 
1387
1388
If the user does not modify the option's value then the following
1389
will be generated in the appropriate configuration header file:
1390
1391
1392
#define CYGDAT_UITRON_MEMPOOLFIXED_EXTERNS static char fpool1[ 2000 ], \
1393
 fpool2[ 2000 ], \
1394
 fpool3[ 2000 ];
1395
1396
 
1397
1398
Getting this desired result usually requires an understanding of both
1399
&Tcl; syntax and &CDL; expression syntax. Sometimes it is possible to
1400
substitute a certain amount of trial and error instead, but this may
1401
prove frustrating. It is also worth pointing out that many &CDL;
1402
scripts do not involve this level of complexity. On the other hand,
1403
some of the more advanced features of the &CDL; language involve
1404
fragments of &Tcl; code, for example the &define-proc; property. To
1405
use these component writers will need to know about the full &Tcl;
1406
language as well as the syntax.
1407
1408
1409
Although the current example may seem to suggest that &Tcl; is rather
1410
complicated, it is actually a very simple yet powerful scripting
1411
language: the syntax is defined by just eleven rules. On occasion this
1412
simplicity means that Tcl's behavior is subtly different from other
1413
languages, which can confuse newcomers.
1414
1415
1416
When the Tcl interpreter is passed some data such as
1417
puts Hello, it splits this data into a command
1418
and its arguments. The command will be terminated by a newline or by a
1419
semicolon, unless one of the quoting mechanisms is used. The command
1420
and each of its arguments are separated by white space. So in the
1421
following example:
1422
1423
1424
puts Hello
1425
set x 42
1426
1427
1428
This will result in two separate commands being executed. The first
1429
command is puts and is passed a single argument,
1430
Hello. The second command is set
1431
and is passed two arguments, x and
1432
42. The intervening newline character serves to
1433
terminate the first command, and a semi-colon separator could be used
1434
instead:
1435
1436
1437
puts Hello;set x 42
1438
1439
1440
Any white space surrounding the semicolon is just ignored because it
1441
does not serve to separate arguments.
1442
1443
1444
Now consider the following:
1445
1446
1447
set x Hello world
1448
1449
1450
This is not valid &Tcl;. It is an attempt to invoke the
1451
set command with three arguments:
1452
x, Hello, and
1453
world. The set only takes two
1454
arguments, a variable name and a value, so it is necessary to combine
1455
the data into a single argument by quoting:
1456
1457
1458
set x "Hello world"
1459
1460
1461
When the &Tcl; interpreter encounters the first quote character it
1462
treats all subsequent data up to but not including the closing quote
1463
as part of the current argument. The quote marks are removed by the
1464
interpreter, so the second argument passed to the
1465
set command is just Hello world
1466
without the quote characters. This can be significant in the context
1467
of &CDL; scripts. For example:
1468
1469
1470
cdl_option CYG_HAL_STARTUP {
1471
1472
    default_value "RAM"
1473
}
1474
1475
1476
The &Tcl; interpreter strips off the quote marks so the &CDL;
1477
expression parsing code sees RAM instead of
1478
"RAM". It will treat this as a reference to
1479
some unknown option RAM rather than as a string
1480
constant, and the expression evaluation code will use a value of
1481
0 when it encounters an option that is not
1482
currently loaded. Therefore the option
1483
CYG_HAL_STARTUP ends up with a default value of
1484
0. Either braces or backslashes should be used to
1485
avoid this, for example
1486
default_value { "RAM" }.
1487
1488
1489
1490
There are long-term plans to implement some sort of &CDL; validation
1491
utility cdllint which
1492
could catch common errors like this one.
1493
1494
1495
1496
A quoted argument continues until the closing quote character is
1497
encountered, which means that it can span multiple lines. Newline or
1498
semicolon characters do not terminate the current command in such
1499
cases. &description; properties usually make use of this:
1500
1501
1502
cdl_package CYGPKG_ERROR {
1503
    description   "
1504
        This package contains the common list of error and
1505
        status codes. It is held centrally to allow
1506
        packages to interchange error codes and status
1507
        codes in a common way, rather than each package
1508
        having its own conventions for error/status
1509
        reporting. The error codes are modelled on the
1510
        POSIX style naming e.g. EINVAL etc. This package
1511
        also provides the standard strerror() function to
1512
        convert error codes to textual representation."
1513
1514
}
1515
1516
1517
The &Tcl; interpreter supports much the same forms of backslash
1518
substitution as other common programming languages. Some backslash
1519
sequences such as \n will be replaced by the
1520
appropriate character. The sequence \\ will be
1521
replaced by a single backslash. A backslash at the very end of a line
1522
will cause that backslash, the newline character, and any white space
1523
at the start of the next line to be replaced by a single space. Hence
1524
the following two Tcl commands are equivalent:
1525
1526
1527
puts  "Hello\nworld\n"
1528
puts \
1529
"Hello
1530
world
1531
"
1532
1533
1534
If a &description; string needs to contain quote marks or other
1535
special characters then backslash escapes can be used. In addition to
1536
quote and backslash characters, the Tcl interpreter treats square
1537
brackets, the $ character, and braces specially.
1538
Square brackets are used for command substitution, for example:
1539
1540
1541
puts "The answer is [expr 6 * 9]"
1542
1543
1544
When the Tcl interpreter encounters the square brackets it will treat
1545
the contents as another command that should be executed first, and the
1546
result of executing that is used when continuing to process the
1547
script. In this case the Tcl interpreter will execute the command
1548
expr 6 * 9, yielding a result of 42
1549
1550
1551
It is possible that some versions of the Tcl interpreter will instead
1552
produce a result of 54 when asked to multiply six by nine. Appropriate
1553
reference
1554
documentation should be consulted for more information on why
1555
42 is in fact the correct answer.
1556
1557
1558
and then the
1559
Tcl interpreter will execute puts "The answer is 42".
1560
It should be noted that the interpreter performs only one level
1561
of substitution: if the result of performing command substitution
1562
performs further special characters such as square brackets then these
1563
will not be treated specially.
1564
1565
1566
Command substitution will not prove useful for many &CDL; scripts,
1567
except for e.g. a &define-proc; property which involves a fragment of
1568
&Tcl; code. Potentially there are some interesting uses, for example
1569
to internationalize &display; strings. However care does have to be
1570
taken to avoid unexpected command substitution, for example if an
1571
option description involves square brackets then typically these would
1572
require backslash-escapes.
1573
1574
1575
The $ character is used in Tcl scripts to perform
1576
variable substitution:
1577
1578
1579
set x [expr 6 * 9]
1580
puts "The answer is $x"
1581
1582
1583
Variable substitution, like command substitution, is unlikely to
1584
prove useful for many &CDL; scripts except in the context of
1585
&Tcl; fragments. If it is necessary to have a $
1586
character then a backslash escape may have to be used.
1587
1588
1589
Braces are used to collect a sequence of characters into a single
1590
argument, just like quotes. The difference is that variable, command
1591
and backslash substitution do not occur inside braces (with the
1592
sole exception of backslash substitution at the end of a line).
1593
Therefore given a line in a &CDL; script such as:
1594
1595
1596
default_value {"RAM"}
1597
1598
1599
The braces are stripped off by the &Tcl; interpreter, leaving
1600
"RAM" which will be handled as a string constant by
1601
the expression parsing code. The same effect could be achieved using
1602
one of the following:
1603
1604
1605
default_value \"RAM\"
1606
default_value "\"RAM\""
1607
1608
1609
Generally the use of braces is less confusing. At this stage it is
1610
worth noting that the basic format of &CDL; data makes use of
1611
braces:
1612
1613
1614
cdl_option <name> {
1615
1616
};
1617
1618
1619
The &cdl-option; command is passed two arguments, a name and a body,
1620
where the body consists of everything inside the braces but not the
1621
braces themselves. This body can then be executed in a recursive
1622
invocation of the &Tcl; interpreter. If a &CDL; script contains
1623
mismatched braces then the interpreter is likely to get rather
1624
confused and the resulting diagnostics may be difficult to understand.
1625
1626
1627
Comments in Tcl scripts are introduced by a hash character
1628
#. However, a hash character only introduces a
1629
comment if it occurs where a command is expected. Consider the
1630
following:
1631
1632
1633
# This is a comment
1634
puts "Hello" # world
1635
1636
1637
The first line is a valid comment, since the hash character occurs
1638
right at the start where a command name is expected. The second line
1639
does not contain a comment. Instead it is an attempt to invoke the
1640
puts command with three arguments:
1641
Hello, # and
1642
world. These are not valid arguments for the
1643
puts command so an error will be raised.
1644
If the second line was rewritten as:
1645
1646
1647
puts "Hello"; # world
1648
1649
1650
then this is a valid Tcl script. The semicolon identifies the end of
1651
the current command, so the hash character occurs at a point where the
1652
next command would start and hence it is interpreted as the start of a
1653
comment.
1654
1655
1656
This handling of comments can lead to subtle behavior. Consider the
1657
following:
1658
1659
1660
cdl_option WHATEVER {
1661
# This is a comment }
1662
    default_value 0
1663
1664
}
1665
1666
1667
Consider the way the Tcl interpreter processes this. The command name
1668
and the first argument do not pose any special difficulties. The
1669
opening brace is interpreted as the start of the next argument, which
1670
continues until a closing brace is encountered. In this case the
1671
closing brace occurs on the second line, so the second argument passed
1672
to cdl_option is
1673
\n    # This is a comment
1674
. This second argument is processed in a recursive
1675
invocation of the Tcl interpreter and does not contain any commands,
1676
just a comment. Top-level script processing then resumes, and the next
1677
command that is encountered is default_value. Since
1678
the parser is not currently processing a configuration option this is
1679
an error. Later on the Tcl interpreter would encounter a closing brace
1680
by itself, which is also an error.
1681
1682
1683
For component writers who need more information about &Tcl;,
1684
especially about the language rather than the syntax, various
1685
resources are available. A reasonable starting point is the
1686
Scriptics developer
1687
web site.
1688
1689
1690
 
1691
1692
1693
 
1694
1695
Values and Expressions
1696
 
1697
1698
 
1699
1700
It is fairly reasonable to expect that enabling or disabling a
1701
configuration option such as
1702
CYGVAR_KERNEL_THREADS_DATA in some way affects its
1703
value. This will have an effect on any
1704
expressions that reference this option such as
1705
requires CYGVAR_KERNEL_THREADS_DATA. It will
1706
also affect the consequences of that option: how it affects the build
1707
process and what happens to any constraints that
1708
CYGVAR_KERNEL_THREADS_DATA may impose (as opposed
1709
to constraints on this option imposed by others).
1710
1711
1712
In a language like C the handling of variables is relatively
1713
straightforward. If a variable x gets referenced in
1714
an expression such as if (x != 0),
1715
and that variable is not defined anywhere, then the code will fail to
1716
build, typically with an unresolved error at link-time. Also in C
1717
a variable x does not live in any hierarchy, so its
1718
value for the purposes of expression evaluation is not affected by
1719
anything else. C variables also have a clear type such as
1720
int or long double.
1721
1722
1723
In &CDL; things are not so straightforward.
1724
1725
 
1726
1727
1728
 
1729
1730
1731
 
1732
Option Values
1733
 
1734
1735
There are four factors which go into an option's value:
1736
1737
1738
1739
1740
An option may or may not be loaded.
1741
1742
1743
1744
1745
If the option is loaded, it may or may not be active.
1746
1747
1748
1749
1750
Even if the option is active, it may or may not be enabled.
1751
1752
1753
1754
1755
If the option is loaded, active and enabled then it will have some
1756
associated data which constitutes its value.
1757
1758
1759
1760
 
1761
1762
1763
 
1764
1765
Is the Option Loaded?
1766
 
1767
1768
At any one time a configuration will contain only a subset of all
1769
possible packages. In fact it is impossible to combine certain
1770
packages in a single configuration. For example architectural HAL
1771
packages should contain a set of options defining endianness, the
1772
sizes of basic data types and so on (many of which will of course be
1773
constant for any given architecture). Any attempt to load two
1774
architectural HAL packages into a configuration will fail because of
1775
the resulting name clash. Since &CDL; expressions can reference
1776
options in other packages, and often need to do so, it is essential to
1777
define the resulting behavior.
1778
1779
1780
One complication is that the component framework does not know about
1781
every single option in every single package. Obviously it cannot know
1782
about packages from arbitrary third parties which have not been
1783
installed. Even for packages which have been installed, the current
1784
repository database does not hold details of every option, only of the
1785
packages themselves. If a &CDL; expression contains a reference to
1786
some option CYGSEM_KERNEL_SCHED_TIMESLICE then the
1787
component framework will only know about this option if the kernel
1788
package is actually loaded into the current configuration. If the
1789
package is not loaded then theoretically the framework might guess
1790
that the option is somehow related to the kernel by examining the
1791
option name but this would not be robust: the option could easily be
1792
part of some other package that violates the naming convention.
1793
1794
1795
Assume that the user is building a minimal configuration which does
1796
not contain the kernel package, but does have other packages which
1797
contain the following constraints:
1798
1799
1800
    requires CYGPKG_KERNEL
1801
    requires CYGPKG_KERNEL_THREADS_DATA
1802
    requires !CYGSEM_KERNEL_SCHED_TIMESLICE
1803
1804
1805
Clearly the first constraint is not satisfied because the kernel is
1806
not loaded. The second constraint is also not satisfied. The third
1807
constraint is trivially satisfied: if there is no kernel then the
1808
kernel's timeslicing support cannot possibly be enabled.
1809
1810
1811
Any options which are not in the current configuration are handled as
1812
follows:
1813
1814
1815
1816
1817
Any references to that option will evaluate to 0,
1818
so requires !CYGSEM_KERNEL_SCHED_TIMESLICE will
1819
be satisfied but
1820
requires CYGSEM_KERNEL_THREADS_DATA will not
1821
be satisfied.
1822
1823
1824
1825
1826
An option that is not loaded has no consequences on the build process.
1827
It cannot directly result in any #define's in a
1828
configuration header file, nor in any files being compiled. This is
1829
only reasonable: if the option is not loaded then the component
1830
framework has no way of knowing about any &compile; or similar
1831
properties. An option that is not loaded can have indirect
1832
consequences by being referenced in &CDL; expressions.
1833
1834
1835
1836
1837
An option that is not loaded cannot impose any constraints on the rest
1838
of the configuration. Again this is the only reasonable behavior: if
1839
the option is not loaded then any associated &requires; or
1840
&legal-values; properties will not be known.
1841
1842
1843
1844
 
1845
1846
 
1847
1848
1849
 
1850
1851
Is the Option Active
1852
 
1853
1854
The next issue to consider is whether or not a particular option is
1855
active. Configuration options are organized in a hierarchy of
1856
components and sub-components. For example the C library package
1857
contains a component CYGPKG_LIBC_STDIO containing
1858
all the options related to standard I/O. If a user disables the
1859
component as a whole then all the options below it become inactive: it
1860
makes no sense to disable all stdio functionality and then manipulate
1861
the buffer sizes.
1862
1863
1864
Inactive is not quite the same as disabled, although the effects are
1865
similar. The value of an inactive option is preserved. If the user
1866
modifies a buffer size option, then disables the whole stdio
1867
component, the buffer size value remains in case the stdio component
1868
is re-enabled later on. Some tools such as the graphical configuration
1869
tool will treat inactive options specially, for example such options
1870
may be grayed out.
1871
1872
1873
The active or inactive state of an option may affect other packages.
1874
For example a package may use the sprintf
1875
function and require support for floating point conversions, a
1876
constraint that is not satisfied if the relevant option is inactive.
1877
It is necessary to define exactly what it means for an option to be
1878
inactive:
1879
1880
1881
1882
1883
An option is inactive if its parent is either inactive or disabled.
1884
For example if CYGPKG_LIBC_STDIO is disabled then
1885
all the options and sub-components become inactive; since
1886
CYGPKG_LIBC_STDIO_FLOATING_POINT is now inactive,
1887
CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT is inactive
1888
as well.
1889
1890
1891
1892
1893
Options may also be inactive as a result of an &active-if; property.
1894
This is useful if a particular option is only relevant if two or more
1895
disjoint sets of conditions need to be satisfied, since the
1896
hierarchical structure can only cope with at most one such set.
1897
1898
1899
1900
1901
If an option is inactive then any references to that option in &CDL;
1902
expressions will evaluate to 0. Hence a constraint
1903
of the form
1904
requires CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
1905
is not satisfied if the entire stdio component is disabled.
1906
1907
1908
1909
1910
An option that is inactive has no consequences on the build process.
1911
No #define will be generated. Any &compile; or
1912
similar properties will be ignored.
1913
1914
1915
1916
1917
An option that is inactive cannot impose any constraints on the rest
1918
of the configuration. For example
1919
CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT has a
1920
dependency requires CYGPKG_LIBM, but if all of
1921
the stdio functionality is disabled then this constraint is ignored
1922
(although of course there may be other packages which have a
1923
dependency on CYGPKG_LIBM.
1924
1925
1926
1927
1928
 
1929
1930
1931
 
1932
1933
Is the Option Enabled? What is the Data?
1934
 
1935
1936
The majority of configuration options are boolean in nature, so the
1937
user can either enable or disable some functionality. Some options are
1938
different. For example CYGNUM_LIBC_STDIO_BUFSIZE is
1939
a number, and CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE is
1940
a string corresponding to a device name. A few options like
1941
CYGDAT_UITRON_TASK_EXTERNS can get very
1942
complicated. &CDL; has to cope with this variety, and define the exact
1943
behavior of the system in terms of constraints and build-time
1944
consequences.
1945
1946
1947
In &CDL; the value of an option consists of two parts. There is a
1948
boolean part, controlling whether or not the option is enabled. There
1949
is also a data part, providing additional information. For most
1950
options one of these parts is fixed, as controlled by the option's
1951
&flavor; property:
1952
1953
1954
1955
1956
  
1957
    Flavor
1958
    Enabled
1959
    Data
1960
  
1961
1962
1963
  
1964
    none
1965
    Always enabled
1966
    1, not modifiable
1967
  
1968
  
1969
    bool
1970
    User-modifiable
1971
    1, not modifiable
1972
  
1973
  
1974
    data
1975
    Always enabled
1976
    User-modifiable
1977
  
1978
  
1979
    booldata
1980
    User-modifiable
1981
    User-modifiable
1982
  
1983
1984
1985
1986
1987
The effects of the boolean and data parts are as follows:
1988
1989
1990
1991
1992
If an option is disabled, in other words if the boolean part is false,
1993
then any references to that option in &CDL; expressions will evaluate
1994
to 0. This is the same behavior as for inactive
1995
options. The data part is not relevant. The none
1996
and data flavors specify that the option is always
1997
enabled, in which case this rule is not applicable.
1998
1999
2000
2001
2002
If an option is enabled then any references to that option in &CDL;
2003
expressions will evaluate to the option's data part. For two of the
2004
flavors, none and bool, this
2005
data part is fixed to the constant 1 which
2006
generally has the expected result.
2007
2008
2009
2010
2011
If a component or package is disabled then all sub-components and
2012
options immediately below it in the hierarchy are inactive. By a
2013
process of recursion this will affect all the nodes in the subtree.
2014
2015
2016
2017
2018
If an option is disabled then it can impose no constraints on the rest
2019
of the configuration, in particular &requires; and &legal-values;
2020
properties will be ignored. If an option is enabled then its
2021
constraints should be satisfied, or the component framework will
2022
report various conflicts. Note that the &legal-values; constraint only
2023
applies to the data part of the option's value, so it is only useful
2024
with the data and booldata
2025
flavors. Options with the none and
2026
data flavors are always enabled so their
2027
constraints always have to be satisfied (assuming the option is
2028
active).
2029
2030
2031
2032
2033
If an option is disabled then it has no direct consequences at
2034
build-time: no #define will be generated, no files
2035
will get compiled, and so on. If an option is active and enabled then
2036
all the consequences take effect. The option name and data part are
2037
used to generate the #define in the appropriate
2038
configuration header file, subject to various properties such as
2039
&no-define;, but the data part has no other effects on the build
2040
system.
2041
2042
2043
2044
2045
By default all options and components have the bool
2046
flavor: most options are boolean in nature, so making this the default
2047
allows for slightly more compact &CDL; scripts. Packages have the
2048
booldata flavor, where the data part always
2049
corresponds to the version of the package that is loaded into the
2050
configuration: changing this value corresponds to unloading the old
2051
version and loading in a different one.
2052
2053
 
2054
2055
&CDL; Flavors
2056
2057
The concept of &CDL; flavors tends to result in various discussions
2058
about why it is unnecessarily complicated, and would it not have been
2059
easier to do … However there are very good reasons why CDL
2060
works the way it does.
2061
2062
2063
The first common suggestion is that there is no need to have separate
2064
flavors bool, data, and so on. A
2065
boolean option could just be handled as a data option with legal
2066
values 0 and 1. The counter
2067
arguments are as follows:
2068
2069
2070
2071
2072
It would actually make &CDL; scripts more verbose. By default all
2073
options and components have the bool flavor, since
2074
most options are boolean in nature. Without a bool
2075
flavor it would be necessary to indicate explicitly what the legal
2076
values are somehow, e.g. with a &legal-values; property.
2077
2078
2079
2080
2081
The boolean part of an option's value has a very different effect from
2082
the data part. If an option is disabled then it has no consequences at
2083
build time, and can impose no constraints. A data
2084
option always has consequences and can impose constraints. To get the
2085
desired effect it would be necessary to add &CDL; data indicating that
2086
a value of 0 should be treated specially. Arguably
2087
this could be made built-in default behavior, although that would
2088
complicate options where 0 is a perfectly legal
2089
number, for example
2090
CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET.
2091
2092
2093
2094
2095
There would no replacement for a booldata option
2096
for which 0 is a valid value. Again some additional
2097
&CDL; syntax would be needed to express such a concept.
2098
2099
2100
2101
2102
Although initially it may seem confusing that an option's value has
2103
both a boolean and a data part, it is an accurate reflection of how
2104
configuration options actually work. The various alternatives would
2105
all make it harder to write &CDL; scripts.
2106
2107
2108
The next common suggestion is that the data part of a value should be
2109
typed in much the same way as C or C++ data types. For example it
2110
should be possible to describe
2111
CYGNUM_LIBC_STDIO_BUFSIZE as an integer value,
2112
rather than imposing &legal-values; constraints. Again there are very
2113
good reasons why this approach was not taken:
2114
2115
2116
2117
2118
The possible legal values for an integer are rarely correct for a
2119
&CDL; option. A constraint such as
2120
1 to 0x7fffffff is a bit more accurate,
2121
although if this option indicates a buffer size it is still not
2122
particularly good — very few targets will have enough
2123
memory for such a buffer. Forcing &CDL; writers to list the
2124
&legal-values; constraints explicitly should make them think a bit
2125
more about what values are actually sensible. For example
2126
CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET has legal
2127
values in the range -90000 to 90000,
2128
which helps the user to set a sensible value.
2129
2130
2131
2132
2133
Not all options correspond to simple data types such as integers.
2134
CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE is a C string,
2135
and would have to be expressed using something like
2136
char []. This introduces plenty of
2137
opportunities for confusion, especially since square brackets may get
2138
processed by the &Tcl; interpreter for command substitution.
2139
2140
2141
2142
2143
Some configuration options can get very complicated indeed, for
2144
example the default value of
2145
CYGDAT_UITRON_TASK_INITIALIZERS is:
2146
2147
2148
CYG_UIT_TASK( "t1", 1, task1, &stack1, CYGNUM_UITRON_STACK_SIZE ), \
2149
CYG_UIT_TASK( "t2", 2, task2, &stack2, CYGNUM_UITRON_STACK_SIZE ), \
2150
CYG_UIT_TASK( "t3", 3, task3, &stack3, CYGNUM_UITRON_STACK_SIZE ), \
2151
CYG_UIT_TASK( "t4", 4, task4, &stack4, CYGNUM_UITRON_STACK_SIZE )
2152
2153
2154
This would require &CDL; knowing about C macros, structures, arrays,
2155
static initializers, and so on. Adding such detailed knowledge about
2156
the C language to the component framework is inappropriate.
2157
2158
2159
2160
2161
&CDL; needs to be usable with languages other than C. At present this
2162
includes C++, in future it may include languages such as Java. Each
2163
language adds new data types and related complications, for example
2164
C++ classes and inheritance. Making &CDL; support a union of all data
2165
types in all possible languages is not sensible.
2166
2167
2168
2169
2170
The &CDL; approach of treating all data as a sequence of characters,
2171
possibly constrained by a &legal-values; property or other means, has
2172
the great advantage of simplicity. It also fits in with the &Tcl;
2173
language that underlies &CDL;.
2174
2175
2176
 
2177
2178
 
2179
2180
2181
 
2182
2183
Some Examples
2184
 
2185
2186
The following excerpt from the C library's &CDL; scripts can be used
2187
to illustrate how values and flavors work in practice:
2188
2189
2190
cdl_component CYGPKG_LIBC_RAND {
2191
    flavor        none
2192
    compile       stdlib/rand.cxx
2193
 
2194
    cdl_option CYGSEM_LIBC_PER_THREAD_RAND {
2195
        requires      CYGVAR_KERNEL_THREADS_DATA
2196
        default_value 0
2197
    }
2198
 
2199
    cdl_option CYGNUM_LIBC_RAND_SEED {
2200
        flavor        data
2201
        legal_values  0 to 0x7fffffff
2202
        default_value 1
2203
    }
2204
 
2205
    cdl_option CYGNUM_LIBC_RAND_TRACE_LEVEL {
2206
        flavor        data
2207
        legal_values  0 to 1
2208
        default_value 0
2209
    }
2210
}
2211
2212
2213
If the application does not require any C library functionality then
2214
it is possible to have a configuration where the C library is not
2215
loaded. This can be achieved by starting with the minimal template, or
2216
by starting with another template such as the default one and then
2217
explicitly unloading the C library package. If this package is not
2218
loaded then any references to the CYGPKG_LIBC_RAND
2219
component or any of its options will have a value of
2220
0 for the purposes of expression evaluation. No
2221
#define's will be generated for the component or
2222
any of its options, and the file stdlib/rand.cxx
2223
will not get compiled. There is nothing special about the C library
2224
here, exactly the same would apply for say a device driver that does
2225
not correspond to any of the devices on the target hardware.
2226
2227
2228
Assuming the C library is loaded, the next thing to consider is
2229
whether or not the component and its options are active. The component
2230
is layered immediately below the C library package itself, so if the
2231
package is loaded then it is safe to assume that the package is also
2232
enabled. Therefore the parent of CYGPKG_LIBC_RAND
2233
is active and enabled, and in the absence of any &active-if;
2234
properties CYGPKG_LIBC_RAND will be active as well.
2235
2236
2237
The component CYGPKG_LIBC_RAND has the flavor
2238
none. This means the component cannot be disabled.
2239
Therefore all the options in this component have an active and enabled
2240
parent, and in the absence of any &active-if; properties they are all
2241
active as well.
2242
2243
2244
The component's flavor none serves to group
2245
together all of the configuration options related to random number
2246
generation. This is particularly useful in the context of the
2247
graphical configuration tool, but it also helps when it comes to
2248
naming the options: all of the options begin with
2249
CYGxxx_LIBC_RAND, giving a clear hint about both
2250
the package and the component within that package. The flavor means
2251
that the component is always enabled and has the value
2252
1 for the purposes of expression evaluation. There
2253
will always be a single #define of the form:
2254
2255
2256
#define CYGPKG_LIBC_RAND 1
2257
2258
2259
In addition the file stdlib/rand.cxx will always
2260
get built. If the component had the default bool
2261
flavor then users would be able to disable the whole component,
2262
and one less file would need to be built. However random number
2263
generation is relatively simple, so the impact on eCos build times are
2264
small. Furthermore by default the code has no dependencies on other
2265
parts of the system, so compiling the code has no unexpected side
2266
effects. Even if it was possible to disable the component, the
2267
sensible default for most applications would still leave it enabled.
2268
The net result is that the flavor none is probably
2269
the most sensible one for this component. For other components the
2270
default bool flavor or one of the other flavors
2271
might be more appropriate.
2272
2273
2274
Next consider option CYGSEM_LIBC_PER_THREAD_RAND
2275
which can be used to get a per-thread random number seed, possibly
2276
useful if the application needs a consistent sequence of random
2277
numbers. In the absence of a &flavor; property this option will be
2278
boolean, and the &default-value; property means that it is disabled by
2279
default — reasonable since few applications need this
2280
particular functionality, and it does impose a constraint on the rest
2281
of the system. If the option is left disabled then no
2282
#define will be generated, and if there were any
2283
&compile; or similar properties these would not take effect. If the
2284
option is enabled then a #define will be generated,
2285
using the option's data part which is fixed at 1:
2286
2287
2288
#define CYGSEM_LIBC_PER_THREAD_RAND 1
2289
2290
2291
The CYGSEM_LIBC_PER_THREAD_RAND option has a
2292
&requires; constraint on
2293
CYGVAR_KERNEL_THREADS_DATA. If the C library option
2294
is enabled then the constraint should be satisfied, or else the
2295
configuration contains a conflict. If the configuration does not
2296
include the kernel package then
2297
CYGVAR_KERNEL_THREADS_DATA will evaluate to
2298
0 and the constraint is not satisfied. Similarly if
2299
the option is inactive or disabled the constraint will not be
2300
satisfied.
2301
2302
2303
CYGNUM_LIBC_RAND_SEED and
2304
CYGNUM_LIBC_RAND_TRACE_LEVEL both have the
2305
data flavor, so they are always enabled and the
2306
component framework will generate appropriate
2307
#define's:
2308
2309
2310
#define CYGNUM_LIBC_RAND_SEED 1
2311
#define CYGNUM_LIBC_RAND_SEED_1
2312
#define CYGNUM_LIBC_RAND_TRACE_LEVEL 0
2313
#define CYGNUM_LIBC_RAND_TRACE_LEVEL_0
2314
2315
2316
Neither option has a &compile; or similar property, but any such
2317
properties would take effect. Any references to these options in &CDL;
2318
expressions would evaluate to the data part, so a hypothetical
2319
constraint of the form
2320
{ requires CYGNUM_LIBC_RAND_SEED > 42 }
2321
would not be satisfied with the default values. Both options use a
2322
simple constant for the &default-value; expression. It would be
2323
possible to use a more complicated expression, for example the default
2324
for CYGNUM_LIBC_RAND_TRACE_LEVEL could be
2325
determined from some global debugging option or from a debugging
2326
option that applies to the C library as a whole. Both options also
2327
have a &legal-values; constraint, which must be satisfied since the
2328
options are active and enabled.
2329
2330
2331
2332
The value 0 is legal for both
2333
CYGNUM_LIBC_RAND_SEED and
2334
CYGNUM_LIBC_RAND_TRACE_LEVEL, so in a &CDL;
2335
expression there is no easy way of distinguishing between the options
2336
being absent or having that particular value. This will be addressed
2337
by future enhancements to the expression syntax.
2338
2339
2340
 
2341
2342
 
2343
2344
2345
 
2346
2347
2348
 
2349
2350
Ordinary Expressions
2351
 
2352
2353
Expressions in &CDL; follow a conventional syntax, for example:
2354
2355
2356
    default_value CYGGLO_CODESIZE > CYGGLO_SPEED
2357
    default_value { (CYG_HAL_STARTUP == "RAM" &&
2358
                     !CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS &&
2359
                     !CYGINT_HAL_USE_ROM_MONITOR_UNSUPPORTED &&
2360
                     !CYGSEM_HAL_POWERPC_COPY_VECTORS) ? 1 : 0 }
2361
    default_value { "\"/dev/ser0\"" }
2362
2363
2364
However there is a complication in that the various arguments to a
2365
&default-value; property will first get processed by a &Tcl;
2366
interpreter, so special characters like quotes and square brackets may
2367
get processed. Such problems can be avoided by enclosing non-trivial
2368
expressions in braces, as in the second example above. The way
2369
expression parsing actually works is as follows:
2370
2371
2372
2373
2374
The &Tcl; interpreter splits the line or lines into a command and its
2375
arguments. In the first &default-value; expression above the command
2376
is default_value and there are three arguments,
2377
CYGGLO_CODESIZE, > and
2378
CYGGLO_SPEED. In the second and third examples
2379
there is just one argument, courtesy of the braces.
2380
2381
2382
2383
2384
Next option processing takes place, so any initial arguments that
2385
begin with a hyphen will be interpreted as options. This can cause
2386
problems if the expression involves a negative number, so the
2387
special argument -- can be used to prevent option
2388
processing on the subsequent arguments.
2389
2390
2391
2392
2393
All of the arguments are now concatenated, with a single space in
2394
between each one. Hence the following two expressions are equivalent,
2395
even though they will have been processed differently up to this point.
2396
2397
2398
    default_value CYGGLO_CODESIZE > CYGGLO_SPEED
2399
    default_value {CYGGLO_CODESIZE > CYGGLO_SPEED}
2400
2401
2402
2403
2404
The expression parsing code now has a single string to process.
2405
2406
2407
2408
2409
&CDL; expressions consist of four types of element: references to
2410
configuration options, constant strings, integers, and floating point
2411
numbers. These are combined using a conventional set of operators: the
2412
unary operators -, ~ and
2413
!; the arithmetic operators +,
2414
-, *, / and
2415
%; the shift operators <<
2416
and >>; the comparison operators
2417
==, !=, <,
2418
<=, > and
2419
>=; the bitwise operators
2420
&, ^ and
2421
|; the logical operators && and
2422
||; the string concatenation operator
2423
.; and the ternary conditional operator
2424
A ? B : C. There is also support for
2425
some less widely available operators for logical equivalence and
2426
implication, and for a set of function-style operations. Bracketed
2427
sub-expressions are supported, and the operators have the usual
2428
precedence:
2429
2430
2431
2432
2433
2434
2435
2436
  
2437
    Priority
2438
    Operators
2439
    Category
2440
  
2441
2442
2443
  
2444
    16
2445
    references, constants
2446
    basic elements
2447
  
2448
  
2449
    15
2450
    f(a, b, c)
2451
    function calls
2452
  
2453
  
2454
    14
2455
    ~
2456
    bitwise not
2457
  
2458
  
2459
    14
2460
    !
2461
    logical not
2462
  
2463
  
2464
    14
2465
    -
2466
    arithmetic negation
2467
  
2468
  
2469
    13
2470
    * / %
2471
    multiplicative arithmetic
2472
  
2473
  
2474
    12
2475
    + - .
2476
    additive arithmetic and string concatenation
2477
  
2478
  
2479
    11
2480
    << >>
2481
    bitwise shifts
2482
  
2483
  
2484
    10
2485
    <= < > >=
2486
    inequality
2487
  
2488
  
2489
    9
2490
    == !=
2491
    comparison
2492
  
2493
  
2494
    8
2495
    &
2496
    bitwise and
2497
  
2498
  
2499
    7
2500
    ^
2501
    bitwise xor
2502
  
2503
  
2504
    6
2505
    |
2506
    bitwise or
2507
  
2508
  
2509
    5
2510
    &&
2511
    logical and
2512
  
2513
  
2514
    4
2515
    ||
2516
    logical or
2517
  
2518
  
2519
    3
2520
    xor, eqv
2521
    logical equivalance
2522
  
2523
  
2524
    2
2525
    implies
2526
    logical implication
2527
  
2528
  
2529
    1
2530
    ? :
2531
    conditional
2532
  
2533
2534
2535
2536
 
2537
2538
Function calls have the usual format of a name, an opening bracket,
2539
one or more arguments separated by commas, and a closing bracket. For
2540
example:
2541
2542
2543
    requires { !is_substr(CYGBLD_GLOBAL_CFLAGS, " -fno-rtti") }
2544
2545
2546
Functions will differ in the number of arguments and may impose
2547
restrictions on some or all of their arguments. For example it may be
2548
necessary for the first argument to be a reference to a configuration
2549
option. The available functions are described in 
2550
linkend="language.functions">.
2551
2552
2553
The logical xor operator evaluates to true if
2554
either the left hand side or the right hand side but not both evaluate
2555
to true The logical eqv operator evaluates to true
2556
if both the left and right hand sides evaluate to true, or if both
2557
evaluate to false. The implies operator evaluates
2558
to true either if the left hand side is false or if the right hand
2559
side is true, in other words A implies B
2560
has the same meaning as !A || B. An
2561
example use would be:
2562
2563
2564
    requires { is_active(CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE) implies
2565
                   (CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE >= (16 * 1024)) }
2566
2567
2568
This constraint would be satisfied if either the support for a main
2569
stack size is disabled, or if that stack is at least 16K. However if
2570
such a stack were in use but was too small, a conflict would be raised.
2571
2572
2573
A valid &CDL; identifier in an expression, for example
2574
CYGGLO_SPEED, will be interpreted as a reference to
2575
a configuration option by that name. The option does not have to be
2576
loaded into the current configuration. When the component framework
2577
evaluates the expression it will substitute in a suitable value that
2578
depends on whether or not the option is loaded, active, and enabled.
2579
The exact rules are described in 
2580
linkend="language.values.value">.
2581
2582
2583
A constant string is any sequence of characters enclosed in quotes.
2584
Care has to be taken that these quotes are not stripped off by the
2585
&Tcl; interpreter before the &CDL; expression parser sees them.
2586
Consider the following:
2587
2588
2589
    default_value "RAM"
2590
2591
2592
The quote marks will be stripped before the &CDL; expression parser
2593
sees the data, so the expression will be interpreted as a reference to
2594
a configuration option RAM. There is unlikely to be
2595
such an option, so the actual default value will be
2596
0. Careful use of braces or other &Tcl; quoting
2597
mechanisms can be used to avoid such problems.
2598
2599
2600
String constants consist of the data inside the quotes. If the data
2601
itself needs to contain quote characters then appropriate quoting is
2602
again necessary, for example:
2603
2604
2605
    default_value { "\"/dev/ser0\"" }
2606
2607
2608
An integer constant consists of a sequence of digits, optionally
2609
preceeded with the unary + or -
2610
operators. As usual the sequence 0x or
2611
0X can be used for hexadecimal data, and a leading
2612
0 indicates octal data. Internally the component
2613
framework uses 64-bit arithmetic for integer data. If a constant is
2614
too large then double precision arithmetic will be used instead.
2615
Traditional syntax is also used for double precision numbers, for
2616
example 3.141592 or -3E6.
2617
2618
2619
Of course this is not completely accurate: &CDL; is not a typed
2620
language, all data is treated as if it were a string. For example the
2621
following two lines are equivalent:
2622
2623
2624
    requires CYGNUM_UITRON_SEMAS > 10
2625
    requires { CYGNUM_UITRON_SEMAS > "10" }
2626
2627
2628
When an expression gets evaluated the operators will attempt
2629
appropriate conversions. The > comparison
2630
operator can be used on either integer or double precision numbers, so
2631
it will begin by attempting a string to integer conversion of both
2632
operands. If that fails it will attempt string to double conversions.
2633
If that fails as well then the component framework will report a
2634
conflict, an evaluation exception. If the conversions from string to
2635
integer are successful then the result will be either the string
2636
0 or the string 1, both of which
2637
can be converted to integers or doubles as required.
2638
2639
2640
It is worth noting that the expression
2641
CYGNUM_UITRON_SEMAS >10 is not ambiguous.
2642
&CDL; identifiers can never begin with a digit, so it is not possible
2643
for 10 to be misinterpreted as a reference to an
2644
identifier instead of as a string.
2645
2646
2647
Of course the implementation is slightly different again. The &CDL;
2648
language definition is such that all data is treated as if it were a
2649
string, with conversions to integer, double or boolean as and when
2650
required. The implementation is allowed to avoid conversions until
2651
they are necessary. For example, given
2652
CYGNUM_UITRON_SEMAS > 10 the
2653
expression parsing code will perform an immediate conversion from
2654
string to integer, storing the integer representation, and there is no
2655
need for a conversion by the comparison operator when the expression
2656
gets evaluated. Given
2657
{ CYGNUM_UITRON_SEMAS > "10" }
2658
the parsing code will store the string representation and a conversion
2659
happens the first time the expression is evaluated. All of this is an
2660
implementation detail, and does not affect the semantics of the
2661
language.
2662
2663
2664
Different operators have different requirements, for example the
2665
bitwise or operator only makes sense if both operands have an integer
2666
representation. For operators which can work with either integer or
2667
double precision numbers, integer arithmetic will be preferred.
2668
2669
2670
The following operators only accept integer operands:
2671
unary ~ (bitwise not), the shift operators
2672
<< and >>, and the
2673
bitwise operators &, | and
2674
^.
2675
2676
2677
The following operators will attempt integer arithmetic first, then
2678
double precision arithmetic: unary -,
2679
the arithmetic operators +, -,
2680
*, /, and %;
2681
and the comparision operators <,
2682
<=, > and
2683
>=.
2684
2685
2686
The equality == and inequality
2687
!= operators will first attempt integer conversion
2688
and comparison. If that fails then double precision will be attempted
2689
(although arguably using these operators on double precision data is
2690
not sensible). As a last resort string comparison will be used.
2691
2692
2693
The operators !, && and
2694
|| all work with boolean data. Any string that can
2695
be converted to the integer 0 or the double
2696
0.0 is treated as false, as is the empty string or
2697
the constant string false. Anything else is
2698
interpreted as true. The result is either 0 or
2699
1.
2700
2701
2702
The conditional operator ? : will interpret
2703
its first operand as a boolean. It does not perform any processing on
2704
the second or third operands.
2705
2706
2707
In practice it is rarely necessary to worry about any of these
2708
details. In nearly every case &CDL; expressions just work as expected,
2709
and there is no need to understand the full details.
2710
2711
 
2712
2713
2714
The current expression syntax does not meet all the needs of component
2715
writers. Some future enhancements will definitely be made, others are
2716
more controversial. The list includes the following:
2717
2718
2719
2720
2721
An option's value is determined by several different factors: whether
2722
or not it is loaded, whether or not it is active, whether or not it is
2723
enabled, and the data part. Currently there is no way of querying
2724
these individually. This is very significant in the context of options
2725
with the bool or booldata
2726
flavors, because there is no way of distinguishing between the option
2727
being absent/inactive/disabled or it being enabled with a data field
2728
of 0. There should be unary operators that allow
2729
any of the factors to be checked.
2730
2731
2732
2733
2734
Only the == and != operators can
2735
be used for string data. More string-related facilities are needed.
2736
2737
2738
2739
2740
An implies operator would be useful for many goal expression, where
2741
A implies B is equivalent to
2742
!A ||B.
2743
2744
2745
2746
2747
Similarly there is inadequate support for lists. On occasion it would
2748
be useful to write expressions involving say the list of implementors
2749
of a given CDL interface, for example a sensible default value could
2750
be the first implementor. Associated with this is a need for an
2751
indirection operator.
2752
2753
2754
2755
2756
Arguably extending the basic &CDL; expression syntax with lots of new
2757
operators is unnecessary, instead expressions should just support
2758
&Tcl; command substitution and then component writers could escape
2759
into &Tcl; scripts for complicated operations. This has some major
2760
disadvantages. First, the inference engine would no longer have any
2761
sensible way of interpreting an expression to resolve a conflict.
2762
Second, the component framework's value propagation code keeps track
2763
of which options get referenced in which expressions and avoids
2764
unnecessary re-evaluation of expressions; if expressions can involve
2765
arbitrary &Tcl; code then there is no simple way to eliminate
2766
unnecessary recalculations, with a potentially major impact on
2767
performance.
2768
2769
2770
2771
2772
 
2773
2774
2775
The current implementation of the component framework uses 64 bit
2776
arithmetic on all host platforms. Although this is adequate for
2777
current target architectures, it may cause problems in future. At some
2778
stage it is likely that an arbitrary precision integer arithmetic
2779
package will be used instead.
2780
2781
2782
 
2783
2784
 
2785
2786
2787
 
2788
2789
Functions
2790
 
2791
2792
CDL expressions can contain calls to a set of built-in functions
2793
using the usual syntax, for example;
2794
2795
2796
    requires { !is_substr(CYGBLD_GLOBAL_CFLAGS, "-fno-rtti") }
2797
2798
2799
The available function calls are as follows:
2800
2801
 
2802
2803
 
2804
2805
 
2806
  
2807
    get_data(option)
2808
    
2809
2810
This function can be used to obtain just the data part of a loaded
2811
configuration option, ignoring other factors such as whether or not
2812
the option is active and enabled. It takes a single argument which
2813
should be the name of a configuration option. If the specified option
2814
is not loaded in the current configuration then the function returns
2815
0, otherwise it returns the data part. Typically this function will
2816
only be used in conjunction with is_active and
2817
is_enabled for fine-grained control over the
2818
various factors that make up an option's value.
2819
2820
    
2821
  
2822
 
2823
2824
2825
 
2826
  
2827
    is_active(option)
2828
    
2829
2830
This function can be used to determine whether or not a particular
2831
configuration option is active. It takes a single argument which
2832
should be the name of an option, and returns a boolean. If the
2833
specified option is not loaded then the function will return false.
2834
Otherwise it will consider the state of the option's parents and
2835
evaluate any &active-if; properties, and return the option's current
2836
active state. A typical use might be:
2837
2838
2839
    requires { is_active(CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE) implies
2840
                   (CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE >= (16 * 1024)) }
2841
2842
2843
In other words either the specified configuration option must be
2844
inactive, for example because the current application does not use
2845
any related C library or POSIX functionality, or the stack size must
2846
be at least 16K.
2847
2848
2849
The configuration system's inference engine can attempt to satisfy
2850
constraints involving is_active in various
2851
different ways, for example by enabling or disabling parent
2852
components, or by examining &active-if; properties and manipulating
2853
terms in the associated expressions.
2854
2855
    
2856
  
2857
 
2858
2859
2860
 
2861
  
2862
    is_enabled(option)
2863
    
2864
2865
This function can be used to determine whether or not a particular
2866
configuration option is enabled. It takes a single argument which
2867
should be the name of an option, and returns a boolean. If the
2868
specified option is not loaded then the function will return false.
2869
Otherwise it will return the current boolean part of the option's
2870
value. The option's active or inactive state is ignored. Typically
2871
this function will be used in conjunction with
2872
is_active and possibly
2873
get_data to provide fine-grained control over the
2874
various factors that make up an option's value.
2875
2876
    
2877
  
2878
 
2879
2880
2881
 
2882
  
2883
    is_loaded(option)
2884
    
2885
2886
This function can be used to determine whether or not a particular
2887
configuration option is loaded. It takes a single argument which
2888
should be the name of an option, and returns a boolean. If the
2889
argument is a package then the is_loaded function
2890
provides little or no extra information, for example the following two
2891
constraints are usually equivalent:
2892
2893
2894
    requires { CYGPKG_KERNEL }
2895
    requires { is_loaded(CYGPKG_KERNEL) }
2896
2897
2898
However if the specified package is loaded but re-parented below a
2899
disabled component, or inactive as a result of an &active-if;
2900
property, then the first constraint would not be satisfied but the
2901
second constraint would. In other words the
2902
is_loaded makes it possible to consider in
2903
isolation one of the factors that are considered when CDL expressions
2904
are evaluated.
2905
2906
2907
The configuration system's inference engine will not automatically
2908
load or unload packages to satisfy is_loaded
2909
constraints.
2910
2911
    
2912
  
2913
 
2914
2915
2916
 
2917
  
2918
    is_substr(haystack, needle)
2919
    
2920
2921
This can be used to check whether or not a particular string is
2922
present in another string. It is used mainly for manipulating compiler
2923
flags. The function takes two arguments, both of which can be
2924
arbitrary expressions, and returns a boolean.
2925
2926
2927
is_substr has some understanding of word
2928
boundaries. If the second argument starts with a space character then
2929
that will match either a real space or the start of the string.
2930
Similarly if the second argument ends with a space character then that
2931
will match a real space or the end of the string. For example, all of
2932
the following conditions are satisfied:
2933
2934
2935
    is_substr("abracadabra", "abra")
2936
    is_substr("abracadabra", " abra")
2937
    is_substr("hocus pocus", " pocus")
2938
    is_substr("abracadabra", "abra ")
2939
2940
2941
The first is an exact match. The second is a match because the leading
2942
space matches the start of the string. The third is an exact match,
2943
with the leading space matching an actual space. The fourth is a match
2944
because the trailing space matches the end of the string. However, the
2945
following condition is not satisfied.
2946
2947
2948
    is_substr("abracadabra", " abra ")
2949
2950
2951
This fails to match at the start of the string because the trailing
2952
space is not matched by either a real space or the end of the string.
2953
Similarly it fails to match at the end of the string.
2954
2955
2956
If a constraint involving is_substr is not
2957
satisfied and the first argument is a reference to a configuration
2958
option, the inference engine will attempt to modify that option's
2959
value. This can be achieved either by appending the second argument to
2960
the current value, or by removing all occurrences of that argument
2961
from the current value.
2962
2963
2964
    requires { !is_substr(CYGBLD_GLOBAL_CFLAGS, " -fno-rtti ") }
2965
    requires { is_substr(CYGBLD_GLOBAL_CFLAGS, " -frtti ") }
2966
2967
2968
When data is removed the leading and trailing spaces will be left. For
2969
example, given an initial value of
2970
<CYGBLD_GLOBAL_CFLAGS of
2971
-g -fno-rtti -O2 the result will be
2972
-g  -O2 rather than -g-O2.
2973
2974
2975
If exact matches are needed, the function
2976
is_xsubstr can be used instead.
2977
2978
    
2979
  
2980
 
2981
2982
2983
 
2984
  
2985
    is_xsubstr(haystack, needle)
2986
    
2987
2988
This function checks whether or not the pattern string is an exact
2989
substring of the string being searched. It is similar to
2990
is_substr but uses exact matching only. In other
2991
words, leading or trailing spaces have to match exactly and will not
2992
match the beginning or end of the string being searched. The function
2993
takes two arguments, both of which can be arbitrary expressions, and
2994
returns a boolean. The difference between
2995
is_substr and is_xsubstr is
2996
illustrated by the following examples:
2997
2998
2999
    cdl_option MAGIC {
3000
        flavor data
3001
        default_value { "abracadabra" }
3002
    }
3003
3004
    requires { is_substr(MAGIC,  " abra") }
3005
    requires { is_xsubstr(MAGIC, " abra") }
3006
3007
3008
The first goal will be satisfied because the leading space in the
3009
pattern matches the beginning of the string. The second goal will not
3010
be satisfied initialy because there is no exact match, so the
3011
inference engine is likely to update the value of
3012
MAGIC to abracadabra abra which
3013
does give an exact match.
3014
3015
    
3016
  
3017
 
3018
3019
3020
 
3021
  
3022
    version_cmp(A, B)
3023
    
3024
3025
This function is used primarily to check that a sufficiently recent
3026
version of some other package
3027
is being used. It takes two arguments, both of which can be arbitrary
3028
expressions. In practice usually one of the arguments will be a
3029
reference to a package and the other will be a constant version
3030
string. The return value is -1 if the first argument is a more recent
3031
version then the second, 0 if the two arguments correspond to
3032
identical versions, and 1 if the first argument is an older version.
3033
For example the following constraint can be used to indicate that the
3034
current package depends on kernel functionality that only became
3035
available in version 1.3:
3036
3037
3038
    requires { version_cmp(CYGPKG_KERNEL, "v1.3") <= 0 }
3039
3040
    
3041
  
3042
 
3043
3044
 
3045
 
3046
3047
3048
3049
At this time it is not possible to define new functions inside a CDL
3050
script. Instead functions can only be added at the C++ level, usually
3051
by extending libcdl itself. This is partly because there is more to
3052
CDL functions than simple evaluation: associated with most functions
3053
is support for the inference engine, so that if a constraint involving
3054
a function is not currently satisfied the system may be able to find a
3055
solution automatically.
3056
3057
3058
 
3059
3060
 
3061
3062
3063
 
3064
3065
Goal Expressions
3066
 
3067
3068
The arguments to certain properties, notably &requires; and
3069
&active-if;, constitute a goal expression. As with an ordinary
3070
expression, all of the arguments get combined and then the expression
3071
parser takes over. The same care has to be taken with constant strings
3072
and anything else that may get processed by the Tcl interpreter, so
3073
often a goal expression is enclosed entirely in braces and the
3074
expression parsing code sees just a single argument.
3075
3076
3077
A goal expression is basically just a sequence of ordinary
3078
expressions, for example:
3079
3080
3081
    requires { CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
3082
               !CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
3083
               !CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT }
3084
3085
3086
This consists of three separate expressions, all of which should
3087
evaluate to a non-zero result. The same expression could be written
3088
as:
3089
3090
3091
    requires { CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS  &&
3092
               !CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT &&
3093
               !CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT }
3094
3095
3096
Alternatively the following would have much the same effect:
3097
3098
3099
    requires CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
3100
    requires !CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
3101
    requires !CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT
3102
3103
3104
Selecting between these alternatives is largely a stylistic choice.
3105
The first is slightly more concise than the others. The second is more
3106
likely to appeal to mathematical purists. The third is more amenable
3107
to cutting and pasting.
3108
3109
3110
The result of evaluating a goal expression is a boolean. If any part
3111
of the goal expression evaluates to the integer 0
3112
or an equivalent string then the result is false, otherwise it is
3113
true.
3114
3115
3116
The term “goal expression” relates to the component
3117
framework's inference engine: it is a description of a goal that
3118
should be satisfied for a conflict-free configuration. If a &requires;
3119
constraint is not satisfied then the inference engine will examine the
3120
goal expression: if there is some way of changing the configuration
3121
that does not introduce new conflicts and that will cause the goal
3122
expression to evaluate to true, the conflict can be resolved.
3123
3124
3125
The inference engine works with one conflict and hence one goal
3126
expression at a time. This means that there can be slightly different
3127
behavior if a constraint is specified using a single &requires;
3128
property or several different ones. Given the above example, suppose
3129
that none of the three conditions are satisfied. If a single goal
3130
expression is used then the inference engine might be able to satisfy
3131
only two of the three parts, but since the conflict as a whole cannot
3132
be resolved no part of the solution will be applied. Instead the user
3133
will have to resolve the entire conflict. If three separate goal
3134
expressions are used then the inference engine might well find
3135
solutions to two of them, leaving less work for the user. On the other
3136
hand, if a single goal expression is used then the inference engine
3137
has a bit more information to work with, and it might well find a
3138
solution to the entire conflict where it would be unable to find
3139
separate solutions for the three parts. Things can get very
3140
complicated, and in general component writers should not worry about
3141
the subtleties of the inference engine and how to manipulate its
3142
behavior.
3143
3144
3145
It is possible to write ambiguous goal expressions, for example:
3146
3147
3148
    requires CYGNUM_LIBC_RAND_SEED -CYGNUM_LIBC_RAND_TRACE_LEVEL > 5
3149
3150
3151
This could be parsed in two ways:
3152
3153
3154
    requires ((CYGNUM_LIBC_RAND_SEED - CYGNUM_LIBC_RAND_TRACE_LEVEL) > 5)
3155
    requires CYGNUM_LIBC_RAND_SEED && ((-CYGNUM_LIBC_RAND_TRACE_LEVEL) > 5)
3156
3157
3158
The goal expression parsing code will always use the largest ordinary
3159
expression for each goal, so the first interpretation will be used.
3160
In such cases it is a good idea to use brackets and avoid possible
3161
confusion.
3162
3163
 
3164
3165
 
3166
3167
3168
 
3169
3170
List Expressions
3171
 
3172
3173
The arguments to the &legal-values; property constitute a goal
3174
expression. As with an ordinary and goal expressions, all of the
3175
arguments get combined and then the expression parser takes over. The
3176
same care has to be taken with constant strings and anything else that
3177
may get processed by the Tcl interpreter, so often a list expression
3178
is enclosed entirely in braces and the expression parsing code sees
3179
just a single argument.
3180
3181
3182
Most list expressions take one of two forms:
3183
3184
3185
    legal_values <expr1> <expr2> <expr3> ...
3186
    legal_values <expr1> to <expr2>
3187
3188
3189
expr1, expr2 and so on are
3190
ordinary expressions. Often these will be constants or references to
3191
calculated options in the architectural HAL package, but it is
3192
possible to use arbitrary expressions when necessary. The first syntax
3193
indicates a list of possible values, which need not be numerical. The
3194
second syntax indicates a numerical range: both sides of the
3195
to must evaluate to a numerical value; if either
3196
side involves a floating point number then any floating point number
3197
in that range is legal; otherwise only integer values are legal;
3198
ranges are inclusive, so 4 is a valid value given a
3199
list expression 1 to ; if one or both
3200
sides of the to does not evaluate to a numerical
3201
value then this will result in a run-time conflict. The following
3202
examples illustrate these possibilities:
3203
3204
3205
    legal_values { "red" "green" "blue" }
3206
    legal_values 1 2 4 8 16
3207
    legal_values 1 to CYGARC_MAXINT
3208
    legal_values 1.0 to 2.0
3209
3210
3211
It is possible to combine the two syntaxes, for example:
3212
3213
3214
    legal_values 1 2 4 to CYGARC_MAXINT -1024 -20.0 to -10
3215
3216
3217
This indicates three legal values 1,
3218
2 and -1024, one
3219
integer range 4 to CYGARC_MAXINT, and one
3220
floating point range -20.0 to -10.0. In
3221
practice such list expressions are rarely useful.
3222
3223
3224
The identifier to is not reserved, so it is
3225
possible to have a configuration option with that name (although it
3226
violates every naming convention). Using that option in a list
3227
expression may however give unexpected results.
3228
3229
3230
The graphical configuration tool uses the &legal-values; list
3231
expression to determine how best to let users manipulate the option's
3232
value. Different widgets will be appropriate for different lists, so
3233
{ "red" "green" "blue" } might
3234
involve a pull-down option menu, and
3235
1 to 16 could involve a spinner. The
3236
exact way in which &legal-values; lists get mapped on to GUI widgets
3237
is not defined and is subject to change at any time.
3238
3239
3240
As with goal expressions, list expressions can be ambiguous. Consider
3241
the following hypothetical example:
3242
3243
3244
    legal_values CYGNUM_LIBC_RAND_SEED -CYGNUM_LIBC_RAND_TRACE_LEVEL
3245
3246
3247
This could be parsed in two ways:
3248
3249
3250
    legal_values (CYGNUM_LIBC_RAND_SEED - CYGNUM_LIBC_RAND_TRACE_LEVEL)
3251
    legal_values (CYGNUM_LIBC_RAND_SEED) (-CYGNUM_LIBC_RAND_TRACE_LEVEL)
3252
3253
3254
Both are legal. The list expression parsing code will always use the
3255
largest ordinary expression for each element, so the first
3256
interpretation will be used. In cases like this it is a good idea to
3257
use brackets and avoid possible confusion.
3258
3259
 
3260
3261
 
3262
3263
3264
 
3265
3266
3267
 
3268
3273
 
3274
3275
Interfaces
3276
 
3277
3278
For many configurability requirements, options provide sufficient
3279
expressive power. However there are times when a higher level of
3280
abstraction is appropriate. As an example, suppose that some package
3281
relies on the presence of code that implements the standard kernel
3282
scheduling interface. However the requirement is no more stringent
3283
than this, so the constraint can be satisfied by the mlqueue
3284
scheduler, the bitmap scheduler, or any additional schedulers that may
3285
get implemented in future. A first attempt at expressing the
3286
dependency might be:
3287
3288
3289
    requires CYGSEM_KERNEL_SCHED_MLQUEUE || CYGSEM_KERNEL_SCHED_BITMAP
3290
3291
3292
This constraint will work with the current release, but it is limited.
3293
Suppose there is a new release of the kernel which adds another
3294
scheduler such as a deadline scheduler, or suppose that there is a new
3295
third party package which adds such a scheduler. The package
3296
containing the limited constraint would now have to be updated and
3297
another release made, with possible knock-on effects.
3298
3299
3300
&CDL; interfaces provide an abstraction mechanism: constraints can be
3301
expressed in terms of an abstract concept, for example
3302
“scheduler”, rather than specific implementations such as
3303
CYGSEM_KERNEL_SCHED_MLQUEUE and
3304
CYGSEM_KERNEL_SCHED_BITMAP. Basically an interface
3305
is a calculated configuration option:
3306
3307
3308
cdl_interface CYGINT_KERNEL_SCHEDULER {
3309
    display  "Number of schedulers in this configuration"
3310
3311
}
3312
3313
3314
The individual schedulers can then implement this interface:
3315
3316
3317
cdl_option CYGSEM_KERNEL_SCHED_MLQUEUE {
3318
    display       "Multi-level queue scheduler"
3319
    default_value 1
3320
    implements    CYGINT_KERNEL_SCHEDULER
3321
3322
}
3323
 
3324
cdl_option CYGSEM_KERNEL_SCHED_BITMAP {
3325
    display       "Bitmap scheduler"
3326
    default_value 0
3327
    implements    CYGINT_KERNEL_SCHEDULER
3328
3329
}
3330
3331
3332
Future schedulers can also implement this interface. The value of an
3333
interface, for the purposes of expression evaluation, is the number of
3334
active and enabled options which implement this interface. Packages
3335
which rely on the presence of a scheduler can impose constraints such
3336
as:
3337
3338
3339
    requires CYGINT_KERNEL_SCHEDULER
3340
3341
3342
If none of the schedulers are enabled, or if the kernel package is not
3343
loaded, then CYGINT_KERNEL_SCHEDULER will evaluate
3344
to 0. If at least one scheduler is active and
3345
enabled then the constraint will be satisfied.
3346
3347
3348
Because interfaces have a calculated value determined by the
3349
implementors, the &default-value; and &calculated; properties are not
3350
applicable and should not appear in the body of a &cdl-interface;
3351
command. Interfaces have the data flavor by
3352
default, but the bool and
3353
booldata flavors may be specified instead. A
3354
bool interface is disabled if there are no active
3355
and enabled implementors, otherwise it is enabled. A
3356
booldata interface is disabled if there are no
3357
active and enabled implementors, otherwise it is enabled and has a
3358
value corresponding to the number of these implementors. Other
3359
properties such as &requires; and &compile; can be used as normal.
3360
3361
3362
Some component writers will not want to use interfaces in this way.
3363
The reasoning is that their code will only have been tested with the
3364
existing schedulers, so the &requires; constraint needs to be
3365
expressed in terms of those schedulers; it is possible that the
3366
component will still work with a new scheduler, but there are no
3367
guarantees. Other component writers may take a more optimistic view
3368
and assume that their code will work with any scheduler until proven
3369
otherwise. It is up to individual component writers to decide which
3370
approach is most appropriate in any given case.
3371
3372
3373
One common use for interfaces is to describe the hardware
3374
functionality provided by a given target. For example the &CDL;
3375
scripts for a TCP/IP package might want to know whether or not the
3376
target hardware has an ethernet interface. Generally it is not
3377
necessary for the TCP/IP stack to know exactly which ethernet hardware
3378
is present, since there should be a device driver which implements the
3379
appropriate functionality. In &CDL; terms the device drivers should
3380
implement an interface CYGHWR_NET_DRIVERS, and the
3381
&CDL; scripts for the TCP/IP stack can use this in appropriate
3382
expressions.
3383
3384
3385
3386
Using the term interface for this concept is
3387
sometimes confusing, since the term has various other meanings as
3388
well. In practice, it is often correct. If there is a configuration
3389
option that implements a given &CDL; interface, then usually this
3390
option will enable some code that provides a particular interface at
3391
the C or C++ level. For example an ethernet device driver implements
3392
the &CDL; interface CYGHWR_NET_DRIVERS, and also
3393
implements a set of C functions that can be used by the TCP/IP stack.
3394
Similarly CYGSEM_KERNEL_SCHED_MLQUEUE implements
3395
the &CDL; interface CYGINT_KERNEL_SCHEDULER and
3396
also provides the appropriate scheduling functions.
3397
3398
3399
 
3400
3401
 
3402
3403
3404
 
3405
3406
Updating the <database>ecos.db</database> database
3407
 
3408
3409
The current implementation of the component framework requires that
3410
all packages be present in a single component repository and listed in
3411
that repository's ecos.db database. This is not
3412
generally a problem for application developers who can consider the
3413
component repository a read-only resource, except when adding or
3414
removing packages via the administration tool. However it means that
3415
component writers need to do their development work inside a
3416
component repository as well, and update the database with details of
3417
their new package or packages. Future enhancements to the component
3418
framework may allow new components to be developed outside a
3419
repository.
3420
3421
3422
Like most files related to the component framework, the
3423
ecos.db database is actually a &Tcl; script.
3424
Typical package entries would look like this:
3425
3426
3427
package CYGPKG_LIBC {
3428
        alias           { "C library" libc clib clibrary }
3429
        directory       language/c/libc
3430
        script          libc.cdl
3431
        description  "
3432
This package enables compatibility with the ISO C standard - ISO/IEC
3433
9899:1990. This allows the user application to use well known standard
3434
C library functions, and in eCos starts a thread to invoke the user
3435
function main()"
3436
}
3437
 
3438
package CYGPKG_IO_PCI   {
3439
        alias           { "PCI configuration library" io_pci }
3440
        directory       io/pci
3441
        script          io_pci.cdl
3442
        hardware
3443
        description "
3444
           This package contains the PCI configuration library."
3445
}
3446
3447
3448
The package command takes two arguments, a name and
3449
a body. The name must be the same as in the &cdl-package; command in
3450
the package's top-level &CDL; script. The body can contain the
3451
following five commands: alias,
3452
directory, script,
3453
hardware and description.
3454
3455
 
3456
3457
3458
alias
3459
3460
3461
Each package should have one or more aliases. The first alias is
3462
typically used when listing the known packages, because a string like
3463
C library is a bit easier to read and
3464
understand than CYGPKG_LIBC. The other aliases are
3465
not used for output, but are accepted on input. For example the
3466
ecosconfig command-line
3467
tool will accept add libc as an option, as well
3468
as add CYGPKG_LIBC.
3469
3470
3471
3472
 
3473
3474
directory
3475
3476
3477
This is used to specify the location of the package relative to the
3478
root of the component repository. It should be noted that in the
3479
current component framework this location cannot be changed in
3480
subsequent releases of the package: if for some reason it is desirable
3481
to install a new release elsewhere in the repository, all the old
3482
versions must first be uninstalled; the database cannot hold two
3483
separate locations for one package.
3484
3485
3486
3487
 
3488
3489
script
3490
3491
3492
The script command specifies the location of the
3493
package's top-level &CDL; script, in other words the one containing the
3494
&cdl-package; definition. If the package follows the 
3495
linkend="package.hierarchy">directory layout conventions then
3496
this script will be in the cdl
3497
sub-directory, otherwise it will be relative to the package's top-level
3498
directory. Again once a release has been made this file should not
3499
change in later releases. In practice the top-level script is generally
3500
named after the package itself, so changing its name is unlikely to be
3501
useful.
3502
3503
3504
3505
 
3506
3507
hardware
3508
3509
3510
Packages which are tied to specific hardware, for example device
3511
drivers and HAL packages, should indicate this in both the
3512
&cdl-package; command of the &CDL; script and in the database entry.
3513
3514
3515
3516
 
3517
3518
description
3519
3520
3521
This should give a brief description of the package. Typically the
3522
text for the &description; property in the &cdl-package; command will
3523
be re-used.
3524
3525
3526
3527
3528
 
3529
3530
3531
Most of the information in the ecos.db file could
3532
be obtained by a relatively simple utility. This would be passed a
3533
single argument identifying a package's top-level &CDL; script. The
3534
directory path relative to the component repository root could be
3535
determined from the filename. The name, description
3536
and hardware fields could be obtained from the
3537
script's &cdl-package; command. The &display; property would supply
3538
the first alias, additional aliases could be obtained by extending the
3539
syntax of that property or by other means. Something along these lines
3540
may be provided by a future release of the component framework.
3541
3542
3543
3544
Currently the ecos.db database also holds
3545
information about the various targets. When porting to a new target it
3546
will be necessary to add information about the target to the database,
3547
as well as the details of the new platform HAL package and any related
3548
packages.
3549
3550
 
3551
3552
 
3553
3554
 
3555

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.