1    /* --COPYRIGHT--,BSD
     2     * Copyright (c) $(CPYYEAR), 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     * --/COPYRIGHT--*/
    32    /*
    33     *  ======== NotifyDriverMbx.xdc ================
    34     */
    35    
    36    import ti.sdo.utils.MultiProc;
    37    import ti.sdo.ipc.interfaces.INotifyDriver;
    38    import ti.sdo.ipc.Notify;
    39    
    40    import ti.sysbios.hal.Hwi;
    41    
    42    import xdc.runtime.Assert;
    43    import xdc.rov.ViewInfo;
    44    
    45    /*!
    46     *  ======== NotifyDriverMbx ========
    47     *  A TI81xx hardware mailbox based driver for the Notify Module.
    48     *
    49     *  This is a {@link ti.sdo.ipc.Notify} driver that uses hardware mailboxes to
    50     *  transmit notifications to remote processors.
    51     *
    52     *  Unlike the Notify drivers available in the {@link ti.sdo.ipc.notifyDrivers}
    53     *  package, this driver is not generic and will only work with the TI81xx 
    54     *  family of devices. 
    55     *
    56     *  The driver uses no shared memory since the event IDs and payloads that
    57     *  comprise notifications are transmitted via the hardware mailbox FIFO.  The
    58     *  FIFO can hold up to 4 mailbox messages.  The number of notification that can
    59     *  be stored in the FIFO depends on the sizes of the payloads being sent via
    60     *  Notify_sendEvent.  If the payload is less than 0x7FFFFFF, then a single 
    61     *  message will be sent per notification.  Otherwise, if the payload is greater 
    62     *  than or equal to 0x7FFFFFF, two mailbox messages are needed to send the 
    63     *  notification.  
    64     *
    65     *  The behavior of Notify_sendEvent when the FIFO is full depends on the value
    66     *  of the 'waitClear' argument to the function.  If 'waitClear' is TRUE, then 
    67     *  Notify_sendEvent will spin waiting for enough room in the FIFO for the 
    68     *  notification before actually sending it.  If 'waitClear' is FALSE, then
    69     *  Notify_sendEvent will return Notify_E_FAIL if there isn't enough room in the
    70     *  FIFO to store the notification.
    71     *
    72     *  The Notify_[enable/disable]Event APIs are not supported by this driver.
    73     *
    74     */
    75    @InstanceFinalize
    76    @ModuleStartup
    77    module NotifyDriverMbx inherits ti.sdo.ipc.interfaces.INotifyDriver
    78    {
    79        /*! @_nodoc */
    80        metaonly struct BasicView {
    81            String      remoteProcName;
    82            UInt        numIncomingPending;
    83            UInt        numOutgoingPending;
    84            String      incomingIntStatus;
    85            String      outgoingIntStatus;
    86            String      registeredEvents;
    87        }
    88        
    89        /*!
    90         *  ======== rovViewInfo ========
    91         */
    92        @Facet
    93        metaonly config ViewInfo.Instance rovViewInfo =
    94            ViewInfo.create({
    95                viewMap: [
    96                    ['Basic',
    97                        {
    98                            type: ViewInfo.INSTANCE,
    99                            viewInitFxn: 'viewInitBasic',
   100                            structName: 'BasicView'
   101                        }
   102                    ],
   103                ]
   104            });
   105        
   106        /*!
   107         *  Assert raised when trying to use Notify_[enable/disable]Event with
   108         *  NotifyDriverMbx
   109         */
   110        config Assert.Id A_notSupported =
   111            {msg: "A_notSupported: [enable/disable]Event not supported by NotifyDriverMbx"};
   112            
   113        
   114        /*! Base address for the Mailbox subsystem */
   115        config UInt32 mailboxBaseAddr = 0x480C8000;
   116    
   117        /*!
   118         *  ======== intVectorId ========
   119         *  Interrupt vector ID to be used by the driver.
   120         *
   121         *  This parameter is only used by the DSP core
   122         */
   123        config UInt intVectorId = ~1u;
   124        
   125    instance:
   126        
   127        /*!
   128         *  ======== remoteProcId ========
   129         *  The MultiProc ID corresponding to the remote processor
   130         */
   131        config UInt16 remoteProcId = MultiProc.INVALIDID;
   132    
   133    internal:
   134    
   135        config UInt16 dspProcId   = MultiProc.INVALIDID;
   136        config UInt16 hostProcId  = MultiProc.INVALIDID;
   137        config UInt16 videoProcId = MultiProc.INVALIDID;
   138        config UInt16 vpssProcId  = MultiProc.INVALIDID;
   139        
   140        /*! 
   141         *  Plugs the interrupt and executes the callback functions according
   142         *  to event priority
   143         */
   144        Void isr(UArg arg);
   145    
   146        /*! Instance state structure */
   147        struct Instance_State {
   148            Bits32           evtRegMask;     /* local event register mask        */
   149            Notify.Handle    notifyHandle;   /* Handle to front-end object       */
   150            UInt16           remoteProcId;   /* Remote MultiProc id              */
   151        }
   152        
   153        struct Module_State {
   154            NotifyDriverMbx.Handle drvHandles[4];
   155            Hwi.Object hwi;
   156        };
   157    }