]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blobdiff - qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/MessageQCopy.c
Add initial support to start/stop cores after launching QNX IPC resource manager
[ipc/ipcdev.git] / qnx / src / ipc3x_dev / ti / syslink / ipc / hlos / knl / MessageQCopy.c
index dd701ac84121fc5ccada522062e1dd926fe31170..b03ae309b91fc3ed747c05f2f164539e0a6123fe 100644 (file)
@@ -1,11 +1,5 @@
 /*
- *  @file   MessageqCopy.c
- *
- *  @brief      Implementation of MessageQCopy module.
- *
- *  ============================================================================
- *
- *  Copyright (c) 2011, Texas Instruments Incorporated
+ *  Copyright (c) 2011-2014, Texas Instruments Incorporated
  *
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
  *  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.
- *  Contact information for paper mail:
- *  Texas Instruments
- *  Post Office Box 655303
- *  Dallas, Texas 75265
- *  Contact information:
- *  http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
- *  DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
- *  ============================================================================
- *
  */
 
 
 #include <ti/syslink/utils/GateSpinlock.h>
 #include <ti/syslink/utils/Memory.h>
 #include <ti/syslink/utils/List.h>
+#include <ti/syslink/inc/Bitops.h>
 #include <ti/ipc/MultiProc.h>
 #include <OsalSemaphore.h>
-#ifdef SYSLINK_BUILDOS_LINUX
-#include <atomic_linux.h>
-#elif SYSLINK_BUILDOS_QNX
 #include <atomic_qnx.h>
-#endif
 
 /* Module headers */
+#include <ti/syslink/ProcMgr.h>
 #include <ti/ipc/MessageQCopy.h>
 #include <_MessageQCopyDefs.h>
 #include <_MessageQCopy.h>
