]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - packages/ti/ipc/mm/MmRpc.h
Added offset pointer support to MmRcp.
[ipc/ipcdev.git] / packages / ti / ipc / mm / MmRpc.h
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_OffPtr,     /*!< buffer at offset in memory block */
108     MmRpc_ParamType_Elem        /*!< array element */
109 } MmRpc_ParamType;
111 /*!
112  *  @brief      MmRpc_Param type
113  */
114 typedef struct {
115     MmRpc_ParamType     type;   /*!< parameter type */
117     union {
118         struct {
119             size_t      size;   /*!< size of the data */
120             size_t      data;   /*!< data (pass by value)*/
121         } scalar;
123         struct {
124             size_t      size;   /*!< size of the data referenced */
125             size_t      addr;   /*!< pointer value */
126             size_t      handle; /*!< memory allocator handle */
127         } ptr;
129         struct {
130             size_t      size;   /*!< size (bytes) of memory block */
131             size_t      base;   /*!< base address of memory block */
132             size_t      offset; /*!< offset (bytes) from base to data */
133             size_t      handle; /*!< memory allocator handle */
134         } offPtr;
136 #if 0 /* TBD */
137         struct {
138             size_t      size;   /*!< size of the array element */
139             size_t      offset; /*!< offset to current array element */
140             size_t      base;   /*!< base address of array */
141             size_t      handle; /*!< memory allocator handle */
142         } elem;
143 #endif
144     } param;
145 } MmRpc_Param;
147 typedef struct {
148     uint32_t    index;  /*!< parameter index to base pointer */
149     ptrdiff_t   offset; /*!< offset from the base address to pointer */
150     size_t      handle; /*!< memory allocator handle */
151 } MmRpc_Xlt;
153 /*!
154  *  @brief      Function call context structure
155  */
156 typedef struct {
157     uint32_t    fxn_id;         /*!< function id to call */
158     uint32_t    num_params;     /*!< number of parameters in params array */
159     MmRpc_Param params[MmRpc_MAX_PARAMS];
160                                 /*!< the array of parameters */
161     uint32_t    num_xlts;       /*!< number of translations in xltAry */
162     MmRpc_Xlt * xltAry;         /*!< array of translations */
163 } MmRpc_FxnCtx;
165 /*!
166  *  @brief      Instance create parameters
167  */
168 typedef struct {
169     int reserved;
170 } MmRpc_Params;
172 /*!
173  *  @brief      Invoke a remote procedure call
174  *
175  */
176 int MmRpc_call(MmRpc_Handle handle, MmRpc_FxnCtx *ctx, int32_t *ret);
178 /*!
179  *  @brief      Create an MmRpc instance
180  *
181  */
182 int MmRpc_create(const char *service, const MmRpc_Params *params,
183         MmRpc_Handle *handlPtr);
185 /*!
186  *  @brief      Delete an MmRpc instance
187  *
188  */
189 int MmRpc_delete(MmRpc_Handle *handlePtr);
191 /*!
192  *  @brief      Initialize the instance create parameter structure
193  *
194  */
195 void MmRpc_Params_init(MmRpc_Params *params);
199 #if defined(__cplusplus)
201 #endif
202 #endif /* ti_ipc_mm_MmRpc__include */