1 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 package ti.sysbios;
37
38 import xdc.rov.ViewInfo;
39
40 import xdc.runtime.Error;
41 import xdc.runtime.Types;
42
43 /*! ======== BIOS ========
44 * SYS/BIOS Top-Level Manager
45 *
46 * This module is responsible for setting up global parameters
47 * pertaining to SYS/BIOS and for performing the SYS/BIOS startup
48 * sequence.
49 *
50 * SYS/BIOS configures the
51 * {@link xdc.runtime.Memory#defaultHeapInstance Memory.defaultHeapInstance}
52 * using a {@link ti.sysbios.heaps.HeapMem HeapMem} instance of size
53 * {@link #heapSize}.
54 *
55 * The SYS/BIOS startup sequence is logically divided into two phases: those
56 * operations that occur prior to the application's "main()" function being
57 * called, and those operations that are performed after the application's
58 * "main()" function is invoked.
59 *
60 * The "before main()" startup sequence is governed completely by the RTSC
61 * runtime package's {@link xdc.runtime.Startup Startup} module.
62 *
63 * The "after main()" startup sequence is governed by SYS/BIOS and is
64 * initiated by an explicit call to the {@link #start BIOS_start()} function
65 * at the end of the application's main() function.
66 *
67 * Control points are provided at various places in each of the two startup
68 * sequences for user startup operations to be inserted.
69 *
70 * The RTSC runtime startup sequence is as follows:
71 *
72 * @p(nlist)
73 * - Immediately after CPU reset, perform target-specific CPU
74 * initialization (beginning at c_int00).
75 * - Prior to cinit(), run the user-supplied "reset functions"
76 * (see {@link xdc.runtime.Reset#fxns Reset.fxns}).
77 * - Run cinit() to initialize C runtime environment.
78 * - Run the user-supplied "first functions"
79 * (see {@link xdc.runtime.Startup#firstFxns Startup.firstFxns}).
80 * - Run all the module initialization functions.
81 * - Run pinit().
82 * - Run the user-supplied "last functions"
83 * (see {@link xdc.runtime.Startup#lastFxns Startup.lastFxns}).
84 * - Run main().
85 * @p
86 *
87 * The SYS/BIOS startup sequence begins at the end of main() when
88 * BIOS_start() is called:
89 *
90 * @p(nlist)
91 * - Run the user-supplied "startup functions"
92 * (see {@link #startupFxns BIOS.startupFxns}).
93 * - Enable Hardware Interrupts.
94 * - Enable Software Interrupts. If the system supports Software Interrupts
95 * (Swis) (see {@link #swiEnabled BIOS.swiEnabled}), then the SYS/BIOS
96 * startup sequence enables Swis at this point.
97 * - Timer Startup. If the system supports Timers, then at this point all
98 * statically configured timers are initialized per their
99 * user-configuration.
100 * If a timer was configured to start "automatically", it is started here.
101 * - Task Startup. If the system supports Tasks
102 * (see {@link #taskEnabled BIOS.taskEnabled}),
103 * then task scheduling begins here. If there are no statically or
104 * dynamically created Tasks in the system, then execution proceeds
105 * directly to the Idle loop.
106 * @p
107 *
108 * @a(Note)
109 * Local variables defined in main() no longer exist once BIOS_start() is
110 * called. The RAM where main's local variables reside is reassigned for
111 * use as the interrupt stack during the execution of BIOS_start().
112 *
113 * Below is a configuration script excerpt that installs a user-supplied
114 * startup function at every possible control point in the RTSC and
115 * SYS/BIOS startup
116 * sequence:
117 *
118 * @p(code)
119 * // get handle to xdc Startup module
120 * var Startup = xdc.useModule('xdc.runtime.Startup');
121 *
122 * // install "reset function"
123 * Startup.resetFxn = '&myReset';
124 *
125 * // install a "first function"
126 * var len = Startup.firstFxns.length
127 * Startup.firstFxns.length++;
128 * Startup.firstFxns[len] = '&myFirst';
129 *
130 * // install a "last function"
131 * var len = Startup.lastFxns.length
132 * Startup.lastFxns.length++;
133 * Startup.lastFxns[len] = '&myLast';
134 *
135 * // get handle to SYS/BIOS module
136 * var BIOS = xdc.useModule('ti.sysbios.BIOS');
137 *
138 * // install a SYS/BIOS startup function
139 * BIOS.addUserStartupFunction('&myBiosStartup');
140 * @p
141 *
142 * @p(html)
143 * <h3> Calling Context </h3>
144 * <table border="1" cellpadding="3">
145 * <colgroup span="1"></colgroup> <colgroup span="5" align="center">
146 * </colgroup>
147 *
148 * <tr><th> Function </th><th> Hwi </th><th> Swi </th>
149 * <th> Task </th><th> Main </th><th> Startup </th></tr>
150 * <!-- -->
151 * <tr><td> {@link #getCpuFreq} </td><td> Y </td><td> Y </td>
152 * <td> Y </td><td> Y </td><td> Y </td></tr>
153 * <tr><td> {@link #getThreadType} </td><td> Y </td><td> Y </td>
154 * <td> Y </td><td> Y </td><td> N </td></tr>
155 * <tr><td> {@link #setCpuFreq} </td><td> Y </td><td> Y </td>
156 * <td> Y </td><td> Y </td><td> Y </td></tr>
157 * <tr><td> {@link #start} </td><td> N </td><td> N </td>
158 * <td> N </td><td> Y </td><td> N </td></tr>
159 * <tr><td colspan="6"> Definitions: <br />
160 * <ul>
161 * <li> <b>Hwi</b>: API is callable from a Hwi thread. </li>
162 * <li> <b>Swi</b>: API is callable from a Swi thread. </li>
163 * <li> <b>Task</b>: API is callable from a Task thread. </li>
164 * <li> <b>Main</b>: API is callable during any of these phases: </li>
165 * <ul>
166 * <li> In your module startup after this module is started
167 * (e.g. BIOS_Module_startupDone() returns TRUE). </li>
168 * <li> During xdc.runtime.Startup.lastFxns. </li>
169 * <li> During main().</li>
170 * <li> During BIOS.startupFxns.</li>
171 * </ul>
172 * <li> <b>Startup</b>: API is callable during any of these phases:</li>
173 * <ul>
174 * <li> During xdc.runtime.Startup.firstFxns.</li>
175 * <li> In your module startup before this module is started
176 * (e.g. BIOS_Module_startupDone() returns FALSE).</li>
177 * </ul>
178 * </ul>
179 * </td></tr>
180 *
181 * </table>
182 * @p
183 */
184
185 @CustomHeader
186 @Template("./BIOS.xdt")
187
188 @DirectCall
189 module BIOS
190 {
191 /*!
192 * ======== ThreadType ========
193 * Current thread type definitions
194 *
195 * These values are returned by {@link #getThreadType BIOS_getThreadType}.
196 *
197 * @see #getThreadType
198 */
199 enum ThreadType {
200 ThreadType_Hwi, /*! Current thread is a Hwi */
201 ThreadType_Swi, /*! Current thread is a Swi */
202 ThreadType_Task, /*! Current thread is a Task */
203 ThreadType_Main /*! Current thread is Boot/Main */
204 };
205
206 /*!
207 * ======== RtsLockType ========
208 * Type of Gate to use in the TI RTS library
209 *
210 * @field(NoLocking) no gate is added to the RTS library. In this case,
211 * the application needs to be careful to always serialize access to the
212 * inherently non-reentrant ANSI C functions (such as `malloc()`,
213 * `printf()`, etc.).
214 *
215 * @field(GateHwi) Interrupts are disabled and restored to maintain
216 * re-entrancy. This is a very efficient lock but will also result in
217 * unbounded interrupt latency times. If real-time response to interrupts
218 * is important, you should not use this gate to lock the RTS library.
219 *
220 * @field(GateSwi) Swis are disabled and restored to maintain
221 * re-entrancy.
222 *
223 * @field(GateMutex) A single mutex is used to maintain re-entrancy.
224 *
225 * @field(GateMutexPri) A single priority inheriting mutex is used to
226 * maintain re-entrancy.
227 *
228 * @see #rtsGateType
229 */
230 enum RtsLockType {
231 NoLocking,
232 GateHwi,
233 GateSwi,
234 GateMutex,
235 GateMutexPri
236 };
237
238 /*!
239 * ======== LibType ========
240 * SYS/BIOS library selection options
241 *
242 * This enumeration defines all the SYS/BIOS library types
243 * supported by the product. You can select the library type by setting
244 * the {@link #libType BIOS.libType} configuration parameter.
245 *
246 * @field(LibType_Instrumented) The library is built with logging and
247 * assertions enabled.
248 *
249 * @field(LibType_NonInstrumented) The library is built with logging and
250 * assertions disabled.
251 *
252 * @field(LibType_Custom) The library is built using the options
253 * specified by {@link #customCCOpts}. Program optimization is performed
254 * to reduce the size of the executable and improve its performance.
255 * Enough debug information is retained to allow you to step through the
256 * application code in CCS and locate global variables.
257 *
258 * @field(LibType_Debug) This setting is similar to the LibType_Custom
259 * setting, however, no program optimization is performed. The resulting
260 * executable is fully debuggable, and you can step into SYS/BIOS code.
261 * The tradeoff is that the executable is larger and runs slower than
262 * builds that use the LibType_Custom option.
263 *
264 * @see #libType
265 */
266 enum LibType {
267 LibType_Instrumented, /*! Instrumented (Asserts and Logs enabled) */
268 LibType_NonInstrumented, /*! Non-instrumented (Asserts and Logs disabled) */
269 LibType_Custom, /*! Custom (Fully configurable) */
270 LibType_Debug /*! Debug (Fully configurable) */
271 };
272
273 /*! Used in APIs that take a timeout to specify wait forever */
274 const UInt WAIT_FOREVER = ~(0);
275
276 /*! Used in APIs that take a timeout to specify no waiting */
277 const UInt NO_WAIT = 0;
278
279 /*! User startup function type definition. */
280 typedef Void (*StartupFuncPtr)(Void);
281
282 /*!
283 * ======== ModuleView ========
284 * @_nodoc
285 */
286 metaonly struct ModuleView {
287 String currentThreadType[];
288 String rtsGateType;
289 Int cpuFreqLow;
290 Int cpuFreqHigh;
291 Bool clockEnabled;
292 Bool swiEnabled;
293 Bool taskEnabled;
294 String startFunc;
295 }
296
297 /*!
298 * ======== ErrorView ========
299 * @_nodoc
300 */
301 metaonly struct ErrorView {
302 String mod;
303 String tab;
304 String inst;
305 String field;
306 String message;
307 }
308
309 /*!
310 * ======== rovViewInfo ========
311 * @_nodoc
312 */
313 @Facet
314 metaonly config ViewInfo.Instance rovViewInfo =
315 ViewInfo.create({
316 viewMap: [
317 [
318 'Module',
319 {
320 type: ViewInfo.MODULE,
321 viewInitFxn: 'viewInitModule',
322 structName: 'ModuleView'
323 }
324 ],
325 [
326 'Scan for errors...',
327 {
328 type: ViewInfo.MODULE_DATA,
329 viewInitFxn: 'viewInitErrorScan',
330 structName: 'ErrorView'
331 }
332 ],
333 ]
334 });
335
336 /*!
337 * ======== libType ========
338 * SYS/BIOS Library type
339 *
340 * The SYS/BIOS runtime is built in the form of a library that is
341 * linked with your application. Several forms of this library are
342 * supported by the SYS/BIOS product. This configuration parameter
343 * allows you to select the form of the SYS/BIOS library to use.
344 *
345 * The default value of libType is
346 * {@link #LibType_Instrumented BIOS_LibType_Instrumented}. For a
347 * complete list of options and what they offer see {@link #LibType}.
348 */
349 metaonly config LibType libType = LibType_Instrumented;
350
351 /*!
352 * ======== customCCOpts ========
353 * Compiler options used when building a custom SYS/BIOS library
354 *
355 * When {@link #libType BIOS.libType} is set to
356 * {@link #LibType_Custom BIOS_LibType_Custom} or
357 * {@link #LibType_Debug BIOS_LibType_Debug},
358 * this string contains the options passed to the compiler during any
359 * build of the SYS/BIOS sources.
360 *
361 * In addition to the options
362 * specified by `BIOS.customCCOpts`, several `-D` and `-I` options are also
363 * passed to the compiler. The options specified by `BIOS.customCCOpts` are,
364 * however, the first options passed to the compiler on the command line.
365 *
366 * To view the custom compiler options, add the following line to your
367 * config script:
368 *
369 * @p(code)
370 * print(BIOS.customCCOpts);
371 * @p
372 *
373 * When {@link #libType BIOS.libType} is set to
374 * {@link #LibType_Custom BIOS_LibType_Custom},
375 * `BIOS.customCCOpts` is initialized to settings that create a highly
376 * optimized SYS/BIOS library.
377 *
378 * When {@link #libType BIOS.libType} is set to
379 * {@link #LibType_Debug BIOS_LibType_Debug},
380 * `BIOS.customCCOpts` is initialized to settings that create a non-optimized
381 * SYS/BIOS library that can be used to single-step through the APIs with
382 * the CCS debugger.
383 *
384 * More information about using `BIOS.customCCOpts` is provided in the
385 * {@link https://processors.wiki.ti.com/index.php/SYS/BIOS_FAQs SYS/BIOS FAQs}.
386 *
387 * @a(Warning)
388 * The default value of `BIOS.customCCOpts`, which is derived from the target
389 * specified by your configuration, includes runtime model options
390 * (such as endianess) that must be the same for all sources built and
391 * linked into your application. You must not change or add any options
392 * that can alter the runtime model specified by the default value of
393 * `BIOS.customCCOpts`.
394 */
395 metaonly config String customCCOpts;
396
397 /*!
398 * ======== includeXdcRuntime ========
399 * Include xdc.runtime sources in custom built library
400 *
401 * By default, the xdc.runtime library sources are not included in the
402 * custom SYS/BIOS library created for the application. Instead,
403 * the pre-built xdc.runtime library is provided by the respective target
404 * used to build the application.
405 *
406 * Setting this parameter to true will cause the xdc.runtime library
407 * sources to be included in the custom SYS/BIOS library. This setting
408 * yields the most efficient library in both code size and runtime
409 * performance.
410 */
411 metaonly config Bool includeXdcRuntime = false;
412
413 /*!
414 * ======== smpEnabled ========
415 * Enables multi core SMP task scheduling
416 *
417 * This functionality is available on only select multi-core devices.
418 *
419 * More information about SMP/BIOS is provided here:
420 * {@link https://processors.wiki.ti.com/index.php/SMP/BIOS SMP/BIOS}.
421 */
422 config Bool smpEnabled = false;
423
424 /*!
425 * ======== cpuFreq ========
426 * CPU frequency in Hz
427 *
428 * This configuration parameter allow SYS/BIOS to convert various
429 * periods between timer ticks (or instruction cycles) and real-time
430 * units. For example, timer periods expressed in micro-seconds need
431 * to be converted into timer ticks in order to properly program the
432 * timers.
433 *
434 * The default value of this parameter is obtained from the platform
435 * (the clockRate property of {@link xdc.cfg.Program#cpu Program.cpu})
436 * which is the CPU clock rate when the processor is reset.
437 *
438 * @a(Example)
439 * If CPU frequency is 720MHz, the following configuration script
440 * configures SYS/BIOS with the proper clock frequency:
441 * @p(code)
442 * var BIOS = xdc.useModule('ti.sysbios.BIOS');
443 * BIOS.cpuFreq.hi = 0;
444 * BIOS.cpuFreq.lo = 720000000;
445 * @p
446 */
447 config Types.FreqHz cpuFreq;
448
449 /*!
450 * ======== runtimeCreatesEnabled ========
451 * Runtime instance creation enable flag.
452 *
453 * true = Mod_create() & Mod_delete() callable at runtime
454 * false = Mod_create() & Mod_delete() not callable at runtime
455 */
456 config Bool runtimeCreatesEnabled = true;
457
458 /*!
459 * ======== taskEnabled ========
460 * SYS/BIOS Task services enable flag
461 *
462 * The following behaviors occur when {@link #taskEnabled} is
463 * set to false:
464 *
465 * @p(blist)
466 * - Static {@link ti.sysbios.knl.Task Task} creation will
467 * result in a fatal build error.
468 * - The Idle task object is not created.
469 * (The Idle functions are invoked within the {@link #start()}
470 * thread.)
471 * - Runtime calls to Task_create will trigger an assertion violation
472 * via {@link xdc.runtime.Assert#isTrue}.
473 * @p
474 */
475 config Bool taskEnabled = true;
476
477 /*!
478 * ======== swiEnabled ========
479 * SYS/BIOS Swi services enable flag
480 *
481 * The following behaviors occur when {@link #swiEnabled} is
482 * set to false:
483 *
484 * @p(blist)
485 * - Static {@link ti.sysbios.knl.Swi Swi} creation will
486 * result in a fatal build error.
487 * - See other effects as noted for {@link #clockEnabled} = false;
488 * - Runtime calls to Swi_create will trigger an assertion violation
489 * via {@link xdc.runtime.Assert#isTrue}.
490 * @p
491 */
492 config Bool swiEnabled = true;
493
494 /*!
495 * ======== clockEnabled ========
496 * SYS/BIOS Clock services enable flag
497 *
498 * The following behaviors occur when {@link #clockEnabled} is
499 * set to false:
500 *
501 * @p(blist)
502 * - Static Clock creation will result in a fatal build error.
503 * - No Clock Swi is created.
504 * - The {@link ti.sysbios.knl.Clock#tickSource Clock_tickSource}
505 * is set to
506 * {@link ti.sysbios.knl.Clock#TickSource_NULL Clock_TickSource_NULL}
507 * to prevent a Timer object from being created.
508 * - For APIs that take a timeout, values other than {@link #NO_WAIT}
509 * will be equivalent to {@link #WAIT_FOREVER}.
510 * @p
511 */
512 config Bool clockEnabled = true;
513
514 /*!
515 * ======== assertsEnabled ========
516 * SYS/BIOS Assert checking in Custom SYS/BIOS library enable flag
517 *
518 * When set to true, Assert checking code is compiled into
519 * the custom library created when {@link #libType BIOS.libType}
520 * is set to {@link #LibType_Custom BIOS_LibType_Custom} or
521 * {@link #LibType_Debug BIOS_LibType_Debug}.
522 *
523 * When set to false, Assert checking code is removed from
524 * the custom library created when BIOS.libType is set to BIOS.LibType_Custom
525 * or BIOS.LibType_Debug.
526 * This option can considerably improve runtime performance as well
527 * significantly reduce the application's code size.
528 *
529 * see {@link #libType BIOS.libType}.
530 */
531 metaonly config Bool assertsEnabled = true;
532
533 /*!
534 * ======== logsEnabled ========
535 * SYS/BIOS Log support in Custom SYS/BIOS library enable flag
536 *
537 * When set to true, SYS/BIOS execution Log code is compiled into
538 * the custom library created when {@link #libType BIOS.libType}
539 * is set to {@link #LibType_Custom BIOS_LibType_Custom} or
540 * {@link #LibType_Debug BIOS_LibType_Debug}.
541 *
542 * When set to false, all Log code is removed from
543 * the custom library created when BIOS.libType = BIOS.LibType_Custom
544 * or BIOS.LibType_Debug.
545 * This option can considerably improve runtime performance as well
546 * significantly reduce the application's code size.
547 *
548 * see {@link #libType BIOS.libType}.
549 *
550 * @a(Warning) Since interrupts
551 * are enabled when logs are generated, this setting will have the
552 * side effect of requiring task stacks to be sized large enough
553 * to absorb two interrupt contexts rather than one.
554 * See the discussion on task stacks in {@link ti.sysbios.knl.Task
555 * Task} for more information.
556 */
557 metaonly config Bool logsEnabled = true;
558
559 /*!
560 * ======== heapSize ========
561 * Size of system heap, units are in MAUs
562 *
563 * The system heap is, by default, used to allocate instance object
564 * state structures, such as {@link ti.sysbios.knl.Task Task} objects
565 * and their stacks, {@link ti.sysbios.knl.Semaphore Semaphore} objects,
566 * etc.
567 *
568 * If the application configuration does not set
569 * Memory.defaultHeapInstance, then SYS/BIOS will create a
570 * {@link ti.sysbios.heaps.HeapMem HeapMem} heap of this size. This
571 * heap will be assigned to
572 * {@link xdc.runtime.Memory#defaultHeapInstance Memory.defaultHeapInstance}
573 * and will therefore be used as the default system heap. This heap
574 * will also be used by the SYS/BIOS version of the standard C library
575 * functions malloc(), calloc() and free().
576 */
577 config SizeT heapSize = 0x1000;
578
579 /*!
580 * ======== heapSection ========
581 * Section to place the system heap
582 *
583 * This configuration parameter allows you to specify a named output
584 * section that will contain the SYS/BIOS system heap. The system heap
585 * is, by default, used to allocate {@link ti.sysbios.knl.Task Task}
586 * stacks and instance object state structures. So, giving this section
587 * a name and explicitly placing it via a linker command file can
588 * significantly improve system performance.
589 *
590 * If heapSection is `null` (or `undefined`) the system heap is placed
591 * in the target's default data section.
592 */
593 config String heapSection = null;
594
595 /*!
596 * ======== heapTrackEnabled ========
597 * Use HeapTrack with system default heap
598 *
599 * This configuration parameter will add a HeapTrack instance on top of
600 * the system heap. HeapTrack adds a tracker packet to every allocated
601 * buffer and displays the information in RTOS Object Viewer (ROV).
602 * An assert will be raised on a free if there was a buffer overflow.
603 */
604 config Bool heapTrackEnabled = false;
605
606 /*!
607 * ======== setupSecureContext ========
608 * @_nodoc
609 * Sets up a secure context when using secure version of BIOS
610 *
611 * This is available for some C66 secure devices only.
612 * This parameter take effect only when 'useSK' is set to true.
613 * If set to true, a call to Hwi_setupSC() is done in a last function.
614 */
615 config Bool setupSecureContext = false;
616
617 /*!
618 * ======== useSK ========
619 * @_nodoc
620 * use the secure version of BIOS
621 *
622 * This is available for some C66 secure devices only.
623 * This parameter can only be used with the custom build.
624 */
625 config Bool useSK = false;
626
627 /*!
628 * ======== rtsGateType ========
629 * Gate to make sure TI RTS library APIs are re-entrant
630 *
631 * The application gets to determine the type of gate (lock) that is used
632 * in the TI RTS library. The gate will be used to guarantee re-entrancy
633 * of the RTS APIs.
634 *
635 * The type of gate depends on the type of threads that are going to
636 * be calling into the RTS library. For example, if both Swi and Task
637 * threads are going to be calling the RTS library's printf, GateSwi
638 * should be used. In this case, Hwi threads are not impacted (i.e.
639 * disabled) during the printf calls from the Swi or Task threads.
640 *
641 * If NoLocking is used, the RTS lock is not plugged and re-entrancy for
642 * the TI RTS library calls are not guaranteed. The application can plug
643 * the RTS locks directly if it wants.
644 *
645 * Numerous gate types are provided by SYS/BIOS. Each has its advantages
646 * and disadvantages. The following list summarizes when each type is
647 * appropriate for protecting an underlying non-reentrant RTS library.
648 * @p(dlist)
649 * - {@link #GateHwi}:
650 * Interrupts are disabled and restored to maintain re-entrancy.
651 * Use if only making RTS calls from a Hwi, Swi and/or Task.
652 *
653 * - {@link #GateSwi}:
654 * Swis are disabled and restored to maintain re-entrancy. Use if
655 * only making RTS calls from a Swi and/or Task.
656 *
657 * - {@link #GateMutex}:
658 * A single mutex is used to maintain re-entrancy. Use if only
659 * making RTS calls from a Task. Blocks only Tasks that are
660 * also trying to execute critical regions of RTS library.
661 *
662 * - {@link #GateMutexPri}:
663 * A priority inheriting mutex is used to maintain re-entrancy.
664 * Blocks only Tasks that are also trying to execute critical
665 * regions of RTS library. Raises the priority of the Task that
666 * is executing the critical region in the RTS library to the
667 * level of the highest priority Task that is block by the mutex.
668 * @p
669 *
670 * The default value of rtsGateType depends on the type of threading
671 * model enabled by other configuration parameters.
672 * If {@link #taskEnabled} is true, {@link #GateMutex} is used.
673 * If {@link #swiEnabled} is true and {@link #taskEnabled} is false:
674 * {@link #GateSwi} is used.
675 * If both {@link #swiEnabled} and {@link #taskEnabled} are false:
676 * {@link xdc.runtime#GateNull} is used.
677 *
678 * If {@link #taskEnabled} is false, the user should not select
679 * {@link #GateMutex} (or other Task level gates). Similarly, if
680 * {@link #taskEnabled} and {@link #swiEnabled}are false, the user
681 * should not select {@link #GateSwi} or the Task level gates.
682 */
683 metaonly config RtsLockType rtsGateType;
684
685 /*!
686 * ======== startupFxns ========
687 * Functions to be executed at the beginning of BIOS_start()
688 *
689 * These user (or middleware) functions are executed before Hwis,
690 * Swis, and Tasks are started.
691 */
692 metaonly config StartupFuncPtr startupFxns[] = [];
693
694 /*!
695 * ======== version ========
696 * SYS/BIOS version number macro
697 *
698 * This macro has a hex value that represents the SYS/BIOS version
699 * number. The hex value has the version format 0xMmmpp, where
700 * M is a single digit Major number, mm is a 2 digit minor number
701 * and pp is a 2 digit patch number.
702 *
703 * Example: A macro hex value of 0x64501 implies that the SYS/BIOS
704 * product version number is 6.45.01
705 */
706 const UInt32 version = 0x65000;
707
708 /*!
709 * ======== addUserStartupFunction ========
710 * @_nodoc
711 * Statically add a function to the startupFxns table.
712 */
713 metaonly Void addUserStartupFunction(StartupFuncPtr func);
714
715 /*!
716 * ======== linkedWithIncorrectBootLibrary ========
717 * Application was linked with incorrect Boot library
718 *
719 * This function has a loop that spins forever. If execution
720 * reaches this function, it indicates that the application
721 * was linked with an incorrect boot library and the XDC
722 * runtime startup functions did not get run. This can happen
723 * if the code gen tool's RTS library was before SYS/BIOS's
724 * generated linker cmd file on the link line.
725 */
726 Void linkedWithIncorrectBootLibrary();
727
728 /*!
729 * ======== start ========
730 * Start SYS/BIOS
731 *
732 * The user's main() function is required to call this function
733 * after all other user initializations have been performed.
734 *
735 * This function does not return.
736 *
737 * This function performs any remaining SYS/BIOS initializations
738 * and then transfers control to the highest priority ready
739 * task if {@link #taskEnabled} is true. If {@link #taskEnabled}
740 * is false, control is transferred directly to the Idle Loop.
741 *
742 * The SYS/BIOS start sequence is as follows:
743 * @p(blist)
744 * - Invoke all the functions in the {@link #startupFxns} array.
745 * - call {@link ti.sysbios.hal.Hwi#enable Hwi_startup()}
746 * to enable interrupts.
747 * - if {@link #swiEnabled} is true, call
748 * {@link ti.sysbios.knl.Swi#enable Swi_startup()} to enable
749 * the Swi scheduler.
750 * - Start any statically created or constructed Timers
751 * in the {@link ti.sysbios.hal.Timer#StartMode Timer_StartMode_AUTO}
752 * mode.
753 * - if {@link #taskEnabled} is true, enable the Task scheduler
754 * and transfer the execution thread to the highest priority
755 * task in the {@link ti.sysbios.knl.Task#Mode Task_Mode_READY}
756 * mode.
757 * - Otherwise, fall directly into the Idle Loop.
758 * @p
759 *
760 */
761 Void start();
762
763 /*!
764 * ======== exit ========
765 * Exit currently running SYS/BIOS executable
766 *
767 * This function is called when a SYS/BIOS executable needs to terminate
768 * normally. This function sets the internal SYS/BIOS threadType to
769 * {@link #ThreadType_Main} and then calls
770 * {@link xdc.runtime.System#exit System_exit}(stat), passing along
771 * the 'stat' argument.
772 *
773 * All functions bound via
774 * `{@link xdc.runtime.System#atexit System_atexit}` or the ANSI C
775 * Standard Library `atexit` function are then executed.
776 *
777 * @param(stat) exit status to return to calling environment.
778 */
779 Void exit(Int stat);
780
781 /*!
782 * ======== getThreadType ========
783 * Get the current thread type
784 *
785 * @b(returns) Current thread type
786 */
787 ThreadType getThreadType();
788
789 /*!
790 * @_nodoc
791 * ======== setThreadType ========
792 * Set the current thread type
793 *
794 * Called by the various threadType owners.
795 *
796 * @param(ttype) New thread type value
797 * @b(returns) Previous thread type
798 */
799 ThreadType setThreadType(ThreadType ttype);
800
801 /*!
802 * ======== setCpuFreq ========
803 * Set CPU Frequency in Hz
804 *
805 * This API is not thread safe. Please use appropriate locks.
806 */
807 Void setCpuFreq(Types.FreqHz *freq);
808
809 /*!
810 * ======== getCpuFreq ========
811 * Get CPU frequency in Hz
812 *
813 * This API is not thread safe. Please use appropriate locks.
814 */
815 Void getCpuFreq(Types.FreqHz *freq);
816
817 /*!
818 * @_nodoc
819 * ======== getCpuFrequency ========
820 * Get CPU frequency in Hz.
821 *
822 * This function is currently used by UIA and is called in the
823 * UIAMetaData validate() function.
824 * NOTE: Javascript does not support UInt64, so this only works
825 * if the frequency is less than 4GHz. Keep this function for
826 * backwards compatibility (for awhile).
827 */
828 metaonly UInt64 getCpuFrequency();
829
830 /*!
831 * @_nodoc
832 * ======== getCpuFreqMeta ========
833 * Get CPU frequency in Hz.
834 *
835 * This function is currently used by UIA and is called in the
836 * UIAMetaData validate() function.
837 */
838 metaonly Types.FreqHz getCpuFreqMeta();
839
840 /*!
841 * @_nodoc
842 * ======== getTimestampFrequency ========
843 * Get timestamp frequency in Hz. If we don't know the timestamp
844 * frequency of the device, return 0.
845 *
846 * This function is currently used by UIA and is called in the
847 * UIAMetaData validate() function.
848 * NOTE: Javascript does not support UInt64, so this only works
849 * if the frequency is less than 4GHz. Keep this function for
850 * backwards compatability (for awhile).
851 */
852 metaonly UInt64 getTimestampFrequency();
853
854 /*!
855 * @_nodoc
856 * ======== getTimestampFreqMeta ========
857 * Get timestamp frequency in Hz. If we don't know the timestamp
858 * frequency of the device, return 0.
859 *
860 * This function is currently used by UIA and is called in the
861 * UIAMetaData validate() function.
862 */
863 metaonly Types.FreqHz getTimestampFreqMeta();
864
865 /*!
866 * @_nodoc
867 * ======== getDefaultTimestampProvider ========
868 * Returns the name of the TimestampProvider module BIOS will set
869 * xdc.runtime.Timestamp.SupportProxy to if it hasn't been configured
870 * in the user's config script.
871 *
872 * This function is meant to be used by modules that have their own
873 * TimestampProvider proxies if they want to initialize them to the
874 * default xdc.runtime.Timestamp.SupportProxy binding selected by BIOS:
875 *
876 * if (!this.$written("TimestampProxy")) {
877 * if (xdc.runtime.$written("Timestamp.SupportProxy") {
878 * this.TimestampProxy = xdc.runtime.Timestamp.SupportProxy;
879 * }
880 * else {
881 * this.TimestampProxy = xdc.module(BIOS.getDefaultTimestampProvider());
882 * }
883 * }
884 */
885 metaonly String getDefaultTimestampProvider();
886
887 internal:
888
889 890 891 892 893 894 895
896 metaonly config Bool buildingAppLib = true;
897
898 899 900 901
902 metaonly config String libDir = null;
903
904 905 906 907
908 metaonly String getCCOpts(String target);
909
910 911 912 913
914 struct intSize {
915 Int intSize;
916 }
917
918 919 920 921 922 923
924 metaonly config Char bitsPerInt;
925
926 927 928 929 930 931 932 933
934 config Void (*installedErrorHook)(Error.Block *);
935
936 937 938 939 940
941 Void errorRaiseHook(Error.Block *eb);
942
943 944 945 946
947 Void startFunc();
948
949 950 951 952
953 Void atExitFunc(Int stat);
954
955 956 957 958
959 Void exitFunc(Int stat);
960
961 962 963 964 965 966
967 Void registerRTSLock();
968
969 970 971 972 973 974
975 Void removeRTSLock();
976
977 978 979 980
981 Void rtsLock();
982
983 984 985 986
987 Void rtsUnlock();
988
989 990 991
992 Void nullFunc();
993
994 995 996
997 function fireFrequencyUpdate(newFreq);
998
999 1000 1001 1002
1003 proxy RtsGateProxy inherits xdc.runtime.IGateProvider;
1004
1005 1006 1007 1008
1009 typedef Void (*StartFuncPtr)(void);
1010
1011 1012 1013 1014
1015 typedef Void (*ExitFuncPtr)(Int);
1016
1017 1018 1019
1020 struct Module_State {
1021 Types.FreqHz cpuFreq;
1022 UInt rtsGateCount;
1023 IArg rtsGateKey;
1024 RtsGateProxy.Handle rtsGate;
1025 ThreadType threadType;
1026
1027 ThreadType smpThreadType[];
1028
1029 volatile StartFuncPtr startFunc;
1030 volatile ExitFuncPtr exitFunc;
1031 };
1032 }