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     *  ======== GateHWSem.xdc ========
    34     *
    35     */
    36    
    37    package ti.sdo.ipc.gates;
    38    
    39    import xdc.runtime.Assert;
    40    import xdc.runtime.IGateProvider;
    41    
    42    import ti.sdo.ipc.interfaces.IGateMPSupport;
    43    
    44    /*!
    45     *  ======== GateHWSem ========
    46     *  Multiprocessor gate that utilizes hardware semaphores
    47     */
    48    @ModuleStartup
    49    
    50    module GateHWSem inherits IGateMPSupport
    51    {
    52        /*! @_nodoc */
    53        metaonly struct BasicView {
    54            Ptr     semNum;
    55            UInt    nested;
    56            String  enteredBy;      /* Which core has entered the hw sem */
    57        }
    58    
    59        /*!
    60         *  ======== rovViewInfo ========
    61         *  @_nodoc
    62         */
    63        @Facet
    64        metaonly config xdc.rov.ViewInfo.Instance rovViewInfo = 
    65            xdc.rov.ViewInfo.create({
    66                viewMap: [
    67                    ['Basic', 
    68                        {
    69                            type: xdc.rov.ViewInfo.INSTANCE,
    70                            viewInitFxn: 'viewInitBasic',
    71                            structName: 'BasicView'
    72                        }
    73                    ],
    74                ]
    75            });
    76    
    77        /*!
    78         *  ======== A_invSemNum ========
    79         *  Asserted when supplied semNum is invalid for the relevant device
    80         */
    81        config Assert.Id A_invSemNum  = {
    82            msg: "A_invSemNum: Invalid hardware semaphore number"
    83        };
    84        
    85        /*!
    86         *  ======== setReserved ========
    87         *  Reserve a HW sempahore for use outside of IPC.
    88         * 
    89         *  GateMP will, by default, manage all HW semaphores on the device unless
    90         *  this API is used to set aside specific HW semaphores for use outside
    91         *  of IPC.
    92         *
    93         *  @param(semNum)      HW semaphore number to reserve
    94         */
    95        metaonly Void setReserved(UInt semNum);
    96    
    97    instance:    
    98    
    99        /*!
   100         *  @_nodoc
   101         *  ======== enter ========
   102         *  Enter this gate
   103         */
   104        @DirectCall
   105        override IArg enter();
   106    
   107        /*!
   108         *  @_nodoc
   109         *  ======== leave ========
   110         *  Leave this gate
   111         */
   112        @DirectCall
   113        override Void leave(IArg key);
   114    
   115    internal:
   116    
   117        /*! Device-specific base address for HW Semaphore subsystem */
   118        config Ptr baseAddr;
   119        
   120        /*! Device-specific query offset for HW Semaphore subsystem (for ROV) */
   121        config Ptr queryAddr;
   122        
   123        /*! Device-specific number of semphores in the HW Semaphore subsystem */
   124        config UInt numSems;
   125        
   126        /*! Mask of reserved HW semaphores */
   127        config Bits32 reservedMaskArr[];
   128    
   129        struct Instance_State {
   130            UInt                     semNum;    /* The sem number being used */
   131            UInt                     nested;    /* For nesting */        
   132            IGateProvider.Handle     localGate;
   133        };
   134    }
   135    /*
   136     *  @(#) ti.sdo.ipc.gates; 1, 0, 0, 0,321; 6-18-2011 17:33:02; /db/vtree/library/trees/ipc/ipc.git/src/ ipc-g26
   137     */
   138