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