@@ -141,6 +124,8 @@ typedef struct MessageQCopy_Object_tag {
     /*!< Address (endpoint) of this MessageQCopy instance */
     Char                name [RPMSG_NAME_SIZE];
     /*!< Name of this MessageQCopy instance (may not be set) */
+    Char                desc [RPMSG_NAME_SIZE];
+    /*!< Desc of this MessageQCopy instance (may not be set) */
     Bool                announce;
     /*!< Flag to indicate if creation/deletion of this instance should be
          announced to the remote cores. */
@@ -148,7 +133,7 @@ typedef struct MessageQCopy_Object_tag {
     /*!< Callback to invoke when a message is received for this addr.  */
     Void              * priv;
     /*!< Private data that is passed to the callback */
-    Void (*notifyCb)(MessageQCopy_Handle, UInt16, UInt32, Bool);
+    Void (*notifyCb)(MessageQCopy_Handle, UInt16, UInt32, Char *, Bool);
     /*!< Optional callback that can be registered to request notification when
          MQCopy objects of the same name are created */
 } MessageQCopy_Object;
@@ -170,7 +155,7 @@ _MessageQCopy_callback_bufReady (VirtQueue_Handle vq, void *arg);
 static
 MessageQCopy_Handle
 _MessageQCopy_create (MessageQCopyTransport_Handle handle, UInt32 reserved,
-                      String name,
+                      String name, String desc,
                       Void (*cb)(MessageQCopy_Handle,
                                  Void *, Int, Void *, UInt32, UInt16),
                       Void *priv, UInt32 * endpoint);
@@ -535,8 +520,8 @@ MessageQCopy_attach (UInt16 remoteProcId, Ptr sharedAddr, UInt16 startId)
                     if (status >= 0) {
                         /* Startup the VirtQueue module for this procId. */
                         VirtQueue_startup(obj->procId,
-                                          MessageQCopy_module->cfg.intId,
-                                          vqPAddr);
+                                    MessageQCopy_module->cfg.intId[obj->procId],
+                                    vqPAddr);
 
                         /*
                          * The buffer area is divided into two parts, one
@@ -688,6 +673,8 @@ MessageQCopy_detach (UInt16 remoteProcId)
                 }
             }
 
+            MessageQCopy_module->transport[remoteProcId] = NULL;
+
             /* Delete the virtqueues */
             for (i = 0; i < MessageQCopy_NUMVIRTQS; i++) {
                 VirtQueue_delete (&obj->vq[i]);
@@ -732,7 +719,7 @@ MessageQCopy_detach (UInt16 remoteProcId)
 static
 MessageQCopy_Handle
 _MessageQCopy_create (MessageQCopyTransport_Handle handle, UInt32 reserved,
-           String name,
+           String name, String desc,
            void (*cb)(MessageQCopy_Handle, void *, int, void *, UInt32, UInt16),
            Void *priv, UInt32 * endpoint)
 {
@@ -745,11 +732,12 @@ _MessageQCopy_create (MessageQCopyTransport_Handle handle, UInt32 reserved,
     MessageQCopy_Handle *       mq              = NULL;
     Bool                        announce        = FALSE;
 
-    GT_4trace (curTrace, GT_ENTER, "_MessageQCopy_create",
-               handle, reserved, name, endpoint);
+    GT_5trace (curTrace, GT_ENTER, "_MessageQCopy_create",
+               handle, reserved, name, desc, endpoint);
 
     GT_assert (curTrace, (endpoint != NULL));
     /* name is optional and may be NULL. */
+    /* desc is optional and may be NULL. */
     /* handle is optional and may be NULL. */
 
 #if !defined(SYSLINK_BUILD_OPTIMIZE)
@@ -785,6 +773,16 @@ _MessageQCopy_create (MessageQCopyTransport_Handle handle, UInt32 reserved,
                              status,
                              "Invalid name argument provided");
     }
+    else if (desc && String_nlen(desc, RPMSG_NAME_SIZE - 1) == -1) {
+        /*! @retval  MessageQCopy_E_INVALIDARG Invalid name argument
+                                         provided. */
+        status = MessageQCopy_E_INVALIDARG;
+        GT_setFailureReason (curTrace,
+                             GT_4CLASS,
+                             "_MessageQCopy_create",
+                             status,
+                             "Invalid desc argument provided");
+    }
     else {
 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
         if (handle == NULL) {
@@ -792,8 +790,9 @@ _MessageQCopy_create (MessageQCopyTransport_Handle handle, UInt32 reserved,
             if (reserved != MessageQCopy_ADDRANY && name != NULL)
                 announce = TRUE;
         }
-        else
+        else {
             mq = handle->mq;
+        }
 
         /* Enter critical section protection. */
         key = IGateProvider_enter (MessageQCopy_module->gateHandle);
@@ -830,6 +829,11 @@ _MessageQCopy_create (MessageQCopyTransport_Handle handle, UInt32 reserved,
                 }
                 else
                     obj->name[0] = '\0';
+                if (desc) {
+                    String_cpy (obj->desc, desc);
+                }
+                else
+                    obj->desc[0] = '\0';
 
                 mq[queueIndex] = obj;
 
@@ -842,6 +846,10 @@ _MessageQCopy_create (MessageQCopyTransport_Handle handle, UInt32 reserved,
                     msg.addr = obj->addr;
                     msg.flags = RPMSG_NS_CREATE;
                     String_ncpy (msg.name, obj->name, RPMSG_NAME_SIZE);
+                    if (obj->desc)
+                        String_ncpy (msg.desc, obj->desc, RPMSG_NAME_SIZE);
+                    else
+                        msg.desc[0] = '\0';
 
                     /* Send to all procs */
                     for (i = 0; i < MultiProc_MAXPROCESSORS; i++) {
@@ -879,6 +887,7 @@ _MessageQCopy_create (MessageQCopyTransport_Handle handle, UInt32 reserved,
                                                      MessageQCopy_module->mq[i],
                                                      obj->procId,
                                                      obj->addr,
+                                                     obj->desc,
                                                      TRUE);
                             }
                         }
@@ -941,7 +950,8 @@ MessageQCopy_create (UInt32 reserved, String name,
     else {
 #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
 
-        obj = _MessageQCopy_create (NULL, reserved, name, cb, priv, endpoint);
+        obj = _MessageQCopy_create (NULL, reserved, name, NULL, cb, priv,
+                                    endpoint);
 
 #if !defined(SYSLINK_BUILD_OPTIMIZE)
         if (obj == NULL) {
@@ -1048,6 +1058,10 @@ MessageQCopy_delete (      MessageQCopy_Handle * handlePtr)
                 msg.addr = obj->addr;
                 msg.flags = RPMSG_NS_DESTROY;
                 String_ncpy(msg.name, obj->name, RPMSG_NAME_SIZE);
+                if (obj->desc)
+                    String_ncpy(msg.desc, obj->desc, RPMSG_NAME_SIZE);
+                else
+                    msg.desc[0] = '\0';
 
                 /* Send to all procs */
                 for (i = 0; i < MultiProc_MAXPROCESSORS; i++) {
@@ -1082,6 +1096,7 @@ MessageQCopy_delete (      MessageQCopy_Handle * handlePtr)
                                                      MessageQCopy_module->mq[i],
                                                      obj->procId,
                                                      obj->addr,
+                                                     obj->desc,
                                                      FALSE);
                         }
                     }
@@ -1121,7 +1136,7 @@ MessageQCopy_delete (      MessageQCopy_Handle * handlePtr)
 /* Register to be notified of a MQ created on the remote core. */
 Int
 MessageQCopy_registerNotify (MessageQCopy_Handle handle,
-                          Void (*cb)(MessageQCopy_Handle, UInt16, UInt32, Bool))
+                  Void (*cb)(MessageQCopy_Handle, UInt16, UInt32, Char *, Bool))
 {
     Int32                               status      = MessageQCopy_S_SUCCESS;
     MessageQCopyTransport_Object *      obj         = NULL;
@@ -1210,7 +1225,8 @@ MessageQCopy_registerNotify (MessageQCopy_Handle handle,
                                                   obj->mq[i]->name,
                                                   RPMSG_NAME_SIZE) ) {
                                     /* call the callback */
-                                    cb(handle, j, obj->mq[i]->addr, TRUE);
+                                    cb(handle, j, obj->mq[i]->addr,
+                                       obj->mq[i]->desc, TRUE);
                                 }
                             }
                         }
@@ -1481,7 +1497,7 @@ MessageQCopy_send (UInt16 dstProc, UInt16 srcProc, UInt32 dstEndpt,
             }
             else {
                 if (!_MessageQCopy_create (transport, msg->addr, msg->name,
-                                           NULL, NULL, &endpoint)) {
+                                           msg->desc, NULL, NULL, &endpoint)) {
                     GT_0trace (curTrace, GT_4CLASS,
                                "creating of MQ in NS Callback failed!");
                 }
@@ -1548,4 +1564,3 @@ _MessageQCopy_callback_bufReady (VirtQueue_Handle vq, void *arg)
 #if defined (__cplusplus)
 }
 #endif /* defined (__cplusplus) */
-