1 /*
2 * Copyright (c) 2012-2013, 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 */
32 /*
33 * ======== NotifyDriverMbx.xs ================
34 */
36 var NotifyDriverMbx = null;
37 var MultiProc = null;
38 var Notify = null;
39 var Hwi = null;
40 var Core = null;
42 /*
43 * ======== module$use ========
44 */
45 function module$use()
46 {
47 NotifyDriverMbx = this;
48 MultiProc = xdc.useModule("ti.sdo.utils.MultiProc");
49 Notify = xdc.useModule("ti.sdo.ipc.Notify");
50 Hwi = xdc.useModule("ti.sysbios.hal.Hwi");
52 if (Program.build.target.$name.match(/M3/)) {
53 Core = xdc.useModule("ti.sysbios.family.arm.ducati.Core");
54 }
56 this.dspProcId = MultiProc.getIdMeta("DSP");
57 this.videoProcId = MultiProc.getIdMeta("VIDEO-M3");
58 this.vpssProcId = MultiProc.getIdMeta("VPSS-M3");
59 this.hostProcId = MultiProc.getIdMeta("HOST");
60 }
63 /*
64 * ======== module$static$init ========
65 */
66 function module$static$init(mod, params)
67 {
68 for (var i = 0; i < mod.drvHandles.length; i++) {
69 mod.drvHandles[i] = null;
70 }
72 if (Program.build.target.$name.match(/M3/)) {
73 if (Core.id == 0) {
74 Hwi.construct(mod.hwi, 53, NotifyDriverMbx.isr);
75 }
76 else {
77 Hwi.construct(mod.hwi, 54, NotifyDriverMbx.isr);
78 }
79 }
80 else if (Program.build.target.$name.match(/674/)) {
81 var hwiParams = new Hwi.Params();
82 hwiParams.eventId = 56;
83 /*
84 * NotifyDriverMbx.intVectorId is typically set by the module that
85 * creates the Notify driver (i.e. the Notify setup module)
86 */
87 Hwi.construct(mod.hwi, this.intVectorId, NotifyDriverMbx.isr,
88 hwiParams);
89 }
90 else if (Program.build.target.$name.match(/A8/)) {
91 Hwi.construct(mod.hwi, 77, NotifyDriverMbx.isr);
92 }
93 else {
94 throw("Invalid target: " + Program.build.target.$name);
95 }
96 }
98 /*
99 *************************************************************************
100 * ROV View functions
101 *************************************************************************
102 */
104 /*
105 * Assigned mailboxes. Structure is:
106 * var mailBoxMap = {
107 * "SRC_PROC_0" : {
108 * "DST_PROC_1" : M(SRC_PROC_0_to_DST_PROC_1)
109 * "DST_PROC_2", M(SRC_PROC_0_to_DST_PROC_2)
110 * :
111 * },
112 * :
113 * }
114 */
115 var mailboxMap = {
116 "DSP" : {
117 "HOST" : 0,
118 "VIDEO-M3" : 1,
119 "VPSS-M3" : 2,
120 },
121 "HOST" : {
122 "DSP" : 3,
123 "VIDEO-M3" : 4,
124 "VPSS-M3" : 5,
125 },
126 "VIDEO-M3" : {
127 "HOST" : 6,
128 "DSP" : 7,
129 "VPSS-M3" : 10,
130 },
131 "VPSS-M3" : {
132 "HOST" : 8,
133 "DSP" : 9,
134 "VIDEO-M3" : 11,
135 },
136 }
138 /* Used to access core-specific mailbox registers */
139 var coreIds = {
140 "HOST" : 0,
141 "DSP" : 1,
142 "VIDEO-M3" : 2,
143 "VPSS-M3" : 3,
144 }
146 /*
147 * ======== viewInitBasic ========
148 */
149 function viewInitBasic(view, obj)
150 {
151 var Program = xdc.useModule('xdc.rov.Program');
152 var ScalarStructs = xdc.useModule('xdc.rov.support.ScalarStructs');
153 var MultiProc = xdc.useModule('ti.sdo.utils.MultiProc');
154 var modCfg =
155 Program.getModuleConfig('ti.sdo.ipc.family.ti81xx.NotifyDriverMbx');
156 var NotifyModCfg = Program.getModuleConfig('ti.sdo.ipc.Notify');
158 /* view.remoteProcName */
159 try {
160 view.remoteProcName = MultiProc.getName$view(obj.remoteProcId);
161 }
162 catch(e) {
163 Program.displayError(view, 'remoteProcName',
164 "Problem retrieving proc name: " + e);
165 }
167 /* view.registeredEvents */
168 var registeredEvents = [];
169 for (i = 0; i < NotifyModCfg.numEvents; i++) {
170 print("Checking event #" + i);
171 if (obj.evtRegMask & (1 << i)) {
172 print("registered!");
173 registeredEvents.push(i.toString());
174 }
175 }
176 view.registeredEvents = registeredEvents.join(", ");
178 /* view.numPending */
179 var localName = MultiProc.getName$view(MultiProc.self$view());
180 var remoteName = view.remoteProcName;
182 var M_in = mailboxMap[remoteName][localName];
183 var M_out = mailboxMap[localName][remoteName];
185 try {
186 var MAILBOX_STATUS_IN = Program.fetchStruct(
187 ScalarStructs.S_Bits32$fetchDesc,
188 modCfg.mailboxBaseAddr + 0xC0 + (0x4 * M_in), false);
189 var MAILBOX_STATUS_OUT = Program.fetchStruct(
190 ScalarStructs.S_Bits32$fetchDesc,
191 modCfg.mailboxBaseAddr + 0xC0 + (0x4 * M_out), false);
192 view.numIncomingPending = MAILBOX_STATUS_IN.elem;
193 view.numOutgoingPending = MAILBOX_STATUS_OUT.elem;
194 }
195 catch(e) {
196 throw(e);
197 }
199 /* view.intStatus */
200 try {
201 var MAILBOX_IRQENABLE_CLR_LOCAL = Program.fetchStruct(
202 ScalarStructs.S_Bits32$fetchDesc,
203 modCfg.mailboxBaseAddr + 0x10C + (0x10 * coreIds[localName]),
204 false);
205 if (MAILBOX_IRQENABLE_CLR_LOCAL.elem & (1 << 2 * M_in)) {
206 view.incomingIntStatus = "Enabled";
207 }
208 else {
209 view.incomingIntStatus = "Disabled";
210 }
212 var MAILBOX_IRQENABLE_CLR_REMOTE = Program.fetchStruct(
213 ScalarStructs.S_Bits32$fetchDesc,
214 modCfg.mailboxBaseAddr + 0x10C + (0x10 * coreIds[remoteName]),
215 false);
216 if (MAILBOX_IRQENABLE_CLR_REMOTE.elem & (1 << 2 * M_out)) {
217 view.outgoingStatus = "Enabled";
218 }
219 else {
220 view.outgoingStatus = "Disabled";
221 }
222 }
223 catch(e) {
224 throw(e);
225 }
226 }