Android: Added support for MessageQ
authorArnie Reynoso <ariner@ti.com>
Wed, 25 Sep 2013 15:50:34 +0000 (08:50 -0700)
committerChris Ring <cring@ti.com>
Wed, 25 Sep 2013 23:55:49 +0000 (16:55 -0700)
Support for MessageQ and related application(LAD) was added for Android.
Android specific build files have been created/modified to build all
user-side libraries (libmmrpc, libtiipc, libtiutils) and applications
from within the Android filesystem. This include test apps (MesssageQ*).

A few changes were also needed by the common source files that
are shared across Linux and Android builds.

android/src/api/Android.mk [new file with mode: 0644]
android/src/daemon/Android.mk [new file with mode: 0644]
android/src/mm/Android.mk [moved from Android.mk with 89% similarity]
android/src/tests/Android.mk [new file with mode: 0644]
android/src/utils/Android.mk [new file with mode: 0644]
linux/include/_lad.h
linux/include/ti/ipc/Std.h
linux/src/daemon/MessageQ_daemon.c
linux/src/daemon/NameServer_daemon.c
linux/src/utils/LAD_client.c

diff --git a/android/src/api/Android.mk b/android/src/api/Android.mk
new file mode 100644 (file)
index 0000000..b14d836
--- /dev/null
@@ -0,0 +1,54 @@
+#
+#   Copyright (c) 2013, Texas Instruments Incorporated
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#   *  Redistributions of source code must retain the above copyright
+#      notice, this list of conditions and the following disclaimer.
+#
+#   *  Redistributions in binary form must reproduce the above copyright
+#      notice, this list of conditions and the following disclaimer in the
+#      documentation and/or other materials provided with the distribution.
+#
+#   *  Neither the name of Texas Instruments Incorporated nor the names of
+#      its contributors may be used to endorse or promote products derived
+#      from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+#   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+#   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+#   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+#   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+#   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+#   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.
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+IPC_ROOT := ../../..
+
+LOCAL_C_INCLUDES +=  $(LOCAL_PATH)/$(IPC_ROOT)/linux/include \
+                     $(LOCAL_PATH)/$(IPC_ROOT)/packages \
+                     $(LOCAL_PATH)/$(IPC_ROOT)/hlos_common/include
+
+LOCAL_CFLAGS += -DIPC_BUILDOS_ANDROID
+LOCAL_MODULE_TAGS:= optional
+
+LOCAL_SRC_FILES:= $(IPC_ROOT)/linux/src/api/MultiProc.c \
+                  $(IPC_ROOT)/linux/src/api/NameServer.c \
+                  $(IPC_ROOT)/linux/src/api/Ipc.c \
+                  $(IPC_ROOT)/linux/src/api/MessageQ.c
+
+LOCAL_SHARED_LIBRARIES := \
+    liblog libtiipcutils
+
+LOCAL_MODULE:= libtiipc
+include $(BUILD_SHARED_LIBRARY)
diff --git a/android/src/daemon/Android.mk b/android/src/daemon/Android.mk
new file mode 100644 (file)
index 0000000..595f5e4
--- /dev/null
@@ -0,0 +1,55 @@
+#
+#   Copyright (c) 2013, Texas Instruments Incorporated
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#   *  Redistributions of source code must retain the above copyright
+#      notice, this list of conditions and the following disclaimer.
+#
+#   *  Redistributions in binary form must reproduce the above copyright
+#      notice, this list of conditions and the following disclaimer in the
+#      documentation and/or other materials provided with the distribution.
+#
+#   *  Neither the name of Texas Instruments Incorporated nor the names of
+#      its contributors may be used to endorse or promote products derived
+#      from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+#   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+#   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+#   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+#   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+#   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+#   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.
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+IPC_ROOT := ../../..
+
+LOCAL_C_INCLUDES +=  $(LOCAL_PATH)/$(IPC_ROOT)/linux/include \
+                     $(LOCAL_PATH)/$(IPC_ROOT)/packages \
+                     $(LOCAL_PATH)/$(IPC_ROOT)/hlos_common/include
+
+LOCAL_CFLAGS += -DIPC_BUILDOS_ANDROID
+LOCAL_MODULE_TAGS:= optional
+
+LOCAL_SRC_FILES:= $(IPC_ROOT)/linux/src/daemon/lad.c \
+                  $(IPC_ROOT)/linux/src/daemon/MessageQ_daemon.c \
+                  $(IPC_ROOT)/linux/src/daemon/MultiProc_daemon.c \
+                  $(IPC_ROOT)/linux/src/daemon/NameServer_daemon.c \
+                  $(IPC_ROOT)/linux/src/daemon/MultiProcCfg_dra7xx.c
+
+LOCAL_SHARED_LIBRARIES := \
+    liblog libtiipcutils_lad libtiipc
+
+LOCAL_MODULE:= lad_dra7xx
+include $(BUILD_EXECUTABLE)
similarity index 89%
rename from Android.mk
rename to android/src/mm/Android.mk
index c88c39bd45924586d7d3d655dc24b9ee34fa93d1..7206df2e7771367411f9709a550c91cf978d3101 100644 (file)
@@ -33,12 +33,17 @@ LOCAL_PATH:= $(call my-dir)
 
 include $(CLEAR_VARS)
 
