aa63a36609903593e27a0742d778f7e7e08da611
[ipc/ipcdev.git] / packages / ti / sdo / ipc / family / vayu / NotifyDriverMbx.c
1 /*
2  * Copyright (c) 2014 Texas Instruments Incorporated - http://www.ti.com
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.c ========
35  */
36 #include <xdc/std.h>
37 #include <xdc/runtime/Assert.h>
38 #include <xdc/runtime/Startup.h>
40 #include <ti/sysbios/BIOS.h>
41 #include <ti/sysbios/family/c64p/EventCombiner.h>
42 #include <ti/sysbios/family/c64p/Hwi.h>
43 #include <ti/sysbios/family/shared/vayu/IntXbar.h>
45 #include <ti/sdo/ipc/_Ipc.h>
46 #include <ti/sdo/ipc/_Notify.h>
47 #include <ti/sdo/ipc/family/vayu/NotifySetup.h>
48 #include <ti/sdo/ipc/interfaces/INotifyDriver.h>
49 #include <ti/sdo/utils/_MultiProc.h>
51 #include "package/internal/NotifyDriverMbx.xdc.h"
53 /* Bit mask operations */
54 #define SET_BIT(num,pos)            ((num) |= (1u << (pos)))
55 #define CLEAR_BIT(num,pos)          ((num) &= ~(1u << (pos)))
56 #define TEST_BIT(num,pos)           ((num) & (1u << (pos)))
58 /* register access methods */
59 #define REG16(A)        (*(volatile UInt16 *)(A))
60 #define REG32(A)        (*(volatile UInt32 *)(A))
62 #define MAILBOX_FIFOLENGTH 4
63 #define PROCID(idx) (NotifyDriverMbx_procIdTable[idx])
65 #define MBX_BASEADDR_IDX(idx) \
66         ((NotifyDriverMbx_mailboxTable[idx] >> 16) & 0xFFFF)
68 #define MAILBOX_ADDR(idx) \
69         (NotifyDriverMbx_mailboxBaseAddr[MBX_BASEADDR_IDX(idx)])
71 #define MBX_TABLE_IDX(src, dst) \
72         ((PROCID(src) * NotifyDriverMbx_NUM_CORES) + PROCID(dst))
74 #define SUBMBX_IDX(idx) (NotifyDriverMbx_mailboxTable[idx] & 0xFF)
76 #define MBX_USER_IDX(idx) ((NotifyDriverMbx_mailboxTable[idx] >> 8) & 0xFF)
78 #define MAILBOX_REG_VAL(m) (0x1 << (2 * m))
80 #define MAILBOX_MESSAGE(idx) \
81         (MAILBOX_ADDR(idx) + 0x40 + (0x4 * SUBMBX_IDX(idx)))
83 #define MAILBOX_STATUS(idx) \
84         (MAILBOX_ADDR(idx) + 0xC0 + (0x4 * SUBMBX_IDX(idx)))
86 #define MAILBOX_IRQSTATUS_CLR(idx) \
87         (MAILBOX_ADDR(idx) + 0x104 + (0x10 * MBX_USER_IDX(idx)))
89 #define MAILBOX_IRQENABLE_SET(idx) \
90         (MAILBOX_ADDR(idx) + 0x108 + (0x10 * MBX_USER_IDX(idx)))
92 #define MAILBOX_IRQENABLE_CLR(idx) \
93         (MAILBOX_ADDR(idx) + 0x10C + (0x10 * MBX_USER_IDX(idx)))
95 #define MAILBOX_EOI_REG(idx) (MAILBOX_ADDR(idx) + 0x140)
97 #define EVENT_GROUP_SIZE 32
99 /* empty the mailbox for the given index, clear its interrupt */
100 #define MAILBOX_INIT(idx)                                                   \
101     while (REG32(MAILBOX_STATUS(idx)) != 0) {                               \
102         REG32(MAILBOX_MESSAGE(idx));                                        \
103     }                                                                       \
104     REG32(MAILBOX_IRQSTATUS_CLR(idx)) = MAILBOX_REG_VAL(SUBMBX_IDX(idx));
106 /*
107  *************************************************************************
108  *                       Module functions
109  *************************************************************************
110  */
112 /*
113  *  ======== NotifyDriverMbx_Module_startup ========
114  */
115 Int NotifyDriverMbx_Module_startup(Int phase)
117 #if defined(xdc_target__isaCompatible_64P)
119     extern cregister volatile UInt DNUM;
121     if (IntXbar_Module_startupDone()) {
122         /* connect mailbox interrupts at startup */
123         if (DNUM == 0) {               /* DSP1 */
124             IntXbar_connect(24, 284);  // eve1 mailbox 0 user 1
125             IntXbar_connect(25, 293);  // eve2 mailbox 0 user 1
126             IntXbar_connect(26, 249);  // system mailbox 5 user 0
128             NotifyDriverMbx_module->interruptTable[6] = 57; // IPU1-0
129             NotifyDriverMbx_module->interruptTable[9] = 57; // IPU1-1
131             /* plug eve3 and eve4 mbxs only if eve3 and eve4 exists */
132             if ((MultiProc_getId("EVE3") != MultiProc_INVALIDID) ||
133                 (MultiProc_getId("EVE4") != MultiProc_INVALIDID)) {
134                 IntXbar_connect(27, 302);  // eve3 mailbox 0 user 1
135                 IntXbar_connect(28, 311);  // eve4 mailbox 0 user 1
136             }
138             /* plug mbx7 only if DSP2 or IPU2 exists */
139             if ((MultiProc_getId("DSP2") != MultiProc_INVALIDID) ||
140                 (MultiProc_getId("IPU2") != MultiProc_INVALIDID) ||
141                 (MultiProc_getId("IPU2-0") != MultiProc_INVALIDID)) {
142                 IntXbar_connect(29, 257);  // system mailbox 7 user 0
143                 NotifyDriverMbx_module->interruptTable[7] = 60; // IPU2-0
144             }
146             /* plug mbx8 only if IPU2-1 exists */
147             if (MultiProc_getId("IPU2-1") != MultiProc_INVALIDID) {
148                 IntXbar_connect(30, 261);  // system mailbox 8 user 0
149                 NotifyDriverMbx_module->interruptTable[10] = 61; // IPU2-1
150             }
151         }
152         else if (DNUM == 1) {          /* DSP2 */
153             IntXbar_connect(24, 287);  // eve1 mailbox 1 user 1
154             IntXbar_connect(25, 296);  // eve2 mailbox 1 user 1
155             IntXbar_connect(26, 253);  // system mailbox 6 user 0
157             NotifyDriverMbx_module->interruptTable[7] = 57; // IPU2-0
158             NotifyDriverMbx_module->interruptTable[10] = 57; // IPU2-1
160             /* plug eve3 and eve4 mbxs only if eve3 and eve4 exists */
161             if ((MultiProc_getId("EVE3") != MultiProc_INVALIDID) ||
162                 (MultiProc_getId("EVE4") != MultiProc_INVALIDID)) {
163                 IntXbar_connect(27, 305);  // eve3 mailbox 1 user 1
164                 IntXbar_connect(28, 314);  // eve4 mailbox 1 user 1
165             }
167             /* plug mbx7 only if DSP1 or IPU1 exists */
168             if ((MultiProc_getId("DSP1") != MultiProc_INVALIDID) ||
169                 (MultiProc_getId("IPU1") != MultiProc_INVALIDID) ||
170                 (MultiProc_getId("IPU1-0") != MultiProc_INVALIDID)) {
171                 IntXbar_connect(29, 258);  // system mailbox 7 user 1
172                 NotifyDriverMbx_module->interruptTable[6] = 60; // IPU1-0
173             }
175             /* plug mbx8 only if IPU1-1 exists */
176             if (MultiProc_getId("IPU1-1") != MultiProc_INVALIDID) {
177                 IntXbar_connect(30, 262);  // system mailbox 8 user 1
178                 NotifyDriverMbx_module->interruptTable[9] = 61; // IPU1-1
179             }
180         }
181         return (Startup_DONE);
182     }
184     return (Startup_NOTDONE);
186 #elif defined(xdc_target__isaCompatible_arp32)
188     /* nothing to do on this processor */
189     return (Startup_DONE);
191 #elif defined(xdc_target__isaCompatible_v7M)
193     /* TODO */
194     return (Startup_DONE);
196 #elif defined(xdc_target__isaCompatible_v7A)
198     /* TODO */
199     return (Startup_DONE);
201 #else
202 #error Invalid target
203 #endif
206 /*
207  **************************************************************
208  *                       Instance functions
209  **************************************************************
210  */
212 /*
213  *  ======== NotifyDriverMbx_Instance_init ========
214  */
215 Void NotifyDriverMbx_Instance_init(NotifyDriverMbx_Object *obj,
216         const NotifyDriverMbx_Params *params)
218     UInt        key;
219     UInt16      selfVirtId;
220     UInt16      index;
222     Assert_isTrue((params->remoteProcId != MultiProc_INVALIDID) &&
223             (params->remoteProcId != MultiProc_self()),
224             ti_sdo_ipc_Ipc_A_invParam);
226     /* TODO: this check is weak */
227     if (params->remoteProcId >= MultiProc_getNumProcessors() ||
228         params->remoteProcId == MultiProc_INVALIDID) {
229         return;    /* keep Coverity happy */
230     }
232     obj->evtRegMask = 0;
233     obj->notifyHandle = NULL;
234     obj->remoteProcId = params->remoteProcId;
235     obj->remoteVirtId = PROCID(params->remoteProcId);
236     obj->cpuIntrNum = params->intVectorId;
238     /* disable global interrupts */
239     key = Hwi_disable();
241     /* clear mailbox of any old messages */
242     selfVirtId = PROCID(MultiProc_self());
243     index = (selfVirtId * NotifyDriverMbx_NUM_CORES) + obj->remoteVirtId;
244     MAILBOX_INIT(index);
246     /* must use processor virtual ID to store driver handle in table */
247     NotifyDriverMbx_module->drvHandles[obj->remoteVirtId] = obj;
249     /* plug the cpu interrupt */
250     NotifySetup_plugHwi(params->remoteProcId, params->intVectorId,
251             NotifyDriverMbx_isr);
253     /* enable the mailbox interrupt from the remote core */
254     NotifyDriverMbx_enable(obj);
256     /* restore global interrupts */
257     Hwi_restore(key);
260 /*
261  *  ======== NotifyDriverMbx_Instance_finalize ========
262  */
263 Void NotifyDriverMbx_Instance_finalize(NotifyDriverMbx_Object *obj)
266     /* disable the mailbox interrupt source */
267     NotifyDriverMbx_disable(obj);
269     /* unplug isr and unprogram the event dispatcher */
270     NotifySetup_unplugHwi(obj->remoteProcId, obj->cpuIntrNum);
272     /* must use processor virtual ID to remove driver handle from table */
273     NotifyDriverMbx_module->drvHandles[obj->remoteVirtId] = NULL;
276 /*
277  *  ======== NotifyDriverMbx_registerEvent ========
278  */
279 Void NotifyDriverMbx_registerEvent(NotifyDriverMbx_Object *obj,
280                                    UInt32 eventId)
282     UInt hwiKey;
284     /*
285      *  Disable interrupt line to ensure that isr doesn't
286      *  preempt registerEvent and encounter corrupt state
287      */
288     hwiKey = Hwi_disable();
290     /* Set the 'registered' bit */
291     SET_BIT(obj->evtRegMask, eventId);
293     /* Restore the interrupt line */
294     Hwi_restore(hwiKey);
297 /*
298  *  ======== NotifyDriverMbx_unregisterEvent ========
299  */
300 Void NotifyDriverMbx_unregisterEvent(NotifyDriverMbx_Object *obj,
301                                      UInt32 eventId)
303     UInt hwiKey;
305     /*
306      *  Disable interrupt line to ensure that isr doesn't
307      *  preempt registerEvent and encounter corrupt state
308      */
309     hwiKey = Hwi_disable();
311     /* Clear the registered bit */
312     CLEAR_BIT(obj->evtRegMask, eventId);
314     /* Restore the interrupt line */
315     Hwi_restore(hwiKey);
318 /*
319  *  ======== NotifyDriverMbx_sendEvent ========
320  */
321 /*
322  *  PUT_NOTIFICATION will spin waiting for enough room in the mailbox FIFO
323  *  to store the number of messages needed for the notification ('numMsgs').
324  *  If spinning is necesssary (i.e. if waitClear is TRUE and there isn't enough
325  *  room in the FIFO) then PUT_NOTIFICATION will allow pre-emption while
326  *  spinning.
327  *
328  *  PUT_NOTIFICATION needs to prevent another local thread from writing to the
329  *  same mailbox after the current thread has
330  *  1) determined that there is enough room to write the notification and
331  *  2) written the first of two messages to the mailbox.
332  *  This is needed to respectively prevent
333  *  1) both threads from incorrectly assuming there is enough space in the FIFO
334  *     for their own notifications
335  *  2) the interrupting thread from writing a notification between two
336  *     two messages that need to be successivly written by the preempted thread.
337  *  Therefore, the check for enough FIFO room and one/both mailbox write(s)
338  *  should all occur atomically (i.e. with interrupts disabled)
339  */
340 #define PUT_NOTIFICATION(idx)                                               \
341         key = Hwi_disable();                                                \
342         while(MAILBOX_FIFOLENGTH - REG32(MAILBOX_STATUS(idx)) < numMsgs) {  \
343             Hwi_restore(key);                                               \
344             if (!waitClear) {                                               \
345                 return (Notify_E_FAIL);                                     \
346             }                                                               \
347             key = Hwi_disable();                                            \
348         };                                                                  \
349         REG32(MAILBOX_MESSAGE(idx)) = eventId + smallPayload;               \
350         if (smallPayload == 0xFFFFFFE0) {                                   \
351             REG32(MAILBOX_MESSAGE(idx)) = payload;                          \
352         }                                                                   \
353         Hwi_restore(key);
355 Int NotifyDriverMbx_sendEvent(NotifyDriverMbx_Object *obj, UInt32 eventId,
356         UInt32 payload, Bool waitClear)
358     UInt16 selfVirtId = PROCID(MultiProc_self());
359     UInt key, numMsgs;
360     UInt32 smallPayload;
361     UInt16 index;
363     /* Decide if the payload is small enough to fit in the first mbx msg */
364     if (payload < 0x7FFFFFF) {
365         smallPayload = (payload << 5);
366         numMsgs = 1;
367     }
368     else {
369         smallPayload = 0xFFFFFFE0;
370         numMsgs = 2;
371     }
373 #if defined(xdc_target__isaCompatible_64P) || \
374     defined(xdc_target__isaCompatible_arp32)
376     index = (selfVirtId * NotifyDriverMbx_NUM_CORES) + obj->remoteVirtId;
377     PUT_NOTIFICATION(index);
379 #elif defined(xdc_target__isaCompatible_v7M)
381 //  if (!(BIOS_smpEnabled) && (Core_getId())) {
382 //      if (remoteProcId == NotifyDriverMbx_dspProcId) {
383 //          PUT_NOTIFICATION(VPSS_TO_DSP)
384 //      }
385 //      else if (remoteProcId == NotifyDriverMbx_hostProcId) {
386 //          PUT_NOTIFICATION(VPSS_TO_HOST)
387 //      }
388 //      else {
389 //          PUT_NOTIFICATION(VPSS_TO_VIDEO)
390 //      }
391 //  }
392 //  else {
393 //      if (remoteProcId == NotifyDriverMbx_dspProcId) {
394 //          PUT_NOTIFICATION(VIDEO_TO_DSP)
395 //      }
396 //      else if (remoteProcId == NotifyDriverMbx_hostProcId) {
397 //          PUT_NOTIFICATION(VIDEO_TO_HOST)
398 //      }
399 //      else {
400 //          PUT_NOTIFICATION(VIDEO_TO_VPSS)
401 //      }
402 //  }
404 #elif defined(xdc_target__isaCompatible_v7A)
406 //  if (remoteProcId == NotifyDriverMbx_dspProcId) {
407 //      PUT_NOTIFICATION(HOST_TO_DSP)
408 //  }
409 //  else if (remoteProcId == NotifyDriverMbx_videoProcId) {
410 //      PUT_NOTIFICATION(HOST_TO_VIDEO)
411 //  }
412 //  else {
413 //      PUT_NOTIFICATION(HOST_TO_VPSS)
414 //  }
416 #else
417 #error Invalid target
418 #endif
420     return (Notify_S_SUCCESS);
423 /*
424  *  ======== NotifyDriverMbx_disable ========
425  */
426 Void NotifyDriverMbx_disable(NotifyDriverMbx_Object *obj)
428     UInt16 selfVirtId = PROCID(MultiProc_self());
429     UInt16 index;
431 #if defined(xdc_target__isaCompatible_64P) || \
432     defined(xdc_target__isaCompatible_arp32)
434     index = (obj->remoteVirtId * NotifyDriverMbx_NUM_CORES) + selfVirtId;
435     REG32(MAILBOX_IRQENABLE_CLR(index)) = MAILBOX_REG_VAL(SUBMBX_IDX(index));
437 #elif defined(xdc_target__isaCompatible_v7M)
439 //  if (!(BIOS_smpEnabled) && (Core_getId())) {
440 //      if (remoteProcId == NotifyDriverMbx_hostProcId) {
441 //          REG32(MAILBOX_IRQENABLE_CLR_VPSS) = MAILBOX_REG_VAL(HOST_TO_VPSS);
442 //      }
443 //      else if (remoteProcId == NotifyDriverMbx_dspProcId) {
444 //          REG32(MAILBOX_IRQENABLE_CLR_VPSS) = MAILBOX_REG_VAL(DSP_TO_VPSS);
445 //      }
446 //      else {
447 //          REG32(MAILBOX_IRQENABLE_CLR_VPSS) = MAILBOX_REG_VAL(VIDEO_TO_VPSS);
448 //      }
449 //  }
450 //  else {
451 //      if (remoteProcId == NotifyDriverMbx_hostProcId) {
452 //          REG32(MAILBOX_IRQENABLE_CLR_VIDEO) = MAILBOX_REG_VAL(HOST_TO_VIDEO);
453 //      }
454 //      else if (remoteProcId == NotifyDriverMbx_dspProcId) {
455 //          REG32(MAILBOX_IRQENABLE_CLR_VIDEO) = MAILBOX_REG_VAL(DSP_TO_VIDEO);
456 //      }
457 //      else {
458 //          REG32(MAILBOX_IRQENABLE_CLR_VIDEO) = MAILBOX_REG_VAL(VPSS_TO_VIDEO);
459 //      }
460 //  }
462 #elif defined(xdc_target__isaCompatible_v7A)
464 //  if (remoteProcId == NotifyDriverMbx_dspProcId) {
465 //      REG32(MAILBOX_IRQENABLE_CLR_HOST) = MAILBOX_REG_VAL(DSP_TO_HOST);
466 //  }
467 //  else if (remoteProcId == NotifyDriverMbx_videoProcId) {
468 //      REG32(MAILBOX_IRQENABLE_CLR_HOST) = MAILBOX_REG_VAL(VIDEO_TO_HOST);
469 //  }
470 //  else {
471 //      REG32(MAILBOX_IRQENABLE_CLR_HOST) = MAILBOX_REG_VAL(VPSS_TO_HOST);
472 //  }
474 #else
475 #error Invalid target
476 #endif
479 /*
480  *  ======== NotifyDriverMbx_enable ========
481  */
482 Void NotifyDriverMbx_enable(NotifyDriverMbx_Object *obj)
484     UInt16 selfVirtId = PROCID(MultiProc_self());
485     UInt16 index;
487 #if defined(xdc_target__isaCompatible_64P) || \
488     defined(xdc_target__isaCompatible_arp32)
490     index = (obj->remoteVirtId * NotifyDriverMbx_NUM_CORES) + selfVirtId;
491     REG32(MAILBOX_IRQENABLE_SET(index)) = MAILBOX_REG_VAL(SUBMBX_IDX(index));
493 #elif defined(xdc_target__isaCompatible_v7M)
495 //  if (!(BIOS_smpEnabled) && (Core_getId())) {
496 //      if (remoteProcId == NotifyDriverMbx_hostProcId) {
497 //          REG32(MAILBOX_IRQENABLE_SET_VPSS) = MAILBOX_REG_VAL(HOST_TO_VPSS);
498 //      }
499 //      else if (remoteProcId == NotifyDriverMbx_dspProcId) {
500 //          REG32(MAILBOX_IRQENABLE_SET_VPSS) = MAILBOX_REG_VAL(DSP_TO_VPSS);
501 //      }
502 //      else {
503 //          REG32(MAILBOX_IRQENABLE_SET_VPSS) = MAILBOX_REG_VAL(VIDEO_TO_VPSS);
504 //      }
505 //  }
506 //  else {
507 //      if (remoteProcId == NotifyDriverMbx_hostProcId) {
508 //          REG32(MAILBOX_IRQENABLE_SET_VIDEO) = MAILBOX_REG_VAL(HOST_TO_VIDEO);
509 //      }
510 //      else if (remoteProcId == NotifyDriverMbx_dspProcId) {
511 //          REG32(MAILBOX_IRQENABLE_SET_VIDEO) = MAILBOX_REG_VAL(DSP_TO_VIDEO);
512 //      }
513 //      else {
514 //          REG32(MAILBOX_IRQENABLE_SET_VIDEO) = MAILBOX_REG_VAL(VPSS_TO_VIDEO);
515 //      }
516 //  }
518 #elif defined(xdc_target__isaCompatible_v7A)
520 //  if (remoteProcId == NotifyDriverMbx_dspProcId) {
521 //      REG32(MAILBOX_IRQENABLE_SET_HOST) = MAILBOX_REG_VAL(DSP_TO_HOST);
522 //  }
523 //  else if (remoteProcId == NotifyDriverMbx_videoProcId) {
524 //      REG32(MAILBOX_IRQENABLE_SET_HOST) = MAILBOX_REG_VAL(VIDEO_TO_HOST);
525 //  }
526 //  else {
527 //      REG32(MAILBOX_IRQENABLE_SET_HOST) = MAILBOX_REG_VAL(VPSS_TO_HOST);
528 //  }
530 #else
531 #error Invalid target
532 #endif
535 /*
536  *  ======== NotifyDriverMbx_disableEvent ========
537  */
538 Void NotifyDriverMbx_disableEvent(NotifyDriverMbx_Object *obj, UInt32 eventId)
540     /* NotifyDriverMbx_disableEvent not supported by this driver */
541     Assert_isTrue(FALSE, NotifyDriverMbx_A_notSupported);
544 /*
545  *  ======== NotifyDriverMbx_enableEvent ========
546  */
547 Void NotifyDriverMbx_enableEvent(NotifyDriverMbx_Object *obj, UInt32 eventId)
549     /* NotifyDriverMbx_enableEvent not supported by this driver */
550     Assert_isTrue(FALSE, NotifyDriverMbx_A_notSupported);
553 /*
554  *************************************************************************
555  *                       Internal functions
556  *************************************************************************
557  */
559 /*
560  *  ======== NotifyDriverMbx_isr ========
561  */
563 /*  Read a message from the mailbox. The low 5 bits of the message
564  *  contains the eventId. The high 27 bits of the message contains
565  *  either:
566  *      1) The payload if the payload is less than 0x7FFFFFF
567  *      2) 0x7FFFFFF otherwise
568  *  If the high 27 bits of the first message is 0x7FFFFFF, then the
569  *  payload is in the next mailbox message.
570  *
571  *  idx = mailbox table index
572  */
573 #define MESSAGE_DELIVERY(idx)                                               \
574     msg = REG32(MAILBOX_MESSAGE(idx));                                      \
575     eventId = (UInt16)(msg & 0x1F);                                         \
576     payload = msg >> 5;                                                     \
577     if (payload == 0x7FFFFFF) {                                             \
578         while(REG32(MAILBOX_STATUS(idx)) == 0);                             \
579         payload = REG32(MAILBOX_MESSAGE(idx));                              \
580     }                                                                       \
581     REG32(MAILBOX_IRQSTATUS_CLR(idx)) = MAILBOX_REG_VAL(SUBMBX_IDX(idx));   \
582     obj = NotifyDriverMbx_module->drvHandles[srcVirtId];                    \
583     Assert_isTrue(obj != NULL, ti_sdo_ipc_Notify_A_internal);               \
584     if (TEST_BIT(obj->evtRegMask, eventId)) {                               \
585         ti_sdo_ipc_Notify_exec(obj->notifyHandle, eventId, payload);        \
586     }                                                                       \
587     REG32(MAILBOX_EOI_REG(idx)) = 0x1;
589 Void NotifyDriverMbx_isr(UInt16 idx)
591     NotifyDriverMbx_Object *obj;
592     UInt32 msg, payload;
593     UInt16 eventId;
595 #if defined(xdc_target__isaCompatible_64P) || \
596     defined(xdc_target__isaCompatible_arp32)
598     UInt16 srcVirtId;
600     srcVirtId = idx / NotifyDriverMbx_NUM_CORES;
601     MESSAGE_DELIVERY(idx)
603 #elif defined(xdc_target__isaCompatible_v7M)
605 //  do {
606 //      numProcessed = 0;
607 //      if (!(BIOS_smpEnabled) && (Core_getId())) {
608 //          GET_NOTIFICATION(VPSS, HOST)
609 //          GET_NOTIFICATION(VPSS, DSP)
610 //          GET_NOTIFICATION(VPSS, VIDEO)
611 //      }
612 //      else {
613 //          GET_NOTIFICATION(VIDEO, HOST)
614 //          GET_NOTIFICATION(VIDEO, DSP)
615 //          GET_NOTIFICATION(VIDEO, VPSS)
616 //      }
617 //  }
618 //  while (numProcessed != 0);
620 #elif defined(xdc_target__isaCompatible_v7A)
622 //  do {
623 //      numProcessed = 0;
624 //      GET_NOTIFICATION(HOST, DSP)
625 //      GET_NOTIFICATION(HOST, VPSS)
626 //      GET_NOTIFICATION(HOST, VIDEO)
627 //  }
628 //  while (numProcessed != 0);
630 #else
631 #error Invalid target
632 #endif
635 /*
636  *  ======== NotifyDriverMbx_setNotifyHandle ========
637  */
638 Void NotifyDriverMbx_setNotifyHandle(NotifyDriverMbx_Object *obj,
639         Ptr notifyHandle)
641     /* internally used, so no assert needed */
642     obj->notifyHandle = (ti_sdo_ipc_Notify_Handle)notifyHandle;