d6f6c7c77723e07168587100d9af9e14a35a5e83
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 * @file ti/ipc/mm/MmRpc.h
35 *
36 * @brief Multi-Media derived Remote Procedure Call
37 *
38 * @note MmRpc is currently only available for Linux and QNX.
39 *
40 *
41 */
43 #ifndef ti_ipc_mm_MmRpc__include
44 #define ti_ipc_mm_MmRpc__include
46 /* add includes here */
47 #include <stddef.h>
48 #include <stdint.h>
50 #if defined(__cplusplus)
51 extern "C" {
52 #endif
54 /*!
55 * @brief Operation is successful
56 */
57 #define MmRpc_S_SUCCESS (0)
59 /*!
60 * @brief Operation failed
61 */
62 #define MmRpc_E_FAIL (-1)
64 /*!
65 * @brief Invalid parameter type
66 */
67 #define MmRpc_E_INVALIDPARAM (-2)
69 /*!
70 * @brief Size of parameter array in function context structure
71 */
72 #define MmRpc_MAX_PARAMS (10)
74 /*!
75 * @brief Maximum size of translation array in function context structure
76 */
77 #define MmRpc_MAX_TRANSLATIONS (1024)
79 /*!
80 * @brief Macro for computing offset to a field of a structure.
81 *
82 * @code
83 * struct foobar {
84 * int a;
85 * int *p;
86 * };
87 *
88 * struct foobar *sp = ...;
89 * offset = MmRpc_OFFSET(sp, &sp->p);
90 * struct foobar st = ...;
91 * offset = MmRpc_OFFSET(&st, &st.p);
92 * @endcode
93 */
94 #define MmRpc_OFFSET(base, field) ((unsigned int)(field)-(unsigned int)(base))
96 /*!
97 * @brief MmRpc_Handle type
98 */
99 typedef struct MmRpc_Object *MmRpc_Handle;
101 /*!
102 * @brief MmRpc_ParamType enum
103 */
104 typedef enum {
105 MmRpc_ParamType_Scalar = 1, /*!< pass by value */
106 MmRpc_ParamType_Ptr, /*!< data pointer */
107 MmRpc_ParamType_Elem /*!< array element */
108 } MmRpc_ParamType;
110 /*!
111 * @brief MmRpc_Param type
112 */
113 typedef struct {
114 MmRpc_ParamType type; /*!< parameter type */
116 union {
117 struct {
118 size_t size; /*!< size of the data */
119 size_t data; /*!< data (pass by value)*/
120 } scalar;
122 struct {
123 size_t size; /*!< size of the data referenced */
124 size_t addr; /*!< pointer value */
125 size_t handle; /*!< memory allocator handle */
126 } ptr;
128 #if 0 /* TBD */
129 struct {
130 size_t size; /*!< size of the array element */
131 size_t offset; /*!< offset to current array element */
132 size_t base; /*!< base address of array */
133 size_t handle; /*!< memory allocator handle */
134 } elem;
135 #endif
136 } param;
137 } MmRpc_Param;
139 typedef struct {
140 uint32_t index; /*!< parameter index to base pointer */
141 ptrdiff_t offset; /*!< offset from the base address to pointer */
142 size_t base; /*!< user virtual address */
143 size_t handle; /*!< memory allocator handle */
144 } MmRpc_Xlt;
146 /*!
147 * @brief Function call context structure
148 */
149 typedef struct {
150 uint32_t fxn_id; /*!< function id to call */
151 uint32_t num_params; /*!< number of parameters in params array */
152 MmRpc_Param params[MmRpc_MAX_PARAMS];
153 /*!< the array of parameters */
154 uint32_t num_xlts; /*!< number of translations in xltAry */
155 MmRpc_Xlt * xltAry; /*!< array of translations */
156 } MmRpc_FxnCtx;
158 /*!
159 * @brief Instance create parameters
160 */
161 typedef struct {
162 int reserved;
163 } MmRpc_Params;
165 /*!
166 * @brief Invoke a remote procedure call
167 *
168 */
169 int MmRpc_call(MmRpc_Handle handle, MmRpc_FxnCtx *ctx, int32_t *ret);
171 /*!
172 * @brief Create an MmRpc instance
173 *
174 */
175 int MmRpc_create(const char *service, const MmRpc_Params *params,
176 MmRpc_Handle *handlPtr);
178 /*!
179 * @brief Delete an MmRpc instance
180 *
181 */
182 int MmRpc_delete(MmRpc_Handle *handlePtr);
184 /*!
185 * @brief Initialize the instance create parameter structure
186 *
187 */
188 void MmRpc_Params_init(MmRpc_Params *params);
192 #if defined(__cplusplus)
193 }
194 #endif
195 #endif /* ti_ipc_mm_MmRpc__include */