5536c6e9755a7d32ade8e90abec4167bb2fe9a67
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 * ======== NotifyDriverShm.xs ================
34 *
35 */
37 var NotifyDriverShm = null;
38 var List = null;
39 var MultiProc = null;
40 var Notify = null;
41 var Ipc = null;
42 var Cache = null;
43 var Memory = null;
44 var SharedRegion = null;
46 /*
47 * ======== module$use ========
48 */
49 function module$use()
50 {
51 NotifyDriverShm = this;
52 List = xdc.useModule("ti.sdo.utils.List");
53 MultiProc = xdc.useModule("ti.sdo.utils.MultiProc");
54 Notify = xdc.useModule("ti.sdo.ipc.Notify");
55 Ipc = xdc.useModule("ti.sdo.ipc.Ipc");
56 SharedRegion = xdc.useModule("ti.sdo.ipc.SharedRegion");
57 Cache = xdc.useModule("ti.sysbios.hal.Cache");
58 Memory = xdc.useModule("xdc.runtime.Memory");
60 if (NotifyDriverShm.InterruptProxy == null) {
61 var Settings = xdc.module("ti.sdo.ipc.family.Settings");
62 var interruptDelegate = Settings.getDefaultInterruptDelegate();
63 NotifyDriverShm.InterruptProxy = xdc.useModule(interruptDelegate);
64 }
65 }
67 /*
68 *************************************************************************
69 * ROV View functions
70 *************************************************************************
71 */
73 /*
74 * ======== viewInitBasic ========
75 */
76 function viewInitBasic(view, obj)
77 {
78 var MultiProc = xdc.useModule('ti.sdo.utils.MultiProc');
80 /* view.remoteProcName */
81 try {
82 view.remoteProcName = MultiProc.getName$view(obj.remoteProcId);
83 }
84 catch(e) {
85 Program.displayError(view, 'remoteProcName',
86 "Problem retrieving proc name: " + e);
87 }
90 /* view.cacheEnabled */
91 view.cacheEnabled = obj.cacheEnabled;
92 }
94 /*
95 * ======== getEventData ========
96 * Helper function for use within viewInitData
97 */
98 function getEventData(view, obj, procCtrlPtr, eventChartPtr)
99 {
100 var NotifyDriverShm =
101 xdc.useModule('ti.sdo.ipc.notifyDrivers.NotifyDriverShm');
102 var modCfg = Program.getModuleConfig('ti.sdo.ipc.Notify');
104 if (procCtrlPtr == obj.selfProcCtrl) {
105 var procName = "[local]";
106 }
107 else {
108 var procName = "[remote]";
109 }
111 try {
112 var procCtrl = Program.fetchStruct(NotifyDriverShm.ProcCtrl$fetchDesc,
113 procCtrlPtr, false);
114 }
115 catch(e) {
116 throw (new Error("Error fetching procCtrl struct from shared memory"));
117 }
119 /* For each possible eventId... */
120 for (var eventId = 0; eventId < modCfg.numEvents; eventId++) {
121 if (procCtrl.eventRegMask & (1 << eventId)) {
122 /* The event is registered */
123 var elem = Program.newViewStruct(
124 'ti.sdo.ipc.notifyDrivers.NotifyDriverShm',
125 'Events');
127 elem.eventId = eventId;
128 elem.procName = procName;
129 elem.enabled = procCtrl.eventEnableMask & (1 << eventId);
131 try {
132 var eventEntry = Program.fetchStruct(
133 NotifyDriverShm.EventEntry$fetchDesc,
134 $addr(Number(eventChartPtr) + obj.eventEntrySize *
135 eventId), false);
137 }
138 catch (e) {
139 throw (new Error("Error fetching eventEntry from shared memory"));
140 }
142 elem.flagged = (eventEntry.flag == NotifyDriverShm.UP);
143 elem.payload = eventEntry.payload;
145 /* Create a new row in the instance data view */
146 view.elements.$add(elem);
147 }
148 }
149 }
152 /*
153 * ======== viewInitData ========
154 * Instance data view.
155 */
156 function viewInitData(view, obj)
157 {
158 var MultiProc = xdc.useModule('ti.sdo.utils.MultiProc');
159 try {
160 var notifyObj = Program.scanHandleView('ti.sdo.ipc.Notify',
161 obj.notifyHandle, 'Basic');
162 }
163 catch (e) {
164 throw (new Error("Error fetching Notify instance view"));
165 }
167 /* Display the instance label in the tree */
168 view.label = "procId = " + obj.remoteProcId + " lineId = " +
169 notifyObj.lineId;
171 /* Fetch self/other procCtrl's */
172 try {
173 var procCtrl = Program.fetchStruct(obj.selfProcCtrl$fetchDesc,
174 obj.selfProcCtrl, false);
175 }
176 catch(e) {
177 throw (new Error("Error fetching procCtrl struct from shared memory"));
178 }
180 /* Get event data for the local processor */
181 getEventData(view, obj, obj.selfProcCtrl, obj.selfEventChart);
183 /* Get event data for the remote processor */
184 getEventData(view, obj, obj.otherProcCtrl, obj.otherEventChart);
186 }