1 /*
2 * Copyright (c) 2011-2015, Texas Instruments Incorporated
3 * All rights reserved.
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 distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
33 /*
34 * ======== package.xs ========
35 *
36 */
38 var powerEnabled = false;
40 /*
41 * ======== init ========
42 */
43 function init()
44 {
45 if (xdc.om.$name != 'cfg') {
46 return;
47 }
49 if (Program.build.target.name.match(/M3/) &&
50 !Program.platformName.match(/ipu/)) {
51 Program.sectMap[".ipcpower_data"] = new Program.SectionSpec();
52 Program.sectMap[".ipcpower_data"].type = "NOINIT";
53 Program.sectMap[".ipcpower_data"].loadAddress = 0x2100;
54 }
55 }
57 /*
58 * ======== close ========
59 */
60 function close()
61 {
62 if (xdc.om.$name != "cfg") {
63 return;
64 }
66 Program.exportModule('ti.sysbios.knl.Idle');
68 xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
70 /* Find out if PM is wanted */
71 if ((("ti.sysbios.family.c66.vayu.Power" in xdc.om) &&
72 (xdc.module('ti.sysbios.family.c66.vayu.Power').$used)) ||
73 (("ti.sysbios.family.c64p.tesla.Power" in xdc.om) &&
74 (xdc.module('ti.sysbios.family.c64p.tesla.Power').$used)) ||
75 (("ti.sysbios.family.arm.ducati.smp.Power" in xdc.om) &&
76 (xdc.module('ti.sysbios.family.arm.ducati.smp.Power').$used))) {
77 powerEnabled = true;
78 }
80 /* plug-in the power event hooks for SMP/BIOS */
81 if (Program.build.target.isa.match(/v7M4/) &&
82 (Program.platformName.match(/IPU/) ||
83 Program.platformName.match(/ipu/))) {
84 var BIOS = xdc.module('ti.sysbios.BIOS');
85 if ((BIOS.smpEnabled) &&
86 ("ti.sysbios.family.arm.ducati.smp.Power" in xdc.om)) {
87 var Power = xdc.module('ti.sysbios.family.arm.ducati.smp.Power');
88 if (Power.$used) {
89 Power.preSuspendHooks.$add("&IpcPower_preSuspend");
90 Power.postSuspendHooks.$add("&IpcPower_postResume");
91 }
92 }
93 }
94 }
96 /*
97 * ======== getLibs ========
98 */
99 function getLibs(prog)
100 {
101 var suffix;
102 var file;
103 var libAry = [];
104 var profile = this.profile;
105 var smp = "";
106 var device = prog.cpu.deviceName;
107 var platform = "";
109 suffix = prog.build.target.findSuffix(this);
110 if (suffix == null) {
111 return ""; /* nothing to contribute */
112 }
114 if (prog.platformName.match(/ipu/)) {
115 smp = "_smp";
116 }
118 switch (device) {
119 case "OMAP5430":
120 platform = "_omap5";
121 break;
123 case "Vayu":
124 case "DRA7XX":
125 platform = "_vayu";
126 break;
128 default:
129 throw ("Unspported device: " + device);
130 return ""; /* nothing to contribute */
131 }
133 /* Use the 'null' implementation if PM is not needed */
134 if (powerEnabled == false) {
135 libAry.push("lib/" + profile + "/ti.pm_null.a" + suffix);
136 }
137 else {
138 /* make sure the library exists, else fallback to a built library */
139 file = "lib/" + profile + "/ti.pm" + smp + platform + ".a" + suffix;
140 if (java.io.File(this.packageBase + file).exists()) {
141 libAry.push(file);
142 }
143 else {
144 file = "lib/release/ti.pm" + smp + platform + ".a" + suffix;
145 if (java.io.File(this.packageBase + file).exists()) {
146 libAry.push(file);
147 }
148 else {
149 /* fallback to a compatible library built by this package */
150 for (var p in this.build.libDesc) {
151 if (suffix == this.build.libDesc[p].suffix) {
152 libAry.push(p);
153 break;
154 }
155 }
156 }
157 }
158 }
160 return libAry.join(";");
161 }