+IPC_ROOT := ../../..
+
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(IPC_ROOT) \
+                    $(LOCAL_PATH)/$(IPC_ROOT)/packages
+
 LOCAL_CFLAGS += -DIPC_BUILDOS_ANDROID
 LOCAL_MODULE_TAGS:= optional
 
-LOCAL_SRC_FILES:= packages/ti/ipc/mm/MmRpc.c
+LOCAL_SRC_FILES:= $(IPC_ROOT)/packages/ti/ipc/mm/MmRpc.c
 LOCAL_SHARED_LIBRARIES := \
     liblog
 
-LOCAL_MODULE:= libipc
+LOCAL_MODULE:= libmmrpc
 include $(BUILD_SHARED_LIBRARY)
diff --git a/android/src/tests/Android.mk b/android/src/tests/Android.mk
new file mode 100644 (file)
index 0000000..2cf11e4
--- /dev/null
@@ -0,0 +1,109 @@
+#
+#   Copyright (c) 2013, Texas Instruments Incorporated
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#   *  Redistributions of source code must retain the above copyright
+#      notice, this list of conditions and the following disclaimer.
+#
+#   *  Redistributions in binary form must reproduce the above copyright
+#      notice, this list of conditions and the following disclaimer in the
+#      documentation and/or other materials provided with the distribution.
+#
+#   *  Neither the name of Texas Instruments Incorporated nor the names of
+#      its contributors may be used to endorse or promote products derived
+#      from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+#   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+#   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+#   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+#   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+#   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+#   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.
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+##### MessageQApp #####
+include $(CLEAR_VARS)
+
+IPC_ROOT := ../../..
+
+LOCAL_C_INCLUDES +=  $(LOCAL_PATH)/$(IPC_ROOT)/linux/include \
+                     $(LOCAL_PATH)/$(IPC_ROOT)/packages
+
+LOCAL_CFLAGS += -DIPC_BUILDOS_ANDROID
+LOCAL_MODULE_TAGS:= optional
+
+LOCAL_SRC_FILES:= $(IPC_ROOT)/linux/src/tests/MessageQApp.c
+
+LOCAL_SHARED_LIBRARIES := \
+    liblog libtiipcutils libtiipc
+
+LOCAL_MODULE:= messageQApp
+include $(BUILD_EXECUTABLE)
+
+##### MessageQBench #####
+include $(CLEAR_VARS)
+
+IPC_ROOT := ../../..
+
+LOCAL_C_INCLUDES +=  $(LOCAL_PATH)/$(IPC_ROOT)/linux/include \
+                     $(LOCAL_PATH)/$(IPC_ROOT)/packages
+
+LOCAL_CFLAGS += -DIPC_BUILDOS_ANDROID
+LOCAL_MODULE_TAGS:= optional
+
+LOCAL_SRC_FILES:= $(IPC_ROOT)/linux/src/tests/MessageQBench.c
+
+LOCAL_SHARED_LIBRARIES := \
+    liblog libtiipcutils libtiipc
+
+LOCAL_MODULE:= messageQBench
+include $(BUILD_EXECUTABLE)
+
+##### MessageQMulti #####
+include $(CLEAR_VARS)
+
+IPC_ROOT := ../../..
+
+LOCAL_C_INCLUDES +=  $(LOCAL_PATH)/$(IPC_ROOT)/linux/include \
+                     $(LOCAL_PATH)/$(IPC_ROOT)/packages
+
+LOCAL_CFLAGS += -DIPC_BUILDOS_ANDROID
+LOCAL_MODULE_TAGS:= optional
+
+LOCAL_SRC_FILES:= $(IPC_ROOT)/linux/src/tests/MessageQMulti.c
+
+LOCAL_SHARED_LIBRARIES := \
+    liblog libtiipcutils libtiipc
+
+LOCAL_MODULE:= messageQMulti
+include $(BUILD_EXECUTABLE)
+
+##### NameServerApp #####
+include $(CLEAR_VARS)
+
+IPC_ROOT := ../../..
+
+LOCAL_C_INCLUDES +=  $(LOCAL_PATH)/$(IPC_ROOT)/linux/include \
+                     $(LOCAL_PATH)/$(IPC_ROOT)/hlos_common/include \
+                     $(LOCAL_PATH)/$(IPC_ROOT)/packages
+
+LOCAL_CFLAGS += -DIPC_BUILDOS_ANDROID
+LOCAL_MODULE_TAGS:= optional
+
+LOCAL_SRC_FILES:= $(IPC_ROOT)/linux/src/tests/NameServerApp.c
+
+LOCAL_SHARED_LIBRARIES := \
+    liblog libtiipcutils libtiipc
+
+LOCAL_MODULE:= nameServerApp
+include $(BUILD_EXECUTABLE)
diff --git a/android/src/utils/Android.mk b/android/src/utils/Android.mk
new file mode 100644 (file)
index 0000000..c2f896d
--- /dev/null
@@ -0,0 +1,78 @@
+#
+#   Copyright (c) 2013, Texas Instruments Incorporated
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#   *  Redistributions of source code must retain the above copyright
+#      notice, this list of conditions and the following disclaimer.
+#
+#   *  Redistributions in binary form must reproduce the above copyright
+#      notice, this list of conditions and the following disclaimer in the
+#      documentation and/or other materials provided with the distribution.
+#
+#   *  Neither the name of Texas Instruments Incorporated nor the names of
+#      its contributors may be used to endorse or promote products derived
+#      from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+#   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+#   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+#   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+#   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+#   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+#   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.
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+IPC_ROOT := ../../..
+
+LOCAL_C_INCLUDES +=  $(LOCAL_PATH)/$(IPC_ROOT)/linux/include \
+                     $(LOCAL_PATH)/$(IPC_ROOT)/packages \
+                     $(LOCAL_PATH)/$(IPC_ROOT)/hlos_common/include
+
+LOCAL_CFLAGS += -DIPC_BUILDOS_ANDROID
+LOCAL_MODULE_TAGS:= optional
+
+LOCAL_SRC_FILES:= $(IPC_ROOT)/linux/src/utils/LAD_client.c \
+                  $(IPC_ROOT)/linux/src/utils/SocketFxns.c \
+                  $(IPC_ROOT)/linux/src/utils/MultiProc_app.c \
+                  $(IPC_ROOT)/hlos_common/src/utils/MultiProc.c
+
+LOCAL_SHARED_LIBRARIES := \
+    liblog
+
+LOCAL_MODULE:= libtiipcutils
+include $(BUILD_SHARED_LIBRARY)
+
+##### libtiipcutils_lad #####
+include $(CLEAR_VARS)
+
+IPC_ROOT := ../../..
+
+LOCAL_C_INCLUDES +=  $(LOCAL_PATH)/$(IPC_ROOT)/linux/include \
+                     $(LOCAL_PATH)/$(IPC_ROOT)/packages \
+                     $(LOCAL_PATH)/$(IPC_ROOT)/hlos_common/include
+
+LOCAL_CFLAGS += -DIPC_BUILDOS_ANDROID
+LOCAL_MODULE_TAGS:= optional
+
+LOCAL_SRC_FILES:= $(IPC_ROOT)/linux/src/utils/LAD_client.c \
+                  $(IPC_ROOT)/linux/src/utils/SocketFxns.c \
+                  $(IPC_ROOT)/hlos_common/src/utils/MultiProc.c
+
+LOCAL_SHARED_LIBRARIES := \
+    liblog
+
+LOCAL_ALLOW_UNDEFINED_SYMBOLS:= true
+
+LOCAL_MODULE:= libtiipcutils_lad
+include $(BUILD_SHARED_LIBRARY)
index 275690585b668aee328565b4b22d78fe5457aedf..d184df4f073b39f72c9e0a4c2f945cc973871970 100644 (file)
@@ -76,8 +76,14 @@ extern FILE *logPtr;
 
 
 /* LAD commmand FIFO strings: */
