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 * ======== GateAAMonitor.xs ========
34 *
35 */
37 var GateAAMonitor = null;
38 var Cache = null;
39 var Ipc = null;
40 var GateMP = null;
42 /*!
43 * ======== module$use ========
44 */
45 function module$use()
46 {
47 GateAAMonitor = this;
48 Cache = xdc.useModule('ti.sysbios.hal.Cache');
49 Ipc = xdc.useModule('ti.sdo.ipc.Ipc');
50 GateMP = xdc.useModule('ti.sdo.ipc.GateMP');
51 }
53 /*!
54 * ======== instance$static$init ========
55 */
56 function instance$static$init(obj, params)
57 {
58 GateAAMonitor.$logError("Static instances not supported yet",
59 GateAAMonitor.common$, GateAAMonitor.common$.namedInstance);
60 }
62 /*!
63 * ======== queryMeta ========
64 */
65 function queryMeta(qual)
66 {
67 var rc = false;
68 var IGateProvider = xdc.module('xdc.runtime.IGateProvider');
70 switch (qual) {
71 case IGateProvider.Q_BLOCKING:
72 rc = true;
73 break;
74 case IGateProvider.Q_PREEMPTING:
75 rc = true;
76 break;
77 default:
78 GateAAMonitor.$logWarning("Invalid quality.", this, qual);
79 break;
80 }
82 return (rc);
83 }
85 /*!
86 * ======== sharedMemReqMeta ========
87 */
88 function sharedMemReqMeta(params)
89 {
90 GateAAMonitor.$logError("Static instances not supported yet",
91 GateAAMonitor.common$, GateAAMonitor.common$.namedInstance);
92 }
94 /*!
95 * ======== getNumResources ========
96 */
97 function getNumResources()
98 {
99 return (this.numInstances);
100 }
102 /*
103 *************************************************************************
104 * ROV View functions
105 *************************************************************************
106 */
108 /*
109 * ======== getRemoteStatus$view ========
110 */
111 function getRemoteStatus$view(handle)
112 {
113 var Program = xdc.useModule('xdc.rov.Program');
115 try {
116 var view = Program.scanHandleView('ti.sdo.ipc.gates.GateAAMonitor',
117 $addr(handle), 'Basic');
118 return ("Entered by " + view.enteredBy);
119 }
120 catch(e) {
121 throw("ERROR: Couldn't scan GateAAMonitor handle view: " + e);
122 }
123 }
125 /*!
126 * ======== viewInitBasic ========
127 */
128 function viewInitBasic(view, obj)
129 {
130 var Ipc = xdc.useModule('ti.sdo.ipc.Ipc');
131 var GateAAMonitor = xdc.useModule('ti.sdo.ipc.gates.GateAAMonitor');
132 var ScalarStructs = xdc.useModule('xdc.rov.support.ScalarStructs');
134 /* view.sharedAddr */
135 view.sharedAddr = "0x" + Number(obj.sharedAddr).toString(16);
137 /* view.nested */
138 view.nested = obj.nested;
140 /* view.enteredBy */
141 try {
142 var sstruct_status = Program.fetchStruct(ScalarStructs.S_Bits32$fetchDesc,
143 obj.sharedAddr.$addr, false);
144 var status = sstruct_status.elem;
145 if (status > 0) {
146 view.enteredBy = "CORE" + (status - 1);
147 }
148 else {
149 view.enteredBy = "[free]";
150 }
151 }
152 catch(e) {
153 view.$status["enteredBy"] =
154 "Error: could not fetch status data from shared memory: " + e;
155 }
156 }