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 {@link #SectionSpec} mapping
267 *
268 * This is a program specific mapping of output section names to
269 * SectionSpec objects. The map supports mapping of section names to
270 * 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 */
303 config Any sectMap[string]; /* section name => SectionSpec */
304
305 /*!
306 * ======== system ========
307 * @_nodoc 308 * A facade for the {@link xdc.runtime.System#SupportProxy} parameter
309 *
310 * The program configuration script may select an implementation of
311 * the `xdc.runtime.ISystemSupport` interface and "bind" it by setting
312 * this parameter. If the module assigned to this parameter does not
313 * inherit from `xdc.runtime.ISystemSupport`, the configuration will fail.
314 *
315 * If this parameter is not set (or set to `undefined`), then a default
316 * implementation is used: `xdc.runtime.SysStd` or, if
317 * `Program.build.target.os` is `null`, `xdc.runtime.SysMin`. Recall that
318 * `Program.build.target.os` is specified in the Build Object Model;
319 * `Program.build.target` is the target specified when the executable was
320 * added to the package.
321 *
322 * If this parameter is set to `null`, then the `System` module is not
323 * linked into the application (unless 'Memory' is used); any references
324 * to `System`'s methods will result in a linker error. By setting this
325 * parameter to `null`, one is asserting that `System`'s methods will not
326 * be used.
327 */
328 config Any system;
329
330 /*!
331 * ======== name ========
332 * The name of the executable file
333 *
334 * This is the full file name (relative to the package's base) of the
335 * executable that results from this configuration.
336 *
337 * @a(readonly) 338 * This parameter is set by the generated program configuration script
339 * and must not be modified.
340 */
341 config String name;
342
343 /*!
344 * ======== buildPackage ========
345 * The name of the executable's package
346 *
347 * This is the full package name (relative to the package's repository)
348 * of the package that contains the executable being configured.
349 *
350 * @a(readonly) 351 * This parameter is set by the generated program configuration script
352 * and must not be modified.
353 */
354 config String buildPackage;
355
356 /*!
357 * ======== endian ========
358 * The endianess of the executable
359 *
360 * This parameter is an alias for `build.target.model.dataModel` and is
361 * set to one of the following values: `"big"`, `"little"`, or `null`.
362 *
363 * @a(readonly) 364 * This parameter is set by the generated program configuration script
365 * and must not be modified.
366 */
367 config String endian = null;
368
369 /*!
370 * ======== codeModel ========
371 * The memory model for code
372 *
373 * This parameter is an alias for `build.target.model.codeModel` and is
374 * set to one of the following target-specific values: `"near"`, `"far"`,
375 * `"large"`, or `null`.
376 *
377 * @a(readonly) 378 * This parameter is set by the generated program configuration script
379 * and must not be modified.
380 */
381 config String codeModel = null;
382
383 /*!
384 * ======== dataModel ========
385 * The memory model for data
386 *
387 * This parameter is an alias for `build.target.model.dataModel` and is
388 * set to one of the following target-specific values: `"near"`, `"far"`,
389 * `"large"`, or `null`.
390 *
391 * @a(readonly) 392 * This parameter is set by the generated program configuration script
393 * and must not be modified.
394 */
395 config String dataModel = null;
396
397 /*!
398 * ======== build ========
399 * This program's build attributes
400 *
401 * This parameter allows arbitrary build attributes to be carried
402 * forward from the Build Object Model (BOM) into the configuration
403 * model for program configuration scripts to read.
404 *
405 * Conceptually, this config parameter should be declared as follows:
406 * @p(code) 407 * struct BuildAttrs inherits xdc.bld.Executable.Attrs {
408 * config xdc.bld.ITarget.Module target;
409 * };
410 * @p 411 * All parameters of the target associated with the executable being
412 * configured are available through '`Program.build.target`'. Any config
413 * parameter set in the BOM's `{@link xdc.bld.Executable#attrs}` is also
414 * available through `{@link #build}`. For example, the name of the
415 * target is `Program.build.target.name` and the name of the
416 * executable's configuration script is `Program.build.cfgScript`.
417 *
418 * @a(readonly) 419 * This parameter is set by the generated program configuration script
420 * and must not be modified.
421 */
422 config Any build; /* BuildAttrs */
423
424 /*!
425 * ======== cpu ========
426 * The execution context "seen" by the executable.
427 *
428 * Since the execution context is largely determined by the CPU that
429 * runs the executable, this configuration parameter allows scripts with
430 * access to the program object to conditionally configure based on CPU
431 * characteristics (e.g., ISA or revision of a chip).
432 *
433 * @a(readonly) 434 * This parameter is set by the platform's implementation of
435 * `xdc.IPackage` (i.e., `package.xs`).
436 */
437 config xdc.platform.IExeContext.Instance cpu;
438
439 /*!
440 * ======== platformName ========
441 * The name of the executable's platform
442 *
443 * This field is the name of the platform instance used to create the
444 * executable; e.g., `"ti.platforms.sim55xx"`, or
445 * `"ti.platforms.sim6xxx:TMS320C6416"`.
446 *
447 * Platform instance names have the form:
448 * @p(code) 449 * <platform_pkg>:<instance_id>
450 * @p 451 * where `<platform_pkg>` is the name of the platform package
452 * responsible for creating the platform instance and the optional
453 * "`:<instance_id>`" is a suffix that uniquely identifies the creation
454 * parameters for this instance.
455 *
456 * The creation parameters are the values specified by the map
457 * `{@link xdc.bld.BuildEnvironment#platformTable}`;
458 * if this map does not contain the platform instance name, the
459 * instance is created with default values that are specific to the
460 * platform.
461 *
462 * @a(readonly) 463 * This parameter is set by the generated program configuration script
464 * and must not be modified.
465 */
466 config String platformName;
467
468 /*!
469 * ======== platform ========
470 * The executable's platform instance object
471 *
472 * The platform instance that provided an execution context for the
473 * executable being configured.
474 *
475 * @a(readonly) 476 * This parameter is set by the generated program configuration script
477 * and must not be modified.
478 */
479 config xdc.platform.IPlatform.Instance platform;
480
481 /*!
482 * ======== global ========
483 * Global variable declarations
484 *
485 * Assignments to this hash table become global symbols that can be
486 * used to directly reference objects. These objects are declared
487 * in a generated header that is indirectly included by the header
488 * `xdc/cfg/global.h`.
489 *
490 * Configuration scripts define symbols by adding new properties to
491 * `global`.
492 * @p(code) 493 * Program.global.myInstance = Mod.create();
494 * Program.global.myString = "hello world";
495 * @p 496 *
497 * Programs can reference the symbols defined in `global` by including
498 * the C/C++ header `xdc/cfg/global.h` as follows:
499 * @p(code) 500 * #include <pkg/Mod.h>
501 * #include <xdc/cfg/global.h>
502 * :
503 * Mod_fxn(myInstance, ...);
504 * printf("greetings: %s\n", myString);
505 * @p 506 *
507 * To compile sources that include `xdc/cfg/global.h`, one symbol must be
508 * defined before including this header:
509 * @p(dlist) 510 * - `xdc_cfg__header__`
511 * the package qualified name of the executable-specific C/C++
512 * header generated by the program configuration tool; e.g.,
513 * `local/examples/package/cfg/mycfg_x62.h`.
514 * @p 515 * For example, to compile sources that reference the values declared in
516 * `{@link #global}` for a TI C6x target with a generated
517 * configuration header named `package/cfg/mycfg_x62.h` in a package
518 * named `local.examples` the following command line is sufficient:
519 * @p(code) 520 * cl6x -Dxdc_cfg__header__=local/examples/package/cfg/mycfg_x62.h ...
521 * @p 522 *
523 * The `xdc_cfg__header__` symbol is automatically defined when you use
524 * the the XDC Build Engine (`{@link xdc.bld}`) to create executables; see
525 * `{@link xdc.bld.Executable#addObjects}`
526 *
527 * @see xdc.bld.Executable#addObjects
528 */
529 config Any global[string];
530
531 /*!
532 * ======== symbol ========
533 * UNDER CONSTRUCTION
534 * @_nodoc 535 *
536 * global symbol specifications
537 */
538 config Any symbol[string];
539
540 /*!
541 * ======== fixedCodeAddr ========
542 * UNDER CONSTRUCTION
543 * @_nodoc 544 *
545 * fixed location of code for ROM assemblies
546 */
547 config UInt fixedCodeAddr = 0;
548
549 /*!
550 * ======== fixedDataAddr ========
551 * UNDER CONSTRUCTION
552 * @_nodoc 553 *
554 * fixed location of data for ROM assemblies
555 */
556 config UInt fixedDataAddr = 0;
557
558 /*!
559 * ======== loadFixedDataAddr ========
560 * UNDER CONSTRUCTION
561 * @_nodoc 562 *
563 * Load location of fixed data accessed from ROM assemblies
564 *
565 * If an application that imports ROM assemblies cannot load data
566 * accessed from ROM to a runtime address, this address specifies the
567 * load address. The load address is specified when the application is
568 * configured. The runtime address for the data is specified at the
569 * time a ROM assembly is built, using `fixedDataAddr`.
570 */
571 config UInt loadFixedDataAddr;
572
573 /*!
574 * ======== loadRom ========
575 * UNDER CONSTRUCTION
576 * @_nodoc 577 *
578 * Control generation of 'type = DSECT' for ROM assemblies.
579 *
580 * When there is no actual ROM on the target, for debugging purposes,
581 * we may need to load ROM sections to the target. If this parameter is
582 * set to `true`, the linker command file will allocate ROM sections in
583 * the same way as other sections.
584 */
585 config Bool loadRom = false;
586
587 /*!
588 * ======== exportModule ========
589 * Force all the symbols of a module to be part of a configuration
590 *
591 * Although a call xdc.useModule() will force some of a module's methods
592 * to be part of a configuration, the linker is still free to omit any
593 * symbols that are not referenced. Use of exportModule will force all
594 * methods of the specified module to be available.
595 */
596 Void exportModule(String modName);
597
598 /*!
599 * ======== freezeRomConfig ========
600 * UNDER CONSTRUCTION
601 * @_nodoc 602 */
603 Void freezeRomConfig(String modName, String cfgName);
604
605 /*!
606 * ======== freezeRomParams ========
607 * UNDER CONSTRUCTION
608 * @_nodoc 609 */
610 Void freezeRomParams( String modName );
611
612 /*!
613 * ======== frozenRomConfig ========
614 * UNDER CONSTRUCTION
615 * @_nodoc 616 */
617 Bool frozenRomConfig( String modName, String cfgName );
618
619 /*!
620 * ======== getSectMap ========
621 * Return the complete mapping of section names to `{@link #SectionSpec}`
622 * entries
623 *
624 * The returned map is assembled from `{@link xdc.bld.ITarget#sectMap}`,
625 * `{@link xdc.platform.IPlatform#sectMap}`,
626 * `{@link xdc.platform.IPlatform#codeMemory}`,
627 * `{@link xdc.platform.IPlatform#dataMemory}`,
628 * `{@link xdc.platform.IPlatform#stackMemory}` and `{@link #sectMap}`.
629 * The function can be called at any time during configuration, but if
630 * it is called before all packages had a chance to change `sectMap`,
631 * the returned map may not correspond to the actual section
632 * allocation as configured in the linker command file.
633 *
634 * @a(returns) 635 * `getSectMap` returns a map with section names as keys and
636 * `{@link #SectionSpec}` entries as values.
637 *
638 * @a(Note) 639 * If BIOS 5 configuration script (Tconf script) is executed, the
640 * section allocations configured in the Tconf script are also being
641 * returned.
642 */
643 function getSectMap();
644
645 /*!
646 * ======== importAssembly ========
647 * UNDER CONSTRUCTION
648 * @_nodoc 649 */
650 Void importAssembly(String asmName);
651
652 /*!
653 * ======== importRomAssembly ========
654 * UNDER CONSTRUCTION
655 * @_nodoc 656 */
657 Void importRomAssembly(String romAsmName);
658
659 /*!
660 * ======== patchRomFxn ========
661 * UNDER CONSTRUCTION
662 * @_nodoc 663 */
664 Void patchRomFxn(String modName, String fxnName, String patchSym);
665
666 /*!
667 * ======== targetModules ========
668 * UNDER CONSTRUCTION
669 * @_nodoc 670 *
671 * This function returns a list of target modules. The list is completed
672 * only after all packages are closed, and runtime.finalized() is closed,
673 * so the only time when this function can be safely called is from
674 * within module$static$init and instance$static$init functions, package
675 * validate() functions, and templates.
676 */
677 function targetModules();
678
679 }
680 /*
681 * @(#) xdc.cfg; 1, 0, 2, 0,214; 7-29-2009 14:53:00; /db/ztree/library/trees/xdc-t56x/src/packages/
682 */
683