Home | History | Annotate | Download | only in inc
      1 /*
      2  * Copyright (c) 2010, 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 /**
     34  *  @file  omx_rpc_utils.h
     35  *         This file contains methods that provides the functionality for
     36  *         the OpenMAX1.1 DOMX Framework RPC.
     37  *
     38  *  @path \WTSD_DucatiMMSW\framework\domx\omx_rpc\inc
     39  *
     40  *  @rev 1.0
     41  */
     42 
     43 /*==============================================================
     44  *! Revision History
     45  *! ============================
     46  *! 29-Mar-2010 Abhishek Ranka : Revamped DOMX implementation
     47  *!
     48  *! 19-August-2009 B Ravi Kiran ravi.kiran (at) ti.com: Initial Version
     49  *================================================================*/
     50 
     51 #ifndef OMX_RPC_UTILSH
     52 #define OMX_RPC_UTILSH
     53 
     54 #ifdef __cplusplus
     55 extern "C"
     56 {
     57 #endif				/* __cplusplus */
     58 
     59 /******************************************************************
     60  *   INCLUDE FILES
     61  ******************************************************************/
     62 #include "omx_rpc.h"
     63 #include "omx_rpc_internal.h"
     64 
     65 #include <timm_osal_trace.h>
     66 
     67 #define DOMX_ERROR(fmt,...)  TIMM_OSAL_Error(fmt, ##__VA_ARGS__)
     68 #define DOMX_WARN(fmt,...)   TIMM_OSAL_Warning(fmt, ##__VA_ARGS__)
     69 #define DOMX_PROF(fmt,...)   TIMM_OSAL_Profiling(fmt, ##__VA_ARGS__)
     70 #define DOMX_INFO(fmt,...)   TIMM_OSAL_Info(fmt, ##__VA_ARGS__)
     71 #define DOMX_DEBUG(fmt,...)  TIMM_OSAL_Debug(fmt, ##__VA_ARGS__)
     72 #define DOMX_ENTER(fmt,...)  TIMM_OSAL_Entering(fmt, ##__VA_ARGS__)
     73 #define DOMX_EXIT(fmt,...)   TIMM_OSAL_Exiting(fmt, ##__VA_ARGS__)
     74 
     75 
     76 /******************************************************************
     77  *   MACROS - ASSERTS
     78  ******************************************************************/
     79 #define RPC_assert  RPC_paramCheck
     80 #define RPC_require RPC_paramCheck
     81 #define RPC_ensure  RPC_paramCheck
     82 
     83 #define RPC_paramCheck(C, V, S) do { \
     84     if (!(C)) { eRPCError = V;\
     85     if(S) DOMX_ERROR("failed check:" #C" - returning error: 0x%x - %s",V,S);\
     86     else DOMX_ERROR("failed check:" #C" - returning error: 0x%x",V); \
     87     goto EXIT; } \
     88     } while(0)
     89 
     90 /* ************************* OFFSET DEFINES ******************************** */
     91 #define GET_PARAM_DATA_OFFSET    (sizeof(RPC_OMX_HANDLE) + sizeof(OMX_INDEXTYPE) + sizeof(OMX_U32) /*4 bytes for offset*/ )
     92 #define USE_BUFFER_DATA_OFFSET   (sizeof(OMX_U32)*5)
     93 
     94 /******************************************************************
     95  *   MACROS
     96  ******************************************************************/
     97 #define RPC_UTIL_GETSTRUCTSIZE(PTR) *((OMX_U32*)PTR)
     98 
     99 /******************************************************************
    100  *   MACROS - COMMON MARSHALLING UTILITIES
    101  ******************************************************************/
    102 #define RPC_SETFIELDVALUE(MSGBODY, POS, VALUE, TYPE) do { \
    103     *((TYPE *) ((OMX_U32)MSGBODY+POS)) = (TYPE)VALUE; \
    104     POS += sizeof(TYPE); \
    105     } while(0)
    106 
    107 #define RPC_SETFIELDOFFSET(MSGBODY, POS, OFFSET, TYPE) do { \
    108     *((TYPE *) ((OMX_U32)MSGBODY+POS)) = OFFSET; \
    109     POS += sizeof(TYPE); \
    110     } while(0)
    111 
    112 #define RPC_SETFIELDCOPYGEN(MSGBODY, POS, PTR, SIZE) do { \
    113     TIMM_OSAL_Memcpy((OMX_U8*)((OMX_U32)MSGBODY+POS), PTR, SIZE); \
    114     POS += SIZE; \
    115     } while (0)
    116 
    117 #define RPC_SETFIELDCOPYTYPE(MSGBODY, POS, PSTRUCT, TYPE) do { \
    118     *((TYPE *)((OMX_U32)MSGBODY+POS)) = *PSTRUCT; \
    119     POS += sizeof(TYPE); \
    120     } while (0)
    121 
    122 /******************************************************************
    123  *   MACROS - COMMON UNMARSHALLING UTILITIES
    124  ******************************************************************/
    125 #define RPC_GETFIELDVALUE(MSGBODY, POS, VALUE, TYPE) do { \
    126     VALUE = *((TYPE *) ((OMX_U32)MSGBODY+POS)); \
    127     POS += sizeof(TYPE); \
    128     } while(0)
    129 
    130 #define RPC_GETFIELDOFFSET(MSGBODY, POS, OFFSET, TYPE) do { \
    131     OFFSET = *((TYPE *) ((OMX_U32)MSGBODY+POS)); \
    132     POS += sizeof(TYPE); \
    133     } while(0)
    134 
    135 #define RPC_GETFIELDCOPYGEN(MSGBODY, POS, PTR, SIZE)  do { \
    136     TIMM_OSAL_Memcpy(PTR, (OMX_U8*)((OMX_U32)MSGBODY+POS), SIZE); \
    137     POS += SIZE; \
    138     } while(0)
    139 
    140 #define RPC_GETFIELDCOPYTYPE(MSGBODY, POS, PSTRUCT, TYPE) do { \
    141     *PSTRUCT = *((TYPE *)((OMX_U32)MSGBODY+POS)); \
    142     POS += sizeof(TYPE); \
    143     } while(0)
    144 
    145 #define RPC_GETFIELDPATCHED(MSGBODY, OFFSET, PTR, TYPE) \
    146 PTR = (TYPE *) (MSGBODY+OFFSET);
    147 
    148 /******************************************************************
    149  *   FUNCTIONS
    150  ******************************************************************/
    151 	RPC_OMX_ERRORTYPE RPC_UnMapBuffer(OMX_U32 mappedBuffer);
    152 	RPC_OMX_ERRORTYPE RPC_MapBuffer(OMX_U32 mappedBuffer);
    153 	RPC_OMX_ERRORTYPE RPC_FlushBuffer(OMX_U8 * pBuffer, OMX_U32 size,
    154 	    OMX_U32 nTargetCoreId);
    155 	RPC_OMX_ERRORTYPE RPC_InvalidateBuffer(OMX_U8 * pBuffer,
    156 	    OMX_U32 size, OMX_U32 nTargetCoreId);
    157 
    158 	RPC_OMX_ERRORTYPE RPC_UTIL_GetTargetServerName(OMX_STRING
    159 	    ComponentName, OMX_STRING ServerName);
    160 	RPC_OMX_ERRORTYPE RPC_UTIL_GetLocalServerName(OMX_STRING
    161 	    ComponentName, OMX_STRING * ServerName);
    162 	RPC_OMX_ERRORTYPE RPC_UTIL_GenerateLocalServerName(OMX_STRING
    163 	    cServerName);
    164 	RPC_OMX_ERRORTYPE RPC_UTIL_GetTargetCore(OMX_STRING cComponentName,
    165 	    OMX_U32 * nCoreId);
    166 
    167 #ifdef __cplusplus
    168 }
    169 #endif
    170 #endif
    171