be8251d7146d38ed46309beb8b90514b79419519
1 /*
2 * Copyright (c) 2012-2014, 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 * ======== NotifyDriverMbx.xs ================
35 */
37 var NotifyDriverMbx = null;
38 var Core = null;
40 /*
41 * ======== module$use ========
42 */
43 function module$use()
44 {
45 var TableInit = xdc.useModule("ti.sdo.ipc.family.vayu.TableInit");
47 NotifyDriverMbx = this;
49 xdc.useModule("ti.sysbios.family.shared.vayu.IntXbar");
50 xdc.useModule("ti.sysbios.family.c64p.EventCombiner");
51 xdc.useModule("ti.sysbios.family.c64p.Hwi");
52 xdc.useModule("ti.sdo.ipc.Notify");
53 xdc.useModule("ti.sdo.utils.MultiProc");
55 if (Program.build.target.$name.match(/M3/)) {
56 Core = xdc.useModule("ti.sysbios.family.arm.ducati.Core");
57 }
59 /* initialize procIdTable */
60 TableInit.initProcId(NotifyDriverMbx);
62 /* Initialize mailboxTable */
63 TableInit.generateTable(NotifyDriverMbx);
65 /* Initialize mailbox base address table */
66 this.mailboxBaseAddr[0] = 0x4208B000; /* EVE1 Internal Mailbox 0 */
67 this.mailboxBaseAddr[1] = 0x4208C000; /* EVE1 Internal Mailbox 1 */
68 this.mailboxBaseAddr[2] = 0x4208D000; /* EVE1 Internal Mailbox 2 */
69 this.mailboxBaseAddr[3] = 0x4218B000; /* EVE2 Internal Mailbox 0 */
70 this.mailboxBaseAddr[4] = 0x4218C000; /* EVE2 Internal Mailbox 1 */
71 this.mailboxBaseAddr[5] = 0x4218D000; /* EVE2 Internal Mailbox 2 */
72 this.mailboxBaseAddr[6] = 0x4228B000; /* EVE3 Internal Mailbox 0 */
73 this.mailboxBaseAddr[7] = 0x4228C000; /* EVE3 Internal Mailbox 1 */
74 this.mailboxBaseAddr[8] = 0x4228D000; /* EVE3 Internal Mailbox 2 */
75 this.mailboxBaseAddr[9] = 0x4238B000; /* EVE4 Internal Mailbox 0 */
76 this.mailboxBaseAddr[10] = 0x4238C000; /* EVE4 Internal Mailbox 1 */
77 this.mailboxBaseAddr[11] = 0x4238D000; /* EVE4 Internal Mailbox 2 */
78 this.mailboxBaseAddr[12] = 0x48840000; /* System Mailbox 5 */
79 this.mailboxBaseAddr[13] = 0x48842000; /* System Mailbox 6 */
80 this.mailboxBaseAddr[14] = 0x48844000; /* System Mailbox 7 */
81 this.mailboxBaseAddr[15] = 0x48846000; /* System Mailbox 8 */
82 }
85 /*
86 * ======== module$static$init ========
87 * Initialize the target state object.
88 */
89 function module$static$init(state, mod)
90 {
92 for (var i = 0; i < state.drvHandles.length; i++) {
93 state.drvHandles[i] = null;
94 }
96 /* TODO this code is specific to the DSP, need to add other processors */
99 if (Program.build.target.$name.match(/M3/)) {
100 /* TODO */
101 if (0) {
102 if (Core.id == 0) {
103 Hwi.construct(state.hwi, 53, NotifyDriverMbx.isr);
104 }
105 else {
106 Hwi.construct(state.hwi, 54, NotifyDriverMbx.isr);
107 }
108 }
109 }
110 else if (Program.build.target.isa == "66") {
111 /* interrupt event IDs used by this processor */
112 state.interruptTable[0] = 55; /* EVE1 -> DSP1 or DSP2 */
113 state.interruptTable[1] = 56; /* EVE2 -> DSP1 or DSP2 */
114 state.interruptTable[2] = 58; /* EVE3 -> DSP1 or DSP2 */
115 state.interruptTable[3] = 59; /* EVE4 -> DSP1 or DSP2 */
116 state.interruptTable[4] = 60; /* DSP1 -> DSP2 */
117 state.interruptTable[5] = 60; /* DSP2 -> DSP1 */
118 state.interruptTable[8] = 57; /* HOST -> DSP1 or DSP2 */
120 /* these are not known at config time, set at runtime */
121 state.interruptTable[6] = 0; /* IPU1 -> DSP1 or DSP2 */
122 state.interruptTable[7] = 0; /* IPU2 -> DSP1 or DSP2 */
123 state.interruptTable[9] = 0; /* IPU1-1 -> DSP1 or DSP2 */
124 state.interruptTable[10] = 0; /* IPU2-1 -> DSP1 or DSP2 */
125 }
126 else if (Program.build.target.$name.match(/A8/)) {
127 /* TODO */
128 if (0) {
129 Hwi.construct(state.hwi, 77, NotifyDriverMbx.isr);
130 }
131 }
132 else {
133 throw("Invalid target: " + Program.build.target.$name);
134 }
135 }
137 /*
138 *************************************************************************
139 * ROV View functions
140 *************************************************************************
141 */
143 /*
144 * ======== viewInitBasic ========
145 */
146 function viewInitBasic(view, obj)
147 {
148 var Program = xdc.useModule('xdc.rov.Program');
149 var ScalarStructs = xdc.useModule('xdc.rov.support.ScalarStructs');
150 var MultiProc = xdc.useModule('ti.sdo.utils.MultiProc');
151 var modCfg = Program.getModuleConfig(
152 'ti.sdo.ipc.family.vayu.NotifyDriverMbx');
154 /* translate the virtual id to a processor id */
155 var remoteProcId = -1;
157 for (var i = 0; i < modCfg.procIdTable.length; i++) {
158 if (obj.remoteVirtId == modCfg.procIdTable[i]) {
159 remoteProcId = i;
160 break;
161 }
162 }
164 /* view.remoteProc */
165 try {
166 view.remoteProc = MultiProc.getName$view(remoteProcId);
167 }
168 catch (e) {
169 Program.displayError(view, 'remoteProc',
170 "Problem retrieving proc name: " + e);
171 }
173 /* view.mailboxAddr */
174 var selfVirtId = modCfg.procIdTable[MultiProc.self$view()];
175 var idx = (obj.remoteVirtId * modCfg.NUM_CORES) + selfVirtId;
176 var baseAddrIdx = (modCfg.mailboxTable[idx] >> 16) & 0xFFFF;
177 var mailboxAddr = modCfg.mailboxBaseAddr[baseAddrIdx];
178 view.mailboxAddr = "0x" + Number(mailboxAddr).toString(16);
180 /* view.subMbxId */
181 view.subMbxId = modCfg.mailboxTable[idx] & 0xFF;
183 /* view.count */
184 try {
185 var MAILBOX_STATUS_IN = Program.fetchStruct(
186 ScalarStructs.S_Bits32$fetchDesc,
187 mailboxAddr + 0xC0 + (0x4 * view.subMbxId), false);
188 view.count = MAILBOX_STATUS_IN.elem;
189 }
190 catch (e) {
191 throw(e);
192 }
193 }