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    /*
    34     *  ======== IpcMP.xdc ========
    35     */
    36    
    37    package ti.uia.sysbios;
    38    
    39    import xdc.runtime.Assert;
    40    import ti.uia.runtime.UIAPacket;
    41    import ti.sysbios.knl.Semaphore;
    42    import ti.sysbios.knl.Clock;
    43    import ti.sysbios.knl.Task;
    44    import ti.sysbios.knl.Event;
    45    import ti.sdo.ipc.MessageQ;
    46    import ti.sysbios.syncs.SyncEvent;
    47    
    48    /*!
    49     *  ======== IpcMP ========
    50     */
    51     
    52    @ModuleStartup      /* Initialize static instances */
    53    
    54    module IpcMP inherits ti.uia.runtime.IServiceMgrSupport
    55    {   
    56        /*!
    57         *  Assert raised IpcMP interaction gets unexpected failure
    58         */
    59        config Assert.Id A_IpcMPFailure  = {
    60            msg: "A_IpcMPFailure: Unexpected failure with the IpcMP"
    61        };
    62    
    63        /*!
    64         *  SharedRegion used to allocate messages
    65         */
    66        config Int sharedRegionId = 0; 
    67    
    68        // -------- Module Functions --------
    69    
    70        /*!
    71         *  @_nodoc
    72         *  ======== rxTaskFxn ========
    73         *  Function used for the transfer agent Task.
    74         */
    75        @DirectCall 
    76        Void rxTaskFxn(UArg arg0, UArg arg1);
    77    
    78        /*!
    79         *  @_nodoc
    80         *  ======== transferAgentFxn ========
    81         *  Function used for the transfer agent Task.
    82         */
    83        @DirectCall 
    84        Void transferAgentFxn(UArg arg0, UArg arg1);
    85    
    86        /*!
    87         *  @_nodoc
    88         *  ======== clockFxn ========
    89         *  Function used for the RTA Agent's Clock instance.
    90         *
    91         *  The Agent C code does not contain any references to this function, so
    92         *  this function has been made public and nodoc'd, rather than being made
    93         *  internal, so that it does not fall away in a ROM build.
    94         */
    95        @DirectCall 
    96        Void clockFxn(UArg arg0);
    97        
    98        /*!
    99         *  @_nodoc
   100         *  ======== start ========     
   101         */     
   102        @DirectCall 
   103        Int start(UArg arg, UInt16 value);
   104        
   105        /*!
   106         *  ======== doNotPlugIpc ========     
   107         *  Work-around for Syslink bug SDOCM00077375
   108         *
   109         *  Only call if you are using Syslink version 2.00.00.66
   110         */     
   111        metaonly Void doNotPlugIpc();
   112    
   113    internal:
   114        /*!
   115         *  ======== period ========
   116         *  Stored as ticks
   117         */
   118        config UInt32 period[];
   119    
   120        /*!
   121         *  ======== scheduled ========
   122         *  Stored as ticks
   123         */
   124        config UInt32 scheduled[];
   125    
   126        /*!
   127         *  ======== reqEnergy ========
   128         */
   129        config Bool reqEnergy[];
   130    
   131        /*!
   132         *  ======== createRxTask ========
   133         */
   134        config Bool createRxTask = false;
   135        
   136        /*!
   137         *  @_nodoc
   138         *  ======== start ========     
   139         */     
   140        @DirectCall     
   141        Int startOrig(Ptr *ptr, UInt16 value);
   142    
   143        /*!
   144         *  ======== giveEnergy ========
   145         */
   146        @DirectCall 
   147        Void giveEnergy();
   148    
   149        /*!
   150         *  ======== handleMsg ========
   151         */
   152        @DirectCall 
   153        Void handleMsg(Ptr msg);
   154    
   155        /*!
   156         *  ======== prime ========
   157         */
   158        @DirectCall 
   159        Void prime(Ptr handle, Int size, Int count);
   160        
   161        /*!
   162         *  ======== registerWithMaster ========
   163         */
   164        @DirectCall 
   165        Void registerWithMaster();
   166    
   167        /*!
   168         *  ======== requestEvents ========
   169         */
   170        @DirectCall 
   171        Void requestEvents();
   172    
   173        /*!
   174         *  ======== Module_State ========
   175         */
   176        struct Module_State {        
   177            Event.Handle            event;
   178            Clock.Handle            clock;
   179            Ptr                     freeEventMQ;
   180            Ptr                     freeMsgMQ;
   181            Ptr                     routerMQ;
   182            UInt32                  masterMQ;
   183            Ptr                     incomingMsgMQ;
   184            UInt32                  replyMQ[];
   185            SyncEvent.Handle        syncEvent01;
   186            Task.Handle             transferAgentHandle;
   187            Ptr                     transportMsgHandle;        
   188            Ptr                     transportEventHandle;  
   189            Semaphore.Handle        releaseTasksSem;
   190            Int                     numMSGPacketsSent;
   191            Int                     numEventPacketsSent;
   192            Bool                    master;
   193            Bool                    masterRunning;
   194        };
   195    }
   196    
   197    /*
   198     *! Revision History
   199     *! ================
   200     *! 23-Jun-2010 toddm Started revision history
   201     */