a45f0cbd8f8e802d9093c9df235bcce99389df0d
2 /* =============================================================================
3 * Copyright (c) Texas Instruments Incorporated 2019
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 var Defaults = xdc.useModule('xdc.runtime.Defaults');
34 var Diags = xdc.useModule('xdc.runtime.Diags');
35 var Error = xdc.useModule('xdc.runtime.Error');
36 var Log = xdc.useModule('xdc.runtime.Log');
37 var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
38 var Main = xdc.useModule('xdc.runtime.Main');
39 var Memory = xdc.useModule('xdc.runtime.Memory')
40 var System = xdc.useModule('xdc.runtime.System');
41 var Text = xdc.useModule('xdc.runtime.Text');
42 var Clock = xdc.useModule('ti.sysbios.knl.Clock');
43 var Task = xdc.useModule('ti.sysbios.knl.Task');
44 var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
45 var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');
46 var GateSwi = xdc.useModule('ti.sysbios.gates.GateSwi');
48 var BIOS = xdc.useModule('ti.sysbios.BIOS');
49 var Hwi = xdc.useModule('ti.sysbios.family.arm.v7r.keystone3.Hwi');
50 var Core = xdc.useModule('ti.sysbios.family.arm.v7r.keystone3.Core');
51 var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
52 var SysMin = xdc.useModule('xdc.runtime.SysMin');
54 /* System stack size (used by ISRs and Swis) */
55 Program.stack = 0x2000;
57 /* Place vector table in separate section - by default this goes to 0x0 which
58 * is reserved by SBL */
59 Program.sectMap[".vecs"] = "RESET_VECTORS";
61 var Task = xdc.useModule('ti.sysbios.knl.Task');
62 Task.defaultStackSize = 0x4000;
63 Task.common$.namedInstance = true;
64 Task.common$.namedModule = true;
66 /* Enable cache */
67 var Cache = xdc.useModule('ti.sysbios.family.arm.v7r.Cache');
68 Cache.enableCache = true;
70 /*
71 * Direct CIO to UART
72 */
73 /* System.SupportProxy = SysUart; */
74 System.SupportProxy = SysMin;
75 System.extendedFormats += "%f";
76 /*
77 * Program.argSize sets the size of the .args section.
78 * The examples don't use command line args so argSize is set to 0.
79 */
80 Program.argSize = 0x0;
82 /*
83 * Uncomment this line to globally disable Asserts.
84 * All modules inherit the default from the 'Defaults' module. You
85 * can override these defaults on a per-module basis using Module.common$.
86 * Disabling Asserts will save code space and improve runtime performance.
87 Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
88 */
90 /*
91 * Uncomment this line to keep module names from being loaded on the target.
92 * The module name strings are placed in the .const section. Setting this
93 * parameter to false will save space in the .const section. Error and
94 * Assert messages will contain an "unknown module" prefix instead
95 * of the actual module name.
96 Defaults.common$.namedModule = false;
97 */
99 /* Create default heap and hook it into Memory */
100 var heapMemParams = new HeapMem.Params;
101 heapMemParams.size = 16384*4;
102 var heap0 = HeapMem.create(heapMemParams);
104 Memory.defaultHeapInstance = heap0;
106 /*
107 * Minimize exit handler array in System. The System module includes
108 * an array of functions that are registered with System_atexit() to be
109 * called by System_exit().
110 */
111 System.maxAtexitHandlers = 4;
113 /*
114 * Uncomment this line to disable the Error print function.
115 * We lose error information when this is disabled since the errors are
116 * not printed. Disabling the raiseHook will save some code space if
117 * your app is not using System_printf() since the Error_print() function
118 * calls System_printf().
119 Error.raiseHook = null;
120 */
122 /*
123 * Uncomment this line to keep Error, Assert, and Log strings from being
124 * loaded on the target. These strings are placed in the .const section.
125 * Setting this parameter to false will save space in the .const section.
126 * Error, Assert and Log message will print raw ids and args instead of
127 * a formatted message.
128 Text.isLoaded = false;
129 */
131 /*
132 * Uncomment this line to disable the output of characters by SysMin
133 * when the program exits. SysMin writes characters to a circular buffer.
134 * This buffer can be viewed using the SysMin Output view in ROV.
135 SysMin.flushAtExit = false;
136 */
138 /*
139 * Create and install logger for the whole system
140 */
141 var loggerBufParams = new LoggerBuf.Params();
142 loggerBufParams.numEntries = 32;
143 var logger0 = LoggerBuf.create(loggerBufParams);
144 Defaults.common$.logger = logger0;
145 Main.common$.diags_INFO = Diags.ALWAYS_ON;
147 BIOS.libType = BIOS.LibType_Custom;
148 BIOS.cpuFreq.lo = 1000000000;
149 BIOS.cpuFreq.hi = 0;
151 var coreId = java.lang.System.getenv("CORE");
153 var DMTimer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
154 DMTimer.checkFrequency = false;
155 for (var i=0; i < DMTimer.numTimerDevices; i++) {
156 DMTimer.intFreqs[i].lo = 19200000;
157 DMTimer.intFreqs[i].hi = 0;
158 }
160 if(coreId=="mcu1_0")
161 {
162 Core.id = 0;
163 /* DM timer cfg */
164 Clock.timerId = 1;
165 }
166 if(coreId=="mcu1_1")
167 {
168 Core.id = 1;
169 /* DM timer cfg */
170 Clock.timerId = 2;
171 }
172 if(coreId=="mcu2_0")
173 {
174 Core.id = 0;
175 Clock.timerId = 0;
176 /* DMTimer #12 - in general, address is 0x024x0000 where x is timer # */
177 DMTimer.timerSettings[0].baseAddr = 0x024c0000;
178 DMTimer.timerSettings[0].intNum = 168;
179 }
180 if(coreId=="mcu2_1")
181 {
182 Core.id = 1;
183 Clock.timerId = 1;
184 /* DMTimer #13 - in general, address is 0x024x0000 where x is timer # */
185 DMTimer.timerSettings[1].baseAddr = 0x024d0000;
186 DMTimer.timerSettings[1].intNum = 169;
187 }
188 if(coreId=="mcu3_0")
189 {
190 Core.id = 0;
191 Clock.timerId = 2;
192 /* DMTimer #14 - in general, address is 0x024x0000 where x is timer # */
193 DMTimer.timerSettings[2].baseAddr = 0x024e0000;
194 DMTimer.timerSettings[2].intNum = 170;
195 }
196 if(coreId=="mcu3_1")
197 {
198 Core.id = 1;
199 Clock.timerId = 3;
200 /* DMTimer #15 - in general, address is 0x024x0000 where x is timer # */
201 DMTimer.timerSettings[3].baseAddr = 0x024f0000;
202 DMTimer.timerSettings[3].intNum = 171;
203 }
205 /* Set base address of Vector Interrupt Manager */
206 if((coreId=="mcu2_0") || (coreId=="mcu2_1") || (coreId=="mcu3_0") || (coreId=="mcu3_1"))
207 {
208 var Hwi = xdc.useModule('ti.sysbios.family.arm.v7r.keystone3.Hwi');
209 Hwi.vimBaseAddress = 0x0ff80000;
210 }
212 /*
213 * Initialize MPU and enable it
214 *
215 * Note: MPU must be enabled and properly configured for caching to work.
216 */
217 xdc.loadCapsule("r5_mpu.xs");
219 var Load = xdc.useModule('ti.sysbios.utils.Load');
221 /* load calculation related settings */
222 Load.swiEnabled = true;
223 Load.hwiEnabled = true;
224 Load.taskEnabled = true;
225 Load.updateInIdle = false;
227 /* Check if application needs to update with custom configuration options */
228 /* Caution: This should be at the end of this file after all other common cfg */
229 var cfgUpdate = java.lang.System.getenv("XDC_CFG_UPDATE")
230 if ((cfgUpdate != '')&&(cfgUpdate != null))
231 {
232 xdc.print("Loading configuration update " + cfgUpdate);
233 xdc.loadCapsule(cfgUpdate);
234 }