1 /* --COPYRIGHT--,EPL
2 * Copyright (c) 2008 Texas Instruments and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Texas Instruments - initial implementation
10 *
11 * --/COPYRIGHT--*/
12 /*
13 * ======== Program.xdc ========
14 */
15 package xdc.cfg;
16
17 /*!
18 * ======== Program ========
19 * The Program object for the configuration object model.
20 *
21 * This module defines the "root" of the configuration object model; all
22 * configuration settings are for the executable represented by this
23 * object. Program configuration scripts reference this module via the
24 * global variable `Program`; i.e., `Program` implicitly initialized as
25 * follows:
26 * @p(code) 27 * var Program = xdc.useModule('xdc.cfg.Program');
28 * @p 29 *
30 * After a configuration script completes successfully, the XDC runtime
31 * generates the following files:
32 * @p(nlist) 33 * - package/cfg/<exe_name>.c
34 * - package/cfg/<exe_name>.xdl
35 * @p 36 * where `<exe_name>` is the name of the executable with the final '.'
37 * character replaced with an '_'.
38 *
39 * The generated C file contains code and data from each module used by the
40 * program and must be compiled and linked with the other sources to
41 * produce the final executable.
42 *
43 * The generated linker command file must also be used during this final
44 * link step. This linker command file is produced by expanding a template
45 * specified by `{@link xdc.cfg.Program#linkTemplate}`.
46 * Each template is responsible for expanding templates specified by each
47 * imported package's `getSects` method (see `{@link xdc.IPackage#getSects}`).
48 * This allows each package participating in the configuration of an
49 * executable to contribute a portion of the executable's linker command file.
50 */
51
52 @Template("./Program.xdt")
53
54 metaonlymodule Program {
55
56 /*!
57 * ======== GenerationOptions ========
58 * Options that control the files generated as part of program
59 * configuration.
60 *
61 * @field(debuggerFiles) If set to `true` in a configuration script,
62 * debugger project files will be generated as part of the
63 * configuration step. If set to `false`, these files will not
64 * be generated.
65 *
66 * If it is not set (or set to undefined) and the environment
67 * variable `environment["xdc.cfg.gen.debuggerFiles"]` is
68 * non-`null`, then the default value of this parameter is taken
69 * to be the value of the following expression:
70 * @p(code) 71 * environment["xdc.cfg.gen.debuggerFiles"] == "true"
72 * @p 73 * This makes it is possible to enable the generation of
74 * debugger project files from build scripts by passing
75 * the option `-Dxdc.cfg.gen.debuggerFiles=true` to the
76 * configuration tool (see
77 * `{@link xdc.bld.Executable#Attrs.xsopts}` or
78 * `{@link xdc.bld.PackageContents#Attrs.xsopts}`).
79 *
80 * Finally, if `debuggerFiles` is not set (or set to `undefined`)
81 * and the environment variable above is not defined,
82 * the generation of debugger project files occurs only if
83 * `{@link xdc.cfg.Program#build.profile}` contains
84 * the string `"debug"`. So, unless otherwise specified, debug
85 * profiles result in debugger project files being generated.
86 */
87 struct GenerationOptions {
88 Bool debuggerFiles; /*! if `true`, generate debugger "project" files */
89 };
90
91 /*!
92 * ======== SectionSpec ========
93 * Map that instructs the linker where to place output sections.
94 *
95 * This structure contains some fields that are specific to TI targets.
96 * On non-TI targets, such fields are ignored.
97 *
98 * @field(runSegment) Defines the memory segment where the section is
99 * to be run.
100 *
101 * @field(loadSegment) Defines the memory segment where the section is
102 * to be loaded. If 'runSegment' or 'loadSegment' is defined,
103 * but not both, the linker is instructed to use the defined
104 * field as the load and run allocation for the section.
105 *
106 * @field(runAddress) Defines the memory address where the section is
107 * to be run. It is an error if both 'runSegment' and 'runAddress'
108 * are specified.
109 *
110 * @field(loadAddress) Defines the memory address where the section is
111 * to be loaded. It is an error if both 'loadSegment' and
112 * 'loadAddress' are specified. If 'runAddress' or 'loadAddress'
113 * is defined, but not both, the linker is instructed to use the
114 * defined field as the load and run address for the section.
115 *
116 * @field(runAlign) If runSegment is specified, runAlign determines the
117 * alignment. It is an error if both 'runAlign' and 'runAddress'
118 * are specified.
119 *
120 * @field(loadAlign) If runSegment is specified, runAlign determins the
121 * alignment. It is an error if both 'loadAlign' and 'loadAddress'
122 * are specified.
123 *
124 * @field(type) Defines flags for special section types (COPY, DSECT,
125 * NOLOAD).
126 *
127 * @field(fill) Defines the value to initialize an uninitialized
128 * section.
129 */
130 struct SectionSpec {
131 String runSegment; /*! segment where section contents are run */
132 String loadSegment; /*! segment where section contents are loaded */
133 UInt runAddress; /*! start address of section when run */
134 UInt loadAddress; /*! start address of section when loaded */
135 UInt runAlign; /*! alignment of section within runSegment */
136 UInt loadAlign; /*! alignment of section within loadSegment */
137 String type; /*! target-specific flags */
138 UInt fill; /*! fill value */
139 };
140
141 /*!
142 * ======== gen ========
143 * Generation options for this executable
144 *
145 * This configuration parameter allows the program configuration script
146 * to control (to some extent) what files are generated as part of the
147 * configuration process.
148 */
149 config GenerationOptions gen;
150
151 /*!
152 * ======== globalSection ========
153 * UNDER CONSTRUCTION
154 * @_nodoc 155 *
156 * Section where `{@link #globals}` are placed.
157 *
158 * All globals specified in the application configuration file
159 * are placed into this section.
160 *
161 * The default is `null`, which means the `{@link #dataSection}` is used.
162 */
163 config String globalSection = null;
164
165 /*!
166 * ======== sysStack ========
167 * The size of the executable's initial system stack
168 *
169 * On platforms that support a separate "system stack", this
170 * parameter sets its initial size (in units of chars).
171 */
172 config UInt sysStack = 0x1000;
173
174 /*!
175 * ======== stack ========
176 * The size of the executable's initial stack
177 *
178 * On platforms that enable control of the initial stack size (the
179 * stack that exists immediately after reset), this parameter specifies
180 * its initial size (in units of chars).
181 */
182 config UInt stack = 0x1000;
183
184 /*!
185 * ======== heap ========
186 * The size of the executable's initial heap
187 *
188 * On platforms that enable control of the size of the heap managed by
189 * the run-time support function malloc(), this parameter specifies
190 * its initial size (in units of chars).
191 */
192 config UInt heap = 0x1000;
193
194 /*!
195 * ======== argSize ========
196 * The size allocated for command line args to the executable
197 *
198 * On platforms that require static allocation of space to hold
199 * command line arguments, this parameter specifies its maximum size
200 * (in units of chars).
201 */
202 config UInt argSize = 0x200;
203
204 /*!
205 * ======== execCmd ========
206 * The command used to run this executable
207 *
208 * If it is not set by the configuration script, it is set by the
209 * program's platform package (during program configuration).
210 *
211 * This command is run as follows:
212 * @p(code) 213 * execCmd <prog> <args>
214 * @p 215 * where, `<prog>` is the name of the executable
216 *
217 * @a(Note) 218 * This parameter is ignored if the exec command is specified as part
219 * of the test; see `{@link xdc.bld.Test#Attrs}`.
220 * and `<args>` are the arguments specified in the test (if any).
221 */
222 config String execCmd;
223
224 /*!
225 * ======== linkTemplate ========
226 * The template for the Program's linker command file
227 *
228 * A template is used to create the linker command file for each
229 * program. It can be optionally specified by setting this
230 * configuration parameter in the program's configuration script. If
231 * `linkTemplate` it is not set or set to `null`, the template is
232 * obtained from the platform associated with this program (i.e., the
233 * platform named by the `{@link #platform}` config in this module).
234 * See `{@link xdc.platform.IPlatform#getLinkTemplate IPlatform.getLinkTemplate}`.
235 *
236 * The `linkTemplate` string names a package path relative path; e.g.,
237 * if the linker template you want to specify is
238 * `"templates/big_n_hairy.xdt"` in the package `myCompany.myPackage`,
239 * `linkTemplate` should be set to:
240 * @p(code) 241 * "myCompany/myPackage/templates/big_n_hairy.xdt"
242 * @p 243 * If `linkTemplate` begins with the string `"./"`, the file is NOT
244 * searched for along the package path; instead the file name is taken
245 * to specify a file relative to the current working directory.
246 *
247 * In any case, if `linkTemplate` is non-`null`, the file must exist;
248 * otherwise, the configuration step will fail.
249 */
250 config String linkTemplate = null;
251
252 /*!
253 * ======== main ========
254 * The main entry point for the program
255 *
256 * This parameter is optionally set by the user's program
257 * configuration script. If it is not set, then a "legacy" `main()`
258 * function is assumed to be linked into the program; otherwise,
259 * the value of `main` is used as the "main" entry point to the
260 * program.
261 */
262 config Int (*main)(Int, Char*[]);
263
264 /*!
265 * ======== sectMap ========
266 * A section name to SectionSpec mapping
267 *
268 * This is a program specific mapping of output section names to
269 * {@link #SectionSpec} objects. The map supports mapping of section
270 * names to memory names; see {@link xdc.platform.IPlatform#sectMap}.
271 *
272 * This parameter enables program configurations to place named
273 * sections in platform specific memory regions. During generation of
274 * the linker command file, sections are mapped to named memories by
275 * first consulting this table; if the table does not contain a mapping,
276 * the target classifies each section as either "code", "data" or
277 * "stack" {@link xdc.bld.ITarget#sectMap} and the platform defines a
278 * memory region for each of these section types
279 * ({@link xdc.platform.IPlatform#codeMemory}/
280 * {@link xdc.platform.IPlatform#dataMemory}). If
281 * this does not produce a result, an error is generated.
282 * It is important to note that `sectMap` does not contain the complete
283 * section allocation for the program. It only contains the entries
284 * explicitly added to `sectMap`. To get the complete section
285 * allocation, a user should call {@link #getSectMap}.
286 *
287 * Suppose for example that the platform defines a memory segment
288 * named "DDR2". The following configuration statement places
289 * everything from the ".text" section into the "DDR2" segment.
290 *
291 * @p(code) 292 * Program.sectMap[".text"] = new prog.SectionSpec();
293 * Program.sectMap[".text"].runSegment = "DDR2";
294 * @p 295 *
296 * @a(Note) 297 * If BIOS 5 configuration script (Tconf script) is executed, the
298 * section allocations configured in the Tconf script take precedence
299 * over any settings for the same sections in this parameter.
300 *
301 * @see #SectionSpec
302 * @see xdc.platform.IPlatform#sectMap
303 * @see xdc.bld.ITarget#sectMap
304 */
305 config Any sectMap[string]; /* section name => SectionSpec */
306
307 /*!
308 * ======== system ========
309 * @_nodoc 310 * A facade for the {@link xdc.runtime.System#SupportProxy} parameter
311 *
312 * The program configuration script may select an implementation of
313 * the `xdc.runtime.ISystemSupport` interface and "bind" it by setting
314 * this parameter. If the module assigned to this parameter does not
315 * inherit from `xdc.runtime.ISystemSupport`, the configuration will fail.
316 *
317 * If this parameter is not set (or set to `undefined`), then a default
318 * implementation is used: `xdc.runtime.SysStd` or, if
319 * `Program.build.target.os` is `null`, `xdc.runtime.SysMin`. Recall that
320 * `Program.build.target.os` is specified in the Build Object Model;
321 * `Program.build.target` is the target specified when the executable was
322 * added to the package.
323 *
324 * If this parameter is set to `null`, then the `System` module is not
325 * linked into the application (unless 'Memory' is used); any references
326 * to `System`'s methods will result in a linker error. By setting this
327 * parameter to `null`, one is asserting that `System`'s methods will not
328 * be used.
329 */
330 config Any system;
331
332 /*!
333 * ======== name ========
334 * The name of the executable file
335 *
336 * This is the full file name (relative to the package's base) of the
337 * executable that results from this configuration.
338 *
339 * @a(readonly) 340 * This parameter is set by the generated program configuration script
341 * and must not be modified.
342 */
343 config String name;
344
345 /*!
346 * ======== buildPackage ========
347 * The name of the executable's package
348 *
349 * This is the full package name (relative to the package's repository)
350 * of the package that contains the executable being configured.
351 *
352 * @a(readonly) 353 * This parameter is set by the generated program configuration script
354 * and must not be modified.
355 */
356 config String buildPackage;
357
358 /*!
359 * ======== endian ========
360 * The endianess of the executable
361 *
362 * This parameter is an alias for `build.target.model.dataModel` and is
363 * set to one of the following values: `"big"`, `"little"`, or `null`.
364 *
365 * @a(readonly) 366 * This parameter is set by the generated program configuration script
367 * and must not be modified.
368 */
369 config String endian = null;
370
371 /*!
372 * ======== codeModel ========
373 * The memory model for code
374 *
375 * This parameter is an alias for `build.target.model.codeModel` and is
376 * set to one of the following target-specific values: `"near"`, `"far"`,
377 * `"large"`, or `null`.
378 *
379 * @a(readonly) 380 * This parameter is set by the generated program configuration script
381 * and must not be modified.
382 */
383 config String codeModel = null;
384
385 /*!
386 * ======== dataModel ========
387 * The memory model for data
388 *
389 * This parameter is an alias for `build.target.model.dataModel` and is
390 * set to one of the following target-specific values: `"near"`, `"far"`,
391 * `"large"`, or `null`.
392 *
393 * @a(readonly) 394 * This parameter is set by the generated program configuration script
395 * and must not be modified.
396 */
397 config String dataModel = null;
398
399 /*!
400 * ======== build ========
401 * This program's build attributes
402 *
403 * This parameter allows arbitrary build attributes to be carried
404 * forward from the Build Object Model (BOM) into the configuration
405 * model for program configuration scripts to read.
406 *
407 * Conceptually, this config parameter should be declared as follows:
408 * @p(code) 409 * struct BuildAttrs inherits xdc.bld.Executable.Attrs {
410 * config xdc.bld.ITarget.Module target;
411 * };
412 * @p 413 * All parameters of the target associated with the executable being
414 * configured are available through '`Program.build.target`'. Any config
415 * parameter set in the BOM's `{@link xdc.bld.Executable#attrs}` is also
416 * available through `{@link #build}`. For example, the name of the
417 * target is `Program.build.target.name` and the name of the
418 * executable's configuration script is `Program.build.cfgScript`.
419 *
420 * @a(readonly) 421 * This parameter is set by the generated program configuration script
422 * and must not be modified.
423 */
424 config Any build; /* BuildAttrs */
425
426 /*!
427 * ======== cpu ========
428 * The execution context "seen" by the executable.
429 *
430 * Since the execution context is largely determined by the CPU that
431 * runs the executable, this configuration parameter allows scripts with
432 * access to the program object to conditionally configure based on CPU
433 * characteristics (e.g., ISA or revision of a chip).
434 *
435 * @a(readonly) 436 * This parameter is set by the platform's implementation of
437 * `xdc.IPackage` (i.e., `package.xs`).
438 */
439 config xdc.platform.IExeContext.Instance cpu;
440
441 /*!
442 * ======== platformName ========
443 * The name of the executable's platform
444 *
445 * This field is the name of the platform instance used to create the
446 * executable; e.g., `"ti.platforms.sim55xx"`, or
447 * `"ti.platforms.sim6xxx:TMS320C6416"`.
448 *
449 * Platform instance names have the form:
450 * @p(code) 451 * <platform_pkg>:<instance_id>
452 * @p 453 * where `<platform_pkg>` is the name of the platform package
454 * responsible for creating the platform instance and the optional
455 * "`:<instance_id>`" is a suffix that uniquely identifies the creation
456 * parameters for this instance.
457 *
458 * The creation parameters are the values specified by the map
459 * `{@link xdc.bld.BuildEnvironment#platformTable}`;
460 * if this map does not contain the platform instance name, the
461 * instance is created with default values that are specific to the
462 * platform.
463 *
464 * @a(readonly) 465 * This parameter is set by the generated program configuration script
466 * and must not be modified.
467 */
468 config String platformName;
469
470 /*!
471 * ======== platform ========
472 * The executable's platform instance object
473 *
474 * The platform instance that provided an execution context for the
475 * executable being configured.
476 *
477 * @a(readonly) 478 * This parameter is set by the generated program configuration script
479 * and must not be modified.
480 */
481 config xdc.platform.IPlatform.Instance platform;
482
483 /*!
484 * ======== global ========
485 * Global variable declarations
486 *
487 * Assignments to this hash table become global symbols that can be
488 * used to directly reference objects. These objects are declared
489 * in a generated header that is indirectly included by the header
490 * `xdc/cfg/global.h`.
491 *
492 * Configuration scripts define symbols by adding new properties to
493 * `global`.
494 * @p(code) 495 * Program.global.myInstance = Mod.create();
496 * Program.global.myString = "hello world";
497 * @p 498 *
499 * Programs can reference the symbols defined in `global` by including
500 * the C/C++ header `xdc/cfg/global.h` as follows:
501 * @p(code) 502 * #include <pkg/Mod.h>
503 * #include <xdc/cfg/global.h>
504 * :
505 * Mod_fxn(myInstance, ...);
506 * printf("greetings: %s\n", myString);
507 * @p 508 *
509 * To compile sources that include `xdc/cfg/global.h`, one symbol must be
510 * defined before including this header:
511 * @p(dlist) 512 * - `xdc_cfg__header__`
513 * the package qualified name of the executable-specific C/C++
514 * header generated by the program configuration tool; e.g.,
515 * `local/examples/package/cfg/mycfg_x62.h`.
516 * @p 517 * For example, to compile sources that reference the values declared in
518 * `{@link #global}` for a TI C6x target with a generated
519 * configuration header named `package/cfg/mycfg_x62.h` in a package
520 * named `local.examples` the following command line is sufficient:
521 * @p(code) 522 * cl6x -Dxdc_cfg__header__=local/examples/package/cfg/mycfg_x62.h ...
523 * @p 524 *
525 * The `xdc_cfg__header__` symbol is automatically defined when you use
526 * the the XDC Build Engine (`{@link xdc.bld}`) to create executables; see
527 * `{@link xdc.bld.Executable#addObjects}`
528 *
529 * @see xdc.bld.Executable#addObjects
530 */
531 config Any global[string];
532
533 /*!
534 * ======== symbol ========
535 * UNDER CONSTRUCTION
536 * @_nodoc 537 *
538 * global symbol specifications
539 */
540 config Any symbol[string];
541
542 /*!
543 * ======== fixedCodeAddr ========
544 * UNDER CONSTRUCTION
545 * @_nodoc 546 *
547 * fixed location of code for ROM assemblies
548 */
549 config UInt fixedCodeAddr = 0;
550
551 /*!
552 * ======== fixedDataAddr ========
553 * UNDER CONSTRUCTION
554 * @_nodoc 555 *
556 * fixed location of data for ROM assemblies
557 */
558 config UInt fixedDataAddr = 0;
559
560 /*!
561 * ======== loadFixedDataAddr ========
562 * UNDER CONSTRUCTION
563 * @_nodoc 564 *
565 * Load location of fixed data accessed from ROM assemblies
566 *
567 * If an application that imports ROM assemblies cannot load data
568 * accessed from ROM to a runtime address, this address specifies the
569 * load address. The load address is specified when the application is
570 * configured. The runtime address for the data is specified at the
571 * time a ROM assembly is built, using `fixedDataAddr`.
572 */
573 config UInt loadFixedDataAddr;
574
575 /*!
576 * ======== loadRom ========
577 * UNDER CONSTRUCTION
578 * @_nodoc 579 *
580 * Control generation of 'type = DSECT' for ROM assemblies.
581 *
582 * When there is no actual ROM on the target, for debugging purposes,
583 * we may need to load ROM sections to the target. If this parameter is
584 * set to `true`, the linker command file will allocate ROM sections in
585 * the same way as other sections.
586 */
587 config Bool loadRom = false;
588
589 /*!
590 * ======== exportModule ========
591 * Force all the symbols of a module to be part of a configuration
592 *
593 * Although a call xdc.useModule() will force some of a module's methods
594 * to be part of a configuration, the linker is still free to omit any
595 * symbols that are not referenced. Use of exportModule will force all
596 * methods of the specified module to be available.
597 */
598 Void exportModule(String modName);
599
600 /*!
601 * ======== freezeRomConfig ========
602 * UNDER CONSTRUCTION
603 * @_nodoc 604 */
605 Void freezeRomConfig(String modName, String cfgName);
606
607 /*!
608 * ======== freezeRomParams ========
609 * UNDER CONSTRUCTION
610 * @_nodoc 611 */
612 Void freezeRomParams( String modName );
613
614 /*!
615 * ======== frozenRomConfig ========
616 * UNDER CONSTRUCTION
617 * @_nodoc 618 */
619 Bool frozenRomConfig( String modName, String cfgName );
620
621 /*!
622 * ======== getSectMap ========
623 * Return the complete mapping of section names to `{@link #SectionSpec}`
624 * entries
625 *
626 * The returned map is assembled from `{@link xdc.bld.ITarget#sectMap}`,
627 * `{@link xdc.platform.IPlatform#sectMap}`,
628 * `{@link xdc.platform.IPlatform#codeMemory}`,
629 * `{@link xdc.platform.IPlatform#dataMemory}`,
630 * `{@link xdc.platform.IPlatform#stackMemory}` and `{@link #sectMap}`.
631 * The function can be called at any time during configuration, but if
632 * it is called before all packages had a chance to change `sectMap`,
633 * the returned map may not correspond to the actual section
634 * allocation as configured in the linker command file.
635 *
636 * @a(returns) 637 * `getSectMap` returns a map with section names as keys and
638 * `{@link #SectionSpec}` entries as values.
639 *
640 * @a(Note) 641 * If BIOS 5 configuration script (Tconf script) is executed, the
642 * section allocations configured in the Tconf script are also being
643 * returned.
644 */
645 function getSectMap();
646
647 /*!
648 * ======== importAssembly ========
649 * UNDER CONSTRUCTION
650 * @_nodoc 651 */
652 Void importAssembly(String asmName);
653
654 /*!
655 * ======== importRomAssembly ========
656 * UNDER CONSTRUCTION
657 * @_nodoc 658 */
659 Void importRomAssembly(String romAsmName);
660
661 /*!
662 * ======== patchRomFxn ========
663 * UNDER CONSTRUCTION
664 * @_nodoc 665 */
666 Void patchRomFxn(String modName, String fxnName, String patchSym);
667
668 /*!
669 * ======== targetModules ========
670 * UNDER CONSTRUCTION
671 * @_nodoc 672 *
673 * This function returns a list of target modules. The list is completed
674 * only after all packages are closed, and runtime.finalized() is closed,
675 * so the only time when this function can be safely called is from
676 * within module$static$init and instance$static$init functions, package
677 * validate() functions, and templates.
678 */
679 function targetModules();
680
681 }
682 /*
683 * @(#) xdc.cfg; 1, 0, 2, 0,236; 12-18-2009 12:26:30; /db/ztree/library/trees/xdc/xdc-u16x/src/packages/
684 */
685