Merge remote-tracking branch 'angela/13_eng_dev-ramsey-3.00.a' into dev-3.00
authorRamsey Harris <ramsey@ti.com>
Thu, 21 Mar 2013 00:03:39 +0000 (17:03 -0700)
committerRamsey Harris <ramsey@ti.com>
Thu, 21 Mar 2013 00:03:39 +0000 (17:03 -0700)
packages/ti/ipc/tests/rpc_task.c
qnx/.gitignore [new file with mode: 0644]
qnx/src/ipc3x_dev/sharedmemallocator/resmgr/SharedMemoryAllocator.c
qnx/src/ipc3x_dev/ti/syslink/family/omap5430/Platform.c
qnx/src/ipc3x_dev/ti/syslink/rpmsg-rpc/rpmsg-rpc.c
qnx/src/ipc3x_dev/ti/syslink/rpmsg-rpc/rpmsg-rpc.h
qnx/src/ipc3x_dev/ti/syslink/samples/hlos/rpmsg-rpc-stress/usr/rpmsg-rpc-stress.use
qnx/src/ipc3x_dev/ti/syslink/samples/hlos/rpmsg-rpc-stress/usr/tests_rpc_stress.c

index 8cfdc1a76eaf10e65f991055874e5dd7f8509d99..a137a3852f3a68d1c1b3eb234a50729cb2c845d3 100644 (file)
@@ -58,6 +58,8 @@
 #include <ti/srvmgr/rpmsg_omx.h>
 #include <ti/srvmgr/omx_packet.h>
 
+#include <ti/sysbios/hal/Cache.h>
+
 /* Turn on/off printf's */
 #define CHATTER 1
 
@@ -83,17 +85,25 @@ typedef enum {
  *  ======== fxnTriple used by omx_benchmark test app ========
  */
 typedef struct {
-    Int size_a;
     Int a;
 } FxnTripleArgs;
 
 typedef struct {
-    Int size_a;
     Int a;
-    Int size_b;
     Int b;
 } FxnAddArgs;
 
+typedef struct {
+    Int a;
+    Int b;
+    Int c;
+} FxnAdd3Args;
+
+typedef struct {
+    Int num;
+    Int *array;
+} FxnAddXArgs;
+
 #define H264_DECODER_NAME   "H264_decoder"
 
 #define OMX_VIDEO_THREAD_PRIORITY    5
@@ -106,6 +116,8 @@ static Int32 RPC_SKEL_SetParameter(UInt32 size, UInt32 *data);
 static Int32 RPC_SKEL_GetParameter(UInt32 size, UInt32 *data);
 static Int32 fxnTriple(UInt32 size, UInt32 *data);
 static Int32 fxnAdd(UInt32 size, UInt32 *data);
+static Int32 fxnAdd3(UInt32 size, UInt32 *data);
+static Int32 fxnAddX(UInt32 size, UInt32 *data);
 
 #if 0
 /* RcmServer static function table */
@@ -124,7 +136,7 @@ static const RcmServer_FxnDescAry RPCServer_fxnTab = {
 };
 #endif
 
-#define RPC_SVR_NUM_FXNS 3
+#define RPC_SVR_NUM_FXNS 5
 OmapRpc_FuncDeclaration RPCServerFxns[RPC_SVR_NUM_FXNS] =
 {
     { RPC_SKEL_Init2,
@@ -152,6 +164,22 @@ OmapRpc_FuncDeclaration RPCServerFxns[RPC_SVR_NUM_FXNS] =
                 {OmapRpc_Direction_In, OmapRpc_Param_S32, 1}
             }
         }
+    },
+    { fxnAdd3,
+        { "fxnAdd3", 2,
+            {
+                {OmapRpc_Direction_Out, OmapRpc_Param_S32, 1}, // return
+                {OmapRpc_Direction_In, OmapRpc_PtrType(OmapRpc_Param_U32), 1}
+            }
+        }
+    },
+    { fxnAddX,
+        { "fxnAddX", 2,
+            {
+                {OmapRpc_Direction_Out, OmapRpc_Param_S32, 1}, // return
+                {OmapRpc_Direction_In, OmapRpc_PtrType(OmapRpc_Param_U32), 1}
+            }
+        }
     }
 };
 
