• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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@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_INFO(fmt,...)   TIMM_OSAL_Info(fmt, ##__VA_ARGS__)
70 #define DOMX_DEBUG(fmt,...)  TIMM_OSAL_Debug(fmt, ##__VA_ARGS__)
71 #define DOMX_ENTER(fmt,...)  TIMM_OSAL_Entering(fmt, ##__VA_ARGS__)
72 #define DOMX_EXIT(fmt,...)   TIMM_OSAL_Exiting(fmt, ##__VA_ARGS__)
73 
74 
75 /******************************************************************
76  *   MACROS - ASSERTS
77  ******************************************************************/
78 #define RPC_assert  RPC_paramCheck
79 #define RPC_require RPC_paramCheck
80 #define RPC_ensure  RPC_paramCheck
81 
82 #define RPC_paramCheck(C, V, S) do { \
83     if (!(C)) { eRPCError = V;\
84     if(S) DOMX_ERROR("failed check:" #C" - returning error: 0x%x - %s",V,S);\
85     else DOMX_ERROR("failed check: %s - returning error: 0x%x",C, V); \
86     goto EXIT; } \
87     } while(0)
88 
89 /* ************************* OFFSET DEFINES ******************************** */
90 #define GET_PARAM_DATA_OFFSET    (sizeof(RPC_OMX_HANDLE) + sizeof(OMX_INDEXTYPE) + sizeof(OMX_U32) /*4 bytes for offset*/ )
91 #define USE_BUFFER_DATA_OFFSET   (sizeof(OMX_U32)*5)
92 
93 /******************************************************************
94  *   MACROS
95  ******************************************************************/
96 #define RPC_UTIL_GETSTRUCTSIZE(PTR) *((OMX_U32*)PTR)
97 
98 /******************************************************************
99  *   MACROS - COMMON MARSHALLING UTILITIES
100  ******************************************************************/
101 #define RPC_SETFIELDVALUE(MSGBODY, POS, VALUE, TYPE) do { \
102     *((TYPE *) ((OMX_U32)MSGBODY+POS)) = VALUE; \
103     POS += sizeof(TYPE); \
104     } while(0)
105 
106 #define RPC_SETFIELDOFFSET(MSGBODY, POS, OFFSET, TYPE) do { \
107     *((TYPE *) ((OMX_U32)MSGBODY+POS)) = OFFSET; \
108     POS += sizeof(TYPE); \
109     } while(0)
110 
111 #define RPC_SETFIELDCOPYGEN(MSGBODY, POS, PTR, SIZE) do { \
112     TIMM_OSAL_Memcpy((OMX_U8*)((OMX_U32)MSGBODY+POS), PTR, SIZE); \
113     POS += SIZE; \
114     } while (0)
115 
116 #define RPC_SETFIELDCOPYTYPE(MSGBODY, POS, PSTRUCT, TYPE) do { \
117     *((TYPE *)((OMX_U32)MSGBODY+POS)) = *PSTRUCT; \
118     POS += sizeof(TYPE); \
119     } while (0)
120 
121 /******************************************************************
122  *   MACROS - COMMON UNMARSHALLING UTILITIES
123  ******************************************************************/
124 #define RPC_GETFIELDVALUE(MSGBODY, POS, VALUE, TYPE) do { \
125     VALUE = *((TYPE *) ((OMX_U32)MSGBODY+POS)); \
126     POS += sizeof(TYPE); \
127     } while(0)
128 
129 #define RPC_GETFIELDOFFSET(MSGBODY, POS, OFFSET, TYPE) do { \
130     OFFSET = *((TYPE *) ((OMX_U32)MSGBODY+POS)); \
131     POS += sizeof(TYPE); \
132     } while(0)
133 
134 #define RPC_GETFIELDCOPYGEN(MSGBODY, POS, PTR, SIZE)  do { \
135     TIMM_OSAL_Memcpy(PTR, (OMX_U8*)((OMX_U32)MSGBODY+POS), SIZE); \
136     POS += SIZE; \
137     } while(0)
138 
139 #define RPC_GETFIELDCOPYTYPE(MSGBODY, POS, PSTRUCT, TYPE) do { \
140     *PSTRUCT = *((TYPE *)((OMX_U32)MSGBODY+POS)); \
141     POS += sizeof(TYPE); \
142     } while(0)
143 
144 #define RPC_GETFIELDPATCHED(MSGBODY, OFFSET, PTR, TYPE) \
145 PTR = (TYPE *) (MSGBODY+OFFSET);
146 
147 /******************************************************************
148  *   FUNCTIONS
149  ******************************************************************/
150 	RPC_OMX_ERRORTYPE RPC_UnMapBuffer(OMX_U32 mappedBuffer);
151 	RPC_OMX_ERRORTYPE RPC_MapBuffer(OMX_U32 mappedBuffer);
152 	RPC_OMX_ERRORTYPE RPC_FlushBuffer(OMX_U8 * pBuffer, OMX_U32 size,
153 	    OMX_U32 nTargetCoreId);
154 	RPC_OMX_ERRORTYPE RPC_InvalidateBuffer(OMX_U8 * pBuffer,
155 	    OMX_U32 size, OMX_U32 nTargetCoreId);
156 
157 	RPC_OMX_ERRORTYPE RPC_UTIL_GetTargetServerName(OMX_STRING
158 	    ComponentName, OMX_STRING ServerName);
159 	RPC_OMX_ERRORTYPE RPC_UTIL_GetLocalServerName(OMX_STRING
160 	    ComponentName, OMX_STRING * ServerName);
161 	RPC_OMX_ERRORTYPE RPC_UTIL_GenerateLocalServerName(OMX_STRING
162 	    cServerName);
163 	RPC_OMX_ERRORTYPE RPC_UTIL_GetTargetCore(OMX_STRING cComponentName,
164 	    OMX_U32 * nCoreId);
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 #endif
170