1 /*
2 * Copyright (c) 2012-2013, 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 */
33 /*
34 * ======== OmapRpc.h ========
35 * OMAP Remote Procedure Call Driver.
36 *
37 */
39 #ifndef ti_srvmgr_OmapRpc__include
40 #define ti_srvmgr_OmapRpc__include
42 #include <ti/grcm/RcmServer.h>
43 #include <ti/ipc/mm/MmType.h>
46 #if defined (__cplusplus)
47 extern "C" {
48 #endif
51 /*!
52 * @def OmapRpc_S_SUCCESS
53 * @brief Operation is successful.
54 */
55 #define OmapRpc_S_SUCCESS 0
57 /*!
58 * @def OmapRpc_E_FAIL
59 * @brief Operation is not successful.
60 */
61 #define OmapRpc_E_FAIL -1
63 #define OmapRpc_NUM_PARAMETERS(size) \
64 ((size)/sizeof(struct OmapRpc_Parameter))
66 #define OmapRpc_PAYLOAD(ptr, type) \
67 ((struct type *)&(ptr)[sizeof(struct OmapRpc_MsgHeader)])
69 #define OmapRpc_PARAM(param, type) ((param).size == sizeof(type) ? (type)(param).data : 0)
71 #define OmapRpc_Stringerize(func) #func
73 #define OmapRpc_dimof(x) (sizeof(x)/sizeof((x)[0]))
75 #define OmapRpc_DESC_EXEC_SYNC (0x0100)
76 #define OmapRpc_DESC_EXEC_ASYNC (0x0200)
77 #define OmapRpc_DESC_SYM_ADD (0x0300)
78 #define OmapRpc_DESC_SYM_IDX (0x0400)
79 #define OmapRpc_DESC_CMD (0x0500)
80 #define OmapRpc_DESC_TYPE_MASK (0x0F00)
81 #define OmapRpc_JOBID_DISCRETE (0)
82 #define OmapRpc_POOLID_DEFAULT (0x8000)
84 #define OmapRpc_SET_FXN_IDX(idx) ((idx) | 0x80000000)
85 #define OmapRpc_FXN_MASK(idx) ((idx) & 0x7FFFFFFF)
87 #define OMAPRPC_MAX_CHANNEL_NAMELEN (64)
88 #define OMAPRPC_MAX_FUNC_NAMELEN (64)
89 #define OMAPRPC_MAX_NUM_PARAMS (10)
90 #define OMAPRPC_MAX_INST_NAMELEN (48)
92 typedef enum OmapRpc_InfoType {
93 /** The function signature */
94 OmapRpc_InfoType_FUNC_SIGNATURE = 1,
95 /** The number of times a function has been called */
96 OmapRpc_InfoType_NUM_CALLS,
97 /** The performance information releated to the function */
98 OmapRpc_InfoType_FUNC_PERFORMANCE,
100 /** @hidden used to define the maximum info type */
101 OmapRpc_InfoType_MAX
102 } OmapRpc_InfoType;
104 /** The applicable types of messages that the HOST may send the SERVICE.
105 */
106 typedef enum OmapRpc_MsgType {
107 /** Ask Service for channel information, uses \ref OmapRpc_ChannelInfo */
108 OmapRpc_MsgType_QUERY_CHAN_INFO = 0,
109 /** The return message from OMAPRPC_MSG_QUERY_CHAN_INFO*/
110 OmapRpc_MsgType_CHAN_INFO = 1,
111 /** Ask the Service Instance to send information about the Service.
112 * Uses \ref OmapRpc_QueryFunction */
113 OmapRpc_MsgType_QUERY_FUNCTION = 2,
114 /** The return message from OMAPRPC_QUERY_INSTANCE,
115 * which contains the information about the instance.
116 * Uses \ref OmapRpc_Instance_Info */
117 OmapRpc_MsgType_FUNCTION_INFO = 3,
118 /** Ask the ServiceMgr to create a new instance of the service.
119 * No secondary data is needed. */
120 OmapRpc_MsgType_CREATE_INSTANCE = 6,
121 /** The return message from OMAPRPC_CREATE_INSTANCE,
122 * contains the new endpoint address in the OmapRpc_InstanceHandle */
123 OmapRpc_MsgType_INSTANCE_CREATED = 8,
124 /** Ask the Service Mgr to destroy an instance */
125 OmapRpc_MsgType_DESTROY_INSTANCE = 4,
126 /** The return message from OMAPRPC_DESTROY_INSTANCE.
127 * contains the old endpoint address in the OmapRpc_InstanceHandle */
128 OmapRpc_MsgType_INSTANCE_DESTROYED = 7,
129 /** Ask the Service Instance to call a particular function */
130 OmapRpc_MsgType_CALL_FUNCTION = 5,
131 /** The return values from a function call */
132 OmapRpc_MsgType_FUNCTION_RETURN = 9,
133 /** Returned from either the ServiceMgr or Service Instance
134 * when an error occurs */
135 OmapRpc_MsgType_ERROR = 10,
136 /** \hidden used to define the max msg enum, not an actual message */
137 OmapRpc_MsgType_MAX
138 } OmapRpc_MsgType;
140 typedef enum OmapRpc_ErrorType {
141 /**< No errors to report */
142 OmapRpc_ErrorType_NONE = 0,
143 /**< Not enough memory exist to process request */
144 OmapRpc_ErrorType_NOT_ENOUGH_MEMORY,
145 /**< The instance died */
146 OmapRpc_ErrorType_INSTANCE_DIED,
147 /**< Some resource was unavailable. */
148 OmapRpc_ErrorType_RESOURCE_UNAVAILABLE,
149 /**< A provided parameter was either out of range, incorrect or NULL */
150 OmapRpc_ErrorType_BAD_PARAMETER,
151 /**< The requested item is not supported */
152 OmapRpc_ErrorType_NOT_SUPPORTED,
154 /** @hidden used to define the max error value */
155 OmapRpc_ErrorType_MAX_VALUE
156 } OmapRpc_ErrorType;
158 typedef struct OmapRpc_CreateInstance {
159 Char name[OMAPRPC_MAX_INST_NAMELEN];
160 } OmapRpc_CreateInstance;
162 typedef struct OmapRpc_ChannelInfo {
163 UInt32 numFuncs; /**< The number of functions supported on this endpoint */
164 } OmapRpc_ChannelInfo;
166 typedef struct OmapRpc_FuncPerf {
167 UInt32 clocksPerSec;
168 UInt32 clockCycles;
169 } OmapRpc_FuncPerf;
171 /** The parameter direction as relative to the function it describes */
172 typedef enum OmapRpc_Direction {
173 OmapRpc_Direction_In = 0,
174 OmapRpc_Direction_Out,
175 OmapRpc_Direction_Bi,
176 OmapRpc_Direction_MAX
177 } OmapRpc_Direction;
179 typedef enum OmapRpc_Param_Type {
180 OmapRpc_Param_VOID = 0,
181 OmapRpc_Param_S08,
182 OmapRpc_Param_U08,
183 OmapRpc_Param_S16,
184 OmapRpc_Param_U16,
185 OmapRpc_Param_S32,
186 OmapRpc_Param_U32,
187 OmapRpc_Param_S64,
188 OmapRpc_Param_U64,
190 OmapRpc_Param_PTR = 0x80, /**< Logically OR'd with lower type to make a
191 pointer to the correct type */
192 OmapRpc_Param_MAX
193 } OmapRpc_Param_Type;
195 #define OmapRpc_PtrType(type) ((type) | OmapRpc_Param_PTR)
197 typedef struct OmapRpc_ParamSignature {
198 UInt32 direction; /**< @see OmapRpc_Direction */
199 UInt32 type; /**< @see OmapRpc_Param_Type */
200 UInt32 count; /**< Used to do some basic sanity checking on array bounds */
201 } OmapRpc_ParamSignature;
203 /**
204 * This is the data structure that represents the function signature.
205 * @note The first parameter (params[0]) is the return value.
206 */
207 typedef struct OmapRpc_FuncSignature {
208 Char name[OMAPRPC_MAX_FUNC_NAMELEN];
209 UInt32 numParam;
210 OmapRpc_ParamSignature params[OMAPRPC_MAX_NUM_PARAMS+1];
211 } OmapRpc_FuncSignature;
213 /**
214 * \brief Function Query Structure.
215 * \details This is used by the host first to ask the remote side for details
216 * about it's published functions
217 */
218 typedef struct OmapRpc_QueryFunction {
219 UInt32 infoType; /**< @see OmapRpc_InfoType */
220 UInt32 funcIndex; /**< The function index to query */
221 union info {
222 UInt32 numCalls;
223 OmapRpc_FuncPerf performance;
224 OmapRpc_FuncSignature signature;
225 } info;
226 } OmapRpc_QueryFunction;
228 /** @brief The generic OMAPRPC message header.
229 * (actually a copy of omx_msg_hdr which is a copy of an RCM header)
230 */
231 typedef struct OmapRpc_MsgHeader {
232 UInt32 msgType; /**< @see OmapRpc_MsgType */
233 UInt32 msgLen; /**< The length of the message data in bytes */
234 } OmapRpc_MsgHeader;
236 typedef struct OmapRpc_InstanceHandle {
237 UInt32 endpointAddress;
238 UInt32 status;
239 } OmapRpc_InstanceHandle;
241 typedef struct OmapRpc_Error {
242 UInt32 endpointAddress;
243 UInt32 status;
244 } OmapRpc_Error;
246 typedef struct OmapRpc_Parameter {
247 SizeT size;
248 SizeT data;
249 } OmapRpc_Parameter;
251 /** This is actually a frankensteined structure of RCM */
252 typedef struct OmapRpc_Packet{
253 UInt16 desc; /**< @see RcmClient_Packet.desc */
254 UInt16 msgId; /**< @see RcmClient_Packet.msgId */
255 UInt16 poolId; /**< @see RcmClient_Message.poolId */
256 UInt16 jobId; /**< @see RcmClient_Message.jobId */
257 UInt32 fxnIdx; /**< @see RcmClient_Message.fxnIdx */
258 Int32 result; /**< @see RcmClient_Message.result */
259 UInt32 dataSize; /**< @see RcmClient_Message.data_size */
260 } OmapRpc_Packet;
262 /** An OmapRpc Function is really an RCM function */
263 typedef RcmServer_MsgFxn OmapRpc_Function;
265 /**
266 * \brief The Function Declaration Structure.
267 * \details This structure is used to declare the function signature and their
268 * associated functions
269 */
270 typedef struct OmapRpc_FuncDeclaration {
271 OmapRpc_Function function; /**< \brief The function pointer */
272 OmapRpc_FuncSignature signature; /**< \brief The signature of the function */
273 } OmapRpc_FuncDeclaration;
275 typedef struct OmapRpc_Object *OmapRpc_Handle;
276 typedef Void (*OmapRpc_SrvDelNotifyFxn)(Void);
278 #if 0
279 OmapRpc_Handle OmapRpc_createChannel(String channelName, UInt16 dstProc,
280 UInt32 port, UInt32 numFuncs, OmapRpc_FuncDeclaration* fxns,
281 OmapRpc_SrvDelNotifyFxn func);
282 #else
283 OmapRpc_Handle OmapRpc_createChannel(String channelName, UInt16 dstProc,
284 UInt32 port, RcmServer_Params *rcmParams, MmType_FxnSigTab *fxnSigTab,
285 OmapRpc_SrvDelNotifyFxn srvDelCBFunc);
286 #endif
288 Int OmapRpc_deleteChannel(OmapRpc_Handle handle);
291 #if defined (__cplusplus)
292 }
293 #endif /* defined (__cplusplus) */
295 /*@}*/
296 #endif /* ti_srvmgr_OmapRpc__include */