]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blobdiff - linux/src/api/Ipc.c
SDOCM00113609 Add version support for MessageQ_Params structure
[ipc/ipcdev.git] / linux / src / api / Ipc.c
index b768feb605d404b9498993601a6394ae8b09faf4..ffad32bb5ce97ffb67c19e64c4ac41b1b3a049a8 100644 (file)
@@ -35,9 +35,6 @@
  *  @brief      Starts and stops user side Ipc
  *              All setup/destroy APIs on user side will be call from this
  *              module.
- *
- *  @ver        0002
- *
  */
 
 /* Standard headers */
@@ -49,6 +46,8 @@
 #include <ti/ipc/Std.h>
 #include <ti/ipc/Ipc.h>
 #include <ti/ipc/NameServer.h>
+#include <IMessageQTransport.h>
+#include <TransportRpmsg.h>
 
 /* User side headers */
 #include <ladclient.h>
@@ -74,17 +73,58 @@ static void cleanup(int arg);
 /* Function to start Ipc */
 Int Ipc_start (Void)
 {
+    TransportRpmsg_Handle  transport;
+    TransportRpmsg_Params  params;
+    IMessageQTransport_Handle iMsgQTrans;
     MessageQ_Config        msgqCfg;
     MultiProc_Config       mpCfg;
+#if defined(GATEMP_SUPPORT)
     GateHWSpinlock_Config  gateHWCfg;
+#endif
+    Int                    attachStatus;
     Int32                  status;
     LAD_Status             ladStatus;
     UInt16                 rprocId;
-    Int32                  attachedAny = 0;
+    Int32                  attachedAny;
 
     /* Catch ctrl-C, and cleanup: */
     (void) signal(SIGINT, cleanup);
 
+    if (getenv("IPC_DEBUG") != NULL) {
+        /* turn on tracing */
+        if (getenv("IPC_DEBUG")[0] == '1') {
+            /* level 1 enables typical user API tracing */
+            _MessageQ_verbose = TRUE;
+            _MultiProc_verbose = TRUE;
+            _NameServer_verbose = TRUE;
+#if defined(GATEMP_SUPPORT)
+            _GateMP_verbose = TRUE;
+
+            _GateHWSpinlock_verbose = TRUE;
+#endif
+        }
+        else if ((getenv("IPC_DEBUG")[0] == '2') ||
+                (getenv("IPC_DEBUG")[0] == '3')) {
+            /* levels 2 and 3 add socket and LAD client tracing */
+            _MessageQ_verbose = TRUE;
+            _MultiProc_verbose = TRUE;
+            _NameServer_verbose = TRUE;
+
+#if defined(GATEMP_SUPPORT)
+            _GateMP_verbose = TRUE;
+
+            _GateHWSpinlock_verbose = TRUE;
+#endif
+
+            /* internals - should be declared in respective _*.h files */
+            extern Bool _SocketFxns_verbose;
+            extern Bool _LAD_Client_verbose;
+
+            _SocketFxns_verbose = TRUE;
+            _LAD_Client_verbose = TRUE;
+        }
+    }
+
     ladStatus = LAD_connect(&ladHandle);
     if (ladStatus != LAD_SUCCESS) {
         printf("Ipc_start: LAD_connect() failed: %d\n", ladStatus);
@@ -92,7 +132,7 @@ Int Ipc_start (Void)
         goto exit;
     }
 
-    /* 
+    /*
      * Get MultiProc configuration from LAD and initialize local MultiProc
      * config structure.
      */
@@ -104,29 +144,44 @@ Int Ipc_start (Void)
         MessageQ_getConfig(&msgqCfg);
         MessageQ_setup(&msgqCfg);
 
-        /* Now attach to all remote processors, assuming they are up. */
+        /*
+         * Attach to all remote processors.  We need to attach to
+         * at least one, so tolerate MessageQ_E_RESOURCE failures for
+         * now.
+         */
+        status = Ipc_S_SUCCESS;
+        attachedAny = FALSE;
+
         for (rprocId = 0; rprocId < MultiProc_getNumProcessors(); rprocId++) {
             if (0 == rprocId) {
                 /* Skip host, which should always be 0th entry. */
                 continue;
             }
-            status = MessageQ_attach(rprocId, NULL);
-            if (status == MessageQ_E_RESOURCE) {
-                continue;
+
+            params.rprocId = rprocId;
+            transport = TransportRpmsg_create(&params, &attachStatus);
+
+            if (transport) {
+                iMsgQTrans = TransportRpmsg_upCast(transport);
+                MessageQ_registerTransport(iMsgQTrans, rprocId, 0);
+
+                attachedAny = TRUE;
             }
-            if (status < 0) {
-                printf("Ipc_start: MessageQ_attach(%d) failed: %d\n",
-                       rprocId, status);
+            else {
+                if (attachStatus == MessageQ_E_RESOURCE) {
+                    continue;
+                }
+
+                printf("Ipc_start: failed to attach to %d: %d\n",
+                       rprocId, attachStatus);
+
                 status = Ipc_E_FAIL;
 
                 break;
             }
-            else {
-                attachedAny = 1;
-            }
         }
-        if (attachedAny) {
-            status = Ipc_S_SUCCESS;
+        if (!attachedAny) {
+            status = Ipc_E_FAIL;
         }
     }
     else {
@@ -168,10 +223,12 @@ Int Ipc_start (Void)
 gatempstart_fail:
     GateHWSpinlock_stop();
 gatehwspinlockstart_fail:
+#if 0
     for (rprocId = rprocId - 1; (rprocId > 0) && (status >= 0); rprocId--) {
         MessageQ_detach(rprocId);
     }
 #endif
+#endif
 
 exit:
     return (status);
@@ -193,6 +250,7 @@ Int Ipc_stop (Void)
           /* Skip host, which should always be 0th entry. */
           continue;
         }
+#if 0
         status = MessageQ_detach(rprocId);
         if (status < 0) {
             printf("Ipc_stop: MessageQ_detach(%d) failed: %d\n",
@@ -200,6 +258,7 @@ Int Ipc_stop (Void)
             status = Ipc_E_FAIL;
             goto exit;
        }
+#endif
     }
 
     status = MessageQ_destroy();