]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blobdiff - linux/src/api/MultiProc.c
Tests: ping_rpmsg: Update Test with Proper Socket Usage
[ipc/ipcdev.git] / linux / src / api / MultiProc.c
index cc54b403454c05b44761979c327bbe8234e4ebf4..015955abed9fac4f6f3d631ebdc2da0fbb40147c 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2013, Texas Instruments Incorporated
+ * Copyright (c) 2013-2015 Texas Instruments Incorporated - http://www.ti.com
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 /*
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 /*
- *  @file      MultiProcQ.c
+ *  @file       MultiProcQ.c
  *
  *
- *  @brief     Prototype Mapping of MultiProc to Socket ABI
- *             (IPC 3).
+ *  @brief      MultiProc Linux implementation
  */
 
  */
 
-/* Standard headers */
-#include <Std.h>
+/* Standard IPC header */
+#include <ti/ipc/Std.h>
 
 /* Module level headers */
 #include <ti/ipc/MultiProc.h>
 #include <_MultiProc.h>
 
 
 /* Module level headers */
 #include <ti/ipc/MultiProc.h>
 #include <_MultiProc.h>
 
-/* Socket Headers */
 #include <sys/types.h>
 #include <string.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <string.h>
 #include <stdio.h>
@@ -53,7 +51,9 @@
 #include <ladclient.h>
 #include <_lad.h>
 
 #include <ladclient.h>
 #include <_lad.h>
 
-static Bool verbose = FALSE;
+/* traces in this file are controlled via _MultiProc_verbose */
+Bool _MultiProc_verbose = FALSE;
+#define verbose _MultiProc_verbose
 
 /* =============================================================================
  * APIS
 
 /* =============================================================================
  * APIS
@@ -62,8 +62,6 @@ static Bool verbose = FALSE;
 /* Function to get default configuration for the MultiProc module.
  *
  */
 /* Function to get default configuration for the MultiProc module.
  *
  */
-
-
 Void MultiProc_getConfig (MultiProc_Config * cfg)
 {
     Int status;
 Void MultiProc_getConfig (MultiProc_Config * cfg)
 {
     Int status;
@@ -74,34 +72,81 @@ Void MultiProc_getConfig (MultiProc_Config * cfg)
     assert (cfg != NULL);
 
     handle = LAD_findHandle();
     assert (cfg != NULL);
 
     handle = LAD_findHandle();
-    if (handle == LAD_MAXNUMCLIENTS) {
-       PRINTVERBOSE1(
-         "MultiProc_getConfig: can't find connection to daemon for pid %d\n",
-          getpid())
 
 
-       return;
+    if (handle == LAD_MAXNUMCLIENTS) {
+        PRINTVERBOSE1("MultiProc_getConfig: can't find connection to daemon "
+                "for pid %d\n", getpid())
+        return;
     }
 
     cmd.cmd = LAD_MULTIPROC_GETCONFIG;
     cmd.clientId = handle;
 
     if ((status = LAD_putCommand(&cmd)) != LAD_SUCCESS) {
     }
 
     cmd.cmd = LAD_MULTIPROC_GETCONFIG;
     cmd.clientId = handle;
 
     if ((status = LAD_putCommand(&cmd)) != LAD_SUCCESS) {
-       PRINTVERBOSE1(
-         "MultiProc_getConfig: sending LAD command failed, status=%d\n", status)
-       return;
+        PRINTVERBOSE1("MultiProc_getConfig: sending LAD command failed, "
+                "status=%d\n", status)
+        return;
     }
 
     if ((status = LAD_getResponse(handle, &rsp)) != LAD_SUCCESS) {
     }
 
     if ((status = LAD_getResponse(handle, &rsp)) != LAD_SUCCESS) {
-       PRINTVERBOSE1("MultiProc_getConfig: no LAD response, status=%d\n", status)
-       return;
+        PRINTVERBOSE1("MultiProc_getConfig: no LAD response, status=%d\n",
+                status)
+        return;
     }
     status = rsp.multiprocGetConfig.status;
 
     }
     status = rsp.multiprocGetConfig.status;
 
-    PRINTVERBOSE2(
-      "MultiProc_getConfig: got LAD response for client %d, status=%d\n",
-      handle, status)
+    PRINTVERBOSE2("MultiProc_getConfig: got LAD response for client %d, "
+            "status=%d\n", handle, status)
 
     memcpy(cfg, &rsp.multiprocGetConfig.cfg, sizeof(*cfg));
 
     return;
 }
 
     memcpy(cfg, &rsp.multiprocGetConfig.cfg, sizeof(*cfg));
 
     return;
 }
+
+/*
+ *  ======== MultiProc_rprocSetId ========
+ */
+Int MultiProc_rprocSetId(UInt16 procId, UInt rprocId)
+{
+    Int status;
+    LAD_ClientHandle handle;
+    struct LAD_CommandObj cmd;
+    union LAD_ResponseObj rsp;
+    UInt16 clusterId;
+
+
+    handle = LAD_findHandle();
+
+    if (handle == LAD_MAXNUMCLIENTS) {
+        PRINTVERBOSE1("MultiProc_rprocSetId: can't find connection to daemon "
+                "for pid %d\n", getpid())
+        return (-1);
+    }
+
+    cmd.cmd = LAD_RPROC_SETID;
+    cmd.clientId = handle;
+    cmd.args.rprocSetId.procId = procId;
+    cmd.args.rprocSetId.rprocId = rprocId;
+
+    if ((status = LAD_putCommand(&cmd)) != LAD_SUCCESS) {
+        PRINTVERBOSE1("MultiProc_rprocSetId: sending LAD command failed, "
+                "status=%d\n", status)
+        return (status);
+    }
+
+    if ((status = LAD_getResponse(handle, &rsp)) != LAD_SUCCESS) {
+        PRINTVERBOSE1("MultiProc_rprocSetId: no LAD response, status=%d\n",
+                status)
+        return (status);
+    }
+    status = rsp.status;
+
+    PRINTVERBOSE2("MultiProc_rprocSetId: got LAD response for client %d, "
+            "status=%d\n", handle, status)
+
+    /* update configuration in api state */
+    clusterId = procId - _MultiProc_cfg.baseIdOfCluster;
+    _MultiProc_cfg.rprocList[clusterId] = rprocId;
+
+    return (status);
+}