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     *  ======== GateHWSpinlock.xdc ========
    34     *
    35     *! Revision History
    36     *! ================
    37     *! 25-Apr-2010 skp     locks are released during Module_startup
    38     *! 28-Jun-2009 skp     Delegates collapsed into frontend
    39     *! 17-Jun-2009 skp     ROV views added
    40     *! 06-May-2009 skp     created from GateHWSem
    41     */
    42    
    43    package ti.sdo.ipc.gates;
    44    
    45    import xdc.runtime.Error;
    46    import xdc.runtime.Assert;
    47    import xdc.runtime.IGateProvider;
    48    import xdc.runtime.Diags;
    49    import xdc.runtime.Log;
    50    
    51    import ti.sdo.ipc.interfaces.IGateMPSupport;
    52    
    53    /*!
    54     *  ======== GateHWSpinlock ========
    55     *  Multiprocessor gate that utilizes a hardware spinlock
    56     */
    57    @ModuleStartup
    58    
    59    module GateHWSpinlock inherits IGateMPSupport
    60    {
    61        /*!
    62         *  ======== BasicView ========
    63         *  @_nodoc
    64         */
    65        metaonly struct BasicView {
    66            UInt    lockNum;
    67            UInt    nested;        
    68        }
    69    
    70        /*!
    71         *  ======== rovViewInfo ========
    72         *  @_nodoc
    73         */
    74        @Facet
    75        metaonly config xdc.rov.ViewInfo.Instance rovViewInfo = 
    76            xdc.rov.ViewInfo.create({
    77                viewMap: [
    78                    ['Basic', 
    79                        {
    80                            type: xdc.rov.ViewInfo.INSTANCE,
    81                            viewInitFxn: 'viewInitBasic',
    82                            structName: 'BasicView'
    83                        }
    84                    ],
    85                ]
    86            });
    87    
    88        /*!
    89         *  ======== LM_enter ========
    90         *  Logged on gate enter
    91         */
    92        config Log.Event LM_enter = {
    93            mask: Diags.USER1,
    94            msg: "LM_enter: Gate (lockNum = %d) entered, returning key = %d"
    95        };
    96    
    97        /*!
    98         *  ======== LM_leave ========
    99         *  Logged on gate leave
   100         */
   101        config Log.Event LM_leave = {
   102            mask: Diags.USER1,
   103            msg: "LM_leave: Gate (lockNum = %d) left using key = %d"
   104        };
   105    
   106        /*!
   107         *  ======== LM_create ========
   108         *  Logged on gate create
   109         */
   110        config Log.Event LM_create = {
   111            mask: Diags.USER1,
   112            msg: "LM_create: Gate (lockNum = %d) created"
   113        };
   114    
   115        /*!
   116         *  ======== LM_open ========
   117         *  Logged on gate open
   118         */
   119        config Log.Event LM_open = {
   120            mask: Diags.USER1,
   121            msg: "LM_open: Remote gate (lockNum = %d) opened"
   122        };
   123    
   124        /*!
   125         *  ======== LM_delete ========
   126         *  Logged on gate deletion
   127         */
   128        config Log.Event LM_delete = {
   129            mask: Diags.USER1,
   130            msg: "LM_delete: Gate (lockNum = %d) deleted"
   131        };
   132    
   133        /*!
   134         *  ======== LM_close ========
   135         *  Logged on gate close
   136         */
   137        config Log.Event LM_close = {
   138            mask: Diags.USER1,
   139            msg: "LM_close: Gate (lockNum = %d) closed"
   140        };
   141        
   142        /*!
   143         *  ======== A_invSpinLockNum ========
   144         *  Assert raised when provided lockNum is invalid for the relevant device
   145         */
   146        config Assert.Id A_invSpinLockNum  = {
   147            msg: "A_invSpinLockNum: Invalid hardware spinlock number"
   148        };
   149        
   150        /*! Device-specific base address for HW Semaphore subsystem */
   151        config Ptr baseAddr = null;
   152        
   153        /*!
   154         *  ======== setReserved ========
   155         *  Reserve a HW spinlock for use outside of IPC.
   156         * 
   157         *  GateMP will, by default, manage all HW spinlocks on the device unless
   158         *  this API is used to set aside specific spinlocks for use outside
   159         *  of IPC.
   160         *
   161         *  @param(lockNum)      HW spinlock number to reserve
   162         */
   163        metaonly Void setReserved(UInt lockNum);
   164        
   165        
   166    
   167    instance:    
   168    
   169        /*!
   170         *  @_nodoc
   171         *  ======== enter ========
   172         *  Enter this gate
   173         */
   174        @DirectCall
   175        override IArg enter();
   176    
   177        /*!
   178         *  @_nodoc
   179         *  ======== leave ========
   180         *  Leave this gate
   181         */
   182        @DirectCall
   183        override Void leave(IArg key);
   184    
   185    internal:
   186       
   187        /*! Device-specific number of semphores in the HW Semaphore subsystem */
   188        config UInt numLocks;
   189        
   190        /*! Mask of reserved HW spinlocks */
   191        config Bits32 reservedMaskArr[];
   192    
   193        struct Instance_State {
   194            UInt            lockNum;   /* The lock number being used */
   195            UInt            nested;    /* For nesting */
   196            IGateProvider.Handle     localGate;
   197        };
   198    }