]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blobdiff - qnx/src/ipc3x_dev/ti/syslink/rpmsg-rpc/rpmsg-rpc.c
Add MmServiceMgr_getId() to allow retrieval of service instance id
[ipc/ipcdev.git] / qnx / src / ipc3x_dev / ti / syslink / rpmsg-rpc / rpmsg-rpc.c
index 8204639b44fcb87319230ece500cb20a7e718cec..19403fcc4a2410923fd8aa7049355cb56f500a4a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2013, Texas Instruments Incorporated
+ *  Copyright (c) 2013-2014, Texas Instruments Incorporated
  *
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
@@ -669,7 +669,7 @@ _rpmsg_rpc_create(resmgr_context_t *ctp, io_devctl_t *msg, rpmsg_rpc_ocb_t *ocb)
 {
     Int status = EOK;
     struct rppc_create_instance * cargs =
-                    (struct rppc_create_instance *)(_DEVCTL_DATA (msg->i));
+        (struct rppc_create_instance *)(_DEVCTL_DATA (msg->i));
     struct rppc_msg_header * msg_hdr = NULL;
     rpmsg_rpc_object * rpc = ocb->rpc;
     Char * msg_data = NULL;
@@ -1675,7 +1675,6 @@ _rpmsg_rpc_translate(ProcMgr_Handle handle, char *data, pid_t pid, bool reverse)
     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);
@@ -1688,15 +1687,14 @@ _rpmsg_rpc_translate(ProcMgr_Handle handle, char *data, pid_t pid, bool reverse)
             status = -EINVAL;
             break;
         }
-        param_offset = function->params[idx].data - function->params[idx].base;
-        if (translation[i].offset - param_offset + sizeof(uint32_t) > function->params[idx].size) {
+        if (translation[i].offset + sizeof(uint32_t) > function->params[idx].size) {
             status = -EINVAL;
             break;
         }
         if (!vptr[idx]) {
             /* get the physical address of ptr */
             status = mem_offset64_peer(pid,
-                                       function->params[idx].data,
+                                       reverse ? function->params[idx].base : function->params[idx].data,
                                        function->params[idx].size,
                                        &paddr[idx], &phys_len);
             if (status >= 0 && phys_len == function->params[idx].size) {
@@ -1716,7 +1714,7 @@ _rpmsg_rpc_translate(ProcMgr_Handle handle, char *data, pid_t pid, bool reverse)
             }
         }
         /* Get physical address of the contents */
-        ptr = (uint32_t)vptr[idx] + translation[i].offset - param_offset;
+        ptr = (uint32_t)vptr[idx] + translation[i].offset;
         if (reverse) {
             *(uint32_t *)ptr = translation[i].base;
         }
@@ -1757,8 +1755,10 @@ _rpmsg_rpc_translate(ProcMgr_Handle handle, char *data, pid_t pid, bool reverse)
             }
             if (status >= 0) {
                 if ((ipu_addr =
-                            _rpmsg_rpc_pa2da(handle, (uint32_t)phys_addr)) != 0)
+                            _rpmsg_rpc_pa2da(handle, (uint32_t)phys_addr)) != 0) {
+                    function->params[i].base = function->params[i].data;
                     function->params[i].data = ipu_addr;
+                }
                 else {
                     status = -EINVAL;
                     break;
@@ -1865,7 +1865,7 @@ rpmsg_rpc_write(resmgr_context_t *ctp, io_write_t *msg, RESMGR_OCB_T *io_ocb)
     Memory_copy (&(fxn_info->func), function,
                  RPPC_PARAM_SIZE(function->num_translations));
 
-    status = _rpmsg_rpc_translate(rpc->conn->procH, (char *)function,
+    status = _rpmsg_rpc_translate(rpc->conn->procH, (char *)&(fxn_info->func),
                                   ctp->info.pid, false);
     if (status < 0) {
         Memory_free(NULL, fxn_info, sizeof(rpmsg_rpc_FxnInfo) +\
@@ -1886,7 +1886,7 @@ rpmsg_rpc_write(resmgr_context_t *ctp, io_write_t *msg, RESMGR_OCB_T *io_ocb)
 
     for (i = 0; i < function->num_params; i++) {
         ((UInt32 *)(packet->data))[i*2] = function->params[i].size;
-        ((UInt32 *)(packet->data))[(i*2)+1] = function->params[i].data;
+        ((UInt32 *)(packet->data))[(i*2)+1] = fxn_info->func.params[i].data;
         packet->data_size += (sizeof(UInt32) * 2);
     }
     msg_hdr->msg_len += packet->data_size;