@@ -246,12 +274,10 @@ static Int32 RPC_SKEL_Init2(UInt32 size, UInt32 *data)
  */
 Int32 fxnTriple(UInt32 size, UInt32 *data)
 {
-    FxnTripleArgs *args;
+    struct OmapRpc_Parameter *payload = (struct OmapRpc_Parameter *)data;
     Int a;
 
-//  args = (FxnTripleArgs *)((UInt32)data + sizeof(map_info_type));
-    args = (FxnTripleArgs *)data;
-    a = args->a;
+    a = (Int)payload[0].data;
 
 #if CHATTER
     System_printf("fxnTriple: a=%d\n", a);
@@ -265,12 +291,11 @@ Int32 fxnTriple(UInt32 size, UInt32 *data)
  */
 Int32 fxnAdd(UInt32 size, UInt32 *data)
 {
-    FxnAddArgs *args;
+    struct OmapRpc_Parameter *payload = (struct OmapRpc_Parameter *)data;
     Int a, b;
 
-    args = (FxnAddArgs *)data;
-    a = args->a;
-    b = args->b;
+    a = (Int)payload[0].data;
+    b = (Int)payload[1].data;
 
 #if CHATTER
     System_printf("fxnAdd: a=%d, b=%d\n", a, b);
@@ -279,6 +304,66 @@ Int32 fxnAdd(UInt32 size, UInt32 *data)
     return(a + b);
 }
 
+/*
+ *  ======== fxnAdd3 ========
+ */
+Int32 fxnAdd3(UInt32 size, UInt32 *data)
+{
+    struct OmapRpc_Parameter *payload = (struct OmapRpc_Parameter *)data;
+    FxnAdd3Args *args;
+    Int a, b, c;
+
+    args = (FxnAdd3Args *)payload[0].data;
+
+    Cache_inv (args, sizeof(FxnAdd3Args), Cache_Type_ALL, TRUE);
+
+    a = args->a;
+    b = args->b;
+    c = args->c;
+
+#if CHATTER
+    System_printf("fxnAdd3: a=%d, b=%d, c=%d\n", a, b, c);
+#endif
+
+    return(a + b + c);
+}
+
+/*
+ *  ======== fxnAddX ========
+ */
+Int32 fxnAddX(UInt32 size, UInt32 *data)
+{
+    struct OmapRpc_Parameter *payload = (struct OmapRpc_Parameter *)data;
+    FxnAddXArgs *args;
+    Int num, i, sum = 0;
+    Int *array;
+
+    args = (FxnAddXArgs *)payload[0].data;
+
+    Cache_inv (args, sizeof(FxnAddXArgs), Cache_Type_ALL, TRUE);
+
+    num = args->num;
+    array = args->array;
+
+    Cache_inv (array, sizeof(Int) * num, Cache_Type_ALL, TRUE);
+
+#if CHATTER
+    System_printf("fxnAddX: ");
+#endif
+    for (i = 0; i < num; i++) {
+#if CHATTER
+        System_printf(" a[%d]=%d,", i, array[i]);
+#endif
+        sum += array[i];
+    }
+
+#if CHATTER
+    System_printf(" sum=%d\n", sum);
+#endif
+
+    return(sum);
+}
+
 Void start_rpc_task()
 {
     /* Init service manager */
diff --git a/qnx/.gitignore b/qnx/.gitignore
new file mode 100644 (file)
index 0000000..000d33e
--- /dev/null
@@ -0,0 +1,13 @@
+*.map
+*.o
+*.so
+*.a
+*.pinfo
+src/tests/MessageQApp/arm/o.g.le.v7/MessageQApp_g
+src/tests/MessageQApp/arm/o.le.v7/MessageQApp
+src/tests/MessageQBench/arm/o.g.le.v7/MessageQBench_g
+src/tests/MessageQBench/arm/o.le.v7/MessageQBench
+src/tests/MessageQMulti/arm/o.g.le.v7/MessageQMulti_g
+src/tests/MessageQMulti/arm/o.le.v7/MessageQMulti
+src/tests/NameServerApp/arm/o.g.le.v7/NameServerApp_g
+src/tests/NameServerApp/arm/o.le.v7/NameServerApp
index 6c05e801af61901f7d127c22605873ce94efdb4e..1c7682921d08adcdc7d68591ce827c4242dd5c5d 100644 (file)
@@ -44,8 +44,8 @@
  *
  */
 
-#define SH_MEM_BLOCK1_START 0x9EB00000
-#define SH_MEM_BLOCK1_SIZE  0x1000000
+#define SH_MEM_BLOCK1_START 0xBA300000
+#define SH_MEM_BLOCK1_SIZE  0x5A00000
 
 #define SH_MEM_BLOCK2_START 0x9DB00000
 #define SH_MEM_BLOCK2_SIZE  0x1000000
index 3ff42eb5491606c58c813472def4275bd6bffad0..9af6aa2ee05c8f22815f5db54bce3be440f6156c 100644 (file)
@@ -236,19 +236,15 @@ extern unsigned int syslink_dsp_mem_size;
 
 #define MAX_SIZE_OVERRIDE_PARAMS 500
 
-Char Syslink_Override_Params[MAX_SIZE_OVERRIDE_PARAMS];
-/*
+/*Char Syslink_Override_Params[MAX_SIZE_OVERRIDE_PARAMS];*/
+
 String Syslink_Override_Params = "ProcMgr.proc[CORE0].mmuEnable=TRUE;"
-                                 "ProcMgr.proc[CORE0].carveoutAddr0=0x95800000;"
-                                 "ProcMgr.proc[CORE0].carveoutSize0=0xA400000;"
-                                 "ProcMgr.proc[CORE0].carveoutAddr1=0xBA300000;"
-                                 "ProcMgr.proc[CORE0].carveoutSize1=0x5A00000;"
+                                 "ProcMgr.proc[CORE0].carveoutAddr0=0xBA300000;"
+                                 "ProcMgr.proc[CORE0].carveoutSize0=0x5A00000;"
                                  "ProcMgr.proc[DSP].mmuEnable=TRUE;"
-                                 "ProcMgr.proc[DSP].carveoutAddr0=0x95000000;"
-                                 "ProcMgr.proc[DSP].carveoutSize0=0x700000;"
-                                 "ProcMgr.proc[DSP].carveoutAddr1=0xBA300000;"
-                                 "ProcMgr.proc[DSP].carveoutSize1=0x5A00000";
-*/
+                                 "ProcMgr.proc[DSP].carveoutAddr0=0xBA300000;"
+                                 "ProcMgr.proc[DSP].carveoutSize0=0x5A00000;";
+
 
 /** ============================================================================
  *  APIs.
@@ -318,7 +314,7 @@ Int32
 Platform_overrideConfig (Platform_Config * config, Ipc_Config * cfg)
 {
     Int32  status = Platform_S_SUCCESS;
-    Char   hexString[16];
+    /*Char   hexString[16];*/
 
     GT_1trace (curTrace, GT_ENTER, "Platform_overrideConfig", config);
 
@@ -338,7 +334,7 @@ Platform_overrideConfig (Platform_Config * config, Ipc_Config * cfg)
     }
     else {
 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
-
+/*
         String_cpy(Syslink_Override_Params,
                    "ProcMgr.proc[CORE0].mmuEnable=TRUE;");
         String_hexToStr(hexString, cfg->pAddr);
@@ -363,6 +359,7 @@ Platform_overrideConfig (Platform_Config * config, Ipc_Config * cfg)
                    "ProcMgr.proc[DSP].carveoutSize0=");
         String_cat(Syslink_Override_Params, hexString);
         String_cat(Syslink_Override_Params, ";");
+*/
         cfg->params = Memory_alloc(NULL,
                                    String_len(Syslink_Override_Params) + 1, 0,
                                    NULL);
index 74ec0a5c275750e19aa727604202f97c79537915..71636ff16e60e7afd2f8d01d3e5d8fc7773ad533 100644 (file)
@@ -66,7 +66,6 @@
 #include <devctl.h>
 
 /* Module headers */
-//#include <ti/ipc/omap_rpc.h>
 #include <ti/ipc/rpmsg_rpc.h>
 #include <ti/ipc/MessageQCopy.h>
 #include <_MessageQCopy.h>
@@ -204,12 +203,26 @@ typedef struct rpmsg_rpc_EventCbck_tag {
     /*!< Process Identifier for user process. */
 } rpmsg_rpc_EventCbck ;
 
+/*!
+ *  @brief  Structure of Fxn Info for reverse translations.
+ */
+typedef struct rpmsg_rpc_FxnInfo_tag {
+    List_Elem              element;
+    /*!< List element header */
+    UInt16                 msgId;
+    /*!< Unique msgId of the rpc fxn call */
+    struct rppc_function   func;
+    /*!< rpc function information. */
+} rpmsg_rpc_FxnInfo ;
+
 /*!
  *  @brief  Keeps the information related to Event.
  */
 typedef struct rpmsg_rpc_EventState_tag {
     List_Handle            bufList;
     /*!< Head of received event list. */
+    List_Handle            fxnList;
+    /*!< Head of received msg list. */
     UInt32                 pid;
     /*!< User process ID. */
     rpmsg_rpc_object *     rpc;
@@ -342,6 +355,13 @@ static void put_uBuf(rpmsg_rpc_EventPacket * uBuf)
     return;
 }
 
+/** ============================================================================
+ *  Function Prototypes
+ *  ============================================================================
+ */
+int
+_rpmsg_rpc_translate (ProcMgr_Handle handle, char *data, pid_t pid,
+                      bool reverse);
 
 /** ============================================================================
  *  Globals
@@ -365,6 +385,8 @@ static rpmsg_rpc_ModuleObject rpmsg_rpc_state =
     .run  = 0
 };
 
+static uint16_t msg_id = 0xFFFF;
+
 extern dispatch_t * syslink_dpp;
 
 
@@ -811,6 +833,7 @@ _rpmsg_rpc_attach (rpmsg_rpc_object * rpc)
     Bool                 flag     = FALSE;
     Bool                 isInit   = FALSE;
     List_Object *        bufList  = NULL;
+    List_Object *        fxnList  = NULL;
     IArg                 key      = 0;
     List_Params          listparams;
     UInt32               i;
@@ -830,12 +853,14 @@ _rpmsg_rpc_attach (rpmsg_rpc_object * rpc)
     if (isInit == FALSE) {
         List_Params_init (&listparams);
         bufList = List_create (&listparams) ;
+        fxnList = List_create (&listparams) ;
         /* Search for an available slot for user process. */
         for (i = 0 ; i < MAX_PROCESSES ; i++) {
             if (rpmsg_rpc_state.eventState [i].rpc == NULL) {
                 rpmsg_rpc_state.eventState [i].rpc = rpc;
                 rpmsg_rpc_state.eventState [i].refCount = 1;
                 rpmsg_rpc_state.eventState [i].bufList = bufList;
+                rpmsg_rpc_state.eventState [i].fxnList = fxnList;
                 flag = TRUE;
                 break;
             }
@@ -858,11 +883,14 @@ _rpmsg_rpc_attach (rpmsg_rpc_object * rpc)
             if (bufList != NULL) {
                 List_delete (&bufList);
             }
+            if (fxnList != NULL) {
+                List_delete (&fxnList);
+            }
         }
     }
     IGateProvider_leave (rpmsg_rpc_state.gateHandle, key);
 
-    GT_1trace (curTrace, GT_LEAVE, "rpmsgDrv_attach", status);
+    GT_1trace (curTrace, GT_LEAVE, "_rpmsg_rpc_attach", status);
 
     /*! @retval Notify_S_SUCCESS Operation successfully completed. */
     return status ;
@@ -884,6 +912,7 @@ Int
 _rpmsg_rpc_addBufByPid (rpmsg_rpc_object *rpc,
                         UInt32             src,
                         UInt32             pid,
+                        UInt16             msgId,
                         void *             data,
                         UInt32             len)
 {
@@ -894,6 +923,8 @@ _rpmsg_rpc_addBufByPid (rpmsg_rpc_object *rpc,
     UInt32                  i;
     WaitingReaders_t *item;
     MsgList_t *msgItem;
+    List_Elem * elem = NULL;
+    List_Elem * temp = NULL;
 
     GT_5trace (curTrace,
                GT_ENTER,
@@ -949,6 +980,23 @@ _rpmsg_rpc_addBufByPid (rpmsg_rpc_object *rpc,
         }
         else {
 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+            key = IGateProvider_enter (rpmsg_rpc_state.gateHandle);
+            List_traverse_safe(elem, temp, rpmsg_rpc_state.eventState [i].fxnList) {
+                if (((rpmsg_rpc_FxnInfo *)elem)->msgId == msgId) {
+                    List_remove(rpmsg_rpc_state.eventState [i].fxnList, elem);
+                    break;
+                }
+            }
+            IGateProvider_leave (rpmsg_rpc_state.gateHandle, key);
+
+            if (elem != (List_Elem *)rpmsg_rpc_state.eventState [i].fxnList) {
+                struct rppc_function * function;
+                function = &(((rpmsg_rpc_FxnInfo *)elem)->func);
+                _rpmsg_rpc_translate(NULL, (char *)function, pid, true);
+                Memory_free(NULL, elem, sizeof(rpmsg_rpc_FxnInfo) +\
+                            RPPC_TRANS_SIZE(function->num_translations));
+            }
+
             List_elemClear (&(uBuf->element));
             GT_assert (curTrace,
                        (rpmsg_rpc_state.eventState [i].bufList != NULL));
@@ -1112,6 +1160,7 @@ _rpmsg_rpc_cb (MessageQCopy_Handle handle, void * data, int len, void * priv,
             _rpmsg_rpc_addBufByPid (rpc,
                                     src,
                                     rpc->pid,
+                                    packet->msg_id,
                                     &packet->fxn_id,
                                     sizeof(packet->fxn_id) + sizeof(packet->result));
 #if !defined(SYSLINK_BUILD_OPTIMIZE)
@@ -1242,6 +1291,7 @@ _rpmsg_rpc_detach (rpmsg_rpc_object * rpc)
     Int32                tmpStatus = EOK;
     Bool                 flag      = FALSE;
     List_Object *        bufList   = NULL;
+    List_Object *        fxnList   = NULL;
     UInt32               i;
     IArg                 key;
     MsgList_t          * item;
@@ -1279,6 +1329,11 @@ _rpmsg_rpc_detach (rpmsg_rpc_object * rpc)
 
         rpmsg_rpc_state.eventState [i].bufList = NULL;
 
+        /* Store in local variable to delete outside lock. */
+        fxnList = rpmsg_rpc_state.eventState [i].fxnList;
+
+        rpmsg_rpc_state.eventState [i].fxnList = NULL;
+
         IGateProvider_leave (rpmsg_rpc_state.gateHandle, key);
     }
 
@@ -1335,6 +1390,16 @@ _rpmsg_rpc_detach (rpmsg_rpc_object * rpc)
             /* Last client being unregistered with Notify module. */
             List_delete (&bufList);
         }
+        if (fxnList != NULL) {
+            key = IGateProvider_enter (rpmsg_rpc_state.gateHandle);
+            rpmsg_rpc_FxnInfo * fxnInfo = NULL;
+            while ((fxnInfo = (rpmsg_rpc_FxnInfo *)List_dequeue (fxnList))) {
+                Memory_free (NULL, fxnInfo, sizeof(rpmsg_rpc_FxnInfo) +\
+                             RPPC_TRANS_SIZE(fxnInfo->func.num_translations));
+            }
+            IGateProvider_leave (rpmsg_rpc_state.gateHandle, key);
+            List_delete (&fxnList);
+        }
 
 #if !defined(SYSLINK_BUILD_OPTIMIZE)
         if ((tmpStatus < 0) && (status >= 0)) {
@@ -1610,7 +1675,7 @@ _rpmsg_rpc_pa2da(ProcMgr_Handle handle, uint32_t pa)
 }
 
 int
-_rpmsg_rpc_translate(ProcMgr_Handle handle, char *data, uint32_t bytes, pid_t pid)
+_rpmsg_rpc_translate(ProcMgr_Handle handle, char *data, pid_t pid, bool reverse)
 {
     int status = EOK;
     struct rppc_function * function = NULL;
@@ -1623,6 +1688,7 @@ _rpmsg_rpc_translate(ProcMgr_Handle handle, char *data, uint32_t bytes, pid_t pi
     uintptr_t ptr;
     void * vptr[RPPC_MAX_PARAMETERS];
     uint32_t idx = 0;
+    uint32_t param_offset = 0;
 
     function = (struct rppc_function *)data;
     memset(vptr, 0, sizeof(void *) * RPPC_MAX_PARAMETERS);
@@ -1635,7 +1701,8 @@ _rpmsg_rpc_translate(ProcMgr_Handle handle, char *data, uint32_t bytes, pid_t pi
             status = -EINVAL;
             break;
         }
-        if (translation[i].offset + sizeof(uint32_t) > function->params[idx].size) {
+        param_offset = function->params[idx].data - function->params[idx].base;
+        if (translation[i].offset - param_offset + sizeof(uint32_t) > function->params[idx].size) {
             status = -EINVAL;
             break;
         }
@@ -1661,27 +1728,34 @@ _rpmsg_rpc_translate(ProcMgr_Handle handle, char *data, uint32_t bytes, pid_t pi
             }
         }
         /* Get physical address of the contents */
-        ptr = (uint32_t)vptr[idx] + translation[i].offset;
-        status = mem_offset64_peer(pid, *(uint32_t *)ptr, sizeof(uint32_t),
-                                   &phys_addr, &phys_len);
-        if (status >= 0 && phys_len == sizeof(uint32_t)) {
-            /* translate pa2da */
-            if ((ipu_addr =
-                    _rpmsg_rpc_pa2da(handle, (uint32_t)phys_addr)) != 0)
-                /* update vptr contents */
-                *(uint32_t *)ptr = ipu_addr;
+        ptr = (uint32_t)vptr[idx] + translation[i].offset - param_offset;
+        if (reverse) {
+            *(uint32_t *)ptr = translation[i].base;
+        }
+        else {
+            translation[i].base = *(uint32_t *)ptr;
+            status = mem_offset64_peer(pid, *(uint32_t *)ptr, sizeof(uint32_t),
+                                       &phys_addr, &phys_len);
+            if (status >= 0 && phys_len == sizeof(uint32_t)) {
+                /* translate pa2da */
+                if ((ipu_addr =
+                        _rpmsg_rpc_pa2da(handle, (uint32_t)phys_addr)) != 0)
+                    /* update vptr contents */
+                    *(uint32_t *)ptr = ipu_addr;
+                else {
+                    status = -EINVAL;
+                    break;
+                }
+            }
             else {
                 status = -EINVAL;
                 break;
             }
         }
-        else {
-            status = -EINVAL;
-            break;
-        }
     }
 
-    for (i = 0; i < function->num_params && status >= 0; i++) {
+    /* No need to do this for reverse translations */
+    for (i = 0; i < function->num_params && status >= 0 && !reverse; i++) {
         if (function->params[i].type == RPPC_PARAM_TYPE_PTR) {
             if (paddr[i]) {
                 phys_addr = paddr[i];
@@ -1690,7 +1764,8 @@ _rpmsg_rpc_translate(ProcMgr_Handle handle, char *data, uint32_t bytes, pid_t pi
                 /* translate the param pointer */
                 status = mem_offset64_peer(pid,
                                            (uintptr_t)(function->params[i].data),
-                                           function->params[i].size, &phys_addr, &phys_len);
+                                           function->params[i].size, &phys_addr,
+                                           &phys_len);
             }
             if (status >= 0) {
                 if ((ipu_addr =
@@ -1748,6 +1823,9 @@ rpmsg_rpc_write(resmgr_context_t *ctp, io_write_t *msg, RESMGR_OCB_T *io_ocb)
     struct rppc_function *function = NULL;
     char usr_msg[MessageQCopy_BUFSIZE];
     int i = 0;
+    rpmsg_rpc_EventState * event_state = NULL;
+    rpmsg_rpc_FxnInfo * fxn_info = NULL;
+    IArg key = 0;
 
     if ((status = iofunc_write_verify(ctp, msg, io_ocb, NULL)) != EOK) {
         return (status);
@@ -1760,6 +1838,16 @@ rpmsg_rpc_write(resmgr_context_t *ctp, io_write_t *msg, RESMGR_OCB_T *io_ocb)
     }
     _IO_SET_WRITE_NBYTES (ctp, bytes);
 
+    for (i = 0 ; i < MAX_PROCESSES ; i++) {
+        if (rpmsg_rpc_state.eventState [i].rpc == rpc) {
+            break;
+        }
+    }
+    if (i == MAX_PROCESSES) {
+        return EINVAL;
+    }
+    event_state = &rpmsg_rpc_state.eventState[i];
+
     msg_hdr = (struct rppc_msg_header *)buf;
     packet = (struct rppc_packet *)((UInt32)msg_hdr + sizeof(struct rppc_msg_header));
 
@@ -1772,9 +1860,7 @@ rpmsg_rpc_write(resmgr_context_t *ctp, io_write_t *msg, RESMGR_OCB_T *io_ocb)
     }
     function = (struct rppc_function *)usr_msg;
 
-    if (bytes < sizeof(struct rppc_function) +
-        (function->num_translations * \
-         sizeof(struct rppc_param_translation))) {
+    if (bytes < RPPC_PARAM_SIZE(function->num_translations)) {
          return (EINVAL);
     }
 
@@ -1783,9 +1869,19 @@ rpmsg_rpc_write(resmgr_context_t *ctp, io_write_t *msg, RESMGR_OCB_T *io_ocb)
         return (EINVAL);
     }
 
-    status = _rpmsg_rpc_translate(rpc->conn->procH, (char *)function, bytes,
-                                  ctp->info.pid);
+    /* store the fxn info for use with reverse translation */
+    fxn_info = Memory_alloc (NULL, sizeof(rpmsg_rpc_FxnInfo) +\
+                             RPPC_TRANS_SIZE(function->num_translations),
+                             0, NULL);
+    List_elemClear(&(fxn_info->element));
+    Memory_copy (&(fxn_info->func), function,
+                 RPPC_PARAM_SIZE(function->num_translations));
+
+    status = _rpmsg_rpc_translate(rpc->conn->procH, (char *)function,
+                                  ctp->info.pid, false);
     if (status < 0) {
+        Memory_free(NULL, fxn_info, sizeof(rpmsg_rpc_FxnInfo) +\
+                    RPPC_TRANS_SIZE(function->num_translations));
         return -status;
     }
 
@@ -1794,7 +1890,7 @@ rpmsg_rpc_write(resmgr_context_t *ctp, io_write_t *msg, RESMGR_OCB_T *io_ocb)
 
     /* initialize the packet structure */
     packet->desc = RPPC_DESC_EXEC_SYNC;
-    packet->msg_id = 0;
+    packet->msg_id = msg_id == 0xFFFF ? msg_id = 1 : ++(msg_id);
     packet->flags = (0x8000);//OMAPRPC_POOLID_DEFAULT;
     packet->fxn_id = RPPC_SET_FXN_IDX(function->fxn_id);
     packet->result = 0;
@@ -1807,10 +1903,21 @@ rpmsg_rpc_write(resmgr_context_t *ctp, io_write_t *msg, RESMGR_OCB_T *io_ocb)
     }
     msg_hdr->msg_len += packet->data_size;
 
+    fxn_info->msgId = packet->msg_id;
+    key = IGateProvider_enter (rpmsg_rpc_state.gateHandle);
+    List_enqueue(event_state->fxnList, &(fxn_info->element));
+    IGateProvider_leave (rpmsg_rpc_state.gateHandle, key);
+
     status = MessageQCopy_send(rpc->conn->procId, MultiProc_self(),
-                               rpc->remoteAddr, rpc->addr, buf,
-                               msg_hdr->msg_len + sizeof(struct rppc_msg_header), TRUE);
+                              rpc->remoteAddr, rpc->addr, buf,
+                              msg_hdr->msg_len + sizeof(struct rppc_msg_header),
+                              TRUE);
     if (status < 0) {
+        key = IGateProvider_enter (rpmsg_rpc_state.gateHandle);
+        List_remove(event_state->fxnList, &(fxn_info->element));
+        IGateProvider_leave (rpmsg_rpc_state.gateHandle, key);
+        Memory_free(NULL, fxn_info, sizeof(rpmsg_rpc_FxnInfo) +\
+                    RPPC_TRANS_SIZE(function->num_translations));
         return (EIO);
     }
 
index 12c1c952262df00e2676cf844f7e26dbc1f036f6..e7cc922b72da537ae0919dfed655379303f01d42 100644 (file)
@@ -56,6 +56,7 @@
 extern "C" {
 #endif
 
+#include <ti/ipc/rpmsg_rpc.h>
 
 /* =============================================================================
  *  Macros and types
@@ -112,6 +113,11 @@ struct rppc_channel_info {
     UInt32 num_funcs;      /**< The number of functions supported on this endpoint */
 };
 
+#define RPPC_TRANS_SIZE(num)   (sizeof(struct rppc_param_translation) * num)
+
+#define RPPC_PARAM_SIZE(num)   (sizeof(struct rppc_function) +\
+                                RPPC_TRANS_SIZE(num))
+
 /*!
  *  @brief  Max number of user processes supported
  */
index 0fad850a334f8cfc3692854dd84b378cb7201fd5..f1f7df4ee8e49c9e905b5091430fd652e5b5ce95 100644 (file)
@@ -1,7 +1,7 @@
 rpmsg-rpc Stress Test
 
 Syntax:
-  rpmsg-rpc-stress -t <test_no> [-c <id>] [-x <num>] [-l <num>]
+  rpmsg-rpc-stress -t <test_no> [-c <id>] [-f <func_id>] [-x <num>] [-l <num>]
 
   Where:
     -t <test_no>    Test number to be run. Valid values are 1-3.
@@ -10,8 +10,12 @@ Syntax:
                     3: Run select test
     -c <id>         Core ID with which to communicate.
                     0: IPU CORE0 (default)
-                    1: IPU CORE1
+                    1: IPU CORE1 or IPU SMP
                     2: DSP
+    -f <func_id>    1: FxnTriple (default)
+                    2: FxnAdd
+                    3: FxnAdd3
+                    4: FxnAddX
     -x <num>        For tests 1 and 3, the number of RPMSGRPC ServiceMgr instances.
                     Default is 1.
     -l <num>        For test 2, the number of threads communicating with the
index abf41e9580786df03d25a84650342b991c0cff7b..23ca57baca4b0faa9deaecdc943c81043fab67e8 100644 (file)
 #include <time.h>
 #include <stdbool.h>
 #include <semaphore.h>
+#include <dlfcn.h>
 
 #include "ti/ipc/rpmsg_rpc.h"
+#include "ti/shmemallocator/SharedMemoryAllocatorUsr.h"
 
 
 typedef struct {
     int a;
-} fxn_triple_args;
+    int b;
+    int c;
+} fxn_add3_args;
+
+typedef struct {
+    int num;
+    int *array;
+} fxn_addx_args;
 
 /* Note: Set bit 31 to indicate static function indicies:
  * This function order will be hardcoded on BIOS side, hence preconfigured:
  */
-#define FXN_IDX_FXNTRIPLE            (1 | 0x80000000)
+enum {
+    FXN_IDX_FXNTRIPLE = 1,
+    FXN_IDX_FXNADD,
+    FXN_IDX_FXNADD3,
+    FXN_IDX_FXNADDX,
+    FXN_IDX_MAX
+};
 
 #define NUM_ITERATIONS               20
 
 static int test_status = 0;
 static bool runTest = true;
+static int testFunc = FXN_IDX_FXNTRIPLE;
 
 int exec_cmd(int fd, char *msg, size_t len, char *reply_msg, int *reply_len)
 {
@@ -127,6 +143,7 @@ typedef struct test_exec_args {
     int test_num;
     sem_t * sem;
     int thread_num;
+    int func_idx;
 } test_exec_args;
 
 static pthread_t * clientThreads = NULL;
@@ -135,6 +152,53 @@ static char **clientPackets = NULL;
 static bool *readMsg = NULL;
 static int *fds;
 
+void *sharedmemalloc_lib = NULL;
+int (*sharedmem_alloc)(int size, shm_buf *buf);
+int (*sharedmem_free)(shm_buf *buf);
+
+int deinit_sharedmem_funcs(void)
+{
+    int ret = 0;
+
+    if (sharedmemalloc_lib)
+        dlclose(sharedmemalloc_lib);
+    sharedmemalloc_lib = NULL;
+
+    return ret;
+}
+
+int init_sharedmem_funcs()
+{
+    int ret = 0;
+
+    if (sharedmemalloc_lib == NULL) {
+        sharedmemalloc_lib = dlopen("libsharedmemallocator.so",
+                                    RTLD_NOW | RTLD_GLOBAL);
+        if (sharedmemalloc_lib == NULL) {
+            perror("init_sharedmem_funcs: Error opening shared lib");
+            ret = -1;
+        }
+        else {
+            sharedmem_alloc = dlsym(sharedmemalloc_lib, "SHM_alloc");
+            if (sharedmem_alloc == NULL) {
+                perror("init_sharedmem_funcs: Error getting shared lib sym");
+                ret = -1;
+            }
+            else {
+                sharedmem_free = dlsym(sharedmemalloc_lib, "SHM_release");
+                if (sharedmem_free == NULL) {
+                    perror("init_sharedmem_funcs: Error getting shared lib sym");
+                    ret = -1;
+                }
+            }
+        }
+    }
+    if (ret < 0) {
+        deinit_sharedmem_funcs();
+    }
+    return ret;
+}
+
 void * test_exec_call(void * arg)
 {
     int               i;
@@ -146,15 +210,85 @@ void * test_exec_call(void * arg)
     int               fd = args->fd;
     struct rppc_function *function;
     struct rppc_function_return *returned;
+    shm_buf           buf, buf2;
+    void              *ptr = NULL, *ptr2 = NULL;
 
     for (i = args->start_num; i < args->start_num + NUM_ITERATIONS; i++) {
         function = (struct rppc_function *)packet_buf;
-        function->fxn_id = FXN_IDX_FXNTRIPLE;
-        function->num_params = 1;
-        function->params[0].type = RPPC_PARAM_TYPE_ATOMIC;
-        function->params[0].size = sizeof(int);
-        function->params[0].data = i;
-        function->num_translations = 0;
+        function->fxn_id = args->func_idx;
+        switch (function->fxn_id) {
+            case FXN_IDX_FXNTRIPLE:
+                function->num_params = 1;
+                function->params[0].type = RPPC_PARAM_TYPE_ATOMIC;
+                function->params[0].size = sizeof(int);
+                function->params[0].data = i;
+                function->num_translations = 0;
+                break;
+            case FXN_IDX_FXNADD:
+                function->num_params = 2;
+                function->params[0].type = RPPC_PARAM_TYPE_ATOMIC;
+                function->params[0].size = sizeof(int);
+                function->params[0].data = i;
+                function->params[1].type = RPPC_PARAM_TYPE_ATOMIC;
+                function->params[1].size = sizeof(int);
+                function->params[1].data = i+1;
+                function->num_translations = 0;
+                break;
+            case FXN_IDX_FXNADD3:
+                if (init_sharedmem_funcs() < 0)
+                    test_status = -1;
+                else {
+                    if ((*sharedmem_alloc)(sizeof(fxn_add3_args), &buf) < 0) {
+                        test_status = -1;
+                    }
+                    else {
+                        ptr = (fxn_add3_args *)(buf.vir_addr);
+                        ((fxn_add3_args *)ptr)->a = i;
+                        ((fxn_add3_args *)ptr)->b = i+1;
+                        ((fxn_add3_args *)ptr)->c = i+2;
+                        function->num_params = 1;
+                        function->params[0].type = RPPC_PARAM_TYPE_PTR;
+                        function->params[0].size = sizeof(fxn_add3_args);
+                        function->params[0].data = (size_t)ptr;
+                        function->params[0].base = (size_t)ptr;
+                        function->num_translations = 0;
+                    }
+                }
+                break;
+            case FXN_IDX_FXNADDX:
+                if (init_sharedmem_funcs() < 0)
+                    test_status = -1;
+                else {
+                    if ((*sharedmem_alloc)(sizeof(fxn_addx_args), &buf) < 0) {
+                        test_status = -1;
+                    }
+                    else if ((*sharedmem_alloc)(sizeof(int) * 3, &buf2) < 0) {
+                        test_status = -1;
+                    }
+                    else {
+                        ptr = (fxn_addx_args *)(buf.vir_addr);
+                        ptr2 = (int *)(buf2.vir_addr);
+                        ((fxn_addx_args *)ptr)->num = 3;
+                        ((fxn_addx_args *)ptr)->array = ptr2;
+                        ((int *)ptr2)[0] = i;
+                        ((int *)ptr2)[1] = i+1;
+                        ((int *)ptr2)[2] = i+2;
+                        function->num_params = 1;
+                        function->params[0].type = RPPC_PARAM_TYPE_PTR;
+                        function->params[0].size = sizeof(fxn_addx_args);
+                        function->params[0].data = (size_t)ptr;
+                        function->params[0].base = (size_t)ptr;
+                        function->num_translations = 1;
+                        function->translations[0].index = 0;
+                        function->translations[0].offset = (int)&(((fxn_addx_args *)ptr)->array) - (int)ptr;
+                        function->translations[0].base = ((fxn_addx_args *)ptr)->array;
+                    }
+                }
+                break;
+        }
+
+        if (test_status == -1)
+            break;
 
         returned = (struct rppc_function_return *)return_buf;
 
@@ -178,17 +312,79 @@ void * test_exec_call(void * arg)
             memcpy(return_buf, clientPackets[args->thread_num], 512);
             readMsg[args->thread_num] = true;
         }
-       if (i * 3 != returned->status) {
-           printf ("rpc_stress: "
-                   "called fxnTriple(%d), result = %d, expected %d\n",
-                        function->params[0].data, returned->status, i * 3);
-           test_status = -1;
-           break;
-       }
-       else {
-           printf ("rpc_stress: called fxnTriple(%d), result = %d\n",
-                        function->params[0].data, returned->status);
-       }
+        switch (function->fxn_id) {
+            case FXN_IDX_FXNTRIPLE:
+                if (i * 3 != returned->status) {
+                    printf ("rpc_stress: "
+                            "called fxnTriple(%d), result = %d, expected %d\n",
+                            function->params[0].data, returned->status, i * 3);
+                    test_status = -1;
+                }
+                else {
+                    printf ("rpc_stress: called fxnTriple(%d), result = %d\n",
+                            function->params[0].data, returned->status);
+                }
+                break;
+            case FXN_IDX_FXNADD:
+                if (i + (i+1) != returned->status) {
+                    printf ("rpc_stress: "
+                            "called fxnAdd(%d,%d), result = %d, expected %d\n",
+                            function->params[0].data, function->params[1].data,
+                            returned->status, i + (i+1));
+                    test_status = -1;
+                }
+                else {
+                    printf ("rpc_stress: called fxnAdd(%d,%d), result = %d\n",
+                            function->params[0].data, function->params[1].data,
+                            returned->status);
+                }
+                break;
+            case FXN_IDX_FXNADD3:
+                if (i + (i+1) + (i+2) != returned->status) {
+                    printf ("rpc_stress: "
+                            "called fxnAdd3(%d,%d,%d), result = %d, expected %d\n",
+                            ((fxn_add3_args *)ptr)->a,
+                            ((fxn_add3_args *)ptr)->b,
+                            ((fxn_add3_args *)ptr)->c, returned->status,
+                            i + (i+1) + (i+2));
+                    test_status = -1;
+                }
+                else {
+                    printf ("rpc_stress: called fxnAdd3(%d,%d,%d), result = %d\n",
+                            ((fxn_add3_args *)ptr)->a,
+                            ((fxn_add3_args *)ptr)->b,
+                            ((fxn_add3_args *)ptr)->c, returned->status);
+                }
+                (*sharedmem_free)(&buf);
+                break;
+            case FXN_IDX_FXNADDX:
+                if (i + (i+1) + (i+2) != returned->status) {
+                    printf ("rpc_stress: "
+                            "called fxnAddX(%d,%d,%d), result = %d, expected %d\n",
+                            ((int *)ptr2)[0], ((int *)ptr2)[1],
+                            ((int *)ptr2)[2], returned->status,
+                            i + (i+1) + (i+2));
+                    test_status = -1;
+                }
+                else {
+                    /* Check that reverse address translation is working */
+                    if (((fxn_addx_args *)ptr)->array != ptr2) {
+                        printf("rpc_stress: reverse addr translation failed, "
+                               "addr = 0x%x expected 0x%x\n",
+                               ((fxn_addx_args *)ptr)->array, ptr2);
+                        test_status = -1;
+                    }
+                    printf ("rpc_stress: called fxnAddX(%d,%d,%d), result = %d\n",
+                            ((int *)ptr2)[0], ((int *)ptr2)[1],
+                            ((int *)ptr2)[2], returned->status);
+                }
+                (*sharedmem_free)(&buf);
+                (*sharedmem_free)(&buf2);
+                break;
+        }
+        if (test_status == -1) {
+            break;
+        }
     }
 
     return NULL;
@@ -265,7 +461,20 @@ void * test_read_thread (void * arg)
             break;
 
         /* Decode reply: */
-        packet_id = ((rtn_packet->status / 3) - 1) / NUM_ITERATIONS;
+        switch (testFunc) {
+            case FXN_IDX_FXNTRIPLE:
+                packet_id = ((rtn_packet->status / 3) - 1) / NUM_ITERATIONS;
+                break;
+            case FXN_IDX_FXNADD:
+                packet_id = (((rtn_packet->status - 1) / 2) - 1) / NUM_ITERATIONS;
+                break;
+            case FXN_IDX_FXNADD3:
+                packet_id = (((rtn_packet->status - 3) / 3) - 1) / NUM_ITERATIONS;
+                break;
+            case FXN_IDX_FXNADDX:
+                packet_id = (((rtn_packet->status - 3) / 3) - 1) / NUM_ITERATIONS;
+                break;
+        }
         while (readMsg[packet_id] == false) {
             sleep(1);
         }
@@ -276,7 +485,7 @@ void * test_read_thread (void * arg)
     return NULL;
 }
 
-int test_rpc_stress_select(int core_id, int num_comps)
+int test_rpc_stress_select(int core_id, int num_comps, int func_idx)
 {
     int ret = 0;
     int i = 0, j = 0;
@@ -426,6 +635,7 @@ int test_rpc_stress_select(int core_id, int num_comps)
         args[i].test_num = 3;
         args[i].sem = &clientSems[i];
         args[i].thread_num = i;
+        args[i].func_idx = func_idx;
         readMsg[i] = true;
         ret = pthread_create(&clientThreads[i], NULL, test_exec_call,
                              (void *)&args[i]);
@@ -485,7 +695,7 @@ int test_rpc_stress_select(int core_id, int num_comps)
     return ret;
 }
 
-int test_rpc_stress_multi_threads(int core_id, int num_threads)
+int test_rpc_stress_multi_threads(int core_id, int num_threads, int func_idx)
 {
     int ret = 0;
     int i = 0, j = 0;
@@ -599,6 +809,7 @@ int test_rpc_stress_multi_threads(int core_id, int num_threads)
         args[i].test_num = 2;
         args[i].sem = &clientSems[i];
         args[i].thread_num = i;
+        args[i].func_idx = func_idx;
         readMsg[i] = true;
         ret = pthread_create(&clientThreads[i], NULL, test_exec_call,
                              (void *)&args[i]);
@@ -655,7 +866,7 @@ int test_rpc_stress_multi_threads(int core_id, int num_threads)
     return ret;
 }
 
-int test_rpc_stress_multi_srvmgr(int core_id, int num_comps)
+int test_rpc_stress_multi_srvmgr(int core_id, int num_comps, int func_idx)
 {
     int ret = 0;
     int i = 0, j = 0;
@@ -731,6 +942,7 @@ int test_rpc_stress_multi_srvmgr(int core_id, int num_comps)
         args[i].test_num = 1;
         args[i].sem = NULL;
         args[i].thread_num = i;
+        args[i].func_idx = func_idx;
         ret = pthread_create(&clientThreads[i], NULL, test_exec_call,
                              (void *)&args[i]);
         if (ret < 0) {
@@ -768,11 +980,12 @@ int main(int argc, char *argv[])
     int core_id = 0;
     int num_comps = 1;
     int num_threads = 1;
+    int func_idx = 1;
     int c;
 
     while (1)
     {
-        c = getopt (argc, argv, "t:c:x:l:");
+        c = getopt (argc, argv, "t:c:x:l:f:");
         if (c == -1)
             break;
 
@@ -790,6 +1003,9 @@ int main(int argc, char *argv[])
         case 'l':
             num_threads = atoi(optarg);
             break;
+        case 'f':
+            func_idx = atoi(optarg);
+            break;
         default:
             printf ("Unrecognized argument\n");
         }
@@ -800,6 +1016,12 @@ int main(int argc, char *argv[])
         return 1;
     }
 
+    if (func_idx < FXN_IDX_FXNTRIPLE || func_idx >= FXN_IDX_MAX) {
+        printf("Invalid function index\n");
+        return 1;
+    }
+    testFunc = func_idx;
+
     switch (test_id) {
         case 1:
             /* multiple threads each with an RPMSG-RPC ServiceMgr instance */
@@ -811,7 +1033,7 @@ int main(int argc, char *argv[])
                 printf("Invalid num comps id\n");
                 return 1;
             }
-            ret = test_rpc_stress_multi_srvmgr(core_id, num_comps);
+            ret = test_rpc_stress_multi_srvmgr(core_id, num_comps, func_idx);
             break;
         case 2:
             /* Multiple threads, 1 RPMSG-RPC ServiceMgr instances */
@@ -823,7 +1045,7 @@ int main(int argc, char *argv[])
                 printf("Invalid num threads\n");
                 return 1;
             }
-            ret = test_rpc_stress_multi_threads(core_id, num_threads);
+            ret = test_rpc_stress_multi_threads(core_id, num_threads, func_idx);
             break;
         case 3:
             /* 1 thread using multiple RPMSG-RPC ServiceMgr instances */
@@ -835,7 +1057,7 @@ int main(int argc, char *argv[])
                 printf("Invalid num comps id\n");
                 return 1;
             }
-            ret = test_rpc_stress_select(core_id, num_comps);
+            ret = test_rpc_stress_select(core_id, num_comps, func_idx);
             break;
         default:
             break;