Initial rpmsgrpc merge from Suman's Mar 11 drop.
authorRamsey Harris <ramsey@ti.com>
Fri, 15 Mar 2013 04:00:30 +0000 (21:00 -0700)
committerRamsey Harris <ramsey@ti.com>
Mon, 18 Mar 2013 17:45:03 +0000 (10:45 -0700)
Merged in Suman's changes. Fixed build errors. Added open/close
calls to MmRpc.c. Minor fix up for check-in.

16 files changed:
packages/ti/ipc/mm/MmRpc.c
packages/ti/ipc/rpmsg/NameMap.c
packages/ti/ipc/rpmsg/NameMap.h
packages/ti/ipc/tests/package.bld
packages/ti/ipc/tests/ping_rpmsg.c
packages/ti/ipc/tests/ping_tasks.c
packages/ti/ipc/tests/rpc_task.c [new file with mode: 0644]
packages/ti/ipc/tests/test_omx.c
packages/ti/ipc/tests/test_omx_ipu_omap5.cfg
packages/ti/ipc/transports/TransportVirtio.c
packages/ti/srvmgr/omaprpc/OmapRpc.c [new file with mode: 0644]
packages/ti/srvmgr/omaprpc/OmapRpc.h [new file with mode: 0644]
packages/ti/srvmgr/omaprpc/package.bld [new file with mode: 0644]
packages/ti/srvmgr/omaprpc/package.xdc [new file with mode: 0644]
packages/ti/srvmgr/omaprpc/package.xs [new file with mode: 0644]
packages/ti/srvmgr/omx/OmxSrvMgr.c

index 7ec3956f6d86e06a7206ce27d4cfbf12f9159eae..12d2425cc4204360a25e4ccf60a8dd8aa3612669 100644 (file)
  *  ======== MmRpc.c ========
  */
 
+#include <stdio.h>
 #include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
 
 #include "MmRpc.h"
 
@@ -42,7 +47,7 @@
  *  ======== MmRpc_Object ========
  */
 typedef struct {
-    int         reserved;
+    int         fd;             /* device file descriptor */
 } MmRpc_Object;
 
 /*
@@ -62,6 +67,8 @@ MmRpc_Handle MmRpc_create(const char *proc, const char *service,
     int                 status = MmRpc_S_SUCCESS;
     MmRpc_Object *      obj;
 
+    printf("MmRpc_create: -->\n");
+
     /* allocate the instance object */
     obj = (MmRpc_Object *)calloc(1, sizeof(MmRpc_Object));
 
@@ -70,7 +77,26 @@ MmRpc_Handle MmRpc_create(const char *proc, const char *service,
         goto leave;
     }
 
+    /* open the driver */
+    obj->fd = open("/dev/rpc_example", O_RDWR);
+
+    if (obj->fd < 0) {
+        printf("MmRpc_create: Error: open failed\n");
+        status = MmRpc_E_FAIL;
+        goto leave;
+    }
+
 leave:
+    if (status < 0) {
+        if ((obj != NULL) && (obj->fd >= 0)) {
+            close(obj->fd);
+        }
+        if (obj != NULL) {
+            free(obj);
+        }
+    }
+
+    printf("MmRpc_create: <--\n");
     return((MmRpc_Handle)obj);
 }
 
@@ -80,10 +106,20 @@ leave:
 int MmRpc_delete(MmRpc_Handle *handlePtr)
 {
     int status = MmRpc_S_SUCCESS;
+    MmRpc_Object *obj;
+
+    printf("MmRpc_delete: -->\n");
+    obj = (MmRpc_Object *)(*handlePtr);
+
+    /* close the device */
+    if ((obj != NULL) && (obj->fd >= 0)) {
+        close(obj->fd);
+    }
 
     /* free the instance object */
     free((void *)(*handlePtr));
     *handlePtr = NULL;
 
+    printf("MmRpc_delete: <--\n");
     return(status);
 }
index 600e746ed2d6f33eb6e702c7174351d0c5d8cde6..7bc4f9e0259a24d95555bf29a17fd5381ea29cc6 100644 (file)
@@ -44,6 +44,7 @@ typedef unsigned int u32;
 
 struct rpmsg_ns_msg {
     char name[RPMSG_NAME_SIZE]; /* name of service including terminal '\0' */
+    char desc[RPMSG_NAME_SIZE]; /* description of service including '\0' */
     u32 addr;                   /* address of the service */
     u32 flags;                  /* see below */
 } __packed;
@@ -53,13 +54,16 @@ enum rpmsg_ns_flags {
     RPMSG_NS_DESTROY = 1
 };
 
-static void sendMessage(Char * name, UInt32 port, enum rpmsg_ns_flags flags)
+static void
+sendMessage(Char * name, Char *desc, UInt32 port, enum rpmsg_ns_flags flags)
 {
     struct rpmsg_ns_msg nsMsg;
     Int s;
 
     strncpy(nsMsg.name, name, (RPMSG_NAME_SIZE - 1));
     nsMsg.name[RPMSG_NAME_SIZE-1] = '\0';
+    strncpy(nsMsg.desc, desc, (RPMSG_NAME_SIZE - 1));
+    nsMsg.desc[RPMSG_NAME_SIZE-1] = '\0';
     nsMsg.addr = port;
     nsMsg.flags = flags;
 
@@ -71,14 +75,16 @@ static void sendMessage(Char * name, UInt32 port, enum rpmsg_ns_flags flags)
     }
 }
 
-void NameMap_register(Char * name, UInt32 port)
+void NameMap_register(Char * name, Char * desc, UInt32 port)
 {
-    System_printf("registering %s service on %d with HOST\n", name, port);
-    sendMessage(name, port, RPMSG_NS_CREATE);
+    System_printf("registering %s:%s service on %d with HOST\n", name, desc,
+                                                                 port);
+    sendMessage(name, desc, port, RPMSG_NS_CREATE);
 }
 
-void NameMap_unregister(Char * name, UInt32 port)
+void NameMap_unregister(Char * name, Char * desc, UInt32 port)
 {
-    System_printf("un-registering %s service on %d with HOST\n", name, port);
-    sendMessage(name, port, RPMSG_NS_DESTROY);
+    System_printf("un-registering %s:%s service on %d with HOST\n", name, desc,
+                                                                    port);
+    sendMessage(name, desc, port, RPMSG_NS_DESTROY);
 }
index 66d6b81f4ee8552b20a9f024742062798ce4489b..bdae1d61d4cfdd219b48b982dc566a175481eece 100644 (file)
@@ -33,7 +33,7 @@
 #ifndef _NAMEMAP_H_
 #define _NAMEMAP_H_
 
