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     *  ======== GateAAMonitor.xdc ========
    34     *
    35     *! Revision History
    36     *! ================
    37     *! 04-Feb-2010 skp     obj->objType not needed; removed
    38     *! 22-Dec-2009 skp     Removed @InstanceFinalize
    39     *! 17-Nov-2009 skp     Added assert to ensure SL2 RAM being used
    40     *! 28-Sep-2009 skp     GateMP compatbility changes
    41     *! 21-Jul-2009 skp     created from GateHWSem
    42     */
    43     
    44    package ti.sdo.ipc.gates;
    45    
    46    import xdc.runtime.Error;
    47    import xdc.runtime.Assert;
    48    import xdc.runtime.IGateProvider;
    49    import xdc.runtime.Diags;
    50    import xdc.runtime.Log;
    51    
    52    import ti.sdo.ipc.Ipc;
    53    
    54    import ti.sdo.ipc.interfaces.IGateMPSupport;
    55    
    56    /*!
    57     *  ======== GateAAMonitor ========
    58     *  Multiprocessor gate that utilizes an atomic access monitor (AAM)
    59     */
    60    @InstanceInitError
    61    
    62    module GateAAMonitor inherits IGateMPSupport
    63    {
    64        /*! @_nodoc */
    65        metaonly struct BasicView {
    66            Ptr     sharedAddr;
    67            UInt    nested;
    68            String  enteredBy;     /* Entered or free */
    69        }
    70    
    71        /*!
    72         *  ======== rovViewInfo ========
    73         *  @_nodoc
    74         */
    75        @Facet
    76        metaonly config xdc.rov.ViewInfo.Instance rovViewInfo =
    77            xdc.rov.ViewInfo.create({
    78                viewMap: [
    79                    ['Basic',
    80                        {
    81                            type: xdc.rov.ViewInfo.INSTANCE,
    82                            viewInitFxn: 'viewInitBasic',
    83                            structName: 'BasicView'
    84                        }
    85                    ],
    86                ]
    87            });
    88            
    89        /*!
    90         *  ======== A_invSharedAddr ========
    91         *  Assert raised when supplied sharedAddr is invalid
    92         *
    93         *  C6472 requires that shared region 0 be placed in SL2 memory and that
    94         *  all GateMP instances be allocated from region 0.  The gate itself may
    95         *  be used to protect the contents of any shared region.
    96         */
    97        config Assert.Id A_invSharedAddr  = {
    98            msg: "A_invSharedAddr: Address must be in shared L2 address space"
    99        };
   100        
   101        /*!
   102         *  ======== numInstances ========
   103         *  Maximum number of instances supported by the GateAAMonitor module
   104         */
   105        config UInt numInstances = 32;
   106    
   107    instance:
   108    
   109    
   110    internal:
   111    
   112        /*! Get the lock */
   113        @DirectCall
   114        UInt getLock(Ptr sharedAddr);
   115        
   116        /*! L1D cache line size is 64 */
   117        const UInt CACHELINE_SIZE = 64;
   118    
   119        /*!
   120         *  Range of SL2 RAM on TMS320TCI6486. Used for ensuring sharedAddr is
   121         *  valid
   122         */
   123        const Ptr SL2_RANGE_BASE = 0x00200000;
   124        const Ptr SL2_RANGE_MAX  = 0x002bffff;
   125        
   126        struct Instance_State {
   127            volatile UInt32*    sharedAddr;
   128            UInt                nested;    /* For nesting */       
   129            IGateProvider.Handle localGate;
   130        };
   131    }