1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
32 33 34
35
36 import ti.sdo.utils.MultiProc;
37 import ti.sdo.ipc.interfaces.INotifyDriver;
38 import ti.sdo.ipc.notifyDrivers.IInterrupt;
39 import ti.sdo.ipc.Notify;
40
41 import xdc.rov.ViewInfo;
42
43 import xdc.runtime.Assert;
44
45 /*!
46 * ======== NotifyDriverCirc ========
47 * Shared memory driver using circular buffer for F28M35x devices.
48 *
49 * This is a {@link ti.sdo.ipc.Notify} driver that utilizes shared memory
50 * and inter-processor hardware interrupts for notification between cores.
51 *
52 * This driver is designed to work with only F28M35x family of devices.
53 * This module needs to be plugged with an appropriate module that implements
54 * the {@link ti.sdo.ipc.notifyDrivers.IInterrupt} interface for a given
55 * device.
56 *
57 * The driver utilizes shared memory in the manner indicated by the following
58 * diagram.
59 *
60 * @p(code)
61 *
62 * NOTE: Processor '0' corresponds to the M3 and '1' corresponds to the C28
63 *
64 * sharedAddr -> --------------------------- bytes
65 * | eventEntry0 (0) | 8
66 * | eventEntry1 (0) | 8
67 * | ... |
68 * | eventEntry15 (0) | 8
69 * | |
70 * |-------------------------|
71 * | eventEntry16 (0) | 8
72 * | eventEntry17 (0) | 8
73 * | ... |
74 * | eventEntry31 (0) | 8
75 * | |
76 * |-------------------------|
77 * | putWriteIndex (0) | 4
78 * | |
79 * |-------------------------|
80 * | getReadIndex (1) | 4
81 * | |
82 * |-------------------------|
83 * | eventEntry0 (1) | 8
84 * | eventEntry1 (1) | 8
85 * | ... |
86 * | eventEntry15 (1) | 8
87 * | |
88 * |-------------------------|
89 * | eventEntry16 (1) | 8
90 * | eventEntry17 (1) | 8
91 * | ... |
92 * | eventEntry31 (1) | 8
93 * | |
94 * |-------------------------|
95 * | putWriteIndex (1) | 4
96 * | |
97 * |-------------------------|
98 * | getReadIndex (0) | 4
99 * | |
100 * |-------------------------|
101 *
102 *
103 * Legend:
104 * (0), (1) : belongs to the respective processor
105 *
106 * @p
107 */
108
109 @InstanceFinalize
110
111 module NotifyDriverCirc inherits ti.sdo.ipc.interfaces.INotifyDriver
112 {
113 /*! @_nodoc */
114 metaonly struct BasicView {
115 String remoteProcName;
116 UInt bufSize;
117 UInt spinCount;
118 UInt maxSpinWait;
119 }
120
121 /*! @_nodoc */
122 metaonly struct EventDataView {
123 UInt index;
124 String buffer;
125 Ptr addr;
126 UInt eventId;
127 Ptr payload;
128 }
129
130 /*!
131 * ======== rovViewInfo ========
132 */
133 @Facet
134 metaonly config ViewInfo.Instance rovViewInfo =
135 ViewInfo.create({
136 viewMap: [
137 ['Basic',
138 {
139 type: ViewInfo.INSTANCE,
140 viewInitFxn: 'viewInitBasic',
141 structName: 'BasicView'
142 }
143 ],
144 ['Events',
145 {
146 type: ViewInfo.INSTANCE_DATA,
147 viewInitFxn: 'viewInitData',
148 structName: 'EventDataView'
149 }
150 ],
151 ]
152 });
153
154 /*!
155 * Assert raised when trying to use Notify_[enable/disable]Event with
156 * NotifyDriverCirc
157 */
158 config Assert.Id A_notSupported =
159 {msg: "A_notSupported: [enable/disable]Event not supported by NotifyDriverCirc"};
160
161 /*! @_nodoc
162 * ======== numMsgs ========
163 * The number of messages or slots in the circular buffer
164 *
165 * This is use to determine the size of the put and get buffers.
166 * Each eventEntry is two 32bits wide, therefore the total size
167 * of each circular buffer is [numMsgs * sizeof(eventEntry)].
168 */
169 config UInt numMsgs = 16;
170
171 /*!
172 * ======== sharedMemReq ========
173 * Amount of shared memory required for creation of each instance
174 *
175 * @param(params) Pointer to parameters that will be used in the
176 * create
177 *
178 * @a(returns) Number of MAUs in shared memory needed to create
179 * the instance.
180 */
181 SizeT sharedMemReq(const Params *params);
182
183 /*! @_nodoc
184 * ======== sharedMemReqMeta ========
185 * Amount of shared memory required
186 *
187 * @param(params) Pointer to the parameters that will be used in
188 * create.
189 *
190 * @a(returns) Size of shared memory in MAUs on local processor.
191 */
192 metaonly SizeT sharedMemReqMeta(const Params *params);
193
194 instance:
195
196 /*!
197 * ======== readAddr ========
198 * Address in shared memory where buffer is placed
199 *
200 * Use {@link #sharedMemReq} to determine the amount of shared memory
201 * required.
202 */
203 config Ptr readAddr = null;
204
205 /*!
206 * ======== writeAddr ========
207 * Address in shared memory where buffer is placed
208 *
209 * Use {@link #sharedMemReq} to determine the amount of shared memory
210 * required.
211 */
212 config Ptr writeAddr = null;
213
214 internal:
215
216 /*!
217 * ======== localIntId ========
218 * Local interrupt ID for interrupt line
219 *
220 * For devices that support multiple inter-processor interrupt lines, this
221 * configuration parameter allows selecting a specific line to use for
222 * receiving an interrupt. The value specified here corresponds to the
223 * incoming interrupt line on the local processor.
224 */
225 config UInt localIntId;
226
227 /*!
228 * ======== remoteIntId ========
229 * Remote interrupt ID for interrupt line
230 *
231 * For devices that support multiple inter-processor interrupt lines, this
232 * configuration parameter allows selecting a specific line to use for
233 * receiving an interrupt. The value specified here corresponds to the
234 * incoming interrupt line on the remote processor.
235 */
236 config UInt remoteIntId;
237
238 /*! The max index set to (numMsgs - 1) */
239 config UInt maxIndex;
240
241 /*!
242 * The modulo index value. Set to (numMsgs / 4).
243 * Used in the isr for doing cache_wb of readIndex.
244 */
245 config UInt modIndex;
246
247 /*!
248 * enable IPC interrupt
249 */
250 Void intEnable();
251
252 /*!
253 * disable IPC interrupt
254 */
255 Void intDisable();
256
257 /*!
258 * trigger IPC interrupt
259 */
260 Void intSend();
261
262 /*!
263 * clear IPC interrupt
264 */
265 UInt intClear();
266
267 /*!
268 * executes the callback functions according to event priority
269 */
270 Void isr(UArg arg);
271
272 /*!
273 * Structure for each event. This struct is placed in shared memory.
274 */
275 struct EventEntry {
276 volatile Bits32 eventid;
277 volatile Bits32 payload;
278 }
279
280 /*! Instance state structure */
281 struct Instance_State {
282 EventEntry *putBuffer;
283 Bits32 *putReadIndex;
284 Bits32 *putWriteIndex;
285 EventEntry *getBuffer;
286 Bits32 *getReadIndex;
287 Bits32 *getWriteIndex;
288 Bits32 evtRegMask;
289 Notify.Handle notifyHandle;
290 UInt16 remoteProcId;
291 }
292 }