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 MmRpc.h
35 *
36 * @brief Multi-Media derived Remote Procedure Call
37 *
38 * ============================================================================
39 */
41 #ifndef ti_ipc_mm_MmRpc__include
42 #define ti_ipc_mm_MmRpc__include
44 /* add includes here */
45 #include <stddef.h>
46 #include <stdint.h>
48 #if defined (__cplusplus)
49 extern "C" {
50 #endif
52 /*!
53 * @brief Operation is successful
54 */
55 #define MmRpc_S_SUCCESS (0)
57 /*!
58 * @brief Operation failed
59 */
60 #define MmRpc_E_FAIL (-1)
62 /*!
63 * @brief Size of parameter array in function context structure
64 */
65 #define MmRpc_MAX_PARAMETERS (10)
67 /*!
68 * @brief Maximum size of translation array in function context structure
69 */
70 #define MmRpc_MAX_TRANSLATIONS (1024)
72 /*!
73 * @brief MmRpc_Handle type
74 */
75 typedef struct MmRpc_Object *MmRpc_Handle;
77 /*!
78 * @brief MmRpc_ParamType enum
79 */
80 typedef enum {
81 MmRpc_ParamType_Atomic = 1, /*!< atomic data type */
82 MmRpc_ParamType_ShMemPtr, /*!< shared memory pointer */
83 MmRpc_ParamType_Ptr /*!< data pointer */
84 } MmRpc_ParamType;
86 /*!
87 * @brief MmRpc_Param type
88 */
89 typedef struct {
90 MmRpc_ParamType type; /*!< parameter type */
91 union {
92 struct {
93 size_t size; /*!< size of the data */
94 size_t data; /*!< atomic data */
95 } atomic;
97 struct {
98 size_t size; /*!< size of the data */
99 size_t data; /*!< pointer to data */
100 size_t base; /*!< base address */
101 size_t smh; /*!< shared memory handle */
102 } shmem;
104 struct {
105 size_t size; /*!< size of the data */
106 size_t ptr; /*!< pointer to data */
107 } ptr;
108 } param;
109 } MmRpc_Param;
111 typedef struct {
112 uint32_t index; /*!< parameter index to base pointer */
113 ptrdiff_t offset; /*!< offset from the base address to pointer */
114 size_t base; /*!< user virtual address */
115 } MmRpc_Txlt;
117 /*!
118 * @brief Function call context structure
119 */
120 typedef struct {
121 uint32_t fxn_id; /*!< The function to call. */
122 uint32_t result; /*!< The function return value. */
123 uint32_t num_params; /*!< Number of elements in param array. */
124 MmRpc_Param params[MmRpc_MAX_PARAMETERS];
125 /*!< The array of parameters */
126 uint32_t num_translations;
127 /*!< The number of translations needed
128 * in the offsets array */
129 MmRpc_Txlt *translations; /*!< array of translations */
130 } MmRpc_FxnCtx;
132 /*!
133 * @brief Instance create parameters
134 */
135 typedef struct {
136 int reserved;
137 } MmRpc_Params;
139 /*!
140 * @brief Invoke a remote procedure call
141 *
142 */
143 int MmRpc_call(MmRpc_Handle handle, MmRpc_FxnCtx *ctx);
145 /*!
146 * @brief Create an MmRpc instance
147 *
148 */
149 MmRpc_Handle MmRpc_create(const char *proc, const char *service,
150 const MmRpc_Params *params);
152 /*!
153 * @brief Delete an MmRpc instance
154 *
155 */
156 int MmRpc_delete(MmRpc_Handle *handlePtr);
158 /*!
159 * @brief Initialize the instance create parameter structure
160 *
161 */
162 void MmRpc_Params_init(MmRpc_Params *params);
166 #if defined (__cplusplus)
167 }
168 #endif
169 #endif /* ti_ipc_mm_MmRpc__include */