SDOCM00115428 Incorrect return status from NameServer_delete
[ipc/ipcdev.git] / linux / src / daemon / GateMP_daemon.c
index 306a7553408cdcce229e9a5eabb1af614658ecab..d2db25d3bed18809991fd4058ad5ef34ed658f03 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2014, Texas Instruments Incorporated
+ * Copyright (c) 2013-2015, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -132,6 +132,8 @@ Int GateMP_setup(Void)
     UInt32            nsValue[NUM_INFO_FIELDS];
     UInt32            len;
     UInt32            size;
+    UInt32            alignDiff;
+    UInt32            offset;
     Int32             fdMem;
 
     NameServer_Params_init(&params);
@@ -190,43 +192,79 @@ Int GateMP_setup(Void)
             size = GateMP_module->numRemoteSystem * sizeof (UInt8) +
                 (nsValue[0] & (sysconf(_SC_PAGE_SIZE) - 1));
             size = PAGE_ALIGN(size, sysconf(_SC_PAGE_SIZE));
+            offset = nsValue[0] & ~(sysconf(_SC_PAGE_SIZE) - 1);
+#if defined(IPC_BUILDOS_ANDROID)
+            GateMP_module->remoteSystemInUse = mmap64(NULL, size,
+                (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem,
+                (off64_t)offset);
+#else
             GateMP_module->remoteSystemInUse = mmap(NULL, size,
                 (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem,
-                (off_t)nsValue[0] & ~(sysconf(_SC_PAGE_SIZE) - 1));
+                (off_t)offset);
+#endif
             if (GateMP_module->remoteSystemInUse == MAP_FAILED) {
-                 GateMP_module->remoteSystemInUse = NULL;
-                 status = GateMP_E_MEMORY;
                  LOG1("Failed to map remoteSystemInUse=0x%p to host address" \
                       "  space!", GateMP_module->remoteSystemInUse);
+                 GateMP_module->remoteSystemInUse = NULL;
+                 status = GateMP_E_MEMORY;
+            }
+            else {
+                alignDiff = nsValue[0] - offset;
+                GateMP_module->remoteSystemInUse =
+                    GateMP_module->remoteSystemInUse + alignDiff;
             }
 
             size = GateMP_module->numRemoteCustom1 * sizeof (UInt8) +
-                (nsValue[0] & (sysconf(_SC_PAGE_SIZE) - 1));
+                (nsValue[1] & (sysconf(_SC_PAGE_SIZE) - 1));
             size = PAGE_ALIGN(size, sysconf(_SC_PAGE_SIZE));
+            offset = nsValue[1] & ~(sysconf(_SC_PAGE_SIZE) - 1);
             if (status == GateMP_S_SUCCESS) {
+#if defined(IPC_BUILDOS_ANDROID)
+                GateMP_module->remoteCustom1InUse = mmap64(NULL, size,
+                    (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem,
+                    (off64_t)offset);
+#else
                 GateMP_module->remoteCustom1InUse = mmap(NULL, size,
                     (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem,
-                    (off_t)nsValue[1] & ~(sysconf(_SC_PAGE_SIZE) - 1));
+                    (off_t)offset);
+#endif
                 if (GateMP_module->remoteCustom1InUse == MAP_FAILED) {
-                    GateMP_module->remoteCustom1InUse = NULL;
-                    status = GateMP_E_MEMORY;
                     LOG1("Failed to map remoteCustom1InUse=%p to host address" \
                         " space!", GateMP_module->remoteCustom1InUse);
+                    GateMP_module->remoteCustom1InUse = NULL;
+                    status = GateMP_E_MEMORY;
+                }
+                else {
+                    alignDiff = nsValue[1] - offset;
+                    GateMP_module->remoteCustom1InUse =
+                        GateMP_module->remoteCustom1InUse + alignDiff;
                 }
             }
 
             size = GateMP_module->numRemoteCustom2 * sizeof (UInt8) +
-                (nsValue[0] & (sysconf(_SC_PAGE_SIZE) - 1));
+                (nsValue[2] & (sysconf(_SC_PAGE_SIZE) - 1));
             size = PAGE_ALIGN(size, sysconf(_SC_PAGE_SIZE));
+            offset = nsValue[2] & ~(sysconf(_SC_PAGE_SIZE) - 1);
             if (status == GateMP_S_SUCCESS) {
+#if defined(IPC_BUILDOS_ANDROID)
+                GateMP_module->remoteCustom2InUse = mmap64(NULL, size,
+                    (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem,
+                    (off64_t)offset);
+#else
                 GateMP_module->remoteCustom2InUse = mmap(NULL, size,
                     (PROT_READ|PROT_WRITE), (MAP_SHARED), fdMem,
-                    (off_t)nsValue[2] & ~(sysconf(_SC_PAGE_SIZE) - 1));
+                    (off_t)offset);
+#endif
                 if (GateMP_module->remoteCustom2InUse == MAP_FAILED) {
-                    GateMP_module->remoteCustom2InUse = NULL;
-                    status = GateMP_E_MEMORY;
                     LOG1("Failed to map remoteCustom2InUse=%p to host address" \
                         " space!", GateMP_module->remoteCustom2InUse);
+                    GateMP_module->remoteCustom2InUse = NULL;
+                    status = GateMP_E_MEMORY;
+                }
+                else {
+                    alignDiff = nsValue[2] - offset;
+                    GateMP_module->remoteCustom2InUse =
+                        GateMP_module->remoteCustom2InUse + alignDiff;
                 }
             }
         }