OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [libcdl/] [doc/] [language.sgml] - Blame information for rev 26

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

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

powered by: WebSVN 2.1.0

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