-extern void NameMap_register(Char * name, UInt32 value);
-extern void NameMap_unregister(Char * name, UInt32 value);
+extern void NameMap_register(Char * name, Char * desc, UInt32 value);
+extern void NameMap_unregister(Char * name, Char * desc, UInt32 value);
 
 #endif
index c41b8c97b23c7a05c4ac53e1f3dee840bbbfb971..221550a2665b81589d9f9d738c7aef979018dae0 100644 (file)
@@ -135,7 +135,7 @@ for (var i = 0; i < Build.targets.length; i++) {
             Pkg.addExecutable(name + "/test_omx_ipu_omap5", targ, platform, {
                 cfgScript: "test_omx_ipu_omap5",
                 defs: "-D IPU -D OMAP5xxx"
-            }).addObjects(["test_omx.c","ping_tasks.c"]);
+            }).addObjects(["test_omx.c","ping_tasks.c","rpc_task.c"]);
         }
     }
 }
index 5671a8efd44698eec1309fdf98a7ce0b9109fd71..b173241681b23c5942ef1ccf6279b28d58d4f3bc 100644 (file)
@@ -81,7 +81,7 @@ Void pingTaskFxn(UArg arg0, UArg arg1)
     }
 
     /* Announce we are here: */
-    NameMap_register("rpmsg-proto", arg0);
+    NameMap_register("rpmsg-proto", "rpmsg-proto", arg0);
 
     /* Note: we don't get a chance to teardown with MessageQCopy_destroy() */
 }
index cea3efe8734b1329ae410a56f69a652c96197041..0cc605124a1d0ca96fed39c859814e08e5bd21fe 100644 (file)
@@ -69,7 +69,7 @@ Void copyTaskFxn(UArg arg0, UArg arg1)
     /* Create the messageQ for receiving (and get our endpoint for sending). */
     handle = MessageQCopy_create(arg0, NULL, NULL, &myEndpoint);
 
-    NameMap_register("rpmsg-client-sample", arg0);
+    NameMap_register("rpmsg-client-sample", "sample-desc", arg0);
 
     for (i = 0; i < APP_NUM_ITERATIONS; i++) {
        /* Await a character message: */
diff --git a/packages/ti/ipc/tests/rpc_task.c b/packages/ti/ipc/tests/rpc_task.c
new file mode 100644 (file)
index 0000000..ad8ab12
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ *  ======== rpc_task.c ========
+ *
+ *  Example of setting up a 'RPC' service with the ServiceMgr, allowing clients
+ *  to instantiate the example RPC instance.
+ *
+ */
+
+#include <xdc/std.h>
+#include <xdc/cfg/global.h>
+#include <xdc/runtime/System.h>
+#include <xdc/runtime/Diags.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <ti/ipc/MultiProc.h>
+#include <ti/sysbios/BIOS.h>
+#include <ti/sysbios/knl/Task.h>
+
+#include <ti/grcm/RcmTypes.h>
+#include <ti/grcm/RcmServer.h>
+
+#include <ti/srvmgr/ServiceMgr.h>
+#include <ti/srvmgr/omaprpc/OmapRpc.h>
+#include <ti/srvmgr/rpmsg_omx.h>
+#include <ti/srvmgr/omx_packet.h>
+
+/* Turn on/off printf's */
+#define CHATTER 0
+
+#define RPC_MGR_PORT    59
+
+/* Legacy function to allow Linux side rpmsg sample tests to work: */
+extern void start_rpc_task();
+
+/*
+ * OMX packet expected to have its data payload start with a payload of
+ * this value. Need to export this properly in a meaningful header file on
+ * both HLOS and RTOS sides
+ */
+typedef enum {
+    RPC_OMX_MAP_INFO_NONE       = 0,
+    RPC_OMX_MAP_INFO_ONE_BUF    = 1,
+    RPC_OMX_MAP_INFO_TWO_BUF    = 2,
+    RPC_OMX_MAP_INFO_THREE_BUF  = 3,
+    RPC_OMX_MAP_INFO_MAX        = 0x7FFFFFFF
+} map_info_type;
+
+/*
+ *  ======== fxnTriple used by omx_benchmark test app ========
+ */
+typedef struct {
+    Int a;
+} FxnTripleArgs;
+
+#define H264_DECODER_NAME   "H264_decoder"
+
+#define OMX_VIDEO_THREAD_PRIORITY    5
+
+typedef UInt32 OMX_HANDLETYPE;
+
+static Int32 RPC_SKEL_Init(Void *, UInt32 size, UInt32 *data);
+static Int32 RPC_SKEL_Init2(UInt32 size, UInt32 *data);
+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);
+
+#if 0
+/* RcmServer static function table */
+static RcmServer_FxnDesc RPCServerFxnAry[] = {
+    {"RPC_SKEL_Init", NULL}, /* filled in dynamically */
+    {"RPC_SKEL_SetParameter", RPC_SKEL_SetParameter},
+    {"RPC_SKEL_GetParameter", RPC_SKEL_GetParameter},
+    {"fxnTriple", fxnTriple },
+};
+
+#define RPCServerFxnAryLen (sizeof RPCServerFxnAry / sizeof RPCServerFxnAry[0])
+
+static const RcmServer_FxnDescAry RPCServer_fxnTab = {
+    RPCServerFxnAryLen,
+    RPCServerFxnAry
+};
+#endif
+
+#define RPC_SVR_NUM_FXNS 2
+OmapRpc_FuncDeclaration RPCServerFxns[RPC_SVR_NUM_FXNS] =
+{
+    { RPC_SKEL_Init2,
+        { "RPC_SKEL_Init2", 3,
+            {
+                {OmapRpc_Direction_Out, OmapRpc_Param_S32, 1}, // return
+                {OmapRpc_Direction_In, OmapRpc_Param_U32, 1},
+                {OmapRpc_Direction_In, OmapRpc_PtrType(OmapRpc_Param_U32), 1},
+            },
+        },
+    },
+    { fxnTriple,
+        { "fxnTriple", 2,
+            {
+                {OmapRpc_Direction_Out, OmapRpc_Param_S32, 1}, // return
+                {OmapRpc_Direction_In, OmapRpc_Param_U32, 1}, // return
+            },
+        },
+    },
+};
+
+static Int32 RPC_SKEL_SetParameter(UInt32 size, UInt32 *data)
+{
+#if CHATTER
+    System_printf("RPC_SKEL_SetParameter: Called\n");
+#endif
+
+    return(0);
+}
+
+static Int32 RPC_SKEL_GetParameter(UInt32 size, UInt32 *data)
+{
+#if CHATTER
+    System_printf("RPC_SKEL_GetParameter: Called\n");
+#endif
+
+    return(0);
+}
+
+Void RPC_SKEL_SrvDelNotification()
+{
+    System_printf("RPC_SKEL_SrvDelNotification: Nothing to cleanup\n");
+}
+
+#define CALLBACK_DATA      "OMX_Callback"
+#define PAYLOAD_SIZE       sizeof(CALLBACK_DATA)
+#define CALLBACK_DATA_SIZE (HDRSIZE + OMXPACKETSIZE + PAYLOAD_SIZE)
+
+static Int32 RPC_SKEL_Init(Void *srvc, UInt32 size, UInt32 *data)
+{
+    char              cComponentName[128] = {0};
+    OMX_HANDLETYPE    hComp;
+    Char              cb_data[HDRSIZE + OMXPACKETSIZE + PAYLOAD_SIZE] =  {0};
+
+    /*
+     * Note: Currently, rpmsg_omx linux driver expects an omx_msg_hdr in front
+     * of the omx_packet data, so we allow space for this:
+     */
+    struct omx_msg_hdr * hdr = (struct omx_msg_hdr *)cb_data;
+    struct omx_packet  * packet = (struct omx_packet *)hdr->data;
+
+
+    //Marshalled:[>offset(cParameterName)|>pAppData|>offset(RcmServerName)|>pid|
+    //>--cComponentName--|>--CallingCorercmServerName--|
+    //<hComp]
+
+    strcpy(cComponentName, (char *)data + sizeof(map_info_type));
+
+#if CHATTER
+    System_printf("RPC_SKEL_GetHandle: Component Name received: %s\n",
+                  cComponentName);
+#endif
+
+    /* Simulate sending an async OMX callback message, passing an omx_packet
+     * structure.
+     */
+    packet->msg_id  = 99;   // Set to indicate callback instance, buffer id, etc.
+    packet->fxn_idx = 5;    // Set to indicate callback fxn
+    packet->data_size = PAYLOAD_SIZE;
+    strcpy((char *)packet->data, CALLBACK_DATA);
+
+#if CHATTER
+    System_printf("RPC_SKEL_GetHandle: Sending callback message id: %d, "
+                  "fxn_id: %d, data: %s\n",
+                  packet->msg_id, packet->fxn_idx, packet->data);
+#endif
+    ServiceMgr_send(srvc, cb_data, CALLBACK_DATA_SIZE);
+
+    /* Call OMX_Get_Handle() and return handle for future calls. */
+    //eCompReturn = OMX_GetHandle(&hComp, (OMX_STRING)&cComponentName[0], pAppData,&rpcCallBackInfo);
+    hComp = 0x5C0FFEE5;
+    data[0] = hComp;
+
+#if CHATTER
+    System_printf("RPC_SKEL_GetHandle: returning hComp: 0x%x\n", hComp);
+#endif
+
+    return(0);
+}
+
+static Int32 RPC_SKEL_Init2(UInt32 size, UInt32 *data)
+{
+    System_printf("RPC_SKEL_Init2: size = 0x%x data = 0x%x\n", size,
+                                                            (UInt32)data);
+}
+
+/*
+ *  ======== fxnTriple ========
+ */
+Int32 fxnTriple(UInt32 size, UInt32 *data)
+{
+    FxnTripleArgs *args;
+    Int a;
+
+#if CHATTER
+    System_printf("fxnTriple: Executing fxnTriple \n");
+#endif
+
+    args = (FxnTripleArgs *)((UInt32)data + sizeof(map_info_type));
+    a = args->a;
+
+    return a * 3;
+}
+
+Void start_rpc_task()
+{
+    /* Init service manager */
+    System_printf("%s initializing OMAPRPC based service manager endpoint\n",
+                    MultiProc_getName(MultiProc_self()));
+
+    OmapRpc_createChannel("rpc_example", MultiProc_getId("HOST"),
+                          RPC_MGR_PORT, RPC_SVR_NUM_FXNS, RPCServerFxns,
+                          (OmapRpc_SrvDelNotifyFxn)RPC_SKEL_SrvDelNotification);
+}
index 7ea6bb6853c07ccc42098a7b1704942acbd6ce18..6338306d17d1a7b16d71138b2875039199db868d 100644 (file)
@@ -66,6 +66,7 @@
 extern void start_ping_tasks();
 extern void start_resmgr_task();
 extern void start_hwSpinlock_task();
