1    /* 
     2     * Copyright (c) 2011, 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     *  ======== GateHWSpinlock.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.interfaces.IGateMPSupport;
    46    
    47    /*!
    48     *  ======== GateHWSpinlock ========
    49     *  Multiprocessor gate that utilizes a hardware spinlock
    50     */
    51    @ModuleStartup
    52    
    53    module GateHWSpinlock inherits IGateMPSupport
    54    {
    55        /*!
    56         *  ======== BasicView ========
    57         *  @_nodoc
    58         */
    59        metaonly struct BasicView {
    60            UInt    lockNum;
    61            UInt    nested;        
    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         *  ======== LM_enter ========
    84         *  Logged on gate enter
    85         */
    86        config Log.Event LM_enter = {
    87            mask: Diags.USER1,
    88            msg: "LM_enter: Gate (lockNum = %d) entered, returning key = %d"
    89        };
    90    
    91        /*!
    92         *  ======== LM_leave ========
    93         *  Logged on gate leave
    94         */
    95        config Log.Event LM_leave = {
    96            mask: Diags.USER1,
    97            msg: "LM_leave: Gate (lockNum = %d) left using key = %d"
    98        };
    99    
   100        /*!
   101         *  ======== LM_create ========
   102         *  Logged on gate create
   103         */
   104        config Log.Event LM_create = {
   105            mask: Diags.USER1,
   106            msg: "LM_create: Gate (lockNum = %d) created"
   107        };
   108    
   109        /*!
   110         *  ======== LM_open ========
   111         *  Logged on gate open
   112         */
   113        config Log.Event LM_open = {
   114            mask: Diags.USER1,
   115            msg: "LM_open: Remote gate (lockNum = %d) opened"
   116        };
   117    
   118        /*!
   119         *  ======== LM_delete ========
   120         *  Logged on gate deletion
   121         */
   122        config Log.Event LM_delete = {
   123            mask: Diags.USER1,
   124            msg: "LM_delete: Gate (lockNum = %d) deleted"
   125        };
   126    
   127        /*!
   128         *  ======== LM_close ========
   129         *  Logged on gate close
   130         */
   131        config Log.Event LM_close = {
   132            mask: Diags.USER1,
   133            msg: "LM_close: Gate (lockNum = %d) closed"
   134        };
   135        
   136        /*!
   137         *  ======== A_invSpinLockNum ========
   138         *  Assert raised when provided lockNum is invalid for the relevant device
   139         */
   140        config Assert.Id A_invSpinLockNum  = {
   141            msg: "A_invSpinLockNum: Invalid hardware spinlock number"
   142        };
   143        
   144        /*! Device-specific base address for HW Semaphore subsystem */
   145        config Ptr baseAddr = null;
   146        
   147        /*!
   148         *  ======== setReserved ========
   149         *  Reserve a HW spinlock for use outside of IPC.
   150         * 
   151         *  GateMP will, by default, manage all HW spinlocks on the device unless
   152         *  this API is used to set aside specific spinlocks for use outside
   153         *  of IPC.
   154         *
   155         *  @param(lockNum)      HW spinlock number to reserve
   156         */
   157        metaonly Void setReserved(UInt lockNum);
   158        
   159        
   160    
   161    instance:    
   162    
   163        /*!
   164         *  @_nodoc
   165         *  ======== enter ========
   166         *  Enter this gate
   167         */
   168        @DirectCall
   169        override IArg enter();
   170    
   171        /*!
   172         *  @_nodoc
   173         *  ======== leave ========
   174         *  Leave this gate
   175         */
   176        @DirectCall
   177        override Void leave(IArg key);
   178    
   179    internal:
   180       
   181        /*! Device-specific number of semphores in the HW Semaphore subsystem */
   182        config UInt numLocks;
   183        
   184        /*! Mask of reserved HW spinlocks */
   185        config Bits32 reservedMaskArr[];
   186    
   187        struct Instance_State {
   188            UInt            lockNum;   /* The lock number being used */
   189            UInt            nested;    /* For nesting */
   190            IGateProvider.Handle     localGate;
   191        };
   192    }
   193    /*
   194     *  @(#) ti.sdo.ipc.gates; 1, 0, 0, 0,321; 6-18-2011 17:33:03; /db/vtree/library/trees/ipc/ipc.git/src/ ipc-g26
   195     */
   196