]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blobdiff - packages/ti/ipc/mm/MmRpc.h
Added offset pointer support to MmRcp.
[ipc/ipcdev.git] / packages / ti / ipc / mm / MmRpc.h
index 04fabe657e3444edc5fa0f1a9f25a029ddb85373..ed8f000e50c699e7853d677142d1ee5b9707fd48 100644 (file)
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/** ============================================================================
- *  @file       MmRpc.h
+/**
+ *  @file       ti/ipc/mm/MmRpc.h
  *
  *  @brief      Multi-Media derived Remote Procedure Call
  *
- *  ============================================================================
+ *  @note       MmRpc is currently only available for Linux and QNX.
+ *
+ *
  */
 
 #ifndef ti_ipc_mm_MmRpc__include
@@ -45,7 +47,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#if defined (__cplusplus)
+#if defined(__cplusplus)
 extern "C" {
 #endif
 
@@ -59,16 +61,38 @@ extern "C" {
  */
 #define MmRpc_E_FAIL (-1)
 
+/*!
+ *  @brief  Invalid parameter type
+ */
+#define MmRpc_E_INVALIDPARAM (-2)
+
 /*!
  *  @brief  Size of parameter array in function context structure
  */
-#define MmRpc_MAX_PARAMETERS (10)
+#define MmRpc_MAX_PARAMS (10)
 
 /*!
  *  @brief  Maximum size of translation array in function context structure
  */
 #define MmRpc_MAX_TRANSLATIONS (1024)
 
+/*!
+ *  @brief  Macro for computing offset to a field of a structure.
+ *
+ *  @code
+ *  struct foobar {
+ *      int a;
+ *      int *p;
+ *  };
+ *
+ *  struct foobar *sp = ...;
+ *  offset = MmRpc_OFFSET(sp, &sp->p);
+ *  struct foobar st = ...;
+ *  offset = MmRpc_OFFSET(&st, &st.p);
+ *  @endcode
+ */
+#define MmRpc_OFFSET(base, field) ((unsigned int)(field)-(unsigned int)(base))
+
 /*!
  *  @brief      MmRpc_Handle type
  */
@@ -78,9 +102,10 @@ typedef struct MmRpc_Object *MmRpc_Handle;
  *  @brief      MmRpc_ParamType enum
  */
 typedef enum {
-    MmRpc_ParamType_Atomic = 1, /*!< atomic data type */
-    MmRpc_ParamType_ShMemPtr,   /*!< shared memory pointer */
-    MmRpc_ParamType_Ptr         /*!< data pointer */
+    MmRpc_ParamType_Scalar = 1, /*!< pass by value */
+    MmRpc_ParamType_Ptr,        /*!< data pointer */
+    MmRpc_ParamType_OffPtr,     /*!< buffer at offset in memory block */
+    MmRpc_ParamType_Elem        /*!< array element */
 } MmRpc_ParamType;
 
 /*!
@@ -88,45 +113,53 @@ typedef enum {
  */
 typedef struct {
     MmRpc_ParamType     type;   /*!< parameter type */
+
     union {
         struct {
             size_t      size;   /*!< size of the data */
-            size_t      data;   /*!< atomic data */
-        } atomic;
+            size_t      data;   /*!< data (pass by value)*/
+        } scalar;
 
         struct {
-            size_t      size;   /*!< size of the data */
-            size_t      data;   /*!< pointer to data */
-            size_t      base;   /*!< base address */
-            size_t      smh;    /*!< shared memory handle */
-        } shmem;
+            size_t      size;   /*!< size of the data referenced */
+            size_t      addr;   /*!< pointer value */
+            size_t      handle; /*!< memory allocator handle */
+        } ptr;
 
         struct {
-            size_t      size;   /*!< size of the data */
-            size_t      ptr;    /*!< pointer to data */
-        } ptr;
+            size_t      size;   /*!< size (bytes) of memory block */
+            size_t      base;   /*!< base address of memory block */
+            size_t      offset; /*!< offset (bytes) from base to data */
+            size_t      handle; /*!< memory allocator handle */
+        } offPtr;
+
+#if 0 /* TBD */
+        struct {
+            size_t      size;   /*!< size of the array element */
+            size_t      offset; /*!< offset to current array element */
+            size_t      base;   /*!< base address of array */
+            size_t      handle; /*!< memory allocator handle */
+        } elem;
+#endif
     } param;
 } MmRpc_Param;
 
 typedef struct {
     uint32_t    index;  /*!< parameter index to base pointer */
     ptrdiff_t   offset; /*!< offset from the base address to pointer */
-    size_t      base;   /*!< user virtual address */
-} MmRpc_Txlt;
+    size_t      handle; /*!< memory allocator handle */
+} MmRpc_Xlt;
 
 /*!
  *  @brief      Function call context structure
  */
 typedef struct {
-    uint32_t    fxn_id;         /*!< The function to call. */
-    uint32_t    result;         /*!< The function return value. */
-    uint32_t    num_params;     /*!< Number of elements in param array. */
-    MmRpc_Param params[MmRpc_MAX_PARAMETERS];
-                                /*!< The array of parameters */
-    uint32_t num_translations;
-                                /*!< The number of translations needed
-                                 *   in the offsets array */
-    MmRpc_Txlt *translations;   /*!< array of translations */
+    uint32_t    fxn_id;         /*!< function id to call */
+    uint32_t    num_params;     /*!< number of parameters in params array */
+    MmRpc_Param params[MmRpc_MAX_PARAMS];
+                                /*!< the array of parameters */
+    uint32_t    num_xlts;       /*!< number of translations in xltAry */
+    MmRpc_Xlt * xltAry;         /*!< array of translations */
 } MmRpc_FxnCtx;
 
 /*!
@@ -140,14 +173,14 @@ typedef struct {
  *  @brief      Invoke a remote procedure call
  *
  */
-int MmRpc_call(MmRpc_Handle handle, MmRpc_FxnCtx *ctx);
+int MmRpc_call(MmRpc_Handle handle, MmRpc_FxnCtx *ctx, int32_t *ret);
 
 /*!
  *  @brief      Create an MmRpc instance
  *
  */
-MmRpc_Handle MmRpc_create(const char *proc, const char *service,
-        const MmRpc_Params *params);
+int MmRpc_create(const char *service, const MmRpc_Params *params,
+        MmRpc_Handle *handlPtr);
 
 /*!
  *  @brief      Delete an MmRpc instance
@@ -163,7 +196,7 @@ void MmRpc_Params_init(MmRpc_Params *params);
 
 
 
-#if defined (__cplusplus)
+#if defined(__cplusplus)
 }
 #endif
 #endif /* ti_ipc_mm_MmRpc__include */