+extern void start_rpc_task();
 
 /*
  * OMX packet expected to have its data payload start with a payload of
@@ -269,6 +270,10 @@ Int main(Int argc, char* argv[])
     /* Start the ServiceMgr services */
     ServiceMgr_start(0);
 
+#if IPU
+    start_rpc_task();
+#endif
+
     BIOS_start();
 
     return (0);
index dae71b2b7a74f258df7705378ea4fec7381a550a..b7829aa73d0ffeeac591a470876aad753af83003 100644 (file)
@@ -37,6 +37,7 @@ BIOS.addUserStartupFunction('&IpcMgr_rpmsgStartup');
 
 xdc.loadPackage('ti.srvmgr');
 xdc.useModule('ti.srvmgr.omx.OmxSrvMgr');
+xdc.loadPackage('ti.srvmgr.omaprpc');
 
 /* ti.grcm Configuration */
 var rcmSettings = xdc.useModule('ti.grcm.Settings');
@@ -46,3 +47,6 @@ xdc.useModule('ti.grcm.RcmServer');
 xdc.loadCapsule("ti/configs/omap54xx/IpcCommon.cfg.xs");
 xdc.includeFile("ti/configs/omap54xx/IpuSmp.cfg");
 xdc.includeFile("ti/configs/omap54xx/IpuAmmu.cfg");
