Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

RingIOShm.h

Go to the documentation of this file.
00001 /** 
00002  *  @file   RingIOShm.h
00003  *
00004  *  @brief      RingIOShm shared memory based physical transport for
00005  *              communication with the remote processor.
00006  *
00007  *              This file contains the declarations of types and APIs as part
00008  *              of interface of the RingIOShm shared memory transport.
00009  *
00010  *
00011  *  @ver        02.00.00.68_beta1
00012  *  
00013  *  ============================================================================
00014  *  
00015  *  Copyright (c) 2008-2009, Texas Instruments Incorporated
00016  *
00017  *  Redistribution and use in source and binary forms, with or without
00018  *  modification, are permitted provided that the following conditions
00019  *  are met:
00020  *  
00021  *  *  Redistributions of source code must retain the above copyright
00022  *     notice, this list of conditions and the following disclaimer.
00023  *  
00024  *  *  Redistributions in binary form must reproduce the above copyright
00025  *     notice, this list of conditions and the following disclaimer in the
00026  *     documentation and/or other materials provided with the distribution.
00027  *  
00028  *  *  Neither the name of Texas Instruments Incorporated nor the names of
00029  *     its contributors may be used to endorse or promote products derived
00030  *     from this software without specific prior written permission.
00031  *  
00032  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00033  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00034  *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00035  *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00036  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00037  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00038  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00039  *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00040  *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00041  *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00042  *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00043  *  Contact information for paper mail:
00044  *  Texas Instruments
00045  *  Post Office Box 655303
00046  *  Dallas, Texas 75265
00047  *  Contact information: 
00048  *  http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
00049  *  DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
00050  *  ============================================================================
00051  *  
00052  */
00053 
00054 
00055 #ifndef RINGIOSHM_H_
00056 #define RINGIOSHM_H_
00057 
00058 #include <ti/ipc/GateMP.h>
00059 
00060 
00061 #if defined (__cplusplus)
00062 extern "C" {
00063 #endif
00064 /* =============================================================================
00065  *  All success and failure codes for the module
00066  * =============================================================================
00067  */
00068 
00069 /*!
00070  *  @def    RingIOShm_MODULEID
00071  *  @brief  Unique module ID.
00072  */
00073 #define RingIOShm_MODULEID               (0x3bff)
00074 
00075 /* =============================================================================
00076  *  All success and failure codes for the module
00077  * =============================================================================
00078  */
00079 /*!
00080  *  @def    RingIOShm_STATUSCODEBASE
00081  *  @brief  Error code base for RingIO.
00082  */
00083 #define RingIOShm_STATUSCODEBASE                              \
00084                                     (RingIOShm_MODULEID << 12u)
00085 
00086 /*!
00087  *  @def    RingIOShm_MAKE_FAILURE
00088  *  @brief  Macro to make error code.
00089  */
00090 #define RingIOShm_MAKE_FAILURE(x)  ((Int32)  (  0x80000000            \
00091                                        + (RingIOShm_STATUSCODEBASE  \
00092                                        + (x))))
00093 
00094 /*!
00095  *  @def    RingIOShm_MAKE_SUCCESS
00096  *  @brief  Macro to make success code.
00097  */
00098 #define RingIOShm_MAKE_SUCCESS(x)                              \
00099                                     (RingIOShm_STATUSCODEBASE + (x))
00100 
00101 /*!
00102  *  @def    RingIOShm_E_INVALIDARG
00103  *  @brief  Argument passed to a function is invalid.
00104  */
00105 #define RingIOShm_E_INVALIDARG   RingIOShm_MAKE_FAILURE(-1)
00106 
00107 /*!
00108  *  @def    RingIOShm_E_INVALIDSIZE
00109  *  @brief  Invalid shared address size
00110  */
00111 #define RingIOShm_E_INVALIDSIZE  RingIOShm_MAKE_FAILURE(-2)
00112 
00113 /*!
00114  *  @def    RingIOShm_E_INVALIDSTATE
00115  *  @brief  Module is not initialized.
00116  */
00117 #define RingIOShm_E_INVALIDSTATE RingIOShm_MAKE_FAILURE(-3)
00118 
00119 /*!
00120  *  @def    RingIOShm_E_BADVERSION
00121  *  @brief  Versions don't match
00122  */
00123 #define RingIOShm_E_BADVERSION   RingIOShm_MAKE_FAILURE(-4)
00124 
00125 /*!
00126  *  @def    RingIOShm_E_FAIL
00127  *  @brief  General Failure
00128 */
00129 #define RingIOShm_E_FAIL         RingIOShm_MAKE_FAILURE(-5)
00130 
00131 /*!
00132  *  @def    RingIOShm_E_MEMORY
00133  *  @brief  Memory allocation failed
00134  */
00135 #define RingIOShm_E_MEMORY       RingIOShm_MAKE_FAILURE(-6)
00136 
00137 /*!
00138  *  @def    RingIOShm_E_OSFAILURE
00139  *  @brief  Failure in OS call.
00140  */
00141 #define RingIOShm_E_OSFAILURE    RingIOShm_MAKE_FAILURE(-7)
00142 
00143 /*!
00144  *  @def    RingIOShm_E_HANDLE
00145  *  @brief  Invalid handle specified.
00146  */
00147 #define RingIOShm_E_HANDLE       RingIOShm_MAKE_FAILURE(-8)
00148 
00149 /*!
00150  *  @def    RingIOShm_E_BUFWRAP
00151  *  @brief  Indicates that the amount of data requested could not be serviced
00152  *          due to the ring buffer getting wrapped
00153  */
00154 #define RingIOShm_E_BUFWRAP      RingIOShm_MAKE_FAILURE(-9)
00155 
00156 /*!
00157  *  @def    RingIOShm_E_BUFEMPTY
00158  *  @brief  Indicates that there is no data in the buffer for reading
00159  */
00160 #define RingIOShm_E_BUFEMPTY     RingIOShm_MAKE_FAILURE(-10)
00161 
00162 /*!
00163  *  @def    RingIOShm_E_BUFFULL
00164  *  @brief  Indicates that the buffer is full
00165  */
00166 #define RingIOShm_E_BUFFULL      RingIOShm_MAKE_FAILURE(-11)
00167 
00168 /*!
00169  *  @def    RingIOShm_E_PENDINGDATA
00170  *  @brief  Indicates that there is no attribute at the current,
00171  *          but attributes are present at a future offset
00172  */
00173 #define RingIOShm_E_PENDINGDATA  RingIOShm_MAKE_FAILURE(-12)
00174 
00175 /*!
00176  *  @def    RingIOShm_E_VARIABLEATTRIBUTE
00177  *  @brief  Indicates that attibute get() failed, need to extract
00178  *          variable length message getv()
00179  */
00180 #define RingIOShm_E_VARIABLEATTRIBUTE   RingIOShm_MAKE_FAILURE(-13)
00181 
00182 /*!
00183  *  @def    RingIOShm_E_NOTCONTIGUOUSDATA
00184  *  @brief  Indicates that Valid data is present in the buffer but is not
00185  *          contiguous as data has been copied from top to footer area.
00186  */
00187 #define RingIOShm_E_NOTCONTIGUOUSDATA   RingIOShm_MAKE_FAILURE(-14)
00188 
00189 /*!
00190  *  @def    RingIOShm_E_WRONGSTATE
00191  *  @brief  Indicates that the RingIO is in a wrong state
00192  */
00193 #define RingIOShm_E_WRONGSTATE          RingIOShm_MAKE_FAILURE(-15)
00194 
00195 /*!
00196  *  @def    RingIOShm_E_INVALIDPROCID
00197  *  @brief  Indicates that an invalid proc id has been specified
00198  */
00199 #define RingIOShm_E_INVALIDPROCID    RingIOShm_MAKE_FAILURE(-16)
00200 /*!
00201  *  @def    RingIOShm_E_INVALIDCONTEXT
00202  *  @brief  Indicates that the api is called with wrong handle
00203  */
00204 #define RingIOShm_E_INVALIDCONTEXT   RingIOShm_MAKE_FAILURE(-17)
00205 
00206 /*!
00207  *  @def    RingIOShm_SUCCESS
00208  *  @brief  Operation successful.
00209  */
00210 #define RingIOShm_S_SUCCESS        RingIOShm_MAKE_SUCCESS(0)
00211 
00212 /*!
00213  *  @def    RingIOShm_S_ALREADYSETUP
00214  *  @brief  The MESSAGETRANSPORTSHM module has
00215  *          already been setup in this process.
00216  */
00217 #define RingIOShm_S_ALREADYSETUP RingIOShm_MAKE_SUCCESS(1)
00218 
00219 /*!
00220  *  @def    RingIOShm_S_PENDINGATTRIBUTE
00221  *  @brief  Indicates that either:
00222  *                        1) The amount of data requested could not be
00223  *                           serviced due to the presence of an attribute
00224  *                        2) During an attribute read if another is also present
00225  *                           at the same offset.
00226  */
00227 #define RingIOShm_S_PENDINGATTRIBUTE    RingIOShm_MAKE_SUCCESS(1)
00228 
00229 
00230 /* =============================================================================
00231  * Structures & Enums
00232  * =============================================================================
00233  */
00234 /*!
00235  *  @brief  Structure defining parameters for creating the RingIOShm
00236  *          instances.
00237  */
00238 typedef struct RingIOShm_Params_Tag {
00239      RingIO_Params commonParams;
00240      /*!< Common create parameters .Same for all the implementations of FrameQ*/
00241      UInt16     ctrlRegionId;
00242      /*!< Shared region ID for RingIOShm control structures
00243       *
00244       *  The index corresponding to the shared region from which shared memory
00245       *  will be allocated if ctrlSharedAddr is NULL.
00246       *  If a valid ctrlSharedAddr is provided, this field is ignored.
00247       */
00248      UInt16     dataRegionId;
00249      /*!< Shared region ID for RingIOShm data buffer
00250       *
00251       *  The index corresponding to the shared region from which shared memory
00252       *  will be allocated if dataSharedAddr is NULL.
00253       *  If a valid dataSharedAddr is provided, this field is ignored.
00254       */
00255      UInt16     attrRegionId;
00256      /*!< Shared region ID for RingIOShm attr buffer
00257       *
00258       *  The index corresponding to the shared region from which shared memory
00259       *  will be allocated if attrSharedAddr is NULL.
00260       *  If a valid attrSharedAddr is provided, this field is ignored.
00261       */
00262      Ptr         ctrlSharedAddr;
00263      /*!<  Shared region address for control structure. The shared address
00264       *    details for control, data and attribute buffers.
00265       *    a RingIOShm instance.
00266       *    If this field is NULL, memory equal to that required to allocate that
00267       *    RingIOShm instance control structure is allocated from heap associated
00268       *    with ctrlRegionId
00269       */
00270      Ptr         dataSharedAddr;
00271      /*!<  Shared Region Address for data buffer
00272       *    If this field is NULL, memory equal to (dataSharedAddrSize +
00273       *    footBufSize)
00274       *    is allocated from heap associated with dataRegionId
00275       */
00276      UInt32      dataSharedAddrSize;
00277      /*!<  Data Buffer size.  */
00278      UInt32      footBufSize;
00279      /*!<  Foot Buffer size.  */
00280      Ptr         attrSharedAddr;
00281      /*!<  Shared Region Address for attr buffer
00282       *    If this field is NULL, memory equal to attrSharedAddrSize
00283       *    is allocated from heap associated with attrRegionId
00284       */
00285      UInt32      attrSharedAddrSize;
00286      /*!<  Attr Buffer size.  */
00287      GateMP_Handle gateHandle;
00288      /*!< Gate for protection.
00289       *   If gateHandle is NULL:
00290       *       * If user has called RingIOShm_useModuleDefault
00291       *         then module wide default GateMP is used.
00292       *       * If RingIOShm_useModuleDefault is not set
00293       *         default gate will be used for all instances
00294       *       * else, If variables GateMP_LocalProtect localProtect and
00295       *         GateMP_RemoteProtect remoteProtect are set to correct
00296       *         values, a GateMP is created for the instance.
00297       */
00298      GateMP_LocalProtect  localProtect;
00299      /*!< Local protection level for the module instance.*/
00300      GateMP_RemoteProtect remoteProtect;
00301      /*!< Remote protection level for the module instance.*/
00302      UInt16        remoteProcId;
00303      /*!< Remote processor id with which the RingIOShm communicates */
00304 } RingIOShm_Params;
00305 
00306 
00307 /*!
00308  *  @brief  Structure defining config parameters for the RingIOShm module.
00309  */
00310 typedef struct RingIOShm_Config_Tag {
00311     UInt32       notifyEventNo;
00312     /*!<  Notify event number to be used by the Client Notify Manager */
00313 } RingIOShm_Config;
00314 
00315 /* =============================================================================
00316  * APIs
00317  * =============================================================================
00318  */
00319 /*!
00320  *  @brief      Function to initialize the parameters for the RingIOShm instance.
00321  *
00322  *              This function can be called by the application to get their
00323  *              configuration parameter to RingIOShm_create filled in by the
00324  *              RingIOShm module with the default parameters.
00325  *
00326  *  @param      params   Pointer to the RingIOShm instance params structure in
00327  *                       which the default params is to be returned.
00328  *
00329  *  @retval     None
00330  *
00331  *  @sa         RingIOShm_create
00332  */
00333 Void RingIOShm_Params_init (Void * params);
00334 /*!
00335  *  @brief      Function to get the default configuration for the RingIOShm
00336  *              module.
00337  *
00338  *              This function can be called by the application to get their
00339  *              configuration parameter to RingIOShm_setup filled in by the
00340  *              RingIOShm module with the default parameters. If the user does
00341  *              not wish to make any change in the default parameters, this API
00342  *              is not required to be called.
00343  *
00344  *  @param      cfgParams Pointer to the RingIOShm module configuration structure
00345  *                        in which the default config is to be returned.
00346  *
00347  *  @sa         RingIOShm_setup
00348  */
00349 Void  RingIOShm_getConfig (RingIOShm_Config * cfgParams);
00350 
00351 /*!
00352  *  @brief      Function to setup the RingIOShm module.
00353  *
00354  *              This function sets up the RingIOShm module. This function must
00355  *              be called before any other instance-level APIs can be invoked.
00356  *              Module-level configuration needs to be provided to this
00357  *              function. If the user wishes to change some specific config
00358  *              parameters, then RingIOShm_getConfig can be called to get the
00359  *              configuration filled with the default values. After this, only
00360  *              the required configuration values can be changed. If the user
00361  *              does not wish to make any change in the default parameters, the
00362  *              application can simply call RingIOShm with NULL parameters.
00363  *              The default parameters would get automatically used.
00364  *
00365  *  @param      cfgParams   Optional RingIOShm module configuration. If provided as
00366  *                    NULL, default configuration is used.
00367  *
00368  *  @retval
00369  *
00370  *  @sa         RingIOShm_destroy
00371  *              NameServer_create
00372  *              GateMutex_create
00373  *              Memory_alloc
00374  */
00375 Int   RingIOShm_setup (const RingIOShm_Config * cfgParams);
00376 
00377 /*!
00378  *  @brief      Function to destroy the RingIOShm module.
00379  *
00380  *              Once this function is called, other RingIOShm module APIs, except
00381  *              for the RingIOShm_getConfig API cannot be called anymore.
00382  *
00383  *  @retval
00384  *  @sa         RingIOShm_setup, NameServer_delete, GateMutex_delete
00385  */
00386 Int   RingIOShm_destroy (Void);
00387 
00388 
00389 
00390 #if defined (__cplusplus)
00391 }
00392 #endif /* defined (__cplusplus) */
00393 
00394 
00395 #endif /* RINGIOSHM_H_ */

Generated on Mon Mar 14 11:59:45 2011 for Syslink by  doxygen 1.4.4