+#if defined (IPC_BUILDOS_ANDROID)
+#define LAD_COMMANDFIFO         "/data/local/tmp/LAD/LADCMDS"
+#define LAD_WORKINGDIR          "/data/local/tmp/LAD/"
+#else
 #define LAD_COMMANDFIFO         "/tmp/LAD/LADCMDS"
 #define LAD_WORKINGDIR          "/tmp/LAD/"
+#endif
+
 #define LAD_RESPONSEFIFOPATH    LAD_WORKINGDIR
 #define LAD_PROTOCOLVERSION     "03000000"    /*  MMSSRRRR */
 
index 63adabf7ac3fd0482d3fcc4060fe58785d6f791f..43891966439c27c3f8587f17df82030cd513816b 100644 (file)
@@ -94,6 +94,10 @@ typedef PVOID           HANDLE;         /* h    */
 #define FAIL   -1
 //#define NULL            '\0'
 
+#if defined (IPC_BUILDOS_ANDROID)
+#define MAX(a,b) (((a)>(b))?(a):(b))
+#endif
+
 #if defined (__cplusplus)
 }
 #endif
index dad1d7cefeb10ef44ca8a23b32ad62bb7b5babd0..d718f2d8249508aaaa6eb7513d40f777b325dd92 100644 (file)
@@ -143,7 +143,11 @@ static MessageQ_ModuleObject MessageQ_state =
     .queues                 = NULL,
     .numQueues              = 2u,
     .canFreeQueues          = FALSE,
