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