summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoranAleksov <Zoran.Aleksov@seavus.com>2012-02-07 15:33:42 +0100
committerViktor Mladenovski <viktor.mladenovski@seavus.com>2012-05-25 14:43:32 +0200
commit828be7d08c886347641d8bba675993caf5a13d1a (patch)
tree17e986bd43df9a9ebbe419bd4539bc6b1860d65c
parent10184ae5b432f3dd7e014afb9a8f0ea0cd880e26 (diff)
Delivery must be compliant with Mac OS Lion
Porting of loader communication to Mac OS Lion ST-Ericsson ID: 358802 ST-Ericsson FOSS-OUT ID: NA Change-Id: I2aee1b2519cb9bfd07940bdf5a9fc55d78bba7da Depends-On: Ic1d148824eed95ed65259fc694e52f0729045208 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/44893 Reviewed-by: QABUILD Tested-by: Cvetko MLADENOVSKI <cvetko.mladenovski@seavus.com> Reviewed-by: Viktor MLADENOVSKI <viktor.mladenovski@stericsson.com>
-rw-r--r--Makefile25
-rw-r--r--lcmodule/Makefile47
-rw-r--r--lcmodule/source/LCM.rc6
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_protocol.h2
-rwxr-xr-xlcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_speedflash.h2
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/r_bulk_protocol.h2
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/r_command_protocol.h2
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_header.h4
-rw-r--r--lcmodule/source/cnh1605551_ldr_utilities/include/r_debug_macro.h2
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/include/r_communication_service.h2
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c2
-rw-r--r--lcmodule/source/legacy_compatibility/c_compiler.h2
-rw-r--r--lcmodule/source/serialization.c1
-rw-r--r--source/LCDriver.h2
-rw-r--r--source/LCDriver.rc6
-rw-r--r--source/LCM/Hash.cpp3
-rw-r--r--source/LCM/include/c_compiler.h2
-rw-r--r--source/LCM/include/t_basicdefinitions.h2
-rw-r--r--source/LCM/include/t_r15_header.h4
-rw-r--r--source/LcdVersion.cpp2
-rw-r--r--source/api_wrappers/linux/CEventObject.cpp51
-rw-r--r--source/api_wrappers/linux/CEventObject.h2
-rw-r--r--source/api_wrappers/linux/CSemaphore.cpp48
-rw-r--r--source/api_wrappers/linux/CSemaphore.h2
-rw-r--r--source/api_wrappers/linux/CSemaphoreQueue.cpp4
-rw-r--r--source/api_wrappers/linux/CThreadWrapper.cpp10
-rw-r--r--source/api_wrappers/linux/CThreadWrapper.h3
-rw-r--r--source/api_wrappers/linux/CWaitableObjectCollection.cpp13
-rw-r--r--source/api_wrappers/linux/OS.cpp18
-rw-r--r--source/api_wrappers/linux/Types.h3
-rw-r--r--source/api_wrappers/linux/sdf0
-rw-r--r--source/utilities/BulkHandler.cpp2
-rw-r--r--source/utilities/CaptiveThreadObject.h2
-rw-r--r--source/utilities/MemMappedFile.cpp6
-rw-r--r--source/utilities/ObjectList.h2
35 files changed, 186 insertions, 100 deletions
diff --git a/Makefile b/Makefile
index 7ee4887..7a7ae08 100644
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,13 @@ LCD_CONFIG:=./source/config/
LCD_DIR:=./
WIN_BINARIES=./win_binaries/
+OS_NAME := $(shell uname)
+ifeq ($(OS_NAME), Linux)
+LIB_EXTENSION := so
+else
+LIB_EXTENSION := dylib
+endif
+
LIBSRC := \
source/utilities/Serialization.cpp\
source/utilities/Logger.cpp\
@@ -73,7 +80,7 @@ INCLUDES := \
# C++ compiler flags (-g -O2 -Wall)
CXXFLAGS := -c -O2 -Wall -fPIC -fvisibility=hidden -fno-strict-aliasing -DLCDRIVER_EXPORTS -D_FILE_OFFSET_BITS=64
-LDFLAGS := -fPIC -fvisibility=hidden -lpthread -lrt -ldl -shared -Wl,-soname,liblcdriver.so
+LDFLAGS := -fPIC -fvisibility=hidden -lpthread -ldl -shared -Wl -o liblcdriver.$(LIB_EXTENSION)
LBITS := $(shell getconf LONG_BIT)
ifeq ($(LBITS),64)
@@ -252,8 +259,8 @@ configfile: $(if $(wildcard $(config_file)),,config)
.PHONY: config
config: BUILDFOLDER := $(LCD_DIR)/out
config: AUTO_DIR_LIB :=$(BUILDFOLDER)/autogen/
-config: LIB_x32 := $(BUILDFOLDER)/liblcdriver.so
-config: LIB_x64 := $(BUILDFOLDER)/liblcdriver_x64.so
+config: LIB_x32 := $(BUILDFOLDER)/liblcdriver.$(LIB_EXTENSION)
+config: LIB_x64 := $(BUILDFOLDER)/liblcdriver_x64.$(LIB_EXTENSION)
config: LIB_x32_OBJ_DIR := x32
config: LIB_x64_OBJ_DIR := x64
config: CXX := $(CROSS_PREFIX)g++
@@ -280,22 +287,20 @@ config:
@echo "LCD_INSTALLDIR := $(LCD_INSTALLDIR)" >> $(config_file)
install: build
- install -m 0755 -t $(LCD_INSTALLDIR) $(BUILDFOLDER)/liblcdriver.so
+ install -m 0755 $(BUILDFOLDER)/liblcdriver.$(LIB_EXTENSION) $(LCD_INSTALLDIR)
ifeq ($(LBITS),64)
- install -m 0755 -t $(LCD_INSTALLDIR) $(BUILDFOLDER)/liblcdriver_x64.so
+ install -m 0755 $(BUILDFOLDER)/liblcdriver_x64.$(LIB_EXTENSION) $(LCD_INSTALLDIR)
endif
- install -m 0755 -t $(LCD_INSTALLDIR) $(WIN_BINARIES)/*.dll
+ install -m 0755 $(WIN_BINARIES)/*.dll $(LCD_INSTALLDIR)
clean:
$(if $(BUILDFOLDER), \
$(if $(LIB_x32_OBJ_DIR), \
- @rm -f $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/*.o \
@rm -rf $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR) \
@rm -rf $(BUILDFOLDER),),)
ifeq ($(LBITS),64)
$(if $(BUILDFOLDER), \
$(if $(LIB_x64_OBJ_DIR), \
- @rm -f $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/*.o \
@rm -rf $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR) \
@rm -rf $(BUILDFOLDER),),)
endif
@@ -308,10 +313,10 @@ distclean: clean
@rm -f $(AUTO_DIR_LIB)/*.cpp \
@rm -f $(AUTO_DIR_LIB)/*.h,)
$(if $(LCD_INSTALLDIR), \
- @rm -f $(LCD_INSTALLDIR)/liblcdriver.so,)
+ @rm -f $(LCD_INSTALLDIR)/liblcdriver.$(LIB_EXTENSION),)
ifeq ($(LBITS),64)
$(if $(LCD_INSTALLDIR), \
- @rm -f $(LCD_INSTALLDIR)/liblcdriver_x64.so,)
+ @rm -f $(LCD_INSTALLDIR)/liblcdriver_x64.$(LIB_EXTENSION),)
endif
$(if $(config_file), \
@rm -f $(config_file),)
diff --git a/lcmodule/Makefile b/lcmodule/Makefile
index a664c0e..ede3f3f 100644
--- a/lcmodule/Makefile
+++ b/lcmodule/Makefile
@@ -19,6 +19,13 @@ LCM_CUST_CONFIG:=$(LCM_PATH)/customer_config
SUPPORTED_CMDS_PATH:=$(LOADER_DIR)/src/platform_support/stn8500/config/supported_commands.xml
WIN_BINARIES=./win_binaries/
+OS_NAME := $(shell uname)
+ifeq ($(OS_NAME), Linux)
+LIB_EXTENSION := so.1
+else
+LIB_EXTENSION := dylib
+endif
+
AUTOGEN_FILES := $(AUTO_DIR_LIB)/commands.h\
$(AUTO_DIR_LIB)/command_ids.h\
$(AUTO_DIR_LIB)/error_codes.h\
@@ -81,7 +88,7 @@ INCLUDES := -I. \
-I ${UTILITIES_PATH}/communication_abstraction/\
-I ${BUFFERS_PATH}/include/\
-I ${SECURITY_ALGORITHMS_PATH}/include/\
- -I ${LCM_PATH}/source/legacy_compatibility/
+ -I ${LCM_PATH}/source/legacy_compatibility/\
# C compiler flags (-g -O2 -Wall)
CFLAGS := -g -O2 -Wall -fPIC -fvisibility=hidden -DUINT64_SUPPORTED -DSINT64_SUPPORTED -DINT64_BASE_TYPE="long long" -DCFG_ENABLE_A2_FAMILY -DLCM_EXPORTS
@@ -100,10 +107,10 @@ build: configfile setup_folders $(LIB_x32)
endif
$(LIB_x32): $(LIBOBJ_x32)
- $(CC) -shared -m32 -Wl,-soname,$(LIB_x32) -o $(LIB_x32) -lc $(addprefix $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/, $(^F))
+ $(CC) -shared -m32 -Wl -o $(LIB_x32) -lc $(addprefix $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/, $(^F))
$(LIB_x64): $(LIBOBJ_x64)
- $(CC) -shared -Wl,-soname,$(LIB_x64) -o $(LIB_x64) -lc $(addprefix $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/, $(^F))
+ $(CC) -shared -Wl -o $(LIB_x64) -lc $(addprefix $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/, $(^F))
$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: ${TRANSPORT_PATH}/source/%.c $(AUTOGEN_FILES)
@mkdir -p $(dir $@)
@@ -276,8 +283,8 @@ config: BUILDFOLDER := $(LCM_PATH)/out
config: LCM_AUTO_DIR:=$(BUILDFOLDER)/autogen
config: AUTO_DIR_LIB:=$(LCM_AUTO_DIR)/lib
config: AUTO_DIR_LOADER:=$(LCM_AUTO_DIR)/loader
-config: LIB_x32 := $(BUILDFOLDER)/liblcm.so.1
-config: LIB_x64 := $(BUILDFOLDER)/liblcm_x64.so.1
+config: LIB_x32 := $(BUILDFOLDER)/liblcm.$(LIB_EXTENSION)
+config: LIB_x64 := $(BUILDFOLDER)/liblcm_x64.$(LIB_EXTENSION)
config: LCMLIB_INSTALLDIR := /tmp/
config: LCMLDR_INSTALLDIR := /tmp/
config: LIB_x32_OBJ_DIR := x32
@@ -316,30 +323,30 @@ config:
@echo CONFIG_DIR : $(CONFIG_DIR)
install: build
- install -p -m 0755 -t ${LCMLIB_INSTALLDIR} ${BUILDFOLDER}/liblcm.so.*
+ install -p -m 0755 ${BUILDFOLDER}/liblcm.$(LIB_EXTENSION) ${LCMLIB_INSTALLDIR}
ifeq ($(LBITS),64)
- install -p -m 0755 -t ${LCMLIB_INSTALLDIR} ${BUILDFOLDER}/liblcm_x64.so.*
+ install -p -m 0755 ${BUILDFOLDER}/liblcm_x64.$(LIB_EXTENSION) ${LCMLIB_INSTALLDIR}
endif
- install -p -m 0755 -t $(LCMLIB_INSTALLDIR) $(WIN_BINARIES)/*.dll
- install -p -m 0555 -t ${LCMLDR_INSTALLDIR} ${AUTO_DIR_LOADER}/*
- install -p -m 0555 -t ${LCMLDR_INSTALLDIR} ${TRANSPORT_PATH}/source/*.c
- install -p -m 0555 -t ${LCMLDR_INSTALLDIR} ${NETWORK_PATH}/source/*.c
- install -p -m 0555 -t ${LCMLDR_INSTALLDIR} ${LCM_CNH_PATH}/source/*.c
- install -p -m 0555 -t ${LCMLDR_INSTALLDIR} ${TRANSPORT_PATH}/include/*.h
- install -p -m 0555 -t ${LCMLDR_INSTALLDIR} ${NETWORK_PATH}/include/*.h
- install -p -m 0555 -t ${LCMLDR_INSTALLDIR} ${LCM_CNH_PATH}/include/*.h
- install -p -m 0555 -t ${LCMLDR_INSTALLDIR} ${LCM_PATH}/source/serialization.c
+ install -p -m 0755 $(WIN_BINARIES)/*.dll ${LCMLIB_INSTALLDIR}
+ install -p -m 0555 ${AUTO_DIR_LOADER}/* ${LCMLDR_INSTALLDIR}
+ install -p -m 0555 ${TRANSPORT_PATH}/source/*.c ${LCMLDR_INSTALLDIR}
+ install -p -m 0555 ${NETWORK_PATH}/source/*.c ${LCMLDR_INSTALLDIR}
+ install -p -m 0555 ${LCM_CNH_PATH}/source/*.c ${LCMLDR_INSTALLDIR}
+ install -p -m 0555 ${TRANSPORT_PATH}/include/*.h ${LCMLDR_INSTALLDIR}
+ install -p -m 0555 ${NETWORK_PATH}/include/*.h ${LCMLDR_INSTALLDIR}
+ install -p -m 0555 ${LCM_CNH_PATH}/include/*.h ${LCMLDR_INSTALLDIR}
+ install -p -m 0555 ${LCM_PATH}/source/serialization.c ${LCMLDR_INSTALLDIR}
clean:
$(if ${BUILDFOLDER}, \
$(if ${LIB_x32_OBJ_DIR}, \
- @rm -f ${BUILDFOLDER}/${LIB_x32_OBJ_DIR}/*.o \
+ @rm -rf ${BUILDFOLDER}/${LIB_x32_OBJ_DIR}/*.o \
@rm -rf ${BUILDFOLDER}/${LIB_x32_OBJ_DIR} \
@rm -rf ${BUILDFOLDER},),)
ifeq ($(LBITS),64)
$(if ${BUILDFOLDER}, \
$(if ${LIB_x64_OBJ_DIR}, \
- @rm -f ${BUILDFOLDER}/${LIB_x64_OBJ_DIR}/*.o \
+ @rm -rf ${BUILDFOLDER}/${LIB_x64_OBJ_DIR}/*.o \
@rm -rf ${BUILDFOLDER}/${LIB_x64_OBJ_DIR} \
@rm -rf ${BUILDFOLDER},),)
endif
@@ -441,10 +448,10 @@ distclean: clean
@rm -f ${LCMLDR_INSTALLDIR}/z_transport.c \
@rm -f ${LCMLDR_INSTALLDIR}/r15_transport_layer.c \
@rm -f ${LCMLDR_INSTALLDIR}/t_a2_network.h \
- @rm -f ${LCMLIB_INSTALLDIR}/liblcm.so.*,)
+ @rm -f ${LCMLIB_INSTALLDIR}/liblcm.$(LIB_EXTENSION),)
ifeq ($(LBITS),64)
$(if ${LCMLDR_INSTALLDIR}, \
- @rm -f ${LCMLIB_INSTALLDIR}/liblcm_x64.so.*,)
+ @rm -f ${LCMLIB_INSTALLDIR}/liblcm_x64.$(LIB_EXTENSION),)
endif
$(if ${LCM_AUTO_DIR}, \
@rm -rf ${LCM_AUTO_DIR},)
diff --git a/lcmodule/source/LCM.rc b/lcmodule/source/LCM.rc
index f943863..0993ba4 100644
--- a/lcmodule/source/LCM.rc
+++ b/lcmodule/source/LCM.rc
@@ -69,15 +69,15 @@ BEGIN
BEGIN
BLOCK "040904b0"
BEGIN
- VALUE "Comments", "Build date: 2012-01-25"
+ VALUE "Comments", "Build date: 2012-02-07"
VALUE "CompanyName", "STEricsson AB"
VALUE "FileDescription", "LCM Dynamic Link Library"
VALUE "FileVersion", "1, 0, 0, 1"
VALUE "InternalName", "Loader Communication Module"
- VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2011"
+ VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2012"
VALUE "PrivateBuild", "Change-Id: I70835353a592d1f1ad40743640a1d0827e56fd2e"
VALUE "ProductName", "CXA1104507 Loader Communication Module"
- VALUE "ProductVersion", "P2Y"
+ VALUE "ProductVersion", "P3Y"
END
END
BLOCK "VarFileInfo"
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_protocol.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_protocol.h
index fc453c2..df59efd 100644
--- a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_protocol.h
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_protocol.h
@@ -31,7 +31,7 @@
#define LCM_API __declspec(dllimport) // import DLL information
#endif // LCM_EXPORTS
-#elif defined(__linux__)
+#elif (defined(__linux__) || defined(__APPLE__))
#ifdef LCM_EXPORTS
#define LCM_API __attribute__((visibility("default")))
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_speedflash.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_speedflash.h
index b36b5f0..525232f 100755
--- a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_speedflash.h
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_speedflash.h
@@ -29,7 +29,7 @@
#define LCM_API __declspec(dllimport) // import DLL information
#endif // LCM_EXPORTS
-#elif defined(__linux__)
+#elif (defined(__linux__) || defined(__APPLE__))
#ifdef LCM_EXPORTS
#define LCM_API __attribute__((visibility("default")))
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_bulk_protocol.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_bulk_protocol.h
index 303161d..fa3f4ee 100644
--- a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_bulk_protocol.h
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_bulk_protocol.h
@@ -37,7 +37,7 @@
#define LCM_API __declspec(dllimport) // import DLL information
#endif // LCM_EXPORTS
-#elif defined(__linux__)
+#elif (defined(__linux__) || defined(__APPLE__))
#ifdef LCM_EXPORTS
#define LCM_API __attribute__((visibility("default")))
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_command_protocol.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_command_protocol.h
index dce0711..d93fb9e 100644
--- a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_command_protocol.h
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_command_protocol.h
@@ -32,7 +32,7 @@
#define LCM_API __declspec(dllimport) // import DLL information
#endif // LCM_EXPORTS
-#elif defined(__linux__)
+#elif (defined(__linux__) || defined(__APPLE__))
#ifdef LCM_EXPORTS
#define LCM_API __attribute__((visibility("default")))
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_header.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_header.h
index f102912..e31ca8c 100644
--- a/lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_header.h
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_header.h
@@ -41,7 +41,11 @@
/** The length of the bulk extended header. */
#define BULK_EXTENDED_HEADER_LENGTH 20
/** Offset of the header in the buffer. */
+#ifndef CFG_ENABLE_LOADER_TYPE
+#define HEADER_OFFSET_IN_BUFFER 0
+#else
#define HEADER_OFFSET_IN_BUFFER 8
+#endif
#define ALIGNED_HEADER_LENGTH ALIGN_SIZE
#define ALIGNED_COMMAND_EXTENDED_HEADER_LENGTH ALIGN_SIZE
diff --git a/lcmodule/source/cnh1605551_ldr_utilities/include/r_debug_macro.h b/lcmodule/source/cnh1605551_ldr_utilities/include/r_debug_macro.h
index 4faf681..adbcad3 100644
--- a/lcmodule/source/cnh1605551_ldr_utilities/include/r_debug_macro.h
+++ b/lcmodule/source/cnh1605551_ldr_utilities/include/r_debug_macro.h
@@ -36,7 +36,7 @@
/*******************************************************************************
* Macro for disabling ARM interrupts. Do nothing for Windows and LINT target.
******************************************************************************/
-#if (defined(WIN32) || defined(CFG_ENABLE_LINT_TARGET_BUILD) || defined(__linux__) || defined(__CYGWIN__))
+#if (defined(WIN32) || defined(CFG_ENABLE_LINT_TARGET_BUILD) || defined(__linux__) || defined(__APPLE__) || defined(__CYGWIN__))
#define INT_DISABLE()
#else
#ifdef MACH_TYPE_DB5700
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/include/r_communication_service.h b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_communication_service.h
index 6d88855..643e067 100644
--- a/lcmodule/source/cnh1606344_ldr_communication_module/include/r_communication_service.h
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_communication_service.h
@@ -31,7 +31,7 @@
#define LCM_API __declspec(dllimport) // import DLL information
#endif // LCM_EXPORTS
-#elif defined(__linux__)
+#elif (defined(__linux__) || defined(__APPLE__))
#ifdef LCM_EXPORTS
#define LCM_API __attribute__((visibility("default")))
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c b/lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c
index d1243f6..ef324cf 100644
--- a/lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c
@@ -13,6 +13,6 @@
* LCD_LCM_CompatibilityList in file LcdVersion.cpp in LCD code.
*/
-char LCM_CurrentVersion[] = "P2Y";
+char LCM_CurrentVersion[] = "P3Y";
/** @} */
diff --git a/lcmodule/source/legacy_compatibility/c_compiler.h b/lcmodule/source/legacy_compatibility/c_compiler.h
index 90799b1..cac45da 100644
--- a/lcmodule/source/legacy_compatibility/c_compiler.h
+++ b/lcmodule/source/legacy_compatibility/c_compiler.h
@@ -84,7 +84,7 @@
#elif defined(__GNUC__)
#ifdef __arm__
#define COMPILER_GCC_ARM
-#elif defined(__linux__)
+#elif (defined(__linux__) || defined(__APPLE__))
/* TARGET IS LINUX */
#define COMPILER_GCC
#endif
diff --git a/lcmodule/source/serialization.c b/lcmodule/source/serialization.c
index 717f847..59725db 100644
--- a/lcmodule/source/serialization.c
+++ b/lcmodule/source/serialization.c
@@ -16,7 +16,6 @@
#include <string.h>
#include <stdlib.h>
#include "r_debug_macro.h"
-
/*******************************************************************************
* Definition of external functions
******************************************************************************/
diff --git a/source/LCDriver.h b/source/LCDriver.h
index b375c5e..0456570 100644
--- a/source/LCDriver.h
+++ b/source/LCDriver.h
@@ -15,7 +15,7 @@
typedef unsigned __int64 uint64;
typedef unsigned long uint32;
-#elif defined(__linux__)
+#elif (defined(__linux__) || defined(__APPLE__))
#ifdef LCDRIVER_EXPORTS
#define LCDRIVER_API __attribute__((visibility("default")))
#else
diff --git a/source/LCDriver.rc b/source/LCDriver.rc
index 83d56ba..06d4ffb 100644
--- a/source/LCDriver.rc
+++ b/source/LCDriver.rc
@@ -81,15 +81,15 @@ BEGIN
BEGIN
BLOCK "000904b0"
BEGIN
- VALUE "Comments", "Build date: 2012-01-25"
+ VALUE "Comments", "Build date: 2012-02-07"
VALUE "CompanyName", "STEricsson AB"
VALUE "FileDescription", "LCDriver Dynamic Link Library"
VALUE "FileVersion", "1, 0, 0, 1"
VALUE "InternalName", "Loader Communication Driver"
- VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2011"
+ VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2012"
VALUE "PrivateBuild", "Change-Id: I70835353a592d1f1ad40743640a1d0827e56fd2e"
VALUE "ProductName", "CXC 173 0865, LCDriver DLL"
- VALUE "ProductVersion", "P2Y"
+ VALUE "ProductVersion", "P3Y"
END
END
BLOCK "VarFileInfo"
diff --git a/source/LCM/Hash.cpp b/source/LCM/Hash.cpp
index 94fb585..1b6efd5 100644
--- a/source/LCM/Hash.cpp
+++ b/source/LCM/Hash.cpp
@@ -78,7 +78,7 @@ void *Hash::WorkerThread(void *arg)
HashRequest *request = 0;
while (true) {
- RemoveResult result = pThis->m_RequestQueue->RemoveHead(reinterpret_cast<void **>(&request), INFINITE);
+ RemoveResult result = pThis->m_RequestQueue->RemoveHead((void**)(&request), INFINITE);
if (REMOVE_SUCCESS != result) {
break;
@@ -91,7 +91,6 @@ void *Hash::WorkerThread(void *arg)
if (request->Length != 0) {
SecurityAlgorithms::SHA256(request->Data_p, request->Length, request->Hash_p);
}
-
break;
case HASH_CRC16:
diff --git a/source/LCM/include/c_compiler.h b/source/LCM/include/c_compiler.h
index 90799b1..cac45da 100644
--- a/source/LCM/include/c_compiler.h
+++ b/source/LCM/include/c_compiler.h
@@ -84,7 +84,7 @@
#elif defined(__GNUC__)
#ifdef __arm__
#define COMPILER_GCC_ARM
-#elif defined(__linux__)
+#elif (defined(__linux__) || defined(__APPLE__))
/* TARGET IS LINUX */
#define COMPILER_GCC
#endif
diff --git a/source/LCM/include/t_basicdefinitions.h b/source/LCM/include/t_basicdefinitions.h
index 038971d..08c3560 100644
--- a/source/LCM/include/t_basicdefinitions.h
+++ b/source/LCM/include/t_basicdefinitions.h
@@ -75,7 +75,7 @@
#define SINT64_SUPPORTED
#define UINT64_SUPPORTED
#define INT64_BASE_TYPE __int64
-#elif defined(__linux__)
+#elif (defined(__linux__) || defined(__APPLE__))
#define SINT64_SUPPORTED
#define UINT64_SUPPORTED
#define INT64_BASE_TYPE long long
diff --git a/source/LCM/include/t_r15_header.h b/source/LCM/include/t_r15_header.h
index f102912..e31ca8c 100644
--- a/source/LCM/include/t_r15_header.h
+++ b/source/LCM/include/t_r15_header.h
@@ -41,7 +41,11 @@
/** The length of the bulk extended header. */
#define BULK_EXTENDED_HEADER_LENGTH 20
/** Offset of the header in the buffer. */
+#ifndef CFG_ENABLE_LOADER_TYPE
+#define HEADER_OFFSET_IN_BUFFER 0
+#else
#define HEADER_OFFSET_IN_BUFFER 8
+#endif
#define ALIGNED_HEADER_LENGTH ALIGN_SIZE
#define ALIGNED_COMMAND_EXTENDED_HEADER_LENGTH ALIGN_SIZE
diff --git a/source/LcdVersion.cpp b/source/LcdVersion.cpp
index daf7e56..538bba8 100644
--- a/source/LcdVersion.cpp
+++ b/source/LcdVersion.cpp
@@ -18,6 +18,6 @@
* This table contains compatibility information for the versions of LCM.
* Current LCM version is defined in file lcm_version.c in LCM code.
*/
-const char *LCD_LCM_CompatibilityList[] = {"P2Y",
+const char *LCD_LCM_CompatibilityList[] = {"P3Y",
NULL
};
diff --git a/source/api_wrappers/linux/CEventObject.cpp b/source/api_wrappers/linux/CEventObject.cpp
index 5f5acda..6c0f6c3 100644
--- a/source/api_wrappers/linux/CEventObject.cpp
+++ b/source/api_wrappers/linux/CEventObject.cpp
@@ -5,7 +5,8 @@
#include <errno.h>
#include <sys/time.h>
-
+#include <fcntl.h>
+#include <time.h>
#include "Types.h"
#include "CEventObject.h"
#include "OS.h"
@@ -17,7 +18,17 @@
// ******************************************************************************
CEventObject::CEventObject()
{
- sem_init(&m_sem, 0, 0);
+ char sem_name[SEM_NAME_MAX_LENGTH];
+ int sem_nr = 1;
+ while(sem_nr <= SEM_MAX_NR) {
+ snprintf(sem_name, SEM_NAME_MAX_LENGTH, "lcdriversem_%d", sem_nr);
+
+ /* open semaphore with "rw" permissions for everyone - 0666 */
+ m_sem = sem_open(sem_name, O_CREAT | O_EXCL, 0666 , 0);
+ if (m_sem != SEM_FAILED)
+ break;
+ sem_nr++;
+ }
}
// ******************************************************************************
@@ -27,7 +38,7 @@ CEventObject::CEventObject()
// ******************************************************************************
CEventObject::~CEventObject()
{
- sem_destroy(&m_sem);
+ sem_close(m_sem);
}
// ******************************************************************************
@@ -37,7 +48,7 @@ CEventObject::~CEventObject()
// ******************************************************************************
void CEventObject::SetEvent()
{
- sem_post(&m_sem);
+ sem_post(m_sem);
}
// ******************************************************************************
@@ -48,19 +59,35 @@ void CEventObject::SetEvent()
DWORD CEventObject::Wait(DWORD dwTimeout)
{
if (INFINITE == dwTimeout) {
- sem_wait(&m_sem);
- return WAIT_OBJECT_0;
+ sem_wait(m_sem);
} else {
- timespec absolute_time = OS::GetAbsoluteTime(dwTimeout);
+ struct timeval curr_time, start_time;
+ DWORD dwTimePassed = 0;
int ret;
- /* coverity[returned_null] */
- while (-1 == (ret = sem_timedwait(&m_sem, &absolute_time)) && errno == EINTR);
+ gettimeofday(&start_time, NULL);
+
+ /* Try to lock the semaphore */
+ ret = sem_trywait(m_sem);
+ if (ret != 0) {
+ while (dwTimePassed < dwTimeout) {
+ /* Sleep 1ms */
+ OS::Sleep(1);
- if (0 == ret) {
- return WAIT_OBJECT_0;
- } else {
+ /* Try to lock the semaphore again*/
+ ret = sem_trywait(m_sem);
+ if (ret == 0) {
+ return WAIT_OBJECT_0;
+ }
+
+ gettimeofday(&curr_time, NULL);
+
+ dwTimePassed = 1000 * (curr_time.tv_sec - start_time.tv_sec) + \
+ (curr_time.tv_usec - start_time.tv_usec) / 1000;
+ }
return WAIT_TIMEOUT;
}
}
+
+ return WAIT_OBJECT_0;
}
diff --git a/source/api_wrappers/linux/CEventObject.h b/source/api_wrappers/linux/CEventObject.h
index 9c86087..987b33e 100644
--- a/source/api_wrappers/linux/CEventObject.h
+++ b/source/api_wrappers/linux/CEventObject.h
@@ -33,7 +33,7 @@ public:
void UnsetEvent();
DWORD Wait(DWORD dwTimeout = INFINITE);
private:
- sem_t m_sem;
+ sem_t *m_sem;
};
#endif /* _CEVENTOBJECT_H */
diff --git a/source/api_wrappers/linux/CSemaphore.cpp b/source/api_wrappers/linux/CSemaphore.cpp
index 0246091..5dae856 100644
--- a/source/api_wrappers/linux/CSemaphore.cpp
+++ b/source/api_wrappers/linux/CSemaphore.cpp
@@ -3,21 +3,33 @@
* License terms: 3-clause BSD license
******************************************************************************/
-#include <errno.h>
+#include <sys/errno.h>
#include <semaphore.h>
#include <sys/time.h>
+#include <fcntl.h>
#include "Types.h"
#include "CSemaphore.h"
#include "OS.h"
+
CSemaphore::CSemaphore(unsigned int initial_count)
{
- sem_init(&m_semaphore, 0, initial_count);
+ char sem_name[SEM_NAME_MAX_LENGTH];
+ int sem_nr = 1;
+ while(sem_nr <= SEM_MAX_NR) {
+ snprintf(sem_name, SEM_NAME_MAX_LENGTH, "lcdriversem_%d", sem_nr);
+
+ /* open semaphore with "rw" permissions for everyone - 0666 */
+ m_semaphore = sem_open(sem_name, O_CREAT | O_EXCL, 0666 , 0);
+ if (m_semaphore != SEM_FAILED)
+ break;
+ sem_nr++;
+ }
}
CSemaphore::~CSemaphore()
{
- sem_destroy(&m_semaphore);
+ sem_close(m_semaphore);
}
bool CSemaphore::Release(unsigned int count)
@@ -27,7 +39,7 @@ bool CSemaphore::Release(unsigned int count)
}
for (unsigned int i = 0; i < count; ++i) {
- if (sem_post(&m_semaphore)) {
+ if (sem_post(m_semaphore)) {
return false;
}
}
@@ -38,15 +50,33 @@ bool CSemaphore::Release(unsigned int count)
DWORD CSemaphore::Wait(DWORD timeout)
{
if (INFINITE == timeout) {
- sem_wait(&m_semaphore);
+ sem_wait(m_semaphore);
} else {
- timespec absoulute_time = OS::GetAbsoluteTime(timeout);
+ struct timeval curr_time, start_time;
+ DWORD dwTimePassed = 0;
int ret;
- /* coverity[returned_null] */
- while (-1 == (ret = sem_timedwait(&m_semaphore, &absoulute_time)) && errno == EINTR);
+ gettimeofday(&start_time, NULL);
+
+ /* Try to lock the semaphore */
+ ret = sem_trywait(m_semaphore);
+ if (ret != 0) {
+ while (dwTimePassed < timeout) {
+ /* Sleep 1ms */
+ OS::Sleep(1);
+
+ /* Try to lock the semaphore again*/
+ ret = sem_trywait(m_semaphore);
+ if (ret == 0) {
+ return WAIT_OBJECT_0;
+ }
+
+ gettimeofday(&curr_time, NULL);
+
+ dwTimePassed = 1000 * (curr_time.tv_sec - start_time.tv_sec) + \
+ (curr_time.tv_usec - start_time.tv_usec) / 1000;
+ }
- if (0 != ret) {
return WAIT_TIMEOUT;
}
}
diff --git a/source/api_wrappers/linux/CSemaphore.h b/source/api_wrappers/linux/CSemaphore.h
index 24af4ad..0abe5dd 100644
--- a/source/api_wrappers/linux/CSemaphore.h
+++ b/source/api_wrappers/linux/CSemaphore.h
@@ -19,7 +19,7 @@ public:
DWORD Wait(DWORD timeout = INFINITE);
private:
- sem_t m_semaphore;
+ sem_t* m_semaphore;
};
#endif /* _CSEMAPHORE_H */
diff --git a/source/api_wrappers/linux/CSemaphoreQueue.cpp b/source/api_wrappers/linux/CSemaphoreQueue.cpp
index 0a2f573..448b4ee 100644
--- a/source/api_wrappers/linux/CSemaphoreQueue.cpp
+++ b/source/api_wrappers/linux/CSemaphoreQueue.cpp
@@ -13,7 +13,7 @@
CSemaphoreQueue::CSemaphoreQueue(unsigned int MaxCount) : m_MaximumCount(MaxCount)
{
m_pEventObject = new CEventObject();
- m_pSemaphore = new CSemaphore();
+ m_pSemaphore = new CSemaphore(0);
m_ObjectCollection.Add(m_pEventObject);
m_ObjectCollection.Add(m_pSemaphore);
@@ -62,6 +62,7 @@ RemoveResult CSemaphoreQueue::RemoveHead(void **ppObject, size_t mSecTimeout)
} else {
// Should never occur
assert(false);
+
return REMOVE_CANCEL;;
}
}
@@ -99,6 +100,7 @@ void CSemaphoreQueue::AddToQueueTail(void *pObject)
void *CSemaphoreQueue::RemoveFromQueueHead()
{
void *Object;
+
Object = m_Queue[m_CurrentHead];
IncrementHead();
return Object;
diff --git a/source/api_wrappers/linux/CThreadWrapper.cpp b/source/api_wrappers/linux/CThreadWrapper.cpp
index 4fe9362..5d38fcf 100644
--- a/source/api_wrappers/linux/CThreadWrapper.cpp
+++ b/source/api_wrappers/linux/CThreadWrapper.cpp
@@ -35,6 +35,7 @@ CThreadWrapper::CThreadWrapper(void *(*pStartAddress)(void *), void *pArgument)
m_pStartAddress = pStartAddress;
m_pArgument = pArgument;
m_tid = (pthread_t)0;
+ m_ThreadEndedEvt = new CEventObject();
}
// ******************************************************************************
@@ -44,6 +45,7 @@ CThreadWrapper::CThreadWrapper(void *(*pStartAddress)(void *), void *pArgument)
// ******************************************************************************
CThreadWrapper::~CThreadWrapper()
{
+ delete m_ThreadEndedEvt;
}
// ******************************************************************************
@@ -53,8 +55,8 @@ CThreadWrapper::~CThreadWrapper()
// ******************************************************************************
DWORD CThreadWrapper::Wait(DWORD dwMilliseconds)
{
- if ((int)m_tid != 0) {
- return m_ThreadEndedEvt.Wait(dwMilliseconds);
+ if (m_tid != 0) {
+ return m_ThreadEndedEvt->Wait(dwMilliseconds);
} else {
return WAIT_OBJECT_0;
}
@@ -102,7 +104,7 @@ void *CThreadWrapper::ThreadFunc(void *arg)
pthis->m_pStartAddress(pthis->m_pArgument);
// Thread has finished, set appropriate event here
- pthis->m_ThreadEndedEvt.SetEvent();
+ pthis->m_ThreadEndedEvt->SetEvent();
pthread_detach(pthread_self());
pthis->m_tid = (pthread_t)0;
return NULL;
@@ -115,5 +117,5 @@ void *CThreadWrapper::ThreadFunc(void *arg)
// ******************************************************************************
DWORD CThreadWrapper::GetThreadId()
{
- return (DWORD)m_tid;
+ return (long long)m_tid;
}
diff --git a/source/api_wrappers/linux/CThreadWrapper.h b/source/api_wrappers/linux/CThreadWrapper.h
index e02a6e8..9e0e473 100644
--- a/source/api_wrappers/linux/CThreadWrapper.h
+++ b/source/api_wrappers/linux/CThreadWrapper.h
@@ -10,6 +10,7 @@
#include "CEventObject.h"
#include <pthread.h>
+
typedef void *(*StartAddress_t)(void *);
class CThreadWrapper : public CWaitableObject
@@ -26,7 +27,7 @@ private:
pthread_t m_tid;
StartAddress_t m_pStartAddress;
void *m_pArgument;
- CEventObject m_ThreadEndedEvt;
+ CEventObject *m_ThreadEndedEvt;
protected:
static void *ThreadFunc(void *Arg);
diff --git a/source/api_wrappers/linux/CWaitableObjectCollection.cpp b/source/api_wrappers/linux/CWaitableObjectCollection.cpp
index e48fd1c..9b47bbc 100644
--- a/source/api_wrappers/linux/CWaitableObjectCollection.cpp
+++ b/source/api_wrappers/linux/CWaitableObjectCollection.cpp
@@ -9,6 +9,7 @@
#include "Types.h"
#include "CWaitableObjectCollection.h"
#include <assert.h>
+#include <sys/time.h>
CWaitableObjectCollection::CWaitableObjectCollection()
{
@@ -30,11 +31,9 @@ CWaitableObject *CWaitableObjectCollection::Wait(DWORD dwTimeout)
vector<CWaitableObject *>::iterator it;
DWORD dwTimePassed = 0;
struct timespec ts;
- struct timespec curr_time, start_time;
+ struct timeval curr_time, start_time;
- if (-1 == clock_gettime(CLOCK_REALTIME, &start_time)) {
- return NULL;
- }
+ gettimeofday(&start_time, NULL);
do {
for (it = m_objs.begin(); it != m_objs.end(); ++it) {
@@ -54,12 +53,10 @@ CWaitableObject *CWaitableObjectCollection::Wait(DWORD dwTimeout)
// coverity[returned_null]
while (-1 == nanosleep(&ts, &ts) && EINTR == errno);
- if (-1 == clock_gettime(CLOCK_REALTIME, &curr_time)) {
- return NULL;
- }
+ gettimeofday(&curr_time, NULL);
dwTimePassed = 1000 * (curr_time.tv_sec - start_time.tv_sec) + \
- (curr_time.tv_nsec - start_time.tv_nsec) / 1000000;
+ (curr_time.tv_usec - start_time.tv_usec) / 1000;
} while (dwTimePassed < dwTimeout);
diff --git a/source/api_wrappers/linux/OS.cpp b/source/api_wrappers/linux/OS.cpp
index 55c82bd..6ed6425 100644
--- a/source/api_wrappers/linux/OS.cpp
+++ b/source/api_wrappers/linux/OS.cpp
@@ -5,6 +5,7 @@
#include <time.h>
#include <errno.h>
+#include <sys/time.h>
#include "Types.h"
#include "OS.h"
@@ -31,29 +32,30 @@ void OS::Sleep(DWORD dwMilliseconds)
time_t OS::GetSystemTimeInMs()
{
- timespec systemTime;
- clock_gettime(CLOCK_REALTIME, &systemTime);
- return (systemTime.tv_sec * 1000) + (systemTime.tv_nsec / 1000000);
+ struct timeval current_time;
+
+ gettimeofday(&current_time, NULL);
+
+ return (current_time.tv_sec * 1000) + (current_time.tv_usec / 1000);
}
timespec OS::GetAbsoluteTime(DWORD dwTimeout)
{
timespec absolute_time;
- timespec current_time;
-
+ timeval current_time;
long timeout_nsec;
- clock_gettime(CLOCK_REALTIME, &current_time);
+ gettimeofday(&current_time, NULL);
absolute_time.tv_sec = current_time.tv_sec + (dwTimeout / 1000);
timeout_nsec = (dwTimeout % 1000) * 1000000L;
- if ((1000000000 - current_time.tv_nsec) < timeout_nsec) {
+ if ((1000000000 - current_time.tv_usec * 1000) < timeout_nsec) {
// overflow will occur!
absolute_time.tv_sec++;
}
- absolute_time.tv_nsec = (current_time.tv_nsec + timeout_nsec) % 1000000000;
+ absolute_time.tv_nsec = (current_time.tv_usec * 1000 + timeout_nsec) % 1000000000;
return absolute_time;
}
diff --git a/source/api_wrappers/linux/Types.h b/source/api_wrappers/linux/Types.h
index 14929b4..4f720aa 100644
--- a/source/api_wrappers/linux/Types.h
+++ b/source/api_wrappers/linux/Types.h
@@ -17,5 +17,8 @@ typedef unsigned int DWORD;
#define WINAPI
+#define SEM_NAME_MAX_LENGTH 16
+#define SEM_MAX_NR 1000
+
#endif /* _TYPES_H */
diff --git a/source/api_wrappers/linux/sdf b/source/api_wrappers/linux/sdf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/api_wrappers/linux/sdf
diff --git a/source/utilities/BulkHandler.cpp b/source/utilities/BulkHandler.cpp
index 5eebd61..bd8af8f 100644
--- a/source/utilities/BulkHandler.cpp
+++ b/source/utilities/BulkHandler.cpp
@@ -183,6 +183,7 @@ void BulkHandler::HandleRxSessionEnd(uint16 session, uint32 chunkSize, uint64 of
m_ReceiveQueue.AddTail(m_pBulkVector);
VERIFY_SUCCESS(m_pLcmInterface->BulkCloseSession(m_pBulkVector));
+
#ifdef _BULKDEBUG
m_pLogger->log("BULK: Session closed Session = %u", session);
#endif
@@ -190,7 +191,6 @@ void BulkHandler::HandleRxSessionEnd(uint16 session, uint32 chunkSize, uint64 of
m_Methods->UpdateBulkProgress();
ErrorExit:
-
if (E_SUCCESS != ReturnValue) {
m_Methods->SignalError(ReturnValue);
}
diff --git a/source/utilities/CaptiveThreadObject.h b/source/utilities/CaptiveThreadObject.h
index 12b7b32..9fdcdae 100644
--- a/source/utilities/CaptiveThreadObject.h
+++ b/source/utilities/CaptiveThreadObject.h
@@ -21,7 +21,7 @@
#if defined(WIN32)
#include <windows.h>
#include "WinApiWrappers.h"
-#elif defined(__linux__)
+#elif (defined(__linux__) || defined(__APPLE__))
#include "LinuxApiWrappers.h"
#else
#error "Unknown target"
diff --git a/source/utilities/MemMappedFile.cpp b/source/utilities/MemMappedFile.cpp
index 018a7c0..21eea7b 100644
--- a/source/utilities/MemMappedFile.cpp
+++ b/source/utilities/MemMappedFile.cpp
@@ -7,7 +7,7 @@
#include "MemMappedFile.h"
#if defined(_WIN32)
#include <windows.h>
-#elif defined(__linux__)
+#elif (defined(__linux__) || defined(__APPLE__))
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
@@ -17,6 +17,10 @@ using namespace std;
#error "Unknown target"
#endif
+#ifdef __APPLE__
+#define lseek64 lseek
+#endif
+
MemMappedFile::MemMappedFile(uint32 alignmentLength):
size_(0),
isMapped_(false),
diff --git a/source/utilities/ObjectList.h b/source/utilities/ObjectList.h
index 6151104..11d1ef1 100644
--- a/source/utilities/ObjectList.h
+++ b/source/utilities/ObjectList.h
@@ -19,7 +19,7 @@
#pragma once
#if defined(_WIN32)
#include "WinApiWrappers.h"
-#elif defined(__linux__)
+#elif (defined(__linux__) || defined(__APPLE__))
#include "LinuxApiWrappers.h"
#include <stdio.h>
#include <stdlib.h>