+#if defined(IPC_BUILDOS_ANDROID)
+    .gate                   = PTHREAD_RECURSIVE_MUTEX_INITIALIZER,
+#else
     .gate                   = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
+#endif
     .defaultCfg.traceFlag   = FALSE,
     .defaultCfg.maxRuntimeEntries = 32u,
     .defaultCfg.maxNameLen    = 32u,
index f4dd2ddeebfc48c9249de86a68bc7e115bf96c3e..bc644e5b5d83ed78c257554044cb3b9cdb95daad 100644 (file)
@@ -168,9 +168,12 @@ static NameServer_ModuleObject NameServer_state = {
     .defInstParams.checkExisting     = TRUE,
     .defInstParams.maxValueLen       = 0u,
     .defInstParams.maxNameLen        = 16u,
+#if defined(IPC_BUILDOS_ANDROID)
+    .modGate                         = PTHREAD_RECURSIVE_MUTEX_INITIALIZER,
+#else
 // only _NP (non-portable) type available in CG tools which we're using
     .modGate                         = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
-//    .modGate                         = PTHREAD_RECURSIVE_MUTEX_INITIALIZER,
+#endif
     .refCount                        = 0
 };
 
index 48ef3d3e382de50975b5466095952325dda11543..6b909508a84ac60bff99b52fb18e1864a140af6e 100644 (file)
@@ -63,9 +63,13 @@ static _LAD_ClientInfo clientInfo[LAD_MAXNUMCLIENTS];
 
 static LAD_Status initWrappers(Void);
 static Bool openCommandFIFO(Void);
+
+#if defined(IPC_BUILDOS_ANDROID)
+static pthread_mutex_t modGate  = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
+#else
 // only _NP (non-portable) type available in CG tools which we're using
 static pthread_mutex_t modGate  = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
-// static pthread_mutex_t modGate  = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
+#endif
 
 
 /*