+
+var Task = xdc.useModule('ti.sysbios.knl.Task');
+Task.defaultStackSize = 12 * 0x400;
index 4775608a0368f3dd80057ba29b6dc309f778416e..7015f7b5ccdbe7bc5158a8875b1c84c27d4b1c5b 100644 (file)
@@ -104,7 +104,7 @@ Int TransportVirtio_Instance_init(TransportVirtio_Object *obj,
     obj->remoteProcId = remoteProcId;
 
     /* Announce our "MessageQ" service to the HOST: */
-    NameMap_register(RPMSG_SOCKET_NAME, RPMSG_MESSAGEQ_PORT);
+    NameMap_register(RPMSG_SOCKET_NAME, RPMSG_SOCKET_NAME, RPMSG_MESSAGEQ_PORT);
 
     /* Associate incomming messages with this transport's callback fxn: */
     obj->msgqHandle = MessageQCopy_create(RPMSG_MESSAGEQ_PORT,
@@ -143,7 +143,8 @@ Void TransportVirtio_Instance_finalize(TransportVirtio_Object *obj, Int status)
     Log_print0(Diags_ENTRY, "--> "FXNN);
 
     /* Announce our "MessageQ" service is going away: */
-    NameMap_unregister(RPMSG_SOCKET_NAME, RPMSG_MESSAGEQ_PORT);
+    NameMap_unregister(RPMSG_SOCKET_NAME, RPMSG_SOCKET_NAME,
+            RPMSG_MESSAGEQ_PORT);
 
     switch(status) {
         case 0: /* MessageQ_registerTransport succeeded */
diff --git a/packages/ti/srvmgr/omaprpc/OmapRpc.c b/packages/ti/srvmgr/omaprpc/OmapRpc.c
new file mode 100644 (file)
index 0000000..7035173
--- /dev/null
@@ -0,0 +1,372 @@
+/*
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <xdc/std.h>
+#include <xdc/cfg/global.h>
+#include <xdc/runtime/System.h>
+#include <xdc/runtime/Memory.h>
+
+#include <ti/sysbios/BIOS.h>
+#include <ti/sysbios/knl/Semaphore.h>
+#include <ti/sysbios/knl/Task.h>
+
+#include <ti/grcm/RcmTypes.h>
+#include <ti/grcm/RcmServer.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <ti/ipc/rpmsg/MessageQCopy.h>
+#include <ti/ipc/rpmsg/NameMap.h>
+#include <ti/srvmgr/ServiceMgr.h>
+
+#include "OmapRpc.h"
+
+typedef struct OmapRpc_Object {
+    Char                    channelName[OMAPRPC_MAX_CHANNEL_NAMELEN];
+    UInt16                  dstProc;
+    UInt32                  port;
+    MessageQCopy_Handle     msgq;
+    UInt32                  localEndPt;
+    Task_Handle             taskHandle;
+    Bool                    shutdown;
+    Semaphore_Handle        exitSem;
+    OmapRpc_SrvDelNotifyFxn srvDelCB;
+    RcmServer_Params        rcmParams;
+    UInt32                  numFuncs;
+    OmapRpc_FuncSignature  *funcSigs;
+} OmapRpc_Object;
+
+static Int32 OmapRpc_GetSvrMgrHandle(Void *srvc, Int32 num, Int32 *params)
+{
+    System_printf("OMAPRPC: Calling RCM Service Manager Create Function!\n");
+    return 0;
+}
+
+static Void omapRpcTask(UArg arg0, UArg arg1)
+{
+    OmapRpc_Object *obj = (OmapRpc_Object *)arg0;
+    UInt32 local;
+    UInt32 remote;
+    Int status;
+    UInt16 len;
+    UInt8  msg[512]; /* maximum rpmsg size is probably smaller, but we need to
+                      * be cautious */
+    OmapRpc_MsgHeader *hdr = (OmapRpc_MsgHeader *)&msg[0];
+
+    if (obj == NULL) {
+        System_printf("OMAPRPC: Failed to start task as arguments are NULL!\n");
+        return;
+    }
+
+    if (obj->msgq == NULL) {
+        System_printf("OMAPRPC: Failed to start task as MessageQ was NULL!\n");
+        return;
+    }
+
+    /* get the local endpoint we are to use */
+    local = obj->localEndPt;
+    System_printf("OMAPRPC: connecting from local endpoint %u to port %u\n",
+                        obj->localEndPt, obj->port);
+
+    NameMap_register("rpmsg-rpc", obj->channelName, obj->port);
+
+    System_printf("OMAPRPC: started channel on port: %d\n", obj->port);
+
+    while (!obj->shutdown) {
+
+        /* clear out the message and our message vars */
+        _memset(msg, 0, sizeof(msg));
+        len = 0;
+        remote = 0;
+
+        /* receive the message */
+        status = MessageQCopy_recv(obj->msgq, (Ptr)msg, &len, &remote,
+                                        MessageQCopy_FOREVER);
+
+        if (status == MessageQCopy_E_UNBLOCKED) {
+            System_printf("OMAPRPC: unblocked while waiting for messages\n");
+            continue;
+        }
+
+        System_printf("OMAPRPC: received msg type: %d len: %d from addr: %d\n",
+                             hdr->msgType, len, remote);
+        switch (hdr->msgType) {
+            case OmapRpc_MsgType_CREATE_INSTANCE:
+            {
+                /* temp pointer to payload */
+                OmapRpc_CreateInstance *create =
+                                OmapRpc_PAYLOAD(msg, OmapRpc_CreateInstance);
+                /* local copy of name */
+                Char name[sizeof(create->name)];
+                /* return structure */
+                OmapRpc_InstanceHandle *handle =
+                                OmapRpc_PAYLOAD(msg, OmapRpc_InstanceHandle);
+                /* save a copy of the input structure data */
+                _strcpy(name, create->name);
+                /* clear out the old data */
+                _memset(msg, 0, sizeof(msg));
+
+                /* create a new instance of the service */
+                handle->status = ServiceMgr_createService(name,
+                                                &handle->endpointAddress);
+
+                System_printf("OMAPRPC: created service instance named: %s "
+                              "(status=%d) addr: %d\n", name, handle->status,
+                                handle->endpointAddress);
+
+                hdr->msgType = OmapRpc_MsgType_INSTANCE_CREATED;
+                hdr->msgLen  = sizeof(OmapRpc_InstanceHandle);
+                break;
+            }
+            case OmapRpc_MsgType_DESTROY_INSTANCE:
+            {
+                /* temp pointer to payload */
+                OmapRpc_InstanceHandle *handle =
+                                OmapRpc_PAYLOAD(msg, OmapRpc_InstanceHandle);
+
+                if (obj->srvDelCB != NULL) {
+                    obj->srvDelCB();
+                }
+
+                /* don't clear out the old data... */
+                System_printf("OMAPRPC: destroying instance addr: %d\n",
+                                                    handle->endpointAddress);
+                handle->status = ServiceMgr_deleteService(
+                                                    handle->endpointAddress);
+                hdr->msgType = OmapRpc_MsgType_INSTANCE_DESTROYED;
+                hdr->msgLen = sizeof(OmapRpc_InstanceHandle);
+                /* leave the endpoint address alone. */
+                break;
+            }
+            case OmapRpc_MsgType_QUERY_CHAN_INFO:
+            {
+                OmapRpc_ChannelInfo *chanInfo =
+                                      OmapRpc_PAYLOAD(msg, OmapRpc_ChannelInfo);
+
+                chanInfo->numFuncs = obj->numFuncs;
+                System_printf("OMAPRPC: channel info query - name %s fxns %u\n",
+                                            obj->channelName, chanInfo->numFuncs);
+                hdr->msgType = OmapRpc_MsgType_CHAN_INFO;
+                hdr->msgLen = sizeof(OmapRpc_ChannelInfo);
+                break;
+            }
+            case OmapRpc_MsgType_QUERY_FUNCTION:
+            {
+                OmapRpc_QueryFunction *fxnInfo = OmapRpc_PAYLOAD(msg,
+                                                         OmapRpc_QueryFunction);
+                System_printf("OMAPRPC: function query of type %u\n",
+                              fxnInfo->infoType);
+
+                switch (fxnInfo->infoType)
+                {
+                    case OmapRpc_InfoType_FUNC_SIGNATURE:
+                        if (fxnInfo->funcIndex < obj->numFuncs)
+                            memcpy(&fxnInfo->info.signature,
+                                   &obj->funcSigs[fxnInfo->funcIndex],
+                                   sizeof(OmapRpc_FuncSignature));
+                        break;
+                    case OmapRpc_InfoType_FUNC_PERFORMANCE:
+                        break;
+                    case OmapRpc_InfoType_NUM_CALLS:
+                        break;
+                    default:
+                        System_printf("OMAPRPC: Invalid info type!\n");
+                        break;
+                }
+                hdr->msgType = OmapRpc_MsgType_FUNCTION_INFO;
+                hdr->msgLen = sizeof(OmapRpc_QueryFunction);
+                break;
+            }
+            default:
+            {
+                /* temp pointer to payload */
+                OmapRpc_Error *err = OmapRpc_PAYLOAD(msg, OmapRpc_Error);
+
+                /* the debugging message before we clear */
+                System_printf("OMAPRPC: unexpected msg type: %d\n",
+                              hdr->msgType);
+
+                /* clear out the old data */
+                _memset(msg, 0, sizeof(msg));
+
+                hdr->msgType = OmapRpc_MsgType_ERROR;
+                err->endpointAddress = local;
+                err->status = OmapRpc_ErrorType_NOT_SUPPORTED;
+                break;
+            }
+       }
+
+       /* compute the length of the return message. */
+       len = sizeof(struct OmapRpc_MsgHeader) + hdr->msgLen;
+
+       System_printf("OMAPRPC: Replying with msg type: %d to addr: %d "
+                      " from: %d len: %u\n", hdr->msgType, remote, local, len);
+
+       /* send the response. All messages get responses! */
+       MessageQCopy_send(obj->dstProc, remote, local, msg, len);
+    }
+
+    System_printf("OMAPRPC: destroying channel on port: %d\n", obj->port);
+    NameMap_unregister("rpmsg-rpc", obj->channelName, obj->port);
+    /* @TODO delete any outstanding ServiceMgr instances if no disconnect
+     * was issued? */
+
+    Semaphore_post(obj->exitSem);
+}
+
+OmapRpc_Handle OmapRpc_createChannel(String channelName,
+                                     UInt16 dstProc,
+                                     UInt32 port,
+                                     UInt32 numFuncs,
+                                     OmapRpc_FuncDeclaration *fxns,
+                                     OmapRpc_SrvDelNotifyFxn srvDelCBFunc)
+{
+    Task_Params          taskParams;
+    UInt32               func;
+
+    OmapRpc_Object *obj = Memory_alloc(NULL, sizeof(OmapRpc_Object), 0, NULL);
+    if (obj == NULL) {
+        System_printf("OMAPRPC: Failed to allocate memory for object!\n");
+        goto unload;
+    }
+    _memset(obj, 0, sizeof(OmapRpc_Object));
+    obj->numFuncs = numFuncs+1;
+    RcmServer_Params_init(&obj->rcmParams);
+    obj->rcmParams.priority = Thread_Priority_ABOVE_NORMAL;
+    obj->rcmParams.fxns.length = obj->numFuncs;
+    obj->rcmParams.fxns.elem = Memory_alloc(NULL, sizeof(RcmServer_FxnDesc)*obj->numFuncs, 0, NULL);
+    if (obj->rcmParams.fxns.elem == NULL) {
+        System_printf("OMAPRPC: Failed to allocate RCM function list!\n");
+        goto unload;
+    }
+    // setup other variables...
+    obj->shutdown = FALSE;
+    obj->dstProc = dstProc;
+    obj->port = port;
+    strncpy(obj->channelName, channelName, OMAPRPC_MAX_CHANNEL_NAMELEN-1);
+    obj->channelName[OMAPRPC_MAX_CHANNEL_NAMELEN-1]='\0';
+    obj->srvDelCB = srvDelCBFunc;
+    obj->funcSigs = Memory_alloc(NULL, sizeof(OmapRpc_FuncSignature)*obj->numFuncs, 0, NULL);
+    if (obj->funcSigs == NULL) {
+        System_printf("OMAPRPC: Failed to allocate signtures list!\n");
+        goto unload;
+    }
+    // setup the RCM functions and Signatures
+    for (func = 0; func < obj->numFuncs; func++)
+    {
+        if (func == 0)
+        {
+            // assign the "first function"
+            obj->rcmParams.fxns.elem[func].name = OmapRpc_Stringerize(OmapRpc_GetSvrMgrHandle);
+            obj->rcmParams.fxns.elem[func].addr.createFxn = (RcmServer_MsgCreateFxn)OmapRpc_GetSvrMgrHandle;
+
+            strncpy(obj->funcSigs[func].name,
+                    obj->rcmParams.fxns.elem[0].name,
+                    OMAPRPC_MAX_CHANNEL_NAMELEN);
+            obj->funcSigs[func].numParam = 0;
+        }
+        else
+        {
+            // assign the other functions
+            obj->rcmParams.fxns.elem[func].name = fxns[func-1].signature.name;
+            obj->rcmParams.fxns.elem[func].addr.fxn = (RcmServer_MsgFxn)fxns[func-1].function;
+
+            // copy the signature
+            memcpy(&obj->funcSigs[func],
+                   &fxns[func-1].signature,
+                   sizeof(OmapRpc_FuncSignature));
+        }
+    }
+
+    ServiceMgr_init();
+    if (ServiceMgr_register(channelName, &obj->rcmParams) == TRUE) {
+        System_printf("OMAPRPC: registered channel: %s\n", obj->channelName);
+        obj->msgq = MessageQCopy_create(obj->port, NULL, NULL,&obj->localEndPt);
+        if (obj->msgq == NULL) {
+            goto unload;
+        }
+        Task_Params_init(&taskParams);
+        taskParams.instance->name = channelName;
+        taskParams.priority = 1;   /* Lowest priority thread */
+        taskParams.arg0 = (UArg)obj;
+        obj->exitSem = Semaphore_create(0, NULL, NULL);
+        if (obj->exitSem == NULL) {
+            goto unload;
+        }
+        obj->taskHandle = Task_create(omapRpcTask, &taskParams, NULL);
+        if (obj->taskHandle == NULL) {
+            goto unload;
+        }
+    }
+    else {
+        System_printf("OMAPRPC: FAILED to register channel: %s\n",
+                                                            obj->channelName);
+    }
+    System_printf("OMAPRPC: Returning Object %p\n", obj);
+    return obj;
+unload:
+    OmapRpc_deleteChannel(obj);
+    return NULL;
+}
+
+Int OmapRpc_deleteChannel(OmapRpc_Handle handle)
+{
+    OmapRpc_Object *obj = (OmapRpc_Object *)handle;
+
+    if (obj == NULL) {
+        return OmapRpc_E_FAIL;
+    }
+
+    System_printf("OMAPRPC: deleting channel %s\n", obj->channelName);
+    obj->shutdown = TRUE;
+    if (obj->msgq) {
+        MessageQCopy_unblock(obj->msgq);
+        if (obj->exitSem) {
+            Semaphore_pend(obj->exitSem, BIOS_WAIT_FOREVER);
+            MessageQCopy_delete(&obj->msgq);
+            Semaphore_delete(&obj->exitSem);
+        }
+        if (obj->taskHandle) {
+            Task_delete(&obj->taskHandle);
+        }
+    }
+    if (obj->funcSigs)
+        Memory_free(NULL, obj->funcSigs, sizeof(*obj->funcSigs)*(obj->numFuncs-1));
+    if (obj->rcmParams.fxns.elem)
+        Memory_free(NULL, obj->rcmParams.fxns.elem,
+                    sizeof(obj->rcmParams.fxns.elem[0])*obj->numFuncs);
+
+    Memory_free(NULL, obj, sizeof(*obj));
+    return OmapRpc_S_SUCCESS;
+}
diff --git a/packages/ti/srvmgr/omaprpc/OmapRpc.h b/packages/ti/srvmgr/omaprpc/OmapRpc.h
new file mode 100644 (file)
index 0000000..a899032
--- /dev/null
@@ -0,0 +1,292 @@
+/*
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *  ======== OmapRpc.h ========
+ *  OMAP Remote Procedure Call Driver.
+ *
+ */
+
+#ifndef ti_srvmgr_OmapRpc__include
+#define ti_srvmgr_OmapRpc__include
+
+#include <ti/grcm/RcmServer.h>
+
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/*!
+ *  @def    OmapRpc_S_SUCCESS
+ *  @brief  Operation is successful.
+ */
+#define OmapRpc_S_SUCCESS              0
+
+/*!
+ *  @def    OmapRpc_E_FAIL
+ *  @brief  Operation is not successful.
+ */
+#define OmapRpc_E_FAIL                 -1
+
+#define OmapRpc_NUM_PARAMETERS(size) \
+    (size/sizeof(struct OmapRpc_Parameter))
+
+#define OmapRpc_PAYLOAD(ptr, type) \
+    ((struct type *)&(ptr)[sizeof(struct OmapRpc_MsgHeader)])
+
+#define OmapRpc_PARAM(param, type) (param.size == sizeof(type) ? (type)param.data : 0)
+
+#define OmapRpc_Stringerize(func)   #func
+
+#define OmapRpc_dimof(x)    (sizeof(x)/sizeof(x[0]))
+
+#define OmapRpc_DESC_EXEC_SYNC  (0x0100)
+#define OmapRpc_DESC_EXEC_ASYNC (0x0200)
+#define OmapRpc_DESC_SYM_ADD    (0x0300)
+#define OmapRpc_DESC_SYM_IDX    (0x0400)
+#define OmapRpc_DESC_CMD        (0x0500)
+#define OmapRpc_DESC_TYPE_MASK  (0x0F00)
+#define OmapRpc_JOBID_DISCRETE  (0)
+#define OmapRpc_POOLID_DEFAULT  (0x8000)
+
+#define OmapRpc_SET_FXN_IDX(idx)    (idx | 0x80000000)
+#define OmapRpc_FXN_MASK(idx)       (idx & 0x7FFFFFFF)
+
+#define OMAPRPC_MAX_CHANNEL_NAMELEN (64)
+#define OMAPRPC_MAX_FUNC_NAMELEN    (64)
+#define OMAPRPC_MAX_NUM_PARAMS      (10)
+#define OMAPRPC_MAX_INST_NAMELEN    (48)
+
+typedef enum OmapRpc_InfoType {
+    /** The function signature */
+    OmapRpc_InfoType_FUNC_SIGNATURE = 1,
+    /** The number of times a function has been called */
+    OmapRpc_InfoType_NUM_CALLS,
+    /** The performance information releated to the function */
+    OmapRpc_InfoType_FUNC_PERFORMANCE,
+
+    /** @hidden used to define the maximum info type */
+    OmapRpc_InfoType_MAX
+} OmapRpc_InfoType;
+
+/** The applicable types of messages that the HOST may send the SERVICE.
+ */
+typedef enum OmapRpc_MsgType {
+    /** Ask Service for channel information, uses \ref OmapRpc_ChannelInfo */
+    OmapRpc_MsgType_QUERY_CHAN_INFO = 0,
+    /** The return message from OMAPRPC_MSG_QUERY_CHAN_INFO*/
+    OmapRpc_MsgType_CHAN_INFO = 1,
+    /** Ask the Service Instance to send information about the Service.
+     * Uses \ref OmapRpc_QueryFunction */
+    OmapRpc_MsgType_QUERY_FUNCTION = 2,
+    /** The return message from OMAPRPC_QUERY_INSTANCE,
+     * which contains the information about the instance.
+     * Uses \ref OmapRpc_Instance_Info */
+    OmapRpc_MsgType_FUNCTION_INFO = 3,
+    /** Ask the ServiceMgr to create a new instance of the service.
+     * No secondary data is needed. */
+    OmapRpc_MsgType_CREATE_INSTANCE = 4,
+    /** The return message from OMAPRPC_CREATE_INSTANCE,
+     * contains the new endpoint address in the OmapRpc_InstanceHandle */
+    OmapRpc_MsgType_INSTANCE_CREATED = 5,
+    /** Ask the Service Mgr to destroy an instance */
+    OmapRpc_MsgType_DESTROY_INSTANCE = 6,
+    /** The return message from OMAPRPC_DESTROY_INSTANCE.
+     * contains the old endpoint address in the OmapRpc_InstanceHandle */
+    OmapRpc_MsgType_INSTANCE_DESTROYED = 7,
+    /** Ask the Service Instance to call a particular function */
+    OmapRpc_MsgType_CALL_FUNCTION = 8,
+    /** The return values from a function call */
+    OmapRpc_MsgType_FUNCTION_RETURN = 9,
+    /** Returned from either the ServiceMgr or Service Instance
+     * when an error occurs */
+    OmapRpc_MsgType_ERROR = 10,
+    /** \hidden used to define the max msg enum, not an actual message */
+    OmapRpc_MsgType_MAX
+} OmapRpc_MsgType;
+
+typedef enum OmapRpc_ErrorType {
+    /**< No errors to report */
+    OmapRpc_ErrorType_NONE = 0,
+    /**< Not enough memory exist to process request */
+    OmapRpc_ErrorType_NOT_ENOUGH_MEMORY,
+    /**< The instance died */
+    OmapRpc_ErrorType_INSTANCE_DIED,
+    /**< Some resource was unavailable. */
+    OmapRpc_ErrorType_RESOURCE_UNAVAILABLE,
+    /**< A provided parameter was either out of range, incorrect or NULL */
+    OmapRpc_ErrorType_BAD_PARAMETER,
+    /**< The requested item is not supported */
+    OmapRpc_ErrorType_NOT_SUPPORTED,
+
+    /** @hidden used to define the max error value */
+    OmapRpc_ErrorType_MAX_VALUE
+} OmapRpc_ErrorType;
+
+typedef struct OmapRpc_CreateInstance {
+    Char name[OMAPRPC_MAX_INST_NAMELEN];
+} OmapRpc_CreateInstance;
+
+typedef struct OmapRpc_ChannelInfo {
+    UInt32 numFuncs;        /**< The number of functions supported on this endpoint */
+} OmapRpc_ChannelInfo;
+
+typedef struct OmapRpc_FuncPerf {
+    UInt32 clocksPerSec;
+    UInt32 clockCycles;
+} OmapRpc_FuncPerf;
+
+/** The parameter direction as relative to the function it describes */
+typedef enum OmapRpc_Direction {
+    OmapRpc_Direction_In = 0,
+    OmapRpc_Direction_Out,
+    OmapRpc_Direction_Bi,
+    OmapRpc_Direction_MAX
+} OmapRpc_Direction;
+
+typedef enum OmapRpc_Param_Type {
+    OmapRpc_Param_VOID = 0,
+    OmapRpc_Param_S08,
+    OmapRpc_Param_U08,
+    OmapRpc_Param_S16,
+    OmapRpc_Param_U16,
+    OmapRpc_Param_S32,
+    OmapRpc_Param_U32,
+    OmapRpc_Param_S64,
+    OmapRpc_Param_U64,
+
+    OmapRpc_Param_PTR = 0x80,   /**< Logically OR'd with lower type to make a
+                                     pointer to the correct type */
+    OmapRpc_Param_MAX
+} OmapRpc_Param_Type;
+
+#define OmapRpc_PtrType(type)   (type | OmapRpc_Param_PTR)
+
+typedef struct OmapRpc_ParamSignature {
+    UInt32 direction;   /**< @see OmapRpc_Direction */
+    UInt32 type;        /**< @see OmapRpc_Param_Type */
+    UInt32 count;       /**< Used to do some basic sanity checking on array bounds */
+} OmapRpc_ParamSignature;
+
+/**
+ * This is the data structure that represents the function signature.
+ * @note The first parameter (params[0]) is the return value.
+ */
+typedef struct OmapRpc_FuncSignature {
+    Char name[OMAPRPC_MAX_FUNC_NAMELEN];
+    UInt32 numParam;
+    OmapRpc_ParamSignature params[OMAPRPC_MAX_NUM_PARAMS+1];
+} OmapRpc_FuncSignature;
+
+/**
+ * \brief Function Query Structure.
+ * \details This is used by the host first to ask the remote side for details
+ * about it's published functions
+ */
+typedef struct OmapRpc_QueryFunction {
+    UInt32 infoType;        /**< @see OmapRpc_InfoType */
+    UInt32 funcIndex;       /**< The function index to query */
+    union info {
+        UInt32 numCalls;
+        OmapRpc_FuncPerf performance;
+        OmapRpc_FuncSignature signature;
+    } info;
+} OmapRpc_QueryFunction;
+
+/** @brief The generic OMAPRPC message header.
+ * (actually a copy of omx_msg_hdr which is a copy of an RCM header)
+ */
+typedef struct OmapRpc_MsgHeader {
+    UInt32 msgType;    /**< @see OmapRpc_MsgType */
+    UInt32 msgLen;     /**< The length of the message data in bytes */
+} OmapRpc_MsgHeader;
+
+typedef struct OmapRpc_InstanceHandle {
+    UInt32 endpointAddress;
+    UInt32 status;
+} OmapRpc_InstanceHandle;
+
+typedef struct OmapRpc_Error {
+    UInt32 endpointAddress;
+    UInt32 status;
+} OmapRpc_Error;
+
+typedef struct OmapRpc_Parameter {
+    SizeT size;
+    SizeT data;
+} OmapRpc_Parameter;
+
+/** This is actually a frankensteined structure of RCM */
+typedef struct OmapRpc_Packet{
+    UInt16  desc;       /**< @see RcmClient_Packet.desc */
+    UInt16  msgId;      /**< @see RcmClient_Packet.msgId */
+    UInt16  poolId;     /**< @see RcmClient_Message.poolId */
+    UInt16  jobId;      /**< @see RcmClient_Message.jobId */
+    UInt32  fxnIdx;     /**< @see RcmClient_Message.fxnIdx */
+    Int32   result;     /**< @see RcmClient_Message.result */
+    UInt32  dataSize;   /**< @see RcmClient_Message.data_size */
+} OmapRpc_Packet;
+
+/** An OmapRpc Function is really an RCM function */
+typedef RcmServer_MsgFxn OmapRpc_Function;
+
+/**
+ * \brief The Function Declaration Structure.
+ * \details This structure is used to declare the function signature and their
+ * associated functions
+ */
+typedef struct OmapRpc_FuncDeclaration {
+    OmapRpc_Function      function;  /**< \brief The function pointer */
+    OmapRpc_FuncSignature signature; /**< \brief The signature of the function */
+} OmapRpc_FuncDeclaration;
+
+typedef struct OmapRpc_Object *OmapRpc_Handle;
+typedef Void (*OmapRpc_SrvDelNotifyFxn)(Void);
+
+OmapRpc_Handle OmapRpc_createChannel(String channelName,
+                                     UInt16 dstProc,
+                                     UInt32 port,
+                                     UInt32 numFuncs,
+                                     OmapRpc_FuncDeclaration* fxns,
+                                     OmapRpc_SrvDelNotifyFxn func);
+
+Int OmapRpc_deleteChannel(OmapRpc_Handle handle);
+
+
+#if defined (__cplusplus)
+}
+#endif /* defined (__cplusplus) */
+
+/*@}*/
+#endif /* ti_srvmgr_OmapRpc__include */
diff --git a/packages/ti/srvmgr/omaprpc/package.bld b/packages/ti/srvmgr/omaprpc/package.bld
new file mode 100644 (file)
index 0000000..6eb579a
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *  ======== package.bld ========
+ *
+ */
+
+/* explicit references to global objects */
+var Build = xdc.useModule('xdc.bld.BuildEnvironment');
+var Pkg = xdc.useModule('xdc.bld.PackageContents');
+var smpBuild = java.lang.System.getenv("BUILD_SMP");
+
+/* clean lib folder */
+Pkg.generatedFiles.$add("lib/");
+Pkg.libDir = "package/";
+
+/* add custom files to all releases */
+Pkg.attrs.exportSrc = false;
+Pkg.attrs.exportCfg = true;
+
+/* list of libraries to build */
+var libArray = new Array();
+if (smpBuild == "1") {
+    /* omaprpc library for IPU SMP target */
+    libArray.push(
+        {
+            name: "ti.srvmgr.omaprpc_smp",
+            sources: [
+                "OmapRpc",
+            ],
+            libAttrs: {
+                defs: " -DSMP"
+            },
+            isas: [ "v7M" ],
+        }
+    );
+}
+else {
+    /* omaprpc library for regular targets */
+    libArray.push(
+        {
+            name: "ti.srvmgr.omaprpc",
+            sources: [
+                "OmapRpc",
+            ],
+        }
+    );
+}
+
+/* generate the package libraries */
+/* check if profile specified in XDCARGS */
+/* XDCARGS="... profile=debug ..." */
+var cmdlProf = (" " + arguments.join(" ") + " ").match(/ profile=([^ ]+) /);
+cmdlProf = cmdlProf != null ? cmdlProf[1] : null;
+
+/* ==== loop over array of libraries ==== */
+for (var i = 0; i < libArray.length; i++) {
+    var lib = libArray[i];
+
+    /* ==== loop over all targets in build array ==== */
+    for (var j = 0; j < Build.targets.length; j++) {
+        var targ = Build.targets[j];
+
+        /* skip target if not compatible with source code */
+        if ("icw" in lib) {
+            var skipTarget = true;
+            var targIsaChain = "/" + targ.getISAChain().join("/") + "/";
+            for (var k = 0; k < lib.icw.length; k++) {
+                if (targIsaChain.match("/" + lib.icw[k] + "/")) {
+                    skipTarget = false;
+                    break;
+                }
+            }
+            if (skipTarget) continue;
+        }
+
+        /* skip target if it does not generate code for the given isa */
+        if ("isas" in lib) {
+            var skipTarget = true;
+            var list = "/" + lib.isas.join("/") + "/";
+            if (list.match("/" + targ.isa + "/")) {
+                skipTarget = false;
+            }
+            if (skipTarget) continue;
+        }
+
+        /* ==== loop over all profiles ==== */
+        for (var profile in targ.profiles) {
+
+            /* skip profile if different than specified on command line */
+            if ((cmdlProf != null) && (profile != cmdlProf)) {
+                continue;
+            }
+
+            /* name = lib/profile/name.a+suffix */
+            var name = "lib/" + profile + "/" + lib.name;
+
+            /* pass along library attributes specified in library array */
+            var libAttrs = "libAttrs" in lib ? lib.libAttrs : {};
+
+            /* must set profile explicitly */
+            libAttrs.profile = profile;
+
+            /* build the library */
+            var library = Pkg.addLibrary(name, targ, libAttrs);
+
+            /* add the source files */
+            library.addObjects(lib.sources);
+        }
+    }
+}
diff --git a/packages/ti/srvmgr/omaprpc/package.xdc b/packages/ti/srvmgr/omaprpc/package.xdc
new file mode 100644 (file)
index 0000000..ca2c1e9
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *  ======== package.xdc ========
+ *
+ */
+
+/*!
+ *  ======== ti.srvmgr.omaprpc ========
+ *  Generic RPC communication.
+ *
+ */
+
+package ti.srvmgr.omaprpc [1,0,0] {
+}
diff --git a/packages/ti/srvmgr/omaprpc/package.xs b/packages/ti/srvmgr/omaprpc/package.xs
new file mode 100644 (file)
index 0000000..afba537
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *  ======== package.xs ========
+ *
+ */
+
+/*
+ *  ======== getLibs ========
+ */
+function getLibs(prog)
+{
+    var suffix;
+    var file;
+    var libAry = [];
+    var profile = this.profile;
+    var smp = "";
+
+    suffix = prog.build.target.findSuffix(this);
+    if (suffix == null) {
+        return "";  /* nothing to contribute */
+    }
+
+    if (prog.platformName.match(/ipu/)) {
+        smp = "_smp";
+    }
+
+    /* make sure the library exists, else fallback to a built library */
+    file = "lib/" + profile + "/ti.srvmgr.omaprpc" + smp + ".a" + suffix;
+    if (java.io.File(this.packageBase + file).exists()) {
+        libAry.push(file);
+    }
+    else {
+        file = "lib/release/ti.srvmgr.omaprpc" + smp + ".a" + suffix;
+        if (java.io.File(this.packageBase + file).exists()) {
+            libAry.push(file);
+        }
+        else {
+            /* fallback to a compatible library built by this package */
+            for (var p in this.build.libDesc) {
+                if (suffix == this.build.libDesc[p].suffix) {
+                    libAry.push(p);
+                    break;
+                }
+            }
+        }
+    }
+
+    return libAry.join(";");
+}
index 3b115a1792bc079d16a511dc5266e87f8842aaf4..5d4b415ca39934fa7b8bff63b41a140b139540a1 100644 (file)
@@ -82,16 +82,19 @@ Void OmxSrvMgr_taskFxn(UArg arg0, UArg arg1)
     System_printf("OmxSrvMgr: started on port: %d\n", OMX_MGR_PORT);
 
 #ifdef SMP
-    NameMap_register("rpmsg-omx1", OMX_MGR_PORT);
+    NameMap_register("rpmsg-omx", "rpmsg-omx1", OMX_MGR_PORT);
+    System_printf("OmxSrvMgr: Proc#%d sending BOOTINIT_DONE\n",
+                        MultiProc_self());
+    VirtQueue_postInitDone();
 #else
     if (MultiProc_self() == MultiProc_getId("CORE0")) {
-        NameMap_register("rpmsg-omx0", OMX_MGR_PORT);
+        NameMap_register("rpmsg-omx", "rpmsg-omx0", OMX_MGR_PORT);
     }
     if (MultiProc_self() == MultiProc_getId("CORE1")) {
-        NameMap_register("rpmsg-omx1", OMX_MGR_PORT);
+        NameMap_register("rpmsg-omx", "rpmsg-omx1", OMX_MGR_PORT);
     }
     if (MultiProc_self() == MultiProc_getId("DSP")) {
-        NameMap_register("rpmsg-omx2", OMX_MGR_PORT);
+        NameMap_register("rpmsg-omx", "rpmsg-omx2", OMX_MGR_PORT);
     }
 #endif