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