summaryrefslogtreecommitdiff
path: root/lcmodule
diff options
context:
space:
mode:
authorViktor Mladenovski <viktor.mladenovski@stericsson.com>2011-05-20 14:10:59 +0200
committerViktor Mladenovski <viktor.mladenovski@stericsson.com>2011-05-20 14:10:59 +0200
commitf7e95217e936da34d7124aaced590692eb515923 (patch)
tree2d9ef4750a67d9d1dd3fe9180a4fef2929fad54b /lcmodule
Initial contribution of loader_communication
ST-Ericsson ID: 326913 ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10204 Change-Id: I171cfc2ee458a8a0a91a1916137d131f0f7ecee5
Diffstat (limited to 'lcmodule')
-rw-r--r--lcmodule/Makefile457
-rw-r--r--lcmodule/customer_config/custom_command_ids_h.xsl45
-rw-r--r--lcmodule/customer_config/custom_command_marshal.xsl193
-rw-r--r--lcmodule/customer_config/custom_commands.xml72
-rw-r--r--lcmodule/customer_config/custom_commands_h.xsl46
-rw-r--r--lcmodule/customer_config/custom_commands_impl_h.xsl49
-rw-r--r--lcmodule/customer_config/custom_common.xsl144
-rw-r--r--lcmodule/source/LCM.rc104
-rw-r--r--lcmodule/source/LCM.vcproj679
-rw-r--r--lcmodule/source/cnh1605203_ldr_communication_buffer/include/t_communication_buffer.h26
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_protocol.h83
-rwxr-xr-xlcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_speedflash.h88
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_transport.h56
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/r_bulk_protocol.h198
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/r_command_protocol.h94
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/r_protrom_protocol.h43
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/r_protrom_transport.h55
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/r_r15_transport_layer.h96
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/r_z_protocol.h45
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/r_z_transport.h74
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/t_a2_protocol.h48
-rwxr-xr-xlcmodule/source/cnh1605204_ldr_transport_layer/include/t_a2_speedflash.h50
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/t_a2_transport.h46
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/t_bulk_protocol.h155
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/t_command_protocol.h73
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/t_protrom_protocol.h36
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/t_protrom_transport.h44
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/t_r15_transport_layer.h72
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/include/t_z_protocol.h40
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_protocol.c309
-rwxr-xr-xlcmodule/source/cnh1605204_ldr_transport_layer/source/a2_speedflash.c156
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_transport.c197
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c1461
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/source/command_protocol.c311
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/source/protrom_protocol.c83
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/source/protrom_transport.c149
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/source/r15_transport_layer.c309
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/source/z_transport.c120
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204.c654
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204.h15
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204_utilities.c111
-rw-r--r--lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204_utilities.h15
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/r_a2_header.h85
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/r_a2_network.h135
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/r_protrom_header.h86
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/r_protrom_network.h87
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/r_r15_header.h135
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/r_r15_network_layer.h151
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/r_z_network.h106
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/t_a2_header.h62
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/t_a2_network.h181
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/t_protrom_header.h63
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/t_protrom_network.h103
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_header.h101
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_network_layer.h314
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/t_z_header.h32
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/include/t_z_network.h79
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/source/a2_header.c201
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/source/a2_network.c599
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_header.c237
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_network.c380
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/source/r15_header.c325
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/source/r15_network_layer.c931
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/source/z_network.c166
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205.c553
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205.h15
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205_utilities.c111
-rw-r--r--lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205_utilities.h15
-rw-r--r--lcmodule/source/cnh1605551_ldr_utilities/debug_subsystem/r_debug_subsystem.h93
-rw-r--r--lcmodule/source/cnh1605551_ldr_utilities/debug_subsystem/t_debug_subsystem.h29
-rw-r--r--lcmodule/source/cnh1605551_ldr_utilities/include/r_debug_macro.h187
-rw-r--r--lcmodule/source/cnh1605551_ldr_utilities/include/r_memmory_utils.h67
-rw-r--r--lcmodule/source/cnh1605551_ldr_utilities/include/r_queue.h275
-rw-r--r--lcmodule/source/cnh1605551_ldr_utilities/include/r_serialization.h380
-rw-r--r--lcmodule/source/cnh1605551_ldr_utilities/include/t_queue.h45
-rw-r--r--lcmodule/source/cnh1605551_ldr_utilities/include/t_serialization.h39
-rw-r--r--lcmodule/source/cnh1605551_ldr_utilities/source/serialization.c329
-rw-r--r--lcmodule/source/cnh1605720_ldr_time_utilities/include/t_time_utilities.h45
-rw-r--r--lcmodule/source/cnh1605721_ldr_security_algorithms/include/t_security_algorithms.h44
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/a2_command_ids_h.xsl70
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/a2_command_marshal.xsl251
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/a2_commands.xml637
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/a2_commands_h.xsl47
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/a2_commands_impl_h.xsl49
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/a2_common.xsl237
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/audit_c.xsl323
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/audit_h.xsl70
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/ces_commands_c.xsl122
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/ces_commands_h.xsl58
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/command_ids_h.xsl86
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/command_marshal.xsl354
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/commands.xml1191
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/commands_h.xsl53
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/commands_impl_h.xsl58
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/common.xsl246
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/error_codes.xml873
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/config/errorcode_h.xsl120
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/include/r_a2_family.h62
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/include/r_communication_service.h226
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/include/r_measurement_tool.h159
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/include/r_protrom_family.h65
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/include/r_r15_family.h68
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/include/r_z_family.h72
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/include/t_a2_family.h45
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/include/t_communication_service.h346
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/include/t_measurement_tool.h89
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/include/t_r15_family.h44
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/source/a2_family.c159
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/source/communication_service.c583
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/source/measurement_tool.c658
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/source/protrom_family.c151
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/source/r15_family.c159
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/source/z_family.c142
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344.c289
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344.h15
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344_utilities.c111
-rw-r--r--lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344_utilities.h15
-rw-r--r--lcmodule/source/legacy_compatibility/c_compiler.h124
-rw-r--r--lcmodule/source/legacy_compatibility/c_system.h34
-rw-r--r--lcmodule/source/legacy_compatibility/r_basicdefinitions.h168
-rw-r--r--lcmodule/source/legacy_compatibility/r_debug.h360
-rw-r--r--lcmodule/source/legacy_compatibility/t_basicdefinitions.h280
-rw-r--r--lcmodule/source/resource.h21
-rw-r--r--lcmodule/source/serialization.c323
-rw-r--r--lcmodule/test_cases/ADbg_cnh1606344.c287
-rw-r--r--lcmodule/test_cases/ADbg_cnh1606344.h15
-rw-r--r--lcmodule/test_cases/ADbg_cnh1606344_utilities.c111
-rw-r--r--lcmodule/test_cases/ADbg_cnh1606344_utilities.h15
-rw-r--r--lcmodule/tools/xalan-j_2_7_1/.dummy_file1
-rwxr-xr-xlcmodule/win_binaries/LCM.dllbin0 -> 81920 bytes
130 files changed, 23929 insertions, 0 deletions
diff --git a/lcmodule/Makefile b/lcmodule/Makefile
new file mode 100644
index 0000000..2c057e2
--- /dev/null
+++ b/lcmodule/Makefile
@@ -0,0 +1,457 @@
+ifeq ($(CONFIG_DIR),)
+ config_file=.config
+else
+ config_file=$(CONFIG_DIR)/.config
+endif
+
+-include $(config_file)
+
+LCM_PATH:=./
+TRANSPORT_PATH:=${LCM_PATH}/source/cnh1605204_ldr_transport_layer/
+NETWORK_PATH:=${LCM_PATH}/source/cnh1605205_ldr_network_layer/
+LCM_CNH_PATH:=${LCM_PATH}/source/cnh1606344_ldr_communication_module/
+UTILITIES_PATH:=$(LOADER_DIR)/src/loader_code_base/cnh1605551_ldr_utilities
+TIME_UTILITIES_PATH:=$(LOADER_DIR)/src/loader_code_base/cnh1605720_ldr_time_utilities
+BUFFERS_PATH:=$(LOADER_DIR)/src/loader_code_base/cnh1605203_ldr_communication_buffer
+SECURITY_ALGORITHMS_PATH:=$(LOADER_DIR)/src/loader_code_base/cnh1605721_ldr_security_algorithms
+LCM_CONFIG:=$(LCM_CNH_PATH)/config
+LCM_CUST_CONFIG:=$(LCM_PATH)/customer_config
+SUPPORTED_CMDS_PATH:=$(LOADER_DIR)/src/platform_support/stn8500/config/supported_commands.xml
+WIN_BINARIES=./win_binaries/
+
+AUTOGEN_FILES := $(AUTO_DIR_LIB)/commands.h\
+ $(AUTO_DIR_LIB)/command_ids.h\
+ $(AUTO_DIR_LIB)/error_codes.h\
+ $(AUTO_DIR_LIB)/command_marshal.c\
+ $(AUTO_DIR_LOADER)/error_codes.h\
+ $(AUTO_DIR_LOADER)/audit.h\
+ $(AUTO_DIR_LOADER)/audit.c\
+ $(AUTO_DIR_LOADER)/command_ids.h\
+ $(AUTO_DIR_LOADER)/commands_impl.h\
+ $(AUTO_DIR_LOADER)/commands.h\
+ $(AUTO_DIR_LOADER)/command_marshal.c\
+ $(AUTO_DIR_LOADER)/custom_command_ids.h\
+ $(AUTO_DIR_LOADER)/custom_commands_impl.h\
+ $(AUTO_DIR_LOADER)/custom_commands.h\
+ $(AUTO_DIR_LOADER)/custom_command_marshal.c\
+ $(AUTO_DIR_LOADER)/ces_commands.c\
+ $(AUTO_DIR_LOADER)/ces_commands.h
+
+
+LIBSRC :=${TRANSPORT_PATH}/source/bulk_protocol.c\
+ ${TRANSPORT_PATH}/source/command_protocol.c\
+ ${TRANSPORT_PATH}/source/protrom_protocol.c\
+ ${TRANSPORT_PATH}/source/protrom_transport.c\
+ ${TRANSPORT_PATH}/source/r15_transport_layer.c\
+ ${TRANSPORT_PATH}/source/a2_transport.c\
+ ${TRANSPORT_PATH}/source/a2_protocol.c\
+ ${TRANSPORT_PATH}/source/a2_speedflash.c\
+ ${TRANSPORT_PATH}/source/z_transport.c\
+ ${NETWORK_PATH}/source/a2_header.c\
+ ${NETWORK_PATH}/source/a2_network.c\
+ ${NETWORK_PATH}/source/r15_header.c\
+ ${NETWORK_PATH}/source/r15_network_layer.c\
+ ${NETWORK_PATH}/source/z_network.c\
+ ${NETWORK_PATH}/source/protrom_header.c\
+ ${NETWORK_PATH}/source/protrom_network.c\
+ ${LCM_CNH_PATH}/source/communication_service.c\
+ ${LCM_CNH_PATH}/source/protrom_family.c\
+ ${LCM_CNH_PATH}/source/z_family.c\
+ ${LCM_CNH_PATH}/source/r15_family.c\
+ ${LCM_CNH_PATH}/source/a2_family.c\
+ ${LCM_PATH}/source/serialization.c
+
+LIBOBJ_x32 := $(addprefix $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/, $(notdir $(LIBSRC:.c=.o)))
+LIBOBJ_x64 := $(addprefix $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/, $(notdir $(LIBSRC:.c=.o)))
+
+ #-I ${AUTO_DIR)\
+ # -I ${LCM_PATH}/include/
+#include directories
+INCLUDES := -I. \
+ -I $(AUTO_DIR_LIB)\
+ -I $(AUTO_DIR_LOADER)\
+ -I ${TRANSPORT_PATH}/include/\
+ -I ${NETWORK_PATH}/include/\
+ -I ${LCM_CNH_PATH}/include/\
+ -I ${TIME_UTILITIES_PATH}/include/\
+ -I ${UTILITIES_PATH}/include/\
+ -I ${UTILITIES_PATH}/communication_abstraction/\
+ -I ${BUFFERS_PATH}/include/\
+ -I ${SECURITY_ALGORITHMS_PATH}/include/\
+ -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
+
+LBITS := $(shell getconf LONG_BIT)
+ifeq ($(LBITS),64)
+#
+# do 64 bit stuff here, like set some CFLAGS
+#
+build: configfile setup_folders $(LIB_x32) $(LIB_x64)
+else
+#
+# do 32 bit stuff here
+#
+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))
+
+$(LIB_x64): $(LIBOBJ_x64)
+ $(CC) -shared -Wl,-soname,$(LIB_x64) -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 $@)
+ $(CC) $(INCLUDES) $(CFLAGS) -c -m32 $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: ${NETWORK_PATH}/source/%.c $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CC) $(INCLUDES) $(CFLAGS) -c -m32 $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: ${LCM_CNH_PATH}/source/%.c $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CC) $(INCLUDES) $(CFLAGS) -c -m32 $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: ${LCM_PATH}/source/%.c $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CC) $(INCLUDES) $(CFLAGS) -c -m32 $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: ${TRANSPORT_PATH}/source/%.c $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: ${NETWORK_PATH}/source/%.c $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: ${LCM_CNH_PATH}/source/%.c $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: ${LCM_PATH}/source/%.c $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)
+
+#Autogen files
+$(AUTO_DIR_LIB)/commands.h: $(LCM_CONFIG)/commands.xml $(LCM_CONFIG)/commands_h.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/commands.xml -xsl $(LCM_CONFIG)/commands_h.xsl -out $@ -PARAM target lcm
+
+$(AUTO_DIR_LIB)/command_ids.h: $(LCM_CONFIG)/commands.xml $(LCM_CONFIG)/command_ids_h.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/commands.xml -xsl $(LCM_CONFIG)/command_ids_h.xsl -out $@ -PARAM target lcm
+
+$(AUTO_DIR_LIB)/error_codes.h: $(LCM_CONFIG)/error_codes.xml $(LCM_CONFIG)/errorcode_h.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/error_codes.xml -xsl $(LCM_CONFIG)/errorcode_h.xsl -out $@
+
+$(AUTO_DIR_LIB)/command_marshal.c: $(LCM_CONFIG)/commands.xml $(LCM_CONFIG)/command_marshal.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/commands.xml -xsl $(LCM_CONFIG)/command_marshal.xsl -out $@ -PARAM target lcm
+
+$(AUTO_DIR_LOADER)/error_codes.h: $(LCM_CONFIG)/error_codes.xml $(LCM_CONFIG)/errorcode_h.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/error_codes.xml -xsl $(LCM_CONFIG)/errorcode_h.xsl -out $@ -param supportedCommands $(SUPPORTED_CMDS_PATH)
+
+$(AUTO_DIR_LOADER)/audit.h: $(LCM_CONFIG)/commands.xml $(LCM_CONFIG)/audit_h.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/commands.xml -xsl $(LCM_CONFIG)/audit_h.xsl -out $@ -param supportedCommands $(SUPPORTED_CMDS_PATH)
+
+$(AUTO_DIR_LOADER)/audit.c: $(LCM_CONFIG)/commands.xml $(LCM_CONFIG)/audit_c.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/commands.xml -xsl $(LCM_CONFIG)/audit_c.xsl -out $@ -param supportedCommands $(SUPPORTED_CMDS_PATH)
+
+$(AUTO_DIR_LOADER)/command_ids.h: $(LCM_CONFIG)/commands.xml $(LCM_CONFIG)/command_ids_h.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/commands.xml -xsl $(LCM_CONFIG)/command_ids_h.xsl -out $@ -param supportedCommands $(SUPPORTED_CMDS_PATH)
+
+$(AUTO_DIR_LOADER)/commands_impl.h: $(LCM_CONFIG)/commands.xml $(LCM_CONFIG)/commands_impl_h.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/commands.xml -xsl $(LCM_CONFIG)/commands_impl_h.xsl -out $@ -param supportedCommands $(SUPPORTED_CMDS_PATH)
+
+$(AUTO_DIR_LOADER)/commands.h: $(LCM_CONFIG)/commands.xml $(LCM_CONFIG)/commands_h.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/commands.xml -xsl $(LCM_CONFIG)/commands_h.xsl -out $@ -param supportedCommands $(SUPPORTED_CMDS_PATH)
+
+$(AUTO_DIR_LOADER)/command_marshal.c: $(LCM_CONFIG)/commands.xml $(LCM_CONFIG)/command_marshal.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/commands.xml -xsl $(LCM_CONFIG)/command_marshal.xsl -out $@ -param supportedCommands $(SUPPORTED_CMDS_PATH)
+
+$(AUTO_DIR_LOADER)/ces_commands.c: $(LCM_CONFIG)/commands.xml $(LCM_CONFIG)/ces_commands_c.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/commands.xml -xsl $(LCM_CONFIG)/ces_commands_c.xsl -out $@ -param supportedCommands $(SUPPORTED_CMDS_PATH)
+
+$(AUTO_DIR_LOADER)/ces_commands.h: $(LCM_CONFIG)/commands.xml $(LCM_CONFIG)/ces_commands_h.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CONFIG)/commands.xml -xsl $(LCM_CONFIG)/ces_commands_h.xsl -out $@ -param supportedCommands $(SUPPORTED_CMDS_PATH)
+
+$(AUTO_DIR_LOADER)/custom_command_ids.h: $(LCM_CUST_CONFIG)/custom_commands.xml $(LCM_CUST_CONFIG)/custom_command_ids_h.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CUST_CONFIG)/custom_commands.xml -xsl $(LCM_CUST_CONFIG)/custom_command_ids_h.xsl -out $@
+
+$(AUTO_DIR_LOADER)/custom_commands_impl.h: $(LCM_CUST_CONFIG)/custom_commands.xml $(LCM_CUST_CONFIG)/custom_commands_impl_h.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CUST_CONFIG)/custom_commands.xml -xsl $(LCM_CUST_CONFIG)/custom_commands_impl_h.xsl -out $@
+
+$(AUTO_DIR_LOADER)/custom_commands.h: $(LCM_CUST_CONFIG)/custom_commands.xml $(LCM_CUST_CONFIG)/custom_commands_h.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CUST_CONFIG)/custom_commands.xml -xsl $(LCM_CUST_CONFIG)/custom_commands_h.xsl -out $@
+
+$(AUTO_DIR_LOADER)/custom_command_marshal.c: $(LCM_CUST_CONFIG)/custom_commands.xml $(LCM_CUST_CONFIG)/custom_command_marshal.xsl | setup_folders
+ java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CUST_CONFIG)/custom_commands.xml -xsl $(LCM_CUST_CONFIG)/custom_command_marshal.xsl -out $@
+
+#setting up needed folders
+$(BUILDFOLDER): | configfile
+ @mkdir -p $@ 2> /dev/null
+
+$(BUILDFOLDER)/.builddummy: | $(BUILDFOLDER)
+ @touch $@
+
+$(LCMLDR_INSTALLDIR): | configfile
+ @mkdir -p $@ 2> /dev/null
+
+$(LCMLDR_INSTALLDIR)/.ldrinstalldummy: | $(LCMLDR_INSTALLDIR)
+ @touch $@
+
+$(LCMLIB_INSTALLDIR): | configfile
+ @mkdir -p $@ 2> /dev/null
+
+$(LCMLIB_INSTALLDIR)/.libinstalldummy: | $(LCMLIB_INSTALLDIR)
+ @touch $@
+
+$(AUTO_DIR_LOADER): | configfile
+ @mkdir -p $@ 2> /dev/null
+
+$(AUTO_DIR_LOADER)/.autodirldrdummy: | $(AUTO_DIR_LOADER)
+ @touch $@
+
+$(AUTO_DIR_LIB): | configfile
+ @mkdir -p $@ 2> /dev/null
+
+$(AUTO_DIR_LIB)/.autodirlibdummy: | $(AUTO_DIR_LIB)
+ @touch $@
+
+$(LCM_AUTO_DIR): | configfile
+ @mkdir -p $@ 2> /dev/null
+
+$(LCM_AUTO_DIR)/.autodirdummy : | $(LCM_AUTO_DIR)
+ @touch $@
+
+.PHONY: setup_folders
+setup_folders: validatevariables
+setup_folders: $(BUILDFOLDER)/.builddummy $(LCMLDR_INSTALLDIR)/.ldrinstalldummy $(LCMLIB_INSTALLDIR)/.libinstalldummy
+setup_folders: $(AUTO_DIR_LOADER)/.autodirldrdummy $(AUTO_DIR_LIB)/.autodirlibdummy $(LCM_AUTO_DIR)/.autodirdummy
+ @echo $< > /dev/null
+
+
+
+
+.PHONY: validatevariables
+validatevariables: configfile
+ $(if $(CC),, $(error "CC not set"))
+ $(if $(LOADER_DIR),, $(error "LOADER_DIR not set"))
+ $(if $(BUILDFOLDER),, $(error "BUILDFOLDER not set"))
+ $(if $(AUTO_DIR_LIB),, $(error "AUTO_DIR_LIB not set"))
+ $(if $(LCM_AUTO_DIR),, $(error "LCM_AUTO_DIR not set"))
+ $(if $(AUTO_DIR_LOADER),, $(error "AUTO_DIR_LOADER not set"))
+ $(if $(LCMLIB_INSTALLDIR),, $(error "LCMLIB_INSTALLDIR not set"))
+ $(if $(LCMLDR_INSTALLDIR),, $(error "LCMLDR_INSTALLDIR not set"))
+ $(if $(LIB_x32),, $(error "LIB_x32 not set"))
+ $(if $(LIB_x64),, $(error "LIB_x64 not set"))
+ $(if $(LIB_x32_OBJ_DIR),, $(error "LIB_x32_OBJ_DIR not set"))
+ $(if $(LIB_x64_OBJ_DIR),, $(error "LIB_x64_OBJ_DIR not set"))
+
+#if the wildcard function finds any file matching the name
+#of the configfile then this will result in
+#"configfile: " so the config target will not be unnecessarily
+#called. If however there is no file matching the configfile
+#this will become "configfile: config" and the config target
+#will be called and the configfile created.
+#(calling config directly will always recreate the configfile
+#so any values that has been changed will be overwritten with
+#the new value)
+.PHONY: configfile
+configfile: $(if $(wildcard $(config_file)),,config)
+ @echo $< > /dev/null
+
+.PHONY: config
+config: BUILDFOLDER := $(if $(strip $(BUILDFOLDER)),$(BUILDFOLDER),$(shell bash -c "mktemp -d"))
+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: LCMLIB_INSTALLDIR := /tmp/
+config: LCMLDR_INSTALLDIR := /tmp/
+config: LIB_x32_OBJ_DIR := x32
+config: LIB_x64_OBJ_DIR := x64
+config: CC := gcc
+config: LOADER_DIR := ./
+config:
+ @echo Generating config file...
+ @echo config_file : $(config_file)
+ @rm -f $(config_file)
+ @touch $(config_file)
+ @echo CC: $(CC)
+ @echo "CC := $(CC)" >> $(config_file)
+ @echo LOADER_DIR: $(LOADER_DIR)
+ @echo "LOADER_DIR := $(LOADER_DIR)" >> $(config_file)
+ @echo BUILDFOLDER: $(BUILDFOLDER)
+ @echo "BUILDFOLDER := $(BUILDFOLDER)" >> $(config_file)
+ @echo AUTO_DIR_LIB: $(AUTO_DIR_LIB)
+ @echo "AUTO_DIR_LIB := $(AUTO_DIR_LIB)" >> $(config_file)
+ @echo LCM_AUTO_DIR: $(LCM_AUTO_DIR)
+ @echo "LCM_AUTO_DIR := $(LCM_AUTO_DIR)" >> $(config_file)
+ @echo LCMLIB_INSTALLDIR: $(LCMLIB_INSTALLDIR)
+ @echo "LCMLIB_INSTALLDIR := $(LCMLIB_INSTALLDIR)" >> $(config_file)
+ @echo LCMLDR_INSTALLDIR: $(LCMLDR_INSTALLDIR)
+ @echo "LCMLDR_INSTALLDIR := $(LCMLDR_INSTALLDIR)" >> $(config_file)
+ @echo AUTO_DIR_LOADER: $(AUTO_DIR_LOADER)
+ @echo "AUTO_DIR_LOADER := $(AUTO_DIR_LOADER)" >> $(config_file)
+ @echo LIB_x32: $(LIB_x32)
+ @echo "LIB_x32 := $(LIB_x32)" >> $(config_file)
+ @echo LIB_x64: $(LIB_x64)
+ @echo "LIB_x64 := $(LIB_x64)" >> $(config_file)
+ @echo LIB_x32_OBJ_DIR: $(LIB_x32_OBJ_DIR)
+ @echo "LIB_x32_OBJ_DIR := $(LIB_x32_OBJ_DIR)" >> $(config_file)
+ @echo LIB_x64_OBJ_DIR: $(LIB_x64_OBJ_DIR)
+ @echo "LIB_x64_OBJ_DIR := $(LIB_x64_OBJ_DIR)" >> $(config_file)
+ @echo CONFIG_DIR : $(CONFIG_DIR)
+
+install: build
+ install -p -m 0755 -t ${LCMLIB_INSTALLDIR} ${BUILDFOLDER}/liblcm.so.*
+ifeq ($(LBITS),64)
+ install -p -m 0755 -t ${LCMLIB_INSTALLDIR} ${BUILDFOLDER}/liblcm_x64.so.*
+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
+
+clean:
+ $(if ${BUILDFOLDER}, \
+ $(if ${LIB_x32_OBJ_DIR}, \
+ @rm -f ${BUILDFOLDER}/${LIB_x32_OBJ_DIR}/*.o \
+ @rm -rf ${BUILDFOLDER}/${LIB_x32_OBJ_DIR},),)
+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},),)
+endif
+ $(if ${BUILDFOLDER}, \
+ @rm -f ${BUILDFOLDER}/*.so*,)
+
+distclean: clean
+ $(if ${LCMLDR_INSTALLDIR}, \
+ @rm -f ${LCMLDR_INSTALLDIR}/a2_family.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_a2_family.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_a2_protocol.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/a2_header.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_a2_header.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_a2_transport.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/a2_network.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_a2_network.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_bulk_protocol.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/a2_protocol.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_a2_protocol.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_command_protocol.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/a2_transport.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_a2_transport.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_communication_service.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/audit.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_bulk_protocol.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/ti_family.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/audit.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_command_protocol.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/ti_header.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/bulk_protocol.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_communication_service.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/ti_network.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/command_ids.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_measurement_tool.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/ti_protocol.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/command_marshal.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/ces_commands.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/ces_commands.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_protrom_family.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/ti_transport.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/command_protocol.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_protrom_header.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_measurement_tool.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/commands.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_protrom_network.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_protrom_header.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/commands_impl.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_protrom_protocol.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_protrom_network.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/communication_service.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_protrom_transport.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_protrom_protocol.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/custom_command_ids.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_r15_family.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_protrom_transport.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/custom_command_marshal.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_r15_header.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_r15_family.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/custom_commands.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_r15_network_layer.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_r15_header.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/custom_commands_impl.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_r15_transport_layer.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_r15_network_layer.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/error_codes.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_ti_family.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_r15_transport_layer.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/measurement_tool.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_ti_header.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_ti_header.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/memmap.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_ti_network.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_ti_network.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/protrom_family.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_ti_protocol.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_ti_protocol.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/protrom_header.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_ti_transport.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_ti_transport.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/protrom_network.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_z_family.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_z_header.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/protrom_protocol.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_z_network.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_z_network.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/protrom_transport.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_z_protocol.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_z_protocol.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/r15_family.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r_z_transport.h \
+ @rm -f ${LCMLDR_INSTALLDIR}/z_family.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r15_header.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/serialization.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/z_network.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/r15_network_layer.c \
+ @rm -f ${LCMLDR_INSTALLDIR}/t_a2_header.h \
+ @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.*,)
+ifeq ($(LBITS),64)
+ $(if ${LCMLDR_INSTALLDIR}, \
+ @rm -f ${LCMLIB_INSTALLDIR}/liblcm_x64.so.*,)
+endif
+ $(if ${LCM_AUTO_DIR}, \
+ @rm -rf ${LCM_AUTO_DIR},)
+ $(if $(config_file), \
+ @rm -f $(config_file),)
+
+COV_DATA_DIR=cov_data
+COV_INTER_DATA_DIR=cov_inter
+
+coverity:
+ @if [ -d "$(COV_DATA_DIR)" ]; then \
+ @cov-stop-gui --datadir $(COV_DATA_DIR); \
+ fi
+ @cov-configure --compiler $(CC) --comptype gcc
+ @if [ -d "$(COV_DATA_DIR)" ]; then \
+ echo coverity gui already installed; \
+ else \
+ cov-install-gui --password admin --datadir $(COV_DATA_DIR) --product lcd --domain "C/C++"; \
+ fi
+
+ @cov-build --dir $(COV_INTER_DATA_DIR) $(MAKE) build
+ @cov-analyze --dir $(COV_INTER_DATA_DIR) --aggressiveness-level medium --all
+ @cov-commit-defects --datadir $(COV_DATA_DIR) --product lcd --user admin --dir $(COV_INTER_DATA_DIR)
+ @cov-start-gui --datadir $(COV_DATA_DIR) --port 1122
+ echo Go to localhost port 1122 in webbrowser and login with username admin and password admin to review result
diff --git a/lcmodule/customer_config/custom_command_ids_h.xsl b/lcmodule/customer_config/custom_command_ids_h.xsl
new file mode 100644
index 0000000..e5efe55
--- /dev/null
+++ b/lcmodule/customer_config/custom_command_ids_h.xsl
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+<import href="custom_common.xsl"/>
+
+<output method="text" indent="no"/>
+<strip-space elements="*"/>
+<param name="target" />
+
+<template match="/commandspec">/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _CUSTOM_COMMAND_IDS_H
+#define _CUSTOM_COMMAND_IDS_H
+#include "t_basicdefinitions.h"
+
+<!--
+typedef enum {
+<apply-templates select="group/command" mode="id"/>} CustomCommandId_e;
+-->
+
+<template match="group" mode="id">
+ <text> </text><call-template name="groupid" /> = <choose> <when test="@number&lt;10"> <value-of select="substring-after(@number, '0')" /> </when> <otherwise> <value-of select="@number"/> </otherwise> </choose>, /**&lt; <value-of select="@name" /> */
+</template>
+
+<template match="group[last()]" mode="id">
+ <text> </text><call-template name="groupid" /> = <choose> <when test="@number&lt;10"> <value-of select="substring-after(@number, '0')" /> </when> <otherwise> <value-of select="@number"/> </otherwise> </choose> /**&lt; <value-of select="@name" /> */
+</template>
+
+<template match="command" mode="id">
+ <text> </text><call-template name="commandid" /> = <value-of select="@number" />, /**&lt; <value-of select="@name" /> */
+</template>
+
+<template match="group[last()]/command[last()]" mode="id">
+ <text> </text><call-template name="commandid" /> = <value-of select="@number" /> /**&lt; <value-of select="@name" /> */
+</template>
+
+#endif /* _CUSTOM_COMMAND_IDS_H */
+</template>
+
+</stylesheet>
diff --git a/lcmodule/customer_config/custom_command_marshal.xsl b/lcmodule/customer_config/custom_command_marshal.xsl
new file mode 100644
index 0000000..4ee1838
--- /dev/null
+++ b/lcmodule/customer_config/custom_command_marshal.xsl
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" >
+
+<import href="custom_common.xsl"/>
+
+<output method="text"/>
+<strip-space elements="*"/>
+<param name="target" />
+
+<template match="group/documentation" mode="marshal">
+/*
+ * <value-of select="normalize-space(.)"/>
+ */
+</template>
+
+<template match="group/documentation" mode="unmarshal">
+ /*
+ * <value-of select="normalize-space(.)"/>
+ */
+</template>
+
+<template name="unmarshal">
+<param name="name" />
+<param name="direction" />
+<choose>
+ <when test="@flag='true'">
+#ifdef CFG_ENABLE_ADBG_LOADER</when>
+</choose>
+<choose>
+<when test="name($direction)='input'">
+ /* Command <value-of select="../@name" /> / <value-of select="@name" /> (<value-of select="../@number" /> / <value-of select="@number" />) */
+ case COMMAND(FALSE, <call-template name="groupid" ><with-param name="path" select=".."/></call-template>, <call-template name="commandid" />):
+ { <apply-templates select="input/value" mode="deserialize" />
+ Status = <value-of select="$name" />(<apply-templates select="input/value" mode="call" />);
+ <apply-templates select="input/value" mode="clean" />
+ }
+ break;
+</when>
+<when test="name($direction)='output'">
+ /* Response to <value-of select="../@name" /> / <value-of select="@name" /> (<value-of select="../@number" /> / <value-of select="@number" />) */
+ case COMMAND(TRUE, <call-template name="groupid" ><with-param name="path" select=".."/></call-template>, <call-template name="commandid" />):
+ { <apply-templates select="output/value" mode="deserialize" />
+ Status = <value-of select="$name" />( PL_GRSize, ResponseStatus<if test="count(output/value) > 0">, </if><apply-templates select="output/value" mode="call"></apply-templates>);
+ <apply-templates select="output/value" mode="clean" />
+ }
+ break;
+</when>
+</choose>
+<choose>
+ <when test="@flag='true'">#endif
+ </when>
+</choose>
+</template>
+
+
+<template match="/commandspec">
+/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+#include &lt;string.h&gt;
+
+#include "t_command_protocol.h"
+#include "r_debug.h"
+#include "r_communication_service.h"
+#include "custom_commands.h"
+#include "custom_command_ids.h"
+#include "custom_commands_impl.h"
+#include "error_codes.h"
+#include "r_serialization.h"
+#include "r_command_protocol.h"
+
+
+#define CUSTOMCOMMAND(response, group, id) (((response) &lt;&lt; 31) | ((group) &lt;&lt; 16) | (id))
+#define CUSTOMCOMMANDDATA(TypeP,ApplicationP,CommandP,SessionP,SizeP) \
+ memset((uint8*)&amp;CmdData, 0x00, sizeof(CommandData_t)); \
+ CmdData.Type = TypeP; \
+ CmdData.ApplicationNr = ApplicationP; \
+ CmdData.CommandNr = CommandP; \
+ CmdData.SessionNr = SessionP; \
+ CmdData.Payload.Size = sizeof(ErrorCode_e)+SizeP; \
+ CmdData.Payload.Data_p = NULL; \
+ if(SizeP !=0)\
+ {\
+ CmdData.Payload.Data_p = (uint8 *)malloc(sizeof(ErrorCode_e)+SizeP); \
+ if(NULL == CmdData.Payload.Data_p) \
+ { \
+ A_(printf("command_marshal.c (%d): ** memory allocation failed! **\n",__LINE__);) \
+ return E_ALLOCATE_FAILED; \
+ }\
+ }
+
+#define CUSTOMCOMMANDDATAOUT(TypeP,ApplicationP,CommandP,SizeP) \
+ memset((uint8*)&amp;CmdData, 0x00, sizeof(CommandData_t)); \
+ CmdData.Type = TypeP; \
+ CmdData.ApplicationNr = ApplicationP; \
+ CmdData.CommandNr = CommandP; \
+ CmdData.SessionNr = 0; \
+ CmdData.Payload.Size = SizeP; \
+ CmdData.Payload.Data_p = NULL; \
+ if(SizeP !=0)\
+ {\
+ CmdData.Payload.Data_p = (uint8 *)malloc( SizeP); \
+ if(NULL == CmdData.Payload.Data_p) \
+ { \
+ A_(printf("command_marshal.c (%d): ** memory allocation failed! **\n",__LINE__);) \
+ return E_ALLOCATE_FAILED; \
+ }\
+ }
+
+//static uint16 Session;
+
+ErrorCode_e Do_CustomCEH_Call(CommandData_t * CmdData_p)
+{
+ ErrorCode_e Status = E_GENERAL_FATAL_ERROR;
+// uint32 PL_GRSize = 0;
+// ErrorCode_e ResponseStatus = E_SUCCESS;
+ boolean response = FALSE;
+
+ void *Data_p = CmdData_p-&gt;Payload.Data_p;
+ (void)(Data_p); //XVSZOAN Temporary solution!
+
+ if (CmdData_p-&gt;Type == GENERAL_RESPONSE_PACKAGE)
+ {
+ response = TRUE;
+// PL_GRSize = CmdData_p-&gt;Payload.Size;
+// ResponseStatus = (ErrorCode_e)get_uint16(&amp;Data_p);
+ }
+
+// Session = CmdData_p-&gt;SessionNr;
+
+ switch(CUSTOMCOMMAND(response, CmdData_p-&gt;ApplicationNr, CmdData_p-&gt;CommandNr))
+ {<apply-templates select="group" mode="unmarshal"/>
+ default:
+ break;
+ }
+
+ return Status;
+}
+
+ <apply-templates select="group" mode="marshal"/>
+
+</template>
+
+<template match="group/command" mode="marshal">
+ <if test="contains(@source, 'ME')">
+ErrorCode_e <value-of select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />(uint32 PLSize<if test="count(output/value) > 0">, </if><apply-templates select="input/value" mode="declare" />)
+{
+ CommandData_t CmdData;
+ void *Data_p;
+
+ CUSTOMCOMMANDDATAOUT(COMMAND, <call-template name="groupidmain" />, <call-template name="commandid" />, PLSize);
+ Data_p = CmdData.Payload.Data_p;
+ <apply-templates select="input/value" mode="serialize" />
+ return Do_R15_Command_Send(GlobalCommunication_p, &amp;CmdData);
+}
+</if>
+ <if test="contains(@source, 'PC')">
+ErrorCode_e <value-of select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />(uint32 PLSize, ErrorCode_e Status<if test="count(output/value) > 0">, </if><apply-templates select="output/value" mode="declare"></apply-templates>)
+{
+ CommandData_t CmdData;
+ void *Data_p;
+
+ CUSTOMCOMMANDDATA( GENERAL_RESPONSE, <call-template name="groupidmain" />, <call-template name="commandid" />, Session, PLSize);
+ Data_p = CmdData.Payload.Data_p;
+
+ put_uint32(&amp;Data_p, Status);
+ <apply-templates select="output/value" mode="serialize" />
+ return Do_R15_Command_Send(GlobalCommunication_p, &amp;CmdData);
+}
+ </if>
+</template>
+
+<template match="group/command" mode="unmarshal">
+ <if test="contains(@source, 'PC')">
+ <call-template name="unmarshal">
+ <with-param name="name" select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="input" />
+ </call-template>
+ </if>
+ <if test="contains(@source, 'ME')">
+ <call-template name="unmarshal">
+ <with-param name="name" select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="output" />
+ </call-template>
+ </if>
+</template>
+
+</stylesheet>
diff --git a/lcmodule/customer_config/custom_commands.xml b/lcmodule/customer_config/custom_commands.xml
new file mode 100644
index 0000000..39169d9
--- /dev/null
+++ b/lcmodule/customer_config/custom_commands.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<?xml-stylesheet type="text/xml" href="custom_command_ids_h.xsl"?>
+<?xml-stylesheet type="text/xml" href="custom_command_marshal.xsl"?>
+<?xml-stylesheet type="text/xml" href="custom_commands_h.xsl"?>
+<?xml-stylesheet type="text/xml" href="custom_commands_impl_h.xsl"?>
+<?xml-stylesheet type="text/xml" href="custom_common.xsl"?>
+
+
+<commandspec>
+ <group number="01" name="System application">
+ <documentation>
+ System command group.
+ </documentation>
+ <interface type="loader" name="System" />
+
+ </group>
+
+ <group number="02" name="Flash application">
+ <documentation>
+ Flash command group.
+ </documentation>
+
+ <interface type="loader" name="Flash" />
+
+ </group>
+
+ <group number="03" name="GDFS application ">
+ <documentation>
+ GDFS command group.
+ </documentation>
+
+ <interface type="loader" name="GDFS" />
+
+ </group>
+
+ <group number ="04" name ="FILE Sys application ">
+ <documentation>
+ File System Unit
+ </documentation>
+
+ <interface type="loader" name="File_Management" />
+
+ </group>
+
+ <group number ="05" name ="Signature application ">
+ <documentation>
+ Signature application
+ </documentation>
+
+ <interface type="loader" name="SIGNATURE" />
+ </group>
+
+ <group number ="06" name ="Internal Security application ">
+ <documentation>
+ Internal Security application
+ </documentation>
+
+ <interface type="loader" name="INTERNAL_SECURITY" />
+ </group>
+
+ <group number ="07" name ="Reset application ">
+ <documentation>
+ Reset application
+ </documentation>
+
+ <interface type="loader" name="RESET" />
+ </group>
+</commandspec>
diff --git a/lcmodule/customer_config/custom_commands_h.xsl b/lcmodule/customer_config/custom_commands_h.xsl
new file mode 100644
index 0000000..ed38668
--- /dev/null
+++ b/lcmodule/customer_config/custom_commands_h.xsl
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" >
+
+<import href="custom_common.xsl"/>
+
+<output method="text"/>
+<strip-space elements="*"/>
+<param name="target" />
+
+<template match="/commandspec">/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _CUSTOM_COMMANDS_H
+#define _CUSTOM_COMMANDS_H
+#include "error_codes.h"
+#include "t_command_protocol.h"
+
+ErrorCode_e Do_CustomCEH_Call(CommandData_t *CmdData_p);
+<apply-templates select="group"/>
+#endif /* _CUSTOM_COMMANDS_H */
+</template>
+
+<template match="group/command">
+ <if test="contains(@source, 'ME')">
+ <call-template name="prototype">
+ <with-param name="name" select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />
+ <with-param name="ref" select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="input" />
+ <with-param name="source" select="'ME'" />
+ </call-template>
+ </if>
+ <if test="contains(@source, 'PC')">
+ <call-template name="prototype">
+ <with-param name="name" select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />
+ <with-param name="ref" select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="output" />
+ <with-param name="source" select="'PC'" />
+ </call-template>
+ </if>
+</template>
+
+</stylesheet>
diff --git a/lcmodule/customer_config/custom_commands_impl_h.xsl b/lcmodule/customer_config/custom_commands_impl_h.xsl
new file mode 100644
index 0000000..a62a434
--- /dev/null
+++ b/lcmodule/customer_config/custom_commands_impl_h.xsl
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" >
+
+<import href="custom_common.xsl"/>
+
+<output method="text"/>
+<strip-space elements="*"/>
+<param name="target" />
+
+<template match="/commandspec">/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _CUSTOM_COMMANDS_IMPL_H
+#define _CUSTOM_COMMANDS_IMPL_H
+#include "error_codes.h"
+<apply-templates select="group" />
+#endif /* _CUSTOM_COMMANDS_IMPL_H */
+</template>
+
+<template match="group/documentation">
+/*
+ * <value-of select="normalize-space(.)"/>
+ */
+</template>
+
+<template match="group/command">
+ <if test="contains(@source, 'PC')">
+ <call-template name="prototype">
+ <with-param name="name" select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="ref" select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />
+ <with-param name="direction" select="input" />
+ <with-param name="source" select="'PC'" />
+ </call-template>
+ </if>
+ <if test="contains(@source, 'ME')">
+ <call-template name="prototype">
+ <with-param name="name" select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="ref" select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />
+ <with-param name="direction" select="output" />
+ <with-param name="source" select="'PC'" />
+ </call-template>
+ </if>
+</template>
+
+</stylesheet>
diff --git a/lcmodule/customer_config/custom_common.xsl b/lcmodule/customer_config/custom_common.xsl
new file mode 100644
index 0000000..76f7e5d
--- /dev/null
+++ b/lcmodule/customer_config/custom_common.xsl
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" >
+
+<!-- Ugly name-mangling templates. upper-case() did not work in this
+ implementation -->
+<template name="groupidmain">
+ <param name="path" select="../." />
+ <value-of select="concat('GROUP_', translate($path/interface[@type='loader']/@name,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'))" />
+</template>
+
+
+<template name="groupid">
+ <param name="path" select="." />
+ <value-of select="concat('GROUP_', translate($path/interface[@type='loader']/@name,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'))" />
+</template>
+
+<template name="commandid">
+ <param name="path" select="." />
+ <value-of select="translate(concat('COMMAND_', $path/../interface[@type='loader']/@name, '_', $path/interface[@type='loader']/@name),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
+</template>
+
+
+
+<template match="value" mode="deserialize">
+<choose>
+ <when test="@type='uint32'">
+ uint32 <value-of select="@name" /> = get_uint32(&amp;Data_p);</when>
+ <when test="@type='string'">
+ const char *<value-of select="@name" /> = get_strdup(&amp;Data_p);</when>
+ <when test="@type='buffer' and @length='*'">
+ int <value-of select="@name" />Length = Meta_p-&gt;Header.PayloadLength - ((uint32)Data_p - (uint32)Meta_p-&gt;Payload_p);
+ const void *<value-of select="@name" /> = Data_p;</when>
+ <when test="@type='buffer' and @length!='*'">
+ const void *<value-of select="@name" /> = Data_p;</when>
+</choose>
+<if test="position() = last()"><text>
+</text></if>
+</template>
+
+<template match="value" mode="serialize">
+<choose>
+ <when test="@type='uint32'">
+ put_uint32(&amp;Data_p, <value-of select="@name" />);</when>
+ <when test="@type='string'">
+ put_string(&amp;Data_p, <value-of select="@name" />);</when>
+ <when test="@type='buffer' and @length='*'">
+ put_block(&amp;Data_p, <value-of select="@name" />, <value-of select="@name" />PLSize);</when>
+ <when test="@type='buffer' and @length!='*'">
+ put_block(&amp;Data_p, <value-of select="@name" />, PLSize);</when>
+</choose>
+<if test="position() = last()"><text>
+</text></if>
+</template>
+
+<template match="value" mode="clean">
+<choose>
+ <when test="@type='string'">
+ free(<value-of select="@name" />);</when>
+</choose>
+</template>
+
+<template match="value" mode="document">
+ * @param [in] <value-of select="@name" /><text> </text><value-of select="text()" />
+<if test="position() = last()">
+ * </if>
+</template>
+
+<template match="value" mode="declare">
+ <if test="position() > 1">, </if>
+<choose>
+ <when test="@type='uint32'">const uint32 <value-of select="@name" /></when>
+ <when test="@type='string'">const char *<value-of select="@name" /></when>
+ <when test="@type='buffer' and @length='*'">int <value-of select="@name" />Length, const void *<value-of select="@name" /></when>
+ <when test="@type='buffer' and @length!='*'">const void *<value-of select="@name" /></when>
+</choose>
+</template>
+
+<template match="input" mode="declare">
+<choose>
+ <when test="current()=''">void</when>
+</choose>
+</template>
+
+<template match="value" mode="call">
+ <if test="position() > 1">, </if>
+<choose>
+ <when test="@type='uint32'"><value-of select="@name" /></when>
+ <when test="@type='string'"><value-of select="@name" /></when>
+ <when test="@type='buffer' and @length='*'"><value-of select="@name" />Length, <value-of select="@name" /></when>
+ <when test="@type='buffer' and @length!='*'"><value-of select="@name" /></when>
+</choose>
+</template>
+
+<template match="group/documentation">
+/*
+ * <value-of select="normalize-space(.)"/>
+ */
+</template>
+
+<template name="prototype">
+<param name="name" />
+<param name="direction" />
+<param name="source" />
+<param name="ref" />
+<choose>
+<when test="name($direction)='input' and contains($source, 'PC')">
+/**
+ * <value-of select="normalize-space(./documentation/text())"/>
+ * \see <value-of select="$ref"/>
+ * Call source: <value-of select="$source"/>
+ * <apply-templates select="input/value" mode="document" />
+ * @return ErrorCode_e ...
+ */
+ErrorCode_e <value-of select="$name"/>(<choose><when test="count(input/value) > 0"><apply-templates select="input" mode="declare"/><apply-templates select="input/value" mode="declare"/></when><otherwise>void</otherwise></choose>);</when>
+<when test="name($direction)='input' and contains($source, 'ME')">
+/**
+ * <value-of select="normalize-space(./documentation/text())"/>
+ * \see <value-of select="$ref"/>
+ * Call source: <value-of select="$source"/>
+ * <apply-templates select="input/value" mode="document" />
+ * @return ErrorCode_e ...
+ */
+ErrorCode_e <value-of select="$name"/>(uint32 PLSize<if test="count(input/value) > 0">, </if><apply-templates select="input/value" mode="declare"/>);</when>
+<when test="name($direction)='output'">
+/**
+ * Response to \see <value-of select="$ref"/>
+ * Call source: <value-of select="$source"/>
+ *
+ * @param [in] Status Completion status code.
+ * <apply-templates select="output/value" mode="document" />
+ * @return ErrorCode_e ...
+ */
+ErrorCode_e <value-of select="$name"/>(uint32 PLSize, ErrorCode_e Status<if test="count(output/value) > 0">, </if><apply-templates select="output/value" mode="declare"></apply-templates>);</when>
+</choose>
+<text>
+</text>
+</template>
+
+
+</stylesheet>
diff --git a/lcmodule/source/LCM.rc b/lcmodule/source/LCM.rc
new file mode 100644
index 0000000..15b65cb
--- /dev/null
+++ b/lcmodule/source/LCM.rc
@@ -0,0 +1,104 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "windows.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""windows.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x1fL
+#ifdef _DEBUG
+ FILEFLAGS 0x9L
+#else
+ FILEFLAGS 0x8L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "Build date: 2011-05-18"
+ VALUE "CompanyName", "ST Ericsson AB"
+ VALUE "FileDescription", "LCM Dynamic Link Library"
+ VALUE "FileVersion", "1,0,0,1"
+ VALUE "InternalName", "LCM"
+ VALUE "LegalCopyright", "Copyright (C) ST Ericsson 2011"
+ VALUE "OriginalFilename", "LCM.dll"
+ VALUE "PrivateBuild", "http://gerrit.lud.stericsson.com/gerrit/21155"
+ VALUE "ProductName", "CXA1104507 Loader Communication Module"
+ VALUE "ProductVersion", "Test Version"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/lcmodule/source/LCM.vcproj b/lcmodule/source/LCM.vcproj
new file mode 100644
index 0000000..77341b9
--- /dev/null
+++ b/lcmodule/source/LCM.vcproj
@@ -0,0 +1,679 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="LCM"
+ ProjectGUID="{E06F2763-9680-40F7-99CB-4065B1157B67}"
+ RootNamespace="LCM"
+ Keyword="ManagedCProj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ CharacterSet="0"
+ ManagedExtensions="0"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;$(ProjectDir)autogen&quot;;&quot;$(ProjectDir)cnh1606344_ldr_communication_module\config&quot;;&quot;$(ProjectDir)legacy_compatibility&quot;;&quot;$(ProjectDir)cnh1606344_ldr_communication_module\include&quot;;&quot;$(ProjectDir)cnh1605721_ldr_security_algorithms\include&quot;;&quot;$(ProjectDir)cnh1605720_ldr_time_utilities\include&quot;;&quot;$(ProjectDir)cnh1605551_ldr_utilities\include&quot;;&quot;$(ProjectDir)cnh1605205_ldr_network_layer\include&quot;;&quot;$(ProjectDir)cnh1605204_ldr_transport_layer\include&quot;;&quot;$(ProjectDir)cnh1605203_ldr_communication_buffer\include&quot;"
+ PreprocessorDefinitions="WIN32;_DEBUG;LCM_EXPORTS;PRINT_A_"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ PrecompiledHeaderThrough=""
+ PrecompiledHeaderFile=""
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ CompileAs="2"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="$(NoInherit)"
+ GenerateDebugInformation="true"
+ AssemblyDebug="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="0"
+ ManagedExtensions="0"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="&quot;$(ProjectDir)autogen&quot;;&quot;$(ProjectDir)cnh1606344_ldr_communication_module\config&quot;;&quot;$(ProjectDir)legacy_compatibility&quot;;&quot;$(ProjectDir)cnh1606344_ldr_communication_module\include&quot;;&quot;$(ProjectDir)cnh1605721_ldr_security_algorithms\include&quot;;&quot;$(ProjectDir)cnh1605720_ldr_time_utilities\include&quot;;&quot;$(ProjectDir)cnh1605551_ldr_utilities\include&quot;;&quot;$(ProjectDir)cnh1605205_ldr_network_layer\include&quot;;&quot;$(ProjectDir)cnh1605204_ldr_transport_layer\include&quot;;&quot;$(ProjectDir)cnh1605203_ldr_communication_buffer\include&quot;"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LCM_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ CompileAs="2"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="$(NoInherit)"
+ GenerateDebugInformation="true"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ <AssemblyReference
+ RelativePath="System.dll"
+ AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
+ />
+ <AssemblyReference
+ RelativePath="System.Data.dll"
+ AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
+ />
+ <AssemblyReference
+ RelativePath="System.XML.dll"
+ AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
+ />
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <Filter
+ Name="cnh1606344_ldr_communication_module"
+ >
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\source\a2_family.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\source\communication_service.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\source\protrom_family.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\source\r15_family.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\source\z_family.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="cnh1605204_ldr_transport_layer"
+ >
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\source\a2_protocol.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\source\a2_speedflash.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\source\a2_transport.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\source\bulk_protocol.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\source\command_protocol.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\source\protrom_protocol.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\source\protrom_transport.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\source\r15_transport_layer.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\source\z_transport.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="cnh1605205_ldr_network_layer"
+ >
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\source\a2_header.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\source\a2_network.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\source\protrom_header.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\source\protrom_network.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\source\r15_header.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\source\r15_network_layer.c"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\source\z_network.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="cnh1605551_ldr_utilities"
+ >
+ <File
+ RelativePath=".\cnh1605551_ldr_utilities\source\serialization.c"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <Filter
+ Name="cnh1606344_ldr_communication_module"
+ >
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\include\r_a2_family.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\include\r_communication_service.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\include\r_protrom_family.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\include\r_r15_family.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\include\r_z_family.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\include\t_a2_family.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\include\t_communication_service.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\include\t_r15_family.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="cnh1605205_ldr_network_layer"
+ >
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\r_a2_header.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\r_a2_network.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\r_protrom_header.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\r_protrom_network.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\r_r15_header.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\r_r15_network_layer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\r_z_network.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\t_a2_header.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\t_a2_network.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\t_protrom_header.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\t_protrom_network.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\t_r15_header.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\t_r15_network_layer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\t_z_header.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605205_ldr_network_layer\include\t_z_network.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="cnh1605204_ldr_transport_layer"
+ >
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\r_a2_protocol.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\r_a2_speedflash.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\r_a2_transport.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\r_bulk_protocol.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\r_command_protocol.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\r_protrom_protocol.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\r_protrom_transport.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\r_r15_transport_layer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\r_z_protocol.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\r_z_transport.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\t_a2_protocol.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\t_a2_speedflash.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\t_a2_transport.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\t_bulk_protocol.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\t_command_protocol.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\t_protrom_protocol.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\t_protrom_transport.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\t_r15_transport_layer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605204_ldr_transport_layer\include\t_z_protocol.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="cnh1605203_ldr_communication_buffer"
+ >
+ <File
+ RelativePath=".\cnh1605203_ldr_communication_buffer\include\t_communication_buffer.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="cnh1605551_ldr_utilities"
+ >
+ <File
+ RelativePath=".\cnh1605551_ldr_utilities\include\r_debug_macro.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605551_ldr_utilities\include\r_queue.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605551_ldr_utilities\include\r_serialization.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605551_ldr_utilities\include\t_queue.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1605551_ldr_utilities\include\t_serialization.h"
+ >
+ </File>
+ <Filter
+ Name="debug_subsystem"
+ >
+ <File
+ RelativePath=".\cnh1605551_ldr_utilities\debug_subsystem\t_debug_subsystem.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="cnh1605720_ldr_time_utilities"
+ >
+ <File
+ RelativePath=".\cnh1605720_ldr_time_utilities\include\t_time_utilities.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="cnh1605721_ldr_security_algorithms"
+ >
+ <File
+ RelativePath=".\cnh1605721_ldr_security_algorithms\include\t_security_algorithms.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="legacy_compatibility"
+ >
+ <File
+ RelativePath=".\legacy_compatibility\c_compiler.h"
+ >
+ </File>
+ <File
+ RelativePath=".\legacy_compatibility\c_system.h"
+ >
+ </File>
+ <File
+ RelativePath=".\legacy_compatibility\r_basicdefinitions.h"
+ >
+ </File>
+ <File
+ RelativePath=".\legacy_compatibility\r_debug.h"
+ >
+ </File>
+ <File
+ RelativePath=".\legacy_compatibility\t_basicdefinitions.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="Config"
+ >
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\config\command_ids_h.xsl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating command_ids.h..."
+ CommandLine="java -classpath ..\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)autogen\command_ids.h&quot; -PARAM target lcm"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\command_ids.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating command_ids.h..."
+ CommandLine="java -classpath ..\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)autogen\command_ids.h&quot; -PARAM target lcm&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\command_ids.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\config\commands.xml"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\config\commands_h.xsl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating commands.h..."
+ CommandLine="java -classpath ..\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)autogen\commands.h&quot; -PARAM target lcm"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\commands.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating commands.h..."
+ CommandLine="java -classpath ..\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)autogen\commands.h&quot; -PARAM target lcm"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\commands.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\config\error_codes.xml"
+ >
+ </File>
+ <File
+ RelativePath=".\cnh1606344_ldr_communication_module\config\errorcode_h.xsl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating error_codes.h..."
+ CommandLine="java -classpath &quot;..\tools\xalan-j_2_7_1\xalan.jar&quot; org.apache.xalan.xslt.Process -in &quot;$(InputDir)error_codes.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)autogen\error_codes.h&quot;"
+ AdditionalDependencies="&quot;$(InputDir)error_codes.xml&quot;"
+ Outputs="autogen\error_codes.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating error_codes.h..."
+ CommandLine="java -classpath &quot;..\tools\xalan-j_2_7_1\xalan.jar&quot; org.apache.xalan.xslt.Process -in &quot;$(InputDir)error_codes.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)autogen\error_codes.h&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="$(InputDir)error_codes.xml"
+ Outputs="autogen\error_codes.h"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Autogen"
+ >
+ <File
+ RelativePath=".\autogen\command_ids.h"
+ >
+ </File>
+ <File
+ RelativePath=".\autogen\commands.h"
+ >
+ </File>
+ <File
+ RelativePath=".\autogen\error_codes.h"
+ >
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\LCM.rc"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/lcmodule/source/cnh1605203_ldr_communication_buffer/include/t_communication_buffer.h b/lcmodule/source/cnh1605203_ldr_communication_buffer/include/t_communication_buffer.h
new file mode 100644
index 0000000..d94e152
--- /dev/null
+++ b/lcmodule/source/cnh1605203_ldr_communication_buffer/include/t_communication_buffer.h
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _INCLUSION_GUARD_T_COMMUNICATION_BUFFER_H_
+#define _INCLUSION_GUARD_T_COMMUNICATION_BUFFER_H_
+
+/**
+ * \addtogroup ldr_communication_buffer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+/** number of defined buffer types */
+#define NUMBER_OF_BUFFER_TYPES 2
+
+
+/** @} */
+
+#endif /* _INCLUSION_GUARD_T_COMMUNICATION_BUFFER_H_ */
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
new file mode 100644
index 0000000..6a94bae
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_protocol.h
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _R_A2_PROTOCOL_H_
+#define _R_A2_PROTOCOL_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup a2_protocol
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_a2_protocol.h"
+#include "t_a2_network.h"
+#include "error_codes.h"
+#include "t_communication_service.h"
+
+#if (defined(WIN32) || defined(__CYGWIN__))
+
+#ifdef LCM_EXPORTS
+#define LCM_API __declspec(dllexport) // export DLL information
+#else //LCM_EXPORTS
+#define LCM_API __declspec(dllimport) // import DLL information
+#endif // LCM_EXPORTS
+
+#elif defined(__linux__)
+
+#ifdef LCM_EXPORTS
+#define LCM_API __attribute__((visibility("default")))
+#else //LCM_EXPORTS
+#define LCM_API
+#endif // LCM_EXPORTS
+
+#elif defined(CFG_ENABLE_LOADER_TYPE)
+
+#define LCM_API
+
+#endif // WIN32
+
+/***********************************************************************
+ * Declaration of functions
+ **********************************************************************/
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif // #ifdef __cplusplus
+ /**
+ * Sends command packet with A2 protocol.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] CmdData_p Pointer to the command data.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS If CmdData_p is NULL.
+ */
+ LCM_API ErrorCode_e Do_A2_Command_Send(Communication_t *Communication_p, A2_CommandData_t *CmdData_p);
+#ifdef __cplusplus
+};
+#endif // #ifdef __cplusplus
+
+/**
+ * Decode received command.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Packet_p Pointer to the received buffer.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS if Packet_p is NULL.
+ */
+ErrorCode_e A2_Command_Process(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif /* _R_A2_PROTOCOL_H_*/
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
new file mode 100755
index 0000000..6124d58
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_speedflash.h
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _R_A2_SPEEDFLASH_H_
+#define _R_A2_SPEEDFLASH_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup a2_speedflash
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_a2_protocol.h"
+#include "t_a2_network.h"
+#include "error_codes.h"
+#include "t_communication_service.h"
+
+#if (defined(WIN32) || defined(__CYGWIN__))
+
+#ifdef LCM_EXPORTS
+#define LCM_API __declspec(dllexport) // export DLL information
+#else //LCM_EXPORTS
+#define LCM_API __declspec(dllimport) // import DLL information
+#endif // LCM_EXPORTS
+
+#elif defined(__linux__)
+
+#ifdef LCM_EXPORTS
+#define LCM_API __attribute__((visibility("default")))
+#else //LCM_EXPORTS
+#define LCM_API
+#endif // LCM_EXPORTS
+
+#elif defined(CFG_ENABLE_LOADER_TYPE)
+
+#define LCM_API
+
+#endif // WIN32
+
+/***********************************************************************
+ * Declaration of functions
+ **********************************************************************/
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif // #ifdef __cplusplus
+ /**
+ * Set the LCM in A2 Speedflash Mode.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] State State of the speedflash (TRUE - on, FALSE - off).
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval
+ */
+ LCM_API void Do_A2_Speedflash_Start(Communication_t *Communication_p);
+
+ LCM_API void Do_A2_Speedflash_SetLastBlock(Communication_t *Communication_p);
+
+ /**
+ * Writes A2 speedflash sub-block on the comm device.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Buffer Buffer containing the data of the sub-block.
+ * @param [in] BufferSize Size of the speedflash sub-blocks.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval
+ */
+ LCM_API ErrorCode_e Do_A2_Speedflash_WriteBlock(Communication_t *Communication_p, const void *Buffer, const uint32 BufferSize);
+#ifdef __cplusplus
+};
+#endif // #ifdef __cplusplus
+
+ErrorCode_e A2_Speedflash_Poll(Communication_t *Communication_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif /* _R_A2_SPEEDFLASH_H_ */
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_transport.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_transport.h
new file mode 100644
index 0000000..bb082e7
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_a2_transport.h
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef INCLUSION_GUARD_R_A2_TRANSPORT_LAYER_H
+#define INCLUSION_GUARD_R_A2_TRANSPORT_LAYER_H
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup ldr_transport_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_a2_transport.h"
+#include "t_communication_service.h"
+#include "error_codes.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+/**
+ * Handles all registered TL processes.
+ *
+ * @param [in] Communication_p The communication context
+ * structure to receive information
+ * about this module instance.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e A2_Transport_Poll(Communication_t *Communication_p);
+
+/*
+ * Function for sending packet.
+ *
+ * @param [in] Communication_p The communication context
+ * structure to receive information
+ * about this module instance.
+ * @param [in] InputData_p Pointer to the input data.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_ALLOCATE_COMM_BUFFER Failed to allocate communication
+ * buffer.
+ */
+ErrorCode_e A2_Transport_Send(Communication_t *Communication_p, void *InputDataIn_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif // INCLUSION_GUARD_R_A2_TRANSPORT_LAYER_H
+
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
new file mode 100644
index 0000000..e3dd83c
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_bulk_protocol.h
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _R_BULK_PROTOCOL_H_
+#define _R_BULK_PROTOCOL_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup bulk_protocol Bulk Protocol
+ * Functionalities for handling bulk protocol. Receiving/Sending bulk
+ * commands and state machines for receivin and sending bulk data chunks.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "c_system.h"
+#include "t_bulk_protocol.h"
+#include "t_r15_transport_layer.h"
+#include "t_r15_network_layer.h"
+#include "error_codes.h"
+#include "r_communication_service.h"
+#ifdef CFG_ENABLE_LOADER_TYPE
+#include "t_security_algorithms.h"
+#endif
+
+#if (defined(WIN32) || defined(__CYGWIN__))
+
+#ifdef LCM_EXPORTS
+#define LCM_API __declspec(dllexport) // export DLL information
+#else //LCM_EXPORTS
+#define LCM_API __declspec(dllimport) // import DLL information
+#endif // LCM_EXPORTS
+
+#elif defined(__linux__)
+
+#ifdef LCM_EXPORTS
+#define LCM_API __attribute__((visibility("default")))
+#else //LCM_EXPORTS
+#define LCM_API
+#endif // LCM_EXPORTS
+
+#elif defined(CFG_ENABLE_LOADER_TYPE)
+
+#define LCM_API
+
+#endif //#ifdef CFG_ENABLE_LOADER_TYPE
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+/**
+ * State machine for bulk transfer from ME to PC.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] BulkVector_p Pointer to the received buffer.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS If Packet_p is NULL.
+ */
+ErrorCode_e R15_Bulk_Process_Write(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p);
+/**
+ * Decoding received bulk command.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Packet_p Pointer to the received buffer.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS If Packet_p is NULL.
+ */
+ErrorCode_e R15_Bulk_Process(Communication_t *Communication_p, PacketMeta_t *Packet_p);
+
+#ifdef CFG_ENABLE_LOADER_TYPE
+/**
+ * Generate bulk Session ID. Allowed bulk session ID is from 1 to 65535.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval Session ID Next free session ID.
+ */
+uint16 Do_R15_Bulk_GenerateBulkSessionID(Communication_t *Communication_p);
+#endif //#ifdef CFG_ENABLE_LOADER_TYPE
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif // #ifdef __cplusplus
+ /**
+ * Opens Bulk session.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] SessionId Session ID.
+ * @param [in] Mode Type of operation(Read or Write).
+ * (send or receive) over the bulk protocol.
+ *
+ * @return Vector ID Vector ID of the newly opened session.
+ * @retval BULK_ERROR If the session can not be opened.
+ */
+ LCM_API uint32 Do_R15_Bulk_OpenSession(const Communication_t *const Communication_p, const uint16 SessionId, const TL_SessionMode_t Mode);
+
+ /**
+ * Creates Bulk Vector.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] BulkVector Index of Bulk Vector.
+ * @param [in] Length Data Length in bytes.
+ * @param [in] BuffSize Requested size of each Buffer.
+ * @param [in] CreatedBulkVector_p Already created bulk vector which
+ * need to be updated with correct
+ * information.
+ *
+ * @return Vector ID The ID of the Vector that has been created.
+ * @retval BULK_ERROR If creation of vector failed.
+ */
+ LCM_API TL_BulkVectorList_t *Do_R15_Bulk_CreateVector(const Communication_t *const Communication_p, const uint32 BulkVector, uint32 Length, const uint32 BuffSize, TL_BulkVectorList_t *CreatedBulkVector_p);
+
+ /**
+ * Frees Bulk Vector.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] BulkVector_p Pointer to the Bulk Vector.
+ * @param [in] ReqReleaseBuffer Defines if complete buffers with metadata will
+ * be released or only only the metadata will be cleared.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval BULK_ERROR Error while destroying vector.
+ */
+ LCM_API uint32 Do_R15_Bulk_DestroyVector(const Communication_t *const Communication_p, TL_BulkVectorList_t *BulkVector_p, boolean ReqReleaseBuffer);
+
+ /**
+ * Start specified bulk session.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] BulkVector_p Pointer to the Bulk Vector.
+ * @param [in] Offset Sets the offset from where data
+ * read/write should be performed.
+ *
+ * @retval E_INVALID_BULK_MODE Invalid bulk mode.
+ * @retval E_FAILED_TO_START_BULK_SESSION Either the session is
+ * invalid or the BulkVector is invalid.
+ * @retval E_SUCCESS After successful execution.
+ */
+ LCM_API ErrorCode_e Do_R15_Bulk_StartSession(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p, const uint64 Offset);
+
+ /**
+ * Get status of bulk transfer.
+ *
+ * @param [in] BulkVector_p Pointer to the Bulk Vector.
+ *
+ * @retval BULK_SESSION_IDLE Idle state of bulk protocol.
+ * @retval BULK_SESSION_OPEN Opened bulk protocol and ready for
+ * transmitting.
+ * @retval BULK_SESSION_PROCESSING Processing bulk transfer.
+ * @retval BULK_SESSION_FINISHED Bulk transfer finished.
+ */
+ LCM_API TL_BulkSessionState_t Do_R15_Bulk_GetStatusSession(const TL_BulkVectorList_t *BulkVector_p);
+
+ /**
+ * Close specified Bulk session.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] BulkVector_p Pointer to the Bulk Vector.
+ * for the session you want to close.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_CLOSE_BULK_SESSION If the BulkVector is not valid.
+ */
+ LCM_API ErrorCode_e Do_R15_Bulk_CloseSession(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p);
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+ /**
+ * Sets pointers to callback functions regarding the bulk transfer.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] BulkCommandCallback_p Pointer to the callback function
+ for handling a received command.
+ * @param [in] BulkDataCallback_p Pointer to the callback function
+ for handling a received data.
+ * @param [in] EndOfDump_p Pointer to the callback function
+ for handling a finished bulk transfer.
+ */
+ LCM_API void Do_R15_Bulk_SetCallbacks(Communication_t *Communication_p, void *BulkCommandCallback_p, void *BulkDataCallback_p, void *EndOfDump_p);
+#endif
+
+#ifdef __cplusplus
+};
+#endif // #ifdef __cplusplus
+
+/** @} */
+/** @} */
+/** @} */
+#endif /* _R_BULK_PROTOCOL_H_*/
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
new file mode 100644
index 0000000..dce0711
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_command_protocol.h
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _R_COMMAND_PROTOCOL_H_
+#define _R_COMMAND_PROTOCOL_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup command_protocol Command Protocol
+ * Functionalities for handling command protocol. Receiving/Sending
+ * commands with command protocol.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_command_protocol.h"
+#include "t_r15_network_layer.h"
+#include "error_codes.h"
+#include "t_communication_service.h"
+
+#if (defined(WIN32) || defined(__CYGWIN__))
+
+#ifdef LCM_EXPORTS
+#define LCM_API __declspec(dllexport) // export DLL information
+#else //LCM_EXPORTS
+#define LCM_API __declspec(dllimport) // import DLL information
+#endif // LCM_EXPORTS
+
+#elif defined(__linux__)
+
+#ifdef LCM_EXPORTS
+#define LCM_API __attribute__((visibility("default")))
+#else //LCM_EXPORTS
+#define LCM_API
+#endif // LCM_EXPORTS
+
+#elif defined(CFG_ENABLE_LOADER_TYPE)
+
+#define LCM_API
+
+#endif // WIN32
+
+/***********************************************************************
+ * Declaration of functions
+ **********************************************************************/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif // #ifdef __cplusplus
+ /**
+ * Reset the Session counters.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ LCM_API ErrorCode_e Do_R15_Command_ResetSessionCounters(const Communication_t *const Communication_p);
+
+ /**
+ * Sends command packet with command protocol.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] CmdData_p Pointer to the command data.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS If CmdData_p is NULL.
+ */
+ LCM_API ErrorCode_e Do_R15_Command_Send(Communication_t *Communication_p, CommandData_t *CmdData_p);
+#ifdef __cplusplus
+};
+#endif // #ifdef __cplusplus
+
+/**
+ * Decode received command.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Packet_p Pointer to the received buffer.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS if Packet_p is NULL.
+ */
+ErrorCode_e R15_Command_Process(Communication_t *Communication_p, PacketMeta_t *Packet_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif /* _R_COMMAND_PROTOCOL_H_*/
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_protrom_protocol.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_protrom_protocol.h
new file mode 100644
index 0000000..2dac437
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_protrom_protocol.h
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _INCLUSION_GUARD_R_PROTROM_PROTOCOL_H_
+#define _INCLUSION_GUARD_R_PROTROM_PROTOCOL_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup protrom_family
+ * @{
+ * @addtogroup protrom_protocol PROTROM protocol
+ * Functionalities for handling PROTROM commands.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_protrom_protocol.h"
+#include "error_codes.h"
+#include "t_communication_service.h"
+#include "t_r15_network_layer.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+/**
+ * Decode received command, and execute.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Packet_p Pointer to the received buffer.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Protrom_Process(const Communication_t *const Communication_p, Protrom_Packet_t *Packet_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif //_INCLUSION_GUARD_R_PROTROM_PROTOCOL_H_
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_protrom_transport.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_protrom_transport.h
new file mode 100644
index 0000000..ad47f6e
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_protrom_transport.h
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef INCLUSION_GUARD_R_PROTROM_TRANSPORT_LAYER_H
+#define INCLUSION_GUARD_R_PROTROM_TRANSPORT_LAYER_H
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup protrom_family
+ * @{
+ * @addtogroup ldr_protrom_transport_layer PROTROM Transport Layer
+ * PROTROM functionalities for sending PROTROM packets and
+ * polling receiver and transmiter.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_protrom_transport.h"
+#include "t_communication_service.h"
+#include "error_codes.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+/**
+ * Handles all registered TL processes for PROTROM protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Protrom_Transport_Poll(Communication_t *Communication_p);
+
+/**
+ * Function for sending packet in PROTROM protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] InputDataIn_p Pointer to the input data.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_ALLOCATE_COMM_BUFFER Failed to allocate communication
+ * buffer.
+ */
+ErrorCode_e Protrom_Transport_Send(Communication_t *Communication_p, void *InputDataIn_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif // INCLUSION_GUARD_R_PROTROM_TRANSPORT_LAYER_H
+
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_r15_transport_layer.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_r15_transport_layer.h
new file mode 100644
index 0000000..904eb8b
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_r15_transport_layer.h
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _INCLUSION_GUARD_R_R15_TRANSPORT_LAYER_H_
+#define _INCLUSION_GUARD_R_R15_TRANSPORT_LAYER_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup ldr_r15_transport_layer R15 Transport layer
+ * R15 functionalities for sending R15 packets and
+ * polling receiver and transmiter.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_r15_transport_layer.h"
+#include "t_communication_service.h"
+#include "error_codes.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+/**
+ * Initializes the transport layer for R15 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_INIT_TL Unsuccessful initialization.
+ * @retval E_ALLOCATE_FAILED Failed to allocate memory space.
+ */
+ErrorCode_e R15_Transport_Initialize(const Communication_t *const Communication_p);
+
+/**
+ * Shut Down the transport layer for R15 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e R15_Transport_Shutdown(const Communication_t *const Communication_p);
+
+/**
+ * Handles all registered TL processes for R15 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e R15_Transport_Poll(Communication_t *Communication_p);
+
+/**
+ * Function for sending packet in R15 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] InputDataIn_p Pointer to the input data.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_ALLOCATE_COMM_BUFFER Failed to allocate communication
+ * buffer.
+ */
+ErrorCode_e R15_Transport_Send(Communication_t *Communication_p, void *InputDataIn_p);
+
+/**
+ * Function for setting the timeouts in the R15 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] TimeoutData_p Pointer to the input data with all timeouts.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e R15_SetProtocolTimeouts(Communication_t *Communication_p, void *TimeoutData_p);
+
+/**
+ * Function for getting the timeouts in the R15 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [out] TimeoutData_p Return all defined timeouts.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e R15_GetProtocolTimeouts(Communication_t *Communication_p, void *TimeoutData_p);
+
+
+/** @} */
+/** @} */
+/** @} */
+#endif // _INCLUSION_GUARD_R_R15_TRANSPORT_LAYER_H_
+
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_z_protocol.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_z_protocol.h
new file mode 100644
index 0000000..f4e9055
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_z_protocol.h
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef INCLUSION_GUARD_R_Z_PROTOCOL_H
+#define INCLUSION_GUARD_R_Z_PROTOCOL_H
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup z_family
+ * @{
+ * @addtogroup z_protocol Z Protocol
+ * Functionalities for handling Z commands. All Z commands are not decoded
+ * in this layer, it is resent to teh application layer for decoding
+ * and executing.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_z_protocol.h"
+#include "error_codes.h"
+#include "t_communication_service.h"
+#include "t_z_network.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+/**
+ * Decode received command, and execute.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Packet_p Pointer to the received buffer.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Z_Family_Process(const Communication_t *const Communication_p, const void *const Packet_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif //INCLUSION_GUARD_R_Z_PROTOCOL_H
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_z_transport.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_z_transport.h
new file mode 100644
index 0000000..6de0225
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/r_z_transport.h
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef INCLUSION_GUARD_R_Z_TRANSPORT_LAYER_H
+#define INCLUSION_GUARD_R_Z_TRANSPORT_LAYER_H
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup z_family
+ * @{
+ * @addtogroup ldr_z_transport_layer Z Transport layer
+ * TI functionalities for sending Z packets, Initialization and
+ * polling receiver and transmiter.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_communication_service.h"
+#include "error_codes.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+/**
+ * Initializes the transport layer for Z protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_INIT_TL unsuccessful initialization.
+ * @retval E_ALLOCATE_FAILED failed to allocate memory space.
+ */
+ErrorCode_e Z_Transport_Initialize(const Communication_t *const Communication_p);
+
+/**
+ * Shut Down the transport layer for Z protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Z_Transport_Shutdown(const Communication_t *const Communication_p);
+
+/**
+ * Handles all registered TL processes for Z protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Z_Transport_Poll(Communication_t *Communication_p);
+
+/**
+ * Function for sending packet in Z protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] InputData_p Pointer to the input data.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_ALLOCATE_COMM_BUFFER Failed to allocate communication
+ * buffer.
+ */
+ErrorCode_e Z_Transport_Send(Communication_t *Communication_p, void *InputData_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif // INCLUSION_GUARD_R_Z_TRANSPORT_LAYER_H
+
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_a2_protocol.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_a2_protocol.h
new file mode 100644
index 0000000..23add7e
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_a2_protocol.h
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef INCLUSION_GUARD_T_A2_PROTOCOL_H
+#define INCLUSION_GUARD_T_A2_PROTOCOL_H
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup a2_protocol
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_command_protocol.h" // only for Buffer_t
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+typedef enum {
+ A2_COMMAND, /**< Command type of the packet.*/
+ A2_GENERAL_RESPONSE, /**< General response type of the packet.*/
+ A2_CONTROL_MESSAGE, /**< Control message protocol packet. */
+ A2_SPEEDFLASH_GR /**< Speedflash GR packet. */
+} A2_CommandType_t;
+
+/**
+ * Holds information for the command received from the transport layer.
+ */
+typedef struct A2_CommandData_s {
+ uint8 CommandNr; /**< Number of the command. */
+ uint8 ApplicationNr; /**< Number of the application (command) group. */
+ uint16 SessionNr; /**< Number of the session in which this command
+ was received. */
+ uint8 DestAddress; /**< Destination address ACC = 0x01, APP = 0x02 */
+ A2_CommandType_t Type; /**< Command type. */
+ Buffer_t Payload; /**< Holds the data received with the command.*/
+} A2_CommandData_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif // INCLUSION_GUARD_T_A2_PROTOCOL_H
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_a2_speedflash.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_a2_speedflash.h
new file mode 100755
index 0000000..0795d7f
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_a2_speedflash.h
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _INCLUSION_GUARD_T_A2_SPEEDFLASH_H_
+#define _INCLUSION_GUARD_T_A2_SPEEDFLASH_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup A2_family
+ * @{
+ *
+ */
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+#define A2_SPEEDFLASH_REQ_SIZE 2
+
+typedef enum {
+ A2_SPEEDFLASH_START,
+ A2_SPEEDFLASH_ACTIVE,
+ A2_SPEEDFLASH_INACTIVE
+} A2_SpeedflashState_t;
+
+typedef enum {
+ A2_SPEEDFLASH_READ_REQ,
+ A2_SPEEDFLASH_WAIT_READ_REQ,
+ A2_SPEEDFLASH_WRITE_BLOCK,
+ A2_SPEEDFLASH_WAIT_WRITE_BLOCK
+} A2_SpeedflashInboundState_t;
+
+/**
+ * A2 speedflash context.
+ * Context structures for A2 speedflash protocol.
+ */
+typedef struct {
+ A2_SpeedflashState_t State;
+ boolean LastBlock;
+ void *Outbound_p;
+ uint32 OutboundSize;
+ uint8 Scratch[A2_SPEEDFLASH_REQ_SIZE];
+ A2_SpeedflashInboundState_t InboundState;
+} A2_SpeedflashContext_t;
+
+
+/** @} */
+/** @} */
+#endif // _INCLUSION_GUARD_T_A2_SPEEDFLASH_H_
+
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_a2_transport.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_a2_transport.h
new file mode 100644
index 0000000..eb18598
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_a2_transport.h
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef INCLUSION_GUARD_T_A2_TRANSPORT_H
+#define INCLUSION_GUARD_T_A2_TRANSPORT_H
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup ldr_transport_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+#include "t_a2_network.h"
+
+/*******************************************************************************
+ * Types, constants and external variables
+ ******************************************************************************/
+/** Callback function type for the A2 protocol handler */
+typedef ErrorCode_e(* A2_Callback_fn)(void *Param_p, uint8 PDU, int PayloadLength, void *Payload_p, Communication_t *Communication_p);
+
+/** Structure for transfer input parameters in "loader protocols" protocol family */
+typedef struct {
+ A2_Header_t *Header_p; /**< Pointer to A2 header data. */
+ void *Payload_p; /**< Pointer to payload data.*/
+ uint32 Time; /**< Used time for retransmission.*/
+ HandleFunction_t TimerCallBackFn_p; /**< Timer callback function for
+ retransmission.*/
+} A2_SendData_LP_t;
+
+/** A2 Transport context */
+typedef struct {
+ A2_Callback_fn Callback;
+} A2_TransportContext_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif // INCLUSION_GUARD_T_A2_TRANSPORT_H
+
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_bulk_protocol.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_bulk_protocol.h
new file mode 100644
index 0000000..fabc1a4
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_bulk_protocol.h
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _T_BULK_PROTOCOL_H_
+#define _T_BULK_PROTOCOL_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup bulk_protocol
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+#include "t_r15_network_layer.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/** Maximum bulk processes used in transport layer. */
+#define MAX_BULK_TL_PROCESSES 16
+
+/** Mask for selecting the TYPE bits in type/flags field */
+#define MASK_BULK_COMMAND_SELECT (0x07)
+
+/** Defined bulk error in 32 bits format. */
+#define BULK_ERROR 0xffffffff
+/** Defined bulk error in 64 bits format. */
+#define BULK_ERROR_64 0xffffffffffffffff
+
+/** Defined Callback functions used for bulk transfer in the LCM on PC side. */
+typedef void (*BulkCommandReqCallback_t)(void *Object_p, uint16 *Session_p, uint32 *ChunkSize_p, uint64 *Offset_p, uint32 *Length_p, boolean ACK_Read);
+typedef void(*BulkDataReqCallback_t)(void *Object_p, uint16 *Session_p, uint32 *ChunkSize_p, uint64 *Offset_p, uint32 *Length_p, uint64 *TotalLength_p, uint32 *TransferedLength_p);
+typedef void(*BulkDataEndOfDump_t)(void *Object_p);
+
+
+/** Defined bulk commands. */
+typedef enum {
+ CMD_BULK_STATUS = 0x00, /**< Status packet type command. */
+ CMD_BULK_READ = 0x01, /**< Read packet type command. */
+ CMD_BULK_DATA = 0x02, /**< Data packet type command. */
+ CMD_BULK_WRITE = 0x03 /**< Write packet type command. */
+} TL_BulkCmmands_t;
+
+/** Defined bulk session ID status. */
+typedef enum {
+ BULK_SESSION_INVALID = 0x00, /**< Received packet with invalid session ID.*/
+ BULK_SESSION_NEW = 0x01, /**< Received packet with new session ID.*/
+ BULK_SESSION_CURRENT = 0x02 /**< Received packet with current session ID.*/
+} TL_BulkSessionID_Status_t;
+
+/** States of bulk protocol. */
+TYPEDEF_ENUM {
+ BULK_IDLE_STATE = 0, /**< Idle state. */
+ SEND_READ_REQUEST = 1, /**< Send read request command to PC. */
+ WAIT_CHUNKS = 2, /**< Wait to receive all expected chunks. */
+ SEND_BULK_ACK = 3, /**< Send bulk acknowledge to PC. */
+ WAIT_BULK_ACK_TIMEOUT = 4, /**< Wait timeout for confirmation of bulk
+ ack command. */
+ SEND_WRITE_REQUEST = 5, /**< Send write request command. */
+ WAIT_READ_REQUEST = 6, /**< Wait read request from PC. */
+ SENDING_CHUNKS = 7, /**< Send chunks to PC. */
+ WAIT_BULK_ACK = 8, /**< Wait bulk acknowledge to PC. */
+ WRITE_BULK_FINISH = 9, /**< Bulk acknowledge has been received,
+ finish the write bulk process. */
+ WAIT_WRITE_REQUEST = 10 /**< Wait bulk request command. */
+} ENUM8(TL_BulkProtocolState_t);
+
+/** Defined bulk process states. */
+TYPEDEF_ENUM {
+ BULK_SESSION_IDLE = 0x00, /**< Bulk transfer is closed and ready
+ for starting. */
+ BULK_SESSION_OPEN = 0x01, /**< Bulk transfer is opened. */
+ BULK_SESSION_PROCESSING = 0x02, /**< Processing the bulk transfer. */
+ BULK_SESSION_FINISHED = 0x04, /**< Bulk transfer is finished. */
+} ENUM8(TL_BulkSessionState_t);
+
+/** Bulk session Mode. */
+typedef enum {
+ BULK_RECEIVE = 1, /**< Receiving Mode. */
+ BULK_SEND = 2, /**< Transmitting Mode. */
+ BULK_RS = 3, /**< Receiving and transmitting Mode. */
+} TL_SessionMode_t;
+
+/**
+ * Status of received chunks in the current session.
+ */
+typedef enum {
+ /**< Chunks are being received in order in current session. */
+ VECTOR_NOT_COMPLETE = 0,
+ /**< All chunks for the current session have been received. */
+ VECTOR_COMPLETE = 1,
+ /**< Missing chunk(s) in the current session. */
+ VECTOR_MISSING_CHUNK = 2,
+} TL_BulkVectorStatus_t;
+
+/**
+ * Bulk Vector Entry parameters
+ */
+typedef struct {
+ PacketMeta_t *Buffer_p; /**< Pointer to reserved buffer meta info. */
+ uint8 *Payload_p; /**< Pointer to payload data in reserved
+ buffer. */
+ uint8 *Hash_p; /**< Pointer to calculated payload hash. */
+} TL_BulkVectorEntry_t;
+
+/**
+ * This type defines Bulk Vector parameters
+ */
+typedef struct {
+ /**< Bulk session status. */
+ TL_BulkSessionState_t Status;
+ /**< Requested bulk process(Read or Write). */
+ TL_SessionMode_t Mode;
+ /**< State of bulk protocol state machine. */
+ TL_BulkProtocolState_t State;
+ /**< Current bulk session ID. */
+ uint16 SessionId;
+ /**< Length of the file transfered with bulk transfer. */
+ uint64 TotalLength;
+ /**< Length of payload data transfered with bulk transfer. */
+ uint32 Length;
+ /**< Number of used buffers for bulk transfer. */
+ uint32 Buffers;
+ /**< requested size of payload. */
+ uint32 ChunkSize;
+ /**< Offset in the cuurent opened file.*/
+ uint64 Offset;
+ /**< Length of payload data transfered with bulk transfer. */
+ uint32 TransferedLength;
+ /**< Callback function pointer for bulk command handling.*/
+ void *BulkCommandCallback_p;
+ /**< Callback function pointer for bulk data command handling.*/
+ void *BulkDataCallback_p;
+ /**< Array with information for used buffers. */
+ TL_BulkVectorEntry_t Entries[MAX_BULK_TL_PROCESSES];
+} TL_BulkVectorList_t;
+
+/** Structure for current bulk transfer handling. */
+typedef struct {
+ uint32 TimerKey; /**< Timer Id for current used timer. */
+ TL_BulkVectorList_t *BulkVector_p; /**< Current used bulk vector for bulk
+ transfer.*/
+} BulkHandle_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*_T_BULK_PROTOCOL_H_*/
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_command_protocol.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_command_protocol.h
new file mode 100644
index 0000000..2ca51c6
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_command_protocol.h
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _T_COMMAND_PROTOCOL_H_
+#define _T_COMMAND_PROTOCOL_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup command_protocol
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+#include "error_codes.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/**
+ * The command type. COMMAND and GENERAL_RESPONSE can be used to
+ * indicate what type of commands to send. The _ACK command types are
+ * used internally to provide end-to-end reliability.
+ */
+typedef enum {
+ COMMAND_TYPE, /**< Command type of the packet.*/
+ COMMAND_ACK, /**< Acknwoledge type of the packet.*/
+ GENERAL_RESPONSE, /**< General response type of the packet.*/
+ GENERAL_RESPONSE_ACK /**< General response acknwoledge type of the packet.*/
+} CommandType_t;
+
+
+/**
+ * Used for storing input and output Payload data.
+ */
+typedef struct Buffer_s {
+ uint32 Size; /**< Size of the buffer in bytes.*/
+ uint8 *Data_p; /**< Data buffer. */
+} Buffer_t;
+
+/**
+ * Used for storing the status of the general response send by the
+ * command and for storing the data that should be send with the
+ * general response.
+ */
+typedef struct Result_s {
+ ErrorCode_e Status; /**< Status send by the general response. */
+ Buffer_t *Response_p; /**< Buffer holding data that should be
+ returned trough the general response */
+} Result_t;
+
+/**
+ * Holds information for the command received from the transport layer.
+ */
+typedef struct CommandData_s {
+ uint8 CommandNr; /**< Number of the command. */
+ uint8 ApplicationNr;/**< Number of the application (command) group. */
+ uint16 SessionNr; /**< Number of the session in which this command
+ was received.*/
+ CommandType_t Type; /**< Command type. */
+ Buffer_t Payload; /**< Holds the data received with the command.*/
+} CommandData_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*_T_COMMAND_PROTOCOL_H_*/
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_protrom_protocol.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_protrom_protocol.h
new file mode 100644
index 0000000..2bc544b
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_protrom_protocol.h
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef INCLUSION_GUARD_T_PROTROM_PROTOCOL_H
+#define INCLUSION_GUARD_T_PROTROM_PROTOCOL_H
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup protrom_family
+ * @{
+ * @addtogroup protrom_protocol
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_protrom_header.h"
+#include "t_protrom_network.h"
+#include "t_protrom_transport.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/** Protrom Family context. */
+typedef struct {
+ Protrom_TransportContext_t Transport;
+ Protrom_NetworkContext_t Network;
+} Protrom_FamilyContext_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif // INCLUSION_GUARD_T_PROTROM_PROTOCOL_H
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_protrom_transport.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_protrom_transport.h
new file mode 100644
index 0000000..20eef29
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_protrom_transport.h
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef INCLUSION_GUARD_T_PROTROM_TRANSPORT_H
+#define INCLUSION_GUARD_T_PROTROM_TRANSPORT_H
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup protrom_family
+ * @{
+ * @addtogroup ldr_protrom_transport_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+#include "t_protrom_network.h"
+
+/*******************************************************************************
+ * Types, constants and external variables
+ ******************************************************************************/
+/** Callback function type for the Protrom protocol handler. */
+typedef ErrorCode_e(* Protrom_Callback_fn)(void *Param_p, uint8 PDU, int PayloadLength, void *Payload_p, Communication_t *Communication_p);
+
+/** Structure for transfer input parameters in PROTROM protocol family */
+typedef struct {
+ Protrom_Header_t *Header_p; /**< Pointer to the PROTROM header structure.*/
+ void *Payload_p; /**< Pointer to the payload data.*/
+} Protrom_SendData_LP_t;
+
+/** Protorm Transport context */
+typedef struct {
+ /**< Callback function pointer for PROTROM protocol handler. */
+ Protrom_Callback_fn Callback;
+} Protrom_TransportContext_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif // INCLUSION_GUARD_T_PROTROM_TRANSPORT_H
+
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_r15_transport_layer.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_r15_transport_layer.h
new file mode 100644
index 0000000..7778607
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_r15_transport_layer.h
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _INCLUSION_GUARD_T_R15_TRANSPORT_LAYER_H_
+#define _INCLUSION_GUARD_T_R15_TRANSPORT_LAYER_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup ldr_r15_transport_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+#include "t_time_utilities.h"
+#include "t_r15_network_layer.h"
+#include "t_bulk_protocol.h"
+
+/*******************************************************************************
+ * Types, constants and external variables
+ ******************************************************************************/
+
+/** Structure for transfer input parameters in R15 prototcol family. */
+typedef struct {
+ R15_Header_t *Header_p; /**< Pointer to R15 header data. */
+ void *ExtendedHeader_p; /**< Pointer to Extended header data.*/
+ void *Payload_p; /**< Pointer to payload data.*/
+ uint32 Time; /**< Used tim for retransmission.*/
+ HandleFunction_t TimerCallBackFn_p; /**< Timer call back function for
+ retransmission.*/
+} SendData_LP_t;
+
+/** R15 Transport context. */
+typedef struct {
+ /**< Session/State for Incoming packet. */
+ uint16 SessionStateIn;
+ /**< Session/State for Outgoing packet. */
+ uint16 SessionStateOut;
+ /**< Bulk Session counter. */
+ uint16 BulkSessionCounter;
+ /**< Bulk Vector List. */
+ TL_BulkVectorList_t BulkVectorList[MAX_BULK_TL_PROCESSES];
+ /**< Bulk handle for the Current bulk transfer. */
+ BulkHandle_t BulkHandle;
+ /**< Bulk vector for previous current bulk transfer. */
+ TL_BulkVectorList_t PreviousBulkVector;
+ /**< Callback function pointer for bulk command handling.*/
+ void *BulkCommandCallback_p;
+ /**< Callback function pointer for bulk data command handling.*/
+ void *BulkDataCallback_p;
+ /**< Callback function pointer for handling end of bulk transfer.*/
+ void *EndOfDump_p;
+ /**< Length of payload data transfered with bulk transfer. */
+ uint32 Length;
+ /**< Offset in the cuurent opened file.*/
+ uint64 Offset;
+ /**< requested size of payload. */
+ uint32 ChunkSize;
+ /**< Current bulk session ID. */
+ uint16 Session;
+} R15_TransportContext_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif // _INCLUSION_GUARD_T_R15_TRANSPORT_LAYER_H_
+
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_z_protocol.h b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_z_protocol.h
new file mode 100644
index 0000000..ea4e07a
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/include/t_z_protocol.h
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef INCLUSION_GUARD_T_Z_PROTOCOL_H
+#define INCLUSION_GUARD_T_Z_PROTOCOL_H
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup z_family
+ * @{
+ * @addtogroup z_protocol
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_z_network.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/** Z protocol family context. */
+typedef struct {
+ Z_NetworkContext_t Network; /**< Network context.*/
+} Z_FamilyContext_t;
+
+
+/** Structure for transfer input parameters in Z protocol family */
+typedef struct {
+ uint8 *Data_p; /**< Pointer to the TI data.*/
+ uint8 Size; /**< Size of the data for transfer. */
+} Z_SendingContent_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif // INCLUSION_GUARD_T_Z_PROTOCOL_H
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_protocol.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_protocol.c
new file mode 100644
index 0000000..a26b677
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_protocol.c
@@ -0,0 +1,309 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup a2_protocol
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "r_communication_service.h"
+#include "r_a2_family.h"
+#include "r_a2_network.h"
+#include "r_a2_transport.h"
+#include "t_a2_header.h"
+#include "t_a2_protocol.h"
+#include "r_a2_protocol.h"
+#include "t_security_algorithms.h"
+#include "r_command_protocol.h"
+#include "r_debug.h"
+#include "r_debug_macro.h"
+#include "r_serialization.h"
+#include "r_memmory_utils.h"
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+/** Holding the sequence number for each communication device.*/
+uint8 A2_SequenceNr = 0;
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+static ErrorCode_e ProcessAcknowledgement(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p);
+static ErrorCode_e ProcessCommand(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p);
+static ErrorCode_e ProcessGeneralResponse(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p_p);
+static ErrorCode_e ProcessControlMessage(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p);
+static ErrorCode_e SendAcknowledge(Communication_t *Communication_p, const A2_PacketMeta_t *const Packet_p);
+static ErrorCode_e DispatchCommand(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p, A2_CommandData_t CmdData);
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+/*
+ * Sends command packet with command protocol.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] CmdData_p Pointer to the command data.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS If CmdData_p is NULL.
+ */
+ErrorCode_e Do_A2_Command_Send(Communication_t *Communication_p, A2_CommandData_t *CmdData_p)
+{
+ A2_Header_t Header = {0};
+ A2_SendData_LP_t Param;
+
+ if (NULL == CmdData_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ Param.Header_p = &Header;
+ Param.Payload_p = CmdData_p->Payload.Data_p;
+
+ Header.HeaderPattern = A2_HEADER_PATTERN;
+ Header.Protocol = PROTO_A2;
+ Header.SourceAddress = 0x00;
+ Header.DestinationAddress = CmdData_p->DestAddress;
+ Header.SequenceNumber = ++A2_SequenceNr;
+ Header.DataLength = CmdData_p->Payload.Size;
+
+ Param.Time = 0xFFFFFFFF; //ACK_TIMEOUT_IN_MS;
+ Param.TimerCallBackFn_p = NULL; //NOTE: the timer will be assigned in "A2_Transport_Send"
+
+ C_(printf("a2_protocol.c (%d): A2_Transport_Send! Type:%d SequenceNr:%d Command:%d CommandGroup:%d\n", __LINE__, CmdData_p->Type, Header.SequenceNumber, CmdData_p->ApplicationNr, CmdData_p->CommandNr);)
+
+ return A2_Transport_Send(Communication_p, &Param);
+}
+
+/*
+ * Decode received command.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Packet_p Pointer to the received buffer.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS if Packet_p is NULL.
+ */
+ErrorCode_e A2_Command_Process(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+
+ if (NULL == Packet_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ switch (((A2_PacketMeta_t *)Packet_p)->Header.Protocol) {
+ case PROTO_CTRL_MSG:
+ ReturnValue = ProcessControlMessage(Communication_p, Packet_p);
+ break;
+
+ case PROTO_A2:
+
+ if (0xFF == *(Packet_p->Payload_p + 1)) {
+ ReturnValue = ProcessGeneralResponse(Communication_p, Packet_p);
+ } else {
+ ReturnValue = ProcessCommand(Communication_p, Packet_p);
+ }
+
+ break;
+
+ case PROTO_A2_ACK:
+ ReturnValue = ProcessAcknowledgement(Communication_p, Packet_p);
+ break;
+
+ default:
+ ReturnValue = E_SUCCESS;
+ break;
+ }
+
+ return ReturnValue;
+}
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+static ErrorCode_e ProcessControlMessage(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p)
+{
+ A2_CommandData_t CmdData = {0};
+
+ if (NULL == Packet_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ void *Tmp_Buffer_p = Packet_p->Payload_p;
+
+ CmdData.Type = A2_CONTROL_MESSAGE;
+ CmdData.ApplicationNr = 0x10;
+ CmdData.CommandNr = get_uint8(&Tmp_Buffer_p);
+ CmdData.SessionNr = (uint16)(Packet_p->Header.SequenceNumber);
+ CmdData.Payload.Size = Packet_p->Header.DataLength;
+ CmdData.Payload.Data_p = NULL;
+
+ if (0 != CmdData.Payload.Size) {
+ CmdData.Payload.Data_p = (uint8 *)malloc(Packet_p->Header.DataLength);
+
+ if (NULL == CmdData.Payload.Data_p) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ memcpy(CmdData.Payload.Data_p, Packet_p->Payload_p, Packet_p->Header.DataLength);
+ }
+
+ return DispatchCommand(Communication_p, Packet_p, CmdData);
+}
+
+static ErrorCode_e ProcessAcknowledgement(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p)
+{
+ ErrorCode_e ReturnValue = E_GENERAL_FATAL_ERROR;
+
+ if (NULL == Packet_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ B_(printf("a2_protocol.c (%d): Received Acknowledge!\n", __LINE__);)
+ ReturnValue = A2_Network_CancelRetransmission(Communication_p, Packet_p->Header.SequenceNumber);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+ ReturnValue = A2_Network_PacketRelease(Communication_p, Packet_p);
+
+ if (A2_SPEEDFLASH_START == A2_SPEEDFLASH(Communication_p)->State) {
+ Communication_p->CommunicationDevice_p->Cancel(Communication_p);
+ A2_SPEEDFLASH(Communication_p)->State = A2_SPEEDFLASH_ACTIVE;
+ A2_SPEEDFLASH(Communication_p)->InboundState = A2_SPEEDFLASH_READ_REQ;
+ }
+
+ErrorExit:
+ return ReturnValue;
+}
+
+static ErrorCode_e ProcessCommand(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p)
+{
+ ErrorCode_e ReturnValue;
+ A2_CommandData_t CmdData = {0};
+
+ if (NULL == Packet_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ void *Tmp_Buffer_p = Packet_p->Payload_p;
+
+ CmdData.Type = A2_COMMAND;
+ CmdData.ApplicationNr = get_uint8(&Tmp_Buffer_p);
+ CmdData.CommandNr = get_uint8(&Tmp_Buffer_p);
+ CmdData.SessionNr = (uint16)(Packet_p->Header.SequenceNumber);
+ CmdData.Payload.Size = Packet_p->Header.DataLength;
+ CmdData.Payload.Data_p = NULL;
+
+ if (0 != CmdData.Payload.Size) {
+ CmdData.Payload.Data_p = (uint8 *)malloc(Packet_p->Header.DataLength);
+
+ if (NULL == CmdData.Payload.Data_p) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ memcpy(CmdData.Payload.Data_p, Packet_p->Payload_p, Packet_p->Header.DataLength);
+ }
+
+ ReturnValue = SendAcknowledge(Communication_p, Packet_p);
+
+ if (E_SUCCESS != ReturnValue) {
+ BUFFER_FREE(CmdData.Payload.Data_p);
+ return ReturnValue;
+ }
+
+ return DispatchCommand(Communication_p, Packet_p, CmdData);
+}
+
+static ErrorCode_e ProcessGeneralResponse(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p)
+{
+ ErrorCode_e ReturnValue;
+ A2_CommandData_t CmdData = {0};
+
+ if (NULL == Packet_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ void *Tmp_Buffer_p = Packet_p->Payload_p;
+
+ CmdData.Type = A2_GENERAL_RESPONSE;
+ CmdData.ApplicationNr = get_uint8(&Tmp_Buffer_p);
+ // skip 0xFF byte signifying GR
+ skip_uint8(&Tmp_Buffer_p);
+ // skip more packets field
+ // TODO check how we should handle situation when GR contains more packets
+ skip_uint8(&Tmp_Buffer_p);
+ CmdData.CommandNr = get_uint8(&Tmp_Buffer_p);
+ CmdData.SessionNr = (uint16)(Packet_p->Header.SequenceNumber);
+ CmdData.Payload.Size = Packet_p->Header.DataLength;
+ CmdData.Payload.Data_p = NULL;
+
+ if (0 != CmdData.Payload.Size) {
+ CmdData.Payload.Data_p = (uint8 *)malloc(Packet_p->Header.DataLength);
+
+ if (NULL == CmdData.Payload.Data_p) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ memcpy(CmdData.Payload.Data_p, Packet_p->Payload_p, Packet_p->Header.DataLength);
+ }
+
+ ReturnValue = SendAcknowledge(Communication_p, Packet_p);
+
+ if (E_SUCCESS != ReturnValue) {
+ BUFFER_FREE(CmdData.Payload.Data_p);
+ return ReturnValue;
+ }
+
+ return DispatchCommand(Communication_p, Packet_p, CmdData);
+}
+
+
+static ErrorCode_e DispatchCommand(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p, A2_CommandData_t CmdData)
+{
+ ErrorCode_e ReturnValue;
+
+ ReturnValue = A2_Network_PacketRelease(Communication_p, Packet_p);
+
+ ReturnValue = Communication_p->Do_CEH_Call_Fn(OBJECT_CEH_CALL(Communication_p), (CommandData_t *)&CmdData);
+
+ if (NULL != CmdData.Payload.Data_p) {
+ free(CmdData.Payload.Data_p);
+ }
+
+ return ReturnValue;
+}
+
+static ErrorCode_e SendAcknowledge(Communication_t *Communication_p, const A2_PacketMeta_t *const Packet_p)
+{
+ A2_Header_t Header = {0};
+ A2_SendData_LP_t Param;
+
+ Header.HeaderPattern = A2_HEADER_PATTERN;
+ Header.Protocol = PROTO_A2_ACK;
+ Header.SourceAddress = 0x00;
+ Header.DestinationAddress = Packet_p->Header.SourceAddress;
+ Header.SequenceNumber = Packet_p->Header.SequenceNumber;
+
+ Param.Header_p = &Header;
+ Param.Payload_p = NULL;
+ Param.Time = 0;
+ Param.TimerCallBackFn_p = NULL;
+
+ return A2_Transport_Send(Communication_p, &Param);
+}
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_speedflash.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_speedflash.c
new file mode 100755
index 0000000..b411027
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_speedflash.c
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup a2_protocol
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "r_communication_service.h"
+#include "r_debug.h"
+#include "r_debug_macro.h"
+#include "r_a2_speedflash.h"
+#include "t_a2_family.h"
+#include "r_a2_family.h"
+#include "r_a2_network.h"
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+static void A2_Speedflash_WriteCallback(const void *Data_p, const uint32 Length, void *Param_p);
+static void A2_Speedflash_ReadCallback(const void *Data_p, const uint32 Length, void *Param_p);
+
+/**
+ * Set the LCM in A2 Speedflash Mode.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] State State of the speedflash (TRUE - on, FALSE - off).
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval
+ */
+void Do_A2_Speedflash_Start(Communication_t *Communication_p)
+{
+ A2_SPEEDFLASH(Communication_p)->State = A2_SPEEDFLASH_START;
+
+ C_(printf("a2_speedflash.c (%d): Do_A2_Speedflash_Start\n", __LINE__);)
+}
+
+void Do_A2_Speedflash_SetLastBlock(Communication_t *Communication_p)
+{
+ A2_SPEEDFLASH(Communication_p)->LastBlock = TRUE;
+
+ C_(printf("a2_speedflash.c (%d): Do_A2_Speedflash_SetLastBlock\n", __LINE__);)
+}
+
+/**
+ * Writes A2 speedflash sub-block on the comm device.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Buffer Buffer containing the data of the sub-block.
+ * @param [in] BufferSize Size of the speedflash sub-blocks.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval
+ */
+ErrorCode_e Do_A2_Speedflash_WriteBlock(Communication_t *Communication_p, const void *Buffer, const uint32 BufferSize)
+{
+ A2_SPEEDFLASH(Communication_p)->Outbound_p = (void *)Buffer;
+ A2_SPEEDFLASH(Communication_p)->OutboundSize = BufferSize;
+
+ C_(printf("a2_speedflash.c (%d): Do_A2_Speedflash_WriteBlock\n", __LINE__);)
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2_Speedflash_Poll(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturValue = E_SUCCESS;
+
+ switch (A2_SPEEDFLASH(Communication_p)->InboundState) {
+ case A2_SPEEDFLASH_READ_REQ:
+ A2_SPEEDFLASH(Communication_p)->InboundState = A2_SPEEDFLASH_WAIT_READ_REQ;
+
+ if (E_SUCCESS != Communication_p->CommunicationDevice_p->Read((void *)A2_SPEEDFLASH(Communication_p)->Scratch,
+ A2_SPEEDFLASH_REQ_SIZE, A2_Speedflash_ReadCallback, Communication_p)) {
+ A2_SPEEDFLASH(Communication_p)->InboundState = A2_SPEEDFLASH_READ_REQ;
+ }
+
+ break;
+ case A2_SPEEDFLASH_WAIT_READ_REQ:
+ /* nothing to do */
+ break;
+ case A2_SPEEDFLASH_WRITE_BLOCK:
+
+ if (NULL != A2_SPEEDFLASH(Communication_p)->Outbound_p) {
+ A2_SPEEDFLASH(Communication_p)->InboundState = A2_SPEEDFLASH_WAIT_WRITE_BLOCK;
+
+ if (E_SUCCESS != Communication_p->CommunicationDevice_p->Write(A2_SPEEDFLASH(Communication_p)->Outbound_p,
+ A2_SPEEDFLASH(Communication_p)->OutboundSize, A2_Speedflash_WriteCallback, Communication_p)) {
+ A2_SPEEDFLASH(Communication_p)->InboundState = A2_SPEEDFLASH_WRITE_BLOCK;
+ }
+ }
+
+ break;
+ case A2_SPEEDFLASH_WAIT_WRITE_BLOCK:
+ /* nothing to do */
+ break;
+ }
+
+ return ReturValue;
+}
+
+void A2_Speedflash_WriteCallback(const void *Data_p, const uint32 Length, void *Param_p)
+{
+ Communication_t *Communication_p = (Communication_t *)Param_p;
+
+ A2_SPEEDFLASH(Communication_p)->Outbound_p = NULL;
+ A2_SPEEDFLASH(Communication_p)->OutboundSize = 0;
+
+ if (A2_SPEEDFLASH(Communication_p)->LastBlock) {
+ A2_SPEEDFLASH(Communication_p)->LastBlock = FALSE;
+ A2_SPEEDFLASH(Communication_p)->State = A2_SPEEDFLASH_INACTIVE;
+
+ /* put A2 state machine in error state to reinitialize */
+ A2_NETWORK(Communication_p)->Inbound.State = A2_RECEIVE_ERROR;
+ } else {
+ A2_SPEEDFLASH(Communication_p)->InboundState = A2_SPEEDFLASH_READ_REQ;
+ }
+}
+
+void A2_Speedflash_ReadCallback(const void *Data_p, const uint32 Length, void *Param_p)
+{
+ Communication_t *Communication_p = (Communication_t *)Param_p;
+ A2_CommandData_t CmdData;
+
+ CmdData.Type = A2_SPEEDFLASH_GR;
+ CmdData.Payload.Size = A2_SPEEDFLASH_REQ_SIZE;
+ CmdData.Payload.Data_p = (uint8 *)malloc(A2_SPEEDFLASH_REQ_SIZE);
+
+ if (NULL == CmdData.Payload.Data_p) {
+ A_(printf("a2_speedflash.c(%d): memory allocation failed", __LINE__);)
+ return;
+ }
+
+ A2_SPEEDFLASH(Communication_p)->InboundState = A2_SPEEDFLASH_WRITE_BLOCK;
+
+ memcpy(CmdData.Payload.Data_p, Data_p, Length);
+ Communication_p->Do_CEH_Call_Fn(OBJECT_CEH_CALL(Communication_p), (CommandData_t *)&CmdData);
+ free(CmdData.Payload.Data_p);
+}
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_transport.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_transport.c
new file mode 100644
index 0000000..cee9aa3
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_transport.c
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup ldr_transport_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "c_system.h"
+#include "r_a2_network.h"
+#include "r_a2_transport.h"
+#include <stdlib.h>
+#include <string.h>
+#include "r_basicdefinitions.h"
+#include "t_time_utilities.h"
+#include "r_debug.h"
+#include "r_debug_macro.h"
+#include "r_a2_header.h"
+#include "r_a2_protocol.h"
+#include "r_a2_family.h"
+#include "r_a2_speedflash.h"
+#include "r_communication_service.h"
+#include "t_security_algorithms.h"
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+static Timer_t *A2_TimerSet(A2_PacketMeta_t *Packet_p, const A2_SendData_LP_t *const InputData_p, Communication_t *Communication_p);
+static void A2_Transport_OutHashCallback(const void *const Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p);
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+/*
+ * Handles all registered TL processes for A2 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e A2_Transport_Poll(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+#ifndef CFG_ENABLE_LOADER_TYPE
+ A2_PacketMeta_t *Packet_p = NULL;
+
+ if (A2_SPEEDFLASH_ACTIVE == A2_SPEEDFLASH(Communication_p)->State) {
+ ReturnValue = A2_Speedflash_Poll(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+ } else {
+ ReturnValue = A2_Network_ReceiverHandler(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+
+ ReturnValue = A2_Network_TransmiterHandler(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+ }
+
+ Packet_p = (A2_PacketMeta_t *)QUEUE(Communication_p, FifoDequeue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p);
+
+ if (NULL != Packet_p) {
+ return A2_Command_Process(Communication_p, Packet_p);
+ }
+
+#endif
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Function for sending packet in A2 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] InputDataIn_p Pointer to the input data.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_ALLOCATE_COMM_BUFFER Failed to allocate communication
+ * buffer.
+ */
+ErrorCode_e A2_Transport_Send(Communication_t *Communication_p, void *InputDataIn_p)
+{
+ A2_PacketMeta_t *Packet_p = NULL;
+ A2_SendData_LP_t *InputData_p = (A2_SendData_LP_t *)InputDataIn_p;
+
+ Packet_p = (A2_PacketMeta_t *)A2_Network_PacketAllocate(Communication_p, A2_COMMAND_BUFFER_SIZE);
+
+ if (NULL == Packet_p) {
+ A_(printf("a2_transport.c (%d): ** Failed to get available buffers! **\n", __LINE__);)
+ return E_FAILED_TO_ALLOCATE_COMM_BUFFER;
+ }
+
+ Packet_p->Resend = 0;
+ Packet_p->CallBack_p = NULL;
+
+ Packet_p->Timer_p = A2_TimerSet(Packet_p, InputData_p, Communication_p);
+ Packet_p->Header = *InputData_p->Header_p;
+ A2_SerializeHeader(Packet_p->Buffer_p, &Packet_p->Header);
+
+ /* setup payload for calculation */
+ memcpy(Packet_p->Buffer_p + A2_HEADER_LENGTH, InputData_p->Payload_p, Packet_p->Header.DataLength);
+
+ /* Calculate Payload CRC */
+ Packet_p->Communication_p = Communication_p;
+
+ if (HASH_NONE != Communication_p->CurrentFamilyHash) {
+ Communication_p->HashDevice_p->Calculate(OBJECT_HASH(Communication_p),
+ Communication_p->CurrentFamilyHash,
+ (void *)Packet_p->Buffer_p, Packet_p->Header.DataLength + A2_HEADER_LENGTH,
+ (uint8 *)&Packet_p->CRC, (HashCallback_t)A2_Transport_OutHashCallback,
+ (void *)Packet_p);
+ } else {
+ memset(&Packet_p->CRC, 0x0, sizeof(uint16));
+ Packet_p->Flags = Packet_p->Flags | A2_BUF_PAYLOAD_CRC_CALCULATED;
+ (void)QUEUE(Packet_p->Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Outbound_p, Packet_p);
+ }
+
+ return E_SUCCESS;
+}
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+
+/*
+ * Callback function for handling calculated data.
+ *
+ * @param [in] Data_p Pointer to the data buffer for calculation.
+ * @param [in] Length Length of the data for calculation.
+ * @param [out] Hash_p Pointer to buffer with calculated hash.
+ * @param [in] Param_p Pointer to extra parameters.
+ *
+ * @return none.
+ */
+static void A2_Transport_OutHashCallback(const void *const Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p)
+{
+ IDENTIFIER_NOT_USED(Data_p);
+ IDENTIFIER_NOT_USED(Length);
+ A2_PacketMeta_t *Packet_p = (A2_PacketMeta_t *)Param_p;
+
+ Packet_p->Flags = Packet_p->Flags | A2_BUF_PAYLOAD_CRC_CALCULATED;
+ memcpy(&Packet_p->CRC, Hash_p, sizeof(uint16));
+
+ if (Packet_p->Header.Protocol == PROTO_A2_ACK) {
+ memcpy((uint8 *)((Packet_p->Buffer_p) + A2_HEADER_LENGTH_ACK), Hash_p, sizeof(uint16));
+ } else {
+ memcpy((uint8 *)((Packet_p->Buffer_p) + A2_HEADER_LENGTH + (Packet_p->Header.DataLength)), Hash_p, sizeof(uint16));
+ }
+
+ (void)QUEUE(Packet_p->Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Outbound_p, Packet_p);
+}
+
+/*
+ * Function for Timer setting.
+ *
+ * @param [in] Packet_p Pointer to the R15 packet meta data.
+ * @param [in] InputData_p Pointer to the input parameters with settings.
+ * @param [in] Communication_p Communication module context.
+ *
+ * @return none.
+ */
+static Timer_t *A2_TimerSet(A2_PacketMeta_t *Packet_p, const A2_SendData_LP_t *const InputData_p, Communication_t *Communication_p)
+{
+ Timer_t *Timer_p = NULL;
+
+ if (InputData_p->Time > 0) {
+ Timer_p = (Timer_t *)malloc(sizeof(Timer_t));
+
+ if (NULL == Timer_p) {
+ return NULL;
+ }
+
+ /* timer data */
+ Timer_p->Time = InputData_p->Time;
+ Timer_p->PeriodicalTime = 0;
+ Timer_p->HandleFunction_p = (HandleFunction_t)(InputData_p->TimerCallBackFn_p);
+ Timer_p->Data_p = (void *)Packet_p;
+ Timer_p->Param_p = (void *)Communication_p;
+ }
+
+ return Timer_p;
+}
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c
new file mode 100644
index 0000000..173bb5b
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c
@@ -0,0 +1,1461 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup bulk_protocol
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "c_system.h"
+#include "r_basicdefinitions.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "r_bulk_protocol.h"
+#include "r_r15_transport_layer.h"
+#include "r_r15_network_layer.h"
+#include "r_r15_family.h"
+#include "r_r15_header.h"
+#include "r_debug.h"
+#include "r_debug_macro.h"
+#include "r_communication_service.h"
+#include "t_security_algorithms.h"
+#include "r_memmory_utils.h"
+
+#ifdef CFG_ENABLE_MEASUREMENT_TOOL
+#include "r_measurement_tool.h"
+#include "r_time_utilities.h"
+#endif
+
+/***********************************************************************
+ * Definition of external constants and variables
+ **********************************************************************/
+#define SESSION(x) ((R15_FamilyContext_t *)(x)->FamilyContext_p)->Transport.Session
+#define CHUNKSIZE(x) ((R15_FamilyContext_t *)(x)->FamilyContext_p)->Transport.ChunkSize
+#define LENGTH(x) ((R15_FamilyContext_t *)(x)->FamilyContext_p)->Transport.Length
+#define OFFSET(x) ((R15_FamilyContext_t *)(x)->FamilyContext_p)->Transport.Offset
+#define TOTALLENGTH(x) ((R15_FamilyContext_t *)(x)->FamilyContext_p)->Transport.BulkHandle.BulkVector_p->TotalLength
+#define TRANSFEREDLENGTH(x) ((R15_FamilyContext_t *)(x)->FamilyContext_p)->Transport.BulkHandle.BulkVector_p->TransferedLength
+
+#ifdef CFG_ENABLE_MEASUREMENT_TOOL
+extern Measurement_t *Measurement_p;
+#endif
+
+static void R15_Bulk_ReadChunkCallBack(Communication_t *Communication_p, const void *const Timer_p, const void *const Data_p);
+static void R15_Bulk_RetransmitChunks_CallBack(const Communication_t *const Communication_p, const void *const Timer_p, const void *const Data_p);
+static ErrorCode_e R15_Bulk_Process_Read(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p, PacketMeta_t *Packet_p);
+static ErrorCode_e R15_Bulk_SendReadRequest(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p, uint32 Chunks, void *ChunksList_p, void *CallBack_p);
+static ErrorCode_e R15_Bulk_SendWriteRequest(Communication_t *Communication_p);
+static void R15_Bulk_SendData(Communication_t *Communication_p, PacketMeta_t *Packet_p, uint32 ChunkId);
+static boolean R15_Bulk_CheckTransmitedChunks(const TL_BulkVectorList_t *BulkVector_p);
+static boolean R15_Bulk_CheckIdInList(const TL_BulkVectorList_t *BulkVector_p, const uint32 ChunkId, const uint8 *const Data_p, const uint32 Length);
+static uint32 R15_Bulk_GetNextPacketChunkId(const TL_BulkVectorList_t *BulkVector_p);
+static void R15_Bulk_GetListOfReceivedChunks(const TL_BulkVectorList_t *const BulkVector_p, uint32 *Chunks_p, uint8 *ChunkList_p);
+static uint32 R15_Bulk_GetChunkId(const PacketMeta_t *const Packet_p);
+static uint32 R15_Bulk_GetTimerChunkRetransmision(const Communication_t *const Communication_p, uint32 Time, HandleFunction_t CallBack_p);
+static void R15_Bulk_MarkNotAckChunks(TL_BulkVectorList_t *BulkVector_p, const uint8 *const Payload_p, const uint32 Length);
+static void R15_Bulk_MarkNotAckAllChunks(TL_BulkVectorList_t *BulkVector_p);
+#ifdef CFG_ENABLE_LOADER_TYPE
+static boolean R15_Bulk_CheckAcknowledgedChunks(const TL_BulkVectorList_t *BulkVector_p, const uint8 *const Payload_p);
+#endif
+static void R15_Bulk_OutHashCallback(const void *const Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p);
+static TL_BulkVectorStatus_t R15_Bulk_GetVectorStatus(TL_BulkVectorList_t *BulkVector_p);
+static TL_BulkSessionID_Status_t R15_Bulk_CheckBulkSession(Communication_t *Communication_p, uint16 SessionId);
+static ErrorCode_e R15_Bulk_DataRequestHandler(Communication_t *Communication_p, PacketMeta_t *Packet_p);
+static ErrorCode_e R15_Bulk_ReadRequestHandler(Communication_t *Communication_p, PacketMeta_t *Packet_p);
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+static void R15_Bulk_ClearBulkTmpParam(Communication_t *Communication_p);
+static boolean IsChunkReceived(Communication_t *Communication_p, uint32 ChunkId);
+#endif
+
+
+/***********************************************************************
+ * Definition of external functions
+ **********************************************************************/
+#ifndef CFG_ENABLE_LOADER_TYPE
+void Do_R15_Bulk_SetCallbacks(Communication_t *Communication_p, void *BulkCommandCallback_p, void *BulkDataCallback_p, void *EndOfDump_p)
+{
+ R15_TRANSPORT(Communication_p)->BulkCommandCallback_p = BulkCommandCallback_p;
+ R15_TRANSPORT(Communication_p)->BulkDataCallback_p = BulkDataCallback_p;
+ R15_TRANSPORT(Communication_p)->EndOfDump_p = EndOfDump_p;
+}
+#endif
+
+/*
+ * Opens Bulk session.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] SessionId Session ID.
+ * @param [in] Mode Type of operation(Read or Write).
+ * (send or receive) over the bulk protocol.
+ *
+ * @return Vector ID Vector ID of the newly opened session.
+ * @retval BULK_ERROR If the session can not be opened.
+ */
+uint32 Do_R15_Bulk_OpenSession(const Communication_t *const Communication_p, const uint16 SessionId, const TL_SessionMode_t Mode)
+{
+ uint32 VectorCounter;
+
+ if (NULL == Communication_p) {
+ return BULK_ERROR;
+ }
+
+ for (VectorCounter = 1; (VectorCounter < MAX_BULK_TL_PROCESSES) && (R15_TRANSPORT(Communication_p)->BulkVectorList[VectorCounter].Status != BULK_SESSION_IDLE); VectorCounter++);
+
+ if (MAX_BULK_TL_PROCESSES != VectorCounter) {
+ if (R15_TRANSPORT(Communication_p)->BulkVectorList[VectorCounter].Status != BULK_SESSION_IDLE) {
+ VectorCounter = BULK_ERROR;
+ } else {
+ R15_TRANSPORT(Communication_p)->BulkVectorList[VectorCounter].Status = BULK_SESSION_OPEN;
+ R15_TRANSPORT(Communication_p)->BulkVectorList[VectorCounter].SessionId = SessionId;
+ R15_TRANSPORT(Communication_p)->BulkVectorList[VectorCounter].Mode = Mode;
+ R15_TRANSPORT(Communication_p)->BulkVectorList[VectorCounter].Length = 0;
+ R15_TRANSPORT(Communication_p)->BulkVectorList[VectorCounter].TransferedLength = 0;
+ R15_TRANSPORT(Communication_p)->BulkVectorList[VectorCounter].Offset = 0;
+ R15_TRANSPORT(Communication_p)->BulkVectorList[VectorCounter].ChunkSize = 0;
+ R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey = 0;
+ }
+ } else {
+ VectorCounter = BULK_ERROR;
+ }
+
+ C_(printf("bulk_protocol.c (%d): Opened Bulk session(%d)with VId(%d)\n", __LINE__, SessionId, VectorCounter);)
+ return VectorCounter;
+}
+
+/*
+ * Creates Bulk Vector.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] BulkVector Index of Bulk Vector.
+ * @param [in] Length Data Length in bytes.
+ * @param [in] BuffSize Requested size of each Buffer.
+ * @param [in] CreatedBulkVector_p Already created bulk vector which
+ * need to be updated with correct
+ * information.
+ *
+ * @return Vector ID The ID of the Vector that has been created.
+ * @retval BULK_ERROR If creation of vector failed.
+ */
+TL_BulkVectorList_t *Do_R15_Bulk_CreateVector(const Communication_t *const Communication_p, const uint32 BulkVector, uint32 Length, const uint32 BuffSize, TL_BulkVectorList_t *CreatedBulkVector_p)
+{
+ uint32 Counter;
+ uint32 AvailableBuffers = 0;
+ uint32 Buffers;
+ PacketMeta_t *Packet_p = NULL;
+ TL_BulkVectorList_t *BulkVector_p = NULL;
+
+ if (NULL == Communication_p) {
+ return NULL;
+ }
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+ int BuffersNr = 0;
+#endif
+
+ /* check input parameters */
+ if ((0 == BulkVector) || (MAX_BULK_TL_PROCESSES <= BulkVector) || (BuffSize == 0) || (BuffSize > (BULK_BUFFER_SIZE - ALIGNED_HEADER_LENGTH - ALIGNED_BULK_EXTENDED_HEADER_LENGTH)) || (Length == 0)) {
+ A_(printf("bulk_protocol.c (%d): ** Invalid input parameters! **\n", __LINE__);)
+ return NULL;
+ }
+
+ BulkVector_p = &(R15_TRANSPORT(Communication_p)->BulkVectorList[BulkVector]);
+
+ if (NULL == CreatedBulkVector_p) {
+ Buffers = ((Length + BuffSize - 1) / BuffSize);
+
+ if (0 == Buffers) {
+ return NULL;
+ }
+
+ AvailableBuffers = BUFFER(Communication_p, BuffersAvailable_Fn)(OBJECT_BUFFER(Communication_p), BULK_BUFFER_SIZE);
+
+ if (AvailableBuffers >= Buffers) {
+ BulkVector_p->Length = Length;
+ BulkVector_p->Buffers = Buffers;
+ BulkVector_p->ChunkSize = BuffSize;
+ BulkVector_p->Offset = 0;
+
+ for (Counter = 0; (Counter < Buffers); Counter++) {
+ BulkVector_p->Entries[Counter].Buffer_p = NULL;
+
+ if (BULK_SEND == BulkVector_p->Mode) {
+#ifdef CFG_ENABLE_LOADER_TYPE
+ Packet_p = R15_Network_PacketAllocate(Communication_p, BULK_BUFFER_SIZE);
+
+ if (NULL == Packet_p) {
+ A_(printf("bulk_protocol.c (%d): ** Memory allocation failed! **\n", __LINE__);)
+ return NULL;
+ }
+
+ Packet_p->ExtendedHeader_p = Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH;
+ Packet_p->Payload_p = Packet_p->ExtendedHeader_p + ALIGNED_BULK_EXTENDED_HEADER_LENGTH;
+#else
+ /* packet meta info allocate */
+ Packet_p = (PacketMeta_t *)malloc(sizeof(PacketMeta_t));
+
+ if (NULL == Packet_p) {
+ return NULL;
+ }
+
+ memset(Packet_p, 0, sizeof(PacketMeta_t));
+
+ /* packet meta info setup */
+ Packet_p->Buffer_p = NULL;
+ Packet_p->BufferSize = BULK_BUFFER_SIZE;
+ SET_PACKET_FLAGS(Packet_p, PACKET_ALLOCATION_STATE_MASK, BUF_ALLOCATED);
+ Packet_p->Payload_p = (uint8 *)(HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH + ALIGNED_BULK_EXTENDED_HEADER_LENGTH);
+ Packet_p->ExtendedHeader_p = Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH;
+ BuffersNr = 0;
+
+ do {
+ if (NULL == R15_NETWORK(Communication_p)->MetaInfoList[BuffersNr]) {
+ R15_NETWORK(Communication_p)->MetaInfoList[BuffersNr] = Packet_p;
+ break;
+ }
+
+ BuffersNr ++;
+ } while (BuffersNr < (COMMAND_BUFFER_COUNT + BULK_BUFFER_COUNT));
+
+ if (COMMAND_BUFFER_COUNT + BULK_BUFFER_COUNT <= BuffersNr) {
+ BUFFER_FREE(Packet_p);
+ return NULL;
+ }
+
+#endif // #ifdef CFG_ENABLE_LOADER_TYPE
+
+ BulkVector_p->Entries[Counter].Buffer_p = Packet_p;
+ BulkVector_p->Entries[Counter].Payload_p = Packet_p->Payload_p;
+ BulkVector_p->Entries[Counter].Hash_p = Packet_p->Hash;
+ }
+ }
+ } else {
+ A_(printf("bulk_protocol.c (%d) ** Not enough buffers! ** \n", __LINE__);)
+ return NULL;
+ }
+ } else {
+ memcpy(BulkVector_p, CreatedBulkVector_p, sizeof(TL_BulkVectorList_t));
+ }
+
+ return BulkVector_p;
+}
+
+/*
+ * Frees Bulk Vector.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] BulkVector_p Pointer to the Bulk Vector.
+ * @param [in] ReqReleaseBuffer Defines if complete buffers with metadata will
+ * be released or only only the metadata will be cleared.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval BULK_ERROR Error while destroying vector.
+ */
+uint32 Do_R15_Bulk_DestroyVector(const Communication_t *const Communication_p, TL_BulkVectorList_t *BulkVector_p, boolean ReqReleaseBuffer)
+{
+ uint32 ReturnValue = E_SUCCESS;
+ uint32 Counter;
+ int BuffersNr = 0;
+
+ if (NULL == Communication_p) {
+ return BULK_ERROR;
+ }
+
+ if (NULL == BulkVector_p) {
+ A_(printf("bulk_protocol.c (%d): ** Invalid bulk vector! **\n", __LINE__);)
+ return BULK_ERROR;
+ }
+
+ for (Counter = 0; (Counter < BulkVector_p->Buffers); Counter++) {
+ /* clear all flags by setting buffer as free */
+ BulkVector_p->Entries[Counter].Buffer_p->Flags = BUF_FREE;
+ BulkVector_p->Entries[Counter].Hash_p = NULL;
+
+ if (NULL != BulkVector_p->Entries[Counter].Buffer_p) {
+ if (ReqReleaseBuffer) {
+ ReturnValue = R15_Network_PacketRelease(Communication_p, BulkVector_p->Entries[Counter].Buffer_p);
+ BulkVector_p->Entries[Counter].Buffer_p = NULL;
+ } else {
+ C_(printf("bulk_protocol.c (%d): Destroyed meta info data (0x%x)for bulk buffers! \n", __LINE__, BulkVector_p->Entries[Counter].Buffer_p);)
+ BuffersNr = 0;
+
+ do {
+ if (BulkVector_p->Entries[Counter].Buffer_p == R15_NETWORK(Communication_p)->MetaInfoList[BuffersNr]) {
+ R15_NETWORK(Communication_p)->MetaInfoList[BuffersNr] = NULL;
+ /* release meta info for buffer */
+ free(BulkVector_p->Entries[Counter].Buffer_p);
+ BulkVector_p->Entries[Counter].Buffer_p = NULL;
+ break;
+ }
+
+ BuffersNr ++;
+ } while (BuffersNr < (COMMAND_BUFFER_COUNT + BULK_BUFFER_COUNT));
+ }
+ }
+ }
+
+ C_(printf("bulk_protocol.c (%d): Destroyed bulk vector for session(%d)! \n", __LINE__, BulkVector_p->SessionId);)
+ BulkVector_p->Status = BULK_SESSION_IDLE;
+ BulkVector_p->SessionId = 0;
+ BulkVector_p->Mode = BULK_RECEIVE;
+ BulkVector_p->Length = 0;
+ BulkVector_p->Buffers = 0;
+ BulkVector_p->ChunkSize = 0;
+ BulkVector_p->Offset = 0;
+
+ return ReturnValue;
+}
+
+/*
+ * Start specified bulk session.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] BulkVector_p Pointer to the Bulk Vector.
+ * @param [in] Offset Sets the offset from where data
+ * read/write should be performed.
+ *
+ * @retval E_INVALID_BULK_MODE Invalid bulk mode.
+ * @retval E_FAILED_TO_START_BULK_SESSION Either the session is
+ * invalid or the BulkVector is invalid.
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_R15_Bulk_StartSession(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p, const uint64 Offset)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ uint32 ChunkId;
+
+ VERIFY(NULL != Communication_p, E_INVALID_INPUT_PARAMETERS);
+
+ /* Verify the new bulk vector. */
+ VERIFY(NULL != BulkVector_p, E_INVALID_INPUT_PARAMETERS);
+ /* Verify that the bulk session is opend for this bulk vector. */
+ VERIFY(BULK_SESSION_IDLE != BulkVector_p->Status, E_FAILED_TO_START_BULK_SESSION);
+ /* Verify that the previouse bulk session is closed. */
+ VERIFY(NULL == R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p, E_PREVIOUS_BULK_SESSION_IS_NOT_CLOSED);
+
+ BulkVector_p->Status = BULK_SESSION_PROCESSING;
+ BulkVector_p->Offset = Offset;
+
+ /* set the handle for the current bulk vector */
+ R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p = BulkVector_p;
+ R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey = 0;
+
+ C_(printf("bulk_protocol.c(%d) Session(%d) Started!\n", __LINE__, BulkVector_p->SessionId);)
+ C_(printf("bulk_protocol.c(%d) Req: Chunks(%d) ChunkSize(%d) Length(%d)\n", __LINE__, BulkVector_p->Buffers, BulkVector_p->ChunkSize, BulkVector_p->Length);)
+
+ if (BULK_RECEIVE == BulkVector_p->Mode) {
+ /* Set BULK READ state machine */
+#ifdef CFG_ENABLE_LOADER_TYPE
+ BulkVector_p->State = SEND_READ_REQUEST;
+#else
+ BulkVector_p->State = WAIT_WRITE_REQUEST;
+#endif
+ ReturnValue = R15_Bulk_Process_Read(Communication_p, BulkVector_p, NULL);
+ } else {
+ VERIFY(BULK_SEND == BulkVector_p->Mode, E_INVALID_BULK_MODE);
+
+ for (ChunkId = 0; ChunkId < BulkVector_p->Buffers; ChunkId++) {
+ SET_PACKET_FLAGS(BulkVector_p->Entries[ChunkId].Buffer_p, PACKET_TX_STATE_MASK, BUF_TX_READY);
+ }
+
+ /* Set BULK WRITE state machine */
+#ifdef CFG_ENABLE_LOADER_TYPE
+ BulkVector_p->State = SEND_WRITE_REQUEST;
+#else
+ BulkVector_p->State = WAIT_READ_REQUEST;
+#endif
+ ReturnValue = R15_Bulk_Process_Write(Communication_p, BulkVector_p);
+ }
+
+#ifdef CFG_ENABLE_MEASUREMENT_TOOL
+ ReturnValue = Do_Measurement_CreateSessionMeasurementData(Communication_p, &(Measurement_p->MeasurementData_p->SessionMeasurement_p),
+ NULL, BulkVector_p->Buffers, BulkVector_p->SessionId);
+ ReturnValue = MP(Measurement_p, 0, START_SESSION_TIME);
+#endif
+ErrorExit:
+ return ReturnValue;
+}
+
+
+/*
+ * Get status of bulk transfer.
+ *
+ * @param [in] BulkVector_p Pointer to the Bulk Vector.
+ *
+ * @retval BULK_SESSION_IDLE Idle state of bulk protocol.
+ * @retval BULK_SESSION_OPEN Opened bulk protocol and ready for
+ * transmitting.
+ * @retval BULK_SESSION_PROCESSING Processing bulk transfer.
+ * @retval BULK_SESSION_FINISHED Bulk transfer finished.
+ */
+TL_BulkSessionState_t Do_R15_Bulk_GetStatusSession(const TL_BulkVectorList_t *BulkVector_p)
+{
+ if (NULL != BulkVector_p) {
+ return BulkVector_p->Status;
+ }
+
+ return BULK_SESSION_IDLE;
+}
+
+/*
+ * Close specified Bulk session.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] BulkVector_p Pointer to the Bulk Vector.
+ * for the session you want to close.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_CLOSE_BULK_SESSION If the BulkVector is not valid.
+ */
+//lint -e{818}
+ErrorCode_e Do_R15_Bulk_CloseSession(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+
+ VERIFY(NULL != Communication_p, E_INVALID_INPUT_PARAMETERS);
+
+ /* Verify that the requested bulk session is started. */
+ VERIFY(NULL != BulkVector_p, E_FAILED_TO_CLOSE_BULK_SESSION);
+
+ R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p = NULL;
+
+ C_(printf("bulk_protocol.c (%d): Bulk session(%d) closed! \n", __LINE__, BulkVector_p->SessionId);)
+#ifdef CFG_ENABLE_MEASUREMENT_TOOL
+ ReturnValue = MP(Measurement_p, 0, END_SESSION_TIME);
+#endif
+
+ErrorExit:
+ return ReturnValue;
+}
+
+
+/*
+ * Handling received bulk command.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Packet_p Pointer to the received buffer.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS If Packet_p is NULL.
+ */
+ErrorCode_e R15_Bulk_Process(Communication_t *Communication_p, PacketMeta_t *Packet_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ BulkExtendedHeader_t ExtendedHeader = {0};
+#ifdef CFG_ENABLE_LOADER_TYPE
+ TL_BulkVectorList_t *BulkVector_p = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p;
+ TL_BulkVectorList_t *PreviousBulkVector_p = &(R15_TRANSPORT(Communication_p)->PreviousBulkVector);
+ uint32 ChunksCount = 0;
+ uint8 ChunksList[MAX_BULK_TL_PROCESSES];
+#endif
+
+ /* check input parameters */
+ VERIFY(NULL != Packet_p, E_INVALID_INPUT_PARAMETERS);
+
+ //lint --e(826)
+ R15_DeserializeBulkExtendedHeader(&ExtendedHeader, Packet_p->ExtendedHeader_p);
+ VERIFY(ExtendedHeader.Session > 0, E_INVALID_BULK_SESSION_ID);
+
+ /* check bulk session opened? */
+#ifdef CFG_ENABLE_LOADER_TYPE
+
+ if ((NULL == BulkVector_p) || (ExtendedHeader.Session != BulkVector_p->SessionId)) {
+ C_(printf("bulk_protocol.c (%d): Session is not opend(%d) or wrong session(%d)! \n", __LINE__, R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p, ExtendedHeader.Session);)
+
+ if ((CMD_BULK_DATA == (ExtendedHeader.TypeFlags & MASK_BULK_COMMAND_SELECT)) &&
+ NULL != PreviousBulkVector_p) {
+ // make the list of received chunks
+ R15_Bulk_GetListOfReceivedChunks(PreviousBulkVector_p, &ChunksCount, ChunksList);
+ // send read ACK for previous session
+ ReturnValue = R15_Bulk_SendReadRequest(Communication_p, PreviousBulkVector_p, ChunksCount, ChunksList, NULL);
+ }
+
+ // release the buffer used for the invalid packet
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+ goto ErrorExit;
+ }
+
+#endif
+
+ switch (ExtendedHeader.TypeFlags & MASK_BULK_COMMAND_SELECT) {
+ case CMD_BULK_DATA:
+ ReturnValue = R15_Bulk_DataRequestHandler(Communication_p, Packet_p);
+ break;
+
+ case CMD_BULK_READ:
+ ReturnValue = R15_Bulk_ReadRequestHandler(Communication_p, Packet_p);
+ break;
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+ case CMD_BULK_WRITE:
+
+ if (NULL != R15_TRANSPORT(Communication_p)->BulkCommandCallback_p) {
+ BulkCommandReqCallback_t pcbf;
+ SESSION(Communication_p) = ExtendedHeader.Session;
+ CHUNKSIZE(Communication_p) = ExtendedHeader.ChunkSize;
+ OFFSET(Communication_p) = ExtendedHeader.Offset;
+ LENGTH(Communication_p) = ExtendedHeader.Length;
+ pcbf = (BulkCommandReqCallback_t)R15_TRANSPORT(Communication_p)->BulkCommandCallback_p;
+ pcbf(Communication_p->Object_p, &SESSION(Communication_p), &CHUNKSIZE(Communication_p), &OFFSET(Communication_p), &LENGTH(Communication_p), FALSE);
+ R15_Bulk_ClearBulkTmpParam(Communication_p);
+ }
+
+ /* release the buffer for undefined command */
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+ break;
+#endif
+ case CMD_BULK_STATUS:
+ // not implemented.
+ A_(printf("bulk_protocol.c (%d): ** Not implemented bulk command! **\n", __LINE__);)
+ /* release the buffer for unimplemented command */
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+ break;
+
+ default:
+ A_(printf("bulk_protocol.c (%d): ** Undefined bulk command! **\n", __LINE__);)
+ /* release the buffer for undefined command */
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+ break;
+ }
+
+ErrorExit:
+ return ReturnValue;
+}
+
+
+#ifdef CFG_ENABLE_LOADER_TYPE
+/*
+ * Generate bulk Session ID. Allowed bulk session ID is from 1 to 65535.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval Session ID Next free session ID.
+ */
+uint16 Do_R15_Bulk_GenerateBulkSessionID(Communication_t *Communication_p)
+{
+ if (NULL == Communication_p) {
+ return 0;
+ }
+
+ R15_TRANSPORT(Communication_p)->BulkSessionCounter++;
+
+ if (R15_TRANSPORT(Communication_p)->BulkSessionCounter == 0) {
+ R15_TRANSPORT(Communication_p)->BulkSessionCounter = 1;
+ }
+
+ return R15_TRANSPORT(Communication_p)->BulkSessionCounter;
+}
+#endif
+
+/***********************************************************************
+ * Definition of internal functions
+ **********************************************************************/
+
+/*
+ * Get the Chunk ID for the next bulk packet which is ready for transmitting.
+ *
+ * @param [in] BulkVector_p Current bulk vector used for bulk transfer.
+ *
+ * @retval ChunkID Chunk ID for the next ready for transmitting packet.
+ * If none chunk is ready return last Chunk ID + 1.
+ */
+static uint32 R15_Bulk_GetNextPacketChunkId(const TL_BulkVectorList_t *BulkVector_p)
+{
+ uint32 ChunkId = 0;
+
+ for (ChunkId = 0; ChunkId < BulkVector_p->Buffers; ChunkId++) {
+ if (CHECK_PACKET_FLAGS(BulkVector_p->Entries[ChunkId].Buffer_p, BUF_TX_READY)) {
+ break;
+ }
+ }
+
+ return ChunkId;
+}
+
+/*
+ * Check all created chunks is it transmited.
+ *
+ * @param [in] BulkVector_p Current bulk vector used for bulk transfer.
+ * @param [in] ChunkId ChunkID for the packet which need to be transmitted.
+ *
+ * @retval TRUE If all created chunks are transmitted.
+ * @retval FALSE If all created chunks are not transmitted.
+ */
+static boolean R15_Bulk_CheckTransmitedChunks(const TL_BulkVectorList_t *BulkVector_p)
+{
+ uint32 ChunkId;
+
+ for (ChunkId = 0; ChunkId < BulkVector_p->Buffers; ChunkId++) {
+ if (!CHECK_PACKET_FLAGS(BulkVector_p->Entries[ChunkId].Buffer_p, BUF_TX_SENT)) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+#ifdef CFG_ENABLE_LOADER_TYPE
+/*
+ * Check all acknowledged chunks.
+ *
+ * @param [in] BulkVector_p Current bulk vector used for bulk transfer.
+ * @param [in] Payload_p List of the acknowledged chunks.
+ *
+ * @retval TRUE If all transmitted chunks are acknowledged.
+ * @retval FALSE If all transmitted chunks are not acknowledged.
+ */
+static boolean R15_Bulk_CheckAcknowledgedChunks(const TL_BulkVectorList_t *BulkVector_p, const uint8 *const Payload_p)
+{
+ uint32 i;
+ uint8 Data[16];
+
+ memset(Data, 0, 16);
+
+ for (i = 0; i < BulkVector_p->Buffers; i++) {
+ Data[i] = (uint8)i;
+ }
+
+ if (memcmp(Data, Payload_p, BulkVector_p->Buffers) == 0) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+#endif
+
+static void R15_Bulk_MarkNotAckChunks(TL_BulkVectorList_t *BulkVector_p, const uint8 *const Payload_p, const uint32 Length)
+{
+ uint32 ChunkId;
+
+ for (ChunkId = 0; ChunkId < BulkVector_p->Buffers; ChunkId++) {
+ if (!R15_Bulk_CheckIdInList(BulkVector_p, ChunkId, Payload_p, Length) &&
+ !CHECK_PACKET_FLAGS(BulkVector_p->Entries[ChunkId].Buffer_p, BUF_TX_SENDING)) {
+ SET_PACKET_FLAGS(BulkVector_p->Entries[ChunkId].Buffer_p, PACKET_TX_STATE_MASK, BUF_TX_READY);
+ BulkVector_p->State = SENDING_CHUNKS;
+ }
+ }
+}
+
+static void R15_Bulk_MarkNotAckAllChunks(TL_BulkVectorList_t *BulkVector_p)
+{
+ uint32 ChunkId;
+
+ for (ChunkId = 0; ChunkId < BulkVector_p->Buffers; ChunkId++) {
+ SET_PACKET_FLAGS(BulkVector_p->Entries[ChunkId].Buffer_p, PACKET_TX_STATE_MASK, BUF_TX_READY);
+ }
+
+ BulkVector_p->State = SENDING_CHUNKS;
+}
+
+static boolean R15_Bulk_CheckIdInList(const TL_BulkVectorList_t *BulkVector_p, const uint32 ChunkId, const uint8 *const Data_p, const uint32 Length)
+{
+ uint32 i;
+
+ for (i = 0; i < Length; i++) {
+ if (ChunkId == *(Data_p + i)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static ErrorCode_e R15_Bulk_Process_Read(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p, PacketMeta_t *Packet_p)
+{
+ uint32 ChunkId = 0;
+ uint8 ChunksList[MAX_BULK_TL_PROCESSES];
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ TL_BulkVectorStatus_t ChunkReceivedStatus;
+#ifndef CFG_ENABLE_LOADER_TYPE
+ BulkCommandReqCallback_t pcbf;
+#endif
+
+ if (NULL == BulkVector_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ switch (BulkVector_p->State) {
+ /* Idle state */
+ case BULK_IDLE_STATE:
+ // wait to start the bulk session
+ break;
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+ /* coverity[unterminated_case] */
+ case WAIT_WRITE_REQUEST:
+ BulkVector_p->State = SEND_READ_REQUEST;
+#endif //CFG_ENABLE_LOADER_TYPE
+
+ /* coverity[fallthrough] */
+ case SEND_READ_REQUEST:
+ //lint --e(611)
+ ReturnValue = R15_Bulk_SendReadRequest(Communication_p, BulkVector_p, 0, NULL, (void *)R15_Bulk_ReadChunkCallBack);
+
+ if (E_SUCCESS == ReturnValue) {
+ BulkVector_p->State = WAIT_CHUNKS;
+ }
+
+ break;
+
+ case WAIT_CHUNKS:
+ ChunkId = R15_Bulk_GetChunkId(Packet_p);
+
+ /* Try to release the timer for the bulk read request */
+ if (R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey > 0) {
+ (void)TIMER(Communication_p, TimerRelease_Fn)(OBJECT_TIMER(Communication_p), R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey);
+ R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey = 0;
+ }
+
+ C_(printf("bulk_protocol.c(%d) Received Chunk(%d) Size(%d) Length(%d)\n", __LINE__, ChunkId, ((BulkExtendedHeader_t *)(Packet_p->ExtendedHeader_p))->ChunkSize, ((BulkExtendedHeader_t *)(Packet_p->ExtendedHeader_p))->Length);)
+
+#ifdef CFG_ENABLE_MEASUREMENT_TOOL
+ ReturnValue = MP(Measurement_p, ChunkId, RECEIVED_CHUNK_TIME);
+#endif
+
+ if (ChunkId >= BulkVector_p->Buffers) {
+ /* Packet with invalid chunk Id and release the buffer. */
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+ break;
+ } else if (NULL == BulkVector_p->Entries[ChunkId].Buffer_p) {
+ BulkVector_p->Entries[ChunkId].Buffer_p = Packet_p;
+
+ SET_PACKET_FLAGS(BulkVector_p->Entries[ChunkId].Buffer_p, PACKET_RX_STATE_MASK, BUF_ACK_READY);
+ //lint --e(413)
+ BulkVector_p->Entries[ChunkId].Payload_p = Packet_p->Payload_p;
+ //lint --e(413)
+ BulkVector_p->Entries[ChunkId].Hash_p = Packet_p->Hash;
+
+ /* */
+ C_(printf("bulk_protocol.c(%d) Received Chunks until (%d)\n", __LINE__, ChunkId);)
+ } else {
+ /* Packet with already received chunk Id. Release the network packet. */
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+ }
+
+ /* make the list of received chunks and send for retransmission of all missed chunks */
+ R15_Bulk_GetListOfReceivedChunks(BulkVector_p, &ChunkId, ChunksList);
+
+ /* check if all chunks are received */
+ ChunkReceivedStatus = R15_Bulk_GetVectorStatus(BulkVector_p);
+
+ if (VECTOR_COMPLETE == ChunkReceivedStatus) {
+ C_(printf("bulk_protocol.c(%d) Last Chunk Received (%d)\n", __LINE__, ChunkId);)
+ /* save the current bulk vector before is bulk session closed */
+ memcpy(&(R15_TRANSPORT(Communication_p))->PreviousBulkVector, BulkVector_p, sizeof(TL_BulkVectorList_t));
+ ReturnValue = R15_Bulk_SendReadRequest(Communication_p, BulkVector_p, ChunkId, ChunksList, NULL);
+ BulkVector_p->Status = BULK_SESSION_FINISHED;
+ BulkVector_p->State = BULK_IDLE_STATE;
+#ifndef CFG_ENABLE_LOADER_TYPE
+ // notify session end
+ pcbf = (BulkCommandReqCallback_t)R15_TRANSPORT(Communication_p)->BulkCommandCallback_p;
+ pcbf(Communication_p->Object_p, &BulkVector_p->SessionId, &BulkVector_p->ChunkSize, &BulkVector_p->Offset, &BulkVector_p->Length, TRUE);
+#endif
+ } else if (VECTOR_MISSING_CHUNK == ChunkReceivedStatus) {
+ ReturnValue = R15_Bulk_SendReadRequest(Communication_p, BulkVector_p, ChunkId, ChunksList, NULL);
+ } else { // Chunks are received in order
+ R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey = R15_Bulk_GetTimerChunkRetransmision(Communication_p, R15_TIMEOUTS(Communication_p)->TBDR, (HandleFunction_t)R15_Bulk_ReadChunkCallBack);
+ }
+
+ break;
+
+ case SEND_BULK_ACK: //TODO: check this state. look like unused state!!!
+ R15_Bulk_GetListOfReceivedChunks(BulkVector_p, &ChunkId, ChunksList);
+ ReturnValue = R15_Bulk_SendReadRequest(Communication_p, BulkVector_p, ChunkId, ChunksList, NULL);
+ break;
+
+ default:
+ BulkVector_p->State = BULK_IDLE_STATE;
+ ReturnValue = E_INVALID_BULK_PROTOCOL_STATE;
+ break;
+ }
+
+ return ReturnValue;
+}
+
+
+/*
+ * State machine for bulk transfer from ME to PC.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] BulkVector_p Pointer to the received buffer.
+ *
+ */
+ErrorCode_e R15_Bulk_Process_Write(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ uint32 ChunkId;
+ static uint32 reentrant = 1;
+
+ if (reentrant) {
+ reentrant = 0;
+
+ if (BulkVector_p->Mode == BULK_SEND) {
+ switch (BulkVector_p->State) {
+ /* Idle state */
+ case BULK_IDLE_STATE:
+ // wait to start the bulk session
+ break;
+
+ case SEND_WRITE_REQUEST:
+ ReturnValue = R15_Bulk_SendWriteRequest(Communication_p);
+
+ if (E_SUCCESS == ReturnValue) {
+ BulkVector_p->State = WAIT_READ_REQUEST;
+ }
+
+ break;
+
+ case WAIT_BULK_ACK:
+ //...?
+ break;
+
+ case WAIT_READ_REQUEST:
+#ifndef CFG_ENABLE_LOADER_TYPE
+ //TODO find end release timer for retransmision
+ BulkVector_p->State = SENDING_CHUNKS;
+#else
+ //...
+ break;
+#endif
+
+ /* continue to send chunks */
+ case SENDING_CHUNKS:
+ /* get Chunk ID of next packet! */
+ ChunkId = R15_Bulk_GetNextPacketChunkId(BulkVector_p);
+
+ if (ChunkId <= BulkVector_p->Buffers - 1) {
+ /* get and send packet with chunk ID */
+ R15_Bulk_SendData(Communication_p, BulkVector_p->Entries[ChunkId].Buffer_p, ChunkId);
+#ifndef CFG_ENABLE_LOADER_TYPE
+
+ if (NULL != R15_TRANSPORT(Communication_p)->BulkDataCallback_p) {
+ BulkDataReqCallback_t pcbf;
+ SESSION(Communication_p) = BulkVector_p->SessionId;
+ CHUNKSIZE(Communication_p) = BulkVector_p->ChunkSize;
+ OFFSET(Communication_p) = BulkVector_p->Offset;
+ LENGTH(Communication_p) = BulkVector_p->Length;
+ TRANSFEREDLENGTH(Communication_p) += CHUNKSIZE(Communication_p);
+ pcbf = (BulkDataReqCallback_t)R15_TRANSPORT(Communication_p)->BulkDataCallback_p;
+ pcbf(Communication_p->Object_p, &SESSION(Communication_p), &CHUNKSIZE(Communication_p), &OFFSET(Communication_p), &LENGTH(Communication_p), &TOTALLENGTH(Communication_p), &TRANSFEREDLENGTH(Communication_p));
+ }
+
+#endif
+ C_(printf("bulk_protocol.c(%d) Sent chunk (%d) session (%d)\n", __LINE__, ChunkId, BulkVector_p->SessionId);)
+ } else {
+ /* all chunks are in process of sending, wait for chunks to be sent */
+ if (R15_Bulk_CheckTransmitedChunks(BulkVector_p)) {
+ /* save the current bulk vector before bulk session is closed */
+ memcpy(&(R15_TRANSPORT(Communication_p))->PreviousBulkVector, BulkVector_p, sizeof(TL_BulkVectorList_t));
+ R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey = R15_Bulk_GetTimerChunkRetransmision(Communication_p, R15_TIMEOUTS(Communication_p)->TBCR, (HandleFunction_t)R15_Bulk_RetransmitChunks_CallBack);
+ BulkVector_p->State = WAIT_BULK_ACK;
+ C_(printf("bulk_protocol.c(%d) Wait BULK ACK for session (%d)!\n", __LINE__, BulkVector_p->SessionId);)
+ }
+ }
+
+#ifdef CFG_ENABLE_MEASUREMENT_TOOL
+ ReturnValue = MP(Measurement_p, ChunkId, RECEIVED_CHUNK_TIME);
+#endif
+ break;
+
+ case WRITE_BULK_FINISH:
+ BulkVector_p->State = BULK_IDLE_STATE;
+ BulkVector_p->Status = BULK_SESSION_FINISHED;
+ C_(printf("bulk_protocol.c(%d) Write bulk process finished! \n", __LINE__);)
+ break;
+
+ default:
+ BulkVector_p->State = BULK_IDLE_STATE;
+ break;
+ }
+ }
+
+ reentrant = 1;
+ }
+
+ return ReturnValue;
+}
+
+
+static ErrorCode_e R15_Bulk_SendReadRequest(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p, uint32 Chunks, void *ChunksList_p, void *CallBack_p)
+{
+ ErrorCode_e ReturnValue = E_GENERAL_COMMUNICATION_ERROR;
+ BulkExtendedHeader_t ExtendedHeader;
+ R15_Header_t Header;
+ SendData_LP_t Param;
+
+ /* setup header data */
+ Header.Protocol = BULK_PROTOCOL;
+ Header.Flags = Communication_p->CurrentFamilyHash;
+ Header.PayloadLength = Chunks * sizeof(uint8);
+ Header.PayloadChecksum = 0;
+ Header.ExtendedHeaderLength = BULK_EXTENDED_HEADER_LENGTH;
+ Header.ExtendedHeaderChecksum = 0;
+
+ /* Set extended header parameters */
+ ExtendedHeader.Session = BulkVector_p->SessionId;
+ ExtendedHeader.AcksChunk = (uint8)Chunks;
+ ExtendedHeader.ChunkSize = BulkVector_p->ChunkSize;
+ ExtendedHeader.Offset = BulkVector_p->Offset;
+ ExtendedHeader.Length = BulkVector_p->Length;
+ ExtendedHeader.TypeFlags = CMD_BULK_READ;
+
+ Param.Header_p = &Header;
+ Param.ExtendedHeader_p = &ExtendedHeader;
+
+ //TODO: (xvlapis) check if ChunksList_p=NULL meaning ReadCMD which requires retransmission timer, else ReadACK CMD which doesn't require retransmission
+ if (0 != Chunks) {
+ VERIFY(NULL != ChunksList_p, E_INVALID_INPUT_PARAMETERS);
+ Param.Payload_p = ChunksList_p;
+ Param.TimerCallBackFn_p = NULL;
+ Param.Time = 0;
+ } else {
+ Param.Time = R15_TIMEOUTS(Communication_p)->TBDR; // Receiving chunks
+
+ if (Chunks != 0) {
+ VERIFY(NULL != ChunksList_p, E_INVALID_INPUT_PARAMETERS);
+ Param.Payload_p = ChunksList_p;
+ }
+
+ VERIFY(NULL != CallBack_p, E_INVALID_INPUT_PARAMETERS);
+ //lint --e(611)
+ Param.TimerCallBackFn_p = (HandleFunction_t)CallBack_p;
+ }
+
+ ReturnValue = R15_Transport_Send(Communication_p, &Param);
+
+ErrorExit:
+ return ReturnValue;
+}
+
+
+static ErrorCode_e R15_Bulk_SendWriteRequest(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_GENERAL_COMMUNICATION_ERROR;
+ BulkExtendedHeader_t ExtendedHeader;
+ R15_Header_t Header;
+ SendData_LP_t Param;
+ TL_BulkVectorList_t *BulkVector_p = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p;
+
+ /* setup header data */
+ Header.Protocol = BULK_PROTOCOL;
+ Header.Flags = Communication_p->CurrentFamilyHash;
+ Header.PayloadLength = 0;
+ Header.PayloadChecksum = 0;
+ Header.ExtendedHeaderLength = BULK_EXTENDED_HEADER_LENGTH;
+ Header.ExtendedHeaderChecksum = 0;
+
+ /* Set extended header parameters */
+ ExtendedHeader.Session = BulkVector_p->SessionId;
+ ExtendedHeader.AcksChunk = 0;
+ ExtendedHeader.ChunkSize = BulkVector_p->ChunkSize;
+ ExtendedHeader.Offset = BulkVector_p->Offset;
+ ExtendedHeader.Length = BulkVector_p->Length;
+ ExtendedHeader.TypeFlags = CMD_BULK_WRITE;
+
+ Param.Header_p = &Header;
+ Param.ExtendedHeader_p = &ExtendedHeader;
+ Param.Payload_p = NULL;
+ Param.Time = R15_TIMEOUTS(Communication_p)->TBCR;
+ Param.TimerCallBackFn_p = NULL;
+ ReturnValue = R15_Transport_Send(Communication_p, &Param);
+ return ReturnValue;
+}
+
+
+static void R15_Bulk_SendData(Communication_t *Communication_p, PacketMeta_t *Packet_p, uint32 ChunkId)
+{
+ BulkExtendedHeader_t ExtendedHeader;
+ R15_Header_t Header;
+ TL_BulkVectorList_t *BulkVector_p = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p;
+ uint32 DeltaLength = 0;
+
+ /* check if packet is already serialized and calculated */
+ if (!CHECK_PACKET_FLAGS(Packet_p, (BUF_ALLOCATED | BUF_TX_READY | BUF_PAYLOAD_CRC_CALCULATED))) {
+ Packet_p->Timer_p = NULL;
+ Packet_p->Resend = 0;
+ /* set call back function */
+ Packet_p->CallBack_p = NULL;
+
+ /* setup header data */
+ memset(&Header, 0, HEADER_LENGTH);
+ Header.Protocol = BULK_PROTOCOL;
+ Header.Flags = Communication_p->CurrentFamilyHash;
+
+ if ((ChunkId + 1) == BulkVector_p->Buffers) {
+ DeltaLength = (ChunkId + 1) * BulkVector_p->ChunkSize - BulkVector_p->Length;
+
+ if (DeltaLength == 0) {
+ Header.PayloadLength = BulkVector_p->ChunkSize;
+ } else {
+ Header.PayloadLength = BulkVector_p->ChunkSize - DeltaLength;
+ }
+ } else {
+ Header.PayloadLength = BulkVector_p->ChunkSize;
+ }
+
+ Header.ExtendedHeaderLength = BULK_EXTENDED_HEADER_LENGTH;
+
+ /* Set extended header parameters */
+ ExtendedHeader.Session = BulkVector_p->SessionId;
+ ExtendedHeader.AcksChunk = (uint8)ChunkId;
+ ExtendedHeader.ChunkSize = BulkVector_p->ChunkSize;
+ ExtendedHeader.Offset = BulkVector_p->Offset;
+ ExtendedHeader.Length = BulkVector_p->Length;
+ ExtendedHeader.TypeFlags = CMD_BULK_DATA;
+
+ /* serialize and calculate extended header */
+ Packet_p->ExtendedHeader_p = Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH;
+ R15_SerializeExtendedHeader(Packet_p->ExtendedHeader_p, Header.Protocol, &ExtendedHeader, &(Header.ExtendedHeaderChecksum));
+ /* setup header for serialization and calculation */
+ memcpy(&Packet_p->Header, &Header, HEADER_LENGTH);
+
+ /* Calculate Payload CRC */
+ Packet_p->Communication_p = Communication_p;
+ SET_PACKET_FLAGS(Packet_p, PACKET_CRC_STATE_MASK, BUF_CRC_CALCULATING);
+
+ if (HASH_NONE != Packet_p->Header.Flags) {
+ Communication_p->HashDevice_p->Calculate(OBJECT_HASH(Communication_p),
+ (HashType_e)Packet_p->Header.Flags,
+ (void *)Packet_p->Payload_p, Packet_p->Header.PayloadLength,
+ Packet_p->Hash, (HashCallback_t)R15_Bulk_OutHashCallback,
+ (void *)Packet_p);
+ } else {
+ SET_PACKET_FLAGS(Packet_p, PACKET_CRC_STATE_MASK, BUF_PAYLOAD_CRC_CALCULATED);
+ memset(&Packet_p->Header.PayloadChecksum, 0x0, sizeof(uint32));
+ //SET_PACKET_FLAGS(Packet_p, PACKET_CRC_STATE_MASK, BUF_HEADER_CRC_CALCULATED);
+ R15_SerializeHeader(Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER, &Packet_p->Header);
+ (void)QUEUE(Packet_p->Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Outbound_p, Packet_p);
+ }
+ } else {
+ (void)QUEUE(Packet_p->Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Outbound_p, Packet_p);
+ }
+
+ /* mark packet as sent */
+ SET_PACKET_FLAGS(BulkVector_p->Entries[ChunkId].Buffer_p, PACKET_TX_STATE_MASK, BUF_TX_SENDING);
+}
+
+static void R15_Bulk_OutHashCallback(const void *const Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p)
+{
+ PacketMeta_t *Packet_p = (PacketMeta_t *)Param_p;
+
+ SET_PACKET_FLAGS(Packet_p, PACKET_CRC_STATE_MASK, BUF_PAYLOAD_CRC_CALCULATED);
+ memcpy(&Packet_p->Header.PayloadChecksum, Hash_p, sizeof(uint32));
+
+ R15_SerializeHeader(Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER, &Packet_p->Header);
+ (void)QUEUE(Packet_p->Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Outbound_p, Packet_p);
+}
+
+
+static void R15_Bulk_ReadChunkCallBack(Communication_t *Communication_p, const void *const Timer_p, const void *const Data_p)
+{
+ R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p->State = WAIT_CHUNKS;
+ (void)QUEUE((Communication_p), FifoEnqueue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, (void *)Data_p);
+}
+
+static void R15_Bulk_RetransmitChunks_CallBack(const Communication_t *const Communication_p, const void *const Timer_p, const void *const Data_p)
+{
+ /* set all chunks for retransmision . Max retransmision is 3. */
+ uint32 ChunkId;
+ PacketMeta_t *Packet_p;
+
+ for (ChunkId = 0; ChunkId < R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p->Buffers; ChunkId++) {
+ Packet_p = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p->Entries[ChunkId].Buffer_p;
+ /* set packet as ready for sending. */
+ SET_PACKET_FLAGS(Packet_p, PACKET_TX_STATE_MASK, BUF_TX_READY);
+ }
+
+ R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p->State = SENDING_CHUNKS;
+}
+
+static void R15_Bulk_GetListOfReceivedChunks(const TL_BulkVectorList_t *const BulkVector_p, uint32 *Chunks_p, uint8 *ChunkList_p)
+{
+ uint8 ChunkCounter;
+ *Chunks_p = 0;
+
+ for (ChunkCounter = 0; ChunkCounter < BulkVector_p->Buffers; ChunkCounter++) {
+ if (NULL != BulkVector_p->Entries[ChunkCounter].Buffer_p) {
+ ChunkList_p[*Chunks_p] = ChunkCounter;
+ (*Chunks_p)++;
+ }
+ }
+}
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+static boolean IsChunkReceived(Communication_t *Communication_p, uint32 ChunkId)
+{
+ PacketMeta_t *Packet_p = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p->Entries[ChunkId].Buffer_p;
+
+ if (NULL != Packet_p) {
+ return CHECK_PACKET_FLAGS(Packet_p, BUF_ACK_READY) || CHECK_PACKET_FLAGS(Packet_p, BUF_ACKNOWLEDGED);
+ } else {
+ return FALSE;
+ }
+}
+#endif
+
+static uint32 R15_Bulk_GetChunkId(const PacketMeta_t *const Packet_p)
+{
+ BulkExtendedHeader_t BulkExtendedHeader = {0};
+
+ R15_DeserializeBulkExtendedHeader(&BulkExtendedHeader, Packet_p->ExtendedHeader_p);
+
+ //lint -e(413,826)
+ return BulkExtendedHeader.AcksChunk;
+}
+
+static TL_BulkVectorStatus_t R15_Bulk_GetVectorStatus(TL_BulkVectorList_t *BulkVector_p)
+{
+ uint32 ChunkCounter;
+ PacketMeta_t *Packet_p;
+ TL_BulkVectorStatus_t Status = VECTOR_COMPLETE;
+
+ for (ChunkCounter = 0; ChunkCounter < BulkVector_p->Buffers; ChunkCounter++) {
+ Packet_p = BulkVector_p->Entries[ChunkCounter].Buffer_p;
+
+ if (Packet_p == NULL ||
+ !(CHECK_PACKET_FLAGS(Packet_p, BUF_ACK_READY) || CHECK_PACKET_FLAGS(Packet_p, BUF_ACKNOWLEDGED))) {
+ Status = VECTOR_NOT_COMPLETE;
+ } else {
+ if (Status == VECTOR_NOT_COMPLETE) {
+ Status = VECTOR_MISSING_CHUNK;
+ break;
+ }
+ }
+ }
+
+ return Status;
+}
+
+static uint32 R15_Bulk_GetTimerChunkRetransmision(const Communication_t *const Communication_p, uint32 Time, HandleFunction_t CallBack_p)
+{
+ Timer_t Timer;
+
+ Timer.Time = Time;
+ Timer.PeriodicalTime = 0;
+ Timer.HandleFunction_p = (HandleFunction_t)CallBack_p;
+ Timer.Data_p = NULL;
+ Timer.Param_p = (void *)Communication_p;
+
+ return TIMER(Communication_p, TimerGet_Fn)(OBJECT_TIMER(Communication_p), &Timer);
+}
+
+static ErrorCode_e R15_Bulk_ReadRequestHandler(Communication_t *Communication_p, PacketMeta_t *Packet_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ BulkExtendedHeader_t ExtendedHeader = {0};
+ TL_BulkVectorList_t *BulkVector_p = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p;
+ TL_BulkSessionID_Status_t BulkSessionIDStatus;
+#ifndef CFG_ENABLE_LOADER_TYPE
+ boolean ACK_Read = FALSE;
+ uint32 Buffers;
+ BulkCommandReqCallback_t pcbf;
+#endif
+
+ R15_DeserializeBulkExtendedHeader(&ExtendedHeader, Packet_p->ExtendedHeader_p);
+
+ // check the session ID of the received packet
+ BulkSessionIDStatus = R15_Bulk_CheckBulkSession(Communication_p, ExtendedHeader.Session);
+ VERIFY(BULK_SESSION_INVALID != BulkSessionIDStatus, E_INVALID_BULK_SESSION_ID);
+
+#ifdef CFG_ENABLE_LOADER_TYPE
+
+ if (BULK_SESSION_NEW != BulkSessionIDStatus) {
+ // check witch chunks are acknowledged!
+ if (Packet_p->Header.PayloadLength > 0) {
+ if (!R15_Bulk_CheckAcknowledgedChunks(BulkVector_p, Packet_p->Payload_p)) {
+ /* mark all not ackonwledged chunks for retransmision */
+ R15_Bulk_MarkNotAckChunks(BulkVector_p, Packet_p->Payload_p, ExtendedHeader.AcksChunk);
+ BulkVector_p->State = SENDING_CHUNKS;
+ } else {
+ BulkVector_p->State = WRITE_BULK_FINISH;
+ }
+
+ /* Try to release the timer for the bulk session acknowledge */
+ if (R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey > 0) {
+ (void)TIMER(Communication_p, TimerRelease_Fn)(OBJECT_TIMER(Communication_p), R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey);
+ R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey = 0;
+ }
+ } else {
+ if ((BulkVector_p->State == SENDING_CHUNKS) || (BulkVector_p->State == WAIT_BULK_ACK)) {
+ /* mark all chunks for retransmision */
+ R15_Bulk_MarkNotAckAllChunks(BulkVector_p);
+ } else {
+ /* release the buffer for previous command BULK WRITE */
+ uint32 Key = R15_Network_CreateUniqueKey(Packet_p, CMD_BULK_WRITE);
+ ReturnValue = R15_Network_CancelRetransmission(Communication_p, Key);
+ VERIFY((E_SUCCESS == ReturnValue) || (E_NOT_FOUND_ELEMENT_IN_RETRANSMISSION_LIST == ReturnValue), ReturnValue);
+ }
+
+ BulkVector_p->State = SENDING_CHUNKS;
+ }
+
+ ReturnValue = R15_Bulk_Process_Write(Communication_p, BulkVector_p); // state machine for WRITE BULK data
+ }
+
+#else
+ C_(printf("bulk_protocol.c(%d) Received READ packet!\n", __LINE__);)
+ C_(printf("bulk_protocol.c(%d) Session (%d)!\n", __LINE__, ExtendedHeader.Session);)
+
+ /*ckeck the ACK */
+ if (NULL != R15_TRANSPORT(Communication_p)->BulkCommandCallback_p) {
+ // check the session ID of the received packet
+ if (BULK_SESSION_NEW == BulkSessionIDStatus) {
+ /* request for new bulk session */
+ // check the status of the current bulk session
+ if (Do_R15_Bulk_GetStatusSession(R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p) != BULK_SESSION_IDLE) {
+ if (BulkVector_p->State == WAIT_BULK_ACK) {
+ C_(printf("bulk_protocol.c(%d) Request for new session but current is not closed!\n", __LINE__);)
+ C_(printf("bulk_protocol.c(%d) Current: Session (%d)!\n", __LINE__, BulkVector_p->SessionId);)
+ C_(printf("bulk_protocol.c(%d) ReceivedPacket: Session (%d)!\n", __LINE__, ExtendedHeader.Session);)
+
+ // close the current bulk session
+ (void)Do_R15_Bulk_CloseSession(Communication_p, BulkVector_p); //TODO: da se hendla return vrednosta!
+
+ // notify session end
+ pcbf = (BulkCommandReqCallback_t)R15_TRANSPORT(Communication_p)->BulkCommandCallback_p;
+ pcbf(Communication_p->Object_p, &BulkVector_p->SessionId, &BulkVector_p->ChunkSize, &BulkVector_p->Offset, &BulkVector_p->Length, TRUE);
+
+ // set bulk parameters for new bulk session
+ ACK_Read = FALSE;
+ SESSION(Communication_p) = ExtendedHeader.Session;
+ CHUNKSIZE(Communication_p) = ExtendedHeader.ChunkSize;
+ OFFSET(Communication_p) = ExtendedHeader.Offset;
+ LENGTH(Communication_p) = ExtendedHeader.Length;
+ pcbf(Communication_p->Object_p, &SESSION(Communication_p), &CHUNKSIZE(Communication_p), &OFFSET(Communication_p), &LENGTH(Communication_p), ACK_Read);
+ } else {
+ // can't be opened new bulk session until current session is not finished.
+ goto ErrorExit;
+ }
+ } else {
+ C_(printf("bulk_protocol.c(%d) Request for new bulk session!\n", __LINE__);)
+ // received request for new bulk session
+ ACK_Read = FALSE;
+ SESSION(Communication_p) = ExtendedHeader.Session;
+ CHUNKSIZE(Communication_p) = ExtendedHeader.ChunkSize;
+ OFFSET(Communication_p) = ExtendedHeader.Offset;
+ LENGTH(Communication_p) = ExtendedHeader.Length;
+ pcbf = (BulkCommandReqCallback_t)R15_TRANSPORT(Communication_p)->BulkCommandCallback_p;
+ pcbf(Communication_p->Object_p, &SESSION(Communication_p), &CHUNKSIZE(Communication_p), &OFFSET(Communication_p), &LENGTH(Communication_p), ACK_Read);
+ R15_Bulk_ClearBulkTmpParam(Communication_p);
+ }
+ } else {
+ // current bulk session
+ Buffers = ((ExtendedHeader.Length + ExtendedHeader.ChunkSize - 1) / ExtendedHeader.ChunkSize);
+
+ if (((ExtendedHeader.AcksChunk == 0) && (Do_R15_Bulk_GetStatusSession(R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p) == BULK_SESSION_IDLE)) || (ExtendedHeader.AcksChunk == Buffers)) {
+ //BulkCommandReqCallback_t pcbf;
+ if (Buffers == ExtendedHeader.AcksChunk) {
+ C_(printf("bulk_protocol.c(%d) ACK for bulk session(%d)!\n", __LINE__, ExtendedHeader.Session);)
+ (void)TIMER(Communication_p, TimerRelease_Fn)(OBJECT_TIMER(Communication_p), R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey);
+ (void)Do_R15_Bulk_CloseSession(Communication_p, BulkVector_p); //TODO: da se hendla return vrednosta!
+
+ // notify session end
+ pcbf = (BulkCommandReqCallback_t)R15_TRANSPORT(Communication_p)->BulkCommandCallback_p;
+ pcbf(Communication_p->Object_p, &BulkVector_p->SessionId, &BulkVector_p->ChunkSize, &BulkVector_p->Offset, &BulkVector_p->Length, TRUE);
+ } else {
+ C_(printf("bulk_protocol.c(%d) Request for new bulk session(%d)!\n", __LINE__, ExtendedHeader.Session);)
+ ACK_Read = FALSE;
+ SESSION(Communication_p) = ExtendedHeader.Session;
+ CHUNKSIZE(Communication_p) = ExtendedHeader.ChunkSize;
+ OFFSET(Communication_p) = ExtendedHeader.Offset;
+ LENGTH(Communication_p) = ExtendedHeader.Length;
+
+ /* Try to release the timer for the bulk session acknowledge */
+ if (R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey > 0) {
+ (void)TIMER(Communication_p, TimerRelease_Fn)(OBJECT_TIMER(Communication_p), R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey); // LCM MB bug fix: Timer should be released on request for retransmission
+ R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey = 0;
+ }
+
+ pcbf = (BulkCommandReqCallback_t)R15_TRANSPORT(Communication_p)->BulkCommandCallback_p;
+ pcbf(Communication_p->Object_p, &SESSION(Communication_p), &CHUNKSIZE(Communication_p), &OFFSET(Communication_p), &LENGTH(Communication_p), ACK_Read);
+ R15_Bulk_ClearBulkTmpParam(Communication_p);
+ }
+ } else {
+ if (ExtendedHeader.AcksChunk == 0) {
+ /* mark all chunks for retransmision */
+ R15_Bulk_MarkNotAckAllChunks(BulkVector_p);
+ } else {
+ /* mark all not ackonwledged chunks for retransmision */
+ A_(printf("bulk_protocol.c (%d): Mark All NACK Chunks for Retransmission **\n", __LINE__);)
+ R15_Bulk_MarkNotAckChunks(BulkVector_p, Packet_p->Payload_p, ExtendedHeader.AcksChunk);
+ }
+
+ BulkVector_p->State = SENDING_CHUNKS;
+
+ /* Try to release the timer for the bulk session acknowledge */
+ if (R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey > 0) {
+ (void)TIMER(Communication_p, TimerRelease_Fn)(OBJECT_TIMER(Communication_p), R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey); // LCM MB bug fix: Timer should be released on request for retransmission
+ R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey = 0;
+ }
+ }
+ }
+ }
+
+#endif
+
+ErrorExit:
+ /* release the buffer for command BULK READ */
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p); // TODO: proveri zosto ReturnValue se zema od ovde za posleden!
+ return ReturnValue;
+}
+
+static ErrorCode_e R15_Bulk_DataRequestHandler(Communication_t *Communication_p, PacketMeta_t *Packet_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ BulkExtendedHeader_t ExtendedHeader = {0};
+ TL_BulkVectorList_t *BulkVector_p = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p;
+ TL_BulkVectorList_t *PreviousBulkVector_p = &(R15_TRANSPORT(Communication_p)->PreviousBulkVector);
+ uint32 ChunksCount = 0;
+ uint8 ChunksList[MAX_BULK_TL_PROCESSES];
+#ifndef CFG_ENABLE_LOADER_TYPE
+ uint32 ChunkId = 0;
+ BulkDataReqCallback_t pcbf;
+#endif
+
+ R15_DeserializeBulkExtendedHeader(&ExtendedHeader, Packet_p->ExtendedHeader_p);
+
+#ifdef CFG_ENABLE_LOADER_TYPE
+
+ if (ExtendedHeader.AcksChunk == 0) {
+ BulkVector_p->State = WAIT_CHUNKS;
+ R15_TRANSPORT(Communication_p)->BulkHandle.TimerKey = 0;
+ }
+
+ if (PreviousBulkVector_p->SessionId == BulkVector_p->SessionId) {
+ // make the list of received chunks
+ R15_Bulk_GetListOfReceivedChunks(PreviousBulkVector_p, &ChunksCount, ChunksList);
+ // send read ACK for previous session
+ ReturnValue = R15_Bulk_SendReadRequest(Communication_p, PreviousBulkVector_p, ChunksCount, ChunksList, NULL);
+ // release the buffer used for this data chunk
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+ goto ErrorExit;
+ }
+
+ /* cancel retransmission, release buffer */
+ ReturnValue = R15_Network_CancelRetransmission(Communication_p, R15_Network_CreateUniqueKey(Packet_p, CMD_BULK_READ));
+ VERIFY(((E_SUCCESS == ReturnValue) || (ReturnValue == E_NOT_FOUND_ELEMENT_IN_RETRANSMISSION_LIST)), ReturnValue);
+ /* state machine for READ BULK data */
+ ReturnValue = R15_Bulk_Process_Read(Communication_p, BulkVector_p, Packet_p);
+#else
+
+ if (Do_R15_Bulk_GetStatusSession(BulkVector_p) == BULK_SESSION_IDLE) {
+ //no opened current session
+ // make the list of received chunks
+ R15_Bulk_GetListOfReceivedChunks(PreviousBulkVector_p, &ChunksCount, ChunksList);
+ // send read ACK for previous session
+ ReturnValue = R15_Bulk_SendReadRequest(Communication_p, PreviousBulkVector_p, ChunksCount, ChunksList, NULL);
+ // release the buffer used for this data chunk
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+ } else {
+ if (NULL != R15_TRANSPORT(Communication_p)->BulkDataCallback_p) {
+ ChunkId = ExtendedHeader.AcksChunk;
+
+ if (!IsChunkReceived(Communication_p, ChunkId)) {
+ SESSION(Communication_p) = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p->SessionId;
+ CHUNKSIZE(Communication_p) = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p->ChunkSize;
+ OFFSET(Communication_p) = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p->Offset;
+ LENGTH(Communication_p) = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p->Length;
+ TRANSFEREDLENGTH(Communication_p) += CHUNKSIZE(Communication_p);
+ pcbf = (BulkDataReqCallback_t)R15_TRANSPORT(Communication_p)->BulkDataCallback_p;
+ pcbf(Communication_p->Object_p, &SESSION(Communication_p), &CHUNKSIZE(Communication_p), &OFFSET(Communication_p), &LENGTH(Communication_p), &TOTALLENGTH(Communication_p), &TRANSFEREDLENGTH(Communication_p));
+ C_(printf("S(%d) L(%d) CS(%d)\n", SESSION(Communication_p), LENGTH(Communication_p), CHUNKSIZE(Communication_p));) //xvsvlpi
+ }
+ }
+
+ /* cancel retransmission, release buffer */
+ ReturnValue = R15_Network_CancelRetransmission(Communication_p, R15_Network_CreateUniqueKey(Packet_p, CMD_BULK_READ));
+ VERIFY(((E_SUCCESS == ReturnValue) || (ReturnValue == E_NOT_FOUND_ELEMENT_IN_RETRANSMISSION_LIST)), ReturnValue);
+ /* state machine for READ BULK data */
+ ReturnValue = R15_Bulk_Process_Read(Communication_p, BulkVector_p, Packet_p);
+ }
+
+#endif
+
+ErrorExit:
+ return ReturnValue;
+}
+
+
+/*
+ * Check the bulk session ID. Can be new bulk session or the current opened bulk
+ * session. Session ID can't be the '0'. Allowed Session ID is 1-65535.
+ *
+ * @param[in] Communication_p Communication module context.
+ * @param[in] SessionId Session ID from the received bulk packet.
+ *
+ * @retval BULK_SESSION_INVALID If the Session ID=0.
+ * @retval BULK_SESSION_CURRENT If the session ID is same as current session ID.
+ * @retval BULK_SESSION_NEW New bulk session
+ */
+static TL_BulkSessionID_Status_t R15_Bulk_CheckBulkSession(Communication_t *Communication_p, uint16 SessionId)
+{
+ TL_BulkSessionID_Status_t ReturnStatus = BULK_SESSION_INVALID;
+ TL_BulkVectorList_t *CurrentBulkVector_p = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p;
+#ifndef CFG_ENABLE_LOADER_TYPE
+ TL_BulkVectorList_t *PreviousBulkVector_p = &(R15_TRANSPORT(Communication_p)->PreviousBulkVector);
+#endif
+
+ if (SessionId == 0) {
+ return ReturnStatus;
+ }
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+
+ if (PreviousBulkVector_p == NULL) {
+ return BULK_SESSION_NEW;
+ }
+
+ if ((PreviousBulkVector_p->SessionId != 0) && (Do_R15_Bulk_GetStatusSession(CurrentBulkVector_p) != BULK_IDLE_STATE)) {
+#endif
+
+ //lint --e(539)
+ if (CurrentBulkVector_p->SessionId == SessionId) {
+ ReturnStatus = BULK_SESSION_CURRENT;
+ } else {
+ ReturnStatus = BULK_SESSION_NEW;
+ }
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+ } else {
+ if (PreviousBulkVector_p->SessionId < SessionId ||
+ (SessionId == 1 && PreviousBulkVector_p->SessionId > SessionId)) {
+ ReturnStatus = BULK_SESSION_NEW;
+ } else {
+ ReturnStatus = BULK_SESSION_INVALID;
+ }
+ }
+
+#endif
+ return ReturnStatus;
+}
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+/*
+ * Clear temporary saved bulk parameters
+ *
+ * @param[in] Communication_p Communication module context.
+ *
+ * return none.
+ */
+static void R15_Bulk_ClearBulkTmpParam(Communication_t *Communication_p)
+{
+ SESSION(Communication_p) = 0;
+ CHUNKSIZE(Communication_p) = 0;
+ OFFSET(Communication_p) = 0;
+ LENGTH(Communication_p) = 0;
+}
+#endif
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/command_protocol.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/command_protocol.c
new file mode 100644
index 0000000..08b4819
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/command_protocol.c
@@ -0,0 +1,311 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup command_protocol
+ * @{
+ */
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+#include "r_command_protocol.h"
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "r_communication_service.h"
+#include "r_r15_family.h"
+#include "r_r15_network_layer.h"
+#include "r_r15_transport_layer.h"
+#include "t_r15_header.h"
+#include "t_security_algorithms.h"
+#include "r_debug.h"
+#include "r_debug_macro.h"
+#include "r_r15_header.h"
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+static ErrorCode_e ProcessAcknowledgement(Communication_t *Communication_p, const PacketMeta_t *Packet_p, const uint16 *const SessionState_p);
+static ErrorCode_e ProcessCommand(Communication_t *Communication_p, PacketMeta_t *Packet_p, uint16 *SessionState);
+static ErrorCode_e ProcessGeneralResponse(Communication_t *Communication_p, PacketMeta_t *Packet_p, uint16 *SessionState_p);
+static ErrorCode_e SendAcknowledge(Communication_t *Communication_p, const PacketMeta_t *const Packet_p);
+static uint16 GetSendSession(const Communication_t *const Communication_p, CommandData_t *CmdData_p);
+static ErrorCode_e DispatchCommand(Communication_t *Communication_p, PacketMeta_t *Packet_p);
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+/*
+ * Reset the Session counters.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_R15_Command_ResetSessionCounters(const Communication_t *const Communication_p)
+{
+ /* Iintialize the session counters */
+ R15_TRANSPORT(Communication_p)->SessionStateIn = 0;
+ R15_TRANSPORT(Communication_p)->SessionStateOut = 0;
+
+ return E_SUCCESS;
+}
+
+
+/*
+ * Sends command packet with command protocol.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] CmdData_p Pointer to the command data.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS If CmdData_p is NULL.
+ */
+ErrorCode_e Do_R15_Command_Send(Communication_t *Communication_p, CommandData_t *CmdData_p)
+{
+ CommandExtendedHeader_t ExtendedHeader;
+ R15_Header_t Header;
+ SendData_LP_t Param;
+
+ if (NULL == CmdData_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ Param.Header_p = &Header;
+ Param.ExtendedHeader_p = &ExtendedHeader;
+ Param.Payload_p = CmdData_p->Payload.Data_p;
+
+ Header.Protocol = COMMAND_PROTOCOL;
+ Header.Flags = Communication_p->CurrentFamilyHash;
+ Header.PayloadLength = CmdData_p->Payload.Size;
+ Header.PayloadChecksum = 0;
+ Header.ExtendedHeaderLength = COMMAND_EXTENDED_HEADER_LENGTH;
+ Header.ExtendedHeaderChecksum = 0;
+
+ ExtendedHeader.SessionState = GetSendSession(Communication_p, CmdData_p);
+ ExtendedHeader.Command = CmdData_p->CommandNr;
+ ExtendedHeader.CommandGroup = CmdData_p->ApplicationNr;
+
+ // TODO: Don't we need a timer callback for this to actually do something?
+ Param.Time = R15_TIMEOUTS(Communication_p)->TCACK; //ACK_TIMEOUT_IN_MS;
+ Param.TimerCallBackFn_p = NULL; //NOTE: the timer will be assigned in "R15_Transport_Send"
+
+ C_(printf("command_protocol.c (%d): R15_Transport_Send! Type:%d Session:%d Command:%d CommandGroup:%d\n", __LINE__, CmdData_p->Type, ExtendedHeader.SessionState, ExtendedHeader.Command, ExtendedHeader.CommandGroup);)
+
+ return R15_Transport_Send(Communication_p, &Param);
+}
+
+/*
+ * Decode received command.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Packet_p Pointer to the received buffer.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS if Packet_p is NULL.
+ */
+ErrorCode_e R15_Command_Process(Communication_t *Communication_p, PacketMeta_t *Packet_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ CommandExtendedHeader_t CommandExtendedHeader = {0};
+
+ if (NULL == Packet_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ R15_DeserializeCommandExtendedHeader(&CommandExtendedHeader, Packet_p->ExtendedHeader_p);
+
+ switch (CommandExtendedHeader.SessionState & MASK_SELECT_STATE) {
+ case COMMAND_PACKAGE:
+ ReturnValue = ProcessCommand(Communication_p, Packet_p, &(R15_TRANSPORT(Communication_p)->SessionStateIn));
+ break;
+
+ case ACK_PACKAGE:
+ ReturnValue = ProcessAcknowledgement(Communication_p, Packet_p, &(R15_TRANSPORT(Communication_p)->SessionStateOut));
+ break;
+
+ case GENERAL_RESPONSE_PACKAGE:
+ ReturnValue = ProcessGeneralResponse(Communication_p, Packet_p, &(R15_TRANSPORT(Communication_p)->SessionStateOut));
+ break;
+
+ case ACK_GENERAL_RESPONSE_PACKAGE:
+ ReturnValue = ProcessAcknowledgement(Communication_p, Packet_p, &(R15_TRANSPORT(Communication_p)->SessionStateIn));
+ break;
+
+ default:
+ ReturnValue = E_SUCCESS;
+ break;
+ }
+
+ return ReturnValue;
+}
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+static uint16 GetSendSession(const Communication_t *const Communication_p, CommandData_t *CmdData_p)
+{
+ uint16 value;
+
+ if (CmdData_p->Type == GENERAL_RESPONSE) {
+ value = CmdData_p->SessionNr << 2 | GENERAL_RESPONSE_PACKAGE;
+ } else {
+ R15_TRANSPORT(Communication_p)->SessionStateOut += 4;
+ value = R15_TRANSPORT(Communication_p)->SessionStateOut;
+ CmdData_p->SessionNr = value >> 2;
+ }
+
+ return value;
+}
+
+
+static ErrorCode_e ProcessAcknowledgement(Communication_t *Communication_p, const PacketMeta_t *Packet_p, const uint16 *const SessionState_p)
+{
+ ErrorCode_e ReturnValue = E_GENERAL_FATAL_ERROR;
+ uint32 Key;
+
+ if (NULL == Packet_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ Key = R15_Network_CreateUniqueKey(Packet_p, 0);
+ (void)R15_Network_CancelRetransmission(Communication_p, Key);
+ B_(printf("command_protocol.c (%d): Received Acknowledge!\n", __LINE__);)
+
+ ReturnValue = R15_Network_PacketRelease(Communication_p, (PacketMeta_t *)Packet_p);
+ return ReturnValue;
+}
+
+
+static ErrorCode_e ProcessCommand(Communication_t *Communication_p, PacketMeta_t *Packet_p, uint16 *SessionState_p)
+{
+ ErrorCode_e ReturnValue;
+ CommandExtendedHeader_t CommandExtendedHeader = {0};
+
+ if (NULL == Packet_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ R15_DeserializeCommandExtendedHeader(&CommandExtendedHeader, Packet_p->ExtendedHeader_p);
+
+ if ((CommandExtendedHeader.SessionState & SESSION_MASK) == (*SessionState_p & SESSION_MASK) + 4) {
+ *SessionState_p += 4;
+ } else {
+ ReturnValue = SendAcknowledge(Communication_p, Packet_p);
+
+ if (E_SUCCESS != ReturnValue) {
+ return ReturnValue;
+ }
+
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+ return ReturnValue;
+ }
+
+ return DispatchCommand(Communication_p, Packet_p);
+}
+
+static ErrorCode_e ProcessGeneralResponse(Communication_t *Communication_p, PacketMeta_t *Packet_p, uint16 *SessionState_p)
+{
+ ErrorCode_e ReturnValue;
+ CommandExtendedHeader_t ExtendedHeader = {0};
+
+ if (NULL == Packet_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ R15_DeserializeCommandExtendedHeader(&ExtendedHeader, Packet_p->ExtendedHeader_p);
+
+ if ((ExtendedHeader.SessionState & SESSION_MASK) > (*SessionState_p & SESSION_MASK)) {
+ ReturnValue = SendAcknowledge(Communication_p, Packet_p);
+
+ if (E_SUCCESS != ReturnValue) {
+ return ReturnValue;
+ }
+
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+ return ReturnValue;
+ }
+
+ return DispatchCommand(Communication_p, Packet_p);
+}
+
+
+static ErrorCode_e DispatchCommand(Communication_t *Communication_p, PacketMeta_t *Packet_p)
+{
+ ErrorCode_e ReturnValue;
+ CommandExtendedHeader_t ExtendedHeader = {0};
+ CommandData_t CmdData;
+
+ ReturnValue = SendAcknowledge(Communication_p, Packet_p);
+
+ if (E_SUCCESS != ReturnValue) {
+ return E_SUCCESS;
+ }
+
+ R15_DeserializeCommandExtendedHeader(&ExtendedHeader, Packet_p->ExtendedHeader_p);
+
+ CmdData.Type = (CommandType_t)(ExtendedHeader.SessionState & MASK_SELECT_STATE);
+ CmdData.CommandNr = ExtendedHeader.Command;
+ CmdData.ApplicationNr = ExtendedHeader.CommandGroup;
+ CmdData.SessionNr = ExtendedHeader.SessionState >> 2;
+ CmdData.Payload.Size = Packet_p->Header.PayloadLength;
+ CmdData.Payload.Data_p = NULL;
+
+ if (0 != CmdData.Payload.Size) {
+ CmdData.Payload.Data_p = (uint8 *)malloc(Packet_p->Header.PayloadLength);
+
+ if (NULL == CmdData.Payload.Data_p) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ memcpy(CmdData.Payload.Data_p, Packet_p->Payload_p, Packet_p->Header.PayloadLength);
+ }
+
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+
+ ReturnValue = Communication_p->Do_CEH_Call_Fn(OBJECT_CEH_CALL(Communication_p), &CmdData);
+
+ if (NULL != CmdData.Payload.Data_p) {
+ free(CmdData.Payload.Data_p);
+ CmdData.Payload.Data_p = NULL;
+ }
+
+ return ReturnValue;
+}
+
+static ErrorCode_e SendAcknowledge(Communication_t *Communication_p, const PacketMeta_t *const Packet_p)
+{
+ CommandExtendedHeader_t ExtendedHeader;
+ R15_Header_t Header;
+ SendData_LP_t Param;
+
+ memcpy(&ExtendedHeader, Packet_p->ExtendedHeader_p, COMMAND_EXTENDED_HEADER_LENGTH);
+ ExtendedHeader.SessionState++;
+ memcpy(&Header, &Packet_p->Header, HEADER_LENGTH);
+ Header.Flags = Communication_p->CurrentFamilyHash;
+ Header.PayloadLength = 0;
+ Header.PayloadChecksum = 0;
+ Header.ExtendedHeaderChecksum = 0;
+
+ Param.Header_p = &Header;
+ Param.ExtendedHeader_p = &ExtendedHeader;
+ Param.Payload_p = NULL;
+ Param.Time = 0;
+ Param.TimerCallBackFn_p = NULL;
+
+ return R15_Transport_Send(Communication_p, &Param);
+}
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/protrom_protocol.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/protrom_protocol.c
new file mode 100644
index 0000000..bf5d5dd
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/protrom_protocol.c
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup protrom_family
+ * @{
+ * @addtogroup protrom_protocol
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <stdlib.h>
+#include <string.h>
+
+#include "r_protrom_family.h"
+#include "r_protrom_protocol.h"
+#include "r_protrom_network.h"
+#include "r_protrom_transport.h"
+#include "r_communication_service.h"
+#include "r_debug_macro.h"
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+/*
+ * Decode received command, and execute.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Packet_p Pointer to the received buffer.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Protrom_Process(const Communication_t *const Communication_p, Protrom_Packet_t *Packet_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ CommandData_t CmdData;
+ uint8 *DataTmp_p;
+
+ if (NULL == Packet_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ //if(PROTO_PROTROM == ((Protrom_Packet_t *)Packet_p)->Header.Protocol)
+ // return E_INVALID_INPUT_PARAMETERS;
+
+ if (NULL != Communication_p->Do_CEH_Call_Fn) {
+ CmdData.Payload.Size = Packet_p->Header.PayloadLength + PROTROM_HEADER_LENGTH + PROTROM_CRC_LENGTH;
+ DataTmp_p = (uint8 *)malloc(CmdData.Payload.Size);
+
+ if (NULL == DataTmp_p) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ CmdData.Payload.Data_p = DataTmp_p;
+ memcpy(CmdData.Payload.Data_p, Packet_p->Buffer_p, CmdData.Payload.Size);
+
+ free(Packet_p->Buffer_p);
+ free(Packet_p);
+
+ ReturnValue = Communication_p->Do_CEH_Call_Fn(OBJECT_CEH_CALL(Communication_p), &CmdData);
+
+ if (NULL != CmdData.Payload.Data_p) {
+ free(CmdData.Payload.Data_p);
+ CmdData.Payload.Data_p = NULL;
+ }
+ }
+
+ return ReturnValue;
+}
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/protrom_transport.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/protrom_transport.c
new file mode 100644
index 0000000..ef50be7
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/protrom_transport.c
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup protrom_family
+ * @{
+ * @addtogroup ldr_transport_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <stdlib.h>
+#include <string.h>
+
+#include "c_system.h"
+#include "t_basicdefinitions.h"
+#include "r_debug.h"
+#include "r_debug_macro.h"
+#include "r_protrom_family.h"
+#include "r_protrom_header.h"
+#include "r_protrom_transport.h"
+#include "r_protrom_network.h"
+#include "r_protrom_protocol.h"
+#include "r_communication_service.h"
+#include "t_security_algorithms.h"
+#include "r_memmory_utils.h"
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+static void Protrom_Transport_OutHashCallback(const void *const Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p);
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+/*
+ * Handles all registered TL processes for PROTROM protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Protrom_Transport_Poll(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ Protrom_Packet_t *Packet_p = NULL;
+
+ Protrom_Network_ReceiverHandler(Communication_p);
+ Packet_p = (Protrom_Packet_t *)QUEUE(Communication_p, FifoDequeue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p);
+
+ if (NULL == Packet_p) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ ReturnValue = Protrom_Process(Communication_p, Packet_p);
+
+ return ReturnValue;
+}
+
+/*
+ * Function for sending packet in PROTROM protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] InputDataIn_p Pointer to the input data.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_ALLOCATE_COMM_BUFFER Failed to allocate communication
+ * buffer.
+ */
+ErrorCode_e Protrom_Transport_Send(Communication_t *Communication_p, void *InputDataIn_p)
+{
+ Protrom_Packet_t *Packet_p = NULL;
+ Protrom_SendData_LP_t *InputData_p = (Protrom_SendData_LP_t *)InputDataIn_p;
+
+ Packet_p = (Protrom_Packet_t *) malloc(sizeof(Protrom_Packet_t));
+
+ if (NULL == Packet_p) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ Packet_p->Header = *InputData_p->Header_p;
+ Packet_p->Buffer_p = (uint8 *)malloc(Packet_p->Header.PayloadLength + PROTROM_HEADER_LENGTH + PROTROM_CRC_LENGTH);
+
+ if (NULL == Packet_p->Buffer_p) {
+ BUFFER_FREE(Packet_p);
+ return E_ALLOCATE_FAILED;
+ }
+
+ Protrom_SerializeHeader(Packet_p->Buffer_p, &Packet_p->Header);
+
+ if (NULL != InputData_p->Payload_p) {
+ /* setup payload for calculation */
+ memcpy(Packet_p->Buffer_p + PROTROM_HEADER_LENGTH, InputData_p->Payload_p, Packet_p->Header.PayloadLength);
+
+ /* Calculate Payload CRC */
+ Packet_p->Communication_p = Communication_p;
+
+ Communication_p->HashDevice_p->Calculate(OBJECT_HASH(Communication_p), Communication_p->CurrentFamilyHash,
+ Packet_p->Buffer_p, Packet_p->Header.PayloadLength + PROTROM_HEADER_LENGTH,
+ (uint8 *)&Packet_p->CRC, (HashCallback_t)Protrom_Transport_OutHashCallback,
+ (void *) Packet_p);
+ } else {
+ //@todo error no payload
+ }
+
+ /* The packet's buffer and the packet resources are
+ * freed in the send callback function */
+
+ /* coverity[leaked_storage] */
+ return E_SUCCESS;
+}
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+
+/*
+ * Callback function for handling calculated data.
+ *
+ * @param [in] Data_p Pointer to the data buffer for calculation.
+ * @param [in] Length Length of the data for calculation.
+ * @param [out] Hash_p Pointer to buffer with calculated hash.
+ * @param [in] Param_p Pointer to extra parameters.
+ *
+ * @return none.
+ */
+static void Protrom_Transport_OutHashCallback(const void *const Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p)
+{
+ Protrom_Packet_t *Packet_p = (Protrom_Packet_t *)Param_p;
+
+ memcpy(&Packet_p->CRC, Hash_p, sizeof(uint16));
+ memcpy((uint8 *)((Packet_p->Buffer_p) + PROTROM_HEADER_LENGTH + (Packet_p->Header.PayloadLength)), Hash_p, sizeof(uint16));
+ Protrom_SerializeHeader(Packet_p->Buffer_p, &Packet_p->Header);
+ (void)QUEUE(Packet_p->Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Outbound_p, Packet_p);
+}
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/r15_transport_layer.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/r15_transport_layer.c
new file mode 100644
index 0000000..d55395c
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/r15_transport_layer.c
@@ -0,0 +1,309 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup ldr_transport_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "c_system.h"
+#include "r_r15_transport_layer.h"
+#include <stdlib.h>
+#include <string.h>
+#include "r_basicdefinitions.h"
+#include "t_time_utilities.h"
+#include "r_debug.h"
+#include "r_debug_macro.h"
+#include "r_r15_header.h"
+#include "r_command_protocol.h"
+#include "r_bulk_protocol.h"
+#include "r_r15_network_layer.h"
+#include "r_r15_family.h"
+#include "r_communication_service.h"
+#include "t_security_algorithms.h"
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+static Timer_t *TimerSet(PacketMeta_t *Packet_p, const SendData_LP_t *const InputData_p, Communication_t *Communication_p);
+static void R15_Transport_OutHashCallback(const void *const Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p);
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+/*
+ * Initializes the transport layer for R15 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_INIT_TL Unsuccessful initialization.
+ * @retval E_ALLOCATE_FAILED Failed to allocate memory space.
+ */
+ErrorCode_e R15_Transport_Initialize(const Communication_t *const Communication_p)
+{
+ int VectorCounter;
+
+ /* Iintialize the session counters for command protocol*/
+ R15_TRANSPORT(Communication_p)->SessionStateIn = 0;
+ R15_TRANSPORT(Communication_p)->SessionStateOut = 0;
+
+ /* Iintialize the session counter for bulk protocol*/
+ R15_TRANSPORT(Communication_p)->BulkSessionCounter = 0;
+
+ /* initialize the default timeouts */
+ R15_TIMEOUTS(Communication_p)->TCACK = ACK_TIMEOUT_IN_MS;
+ R15_TIMEOUTS(Communication_p)->TBCR = BULK_COMMAND_RECEIVING_TIMEOUT;
+ R15_TIMEOUTS(Communication_p)->TBDR = BULK_DATA_RECEIVING_TIMEOUT;
+
+ for (VectorCounter = 0; VectorCounter < MAX_BULK_TL_PROCESSES; VectorCounter++) {
+ R15_TRANSPORT(Communication_p)->BulkVectorList[VectorCounter].Status = BULK_SESSION_IDLE;
+ }
+
+ memset(&(R15_TRANSPORT(Communication_p)->PreviousBulkVector), 0x00, sizeof(TL_BulkVectorList_t));
+ R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p = NULL;
+
+ return E_SUCCESS;
+}
+
+/*
+ * Shut Down the transport layer for R15 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e R15_Transport_Shutdown(const Communication_t *const Communication_p)
+{
+ return E_SUCCESS;
+}
+
+/*
+ * Handles all registered TL processes for R15 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e R15_Transport_Poll(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_GENERAL_FATAL_ERROR;
+#ifndef CFG_ENABLE_LOADER_TYPE
+ PacketMeta_t *Packet_p = NULL;
+
+ ReturnValue = R15_Network_ReceiverHandler(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+
+ ReturnValue = R15_Network_TransmiterHandler(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+#endif
+
+ if (BULK_SESSION_IDLE != Do_R15_Bulk_GetStatusSession(R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p)) {
+ ReturnValue = R15_Bulk_Process_Write(Communication_p, R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+ }
+
+ ReturnValue = R15_NETWORK(Communication_p)->Outbound.LCM_Error;
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+
+ while ((Packet_p = (PacketMeta_t *)QUEUE(Communication_p, FifoDequeue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p)) != NULL) {
+ switch (Packet_p->Header.Protocol) {
+ case PROTO_BULK:
+ return R15_Bulk_Process(Communication_p, Packet_p);
+ case PROTO_COMMAND:
+ return R15_Command_Process(Communication_p, Packet_p);
+ default:
+ return E_SUCCESS;
+ }
+ }
+
+#endif
+
+ErrorExit:
+ return ReturnValue;
+}
+
+
+/*
+ * Function for sending packet in R15 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] InputDataIn_p Pointer to the input data.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_ALLOCATE_COMM_BUFFER Failed to allocate communication
+ * buffer.
+ */
+ErrorCode_e R15_Transport_Send(Communication_t *Communication_p, void *InputDataIn_p)
+{
+ PacketMeta_t *Packet_p;
+ SendData_LP_t *InputData_p = (SendData_LP_t *)InputDataIn_p;
+
+ if (InputData_p->Header_p->Protocol == BULK_PROTOCOL && (((BulkExtendedHeader_t *)InputData_p->ExtendedHeader_p)->TypeFlags & MASK_BULK_COMMAND_SELECT) == CMD_BULK_DATA) {
+ Packet_p = R15_Network_PacketAllocate(Communication_p, BULK_BUFFER_SIZE);
+ } else {
+ Packet_p = R15_Network_PacketAllocate(Communication_p, COMMAND_BUFFER_SIZE);
+ }
+
+ if (NULL == Packet_p) {
+ A_(printf("r15_transport_layer.c (%d): ** Failed to get available buffers! **\n", __LINE__);)
+ return E_FAILED_TO_ALLOCATE_COMM_BUFFER;
+ }
+
+ Packet_p->Resend = 0;
+ Packet_p->CallBack_p = NULL;
+
+ Packet_p->Timer_p = TimerSet(Packet_p, InputData_p, Communication_p);
+ Packet_p->Header = *InputData_p->Header_p;
+ /* serialize and calculate extended header */
+ Packet_p->ExtendedHeader_p = Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH;
+ R15_SerializeExtendedHeader(Packet_p->ExtendedHeader_p, InputData_p->Header_p->Protocol, InputData_p->ExtendedHeader_p, &(Packet_p->Header.ExtendedHeaderChecksum));
+ if (Packet_p->Header.ExtendedHeaderLength == COMMAND_EXTENDED_HEADER_LENGTH) {
+ Packet_p->Payload_p = Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH + ALIGNED_COMMAND_EXTENDED_HEADER_LENGTH;
+ } else {
+ Packet_p->Payload_p = Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH + ALIGNED_BULK_EXTENDED_HEADER_LENGTH;
+ }
+ if (NULL != InputData_p->Payload_p) {
+ /* setup payload for calculation */
+ memcpy(Packet_p->Payload_p, InputData_p->Payload_p, Packet_p->Header.PayloadLength);
+
+ /* Calculate Payload CRC */
+ Packet_p->Communication_p = Communication_p;
+
+ if (HASH_NONE != Packet_p->Header.Flags) {
+ Communication_p->HashDevice_p->Calculate(OBJECT_HASH(Communication_p),
+ (HashType_e)Packet_p->Header.Flags,
+ (void *)Packet_p->Payload_p, Packet_p->Header.PayloadLength,
+ Packet_p->Hash, (HashCallback_t)R15_Transport_OutHashCallback,
+ (void *)Packet_p);
+ } else {
+ SET_PACKET_FLAGS(Packet_p, PACKET_CRC_STATE_MASK, BUF_PAYLOAD_CRC_CALCULATED);
+ memset(&Packet_p->Header.PayloadChecksum, 0x0, sizeof(uint32));
+ R15_SerializeHeader(Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER, &Packet_p->Header);
+
+ (void)QUEUE(Packet_p->Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Outbound_p, Packet_p);
+ }
+ } else {
+ R15_SerializeHeader(Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER, &Packet_p->Header);
+
+ (void)QUEUE(Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, Packet_p);
+ }
+
+ return E_SUCCESS;
+}
+
+/*
+ * Function for setting the timeouts in the R15 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] TimeoutData_p Pointer to the input data with all timeouts.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e R15_SetProtocolTimeouts(Communication_t *Communication_p, void *TimeoutData_p)
+{
+ ErrorCode_e ReturnValue = E_INVALID_INPUT_PARAMETERS;
+ R15_Timeouts_t *NewTimeoutData_p = (R15_Timeouts_t *)TimeoutData_p;
+ VERIFY(NULL != TimeoutData_p, E_INVALID_INPUT_PARAMETERS);
+
+ R15_TIMEOUTS(Communication_p)->TCACK = NewTimeoutData_p->TCACK;
+ R15_TIMEOUTS(Communication_p)->TBCR = NewTimeoutData_p->TBCR;
+ R15_TIMEOUTS(Communication_p)->TBDR = NewTimeoutData_p->TBDR;
+ ReturnValue = E_SUCCESS;
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Function for getting the timeouts in the R15 protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [out] TimeoutData_p Return all defined timeouts.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e R15_GetProtocolTimeouts(Communication_t *Communication_p, void *TimeoutData_p)
+{
+ ErrorCode_e ReturnValue = E_INVALID_INPUT_PARAMETERS;
+ VERIFY(NULL != TimeoutData_p, E_INVALID_INPUT_PARAMETERS);
+
+ ((R15_Timeouts_t *)TimeoutData_p)->TCACK = R15_TIMEOUTS(Communication_p)->TCACK;
+ ((R15_Timeouts_t *)TimeoutData_p)->TBCR = R15_TIMEOUTS(Communication_p)->TBCR;
+ ((R15_Timeouts_t *)TimeoutData_p)->TBDR = R15_TIMEOUTS(Communication_p)->TBDR;
+ ReturnValue = E_SUCCESS;
+
+ErrorExit:
+ return ReturnValue;
+}
+
+
+/*
+ * Callback function for handling calculated data.
+ *
+ * @param [in] Data_p Pointer to the data buffer for calculation.
+ * @param [in] Length Length of the data for calculation.
+ * @param [out] Hash_p Pointer to buffer with calculated hash.
+ * @param [in] Param_p Pointer to extra parameters.
+ *
+ * @return none.
+ */
+static void R15_Transport_OutHashCallback(const void *const Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p)
+{
+ PacketMeta_t *Packet_p = (PacketMeta_t *)Param_p;
+
+ SET_PACKET_FLAGS(Packet_p, PACKET_CRC_STATE_MASK, BUF_PAYLOAD_CRC_CALCULATED);
+ memcpy(&Packet_p->Header.PayloadChecksum, Hash_p, sizeof(uint32));
+ R15_SerializeHeader(Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER, &Packet_p->Header);
+
+ (void)QUEUE(Packet_p->Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Outbound_p, Packet_p);
+}
+
+/*
+ * Function for Timer setting.
+ *
+ * @param [in] Packet_p Pointer to the R15 packet meta data.
+ * @param [in] InputData_p Pointer to the input parameters with settings.
+ * @param [in] Communication_p Communication module context.
+ *
+ * @return none.
+ */
+static Timer_t *TimerSet(PacketMeta_t *Packet_p, const SendData_LP_t *const InputData_p, Communication_t *Communication_p)
+{
+ Timer_t *Timer_p = NULL;
+
+ if (InputData_p->Time > 0) {
+ Timer_p = (Timer_t *)malloc(sizeof(Timer_t));
+
+ if (NULL == Timer_p) {
+ return NULL;
+ }
+
+ /* timer data */
+ Timer_p->Time = InputData_p->Time;
+ Timer_p->PeriodicalTime = 0;
+ Timer_p->HandleFunction_p = (HandleFunction_t)(InputData_p->TimerCallBackFn_p);
+ Timer_p->Data_p = (void *)Packet_p;
+ Timer_p->Param_p = (void *)Communication_p;
+ }
+
+ return Timer_p;
+}
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/z_transport.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/z_transport.c
new file mode 100644
index 0000000..578e176
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/z_transport.c
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup z_family
+ * @{
+ * @addtogroup ldr_transport_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <stdlib.h>
+#include <string.h>
+
+#include "t_basicdefinitions.h"
+#include "r_debug.h"
+#include "r_z_transport.h"
+#include "r_z_network.h"
+#include "r_communication_service.h"
+#include "r_z_protocol.h"
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+static ErrorCode_e Z_Process(Communication_t *Communication_p);
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+/*
+ * Initializes the transport layer for Z protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_INIT_TL unsuccessful initialization.
+ * @retval E_ALLOCATE_FAILED failed to allocate memory space.
+ */
+ErrorCode_e Z_Transport_Initialize(const Communication_t *const Communication_p)
+{
+ return E_SUCCESS;
+}
+
+/*
+ * Shut Down the transport layer for Z protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Z_Transport_Shutdown(const Communication_t *const Communication_p)
+{
+ return E_SUCCESS;
+}
+
+/*
+ * Handles all registered TL processes for Z protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Z_Transport_Poll(Communication_t *Communication_p)
+{
+ return Z_Process(Communication_p);
+}
+
+
+/*
+ * Function for sending packet in Z protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] InputData_p Pointer to the input data.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_ALLOCATE_COMM_BUFFER Failed to allocate communication
+ * buffer.
+ */
+ErrorCode_e Z_Transport_Send(Communication_t *Communication_p, void *InputDataIn_p)
+{
+ Z_SendingContent_t SendingContent;
+
+ SendingContent.Size = *((uint8 *)InputDataIn_p);
+ SendingContent.Data_p = (uint8 *)InputDataIn_p + 1;
+
+ return Z_Network_TransmiterHandler(Communication_p, &SendingContent);
+}
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+/*
+ * Handles all registered TL processes for Z protocol family.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+static ErrorCode_e Z_Process(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+
+ Z_Network_ReceiverHandler(Communication_p);
+
+ return ReturnValue;
+}
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204.c b/lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204.c
new file mode 100644
index 0000000..8453acf
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204.c
@@ -0,0 +1,654 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+/**
+ * @file ADbg_cnh<ModuleNumber>.c
+ *
+ * @brief Test cases for CNH1605204 module.
+ *
+ * This file consist of test cases for autometic testing functions from
+ * CNH1605204 module.
+ */
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "r_adbg.h"
+#include "r_adbg_assert.h"
+#include "r_adbg_case.h"
+#include "r_adbg_module.h"
+#include "r_adbg_command.h"
+#include "r_a2_protocol.h"
+#include "r_bulk_protocol.h"
+#include "r_command_protocol.h"
+#include "r_r15_transport_layer.h"
+#include <stdlib.h>
+
+/*******************************************************************************
+ * The test case functions declarations
+ ******************************************************************************/
+static void ADbg_Do_A2_Command_Send(ADbg_Case_t *Case_p);
+
+static void ADbg_Do_R15_Bulk_OpenSession(ADbg_Case_t *Case_p);
+static void ADbg_Do_R15_Bulk_CreateVector(ADbg_Case_t *Case_p);
+static void ADbg_Do_R15_Bulk_DestroyVector(ADbg_Case_t *Case_p);
+static void ADbg_Do_R15_Bulk_StartSession(ADbg_Case_t *Case_p);
+static void ADbg_Do_R15_Bulk_GetStatusSession(ADbg_Case_t *Case_p);
+static void ADbg_Do_R15_Bulk_CloseSession(ADbg_Case_t *Case_p);
+static void ADbg_R15_Bulk_Process(ADbg_Case_t *Case_p);
+
+static void ADbg_Do_R15_Command_ResetSessionCounters(ADbg_Case_t *Case_p);
+static void ADbg_Do_R15_Command_Send(ADbg_Case_t *Case_p);
+static void ADbg_R15_Command_Process(ADbg_Case_t *Case_p);
+
+static void ADbg_R15_Transport_Initialize(ADbg_Case_t *Case_p);
+static void ADbg_R15_Transport_Shutdown(ADbg_Case_t *Case_p);
+static void ADbg_R15_Transport_Poll(ADbg_Case_t *Case_p);
+static void ADbg_R15_Transport_Send(ADbg_Case_t *Case_p);
+static void ADbg_R15_SetProtocolTimeouts(ADbg_Case_t *Case_p);
+static void ADbg_R15_GetProtocolTimeouts(ADbg_Case_t *Case_p);
+
+/*******************************************************************************
+ * The test case definitions
+ ******************************************************************************/
+// A2_protocol
+static uint8 Parameters1_1[4] = {3, WORDPTR, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_Do_A2_Command_Send, 1, 8, ADbg_Do_A2_Command_Send, Parameters1_1);
+
+// Bulk_protocol
+static uint8 Parameters3_1[5] = {4, WORDPTR, SHORT, WORD, WORD};
+ADBG_CASE_DEFINE(Test_Do_R15_Bulk_OpenSession, 2, 8, ADbg_Do_R15_Bulk_OpenSession, Parameters3_1);
+static uint8 Parameters3_2[7] = {6, WORDPTR, WORD, WORD, WORD, WORDPTR, WORDPTR};
+ADBG_CASE_DEFINE(Test_Do_R15_Bulk_CreateVector, 3, 8, ADbg_Do_R15_Bulk_CreateVector, Parameters3_2);
+static uint8 Parameters3_3[5] = {4, WORDPTR, WORDPTR, BYTE, WORD};
+ADBG_CASE_DEFINE(Test_Do_R15_Bulk_DestroyVector, 4, 8, ADbg_Do_R15_Bulk_DestroyVector, Parameters3_3);
+static uint8 Parameters3_5[5] = {4, WORDPTR, WORDPTR, DOUBLEWORD, WORD};
+ADBG_CASE_DEFINE(Test_Do_R15_Bulk_StartSession, 6, 8, ADbg_Do_R15_Bulk_StartSession, Parameters3_5);
+static uint8 Parameters3_6[3] = {2, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_Do_R15_Bulk_GetStatusSession, 7, 8, ADbg_Do_R15_Bulk_GetStatusSession, Parameters3_6);
+static uint8 Parameters3_7[4] = {3, WORDPTR, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_Do_R15_Bulk_CloseSession, 8, 8, ADbg_Do_R15_Bulk_CloseSession, Parameters3_7);
+static uint8 Parameters3_8[4] = {3, WORDPTR, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_R15_Bulk_Process, 9, 8, ADbg_R15_Bulk_Process, Parameters3_8);
+
+// Command_protocol
+static uint8 Parameters4_1[3] = {2, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_Do_R15_Command_ResetSessionCounters, 10, 8, ADbg_Do_R15_Command_ResetSessionCounters, Parameters4_1);
+static uint8 Parameters4_2[4] = {3, WORDPTR, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_Do_R15_Command_Send, 11, 8, ADbg_Do_R15_Command_Send, Parameters4_2);
+static uint8 Parameters4_3[4] = {3, WORDPTR, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_R15_Command_Process, 12, 8, ADbg_R15_Command_Process, Parameters4_3);
+
+//Protrom_protocol
+
+// R15_transport_layer
+static uint8 Parameters7_1[3] = {2, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_R15_Transport_Initialize, 13, 8, ADbg_R15_Transport_Initialize, Parameters7_1);
+static uint8 Parameters7_2[3] = {2, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_R15_Transport_Shutdown, 14, 8, ADbg_R15_Transport_Shutdown, Parameters7_2);
+static uint8 Parameters7_3[3] = {2, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_R15_Transport_Poll, 15, 8, ADbg_R15_Transport_Poll, Parameters7_3);
+static uint8 Parameters7_4[4] = {3, WORDPTR, VOIDPTR, WORD};
+ADBG_CASE_DEFINE(Test_R15_Transport_Send, 16, 8, ADbg_R15_Transport_Send, Parameters7_4);
+static uint8 Parameters7_5[4] = {3, WORDPTR, VOIDPTR, WORD};
+ADBG_CASE_DEFINE(Test_R15_SetProtocolTimeouts, 17, 8, ADbg_R15_SetProtocolTimeouts, Parameters7_5);
+static uint8 Parameters7_6[4] = {3, WORDPTR, VOIDPTR, WORD};
+ADBG_CASE_DEFINE(Test_R15_GetProtocolTimeouts, 18, 8, ADbg_R15_GetProtocolTimeouts, Parameters7_6);
+
+/*******************************************************************************
+* The test case suite definition
+******************************************************************************/
+ADBG_SUITE_DEFINE_BEGIN(TestCase_CNH1605204, 0, 8)
+
+ADBG_SUITE_ENTRY(Test_Do_A2_Command_Send)
+
+ADBG_SUITE_ENTRY(Test_Do_R15_Bulk_OpenSession)
+ADBG_SUITE_ENTRY(Test_Do_R15_Bulk_CreateVector)
+ADBG_SUITE_ENTRY(Test_Do_R15_Bulk_DestroyVector)
+ADBG_SUITE_ENTRY(Test_Do_R15_Bulk_GetStatusSession)
+ADBG_SUITE_ENTRY(Test_Do_R15_Bulk_CloseSession)
+ADBG_SUITE_ENTRY(Test_R15_Bulk_Process)
+
+ADBG_SUITE_ENTRY(Test_Do_R15_Command_ResetSessionCounters)
+ADBG_SUITE_ENTRY(Test_Do_R15_Command_Send)
+ADBG_SUITE_ENTRY(Test_R15_Command_Process)
+
+ADBG_SUITE_ENTRY(Test_R15_Transport_Initialize)
+ADBG_SUITE_ENTRY(Test_R15_Transport_Shutdown)
+ADBG_SUITE_ENTRY(Test_R15_Transport_Poll)
+ADBG_SUITE_ENTRY(Test_R15_Transport_Send)
+ADBG_SUITE_ENTRY(Test_R15_SetProtocolTimeouts)
+ADBG_SUITE_ENTRY(Test_R15_GetProtocolTimeouts)
+
+ADBG_SUITE_DEFINE_END();
+
+/*******************************************************************************
+ * Case runner
+ ******************************************************************************/
+void Do_CNH1605204_Module_Test_Run(ADbg_MainModule_t *MainModule_p)
+{
+ ADbg_Module_t *Module_p = Do_ADbg_Module_Create(TestCase_CNH1605204, NULL, MainModule_p->Command_p, MainModule_p->Result_p);
+ Do_ADbg_InModule_Command(Module_p);
+ Do_ADbg_Module_Destroy(Module_p);
+}
+/*******************************************************************************
+ * Test cases
+ ******************************************************************************/
+/**
+ * This function will test function:
+ * CNH1605204_TestedFunction1.
+ * Function used in: Test_CNH1605204_TestedFunction1.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_A2_Command_Send(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ CommandData_t *CmdData_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+ CmdData_p = Do_ADbg_GetDataPointer(sizeof(CommandData_t), (void **)&Var_p);
+
+ Result = Do_A2_Command_Send(Communication_p, CmdData_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+
+ if (NULL != CmdData_p) {
+ free(CmdData_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * Do_R15_Bulk_OpenSession.
+ * Function used in: Test_Do_R15_Bulk_OpenSession.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_R15_Bulk_OpenSession(ADbg_Case_t *Case_p)
+{
+ uint32 Result = BULK_SESSION_OPEN;
+ Communication_t *Communication_p;
+ uint16 SessionId = 0;
+ TL_SessionMode_t Mode;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+
+ Do_ADbg_GetDataVar(sizeof(uint16), &Var_p, &SessionId);
+ Do_ADbg_GetDataVar(sizeof(TL_SessionMode_t), &Var_p, &Mode);
+
+ Result = Do_R15_Bulk_OpenSession(Communication_p, SessionId, Mode);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * Do_R15_Bulk_CreateVector.
+ * Function used in: Test_Do_R15_Bulk_CreateVector.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_R15_Bulk_CreateVector(ADbg_Case_t *Case_p)
+{
+ TL_BulkVectorList_t *Result = NULL;
+ Communication_t *Communication_p;
+ uint32 BulkVector = 0;
+ uint32 Length = 0;
+ uint32 BuffSize = 0;
+ TL_BulkVectorList_t *CreatedBulkVector_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+
+ Do_ADbg_GetDataVar(sizeof(uint32), &Var_p, &BulkVector);
+ Do_ADbg_GetDataVar(sizeof(uint32), &Var_p, &Length);
+ Do_ADbg_GetDataVar(sizeof(uint32), &Var_p, &BuffSize);
+
+ CreatedBulkVector_p = Do_ADbg_GetDataPointer(sizeof(TL_BulkVectorList_t *), (void **)&Var_p);
+
+ Result = Do_R15_Bulk_CreateVector(Communication_p, BulkVector, Length, BuffSize, CreatedBulkVector_p);
+ Do_ADbg_Assert((TL_BulkVectorList_t *)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+
+ if (NULL != CreatedBulkVector_p) {
+ free(CreatedBulkVector_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * Do_R15_Bulk_DestroyVector.
+ * Function used in: Test_Do_R15_Bulk_DestroyVector.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_R15_Bulk_DestroyVector(ADbg_Case_t *Case_p)
+{
+ uint32 Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ TL_BulkVectorList_t *BulkVector_p;
+ boolean ReqReleaseBuffer;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+ BulkVector_p = Do_ADbg_GetDataPointer(sizeof(TL_BulkVectorList_t *), (void **)&Var_p);
+
+ Do_ADbg_GetDataVar(sizeof(boolean), &Var_p, &ReqReleaseBuffer);
+
+ Result = Do_R15_Bulk_DestroyVector(Communication_p, BulkVector_p, ReqReleaseBuffer);
+ Do_ADbg_Assert((uint32)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+
+ if (NULL != BulkVector_p) {
+ free(BulkVector_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * Do_R15_Bulk_StartSession.
+ * Function used in: Test_Do_R15_Bulk_StartSession.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_R15_Bulk_StartSession(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ TL_BulkVectorList_t *BulkVector_p;
+ uint64 Offset = 0;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+ BulkVector_p = Do_ADbg_GetDataPointer(sizeof(TL_BulkVectorList_t *), (void **)&Var_p);
+
+ Do_ADbg_GetDataVar(sizeof(uint64), &Var_p, &Offset);
+
+ Result = Do_R15_Bulk_StartSession(Communication_p, BulkVector_p, Offset);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+
+ if (NULL != BulkVector_p) {
+ free(BulkVector_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * Do_R15_Bulk_GetStatusSession.
+ * Function used in: Test_Do_R15_Bulk_GetStatusSession.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_R15_Bulk_GetStatusSession(ADbg_Case_t *Case_p)
+{
+ TL_BulkSessionState_t Result = E_SUCCESS;
+ TL_BulkVectorList_t *BulkVector_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ BulkVector_p = Do_ADbg_GetDataPointer(sizeof(TL_BulkVectorList_t *), (void **)&Var_p);
+
+ Result = Do_R15_Bulk_GetStatusSession(BulkVector_p);
+ Do_ADbg_Assert((TL_BulkSessionState_t)(*Var_p) == Result, Case_p);
+
+ if (NULL != BulkVector_p) {
+ free(BulkVector_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * Do_R15_Bulk_CloseSession.
+ * Function used in: Test_Do_R15_Bulk_CloseSession.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_R15_Bulk_CloseSession(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ TL_BulkVectorList_t *BulkVector_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+ BulkVector_p = Do_ADbg_GetDataPointer(sizeof(TL_BulkVectorList_t *), (void **)&Var_p);
+
+ Result = Do_R15_Bulk_CloseSession(Communication_p, BulkVector_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+
+ if (NULL != BulkVector_p) {
+ free(BulkVector_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_Bulk_Process.
+ * Function used in: Test_R15_Bulk_Process.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_Bulk_Process(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ PacketMeta_t *Packet_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+ Packet_p = Do_ADbg_GetDataPointer(sizeof(PacketMeta_t *), (void **)&Var_p);
+
+ Result = R15_Bulk_Process(Communication_p, Packet_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+
+ if (NULL != Packet_p) {
+ free(Packet_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * Do_R15_Command_ResetSessionCounters.
+ * Function used in: Test_Do_R15_Command_ResetSessionCounters.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_R15_Command_ResetSessionCounters(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+
+ Result = Do_R15_Command_ResetSessionCounters(Communication_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * Do_R15_Command_Send.
+ * Function used in: Test_Do_R15_Command_Send.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_R15_Command_Send(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ CommandData_t *CmdData_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+ CmdData_p = Do_ADbg_GetDataPointer(sizeof(CommandData_t *), (void **)&Var_p);
+
+ Result = Do_R15_Command_Send(Communication_p, CmdData_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+
+ if (NULL != CmdData_p) {
+ free(CmdData_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_Command_Process.
+ * Function used in: Test_R15_Command_Process.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_Command_Process(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ PacketMeta_t *Packet_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+ Packet_p = Do_ADbg_GetDataPointer(sizeof(PacketMeta_t *), (void **)&Var_p);
+
+ Result = R15_Command_Process(Communication_p, Packet_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+
+ if (NULL != Packet_p) {
+ free(Packet_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_Transport_Initialize.
+ * Function used in: Test_R15_Transport_Initialize.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_Transport_Initialize(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+
+ Result = R15_Transport_Initialize(Communication_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_Transport_Shutdown.
+ * Function used in: Test_R15_Transport_Shutdown.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_Transport_Shutdown(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+
+ Result = R15_Transport_Shutdown(Communication_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_Transport_Poll.
+ * Function used in: Test_R15_Transport_Poll.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_Transport_Poll(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+
+ Result = R15_Transport_Poll(Communication_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_Transport_Send.
+ * Function used in: Test_R15_Transport_Send.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_Transport_Send(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ void *InputDataIn_p = NULL;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+ InputDataIn_p = Do_ADbg_GetDataPointer(sizeof(void *), (void **)&Var_p);
+
+ Result = R15_Transport_Send(Communication_p, InputDataIn_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+
+ if (NULL != InputDataIn_p) {
+ free(InputDataIn_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_SetProtocolTimeouts.
+ * Function used in: Test_R15_SetProtocolTimeouts.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_SetProtocolTimeouts(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ void *TimeoutData_p = NULL;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+ TimeoutData_p = Do_ADbg_GetDataPointer(sizeof(void *), (void **)&Var_p);
+
+ Result = R15_SetProtocolTimeouts(Communication_p, TimeoutData_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+
+ if (NULL != TimeoutData_p) {
+ free(TimeoutData_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_GetProtocolTimeouts.
+ * Function used in: Test_R15_GetProtocolTimeouts.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_GetProtocolTimeouts(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ void *TimeoutData_p = NULL;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+ TimeoutData_p = Do_ADbg_GetDataPointer(sizeof(void *), (void **)&Var_p);
+
+ Result = R15_GetProtocolTimeouts(Communication_p, &TimeoutData_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+
+ if (NULL != TimeoutData_p) {
+ free(TimeoutData_p);
+ }
+}
+
+/** @} */
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204.h b/lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204.h
new file mode 100644
index 0000000..7749693
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204.h
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef ADBG_CNH1605204_H_
+#define ADBG_CNH1605204_H_
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+
+/* @} */
+#endif /*ADBG_CNH1605204_H_*/
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204_utilities.c b/lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204_utilities.c
new file mode 100644
index 0000000..6744a6f
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204_utilities.c
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+/**
+ * @file ADbg_cnh1605204_utilities.c
+ *
+ * @brief Interface functions for CNH1605204 module.
+ *
+ * This file consist of interface functions for setting preconditions
+ * for automatic testing functions from CNH1605204 module.
+ */
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "r_adbg.h"
+#include "r_adbg_int_function.h"
+#include "r_adbg_int_group.h"
+#include "r_adbg_command.h"
+#include "r_adbg_module.h"
+#include "r_communication_service.h"
+#include "ADbg_cnh1605204_utilities.h"
+
+/*******************************************************************************
+ * The interface functions declarations
+ ******************************************************************************/
+
+static void ADbg_IntGroup1_CNH1605204_Group(ADbg_Module_t *Module_p);
+/** Functions used for set the global variables. */
+static void ADbg_Test_Function1_CNH1605204(ADbg_IntFunction_t *IntFunction_p);
+
+/*******************************************************************************
+ * The interface group definitions
+ ******************************************************************************/
+//ADBG_INTERFACE_GROUP_DEFINE(InterfaceGroupName, InterfaceGroupId, ModuleId, InterfaceFunctionRunner)
+ADBG_INTERFACE_GROUP_DEFINE(Test_IntGroup1_CNH1605204_Group, 1, 8, ADbg_IntGroup1_CNH1605204_Group);
+
+/*******************************************************************************
+ * The interface function definitions
+ ******************************************************************************/
+
+static uint8 Param1[2] = {1, WORD};
+static uint8 Param2[4];
+ADBG_INTERFACE_FUNCTION_DEFINE(Test_Function1_CNH1605204, 1, 1, 8, ADbg_Test_Function1_CNH1605204, Param1, Param2);
+
+/*******************************************************************************
+ * The interface group suite definition
+ ******************************************************************************/
+//ADBG_INTERFACE_GROUP_SUITE_DEFINE_BEGIN(TestIntGroup_CNH1605204, 0, ModuleId)
+ADBG_INTERFACE_GROUP_SUITE_DEFINE_BEGIN(IntGroup_CNH1605204, 0, 8)
+
+//ADBG_INTERFACE_GROUP_SUITE_ENTRY(InterfaceGroupName)
+ADBG_INTERFACE_GROUP_SUITE_ENTRY(Test_IntGroup1_CNH1605204_Group)
+
+ADBG_INTERFACE_GROUP_SUITE_DEFINE_END();
+
+/*******************************************************************************
+ * The interface functions suites definition
+ ******************************************************************************/
+//ADBG_INTERFACE_FUNCTION_SUITE_DEFINE_BEGIN(TestIntFunctionSuiteName, 0, IntGroupId, ModuleId)
+
+ADBG_INTERFACE_FUNCTION_SUITE_DEFINE_BEGIN(IntGroup1_CNH1605204, 0, 1, 8)
+
+ADBG_INTERFACE_FUNCTION_SUITE_ENTRY(Test_Function1_CNH1605204) //InterfaceFunctionName
+
+ADBG_INTERFACE_FUNCTION_SUITE_DEFINE_END();
+
+/*******************************************************************************
+ * Interface group runner
+ ******************************************************************************/
+void Do_CNH1605204_Module_Interface_Run(ADbg_MainModule_t *MainModule_p)
+{
+ ADbg_Module_t *Module_p = Do_ADbg_Module_Create(NULL, IntGroup_CNH1605204, MainModule_p->Command_p, MainModule_p->Result_p);
+ Do_ADbg_InModule_Command(Module_p);
+ Do_ADbg_Module_Destroy(Module_p);
+}
+
+/*******************************************************************************
+ * Interface functions from group1 runner
+ ******************************************************************************/
+static void ADbg_IntGroup1_CNH1605204_Group(ADbg_Module_t *Module_p)
+{
+ ADbg_IntGroup_t *IntGroup1_p = Do_ADbg_IntGroup_Create(IntGroup1_CNH1605204, Module_p->Command_p, Module_p->Result_p);
+ Do_ADbg_InIntGroup_Command(IntGroup1_p);
+ Do_ADbg_IntGroup_Destroy(IntGroup1_p);
+}
+
+/**
+ * @brief Interface function.
+ *
+ * This function...
+ *
+ * @param [in] IntFunction_p is pointer.
+ * @return void.
+ */
+static void ADbg_Test_Function1_CNH1605204(ADbg_IntFunction_t *IntFunction_p)
+{
+ uint32 Param;
+
+ //...
+ Do_ADbg_SetAndRecoveryCondition((void *)&Param, Param2, sizeof(uint32), IntFunction_p);
+}
+
+/* @} */
diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204_utilities.h b/lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204_utilities.h
new file mode 100644
index 0000000..00299e7
--- /dev/null
+++ b/lcmodule/source/cnh1605204_ldr_transport_layer/test_cases/ADbg_cnh1605204_utilities.h
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef ADBG_CNH1605204_UTILITIES_H_
+#define ADBG_CNH1605204_UTILITIES_H_
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+
+/* @} */
+#endif /*ADBG_CNH1605204_UTIILITIES_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/r_a2_header.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_a2_header.h
new file mode 100644
index 0000000..cefb39f
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_a2_header.h
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _R_A2_HEADER_H_
+#define _R_A2_HEADER_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup ldr_header
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+#include "t_a2_header.h"
+#include "t_a2_network.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+/**
+ * Calculates the expected total packet length in bytes given the in-
+ * formation in Header_p.
+ *
+ * @param [in] Header_p Pointer to the header structure.
+ *
+ * @return The length of the packet in bytes.
+ */
+uint32 A2_GetPacketLength(const A2_Header_t *Header_p);
+
+/**
+ * Converts the header stored in network format to a structure.
+ *
+ * @param [out] Header_p Pointer to the header structure where the
+ * header data should be placed.
+ * @param [in] Data_p Pointer to the buffer with received header.
+ *
+ * @return Nothing.
+ */
+void A2_DeserializeHeader(A2_Header_t *Header_p, void *Data_p);
+
+/**
+ * Converts the header structure to network format.
+ *
+ * The data buffer must be of at least size A2_HEADER_LENGTH.
+ *
+ * @param [out] Data_p Pointer to the buffer where the
+ * serialized header should be placed.
+ * @param [in] Header_p Pointer to the source header structure.
+ *
+ * @return none.
+ */
+void A2_SerializeHeader(void *Data_p, const A2_Header_t *Header_p);
+
+/**
+ * Determines whether the first HEADER_LENGTH bytes of Data_p contains a
+ * valid header.
+ *
+ * @param [in] Data_p Pointer to the header candidate.
+ *
+ * @retval TRUE if header is valid.
+ * @retval FALSE if header is not valid.
+ */
+boolean A2_IsValidHeader(const void *Data_p);
+
+/**
+ * Checks if new header is received.
+ *
+ * @param [in] In_p Pointer to the structure with receiver information.
+ *
+ * @retval TRUE If header is received.
+ * @retval FALSE If header is not received.
+ */
+boolean A2_IsReceivedHeader(A2_Inbound_t *In_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*_R_A2_HEADER_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/r_a2_network.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_a2_network.h
new file mode 100644
index 0000000..e97a3e7
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_a2_network.h
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _R_A2_NETWORK_H_
+#define _R_A2_NETWORK_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup ldr_network_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "error_codes.h"
+#include "t_basicdefinitions.h"
+#include "t_a2_network.h"
+#include "t_communication_service.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+/**
+ * Initializes the A2 family network layer.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_INIT_COM_DEVICE Fail to initialize the communication
+ * device.
+ */
+ErrorCode_e A2_Network_Initialize(Communication_t *Communication_p);
+
+/**
+ * Shut down the A2 network layer.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e A2_Network_Shutdown(const Communication_t *const Communication_p);
+
+/**
+ * Cancel retransmission of packets.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] UniqueKey Unique key used for identification of packet
+ * for retransmission.
+ *
+ * @return none.
+ */
+ErrorCode_e A2_Network_CancelRetransmission(const Communication_t *const Communication_p, uint32 UniqueKey);
+
+/**
+ * Handler for received packets in A2 protocl family.
+ *
+ * This callback function handles the received packets.
+ *
+ * @param [in] Data_p Pointer to the received data.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Parameters;
+ *
+ * @return none.
+ */
+void A2_Network_ReadCallback(const void *Data_p, const uint32 Length, void *Param_p);
+
+/**
+ * Handler function that is called after successful transmission
+ * of a packet.
+ *
+ * If new packet is ready for transmitting it starts
+ * the transmission of the packet.
+ *
+ * @param [in] Data_p Pointer to the data for transmitting.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Parameters.
+ *
+ * @return none.
+ */
+void A2_Network_WriteCallback(const void *Data_p, const uint32 Length, void *Param_p);
+
+/**
+ * Handler for receiving new data.
+ *
+ * This function checks if new data has been received.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_FIND_COMM_BUFFER Fail to allocate the communication buffer.
+ */
+ErrorCode_e A2_Network_ReceiverHandler(Communication_t *Communication_p);
+
+/**
+ * Handler for transmitting available packets.
+ *
+ * This function transmits packet from outgoing queue.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_RETRANSMITION_FAILED If packet sending fails.
+ */
+ErrorCode_e A2_Network_TransmiterHandler(Communication_t *Communication_p);
+
+/**
+ * Network packet allocation in A2 protocol family.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] BufferSize Size of buffer used for network packet.
+ *
+ * @retval Pointer Pointer to allocated packet meta info.
+ * @retval NULL if allocation fail.
+ */
+A2_PacketMeta_t *A2_Network_PacketAllocate(const Communication_t *const Communication_p, int BufferSize);
+
+/**
+ * Network packet release in A2 protocol family.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] Meta_p Meta info for used network packet.
+ *
+ * @retval E_SUCCESS Successful network packet release.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e A2_Network_PacketRelease(const Communication_t *const Communication_p, A2_PacketMeta_t *Meta_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*_R_A2_NETWORK_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/r_protrom_header.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_protrom_header.h
new file mode 100644
index 0000000..8165430
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_protrom_header.h
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef R_PROTROM_HEADER_H_
+#define R_PROTROM_HEADER_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup protrom_family
+ * @{
+ * @addtogroup ldr_protrom_header PROTROM header
+ * Functionalities for serialization and de-serialization PROTROM header.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <t_basicdefinitions.h>
+#include "t_protrom_header.h"
+#include "t_protrom_network.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+/**
+ * Get packet length in bytes given the information in Header_p.
+ *
+ * @param [in] Header_p Pointer to the header structure.
+ *
+ * @return The length of the packet in bytes.
+ */
+uint32 Protrom_GetPacketLength(const Protrom_Header_t *Header_p);
+
+/**
+ * Converts the header stored in network format to a structure.
+ *
+ * @param [out] Header_p Pointer to the header structure where the
+ * header data should be placed.
+ * @param [in] Data_p Pointer to the buffer with received header.
+ *
+ * @return none.
+ */
+void Protrom_DeserializeHeader(Protrom_Header_t *Header_p, void *Data_p);
+
+/**
+ * Converts the header structure to network format.
+ *
+ * The data buffer must be of at least size PROTROM_HEADER_LENGTH.
+ *
+ * @param [out] Data_p Pointer to the buffer where the
+ * serialized header should be placed.
+ * @param [in] Header_p Pointer to the source header structure.
+ *
+ * @return none.
+ */
+void Protrom_SerializeHeader(void *Data_p, const Protrom_Header_t *Header_p);
+
+/**
+ * Determines whether the first PROTROM_HEADER_LENGTH bytes of Data_p contains a
+ * valid header.
+ *
+ * @param [in] Data_p Pointer to the header candidate.
+ *
+ * @retval TRUE If header is valid.
+ * @retval FALSE If header is not valid.
+ */
+boolean Protrom_IsValidHeader(const void *Data_p);
+
+/**
+ * Checks if new header is received.
+ *
+ * @param [in] In_p Pointer to the structure with receiver information.
+ *
+ * @retval TRUE If header is received.
+ * @retval FALSE If header is not received.
+ */
+boolean Protrom_IsReceivedHeader(Protrom_Inbound_t *In_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*R_PROTROM_HEADER_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/r_protrom_network.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_protrom_network.h
new file mode 100644
index 0000000..a6e897c
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_protrom_network.h
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef R_PROTROM_NETWORK_H_
+#define R_PROTROM_NETWORK_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup protrom_family
+ * @{
+ * @addtogroup ldr_protrom_network_layer PROTROM network layer
+ * PROTROM network layer support receiving and sending PROTROM packets.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "error_codes.h"
+#include "t_basicdefinitions.h"
+#include "t_protrom_network.h"
+#include "t_communication_service.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+/**
+ * Initializes the PROTOROM network layer.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_INIT_COM_DEVICE Failed to initialize the communication
+ * device.
+ */
+ErrorCode_e Protrom_Network_Initialize(Communication_t *Communication_p);
+
+/**
+ * Shutdown the PROTROM network layer.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Protrom_Network_Shutdown(const Communication_t *const Communication_p);
+
+/**
+ * This callback function handles the received packets.
+ *
+ * @param [in] Data_p Pointer to the received data.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Extra parameteres.
+ *
+ * @return none.
+ */
+void Protrom_Network_ReadCallback(const void *Data_p, const uint32 Length, void *Param_p);
+
+/**
+ * Handler function that is called after successful transmission
+ * of a packet.
+ *
+ * If new packet is ready for transmitting it starts
+ * the transmission of the packet.
+ *
+ * @param [in] Data_p Pointer to the data for transmitting.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Extra parameters.
+ *
+ * @return none.
+ */
+void Protrom_Network_WriteCallback(const void *Data_p, const uint32 Length, void *Param_p);
+
+/**
+ * This function checks if new data has been received.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @return none.
+ */
+void Protrom_Network_ReceiverHandler(Communication_t *Communication_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*R_PROTROM_NETWORK_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/r_r15_header.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_r15_header.h
new file mode 100644
index 0000000..fc05539
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_r15_header.h
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _R_R15_HEADER_H_
+#define _R_R15_HEADER_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup ldr_r15_header R15 header
+ * Functionalities for serialization and de-serialization header from R15
+ * protocol family.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+#include "t_r15_header.h"
+#include "t_r15_network_layer.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+/**
+ * Get packet length in bytes given the information in Header_p.
+ *
+ * @param [in] Header_p Pointer to the header structure.
+ *
+ * @return The length of the packet in bytes.
+ */
+uint32 R15_GetPacketLength(const R15_Header_t *Header_p);
+
+/**
+ * Deserialize the header stored in network format to a structure.
+ *
+ * @param [out] Header_p Pointer to the header structure where the
+ * header data should be placed.
+ * @param [in] Data_p Pointer to the buffer with received header.
+ *
+ * @return none.
+ */
+void R15_DeserializeHeader(R15_Header_t *Header_p, void *Data_p);
+
+/**
+ * Serialize the header structure to network format.
+ *
+ * The data buffer must be of at least size HEADER_LENGTH.
+ *
+ * @param [out] Data_p Pointer to the buffer where the
+ * serialized header should be placed.
+ * @param [in] Header_p Pointer to the source header structure.
+ *
+ * @return none.
+ */
+void R15_SerializeHeader(void *Data_p, const R15_Header_t *Header_p);
+
+/**
+ * Deserialize the extended header stored in network format to a structure.
+ *
+ * @param [out] Header_p Pointer to the extended header structure where the
+ * header data should be placed.
+ * @param [in] Data_p Pointer to the buffer with received header.
+ *
+ * @return none.
+ */
+void R15_DeserializeBulkExtendedHeader(BulkExtendedHeader_t *ExtendedHeader_p, void *Data_p);
+
+/**
+ * Converts the extended header structure to network format.
+ *
+ * @param [out] Data_p Pointer to the buffer where the
+ * serialized header should be placed.
+ * @param [in] ProtocolType The type of the protocol used for
+ * communication.
+ * @param [in] ExtHeader_p Pointer to the source header structure.
+ * @param [out] ExtHdrChecksum_p Calculated checksum for extended header data.
+ *
+ * @return none.
+ */
+void R15_SerializeExtendedHeader(void *Data_p, uint8 ProtocolType, const void *ExtHeader_p, uint8 *ExtHdrChecksum_p);
+
+/**
+ * Deserialize the command extended header stored in network format to a structure.
+ *
+ * @param [out] CommandExtendedHeader_p Pointer to the command extended header structure where the
+ * header data should be placed.
+ * @param [in] Data_p Pointer to the buffer with received header.
+ *
+ * @return none.
+ */
+void R15_DeserializeCommandExtendedHeader(CommandExtendedHeader_t *CommandExtendedHeader_p, void *Data_p);
+
+/**
+ * Determines whether the first HEADER_LENGTH bytes of Data_p contains a
+ * valid header.
+ *
+ * @param [in] Data_p Pointer to the header candidate.
+ *
+ * @retval TRUE If header is valid.
+ * @retval FALSE If header is not valid.
+ */
+boolean R15_IsValidHeader(const void *Data_p);
+
+/**
+ * Verify received extended header.
+ *
+ * @param [in] Data_p Pointer to the buffer.
+ * @param [in] Length Length of the buffer.
+ * @param [in] Checksum Checksum of the buffer.
+ *
+ * @retval TRUE If is extended header verified.
+ * @retval FALSE If extended header is not verified.
+ */
+boolean R15_IsValidExtendedHeader(const void *Data_p, const uint8 Length, const uint8 Checksum);
+
+/**
+ * Checks if new header is received.
+ *
+ * @param [in] In_p Pointer to the structure with receiver information.
+ *
+ * @retval TRUE If header is received.
+ * @retval FALSE If header is not received.
+ */
+boolean R15_IsReceivedHeader(R15_Inbound_t *In_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif /* _R_R15_HEADER_H_ */
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/r_r15_network_layer.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_r15_network_layer.h
new file mode 100644
index 0000000..cf739b5
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_r15_network_layer.h
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _R_R15_NETWORK_LAYER_H_
+#define _R_R15_NETWORK_LAYER_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup ldr_r15_network_layer R15 network layer
+ * R15 network layer support receiving and sending packets from
+ * R15 protocols.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "error_codes.h"
+#include "t_basicdefinitions.h"
+#include "t_r15_network_layer.h"
+#include "t_communication_service.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+/**
+ * Initializes the r15 network layer.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_INIT_COM_DEVICE Fail to initialize the communication
+ * device.
+ */
+ErrorCode_e R15_Network_Initialize(Communication_t *Communication_p);
+
+/**
+ * Shut down the r15 network layer.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e R15_Network_Shutdown(const Communication_t *const Communication_p);
+
+/**
+ * Cancel retransmission of packets.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] UniqueKey Unique key used for identification of packet
+ * for retransmission.
+ *
+ * @return none.
+ */
+ErrorCode_e R15_Network_CancelRetransmission(const Communication_t *const Communication_p, uint32 UniqueKey);
+
+/**
+ * Create unique key.
+ *
+ * This function combine the session number and protocol type in one
+ * unique key for command packet. For the bulk packet the unique key is the
+ * combination of protocol type, session number and command.
+ *
+ * @param [in] Packet_p Pointer to the packet.
+ * @param [in] ExternalKey External key for marking the packet for retransmision.
+ *
+ * @return Unique key.
+ */
+uint32 R15_Network_CreateUniqueKey(const PacketMeta_t *const Packet_p, const uint8 ExternalKey);
+
+/**
+ * Handler for received packets in R15 protocl family.
+ *
+ * This callback function handles the received packets.
+ *
+ * @param [in] Data_p Pointer to the received data.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Parameters;
+ *
+ * @return none.
+ */
+void R15_Network_ReadCallback(const void *Data_p, const uint32 Length, void *Param_p);
+
+/**
+ * Handler function that is called after successful transmission of a packet.
+ *
+ * If new packet is ready for transmitting it starts
+ * the transmission of the packet.
+ *
+ * @param [in] Data_p Pointer to the data for transmitting.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Parameters.
+ *
+ * @return none.
+ */
+void R15_Network_WriteCallback(const void *Data_p, const uint32 Length, void *Param_p);
+
+/**
+ * Handler for receiving new data.
+ *
+ * This function checks if new data has been received.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_FIND_COMM_BUFFER Fail to allocate the communication buffer.
+ */
+ErrorCode_e R15_Network_ReceiverHandler(Communication_t *Communication_p);
+
+/**
+ * Handler for sending data.
+ *
+ * This function checks if new data is available for sending and handles the transmision.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_RETRANSMITION_FAILED Packet retransmission failed.
+ */
+ErrorCode_e R15_Network_TransmiterHandler(Communication_t *Communication_p);
+
+/**
+ * Network packet allocation in R15 protocol family.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] BufferSize Size of buffer used for network packet.
+ *
+ * @retval Pointer Pointer to allocated packet meta info.
+ * @retval NULL if allocation fail.
+ */
+PacketMeta_t *R15_Network_PacketAllocate(const Communication_t *const Communication_p, int BufferSize);
+
+/**
+ * Network packet release in R15 protocol family.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] Meta_p Meta info for used network packet.
+ *
+ * @retval E_SUCCESS Successful network packet release.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e R15_Network_PacketRelease(const Communication_t *const Communication_p, PacketMeta_t *Meta_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*_R_R15_NETWORK_LAYER_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/r_z_network.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_z_network.h
new file mode 100644
index 0000000..c8450e5
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/r_z_network.h
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef R_Z_NETWORK_H_
+#define R_Z_NETWORK_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup z_family
+ * @{
+ * @addtogroup ldr_z_network_layer Z network layer
+ * Z network layer support receiving and sending bytes from
+ * Z protocol.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "error_codes.h"
+#include "t_basicdefinitions.h"
+#include "t_z_network.h"
+#include "t_communication_service.h"
+#include "t_z_protocol.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+/**
+ * Initializes the Z family network layer.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_INIT_COM_DEVICE Failed to initialize the communication
+ * device.
+ */
+ErrorCode_e Z_Network_Initialize(Communication_t *Communication_p);
+
+/**
+ * Shut down the Z family network layer.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Z_Network_Shutdown(const Communication_t *const Communication_p);
+
+/**
+ * Handler for received packets in Z protcol family.
+ *
+ * This callback function handles the received packets.
+ *
+ * @param [in] Data_p Pointer to the received data.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Extra parameters.
+ *
+ * @return none.
+ */
+void Z_Network_ReadCallback(const void *Data_p, const uint32 Length, void *Param_p);
+
+/**
+ * Handler function that is called after successful transmission of a packet.
+ *
+ * If new packet is ready for transmitting it starts
+ * the transmission of the packet.
+ *
+ * @param [in] Data_p Pointer to the data for transmitting.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Extra parameters.
+ *
+ * @return none.
+ */
+
+void Z_Network_WriteCallback(const void *Data_p, const uint32 Length, void *Param_p);
+
+/**
+ * Handler for receiving new data in Z protcol family.
+ *
+ * This function checks if new data has been received.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @return none.
+ */
+void Z_Network_ReceiverHandler(Communication_t *Communication_p);
+
+
+/**
+ * Handler for sending new data in Z protcol family.
+ *
+ * This function checks if new data has been transmited.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] SendingContent_p Pointer to the sending context.
+ *
+ * @return none.
+ */
+ErrorCode_e Z_Network_TransmiterHandler(Communication_t *Communication_p, Z_SendingContent_t *SendingContent_p);
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*R_Z_NETWORK_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/t_a2_header.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_a2_header.h
new file mode 100644
index 0000000..7607399
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_a2_header.h
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef T_A2_HEADER_H_
+#define T_A2_HEADER_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup ldr_header
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/** Header pattern for the A2 protocol*/
+#define A2_HEADER_PATTERN (0xAA)
+/** The length of the header */
+#define A2_HEADER_LENGTH 12
+/** The length of the header for acknowledge */
+#define A2_HEADER_LENGTH_ACK 10
+
+/**
+ * Header search results
+ */
+#define NO_A2_HEADER_PATTERN (0x00)
+#define A2_HEADER_PATTERN_MATCH (0x01)
+
+/** Protocol types*/
+typedef enum {
+ /** Control Message Protocol*/
+ PROTO_CTRL_MSG = 0x01,
+ /** Application data protocol (Command and General Response)*/
+ PROTO_A2 = 0x06,
+ /** Application data acknowledge protocol*/
+ PROTO_A2_ACK = 0x07,
+} A2_Protocol_t;
+
+/** Header for command protocol */
+typedef struct {
+ uint8 HeaderPattern;
+ uint8 Protocol;
+ uint8 SourceAddress;
+ uint8 DestinationAddress;
+ uint8 SequenceNumber;
+ uint8 Reserved[3];
+ uint32 DataLength;
+} A2_Header_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*T_A2_HEADER_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/t_a2_network.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_a2_network.h
new file mode 100644
index 0000000..6eb8ec5
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_a2_network.h
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef T_A2_NETWORK_H_
+#define T_A2_NETWORK_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup ldr_network_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_communication_service.h"
+#include "t_a2_header.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/** A2 protocol ID */
+#define A2_PROTOCOL (0xAA)
+/** A2 CRC length */
+#define A2_CRC_LENGTH (CRC16_LENGTH)
+
+/** Number of pre-allocated buffers */
+#define A2_COMMAND_BUFFER_COUNT 16
+/** Size of a buffer used for commands. */
+#define A2_COMMAND_BUFFER_SIZE 0x00010011
+
+/** Amount of resends of the same package (until it aborts) */
+#define MAX_RESENDS (0x03)
+
+TYPEDEF_ENUM {
+ //A2_BUF_FREE = 0x00000000, /**< No buffer activity */
+ A2_BUF_ALLOCATED = 0x00000001, /**< The buffer is allocated. */
+ //A2_BUF_TX_READY = 0x00000002, /**< The buffer is filled with data
+ // and is ready to be sent. */
+ //A2_BUF_TX_SENT = 0x00000004, /**< The buffer is sent and wait ACK. */
+ //A2_BUF_TX_SENDING = 0x00000008, /**< The buffer is sending. */
+ //A2_BUF_TX_DONE = 0x00000010, /**< The buffer has been sent and can
+ // be deallocated. */
+ //A2_BUF_TX_TIMEOUT = 0x00000020, /**< The timeout occur when buffer is
+ // sending. */
+ A2_BUF_RX_READY = 0x00000040, /**< The buffer is filled with
+ received data and is ready for
+ processing. */
+ A2_BUF_HDR_CRC_OK = 0x00000080, /**< Set to true if the CRC has been
+ calculated. */
+ A2_BUF_PAYLOAD_CRC_OK = 0x00000100, /**< Set to true if the CRC has been
+ calculated and is correct. */
+ //A2_BUF_ACK_READY = 0x00000200, /**< Set the buffer ready for
+ // acknowledge. */
+ //A2_BUF_ACKNOWLEDGED = 0x00000400, /**< Set if the buffer is
+ // acknowledged. */
+ //A2_BUF_CRC_CALC_READY = 0x00000800, /**< Set if the buffer is ready for
+ // payload CRC calculating */
+ //A2_BUF_CRC_CALCULATING = 0x00001000, /**< Set if the calculating of
+ // payload CRC is started */
+ A2_BUF_PAYLOAD_CRC_CALCULATED = 0x00002000, /**< Set if the payload CRC is
+ calculated */
+ A2_BUF_HEADER_CRC_CALCULATED = 0x00004000, /**< Set if the header CRC is
+ calculated */
+} ENUM32(A2_PacketFlags_t);
+
+/** defined state of the receiver */
+typedef enum {
+ A2_RECEIVE_HEADER, /**< State for receiving Header.*/
+ A2_RECEIVE_PAYLOAD, /**< State for receiving Payload.*/
+ A2_RECEIVE_ERROR, /**< State for error handling.*/
+ A2_RECEIVE_IDLE /**< Receiver idle state.*/
+} A2_InboundState_t;
+
+/** defined state of the transmitter */
+typedef enum {
+ A2_SEND_IDLE, /**< Transmitter idle state.*/
+ A2_SEND_HEADER, /**< Transmitter send header. */
+ A2_SENDING_HEADER, /**< Transmitter is in process of sending header. */
+ A2_SEND_PAYLOAD, /**< Transmitter send payload. */
+ A2_SENDING_PAYLOAD /**< Transmitter is in process of sending payload. */
+} A2_OutboundState_t;
+
+typedef void (*A2_PacketCallBack_t)(Communication_t *Communication_p, const void *Data_p);
+
+/** Structure for the packet meta data. */
+typedef struct A2_PacketMeta {
+ A2_PacketCallBack_t CallBack_p; /**< Callback function used after
+ sending packet.*/
+ uint32 Flags; /**< Field is a bit-field. Flags
+ for the Packet state. */
+ int BufferSize; /**< Field contains a Size of the
+ corresponding buffer used in
+ the packet. */
+ A2_Header_t Header; /**< Structure of the header. */
+ uint32 Resend; /**< Resend counter. */
+ Timer_t *Timer_p; /**< Timer data used for
+ sending/receiving packet. */
+ uint8 *Payload_p; /**< Pointer to the payload data
+ located in the packet. */
+ uint8 *Buffer_p; /**< Field contains a pointer to
+ the corresponding (type)
+ buffer. */
+ uint32 Canary; /**< Field contains the master
+ Canary value. NOTE: Currently
+ is not used */
+ Communication_t *Communication_p; /**< The communication over which
+ this packet has been/is to be
+ transferred over. */
+ uint8 CRC[A2_CRC_LENGTH]; /**< Field contain calculated CRC
+ for payload. */
+} A2_PacketMeta_t;
+
+/** Structure for handling incoming A2 packets.*/
+typedef struct {
+ /**< State of the state machine for handling incoming A2 packets. */
+ A2_InboundState_t State;
+ /**< Number of requested data for receiving from communication device. */
+ uint32 ReqData;
+ /**< Number of received data from communication device. */
+ uint32 RecData;
+ /**< Number of received data from backup buffer used for switching the
+ * protocol family. */
+ uint32 RecBackupData;
+ /**< Offset in the buffer for next data that should be received. */
+ uint32 ReqBuffOffset;
+ /**< Temporary pointer to buffer for handling received data.*/
+ uint8 *Target_p;
+ /**< Temporary buffer for receiving data. */
+ uint8 Scratch[A2_HEADER_LENGTH];
+ /** Temporary structure for handling A2 packet.*/
+ A2_Header_t Header;
+ /** Pointer to meta data for allocated buffer for handling A2 packet.*/
+ A2_PacketMeta_t *Packet_p;
+ /** Number of packets before receiver is stoped. */
+ uint8 PacketsBeforeReceiverStop;
+ /** Indicator for stopping the receiver. */
+ boolean StopTransfer;
+ /** Error flag, purposed for error handling.*/
+ ErrorCode_e LCM_Error;
+} A2_Inbound_t;
+
+/** A2_Outbound_t*/
+/** Structure for handling outgoing A2 packets.*/
+typedef struct {
+ /**< State of the state machine for handling outgoing A2 packets. */
+ A2_OutboundState_t State;
+ /** Temporary pointer for handling PROTROM packet.*/
+ A2_PacketMeta_t *Packet_p;
+ /**< Boolean value for controlling re-entry in transmitter function. */
+ boolean InLoad;
+ /** Error flag, purposed for error handling.*/
+ ErrorCode_e LCM_Error;
+} A2_Outbound_t;
+
+/** A2 Retransmission context. */
+typedef struct {
+ uint32 Timeout; /**< Defined timeout for retransmission. */
+ uint32 TimerKey; /**< Timer identification number.*/
+} A2_RetransmissionContext_t;
+
+/** A2 Network context */
+typedef struct {
+ A2_PacketMeta_t *MetaInfoList[A2_COMMAND_BUFFER_COUNT];
+ /**< List of meta data for used packets. */
+ A2_Inbound_t Inbound;
+ /**< @todo Write Documentation*/
+ A2_Outbound_t Outbound;
+ /**< @todo Write Documentation*/
+ A2_RetransmissionContext_t RetransmissionContext;
+ /**< Retransmission context for the packet that is currently sent. */
+} A2_NetworkContext_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*T_NETWORK_LAYER_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/t_protrom_header.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_protrom_header.h
new file mode 100644
index 0000000..63ae6ef
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_protrom_header.h
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef T_PROTROM_HEADER_H_
+#define T_PROTROM_HEADER_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup protrom_family
+ * @{
+ * @addtogroup ldr_protrom_header
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/** Header pattern for the protrom protocol*/
+#define PROTROM_HEADER_PATTERN (0xAA)
+/** Source address in the header*/
+#define PROTROM_SOURCE_ADDRESS (0xEE)
+/** Destination address in the header*/
+#define PROTROM_DESTINATION_ADDRESS (0xEE)
+/** The length of the header */
+#define PROTROM_HEADER_LENGTH 7
+/** Value of the reserved field */
+#define PROTROM_RESERVED_FIELD 0x00
+/** Offset of the header in the buffer */
+#define HEADER_OFFSET_IN_BUFFER 8
+
+/**
+ * Header search results
+ */
+#define NO_PROTROM_HEADER_PATTERN (0x00)
+#define PROTROM_HEADER_PATTERN_MATCH (0x01)
+#define PROTROM_HEADER_PATTERN_CANDIDATE (0x02)
+
+/** Protocol types*/
+typedef enum {
+ PROTO_PROTROM = 0xFB, /**< PROTROM protocol identification number. */
+} Protrom_Protocol_t;
+
+/** Header for command and bulk protocol */
+typedef struct {
+ uint8 HeaderPattern; /**< Header pattern for marking header start.*/
+ uint8 Protocol; /**< Protocol type. */
+ uint8 SourceAddress; /**< Source address. */
+ uint8 DestinationAddress; /**< Destionation address. */
+ uint8 ReservedField; /**< Reserved field. */
+ uint16 PayloadLength; /**< Payload length. */
+} Protrom_Header_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*T_PROTROM_HEADER_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/t_protrom_network.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_protrom_network.h
new file mode 100644
index 0000000..fa5402f
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_protrom_network.h
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef T_PROTROM_NETWORK_H_
+#define T_PROTROM_NETWORK_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup protrom_family
+ * @{
+ * @addtogroup ldr_protrom_network_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_communication_service.h"
+#include "t_protrom_header.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/** PROTROM protocol ID */
+#define PROTROM_PROTOCOL (0xFB)
+/** PROTROM CRC length */
+#define PROTROM_CRC_LENGTH (2)
+
+/** Defined state of the receiver */
+typedef enum {
+ PROTROM_RECEIVE_HEADER, /**< State for receiving Header.*/
+ PROTROM_RECEIVE_PAYLOAD, /**< State for receiving Payload.*/
+ PROTROM_RECEIVE_ERROR, /**< State for error handling.*/
+ PROTROM_RECEIVE_IDLE /**< State for receiver idele.*/
+} Protrom_InboundState_t;
+
+/** Defined state of the transmitter */
+typedef enum {
+ PROTROM_SEND_IDLE, /**< Transmiter idle state.*/
+ PROTROM_SEND_PACKET, /**< Transmiter send packet. */
+ PROTROM_SENDING_PACKET /**< Transmiter is in process sending packet.*/
+} Protrom_OutboundState_t;
+
+/** Structure for the packet meta data type. */
+typedef struct Protrom_Packet {
+ Protrom_Header_t Header; /**< PROTROM header structure. */
+ uint8 *Buffer_p; /**< Temporary buffer for receiving data.*/
+ uint16 CRC; /**< Calculated CRC of received packet. */
+ Communication_t *Communication_p; /**< The communication over which this
+ packet has been/is to be transferred
+ over */
+} Protrom_Packet_t;
+
+/** Structure for handling incoming PROTROM packets.*/
+typedef struct {
+ /**< State of the state machine for handling incoming PROTROM packets. */
+ Protrom_InboundState_t State;
+ /**< Number of requested data for receiving from communication device. */
+ uint32 ReqData;
+ /**< Number of receivied data from communication device. */
+ uint32 RecData;
+ /**< Number of receivied data from backup buffer used for switching the
+ * protocol family. */
+ uint32 RecBackupData;
+ /**< Offset in the buffer for next data that should be received. */
+ uint32 ReqBuffOffset;
+ /**< Temporary pointer to buffer for handling received data.*/
+ uint8 *Target_p;
+ /**< Temporary buffer for receiving data. */
+ uint8 Scratch[PROTROM_HEADER_LENGTH];
+ /** Number of packets before receiver is stoped. */
+ uint8 PacketsBeforeReceiverStop;
+ /** Indicator for stopping the receiver. */
+ boolean StopTransfer;
+ /** Temporary structure for handling PROTROM packet.*/
+ Protrom_Packet_t *Packet_p;
+} Protrom_Inbound_t;
+
+/** Structure for handling outgoing PROTROM packets.*/
+typedef struct {
+ /**< State of the state machine for handling outgoing PROTROM packets. */
+ Protrom_OutboundState_t State;
+ /** Temporary pointer for handling PROTROM packet.*/
+ Protrom_Packet_t *Packet_p;
+ /**< Boolean value for controling re-entry in transmiter fucntion. */
+ boolean InLoad;
+} Protrom_Outbound_t;
+
+
+/** PROTROM Network context */
+typedef struct {
+ /**< Structure for handling incoming PROTROM packets.*/
+ Protrom_Inbound_t Inbound;
+ /**< Structure for handling outgoing PROTROM packets.*/
+ Protrom_Outbound_t Outbound;
+} Protrom_NetworkContext_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*T_NETWORK_LAYER_H_*/
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
new file mode 100644
index 0000000..f102912
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_header.h
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _T_R15_HEADER_H_
+#define _T_R15_HEADER_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup ldr_r15_header
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+#define ALIGN_SIZE 512
+
+/** Length of the command packet header.*/
+#define TL_COMMAND_PACKET_HEADER_LENGTH 20
+/** Length of the bulk packet header.*/
+#define TL_BULK_PACKET_HEADER_LENGTH 36
+/** Length of the calculated sha256 hash. */
+#define SHA_256_HASH_LENGTH 32
+/** Header pattern for the loader protocol.*/
+#define HEADER_PATTERN (0xAA)
+/** Extended header pattern of the loader protocol.*/
+#define HEADER_PATTERN_EXTENSION (0xEE)
+/** The length of the header. */
+#define HEADER_LENGTH 16
+/** The length of the command extended header. */
+#define COMMAND_EXTENDED_HEADER_LENGTH 4
+/** The length of the bulk extended header. */
+#define BULK_EXTENDED_HEADER_LENGTH 20
+/** Offset of the header in the buffer. */
+#define HEADER_OFFSET_IN_BUFFER 8
+
+#define ALIGNED_HEADER_LENGTH ALIGN_SIZE
+#define ALIGNED_COMMAND_EXTENDED_HEADER_LENGTH ALIGN_SIZE
+#define ALIGNED_BULK_EXTENDED_HEADER_LENGTH ALIGN_SIZE
+
+/**
+ * Header search results
+ */
+#define NO_HEADER_PATTERN (0x00)
+#define HEADER_PATTERN_MATCH (0x01)
+#define HEADER_PATTERN_CANDIDATE (0x02)
+
+/** Protocol types*/
+typedef enum {
+ PROTO_COMMAND = 0xBC, /**< R15 command protocol identification number. */
+ PROTO_BULK = 0xBD /**< R15 bulk protocol identification number. */
+} R15_Protocol_t;
+
+/** Header for command and bulk protocol */
+typedef struct {
+ uint8 HeaderPattern; /**< Header pattern for marking header start.*/
+ uint8 Protocol; /**< Protocol type. */
+ uint16 HeaderPatternExtension; /**< Header pattern extension.*/
+ uint8 Flags; /**< Flasgs for the header.*/
+ uint8 ExtendedHeaderLength; /**< Extended header length.*/
+ uint8 ExtendedHeaderChecksum; /**< Extended header checksum.*/
+ uint32 PayloadLength; /**< Payload length. */
+ uint32 PayloadChecksum; /**< Payload checksum. */
+ uint8 HeaderChecksum; /**< Header checksum. */
+} R15_Header_t;
+
+
+/**
+ * Extended header for command protocol
+ */
+typedef struct {
+ uint16 SessionState; /**< Session and state for command header */
+ uint8 Command; /**< Specified command */
+ uint8 CommandGroup; /**< Specified command group */
+} CommandExtendedHeader_t;
+
+/**
+ * Extended header for bulk protocol
+ */
+typedef struct {
+ uint16 Session; /**< Session for bulk header */
+ uint8 TypeFlags; /**< Flags for data packet */
+ uint8 AcksChunk; /**< Number of acknowledged chunks or chunk identifier */
+ uint32 ChunkSize; /**< The maximum payload size of data packet */
+ uint64 Offset; /**< Offset from where the reading and writing of data should begin*/
+ uint32 Length; /**< How many bytes should be read/write */
+} BulkExtendedHeader_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*_T_R15_HEADER_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_network_layer.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_network_layer.h
new file mode 100644
index 0000000..bff1930
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_r15_network_layer.h
@@ -0,0 +1,314 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _T_R15_NETWORK_LAYER_H_
+#define _T_R15_NETWORK_LAYER_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup ldr_r15_network_layer
+ * @{
+ */
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_communication_service.h"
+#include "t_r15_header.h"
+#include "t_time_utilities.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/** PROTROM protocol ID*/
+#define PROTROM_PROTOCOL (0xFB)
+/** COMMAND protocol ID*/
+#define COMMAND_PROTOCOL (0xBC)
+/** BULK protocol ID*/
+#define BULK_PROTOCOL (0xBD)
+/** State: Command packet */
+#define COMMAND_PACKAGE (0x0000)
+/** State: Acknowledge packet */
+#define ACK_PACKAGE (0x0001)
+/** State: General response */
+#define GENERAL_RESPONSE_PACKAGE (0x0002)
+/** State: Acknowledge for general response */
+#define ACK_GENERAL_RESPONSE_PACKAGE (0x0003)
+/**
+ * Maximum numbers of used process in transport layer
+ */
+#define MAX_SIZE_RETRANSMISSION_LIST 32
+/** Amount of resends of the same package (until it aborts) */
+#define MAX_RESENDS (0x03)
+
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+/** Acknowledge packet time(mS) out value */
+#define ACK_TIMEOUT_IN_MS 10000
+/** Default time(mS) out for receiving bulk command */
+#define BULK_COMMAND_RECEIVING_TIMEOUT 10000
+/** Default time(mS) out for receiving bulk data. This value is set for UART on 115200kbps! */
+#define BULK_DATA_RECEIVING_TIMEOUT 120000
+
+#else
+/** Acknowledge packet time(mS) out value */
+#define ACK_TIMEOUT_IN_MS (5000)
+/** Default time(mS) out for receiving bulk command */
+#define BULK_COMMAND_RECEIVING_TIMEOUT (5000)
+/** Default time(mS) out for receiving bulk data. This value is set for UART on 115200kbps! */
+#define BULK_DATA_RECEIVING_TIMEOUT (120000)
+#endif
+
+/** Number of pre-allocated buffers */
+#define COMMAND_BUFFER_COUNT 16
+/** Number of pre-allocated buffers */
+#define BULK_BUFFER_COUNT 16
+
+/** Size of a buffer used for commands. */
+#define COMMAND_BUFFER_SIZE 0x00010000
+
+/** Size of a buffer used for bulk transfer,
+ * must be biger than buffer for commands. */
+#define BULK_BUFFER_SIZE 0x00100000
+
+
+/** Mask for clearing the state bits in session/state field */
+#define MASK_CLR_STATE (0xFFFC)
+/** Mask for selecting the state bits in session/state field */
+#define MASK_SELECT_STATE (0x0003)
+/** Mask for selecting the session number in session/state field */
+#define MASK_SELECT_SESSION_NUMBER (0x3FFF)
+/** Mask for selecting session bits */
+#define SESSION_MASK 0xFFFC
+
+/**
+ * Defines all posible types of buffers that can be created (allocated).
+ *
+ * It is used to specified the type of the buffer
+ * when allocating a new buffer. Also it is used when
+ * requesting the number of buffers to specify the buffer type.
+ */
+typedef enum {
+ UNDEFINED_BUFFER = 0, /** Buffer with no specified type.*/
+ COMMAND_BUFFER = 1, /** Command buffer type, used for commands.*/
+ BULK_BUFFER = 2 /** Bulk buffer type, used for bulk transfer.*/
+} BuffersType_t;
+
+/** The enum for buffer Flags values. */
+TYPEDEF_ENUM {
+ BUF_FREE = 0x00000000, /**< No buffer activity */
+ BUF_ALLOCATED = 0x00000001, /**< The buffer is allocated. */
+ BUF_TX_READY = 0x00000002, /**< The buffer is filled with data
+ and is ready to be sent. */
+ BUF_TX_SENDING = 0x00000004, /**< The buffer is sending. */
+ BUF_TX_SENT = 0x00000008, /**< The buffer is sent and wait ACK. */
+ BUF_TX_DONE = 0x00000010, /**< The buffer has been sent and can
+ be deallocated. */
+ BUF_TX_TIMEOUT = 0x00000020, /**< The timeout ocure when buffer is
+ sending. */
+ BUF_RX_READY = 0x00000040, /**< The buffer is filled with
+ received data and is ready for
+ processing. */
+ BUF_HDR_CRC_OK = 0x00000080, /**< Set to true if the CRC has been
+ calculated. */
+ BUF_PAYLOAD_CRC_OK = 0x00000100, /**< Set to true if the CRC has been
+ calculated and is correct. */
+ BUF_ACK_READY = 0x00000200, /**< Set the buffer ready for
+ acknowledge. */
+ BUF_ACKNOWLEDGED = 0x00000400, /**< Set if the buffer is
+ acknowledged. */
+ BUF_CRC_CALC_READY = 0x00000800, /**< Set if the buffer is ready for
+ payload CRC calculating */
+ BUF_CRC_CALCULATING = 0x00001000, /**< Set if the calculating of
+ payload CRC is started */
+ BUF_HEADER_CRC_CALCULATED = 0x00002000, /**< Set if the header CRC is
+ calculated */
+ BUF_PAYLOAD_CRC_CALCULATED = 0x00004000, /**< Set if the payload CRC is
+ calculated */
+} ENUM32(PacketFlags_t);
+
+/** Flags Masks **/
+#define PACKET_ALLOCATION_STATE_MASK (BUF_FREE | BUF_ALLOCATED)
+#define PACKET_TX_STATE_MASK (BUF_TX_READY | BUF_TX_SENDING | BUF_TX_SENT | BUF_TX_DONE | BUF_TX_TIMEOUT)
+#define PACKET_RX_STATE_MASK (BUF_RX_READY | BUF_HDR_CRC_OK | BUF_PAYLOAD_CRC_OK | BUF_ACK_READY | BUF_ACKNOWLEDGED)
+#define PACKET_CRC_STATE_MASK (BUF_CRC_CALC_READY | BUF_CRC_CALCULATING | BUF_PAYLOAD_CRC_CALCULATED | BUF_HEADER_CRC_CALCULATED)
+
+/** Macro for setting a packet state **/
+#define SET_PACKET_FLAGS(packet, mask, flags) \
+ do \
+ { \
+ (packet)->Flags &= ~(mask); \
+ (packet)->Flags |= (mask & flags); \
+ } while (0)
+
+#define CHECK_PACKET_FLAGS(packet, flags) (((flags) == ((packet)->Flags & (flags))) ? TRUE : FALSE)
+
+/** Defined state of the receiver */
+typedef enum {
+ RECEIVE_HEADER, /**< State for receiving Header.*/
+ RECEIVE_EXTENDED_HEADER, /**< State for receiving Extended Header.*/
+ RECEIVE_PAYLOAD, /**< State for receiving Payload.*/
+ RECEIVE_ERROR, /**< State for error handling.*/
+ RECEIVE_IDLE /**< State for receiver idle.*/
+} R15_InboundState_t;
+
+/** Defined state of the transmitter */
+typedef enum {
+ SEND_IDLE, /**< Transmiter idle state.*/
+ SEND_HEADER, /**< Transmiter send header and extended header. */
+ SENDING_HEADER, /**< Transmiter is in process sending the header and extended header. */
+ SEND_PAYLOAD, /**< Transmiter send payload. */
+ SENDING_PAYLOAD /**< Transmiter is in process sending payload.*/
+} R15_OutboundState_t;
+
+/**
+ * Command buffer used for sending and receiving commands.
+ */
+typedef struct {
+ uint32 Id; /**< The buffer ID. NOTE: Currently is
+ not used */
+ uint32 Canary0; /**< A canary value. NOTE: Currently is
+ not used */
+ uint8 Payload[COMMAND_BUFFER_SIZE]; /**< The buffer containing the raw packet
+ data. NOTE! The buffer includes all
+ the data that is sent
+ (header, data and CRC) */
+ uint32 Canary1; /**< A canary value. NOTE: Currently is
+ not used */
+} CommandBuffer_t;
+
+/** Structure for the bulk buffer type. */
+typedef struct {
+ uint32 Id; /**< The buffer ID. NOTE: Currently is
+ not used */
+ uint32 Canary0; /**< A canary value. NOTE: Currently is
+ not used */
+ uint8 Payload[BULK_BUFFER_SIZE]; /**< The buffer containing the raw packet
+ data. NOTE! The buffer includes all
+ the data that is sent
+ (header, data and CRC) */
+ uint32 Canary1; /**< A Canary value. NOTE: Currently is
+ not used */
+} BulkBuffer_t;
+
+typedef void (*PacketCallBack_t)(Communication_t *Communication_p, const void *Data_p);
+
+/** Structure for the packet meta data. */
+typedef struct PacketMeta {
+ PacketCallBack_t CallBack_p; /**< Cllback function used after
+ sending packet.*/
+ uint32 Flags; /**< Field is a bit-field. Flags
+ for the Packet state. */
+ int BufferSize; /**< Field contains a Size of the
+ corresponding buffer used in
+ the packet. */
+ R15_Header_t Header; /**< Structure of the header. */
+ uint32 Resend; /**< Resend counter. */
+ Timer_t *Timer_p; /**< Timer data used for
+ sending/reciving packet. */
+ uint8 *ExtendedHeader_p; /**< Pointer to the extended
+ header located in the packet. */
+ uint8 *Payload_p; /**< Pointer to the payload data
+ located in the packet. */
+ uint8 *Buffer_p; /**< Field contains a pointer to
+ the corresponding (type)
+ buffer. */
+ uint32 Canary; /**< Field contains the master
+ Canary value. NOTE: Currently
+ is not used */
+ Communication_t *Communication_p; /**< The communication over which
+ this packet has been/is to be
+ transferred over. */
+ uint8 Hash[SHA_256_HASH_LENGTH]; /**< Field contain calculated hash
+ for payload. */
+} PacketMeta_t;
+
+/** Retransmission context. */
+typedef struct {
+ uint32 Timeout; /**< Defined timeout for retransmission. */
+ uint32 TimerKey; /**< Timer identification number.*/
+ uint32 Key; /**< Generated unique key, used for marking packet for
+ retransmission or removing from
+ retransmission list. */
+ PacketMeta_t *Packet_p; /**< Pointer to the packet for retransmission. */
+} RetransmissionContext_t;
+
+
+/** Structure for handling incoming R15 packets.*/
+typedef struct {
+ /**< State of the state machine for handling incoming R15 packets. */
+ R15_InboundState_t State;
+ /**< Number of requested data for receiving from communication device. */
+ uint32 ReqData;
+ /**< Number of receivied data from communication device. */
+ uint32 RecData;
+ /**< Number of receivied data from backup buffer used for switching the
+ * protocol family. */
+ uint32 RecBackupData;
+ /**< Offset in the buffer for next data that should be received. */
+ uint32 ReqBuffOffset;
+ /**< Temporary pointer to buffer for handling received data.*/
+ uint8 *Target_p;
+ /**< Temporary buffer for receiving data. */
+ uint8 Scratch[ALIGNED_HEADER_LENGTH + ALIGNED_BULK_EXTENDED_HEADER_LENGTH];
+ /** Temporary structure for handling R15 packet.*/
+ R15_Header_t Header;
+ /** Poiter to meta data for allocated buffer for handling R15 packet.*/
+ PacketMeta_t *Packet_p;
+ /** Number of packets before receiver is stoped. */
+ uint8 PacketsBeforeReceiverStop;
+ /** Indicator for stopping the receiver. */
+ boolean StopTransfer;
+ /** Error flag, purposed for error handling.*/
+ ErrorCode_e LCM_Error;
+} R15_Inbound_t;
+
+
+/** Structure for handling outgoing R15 packets.*/
+typedef struct {
+ /**< State of the state machine for handling outgoing R15 packets. */
+ R15_OutboundState_t State;
+ /** Temporary pointer for handling PROTROM packet.*/
+ PacketMeta_t *Packet_p;
+ /**< Boolean value for controling re-entry in transmiter fucntion. */
+ boolean InLoad;
+ /** Error flag, purposed for error handling.*/
+ ErrorCode_e LCM_Error;
+} R15_Outbound_t;
+
+
+/** R15 Network context */
+typedef struct {
+ PacketMeta_t *MetaInfoList[COMMAND_BUFFER_COUNT+BULK_BUFFER_COUNT];
+ /**< List of meta data for used packets. */
+ RetransmissionContext_t *RetransmissionList[MAX_SIZE_RETRANSMISSION_LIST];
+ /**< List of packet for retransmision */
+ uint32 RetransmissionListCount;
+ /**< Counter for packets retransmision */
+ R15_Inbound_t Inbound;
+ /**< Context for receiver. */
+ R15_Outbound_t Outbound;
+ /**< Context for transmiter. */
+} R15_NetworkContext_t;
+
+/*
+ * XVSZOAN @TODO:
+ *
+ * This structure is only for UART Process File fix.
+ * When we start using ESB block for data verification
+ * structure should be deleted!
+ */
+typedef struct {
+ const uint8 *Data_Packet_p;
+ uint32 Packet_Size;
+ uint32 UART_Device;
+ boolean New_Packed_Arrived;
+} DataBox_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*_T_R15_NETWORK_LAYER_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/t_z_header.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_z_header.h
new file mode 100644
index 0000000..09fe771
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_z_header.h
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef T_Z_HEADER_H_
+#define T_Z_HEADER_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup z_family
+ * @{
+ * @addtogroup ldr_z_header Z header
+ * Functionalities for analizing header from Z protocol family.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+/** The length of the header */
+#define Z_HEADER_LENGTH 1
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*T_Z_HEADER_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/include/t_z_network.h b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_z_network.h
new file mode 100644
index 0000000..4135873
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/include/t_z_network.h
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef T_Z_NETWORK_H_
+#define T_Z_NETWORK_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup z_family
+ * @{
+ * @addtogroup ldr_z_network_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_communication_service.h"
+#include "t_z_header.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/** Defined state of the receiver */
+typedef enum {
+ Z_RECEIVE_HEADER, /**< State for receiving Header.*/
+ Z_RECEIVE_PAYLOAD, /**< State for receiving Payload.*/
+ Z_RECEIVE_ERROR, /**< State for error handling.*/
+ Z_RECEIVE_IDLE /**< Receiver idle state.*/
+} Z_InboundState_t;
+
+/** Defined state of the transmitter */
+typedef enum {
+ Z_SEND_IDLE, /**< Transmiter idle state.*/
+ Z_SEND_PACKET, /**< Transmiter send packet. */
+ Z_SENDING_PACKET /**< Transmiter is in process sending packet.*/
+} Z_OutboundState_t;
+
+/** Structure for handling incoming Z packets.*/
+typedef struct {
+ /**< State of the state machine for handling incoming Z packets. */
+ Z_InboundState_t State;
+ /**< Number of requested data for receiving from communication device. */
+ uint32 ReqData;
+ /**< Number of receivied data from communication device. */
+ uint32 RecData;
+ /**< Temporary pointer to buffer for handling received data.*/
+ uint8 *Target_p;
+ /** Number of packets before receiver is stoped. */
+ uint8 PacketsBeforeReceiverStop;
+ /** Indicator for stopping the receiver. */
+ boolean StopTransfer;
+ /**< Temporary buffer for receiving data. */
+ uint8 Scratch[Z_HEADER_LENGTH];
+} Z_Inbound_t;
+
+/** Structure for handling outgoing Z packets.*/
+typedef struct {
+ /**< State of the state machine for handling outgoing Z packets. */
+ Z_OutboundState_t State;
+ /**< Boolean value for controling re-entry in transmiter fucntion. */
+ boolean InLoad;
+} Z_Outbound_t;
+
+
+/** Z Network context */
+typedef struct {
+ /**< Structure for handling incoming Z packets.*/
+ Z_Inbound_t Inbound;
+ /**< Structure for handling outgoing Z packets.*/
+ Z_Outbound_t Outbound;
+} Z_NetworkContext_t;
+
+/** @} */
+/** @} */
+/** @} */
+#endif /*T_Z_LAYER_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/source/a2_header.c b/lcmodule/source/cnh1605205_ldr_network_layer/source/a2_header.c
new file mode 100644
index 0000000..7b7631b
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/source/a2_header.c
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup ldr_header
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "c_system.h"
+#include <string.h>
+#include "t_basicdefinitions.h"
+#include "r_a2_header.h"
+#include "r_serialization.h"
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+static uint8 A2_FindHeaderPattern(const uint8 *const HeaderData_p, uint32 *StartInBuffer_p);
+
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+
+/*
+ * Deserialize the header stored in network format to a structure.
+ *
+ * @param [out] Header_p Pointer to the header structure where the
+ * header data should be placed.
+ * @param [in] Data_p Pointer to the buffer with received header.
+ *
+ * @return none.
+ */
+void A2_DeserializeHeader(A2_Header_t *Header_p, void *Data_p)
+{
+ void *Iter_p = Data_p;
+
+ Header_p->HeaderPattern = get_uint8(&Iter_p);
+ Header_p->Protocol = get_uint8(&Iter_p);
+
+ if (PROTO_A2_ACK == Header_p->Protocol) {
+ Header_p->SourceAddress = get_uint8(&Iter_p);
+ Header_p->DestinationAddress = get_uint8(&Iter_p);
+ Header_p->SequenceNumber = get_uint8(&Iter_p);
+ Header_p->Reserved[0] = get_uint8(&Iter_p);
+ Header_p->Reserved[1] = get_uint8(&Iter_p);
+ Header_p->Reserved[2] = get_uint8(&Iter_p);
+ Header_p->DataLength = 0;
+ } else {
+ Header_p->SourceAddress = get_uint8(&Iter_p);
+ Header_p->DestinationAddress = get_uint8(&Iter_p);
+ Header_p->SequenceNumber = get_uint8(&Iter_p);
+ Header_p->Reserved[0] = get_uint8(&Iter_p);
+ Header_p->Reserved[1] = get_uint8(&Iter_p);
+ Header_p->Reserved[2] = get_uint8(&Iter_p);
+ Header_p->DataLength = get_uint32_le(&Iter_p);
+ }
+}
+
+/*
+ * Serialize the header structure to network format.
+ *
+ * The data buffer must be of at least size HEADER_LENGTH.
+ *
+ * @param [out] Data_p Pointer to the buffer where the
+ * serialized header should be placed.
+ * @param [in] Header_p Pointer to the source header structure.
+ *
+ * @return none.
+ */
+void A2_SerializeHeader(void *Data_p, const A2_Header_t *Header_p)
+{
+ void *Iter_p = Data_p;
+
+ if (PROTO_A2_ACK == Header_p->Protocol) {
+ put_uint8(&Iter_p, A2_HEADER_PATTERN);
+ put_uint8(&Iter_p, PROTO_A2_ACK);
+ put_uint8(&Iter_p, Header_p->SourceAddress);
+ put_uint8(&Iter_p, Header_p->DestinationAddress);
+ put_uint8(&Iter_p, Header_p->SequenceNumber);
+ put_uint8(&Iter_p, Header_p->Reserved[0]);
+ put_uint8(&Iter_p, Header_p->Reserved[1]);
+ put_uint8(&Iter_p, Header_p->Reserved[2]);
+ put_uint16_le(&Iter_p, 0);
+ } else {
+ put_uint8(&Iter_p, A2_HEADER_PATTERN);
+ put_uint8(&Iter_p, PROTO_A2);
+ put_uint8(&Iter_p, Header_p->SourceAddress);
+ put_uint8(&Iter_p, Header_p->DestinationAddress);
+ put_uint8(&Iter_p, Header_p->SequenceNumber);
+ put_uint8(&Iter_p, Header_p->Reserved[0]);
+ put_uint8(&Iter_p, Header_p->Reserved[1]);
+ put_uint8(&Iter_p, Header_p->Reserved[2]);
+ put_uint32_le(&Iter_p, Header_p->DataLength);
+ }
+}
+
+
+/*
+ * Get packet length in bytes given the information in Header_p.
+ *
+ * @param [in] Header_p Pointer to the header structure.
+ *
+ * @return The length of the packet in bytes.
+ */
+uint32 A2_GetPacketLength(const A2_Header_t *Header_p)
+{
+ return A2_HEADER_LENGTH + Header_p->DataLength;
+}
+
+
+/*
+ * Determines whether the first HEADER_LENGTH bytes of Data_p contains a
+ * valid header.
+ *
+ * @param [in] Data_p Pointer to the header candidate.
+ *
+ * @retval TRUE If header is valid.
+ * @retval FALSE If header is not valid.
+ */
+boolean A2_IsValidHeader(const void *Data_p)
+{
+ uint8 *Temp_p = (uint8 *)Data_p;
+
+ if (A2_HEADER_PATTERN != *Temp_p) {
+ return FALSE;
+ }
+
+ if ((PROTO_A2 != *(Temp_p + 1)) && (PROTO_A2_ACK != *(Temp_p + 1)) && (PROTO_CTRL_MSG != *(Temp_p + 1))) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+ * Checks if new header is received.
+ *
+ * @param [in] In_p Pointer to the structure with receiver information.
+ *
+ * @retval TRUE If header is received.
+ * @retval FALSE If header is not received.
+ */
+boolean A2_IsReceivedHeader(A2_Inbound_t *In_p)
+{
+ uint32 StartHeaderInBuffer = 0;
+ uint8 *TmpPointer_p = NULL;
+ uint8 Res = 0;
+
+ Res = A2_FindHeaderPattern(In_p->Scratch, &StartHeaderInBuffer);
+
+ if (A2_HEADER_PATTERN_MATCH == Res) {
+ /* Check start point of header in received data */
+ if (StartHeaderInBuffer == 0) {
+ return TRUE;
+ } else {
+ In_p->ReqData = StartHeaderInBuffer;
+ TmpPointer_p = (uint8 *)((uint32)In_p->Target_p + StartHeaderInBuffer);
+ memcpy(In_p->Target_p, (uint8 *)TmpPointer_p, A2_HEADER_LENGTH - StartHeaderInBuffer);
+ In_p->ReqBuffOffset = A2_HEADER_LENGTH - StartHeaderInBuffer;
+ }
+ } else {
+ /* setup for receiving new packet */
+ In_p->State = A2_RECEIVE_ERROR;
+ }
+
+ return FALSE;
+}
+
+static uint8 A2_FindHeaderPattern(const uint8 *const HeaderData_p, uint32 *StartInBuffer_p)
+{
+ uint8 Res = NO_A2_HEADER_PATTERN;
+ uint32 Offset = 0;
+
+ do {
+ Res = NO_A2_HEADER_PATTERN;
+
+ if ((*((uint8 *)HeaderData_p + Offset) == A2_HEADER_PATTERN)) {
+ Res = A2_HEADER_PATTERN_MATCH;
+ break;
+ }
+
+ Offset++;
+ } while (Offset < (A2_HEADER_LENGTH - 1));
+
+ *StartInBuffer_p = Offset;
+
+ return Res;
+}
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/source/a2_network.c b/lcmodule/source/cnh1605205_ldr_network_layer/source/a2_network.c
new file mode 100644
index 0000000..19d7800
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/source/a2_network.c
@@ -0,0 +1,599 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup ldr_network_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "c_system.h"
+#include "r_basicdefinitions.h"
+#include "r_a2_family.h"
+#include "r_a2_transport.h"
+#include "r_a2_network.h"
+#include "r_a2_protocol.h"
+#include "r_a2_header.h"
+#include "r_communication_service.h"
+#include "r_debug.h"
+#include "r_debug_macro.h"
+
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+static ErrorCode_e A2_Network_ReceiveHeader(const Communication_t *const Communication_p);
+static ErrorCode_e A2_Network_ReceivePayload(Communication_t *Communication_p);
+static ErrorCode_e A2_Network_RegisterRetransmission(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p);
+static void A2_Network_RetransmissionCallback(Communication_t *Communication_p, const void *const Timer_p, void *Data_p);
+static void A2_InHashCallback(const void *const Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p);
+#ifdef CFG_ENABLE_LOADER_TYPE
+static void A2_QueueCallback(const void *const Queue_p, void *Param_p);
+#endif //CFG_ENABLE_LOADER_TYPE
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+#define A2_RESET_INBOUND(c, s) do { (c)->ReqData = 0; (c)->RecData = 0; (c)->ReqBuffOffset = 0; (c)->Target_p = NULL; (c)->State = (s); } while(0);
+#define A2_SYNC_HEADER(c, d, t) do { (c)->ReqData = d; (c)->Target_p = t; } while(0);
+#define A2_SET_INBOUND(c, s, d) do { (c)->ReqData = d; (c)->RecData = 0; (c)->ReqBuffOffset = 0; (c)->State = (s); } while(0);
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+/*
+ * Initializes the A2 network layer.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_INIT_COM_DEVICE Fail to initialize the communication
+ * device.
+ */
+ErrorCode_e A2_Network_Initialize(Communication_t *Communication_p)
+{
+ memset(A2_NETWORK(Communication_p), 0, sizeof(A2_NetworkContext_t));
+
+ /* Simulate a finished read to get the inbound state-machine going. */
+ A2_Network_ReadCallback(NULL, 0, Communication_p);
+ A2_NETWORK(Communication_p)->Outbound.InLoad = FALSE;
+
+#ifdef CFG_ENABLE_LOADER_TYPE
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, QUEUE_NONEMPTY, A2_QueueCallback, Communication_p);
+#endif
+ A2_NETWORK(Communication_p)->Inbound.LCM_Error = E_SUCCESS;
+ A2_NETWORK(Communication_p)->Outbound.LCM_Error = E_SUCCESS;
+
+ return E_SUCCESS;
+}
+
+/*
+ * Shut down the A2 network layer.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e A2_Network_Shutdown(const Communication_t *const Communication_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, QUEUE_NONEMPTY, NULL, NULL);
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, QUEUE_EMPTY, NULL, NULL);
+
+
+ /* Wait until the all packets in the queue has released. */
+ while (!QUEUE(Communication_p, Fifo_IsEmpty_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p)) {
+ A2_PacketMeta_t *Packet_p = (A2_PacketMeta_t *)QUEUE(Communication_p, FifoDequeue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p);
+
+ if (Packet_p->Header.Protocol != A2_PROTOCOL) {
+ ReturnValue = A2_Network_PacketRelease(Communication_p, Packet_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+ }
+ }
+
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p, QUEUE_NONEMPTY, NULL, NULL);
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p, QUEUE_EMPTY, NULL, NULL);
+
+ /* Wait until the all packets in the queue has released. */
+ while (!QUEUE(Communication_p, Fifo_IsEmpty_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p)) {
+ ReturnValue = A2_Network_PacketRelease(Communication_p, (A2_PacketMeta_t *)QUEUE(Communication_p, FifoDequeue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p));
+ }
+
+ErrorExit:
+ return ReturnValue;
+}
+
+
+/*
+ * Handler for received packets in A2 protocl family.
+ *
+ * This callback function handles the received packets.
+ *
+ * @param [in] Data_p Pointer to the received data.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Parameters;
+ *
+ * @return none.
+ */
+void A2_Network_ReadCallback(const void *Data_p, const uint32 Length, void *Param_p)
+{
+ IDENTIFIER_NOT_USED(Data_p);
+ Communication_t *Communication_p = (Communication_t *)Param_p;
+
+ C_(printf("a2_network.c (%d) RecLength(%d) RecBackupData (%d)\n", __LINE__, Length, A2_NETWORK(Communication_p)->Inbound.RecBackupData);)
+ A2_NETWORK(Communication_p)->Inbound.RecData += Length + A2_NETWORK(Communication_p)->Inbound.RecBackupData;
+ A2_NETWORK(Communication_p)->Inbound.RecBackupData = 0;
+
+ if (A2_NETWORK(Communication_p)->Inbound.ReqData == 0) {
+ ErrorCode_e ReturnValue = E_GENERAL_COMMUNICATION_ERROR;
+
+ switch (A2_NETWORK(Communication_p)->Inbound.State) {
+ case A2_RECEIVE_HEADER:
+ ReturnValue = A2_Network_ReceiveHeader(Communication_p);
+ break;
+ case A2_RECEIVE_PAYLOAD:
+ ReturnValue = A2_Network_ReceivePayload(Communication_p);
+ break;
+ default:
+ A2_NETWORK(Communication_p)->Inbound.State = A2_RECEIVE_HEADER;
+ A2_NETWORK(Communication_p)->Inbound.RecData = 0;
+ A2_NETWORK(Communication_p)->Inbound.ReqData = A2_HEADER_LENGTH;
+ A2_NETWORK(Communication_p)->Inbound.Target_p = A2_NETWORK(Communication_p)->Inbound.Scratch;
+ A2_NETWORK(Communication_p)->Inbound.LCM_Error = E_SUCCESS;
+ ReturnValue = E_SUCCESS;
+ break;
+ }
+
+#ifdef CFG_ENABLE_LOADER_TYPE
+ ReturnValue = A2_Network_ReceiverHandler(Communication_p);
+#endif
+
+ if (E_SUCCESS != ReturnValue) {
+ A2_NETWORK(Communication_p)->Inbound.State = A2_RECEIVE_ERROR;
+ }
+
+ A2_NETWORK(Communication_p)->Inbound.LCM_Error = ReturnValue;
+ }
+}
+
+/*
+ * Handler for receiving new data.
+ *
+ * This function checks if new data has been received.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @return none.
+ */
+ErrorCode_e A2_Network_ReceiverHandler(Communication_t *Communication_p)
+{
+ uint32 ReqData;
+ A2_Inbound_t *In_p = &(A2_NETWORK(Communication_p)->Inbound);
+
+ if (In_p->ReqData > 0) {
+ if (Communication_p->BackupCommBufferSize != 0) {
+ if (Communication_p->BackupCommBufferSize < In_p->ReqData) {
+ memcpy(In_p->Target_p + In_p->ReqBuffOffset, Communication_p->BackupCommBuffer_p, Communication_p->BackupCommBufferSize);
+ In_p->RecBackupData = Communication_p->BackupCommBufferSize;
+ (void)Communication_p->CommunicationDevice_p->Read(In_p->Target_p + In_p->ReqBuffOffset + Communication_p->BackupCommBufferSize,
+ In_p->ReqData - Communication_p->BackupCommBufferSize,
+ A2_Network_ReadCallback, Communication_p);
+ C_(printf("a2_network.c (%d) ReqData(%d) RecData(%d)\n", __LINE__, In_p->ReqData, In_p->RecData);)
+ C_(printf("a2_network.c (%d) Communication_p->BackupCommBufferSize(%d) RecBackupData (%d)\n", __LINE__, Communication_p->BackupCommBufferSize, In_p->RecBackupData);)
+ In_p->RecData = 0;
+ In_p->ReqBuffOffset = 0;
+ Communication_p->BackupCommBufferSize = 0;
+ In_p->ReqData = 0;
+ } else {
+ memcpy(In_p->Target_p + In_p->ReqBuffOffset, Communication_p->BackupCommBuffer_p, In_p->ReqData);
+ Communication_p->BackupCommBufferSize = Communication_p->BackupCommBufferSize - In_p->ReqData;
+ ReqData = In_p->ReqData;
+ In_p->ReqData = 0;
+ A2_Network_ReadCallback(In_p->Target_p + In_p->ReqBuffOffset, ReqData, Communication_p);
+ In_p->RecData = 0;
+ }
+ } else {
+ ReqData = In_p->ReqData;
+ In_p->ReqData = 0;
+ (void)Communication_p->CommunicationDevice_p->Read(In_p->Target_p + In_p->ReqBuffOffset, ReqData, A2_Network_ReadCallback, Communication_p);
+ C_(printf("a2_network.c (%d) ReqData(%d) RecData(%d) \n", __LINE__, In_p->ReqData, In_p->RecData);)
+ C_(printf("a2_network.c (%d) Communication_p->BackupCommBufferSize(%d) RecBackupData (%d)\n", __LINE__, Communication_p->BackupCommBufferSize, In_p->RecBackupData);)
+ In_p->RecData = 0;
+ In_p->ReqBuffOffset = 0;
+ }
+ }
+
+ /* check for receiver sinhronization */
+ if (In_p->State == A2_RECEIVE_ERROR) {
+ A2_RESET_INBOUND(In_p, A2_RECEIVE_HEADER);
+ A2_SYNC_HEADER(In_p, A2_HEADER_LENGTH, In_p->Scratch);
+ //(void)Communication_p->CommunicationDevice_p->Read(In_p->Target_p, A2_HEADER_LENGTH, A2_Network_ReadCallback, Communication_p);
+ }
+
+ return A2_NETWORK(Communication_p)->Inbound.LCM_Error;
+}
+
+/*
+ * Cancel retransmission of packets.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] UniqueKey Unique key used for identification of packet
+ * for retransmission.
+ *
+ * @return none.
+ */
+ErrorCode_e A2_Network_CancelRetransmission(const Communication_t *const Communication_p, uint32 UniqueKey)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ uint32 SequenceNumber = A2_NETWORK(Communication_p)->Outbound.Packet_p->Header.SequenceNumber;
+
+ if (SequenceNumber != UniqueKey) {
+ A_(printf("a2_network.c(%d): Cancel packet retransmission error: SequenceNumber = %u, UniqueKey = %u\n", __LINE__, SequenceNumber, UniqueKey);)
+ return E_GENERAL_FATAL_ERROR;
+ }
+
+ (void)TIMER(Communication_p, TimerRelease_Fn)(OBJECT_TIMER(Communication_p), A2_NETWORK(Communication_p)->RetransmissionContext.TimerKey);
+ free(A2_NETWORK(Communication_p)->Outbound.Packet_p->Timer_p);
+ ReturnValue = A2_Network_PacketRelease(Communication_p, A2_NETWORK(Communication_p)->Outbound.Packet_p);
+
+ if (E_SUCCESS != ReturnValue) {
+ A_(printf("a2_network.c(%d): Packet release failed\n", __LINE__);)
+ return ReturnValue;
+ }
+
+ A2_NETWORK(Communication_p)->Outbound.State = A2_SEND_IDLE;
+ A2_NETWORK(Communication_p)->Outbound.Packet_p = NULL;
+
+ return ReturnValue;
+}
+
+/*
+ * Network packet allocation in A2 protocol family.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] BufferSize Size of buffer used for network packet.
+ *
+ * @retval Pointer Pointer to allocated packet meta info.
+ * @retval NULL if allocation fail.
+ */
+A2_PacketMeta_t *A2_Network_PacketAllocate(const Communication_t *const Communication_p, int BufferSize)
+{
+ A2_PacketMeta_t *Meta_p = NULL;
+ void *Buffer_p = NULL;
+ int BuffersNr = 0;
+
+ /* Find the first unallocated buffers. */
+ Buffer_p = BUFFER(Communication_p, BufferAllocate_Fn)(OBJECT_BUFFER(Communication_p), BufferSize);
+
+ if (NULL == Buffer_p) {
+ A_(printf("a2_network.c (%d): ** Buffer allocation fail! **\n", __LINE__);)
+ goto ErrorExit;
+ }
+
+ B_(printf("a2_network.c (%d): Buffer allocate (0x%x)! **\n", __LINE__, (uint32)Buffer_p);)
+
+ /* packet meta info allocate */
+ Meta_p = (A2_PacketMeta_t *)malloc(sizeof(A2_PacketMeta_t));
+
+ if (NULL == Meta_p) {
+ A2_NETWORK(Communication_p)->Inbound.LCM_Error = E_ALLOCATE_FAILED;
+ goto ErrorExit;
+ }
+
+ /* packet meta info setup */
+ Meta_p->Buffer_p = (uint8 *)Buffer_p;
+ Meta_p->BufferSize = BufferSize;
+ Meta_p->Flags = A2_BUF_ALLOCATED;
+
+ do {
+ if (NULL == A2_NETWORK(Communication_p)->MetaInfoList[BuffersNr]) {
+ A2_NETWORK(Communication_p)->MetaInfoList[BuffersNr] = Meta_p;
+ break;
+ }
+
+ BuffersNr++;
+ } while (BuffersNr < (A2_COMMAND_BUFFER_COUNT));
+
+ErrorExit:
+ return Meta_p;
+}
+
+/*
+ * Network packet release in A2 protocol family.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] Meta_p Meta info for used network packet.
+ *
+ * @retval E_SUCCESS Successful network packet release.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e A2_Network_PacketRelease(const Communication_t *const Communication_p, A2_PacketMeta_t *Meta_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ int BuffersNr = 0;
+
+ VERIFY(NULL != Meta_p, E_INVALID_INPUT_PARAMETERS);
+
+ /* remove the meta info data from list */
+ do {
+ if (Meta_p == A2_NETWORK(Communication_p)->MetaInfoList[BuffersNr]) {
+ /* release buffer */
+ B_(printf("a2_network.c (%d): Buffer release (0x%x)! **\n", __LINE__, (uint32)(Meta_p->Buffer_p));)
+ ReturnValue = BUFFER(Communication_p, BufferRelease_Fn)(OBJECT_BUFFER(Communication_p), Meta_p->Buffer_p, Meta_p->BufferSize);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+ B_(printf("a2_network.c (%d): Buffer released! **\n", __LINE__);)
+
+ A2_NETWORK(Communication_p)->MetaInfoList[BuffersNr] = NULL;
+ memset(Meta_p, 0, sizeof(A2_PacketMeta_t));
+ break;
+ }
+
+ BuffersNr++;
+ } while (BuffersNr < (A2_COMMAND_BUFFER_COUNT));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Handler function that is called after successful transmission of a packet.
+ *
+ * If new packet is ready for transmitting it starts
+ * the transmission of the packet.
+ *
+ * @param [in] Data_p Pointer to the data for transmitting.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Parameters.
+ *
+ * @return none.
+ */
+void A2_Network_WriteCallback(const void *Data_p, const uint32 Length, void *Param_p)
+{
+ IDENTIFIER_NOT_USED(Data_p);
+ IDENTIFIER_NOT_USED(Length);
+ Communication_t *Communication_p = (Communication_t *)Param_p;
+ A2_Outbound_t *Out_p = &(A2_NETWORK(Communication_p)->Outbound);
+
+ if (A2_SENDING_PAYLOAD == Out_p->State) {
+ if (NULL != Out_p->Packet_p->Timer_p) {
+ (void)A2_Network_RegisterRetransmission(Communication_p, Out_p->Packet_p);
+ } else {
+ (void)A2_Network_PacketRelease(Communication_p, Out_p->Packet_p);
+ Out_p->State = A2_SEND_IDLE;
+ Out_p->Packet_p = NULL;
+ }
+ } else if (A2_SENDING_HEADER == Out_p->State) {
+ Out_p->State = A2_SEND_PAYLOAD;
+ } else {
+ /* should never happen
+ TODO: Error handling */
+ }
+
+#ifdef CFG_ENABLE_LOADER_TYPE
+
+ if (E_SUCCESS != A2_Network_TransmiterHandler(Communication_p)) {
+ A2_NETWORK(Communication_p)->Outbound.LCM_Error = E_GENERAL_COMMUNICATION_ERROR;
+ }
+
+#endif
+}
+
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+static ErrorCode_e A2_Network_ReceiveHeader(const Communication_t *const Communication_p)
+{
+ A2_Inbound_t *In_p = &(A2_NETWORK(Communication_p)->Inbound);
+ ErrorCode_e ReturnValue = E_SUCCESS;
+
+ if (In_p->RecData == 0) {
+ In_p->ReqData = A2_HEADER_LENGTH;
+ In_p->Target_p = In_p->Scratch;
+ In_p->ReqBuffOffset = 0;
+ } else {
+ if (A2_IsReceivedHeader(In_p)) {
+ if (A2_IsValidHeader(In_p->Scratch)) {
+ A2_DeserializeHeader(&In_p->Header, In_p->Scratch);
+ In_p->Packet_p = A2_Network_PacketAllocate(Communication_p, A2_COMMAND_BUFFER_SIZE);
+ VERIFY(NULL != In_p->Packet_p, E_FAILED_TO_FIND_COMM_BUFFER);
+ A2_DeserializeHeader(&In_p->Packet_p->Header, In_p->Scratch);
+ In_p->Packet_p->Flags = In_p->Packet_p->Flags | A2_BUF_HDR_CRC_OK;
+ In_p->Target_p = In_p->Packet_p->Buffer_p;
+ memcpy(In_p->Target_p, In_p->Scratch, A2_HEADER_LENGTH);
+ In_p->Target_p += A2_HEADER_LENGTH;
+ In_p->Packet_p->Payload_p = In_p->Packet_p->Buffer_p + A2_HEADER_LENGTH;
+
+ /* check for expected payload */
+ if (In_p->Header.DataLength != 0) {
+ A2_SET_INBOUND(In_p, A2_RECEIVE_PAYLOAD, In_p->Header.DataLength + A2_CRC_LENGTH);
+ } else {
+ (void)QUEUE(Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p, In_p->Packet_p);
+
+ /* Sync the header. */
+ In_p->Packet_p = NULL;
+ A2_RESET_INBOUND(In_p, A2_RECEIVE_HEADER);
+
+ if (A2_SPEEDFLASH_START != A2_SPEEDFLASH(Communication_p)->State) {
+ A2_SYNC_HEADER(In_p, A2_HEADER_LENGTH, In_p->Scratch);
+ }
+
+ C_(printf("a2_network.c (%d) ReqData(%d) RecData(%d) \n", __LINE__, In_p->ReqData, In_p->RecData);)
+ }
+ } else {
+ /* Sync the header. */
+ A2_RESET_INBOUND(In_p, A2_RECEIVE_HEADER);
+ A2_SYNC_HEADER(In_p, A2_HEADER_LENGTH, In_p->Scratch);
+ }
+ }
+ }
+
+ErrorExit:
+ return ReturnValue;
+}
+
+static ErrorCode_e A2_Network_ReceivePayload(Communication_t *Communication_p)
+{
+ A2_Inbound_t *In_p = &(A2_NETWORK(Communication_p)->Inbound);
+ A2_PacketMeta_t *Packet_p = In_p->Packet_p;
+
+ Packet_p->Communication_p = Communication_p;
+
+ if (HASH_NONE != Communication_p->CurrentFamilyHash) {
+ Communication_p->HashDevice_p->Calculate(OBJECT_HASH(Communication_p),
+ Communication_p->CurrentFamilyHash,
+ Packet_p->Buffer_p, Packet_p->Header.DataLength + A2_HEADER_LENGTH,
+ Packet_p->CRC, (HashCallback_t)A2_InHashCallback,
+ (void *)Packet_p);
+ } else {
+ Packet_p->Flags = Packet_p->Flags | A2_BUF_PAYLOAD_CRC_OK | A2_BUF_RX_READY;
+ (void)QUEUE((Packet_p->Communication_p), FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Inbound_p, Packet_p);
+ }
+
+ In_p->Packet_p = NULL;
+ A2_RESET_INBOUND(In_p, A2_RECEIVE_HEADER);
+ A2_SYNC_HEADER(In_p, A2_HEADER_LENGTH, In_p->Scratch);
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2_Network_TransmiterHandler(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ A2_Outbound_t *Out_p = &(A2_NETWORK(Communication_p)->Outbound);
+
+ if (Out_p->InLoad) {
+ return E_SUCCESS;
+ }
+
+ Out_p->InLoad = TRUE;
+
+ switch (Out_p->State) {
+ case A2_SEND_IDLE:
+ /* check retransmission count before send */
+ Out_p->Packet_p = (A2_PacketMeta_t *)QUEUE(Communication_p, FifoDequeue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p);
+
+ if (NULL != Out_p->Packet_p) {
+ if (Out_p->Packet_p->Resend < MAX_RESENDS) {
+ Out_p->Packet_p->Resend++;
+ /* get next packet for transmitting */
+ Out_p->State = A2_SEND_HEADER;
+ } else {
+ return E_RETRANSMITION_FAILED;
+ }
+ } else {
+ break;
+ }
+
+ /* FALLTHROUGH */
+ case A2_SEND_HEADER:
+
+ /* set next state before calling the communication device, to avoid race condition
+ where write callback is called before new state is set */
+ if (Out_p->Packet_p->Header.Protocol == PROTO_A2_ACK) {
+ Out_p->State = A2_SENDING_PAYLOAD;
+ } else {
+ Out_p->State = A2_SENDING_HEADER;
+ }
+
+ if (E_SUCCESS == Communication_p->CommunicationDevice_p->Write((Out_p->Packet_p->Buffer_p),
+ A2_HEADER_LENGTH, A2_Network_WriteCallback, Communication_p)) {
+ C_(printf("a2_network.c (%d) Header Sent to comm device! \n", __LINE__);)
+ } else {
+ Out_p->State = A2_SEND_HEADER;
+ C_(printf("a2_network.c (%d) Error sending header to comm device! \n", __LINE__);)
+ }
+
+ break;
+ case A2_SENDING_HEADER:
+ /* nothing to do, wait until sending is finished and state changed in write callback */
+ break;
+ case A2_SEND_PAYLOAD:
+ Out_p->State = A2_SENDING_PAYLOAD;
+
+ if (E_SUCCESS == Communication_p->CommunicationDevice_p->Write(
+ (Out_p->Packet_p->Buffer_p + A2_HEADER_LENGTH),
+ Out_p->Packet_p->Header.DataLength + A2_CRC_LENGTH,
+ A2_Network_WriteCallback, Communication_p)) {
+ C_(printf("a2_network.c (%d) Payload Sent to comm device! \n", __LINE__);)
+ } else {
+ Out_p->State = A2_SEND_PAYLOAD;
+ C_(printf("a2_network.c (%d) Error sending payload to comm device! \n", __LINE__);)
+ }
+
+ break;
+ case A2_SENDING_PAYLOAD:
+ /* nothing to do, wait until sending is finished and state changed when packet ACK is received */
+ break;
+ }
+
+ Out_p->InLoad = FALSE;
+
+ return ReturnValue;
+}
+
+static ErrorCode_e A2_Network_RegisterRetransmission(Communication_t *Communication_p, A2_PacketMeta_t *Packet_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+
+ if (NULL == Packet_p->Timer_p->HandleFunction_p) {
+ Packet_p->Timer_p->HandleFunction_p = (HandleFunction_t)A2_Network_RetransmissionCallback;
+ Packet_p->Timer_p->Param_p = Communication_p;
+ }
+
+ A2_NETWORK(Communication_p)->RetransmissionContext.TimerKey = TIMER(Communication_p, TimerGet_Fn)(OBJECT_TIMER(Communication_p), Packet_p->Timer_p);
+ A2_NETWORK(Communication_p)->RetransmissionContext.Timeout = Packet_p->Timer_p->Time;
+
+ return ReturnValue;
+}
+
+static void A2_Network_RetransmissionCallback(Communication_t *Communication_p, const void *const Timer_p, void *Data_p)
+{
+ (void)QUEUE(Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, Data_p);
+}
+
+static void A2_InHashCallback(const void *const Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p)
+{
+ IDENTIFIER_NOT_USED(Data_p);
+ IDENTIFIER_NOT_USED(Length);
+ A2_PacketMeta_t *Packet_p = (A2_PacketMeta_t *)Param_p;
+
+ if (memcmp(Hash_p, Packet_p->Buffer_p + A2_HEADER_LENGTH + Packet_p->Header.DataLength, sizeof(uint16)) == 0) {
+ Packet_p->Flags = Packet_p->Flags | A2_BUF_PAYLOAD_CRC_OK | A2_BUF_RX_READY;
+ (void)QUEUE((Packet_p->Communication_p), FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Inbound_p, Packet_p);
+ } else {
+ /* Invalid packet */
+ ErrorCode_e ReturnValue = E_GENERAL_FATAL_ERROR;
+
+ if (E_SUCCESS != (ReturnValue = A2_Network_PacketRelease((Communication_t *)Packet_p->Communication_p, Packet_p))) {
+ A2_NETWORK((Communication_t *)((A2_PacketMeta_t *)Param_p)->Communication_p)->Inbound.LCM_Error = ReturnValue;
+ }
+ }
+}
+
+#ifdef CFG_ENABLE_LOADER_TYPE
+static void A2_QueueCallback(const void *const Queue_p, void *Param_p)
+{
+ if (E_SUCCESS != A2_Network_TransmiterHandler((Communication_t *)Param_p)) {
+ A2_NETWORK((Communication_t *)Param_p)->Outbound.LCM_Error = E_GENERAL_COMMUNICATION_ERROR;
+ }
+}
+#endif //CFG_ENABLE_LOADER_TYPE
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_header.c b/lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_header.c
new file mode 100644
index 0000000..eab4a6a
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_header.c
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup protrom_family
+ * @{
+ * @addtogroup ldr_header
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "c_system.h"
+#include <string.h>
+#include "t_basicdefinitions.h"
+#include "r_protrom_header.h"
+#include "r_serialization.h"
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+static uint8 Protrom_FindHeaderPattern(const uint8 *const HeaderData_p, uint32 *StartInBuffer_p);
+
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+
+/*
+ * Converts the header stored in network format to a structure.
+ *
+ * @param [out] Header_p Pointer to the header structure where the
+ * header data should be placed.
+ * @param [in] Data_p Pointer to the buffer with received header.
+ *
+ * @return none.
+ */
+void Protrom_DeserializeHeader(Protrom_Header_t *Header_p, void *Data_p)
+{
+ void *Iter_p = Data_p;
+
+ Header_p->HeaderPattern = get_uint8(&Iter_p);
+ Header_p->Protocol = get_uint8(&Iter_p);
+ Header_p->SourceAddress = get_uint8(&Iter_p);
+ Header_p->DestinationAddress = get_uint8(&Iter_p);
+ Header_p->ReservedField = get_uint8(&Iter_p);
+ Header_p->PayloadLength = get_uint16(&Iter_p);
+}
+
+
+/*
+ * Converts the header structure to network format.
+ *
+ * The data buffer must be of at least size PROTROM_HEADER_LENGTH.
+ *
+ * @param [out] Data_p Pointer to the buffer where the
+ * serialized header should be placed.
+ * @param [in] Header_p Pointer to the source header structure.
+ *
+ * @return none.
+ */
+void Protrom_SerializeHeader(void *Data_p, const Protrom_Header_t *Header_p)
+{
+ void *Iter_p = Data_p;
+
+ put_uint8(&Iter_p, PROTROM_HEADER_PATTERN);
+ put_uint8(&Iter_p, PROTO_PROTROM);
+ put_uint8(&Iter_p, PROTROM_SOURCE_ADDRESS);
+ put_uint8(&Iter_p, PROTROM_DESTINATION_ADDRESS);
+ put_uint8(&Iter_p, PROTROM_RESERVED_FIELD);
+ put_uint16(&Iter_p, Header_p->PayloadLength);
+}
+
+/*
+ * Get packet length in bytes given the information in Header_p.
+ *
+ * @param [in] Header_p Pointer to the header structure.
+ *
+ * @return The length of the packet in bytes.
+ */
+uint32 Protrom_GetPacketLength(const Protrom_Header_t *Header_p)
+{
+ return PROTROM_HEADER_LENGTH + Header_p->PayloadLength;
+}
+
+
+/*
+ * Determines whether the first PROTROM_HEADER_LENGTH bytes of Data_p contains a
+ * valid header.
+ *
+ * @param [in] Data_p Pointer to the header candidate.
+ *
+ * @retval TRUE If header is valid.
+ * @retval FALSE If header is not valid.
+ */
+boolean Protrom_IsValidHeader(const void *Data_p)
+{
+ uint8 *Temp_p = (uint8 *)Data_p;
+
+ if (PROTROM_HEADER_PATTERN != *Temp_p) {
+ return FALSE;
+ }
+
+ if (PROTO_PROTROM != *(Temp_p + 1)) {
+ return FALSE;
+ }
+
+ if (PROTROM_SOURCE_ADDRESS != *(Temp_p + 2)) {
+ return FALSE;
+ }
+
+ if (PROTROM_DESTINATION_ADDRESS != *(Temp_p + 3)) {
+ return FALSE;
+ }
+
+ if (PROTROM_RESERVED_FIELD != *(Temp_p + 4)) {
+ return FALSE;
+ }
+
+ if (*(uint16 *)(Temp_p + 5) < 1) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Checks if new header is received.
+ *
+ * @param [in] In_p Pointer to the structure with receiver information.
+ *
+ * @retval TRUE If header is received.
+ * @retval FALSE If header is not received.
+ */
+boolean Protrom_IsReceivedHeader(Protrom_Inbound_t *In_p)
+{
+ uint32 StartHeaderInBuffer = 0;
+ uint8 *TmpPointer_p = NULL;
+ uint8 Res = 0;
+
+ Res = Protrom_FindHeaderPattern(In_p->Scratch, &StartHeaderInBuffer);
+
+ if (PROTROM_HEADER_PATTERN_CANDIDATE == Res) {
+ /* call for receiving the rest bytes in header */
+ In_p->ReqData = StartHeaderInBuffer + PROTROM_HEADER_LENGTH - In_p->RecData;
+ TmpPointer_p = (uint8 *)((uint32)In_p->Target_p + StartHeaderInBuffer);
+ memcpy(In_p->Target_p, (uint8 *)TmpPointer_p, In_p->RecData - StartHeaderInBuffer);
+ In_p->ReqBuffOffset = In_p->RecData - StartHeaderInBuffer;
+ } else {
+ if (PROTROM_HEADER_PATTERN_MATCH == Res) {
+ /* Check start point of header in received data */
+ if (StartHeaderInBuffer == 0) {
+ return TRUE;
+ } else {
+ In_p->ReqData = StartHeaderInBuffer + PROTROM_HEADER_LENGTH - In_p->RecData;
+ TmpPointer_p = (uint8 *)((uint32)In_p->Target_p + StartHeaderInBuffer);
+ memcpy(In_p->Target_p, (uint8 *)TmpPointer_p, In_p->RecData - StartHeaderInBuffer);
+ In_p->ReqBuffOffset = In_p->RecData - StartHeaderInBuffer;
+ }
+ } else {
+ In_p->ReqData = PROTROM_HEADER_LENGTH;
+ In_p->ReqBuffOffset = 0;
+ }
+ }
+
+ return FALSE;
+}
+
+/*
+ * Find header pattern in the received data.
+ *
+ * @param [in] HeaderData_p Pointer to the structure with receiver data.
+ * @param [out] StartInBuffer_p Offset in the buffer where is find header.
+ *
+ * @retval TRUE If header is received.
+ * @retval FALSE If header is not received.
+ */
+static uint8 Protrom_FindHeaderPattern(const uint8 *const HeaderData_p, uint32 *StartInBuffer_p)
+{
+ uint8 Res = NO_PROTROM_HEADER_PATTERN;
+ uint32 Offset = 0;
+
+ do {
+ Res = NO_PROTROM_HEADER_PATTERN;
+
+ if (*((uint8 *)HeaderData_p + Offset) == PROTROM_HEADER_PATTERN) {
+ Res = PROTROM_HEADER_PATTERN_CANDIDATE;
+
+ if (Offset < 6) {
+ if (*((uint8 *)HeaderData_p + Offset + 1) == PROTO_PROTROM) {
+ if (Offset < 5) {
+ if (*((uint8 *)HeaderData_p + Offset + 2) == PROTROM_SOURCE_ADDRESS) {
+ if (Offset < 4) {
+ if (*((uint8 *)HeaderData_p + Offset + 3) == PROTROM_DESTINATION_ADDRESS) {
+ Res = PROTROM_HEADER_PATTERN_MATCH;
+ break;
+ } else {
+ Offset = Offset + 2;
+ Res = NO_PROTROM_HEADER_PATTERN;
+ }
+ } else {
+ Res = PROTROM_HEADER_PATTERN_CANDIDATE;
+ break;
+ }
+ } else {
+ Offset ++;
+ Res = NO_PROTROM_HEADER_PATTERN;
+ }
+ } else {
+ Res = PROTROM_HEADER_PATTERN_CANDIDATE;
+ break;
+ }
+ } else {
+ Res = NO_PROTROM_HEADER_PATTERN;
+ }
+ } else {
+ Res = PROTROM_HEADER_PATTERN_CANDIDATE;
+ break;
+ }
+ }
+
+ Offset++;
+ } while (Offset < PROTROM_HEADER_LENGTH);
+
+ *StartInBuffer_p = Offset;
+
+ return Res;
+}
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_network.c b/lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_network.c
new file mode 100644
index 0000000..cce7a65
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_network.c
@@ -0,0 +1,380 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup protrom_family
+ * @{
+ * @addtogroup ldr_network_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <stdlib.h>
+#include <string.h>
+#include "c_system.h"
+#include "t_basicdefinitions.h"
+#include "r_protrom_family.h"
+#include "r_protrom_transport.h"
+#include "r_protrom_network.h"
+#include "r_protrom_protocol.h"
+#include "r_protrom_header.h"
+#include "r_communication_service.h"
+#include "r_debug.h"
+#include "r_debug_macro.h"
+
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+static ErrorCode_e Protrom_Network_ReceiveHeader(Communication_t *Communication_p);
+static ErrorCode_e Protrom_Network_ReceivePayload(Communication_t *Communication_p);
+static ErrorCode_e Protrom_Network_TransmiterHandler(Communication_t *Communication_p);
+static void Protrom_InHashCallback(void *Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p);
+static void Protrom_QueueCallback(const void *const Queue_p, void *Param_p);
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+#define PROTROM_RESET_INBOUND(c, s) do { (c)->ReqData = 0; (c)->RecData = 0; (c)->ReqBuffOffset = 0; (c)->Target_p = NULL; (c)->State = (s); } while(0);
+#define PROTROM_SYNC_HEADER(c, d, t) do { (c)->ReqData = (d); (c)->Target_p = (t); } while(0);
+#define PROTROM_SET_INBOUND(c, s, d) do { (c)->ReqData = (d); (c)->RecData = 0; (c)->ReqBuffOffset = 0; (c)->State = (s); } while(0);
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+/*
+ * Initializes the PROTOROM network layer.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_INIT_COM_DEVICE Failed to initialize the communication
+ * device.
+ */
+ErrorCode_e Protrom_Network_Initialize(Communication_t *Communication_p)
+{
+ memset(PROTROM_NETWORK(Communication_p), 0, sizeof(Protrom_NetworkContext_t));
+
+ /* Simulate a finished read to get the inbound state-machine going. */
+ Protrom_Network_ReadCallback(NULL, 0, Communication_p);
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, QUEUE_NONEMPTY, Protrom_QueueCallback, Communication_p);
+
+ return E_SUCCESS;
+}
+
+/*
+ * Shutdown the PROTROM network layer.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Protrom_Network_Shutdown(const Communication_t *const Communication_p)
+{
+ Protrom_Inbound_t *In_p = &(PROTROM_NETWORK(Communication_p)->Inbound);
+
+ if (NULL != In_p->Packet_p) {
+ if (NULL != In_p->Packet_p->Buffer_p) {
+ free(In_p->Packet_p->Buffer_p);
+ }
+
+ free(In_p->Packet_p);
+ In_p->Packet_p = NULL;
+ }
+
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, QUEUE_NONEMPTY, NULL, NULL);
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, QUEUE_EMPTY, NULL, NULL);
+
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p, QUEUE_NONEMPTY, NULL, NULL);
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p, QUEUE_EMPTY, NULL, NULL);
+
+ return E_SUCCESS;
+}
+
+/*
+ * This callback function handles the received packets.
+ *
+ * @param [in] Data_p Pointer to the received data.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Extra parameteres.
+ *
+ * @return none.
+ */
+void Protrom_Network_ReadCallback(const void *Data_p, const uint32 Length, void *Param_p)
+{
+ Communication_t *Communication_p = (Communication_t *)Param_p;
+
+ A_(printf("protrom_family.c (%d) RecLength(%d) RecBackupData (%d)\n", __LINE__, Length, PROTROM_NETWORK(Communication_p)->Inbound.RecBackupData);)
+ PROTROM_NETWORK(Communication_p)->Inbound.RecData = Length + PROTROM_NETWORK(Communication_p)->Inbound.RecBackupData;
+ PROTROM_NETWORK(Communication_p)->Inbound.RecBackupData = 0;
+
+ if (PROTROM_NETWORK(Communication_p)->Inbound.ReqData == 0) {
+ ErrorCode_e ReturnValue = E_GENERAL_COMMUNICATION_ERROR;
+
+ if (PROTROM_NETWORK(Communication_p)->Inbound.StopTransfer) {
+ if (PROTROM_NETWORK(Communication_p)->Inbound.PacketsBeforeReceiverStop){
+ PROTROM_NETWORK(Communication_p)->Inbound.PacketsBeforeReceiverStop--;
+ }
+ else {
+ PROTROM_NETWORK(Communication_p)->Inbound.State = PROTROM_RECEIVE_IDLE;
+ }
+ }
+
+ switch (PROTROM_NETWORK(Communication_p)->Inbound.State) {
+
+ case PROTROM_RECEIVE_IDLE:
+ ReturnValue = E_SUCCESS;
+ break;
+
+ case PROTROM_RECEIVE_HEADER:
+ ReturnValue = Protrom_Network_ReceiveHeader(Communication_p);
+ break;
+
+ case PROTROM_RECEIVE_PAYLOAD:
+ ReturnValue = Protrom_Network_ReceivePayload(Communication_p);
+ break;
+
+ default:
+ PROTROM_NETWORK(Communication_p)->Inbound.State = PROTROM_RECEIVE_HEADER;
+ PROTROM_NETWORK(Communication_p)->Inbound.RecData = 0;
+ PROTROM_NETWORK(Communication_p)->Inbound.ReqData = PROTROM_HEADER_LENGTH;
+ PROTROM_NETWORK(Communication_p)->Inbound.Target_p = PROTROM_NETWORK(Communication_p)->Inbound.Scratch;
+ return;
+ }
+
+ if (E_SUCCESS != ReturnValue) {
+ PROTROM_NETWORK(Communication_p)->Inbound.State = PROTROM_RECEIVE_ERROR;
+ return;
+ }
+ }
+}
+
+/*
+ * This function checks if new data has been received.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @return none.
+ */
+void Protrom_Network_ReceiverHandler(Communication_t *Communication_p)
+{
+ uint32 ReqData;
+ Protrom_Inbound_t *In_p = &(PROTROM_NETWORK(Communication_p)->Inbound);
+
+ /* new data for receiving ? */
+ if (In_p->ReqData > 0) {
+ if (Communication_p->BackupCommBufferSize != 0) {
+ if (Communication_p->BackupCommBufferSize < In_p->ReqData) {
+ memcpy(In_p->Target_p + In_p->ReqBuffOffset, Communication_p->BackupCommBuffer_p, Communication_p->BackupCommBufferSize);
+ In_p->RecBackupData = Communication_p->BackupCommBufferSize;
+ (void)Communication_p->CommunicationDevice_p->Read(In_p->Target_p + In_p->ReqBuffOffset + Communication_p->BackupCommBufferSize,
+ In_p->ReqData - Communication_p->BackupCommBufferSize,
+ Protrom_Network_ReadCallback, Communication_p);
+ C_(printf("protrom_network.c (%d) ReqData(%d) RecData(%d)\n", __LINE__, In_p->ReqData, In_p->RecData);)
+ C_(printf("protrom_network.c (%d) Communication_p->BackupCommBufferSize(%d) RecBackupData (%d)\n", __LINE__, Communication_p->BackupCommBufferSize, In_p->RecBackupData);)
+ In_p->RecData = 0;
+ In_p->ReqBuffOffset = 0;
+ Communication_p->BackupCommBufferSize = 0;
+ In_p->ReqData = 0;
+ } else {
+ memcpy(In_p->Target_p + In_p->ReqBuffOffset, Communication_p->BackupCommBuffer_p, In_p->ReqData);
+ Communication_p->BackupCommBufferSize = Communication_p->BackupCommBufferSize - In_p->ReqData;
+ ReqData = In_p->ReqData;
+ In_p->ReqData = 0;
+ Protrom_Network_ReadCallback(In_p->Target_p + In_p->ReqBuffOffset, ReqData, Communication_p);
+ In_p->RecData = 0;
+ }
+ } else {
+ ReqData = In_p->ReqData;
+ In_p->ReqData = 0;
+ In_p->RecData = 0;
+ (void)Communication_p->CommunicationDevice_p->Read(In_p->Target_p + In_p->ReqBuffOffset, ReqData, Protrom_Network_ReadCallback, Communication_p);
+ C_(printf("protrom_network.c (%d) ReqData(%d) RecData(%d) \n", __LINE__, In_p->ReqData, In_p->RecData);)
+ C_(printf("protrom_network.c (%d) Communication_p->BackupCommBufferSize(%d) RecBackupData (%d)\n", __LINE__, Communication_p->BackupCommBufferSize, In_p->RecBackupData);)
+ In_p->ReqBuffOffset = 0;
+ }
+ }
+
+ /* check for receiver sinhronization */
+ if (In_p->State == PROTROM_RECEIVE_ERROR) {
+ In_p->ReqData = 0;
+ In_p->RecData = 0;
+ In_p->ReqBuffOffset = 0;
+ (void)Communication_p->CommunicationDevice_p->Read(In_p->Target_p, PROTROM_HEADER_LENGTH, Protrom_Network_ReadCallback, Communication_p);
+ In_p->State = PROTROM_RECEIVE_HEADER;
+ }
+}
+
+/*
+ * Handler function that is called after successful transmission
+ * of a packet.
+ *
+ * If new packet is ready for transmitting it starts
+ * the transmission of the packet.
+ *
+ * @param [in] Data_p Pointer to the data for transmitting.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Extra parameters.
+ *
+ * @return none.
+ */
+void Protrom_Network_WriteCallback(const void *Data_p, const uint32 Length, void *Param_p)
+{
+ Communication_t *Communication_p = (Communication_t *)Param_p;
+ Protrom_Outbound_t *Out_p = &(PROTROM_NETWORK(Communication_p)->Outbound);
+
+ if (NULL != Out_p->Packet_p) {
+ if (NULL != Out_p->Packet_p->Buffer_p) {
+ free(Out_p->Packet_p->Buffer_p);
+ }
+
+ free(Out_p->Packet_p);
+ Out_p->Packet_p = NULL;
+ }
+
+ Out_p->State = PROTROM_SEND_IDLE;
+
+ /* check for more stuff to send. */
+ (void)Protrom_Network_TransmiterHandler(Communication_p);
+}
+
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+
+static ErrorCode_e Protrom_Network_ReceiveHeader(Communication_t *Communication_p)
+{
+ Protrom_Inbound_t *In_p = &(PROTROM_NETWORK(Communication_p)->Inbound);
+
+ if (In_p->RecData == 0) {
+ In_p->ReqData = PROTROM_HEADER_LENGTH;
+ In_p->Target_p = In_p->Scratch;
+ In_p->ReqBuffOffset = 0;
+ } else {
+ if (Protrom_IsReceivedHeader(In_p)) {
+ if (Protrom_IsValidHeader(In_p->Scratch)) {
+ In_p->Packet_p = (Protrom_Packet_t *)malloc(sizeof(Protrom_Packet_t));
+
+ if (NULL == In_p->Packet_p) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ In_p->Packet_p->Communication_p = Communication_p;
+ Protrom_DeserializeHeader(&In_p->Packet_p->Header, In_p->Scratch);
+ In_p->Packet_p->Buffer_p = (uint8 *)malloc(In_p->Packet_p->Header.PayloadLength + PROTROM_HEADER_LENGTH + PROTROM_CRC_LENGTH);
+
+ if (NULL == In_p->Packet_p->Buffer_p) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ In_p->Target_p = In_p->Packet_p->Buffer_p;
+ memcpy(In_p->Target_p, In_p->Scratch, PROTROM_HEADER_LENGTH);
+ In_p->Target_p += PROTROM_HEADER_LENGTH;
+ PROTROM_SET_INBOUND(In_p, PROTROM_RECEIVE_PAYLOAD, In_p->Packet_p->Header.PayloadLength + PROTROM_CRC_LENGTH);
+ } else {
+ /* Sync the header. */
+ PROTROM_RESET_INBOUND(In_p, PROTROM_RECEIVE_HEADER);
+ PROTROM_SYNC_HEADER(In_p, PROTROM_HEADER_LENGTH, In_p->Scratch);
+ }
+ }
+ }
+
+ return E_SUCCESS;
+}
+
+
+static ErrorCode_e Protrom_Network_ReceivePayload(Communication_t *Communication_p)
+{
+ Protrom_Inbound_t *In_p = &(PROTROM_NETWORK(Communication_p)->Inbound);
+ Protrom_Packet_t *Packet_p = In_p->Packet_p;
+
+ Packet_p->Communication_p = Communication_p;
+ Communication_p->HashDevice_p->Calculate(OBJECT_HASH(Communication_p),
+ Communication_p->CurrentFamilyHash, Packet_p->Buffer_p,
+ Packet_p->Header.PayloadLength + PROTROM_HEADER_LENGTH,
+ (uint8 *)&Packet_p->CRC, (HashCallback_t)Protrom_InHashCallback,
+ (void *)Packet_p);
+
+ In_p->Packet_p = NULL;
+ PROTROM_RESET_INBOUND(In_p, PROTROM_RECEIVE_HEADER);
+ PROTROM_SYNC_HEADER(In_p, PROTROM_HEADER_LENGTH, In_p->Scratch);
+ return E_SUCCESS;
+}
+
+
+static ErrorCode_e Protrom_Network_TransmiterHandler(Communication_t *Communication_p)
+{
+ Protrom_Outbound_t *Out_p = &(PROTROM_NETWORK(Communication_p)->Outbound);
+
+ if (Out_p->InLoad) {
+ return E_SUCCESS;
+ }
+
+ Out_p->InLoad = TRUE;
+
+ switch (Out_p->State) {
+ case PROTROM_SEND_IDLE:
+ Out_p->Packet_p = (Protrom_Packet_t *)QUEUE(Communication_p, FifoDequeue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p);
+
+ if (NULL != Out_p->Packet_p) {
+ /* get next packet for transmiting */
+ Out_p->State = PROTROM_SEND_PACKET;
+ } else {
+ break;
+ }
+
+ /* FALLTHROUGH */
+
+ case PROTROM_SEND_PACKET:
+ Out_p->State = PROTROM_SENDING_PACKET;
+
+ if (E_SUCCESS != Communication_p->CommunicationDevice_p->Write(Out_p->Packet_p->Buffer_p,
+ PROTROM_HEADER_LENGTH + Out_p->Packet_p->Header.PayloadLength + PROTROM_CRC_LENGTH,
+ Protrom_Network_WriteCallback, Communication_p)) {
+ Out_p->State = PROTROM_SEND_PACKET;
+ break;
+ }
+
+ /* FALLTHROUGH */
+
+ case PROTROM_SENDING_PACKET:
+ break;
+
+ }
+
+ Out_p->InLoad = FALSE;
+
+ return E_SUCCESS;
+}
+
+static void Protrom_QueueCallback(const void *const Queue_p, void *Param_p)
+{
+ (void)Protrom_Network_TransmiterHandler((Communication_t *)Param_p);
+}
+
+static void Protrom_InHashCallback(void *Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p)
+{
+ Protrom_Packet_t *Packet_p = (Protrom_Packet_t *)Param_p;
+
+ if (memcmp(Hash_p, Packet_p->Buffer_p + PROTROM_HEADER_LENGTH + Packet_p->Header.PayloadLength, sizeof(uint16)) == 0) {
+ (void)QUEUE(Packet_p->Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Inbound_p, Packet_p);
+ } else {
+ /* Invalid packet */
+ free(Packet_p->Buffer_p);
+ free(Packet_p);
+ }
+}
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/source/r15_header.c b/lcmodule/source/cnh1605205_ldr_network_layer/source/r15_header.c
new file mode 100644
index 0000000..8058506
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/source/r15_header.c
@@ -0,0 +1,325 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup ldr_header
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "c_system.h"
+#include <string.h>
+#include "t_basicdefinitions.h"
+#include "r_r15_header.h"
+#include "r_serialization.h"
+#include "t_bulk_protocol.h"
+#include "t_r15_network_layer.h"
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+static uint8 memxor(const uint8 *Buf_p, uint32 Length);
+static uint8 R15_FindHeaderPattern(R15_Inbound_t *In_p, uint32 *StartInBuffer_p);
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+
+/*
+ * Deserialize the header stored in network format to a structure.
+ *
+ * @param [out] Header_p Pointer to the header structure where the
+ * header data should be placed.
+ * @param [in] Data_p Pointer to the buffer with received header.
+ *
+ * @return none.
+ */
+void R15_DeserializeHeader(R15_Header_t *Header_p, void *Data_p)
+{
+ void *Iter_p = Data_p;
+
+ Header_p->HeaderPattern = get_uint8(&Iter_p);
+ Header_p->Protocol = get_uint8(&Iter_p);
+ Header_p->HeaderPatternExtension = get_uint16(&Iter_p);
+ Header_p->Flags = get_uint8(&Iter_p);
+ Header_p->ExtendedHeaderLength = get_uint8(&Iter_p);
+ Header_p->ExtendedHeaderChecksum = get_uint8(&Iter_p);
+ Header_p->PayloadLength = get_uint32_le(&Iter_p);
+ Header_p->PayloadChecksum = get_uint32_le(&Iter_p);
+ Header_p->HeaderChecksum = get_uint8(&Iter_p);
+}
+
+/**
+ * Deserialize the extended header stored in network format to a structure.
+ *
+ * @param [out] Header_p Pointer to the extended header structure where the
+ * header data should be placed.
+ * @param [in] Data_p Pointer to the buffer with received header.
+ *
+ * @return none.
+ */
+void R15_DeserializeBulkExtendedHeader(BulkExtendedHeader_t *ExtendedHeader_p, void *Data_p)
+{
+ void *Iter_p = Data_p;
+
+ ExtendedHeader_p->Session = get_uint16_le(&Iter_p);
+ ExtendedHeader_p->TypeFlags = get_uint8(&Iter_p);
+ ExtendedHeader_p->AcksChunk = get_uint8(&Iter_p);
+ ExtendedHeader_p->ChunkSize = get_uint32_le(&Iter_p);
+ ExtendedHeader_p->Offset = get_uint64_le(&Iter_p);
+ ExtendedHeader_p->Length = get_uint32_le(&Iter_p);
+}
+
+/*
+ * Serialize the header structure to network format.
+ *
+ * The data buffer must be of at least size HEADER_LENGTH.
+ *
+ * @param [out] Data_p Pointer to the buffer where the
+ * serialized header should be placed.
+ * @param [in] Header_p Pointer to the source header structure.
+ *
+ * @return none.
+ */
+void R15_SerializeHeader(void *Data_p, const R15_Header_t *header_p)
+{
+ void *Iter_p = Data_p;
+
+ put_uint8(&Iter_p, HEADER_PATTERN);
+ put_uint8(&Iter_p, header_p->Protocol);
+ put_uint8(&Iter_p, HEADER_PATTERN_EXTENSION);
+ put_uint8(&Iter_p, HEADER_PATTERN_EXTENSION);
+ put_uint8(&Iter_p, header_p->Flags);
+
+ put_uint8(&Iter_p, header_p->ExtendedHeaderLength);
+ put_uint8(&Iter_p, header_p->ExtendedHeaderChecksum);
+
+ put_uint32_le(&Iter_p, header_p->PayloadLength);
+ put_uint32_le(&Iter_p, header_p->PayloadChecksum);
+
+ put_uint8(&Iter_p, memxor((uint8 *)Data_p, HEADER_LENGTH - 1));
+}
+
+
+/*
+ * Converts the extended header structure to network format.
+ *
+ * @param [out] Data_p Pointer to the buffer where the
+ * serialized header should be placed.
+ * @param [in] ProtocolType The type of the protocol used for
+ * communication.
+ * @param [in] ExtHeader_p Pointer to the source header structure.
+ * @param [out] ExtHdrChecksum_p Calculated checksum for extended header data.
+ *
+ * @return none.
+ */
+void R15_SerializeExtendedHeader(void *Data_p, uint8 ProtocolType, const void *ExtHeader_p, uint8 *ExtHdrChecksum_p)
+{
+ void *Iter_p = Data_p;
+
+ if (COMMAND_PROTOCOL == ProtocolType) {
+ put_uint16_le(&Iter_p, ((CommandExtendedHeader_t *)ExtHeader_p)->SessionState);
+ put_uint8(&Iter_p, ((CommandExtendedHeader_t *)ExtHeader_p)->Command);
+ put_uint8(&Iter_p, ((CommandExtendedHeader_t *)ExtHeader_p)->CommandGroup);
+ *ExtHdrChecksum_p = memxor((uint8 *)ExtHeader_p, COMMAND_EXTENDED_HEADER_LENGTH);
+ } else {
+ put_uint16_le(&Iter_p, ((BulkExtendedHeader_t *)ExtHeader_p)->Session);
+ put_uint8(&Iter_p, ((BulkExtendedHeader_t *)ExtHeader_p)->TypeFlags);
+ put_uint8(&Iter_p, ((BulkExtendedHeader_t *)ExtHeader_p)->AcksChunk);
+ put_uint32_le(&Iter_p, ((BulkExtendedHeader_t *)ExtHeader_p)->ChunkSize);
+ put_uint64_le(&Iter_p, ((BulkExtendedHeader_t *)ExtHeader_p)->Offset);
+ put_uint32_le(&Iter_p, ((BulkExtendedHeader_t *)ExtHeader_p)->Length);
+ *ExtHdrChecksum_p = memxor((uint8 *)ExtHeader_p, BULK_EXTENDED_HEADER_LENGTH);
+ }
+}
+
+/**
+ * Deserialize the command extended header stored in network format to a structure.
+ *
+ * @param [out] CommandExtendedHeader_p Pointer to the command extended header structure where the
+ * header data should be placed.
+ * @param [in] Data_p Pointer to the buffer with received header.
+ *
+ * @return none.
+ */
+void R15_DeserializeCommandExtendedHeader(CommandExtendedHeader_t *CommandExtendedHeader_p, void *Data_p)
+{
+ void *Iter_p = Data_p;
+
+ CommandExtendedHeader_p->SessionState = get_uint16_le(&Iter_p);
+ CommandExtendedHeader_p->Command = get_uint8(&Iter_p);
+ CommandExtendedHeader_p->CommandGroup = get_uint8(&Iter_p);
+}
+
+/*
+ * Get packet length in bytes given the information in Header_p.
+ *
+ * @param [in] Header_p Pointer to the header structure.
+ *
+ * @return The length of the packet in bytes.
+ */
+uint32 R15_GetPacketLength(const R15_Header_t *Header_p)
+{
+ return HEADER_LENGTH + Header_p->ExtendedHeaderLength +
+ Header_p->PayloadLength;
+}
+
+/*
+ * Determines whether the first HEADER_LENGTH bytes of Data_p contains a
+ * valid header.
+ *
+ * @param [in] Data_p Pointer to the header candidate.
+ *
+ * @retval TRUE If header is valid.
+ * @retval FALSE If header is not valid.
+ */
+boolean R15_IsValidHeader(const void *Data_p)
+{
+ if (memxor((uint8 *)Data_p, HEADER_LENGTH) == 0) {
+ /** @todo It's possible to check other things here */
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*
+ * Checks if new header is received.
+ *
+ * @param [in] In_p Pointer to the structure with receiver information.
+ *
+ * @retval TRUE If header is received.
+ * @retval FALSE If header is not received.
+ */
+boolean R15_IsReceivedHeader(R15_Inbound_t *In_p)
+{
+ uint32 StartHeaderInBuffer = 0;
+ uint8 *TmpPointer_p = NULL;
+ uint8 Res = 0;
+
+ Res = R15_FindHeaderPattern(In_p, &StartHeaderInBuffer);
+
+ if (HEADER_PATTERN_CANDIDATE == Res) {
+ /* call for receiving the rest bytes in header */
+ In_p->ReqData = StartHeaderInBuffer + ALIGNED_HEADER_LENGTH - In_p->RecData;
+ TmpPointer_p = (uint8 *)((uint32)In_p->Target_p + StartHeaderInBuffer);
+ memcpy(In_p->Target_p, (uint8 *)TmpPointer_p, In_p->RecData - StartHeaderInBuffer);
+ In_p->ReqBuffOffset = In_p->RecData - StartHeaderInBuffer;
+ } else {
+ if (HEADER_PATTERN_MATCH == Res) {
+ /* Check start point of header in received data */
+ if (StartHeaderInBuffer == 0) {
+ return TRUE;
+ } else {
+ In_p->ReqData = StartHeaderInBuffer + ALIGNED_HEADER_LENGTH - In_p->RecData;
+ TmpPointer_p = (uint8 *)((uint32)In_p->Target_p + StartHeaderInBuffer);
+ memcpy(In_p->Target_p, (uint8 *)TmpPointer_p, In_p->RecData - StartHeaderInBuffer);
+ In_p->ReqBuffOffset = In_p->RecData - StartHeaderInBuffer;
+ }
+ } else {
+ In_p->ReqData = ALIGNED_HEADER_LENGTH;
+ In_p->ReqBuffOffset = 0;
+ }
+ }
+
+ return FALSE;
+}
+
+
+/*
+ * Verify received extended header.
+ *
+ * @param [in] Data_p Pointer to the buffer.
+ * @param [in] Length Length of the buffer.
+ * @param [in] Checksum Checksum of the buffer.
+ *
+ * @retval TRUE If is extended header verified.
+ * @retval FALSE If extended header is not verified.
+ */
+boolean R15_IsValidExtendedHeader(const void *Data_p, const uint8 Length, const uint8 Checksum)
+{
+ if (memxor((uint8 *)Data_p, Length) == Checksum) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+static uint8 R15_FindHeaderPattern(R15_Inbound_t *In_p, uint32 *StartInBuffer_p)
+{
+ uint8 Res = NO_HEADER_PATTERN;
+ uint32 Offset = 0;
+ uint8 *HeaderData_p = In_p->Scratch;
+
+ do {
+ Res = NO_HEADER_PATTERN;
+
+ if (*((uint8 *)HeaderData_p + Offset) == HEADER_PATTERN) {
+ Res = HEADER_PATTERN_CANDIDATE;
+
+ if (Offset < In_p->RecData - 1) {
+ if ((*((uint8 *)HeaderData_p + Offset + 1) == PROTO_COMMAND) || (*((uint8 *)HeaderData_p + Offset + 1) == PROTO_BULK)) {
+ if (Offset < In_p->RecData - 2) {
+ if (*((uint8 *)HeaderData_p + Offset + 2) == HEADER_PATTERN_EXTENSION) {
+ if (Offset < In_p->RecData - 3) {
+ if (*((uint8 *)HeaderData_p + Offset + 3) == HEADER_PATTERN_EXTENSION) {
+ Res = HEADER_PATTERN_MATCH;
+ break;
+ } else {
+ Offset = Offset + 2;
+ Res = NO_HEADER_PATTERN;
+ }
+ } else {
+ Res = HEADER_PATTERN_CANDIDATE;
+ break;
+ }
+ } else {
+ Offset ++;
+ Res = NO_HEADER_PATTERN;
+ }
+ } else {
+ Res = HEADER_PATTERN_CANDIDATE;
+ break;
+ }
+ } else {
+ Res = NO_HEADER_PATTERN;
+ }
+ } else {
+ Res = HEADER_PATTERN_CANDIDATE;
+ break;
+ }
+ }
+
+ Offset++;
+ } while (Offset < In_p->RecData);
+
+ *StartInBuffer_p = Offset;
+
+ return Res;
+}
+
+
+static uint8 memxor(const uint8 *Buf_p, uint32 Length)
+{
+ uint8 Value = 0;
+ const uint8 *Stop_p = Buf_p + Length;
+
+ /** @todo Optimize for 32 bit access? */
+ do {
+ Value ^= *Buf_p++;
+ } while (Buf_p < Stop_p);
+
+ return Value;
+}
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/source/r15_network_layer.c b/lcmodule/source/cnh1605205_ldr_network_layer/source/r15_network_layer.c
new file mode 100644
index 0000000..3b3a2fc
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/source/r15_network_layer.c
@@ -0,0 +1,931 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup r15_family
+ * @{
+ * @addtogroup ldr_network_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "r_r15_network_layer.h"
+#include "r_basicdefinitions.h"
+#include <stdlib.h>
+#include "r_debug.h"
+#include "r_debug_macro.h"
+#include <string.h>
+#include "c_system.h"
+#include "r_r15_transport_layer.h"
+#include "r_r15_family.h"
+#include "r_communication_service.h"
+#include "r_r15_header.h"
+#include "r_bulk_protocol.h"
+#include "r_command_protocol.h"
+
+#ifdef CFG_ENABLE_MEASUREMENT_TOOL
+#include "r_measurement_tool.h"
+#include "r_time_utilities.h"
+#endif
+
+#define FREE_TRANSMITER 0
+#define BUSY_TRANSMITER 1
+
+#ifdef CFG_ENABLE_MEASUREMENT_TOOL
+extern Measurement_t *Measurement_p;
+#endif
+
+static PacketMeta_t PacketMetaInfo[COMMAND_BUFFER_COUNT + BULK_BUFFER_COUNT] = {0}; /* Packet Meta Info vector*/
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+static ErrorCode_e R15_Network_ReceiveHeader(const Communication_t *const Communication_p);
+static ErrorCode_e R15_Network_ReceiveExtendedHeader(Communication_t *Communication_p);
+static ErrorCode_e R15_Network_ReceivePayload(Communication_t *Communication_p);
+static ErrorCode_e R15_Network_RegisterRetransmission(Communication_t *Communication_p, PacketMeta_t *Packet_p);
+static void R15_Network_RetransmissionCallback(Communication_t *Communication_p, const void *const Timer_p, void *Data_p);
+static void R15_InHashCallback(const void *const Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p);
+#ifdef CFG_ENABLE_LOADER_TYPE
+static void R15_QueueOutCallback(const void *const Queue_p, void *Param_p);
+static void R15_QueueInCallback(const void *const Queue_p, void *Param_p);
+#endif
+static PacketMeta_t *R15_Network_GetAvailableMetaPacket(void);
+
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+
+#define RESET_INBOUND(c, s) do { (c)->ReqData = 0; (c)->RecData = 0; (c)->ReqBuffOffset = 0; (c)->Target_p = NULL; (c)->State = (s); } while(0);
+#define SYNC_HEADER(c, d, t) do { (c)->ReqData = d; (c)->Target_p = t; } while(0);
+#define SET_INBOUND(c, s, d) do { (c)->ReqData = d; (c)->RecData = 0; (c)->ReqBuffOffset = 0; (c)->State = (s); } while(0);
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+/*
+ * Initializes the r15 network layer.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_INIT_COM_DEVICE Fail to initialize the communication
+ * device.
+ */
+ErrorCode_e R15_Network_Initialize(Communication_t *Communication_p)
+{
+ memset(R15_NETWORK(Communication_p), 0, sizeof(R15_NetworkContext_t));
+
+ /* Simulate a finished read to get the inbound state-machine going. */
+ R15_Network_ReadCallback(NULL, 0, Communication_p);
+ R15_NETWORK(Communication_p)->Outbound.InLoad = FALSE;
+#ifdef CFG_ENABLE_LOADER_TYPE
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, QUEUE_NONEMPTY, R15_QueueOutCallback, Communication_p);
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p, QUEUE_NONEMPTY, R15_QueueInCallback, Communication_p);
+#endif
+ R15_NETWORK(Communication_p)->Inbound.LCM_Error = E_SUCCESS;
+ R15_NETWORK(Communication_p)->Outbound.LCM_Error = E_SUCCESS;
+
+ return E_SUCCESS;
+}
+
+/*
+ * Shut down the r15 network layer.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e R15_Network_Shutdown(const Communication_t *const Communication_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, QUEUE_NONEMPTY, NULL, NULL);
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, QUEUE_EMPTY, NULL, NULL);
+
+ /* Wait until the all packets in the queue has released. */
+ while (!QUEUE(Communication_p, Fifo_IsEmpty_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p)) {
+ PacketMeta_t *Packet_p = (PacketMeta_t *)QUEUE(Communication_p, FifoDequeue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p);
+ BulkExtendedHeader_t ExtendedHeader = {0};
+
+ R15_DeserializeBulkExtendedHeader(&ExtendedHeader, Packet_p->ExtendedHeader_p);
+
+ if (Packet_p->Header.Protocol != BULK_PROTOCOL || (ExtendedHeader.TypeFlags & MASK_BULK_COMMAND_SELECT) != CMD_BULK_DATA) {
+ ReturnValue = R15_Network_PacketRelease(Communication_p, Packet_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+ }
+ }
+
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p, QUEUE_NONEMPTY, NULL, NULL);
+ (void)QUEUE(Communication_p, Fifo_SetCallback_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p, QUEUE_EMPTY, NULL, NULL);
+
+ /* Wait until the all packets in the queue has released. */
+ while (!QUEUE(Communication_p, Fifo_IsEmpty_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p)) {
+ ReturnValue = R15_Network_PacketRelease(Communication_p, (PacketMeta_t *)QUEUE(Communication_p, FifoDequeue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p));
+ }
+
+ErrorExit:
+ return ReturnValue;
+}
+
+
+/*
+ * Handler for received packets in R15 protocol family.
+ *
+ * This callback function handles the received packets.
+ *
+ * @param [in] Data_p Pointer to the received data.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Parameters;
+ *
+ * @return none.
+ */
+void R15_Network_ReadCallback(const void *Data_p, const uint32 Length, void *Param_p)
+{
+ Communication_t *Communication_p = (Communication_t *)Param_p;
+
+ C_(printf("r15_network_layer.c (%d) RecLength(%d) RecBackupData (%d)\n", __LINE__, Length, R15_NETWORK(Communication_p)->Inbound.RecBackupData);)
+ R15_NETWORK(Communication_p)->Inbound.RecData = Length + R15_NETWORK(Communication_p)->Inbound.RecBackupData;
+ R15_NETWORK(Communication_p)->Inbound.RecBackupData = 0;
+
+ if (R15_NETWORK(Communication_p)->Inbound.ReqData == 0) {
+ ErrorCode_e ReturnValue = E_GENERAL_COMMUNICATION_ERROR;
+
+ switch (R15_NETWORK(Communication_p)->Inbound.State) {
+ case RECEIVE_HEADER:
+ ReturnValue = R15_Network_ReceiveHeader(Communication_p);
+ break;
+
+ case RECEIVE_EXTENDED_HEADER:
+ ReturnValue = R15_Network_ReceiveExtendedHeader(Communication_p);
+ break;
+
+ case RECEIVE_PAYLOAD:
+ ReturnValue = R15_Network_ReceivePayload(Communication_p);
+ break;
+
+ default:
+ R15_NETWORK(Communication_p)->Inbound.State = RECEIVE_HEADER;
+ R15_NETWORK(Communication_p)->Inbound.RecData = 0;
+ R15_NETWORK(Communication_p)->Inbound.ReqData = ALIGNED_HEADER_LENGTH;
+ R15_NETWORK(Communication_p)->Inbound.Target_p = R15_NETWORK(Communication_p)->Inbound.Scratch;
+ R15_NETWORK(Communication_p)->Inbound.LCM_Error = E_SUCCESS;
+ ReturnValue = E_SUCCESS;
+ break;
+ }
+
+#ifdef CFG_ENABLE_LOADER_TYPE
+ ReturnValue = R15_Network_ReceiverHandler(Communication_p);
+#endif
+
+ if (E_SUCCESS != ReturnValue) {
+ R15_NETWORK(Communication_p)->Inbound.State = RECEIVE_ERROR;
+ }
+
+ R15_NETWORK(Communication_p)->Inbound.LCM_Error = ReturnValue;
+ }
+}
+
+/*
+ * Handler for receiving new data.
+ *
+ * This function checks if new data has been received.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ *
+ * @return none.
+ */
+ErrorCode_e R15_Network_ReceiverHandler(Communication_t *Communication_p)
+{
+ uint32 ReqData;
+ uint32 ReqBuffOffset = 0;
+ R15_Inbound_t *In_p = &(R15_NETWORK(Communication_p)->Inbound);
+
+ /* new data for receiving ? */
+ if (In_p->ReqData > 0) {
+ if (Communication_p->BackupCommBufferSize != 0) {
+ if (Communication_p->BackupCommBufferSize < In_p->ReqData) {
+ memcpy(In_p->Target_p + In_p->ReqBuffOffset, Communication_p->BackupCommBuffer_p, Communication_p->BackupCommBufferSize);
+ In_p->RecBackupData = Communication_p->BackupCommBufferSize;
+ (void)Communication_p->CommunicationDevice_p->Read(In_p->Target_p + In_p->ReqBuffOffset + Communication_p->BackupCommBufferSize,
+ In_p->ReqData - Communication_p->BackupCommBufferSize,
+ R15_Network_ReadCallback, Communication_p);
+ C_(printf("r15_network_layer.c (%d) ReqData(%d) RecData(%d)\n", __LINE__, In_p->ReqData, In_p->RecData);)
+ C_(printf("r15_network_layer.c (%d) Communication_p->BackupCommBufferSize(%d) RecBackupData (%d)\n", __LINE__, Communication_p->BackupCommBufferSize, In_p->RecBackupData);)
+ In_p->RecData = 0;
+ In_p->ReqBuffOffset = 0;
+ Communication_p->BackupCommBufferSize = 0;
+ In_p->ReqData = 0;
+ } else {
+ memcpy(In_p->Target_p + In_p->ReqBuffOffset, Communication_p->BackupCommBuffer_p, In_p->ReqData);
+ Communication_p->BackupCommBufferSize = Communication_p->BackupCommBufferSize - In_p->ReqData;
+ ReqData = In_p->ReqData;
+ In_p->ReqData = 0;
+ R15_Network_ReadCallback(In_p->Target_p + In_p->ReqBuffOffset, ReqData, Communication_p);
+ In_p->RecData = 0;
+ }
+ } else {
+ ReqData = In_p->ReqData;
+ ReqBuffOffset = (uint32)(In_p->ReqBuffOffset);
+ In_p->ReqBuffOffset = 0;
+ In_p->ReqData = 0;
+ (void)Communication_p->CommunicationDevice_p->Read(In_p->Target_p + ReqBuffOffset, ReqData, R15_Network_ReadCallback, Communication_p);
+ C_(printf("r15_network_layer.c (%d) ReqData(%d) RecData(%d) \n", __LINE__, In_p->ReqData, In_p->RecData);)
+ C_(printf("r15_network_layer.c (%d) Communication_p->BackupCommBufferSize(%d) RecBackupData (%d)\n", __LINE__, Communication_p->BackupCommBufferSize, In_p->RecBackupData);)
+ In_p->RecData = 0;
+ }
+ }
+
+ /* check for receiver sinhronization */
+ if (In_p->State == RECEIVE_ERROR) {
+ In_p->ReqData = 0;
+ In_p->RecData = 0;
+ In_p->ReqBuffOffset = 0;
+ In_p->State = RECEIVE_HEADER;
+ (void)Communication_p->CommunicationDevice_p->Read(In_p->Target_p, ALIGNED_HEADER_LENGTH, R15_Network_ReadCallback, Communication_p);
+ }
+
+ return R15_NETWORK(Communication_p)->Inbound.LCM_Error;
+}
+
+ErrorCode_e R15_Network_TransmiterHandler(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ R15_Outbound_t *Out_p = &(R15_NETWORK(Communication_p)->Outbound);
+ uint8 *HeaderStartInBuffer_p = NULL;
+ boolean IsBufferContinuous = FALSE;
+ boolean RegisterRetransmission = FALSE;
+ uint32 ContinuousBufferLength = 0;
+ uint32 ExtHdrLen = 0;
+ uint32 Aligned_Length = 0;
+
+ if (Out_p->InLoad) {
+ return E_SUCCESS;
+ }
+
+ Out_p->InLoad = TRUE;
+
+ switch (Out_p->State) {
+ case SEND_IDLE:
+ /* check retransmission count before send */
+ Out_p->Packet_p = (PacketMeta_t *)QUEUE(Communication_p, FifoDequeue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p);
+
+ if (NULL != Out_p->Packet_p) {
+ if (Out_p->Packet_p->Resend < MAX_RESENDS) {
+ Out_p->Packet_p->Resend++;
+ /* get next packet for transmitting */
+ Out_p->State = SEND_HEADER;
+ } else {
+ //Do_CommunicationInternalErrorHandler(E_RETRANSMITION_FAILED);
+ return E_RETRANSMITION_FAILED;
+ }
+ } else {
+ break;
+ }
+
+ /* FALLTHROUGH */
+ case SEND_HEADER:
+ HeaderStartInBuffer_p = Out_p->Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER;
+
+ if (Out_p->Packet_p->Header.ExtendedHeaderLength == COMMAND_EXTENDED_HEADER_LENGTH) {
+ ExtHdrLen = ALIGNED_COMMAND_EXTENDED_HEADER_LENGTH;
+ } else {
+ ExtHdrLen = ALIGNED_BULK_EXTENDED_HEADER_LENGTH;
+ }
+
+ if ((HeaderStartInBuffer_p + ALIGNED_HEADER_LENGTH + ExtHdrLen) == Out_p->Packet_p->Payload_p) {
+ /* end of the header and beginning of the payload are same */
+ IsBufferContinuous = TRUE;
+ }
+
+ /* set next state before calling the communication device, to avoid race condition
+ where write callback is called before new state is set */
+ if (IsBufferContinuous || Out_p->Packet_p->Header.PayloadLength == 0) {
+ /* we have a packet without payload or header and payload are contained in one
+ continuous buffer so it can be sent with one write request */
+ ContinuousBufferLength = ALIGNED_HEADER_LENGTH + ExtHdrLen + Out_p->Packet_p->Header.PayloadLength;
+ ContinuousBufferLength = (ContinuousBufferLength + (ALIGN_SIZE - 1)) & (~(ALIGN_SIZE - 1));
+
+ Out_p->State = SENDING_PAYLOAD;
+ RegisterRetransmission = TRUE;
+ } else {
+ ContinuousBufferLength = ALIGNED_HEADER_LENGTH + ExtHdrLen;
+ Out_p->State = SENDING_HEADER;
+ }
+
+ if (E_SUCCESS == Communication_p->CommunicationDevice_p->Write((Out_p->Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER),
+ ContinuousBufferLength,
+ R15_Network_WriteCallback, Communication_p)) {
+ C_(printf("r15_network_layer.c (%d) Header Sent to comm device! \n", __LINE__);)
+ } else {
+ Out_p->State = SEND_HEADER;
+ RegisterRetransmission = FALSE;
+ C_(printf("r15_network_layer.c (%d) Error sending header to comm device! \n", __LINE__);)
+ }
+
+ break;
+ case SENDING_HEADER:
+ /* nothing to do, wait until sending is finished and state changed by write callback */
+ break;
+ case SEND_PAYLOAD:
+ Out_p->State = SENDING_PAYLOAD;
+
+ Aligned_Length = (Out_p->Packet_p->Header.PayloadLength + (ALIGN_SIZE - 1)) & (~(ALIGN_SIZE - 1));
+
+ if (E_SUCCESS == Communication_p->CommunicationDevice_p->Write(Out_p->Packet_p->Payload_p,
+ Aligned_Length,
+ R15_Network_WriteCallback, Communication_p)) {
+ RegisterRetransmission = TRUE;
+ C_(printf("r15_network_layer.c (%d) Payload Sent to comm device! \n", __LINE__);)
+ } else {
+ Out_p->State = SEND_PAYLOAD;
+ C_(printf("r15_network_layer.c (%d) Error sending payload to comm device! \n", __LINE__);)
+ }
+
+ break;
+ case SENDING_PAYLOAD:
+ /* nothing to do, wait until sending is finished and state changed by write callback */
+ break;
+ }
+
+ if (RegisterRetransmission) {
+ if (NULL != Out_p->Packet_p->Timer_p) {
+ C_(printf("r15_network_layer.c (%d) Register retransmission\n", __LINE__);)
+ (void)R15_Network_RegisterRetransmission(Communication_p, Out_p->Packet_p);
+ }
+ }
+
+ Out_p->InLoad = FALSE;
+
+ return ReturnValue;
+}
+
+/*
+ * Cancel retransmission of packets.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] UniqueKey Unique key used for identification of packet
+ * for retransmission.
+ *
+ * @return none.
+ */
+ErrorCode_e R15_Network_CancelRetransmission(const Communication_t *const Communication_p, uint32 UniqueKey)
+{
+ ErrorCode_e ReturnValue = E_NOT_FOUND_ELEMENT_IN_RETRANSMISSION_LIST;
+ uint32 Index = 0;
+
+ do {
+ if ((R15_NETWORK(Communication_p)->RetransmissionList[Index] != NULL) && (R15_NETWORK(Communication_p)->RetransmissionList[Index]->Key == UniqueKey)) {
+ (void)TIMER(Communication_p, TimerRelease_Fn)(OBJECT_TIMER(Communication_p), R15_NETWORK(Communication_p)->RetransmissionList[Index]->TimerKey);
+
+ free(R15_NETWORK(Communication_p)->RetransmissionList[Index]->Packet_p->Timer_p);
+ ReturnValue = R15_Network_PacketRelease(Communication_p, R15_NETWORK(Communication_p)->RetransmissionList[Index]->Packet_p);
+
+ if (E_SUCCESS != ReturnValue) {
+ A_(printf("r15_network_layer.c(%d): Packet release failed!\n", __LINE__);)
+ return ReturnValue;
+ }
+
+ free(R15_NETWORK(Communication_p)->RetransmissionList[Index]);
+ R15_NETWORK(Communication_p)->RetransmissionList[Index] = NULL;
+ R15_NETWORK(Communication_p)->RetransmissionListCount--;
+
+ for (; Index < R15_NETWORK(Communication_p)->RetransmissionListCount; Index++) {
+ R15_NETWORK(Communication_p)->RetransmissionList[Index] = R15_NETWORK(Communication_p)->RetransmissionList[Index+1];
+ }
+
+ R15_NETWORK(Communication_p)->RetransmissionList[Index] = NULL;
+ ReturnValue = E_SUCCESS;
+ break;
+ }
+
+ Index++;
+ } while (Index < R15_NETWORK(Communication_p)->RetransmissionListCount);
+
+ return ReturnValue;
+}
+
+/*
+ * Create unique key.
+ *
+ * This function combine the session number and protocol type in one
+ * unique key for command packet. For the bulk packet the unique key is the
+ * combination of protocol type, session number and command.
+ *
+ * @param [in] Packet_p Pointer to the packet.
+ * @param [in] ExternalKey External key for marking the packet for retransmision.
+ *
+ * @return Unique key.
+ */
+uint32 R15_Network_CreateUniqueKey(const PacketMeta_t *const Packet_p, const uint8 ExternalKey)
+{
+ uint32 Key = Packet_p->Header.Protocol;
+
+ if (Key == PROTO_COMMAND) {
+ return((Key << 16) | *(Packet_p->ExtendedHeader_p) & MASK_CLR_STATE);
+ } else {
+ return ((Key << 16) | ((*(Packet_p->ExtendedHeader_p) & 0x00FF) << 8) | ExternalKey);
+ }
+}
+
+
+/*
+ * Network packet allocation in R15 protocol family.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] BufferSize Size of buffer used for network packet.
+ *
+ * @retval Pointer Pointer to allocated packet meta info.
+ * @retval NULL if allocation fail.
+ */
+PacketMeta_t *R15_Network_PacketAllocate(const Communication_t *const Communication_p, int BufferSize)
+{
+ PacketMeta_t *Meta_p = NULL;
+ void *Buffer_p = NULL;
+ int BuffersNr = 0;
+
+ /* Find the first unallocated buffers. */
+ Buffer_p = BUFFER(Communication_p, BufferAllocate_Fn)(OBJECT_BUFFER(Communication_p), BufferSize);
+
+ if (NULL == Buffer_p) {
+ A_(printf("r15_network_layer.c (%d): ** Buffer allocation fail! **\n", __LINE__);)
+ goto ErrorExit;
+ }
+
+ B_(printf("r15_network_layer.c (%d): Buffer allocate (0x%x)! **\n", __LINE__, (uint32)Buffer_p);)
+
+ /* packet meta info allocate, get free packet meta structure */
+
+ Meta_p = R15_Network_GetAvailableMetaPacket();
+
+ if (NULL == Meta_p) {
+ R15_NETWORK(Communication_p)->Inbound.LCM_Error = E_ALLOCATE_FAILED;
+ goto ErrorExit;
+ }
+
+ /* packet meta info setup */
+ C_(
+
+ if (BULK_BUFFER_SIZE > BufferSize)
+ printf("CmdBuffGet:%x\n", Buffer_p);
+ else {
+ printf("ChunkBuffGet:%x\n", Buffer_p);
+ })
+
+ Meta_p->Buffer_p = (uint8 *)Buffer_p;
+ Meta_p->BufferSize = BufferSize;
+ SET_PACKET_FLAGS(Meta_p, PACKET_ALLOCATION_STATE_MASK, BUF_ALLOCATED);
+
+ do {
+ if (NULL == R15_NETWORK(Communication_p)->MetaInfoList[BuffersNr]) {
+ R15_NETWORK(Communication_p)->MetaInfoList[BuffersNr] = Meta_p;
+ break;
+ }
+
+ BuffersNr ++;
+ } while (BuffersNr < (COMMAND_BUFFER_COUNT + BULK_BUFFER_COUNT));
+
+ErrorExit:
+ return Meta_p;
+}
+
+
+/*
+ * Network packet release in R15 protocol family.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] Meta_p Meta info for used network packet.
+ *
+ * @retval E_SUCCESS Successful network packet release.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e R15_Network_PacketRelease(const Communication_t *const Communication_p, PacketMeta_t *Meta_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ int BuffersNr = 0;
+
+ VERIFY(NULL != Meta_p, E_INVALID_INPUT_PARAMETERS);
+
+ /* remove the meta info data from list */
+ do {
+ if (Meta_p == R15_NETWORK(Communication_p)->MetaInfoList[BuffersNr]) {
+ R15_NETWORK(Communication_p)->MetaInfoList[BuffersNr] = NULL;
+ /* release buffer */
+ B_(printf("r15_network_layer.c (%d): Buffer release (0x%x)! **\n", __LINE__, (uint32)(Meta_p->Buffer_p));)
+#ifndef CFG_ENABLE_LOADER_TYPE
+ ReturnValue = BUFFER(Communication_p, BufferRelease_Fn)(OBJECT_BUFFER(Communication_p), Meta_p->Buffer_p, Meta_p->BufferSize);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+ B_(printf("r15_network_layer.c (%d): Buffer released! **\n", __LINE__);)
+#else
+ C_(
+
+ if (BULK_BUFFER_SIZE > Meta_p->BufferSize)
+ printf("CmdBuffRel:%x\n", Meta_p->Buffer_p);
+ else {
+ printf("ChunkBuffRel:%x\n", Meta_p->Buffer_p);
+ })
+ ReturnValue = BUFFER(Communication_p, BufferRelease_Fn)(OBJECT_BUFFER(Communication_p), Meta_p->Buffer_p, Meta_p->BufferSize);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+ B_(printf("r15_network_layer.c (%d): Buffer released! **\n", __LINE__);)
+#endif
+
+ memset(Meta_p, 0, sizeof(PacketMeta_t));
+ break;
+ }
+
+ BuffersNr ++;
+ } while (BuffersNr < (COMMAND_BUFFER_COUNT + BULK_BUFFER_COUNT));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Handler function that is called after successful transmission of a packet.
+ *
+ * If new packet is ready for transmitting it starts
+ * the transmission of the packet.
+ *
+ * @param [in] Data_p Pointer to the data for transmitting.
+ * @param [in] Length Length of the received data.
+ * @param [in] Param_p Parameters.
+ *
+ * @return none.
+ */
+void R15_Network_WriteCallback(const void *Data_p, const uint32 Length, void *Param_p)
+{
+ Communication_t *Communication_p = (Communication_t *)Param_p;
+ R15_Outbound_t *Out_p = &(R15_NETWORK(Communication_p)->Outbound);
+ BulkExtendedHeader_t ExtendedHeader = {0};
+ B_(printf("r15_network_layer.c (%d): Device write finished!! \n", __LINE__);)
+
+ if (SENDING_HEADER == Out_p->State) {
+ Out_p->State = SEND_PAYLOAD;
+ } else if (SENDING_PAYLOAD == Out_p->State) {
+ if (NULL == Out_p->Packet_p->Timer_p) {
+ if (Out_p->Packet_p->Header.Protocol == BULK_PROTOCOL) {
+ R15_DeserializeBulkExtendedHeader(&ExtendedHeader, Out_p->Packet_p->ExtendedHeader_p);
+ }
+
+ if (!((Out_p->Packet_p->Header.Protocol == BULK_PROTOCOL) && ((ExtendedHeader.TypeFlags & MASK_BULK_COMMAND_SELECT) == CMD_BULK_DATA))) {
+ (void)R15_Network_PacketRelease(Communication_p, Out_p->Packet_p);
+ }
+ }
+
+ Out_p->State = SEND_IDLE;
+ SET_PACKET_FLAGS(Out_p->Packet_p, PACKET_TX_STATE_MASK, BUF_TX_SENT);
+ }
+
+#ifdef CFG_ENABLE_LOADER_TYPE
+
+ if (E_SUCCESS != R15_Network_TransmiterHandler(Communication_p)) {
+ R15_NETWORK(Communication_p)->Outbound.LCM_Error = E_GENERAL_COMMUNICATION_ERROR;
+ }
+
+#endif
+}
+
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+
+static ErrorCode_e R15_Network_ReceiveHeader(const Communication_t *const Communication_p)
+{
+ R15_Inbound_t *In_p = &(R15_NETWORK(Communication_p)->Inbound);
+
+ if (In_p->RecData == 0) {
+ In_p->ReqData = ALIGNED_HEADER_LENGTH;
+ In_p->Target_p = In_p->Scratch;
+ } else {
+ if (R15_IsReceivedHeader(In_p)) {
+ if (R15_IsValidHeader(In_p->Scratch)) {
+ R15_DeserializeHeader(&In_p->Header, In_p->Scratch);
+
+ In_p->Target_p += ALIGNED_HEADER_LENGTH;
+ if (In_p->Header.ExtendedHeaderLength == COMMAND_EXTENDED_HEADER_LENGTH) {
+ SET_INBOUND(In_p, RECEIVE_EXTENDED_HEADER, ALIGNED_COMMAND_EXTENDED_HEADER_LENGTH);
+ } else {
+ SET_INBOUND(In_p, RECEIVE_EXTENDED_HEADER, ALIGNED_BULK_EXTENDED_HEADER_LENGTH);
+ }
+ } else {
+ A_(printf("Not valid header!\n");)
+ /* Sync the header. */
+ RESET_INBOUND(In_p, RECEIVE_HEADER);
+ SYNC_HEADER(In_p, ALIGNED_HEADER_LENGTH, In_p->Scratch);
+ }
+ }
+ else
+ {
+ uint32 Counter = 0;
+
+ A_(printf("Invalid header! ");)
+ for (Counter = 0; Counter < 16; Counter++)
+ {
+ A_(printf(" %02X", In_p->Scratch[Counter]);)
+ }
+ A_(printf("\n\n");)
+ }
+ }
+
+ return E_SUCCESS;
+}
+
+static ErrorCode_e R15_Network_ReceiveExtendedHeader(Communication_t *Communication_p)
+{
+ R15_Inbound_t *In_p = &(R15_NETWORK(Communication_p)->Inbound);
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ R15_Header_t R15Header = {0};
+ BulkExtendedHeader_t BulkExtendedHeader = {0};
+ boolean IsValidHeader = FALSE;
+
+ VERIFY(NULL != In_p, E_GENERAL_FATAL_ERROR);
+
+ R15_DeserializeHeader(&R15Header, In_p->Scratch);
+ R15_DeserializeBulkExtendedHeader(&BulkExtendedHeader, In_p->Target_p);
+
+ IsValidHeader = R15_IsValidExtendedHeader(In_p->Target_p,
+ In_p->Header.ExtendedHeaderLength,
+ In_p->Header.ExtendedHeaderChecksum);
+
+ if (IsValidHeader) {
+ if (R15Header.Protocol == BULK_PROTOCOL &&
+ (BulkExtendedHeader.TypeFlags & MASK_BULK_COMMAND_SELECT) == CMD_BULK_DATA) {
+ In_p->Packet_p = R15_Network_PacketAllocate(Communication_p, BULK_BUFFER_SIZE);
+ } else {
+ In_p->Packet_p = R15_Network_PacketAllocate(Communication_p, COMMAND_BUFFER_SIZE);
+ }
+
+ VERIFY(NULL != In_p->Packet_p, E_FAILED_TO_FIND_COMM_BUFFER);
+
+ In_p->Packet_p->Header = R15Header;
+ In_p->Packet_p->ExtendedHeader_p = In_p->Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH;
+ SET_PACKET_FLAGS(In_p->Packet_p, PACKET_RX_STATE_MASK, BUF_HDR_CRC_OK);
+ if (In_p->Packet_p->Header.ExtendedHeaderLength == COMMAND_EXTENDED_HEADER_LENGTH) {
+ In_p->Packet_p->Payload_p = In_p->Packet_p->ExtendedHeader_p + ALIGNED_COMMAND_EXTENDED_HEADER_LENGTH;
+ } else {
+ In_p->Packet_p->Payload_p = In_p->Packet_p->ExtendedHeader_p + ALIGNED_BULK_EXTENDED_HEADER_LENGTH;
+ }
+ memcpy(In_p->Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER, &In_p->Packet_p->Header, HEADER_LENGTH);
+ memcpy(In_p->Packet_p->ExtendedHeader_p, In_p->Target_p, In_p->Header.ExtendedHeaderLength);
+
+ In_p->Target_p = In_p->Packet_p->Payload_p;
+
+ /* check for expected payload */
+ if (In_p->Packet_p->Header.PayloadLength != 0) {
+ uint32 Aligned_Size = 0;
+ Aligned_Size = (In_p->Packet_p->Header.PayloadLength + (ALIGN_SIZE - 1)) & (~(ALIGN_SIZE - 1));
+
+ SET_INBOUND(In_p, RECEIVE_PAYLOAD, Aligned_Size);
+ } else {
+#ifdef DISABLE_SECURITY
+ SET_PACKET_FLAGS(In_p->Packet_p, PACKET_RX_STATE_MASK, BUF_RX_READY);
+ (void)QUEUE(Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p, In_p->Packet_p);
+#else
+ PacketMeta_t *Packet_p = In_p->Packet_p;
+ Packet_p->Communication_p = Communication_p;
+ SET_PACKET_FLAGS(In_p->Packet_p, PACKET_RX_STATE_MASK, BUF_RX_READY);
+ // Copy the original packet checksum to avoid hash mismatch
+ memcpy(Packet_p->Hash, &Packet_p->Header.PayloadChecksum, 4);
+
+ Communication_p->HashDevice_p->Calculate(OBJECT_HASH(Communication_p),
+ HASH_NONE,
+ Packet_p->Payload_p, Packet_p->Header.PayloadLength,
+ Packet_p->Hash, (HashCallback_t)R15_InHashCallback,
+ (void *)Packet_p);
+#endif
+
+ In_p->Packet_p = NULL;
+ RESET_INBOUND(In_p, RECEIVE_HEADER);
+ SYNC_HEADER(In_p, ALIGNED_HEADER_LENGTH, In_p->Scratch);
+ C_(printf("r15_network_layer.c (%d) ReqData(%d) RecData(%d) \n", __LINE__, In_p->ReqData, In_p->RecData);)
+ }
+ } else {
+ RESET_INBOUND(In_p, RECEIVE_HEADER);
+ SYNC_HEADER(In_p, ALIGNED_HEADER_LENGTH, In_p->Scratch);
+ }
+
+ErrorExit:
+ return ReturnValue;
+}
+
+static ErrorCode_e R15_Network_ReceivePayload(Communication_t *Communication_p)
+{
+ R15_Inbound_t *In_p = &(R15_NETWORK(Communication_p)->Inbound);
+ PacketMeta_t *Packet_p = In_p->Packet_p;
+
+ Packet_p->Communication_p = Communication_p;
+ SET_PACKET_FLAGS(In_p->Packet_p, PACKET_RX_STATE_MASK, BUF_RX_READY);
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+ Communication_p->CurrentFamilyHash = (HashType_e)Packet_p->Header.Flags;
+#endif
+
+ if (HASH_NONE != Packet_p->Header.Flags) {
+#ifdef CFG_ENABLE_MEASUREMENT_TOOL
+ if(In_p->Packet_p->Header.Protocol == BULK_PROTOCOL){
+ BulkExtendedHeader_t ExtendedHeader = {0};
+ R15_DeserializeBulkExtendedHeader(&ExtendedHeader, Packet_p->ExtendedHeader_p);
+
+ if ((ExtendedHeader.TypeFlags & MASK_BULK_COMMAND_SELECT) == CMD_BULK_DATA){
+ (void)MP(Measurement_p, ExtendedHeader.AcksChunk, START_HASHINGCHUNK_TIME);
+ }
+ }
+#endif
+ Communication_p->HashDevice_p->Calculate(OBJECT_HASH(Communication_p),
+ Communication_p->CurrentFamilyHash,
+ Packet_p->Payload_p, Packet_p->Header.PayloadLength,
+ Packet_p->Hash, (HashCallback_t)R15_InHashCallback,
+ (void *)Packet_p);
+ } else {
+ SET_PACKET_FLAGS(Packet_p, PACKET_RX_STATE_MASK, BUF_PAYLOAD_CRC_OK);
+ (void)QUEUE((Packet_p->Communication_p), FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Inbound_p, Packet_p);
+ }
+
+ In_p->Packet_p = NULL;
+ RESET_INBOUND(In_p, RECEIVE_HEADER);
+ SYNC_HEADER(In_p, ALIGNED_HEADER_LENGTH, In_p->Scratch);
+ return E_SUCCESS;
+}
+
+static ErrorCode_e R15_Network_RegisterRetransmission(Communication_t *Communication_p, PacketMeta_t *Packet_p)
+{
+ int i;
+ int Index;
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ static RetransmissionContext_t *R_Ctx_p = NULL;
+
+ if (R15_NETWORK(Communication_p)->RetransmissionListCount < MAX_SIZE_RETRANSMISSION_LIST) {
+ if (NULL == Packet_p->Timer_p->HandleFunction_p) {
+ Packet_p->Timer_p->HandleFunction_p = (HandleFunction_t)R15_Network_RetransmissionCallback;
+ Packet_p->Timer_p->Param_p = Communication_p;
+ }
+
+ R_Ctx_p = (RetransmissionContext_t *)malloc(sizeof(RetransmissionContext_t));
+
+ if (NULL == R_Ctx_p) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ R_Ctx_p->TimerKey = TIMER(Communication_p, TimerGet_Fn)(OBJECT_TIMER(Communication_p), Packet_p->Timer_p);
+ R_Ctx_p->Timeout = Packet_p->Timer_p->Time;
+ R_Ctx_p->Packet_p = Packet_p;
+ R_Ctx_p->Key = R15_Network_CreateUniqueKey(Packet_p, (uint8)(*(R_Ctx_p->Packet_p->ExtendedHeader_p + sizeof(uint16))));
+
+ Index = 0;
+ C_(printf("r15_network_layer.c (%d) Key(%d) TKey(%d) \n", __LINE__, R_Ctx_p->Key, R_Ctx_p->TimerKey);)
+
+ do {
+ if (NULL != R15_NETWORK(Communication_p)->RetransmissionList[Index]) {
+ if (R_Ctx_p->Timeout < TIMER(Communication_p, ReadTime_Fn)(OBJECT_TIMER(Communication_p), R15_NETWORK(Communication_p)->RetransmissionList[Index]->TimerKey)) {
+ i = R15_NETWORK(Communication_p)->RetransmissionListCount;
+
+ for (; Index < i; i--) {
+ R15_NETWORK(Communication_p)->RetransmissionList[i] = R15_NETWORK(Communication_p)->RetransmissionList[i-1];
+ }
+
+ R15_NETWORK(Communication_p)->RetransmissionList[Index] = R_Ctx_p;
+ R_Ctx_p = NULL;
+ R15_NETWORK(Communication_p)->RetransmissionListCount++;
+ break;
+ }
+
+ Index++;
+ } else {
+ R15_NETWORK(Communication_p)->RetransmissionList[Index] = R_Ctx_p;
+ R_Ctx_p = NULL;
+ R15_NETWORK(Communication_p)->RetransmissionListCount++;
+ break;
+ }
+ } while (Index < MAX_SIZE_RETRANSMISSION_LIST);
+ } else {
+ A_(printf("r15_network_layer.c (%d) ** Err: Retransmision List is full! ** \n", __LINE__);)
+ }
+
+ return ReturnValue;
+}
+
+
+static void R15_Network_RetransmissionCallback(Communication_t *Communication_p, const void *const Timer_p, void *Packet_p)
+{
+ uint32 Index = 0;
+
+ /* get first in list of packets for retransmission and remove */
+ if (NULL != R15_NETWORK(Communication_p)->RetransmissionList[Index]) {
+ free(R15_NETWORK(Communication_p)->RetransmissionList[Index]);
+ R15_NETWORK(Communication_p)->RetransmissionList[Index] = NULL;
+ }
+
+ if (R15_NETWORK(Communication_p)->RetransmissionListCount > 0) {
+ C_(printf("r15_network_layer.c (%d) RetransmissionListCount(%d) \n", __LINE__, R15_NETWORK(Communication_p)->RetransmissionListCount);)
+ R15_NETWORK(Communication_p)->RetransmissionListCount--;
+
+ for (; Index < R15_NETWORK(Communication_p)->RetransmissionListCount; Index++) {
+ R15_NETWORK(Communication_p)->RetransmissionList[Index] = R15_NETWORK(Communication_p)->RetransmissionList[Index+1];
+ }
+
+ R15_NETWORK(Communication_p)->RetransmissionList[Index] = NULL;
+
+ /* enqueue the packet for retransmission */
+ (void)QUEUE(Communication_p, FifoEnqueue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Outbound_p, Packet_p);
+ }
+}
+
+
+static void R15_InHashCallback(const void *const Data_p, uint32 Length, const uint8 *const Hash_p, void *Param_p)
+{
+ PacketMeta_t *Packet_p = (PacketMeta_t *)Param_p;
+
+#ifdef CFG_ENABLE_MEASUREMENT_TOOL
+ if(Packet_p->Header.Protocol == BULK_PROTOCOL){
+ BulkExtendedHeader_t ExtendedHeader = {0};
+ R15_DeserializeBulkExtendedHeader(&ExtendedHeader, Packet_p->ExtendedHeader_p);
+
+ if ((ExtendedHeader.TypeFlags & MASK_BULK_COMMAND_SELECT) == CMD_BULK_DATA){
+ (void)MP(Measurement_p, ExtendedHeader.AcksChunk, END_HASHINGCHUNK_TIME);
+ }
+ }
+#endif
+
+ if (memcmp(Hash_p, &Packet_p->Header.PayloadChecksum, 4) == 0) {
+ SET_PACKET_FLAGS(Packet_p, PACKET_RX_STATE_MASK, BUF_PAYLOAD_CRC_OK);
+ (void)QUEUE((Packet_p->Communication_p), FifoEnqueue_Fn)(OBJECT_QUEUE(Packet_p->Communication_p), Packet_p->Communication_p->Inbound_p, Packet_p);
+ } else {
+ /* Invalid packet */
+ ErrorCode_e ReturnValue = E_GENERAL_FATAL_ERROR;
+
+ if (E_SUCCESS != (ReturnValue = R15_Network_PacketRelease((Communication_t *)Packet_p->Communication_p, Packet_p))) {
+ R15_NETWORK((Communication_t *)Packet_p->Communication_p)->Inbound.LCM_Error = ReturnValue;
+ }
+ }
+}
+
+#ifdef CFG_ENABLE_LOADER_TYPE
+static void R15_QueueOutCallback(const void *const Queue_p, void *Param_p)
+{
+ if (E_SUCCESS != R15_Network_TransmiterHandler((Communication_t *)Param_p)) {
+ R15_NETWORK((Communication_t *)Param_p)->Outbound.LCM_Error = E_GENERAL_COMMUNICATION_ERROR;
+ }
+}
+
+static void R15_QueueInCallback(const void *const Queue_p, void *Param_p)
+{
+ ErrorCode_e ReturnValue = E_GENERAL_FATAL_ERROR;
+ Communication_t *Communication_p = (Communication_t *)Param_p;
+ PacketMeta_t *Packet_p = NULL;
+
+ while ((Packet_p = (PacketMeta_t *)QUEUE(Communication_p, FifoDequeue_Fn)(OBJECT_QUEUE(Communication_p), Communication_p->Inbound_p)) != NULL) {
+ switch (Packet_p->Header.Protocol) {
+ case PROTO_BULK:
+ ReturnValue = R15_Bulk_Process(Communication_p, Packet_p);
+
+ if (E_SUCCESS != ReturnValue) {
+ R15_NETWORK(Communication_p)->Inbound.LCM_Error = ReturnValue;
+ }
+
+ break;
+
+ case PROTO_COMMAND:
+ ReturnValue = R15_Command_Process(Communication_p, Packet_p);
+
+ if (E_SUCCESS != ReturnValue) {
+ R15_NETWORK(Communication_p)->Inbound.LCM_Error = ReturnValue;
+ }
+
+ break;
+
+ default:
+ R15_NETWORK(Communication_p)->Inbound.LCM_Error = E_SUCCESS;
+ break;
+ }
+ }
+}
+#endif
+
+static PacketMeta_t *R15_Network_GetAvailableMetaPacket(void)
+{
+ uint8 i = 0;
+ PacketMeta_t *PacketMeta_p = NULL;
+
+ do {
+ if (NULL == PacketMetaInfo[i].Buffer_p) {
+ PacketMeta_p = &PacketMetaInfo[i];
+ break;
+ }
+
+ i++;
+ } while (i < COMMAND_BUFFER_COUNT + BULK_BUFFER_COUNT);
+
+ return PacketMeta_p;
+}
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/source/z_network.c b/lcmodule/source/cnh1605205_ldr_network_layer/source/z_network.c
new file mode 100644
index 0000000..54abf46
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/source/z_network.c
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup z_family
+ * @{
+ * @addtogroup ldr_network_layer
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <stdlib.h>
+#include <string.h>
+#include "c_system.h"
+#include "t_basicdefinitions.h"
+#include "r_z_family.h"
+#include "r_z_transport.h"
+#include "r_z_network.h"
+#include "r_z_protocol.h"
+#include "r_debug.h"
+//#include "r_debug_macro.h"
+#include "r_communication_service.h"
+#include "t_z_protocol.h"
+
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+/*******************************************************************************
+ * Declaration of file local functions
+ ******************************************************************************/
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+#define Z_RESET_INBOUND(c, s) do { (c)->ReqData = 0; (c)->RecData = 0; (c)->Target_p = NULL; (c)->State = (s); } while(0);
+#define Z_SYNC_HEADER(c, d, t) do { (c)->ReqData = d; (c)->Target_p = t; } while(0);
+#define Z_SET_INBOUND(c, s, d) do { (c)->ReqData = d; (c)->RecData = 0; (c)->State = (s); } while(0);
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+ErrorCode_e Z_Network_Initialize(Communication_t *Communication_p)
+{
+ if (NULL == Communication_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ memset(Z_NETWORK(Communication_p), 0, sizeof(Z_NetworkContext_t));
+
+ /* Simulate a finished read to get the inbound state-machine going. */
+ Z_Network_ReadCallback(NULL, 0, Communication_p);
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e Z_Network_Shutdown(const Communication_t *const Communication_p)
+{
+
+ return E_SUCCESS;
+}
+
+void Z_Network_ReadCallback(const void *Data_p, const uint32 Length, void *Param_p)
+{
+ Communication_t *Communication_p = (Communication_t *)Param_p;
+ CommandData_t CmdData;
+
+ Z_NETWORK(Communication_p)->Inbound.RecData += Length;
+
+ if (Z_NETWORK(Communication_p)->Inbound.ReqData == 0) {
+ Z_Inbound_t *In_p = &(Z_NETWORK(Communication_p)->Inbound);
+
+ if (In_p->RecData == 0) {
+ In_p->ReqData = Z_HEADER_LENGTH;
+ In_p->Target_p = In_p->Scratch;
+ } else {
+ CmdData.Payload.Data_p = In_p->Scratch;
+ (void)Communication_p->Do_CEH_Call_Fn(Communication_p->Object_p, &CmdData);
+ Z_RESET_INBOUND(In_p, Z_RECEIVE_HEADER);
+ Z_SYNC_HEADER(In_p, Z_HEADER_LENGTH, In_p->Scratch);
+ }
+ }
+}
+
+void Z_Network_ReceiverHandler(Communication_t *Communication_p)
+{
+ uint32 ReqData;
+ Z_Inbound_t *In_p = &(Z_NETWORK(Communication_p)->Inbound);
+
+ /* new data for receiving ? */
+ if (In_p->ReqData > 0) {
+ ReqData = In_p->ReqData;
+ In_p->ReqData = 0;
+ In_p->RecData = 0;
+ (void)Communication_p->CommunicationDevice_p->Read(In_p->Target_p, ReqData, Z_Network_ReadCallback, Communication_p);
+ C_(printf("z_network.c (%d) ReqData(%d) RecData(%d) \n", __LINE__, ReqData, In_p->RecData);)
+ }
+
+ /* check for receiver sinhronization */
+ if (In_p->State == Z_RECEIVE_ERROR) {
+ In_p->ReqData = 0;
+ In_p->RecData = 0;
+ (void)Communication_p->CommunicationDevice_p->Read(In_p->Target_p, Z_HEADER_LENGTH, Z_Network_ReadCallback, Communication_p);
+ }
+}
+
+
+void Z_Network_WriteCallback(const void *Data_p, const uint32 Length, void *Param_p)
+{
+}
+
+
+ErrorCode_e Z_Network_TransmiterHandler(Communication_t *Communication_p, Z_SendingContent_t *SendingContent_p)
+{
+ uint8 *Data_p = SendingContent_p->Data_p;
+ uint8 Size = SendingContent_p->Size;
+ Z_Outbound_t *Out_p = &(Z_NETWORK(Communication_p)->Outbound);
+
+ if (Out_p->InLoad) {
+ return E_SUCCESS;
+ }
+
+ Out_p->InLoad = TRUE;
+
+ switch (Out_p->State) {
+ case Z_SEND_IDLE:
+ /* get next packet for transmiting */
+ Out_p->State = Z_SEND_PACKET;
+
+ /* FALLTHROUGH */
+ case Z_SEND_PACKET:
+
+ if (E_SUCCESS == Communication_p->CommunicationDevice_p->Write(Data_p,
+ Size,
+ Z_Network_WriteCallback, Communication_p)) {
+ Out_p->State = Z_SENDING_PACKET;
+ } else {
+ /* error state ?*/
+ }
+
+ /* FALLTHROUGH */
+ case Z_SENDING_PACKET:
+ Out_p->State = Z_SEND_IDLE;
+ break;
+
+ }
+
+ Out_p->InLoad = FALSE;
+
+ return E_SUCCESS;
+}
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205.c b/lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205.c
new file mode 100644
index 0000000..68455bf
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205.c
@@ -0,0 +1,553 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+/**
+ * @file ADbg_cnh<ModuleNumber>.c
+ *
+ * @brief Test cases for CNH1605205 module.
+ *
+ * This file consist of test cases for autometic testing functions from
+ * CNH1605205 module.
+ */
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "r_adbg.h"
+#include "r_adbg_assert.h"
+#include "r_adbg_case.h"
+#include "r_adbg_module.h"
+#include "r_adbg_command.h"
+#include "r_a2_header.h"
+#include "r_a2_network.h"
+#include "r_r15_header.h"
+#include "r_r15_network_layer.h"
+#include <stdlib.h>
+
+/*******************************************************************************
+ * The test case functions declarations
+ ******************************************************************************/
+static void ADbg_A2_GetPacketLength(ADbg_Case_t *Case_p);
+static void ADbg_A2_IsValidHeader(ADbg_Case_t *Case_p);
+static void ADbg_A2_IsReceivedHeader(ADbg_Case_t *Case_p);
+
+static void ADbg_A2_Network_Initialize(ADbg_Case_t *Case_p);
+static void ADbg_A2_Network_Shutdown(ADbg_Case_t *Case_p);
+static void ADbg_A2_Network_PacketAllocate(ADbg_Case_t *Case_p);
+static void ADbg_A2_Network_PacketRelease(ADbg_Case_t *Case_p);
+
+static void ADbg_R15_GetPacketLength(ADbg_Case_t *Case_p);
+static void ADbg_R15_IsValidHeader(ADbg_Case_t *Case_p);
+static void ADbg_R15_IsReceivedHeader(ADbg_Case_t *Case_p);
+static void ADbg_R15_IsValidExtendedHeader(ADbg_Case_t *Case_p);
+
+static void ADbg_R15_Network_Initialize(ADbg_Case_t *Case_p);
+static void ADbg_R15_Network_Shutdown(ADbg_Case_t *Case_p);
+static void ADbg_R15_Network_CreateUniqueKey(ADbg_Case_t *Case_p);
+static void ADbg_R15_Network_PacketAllocate(ADbg_Case_t *Case_p);
+static void ADbg_R15_Network_PacketRelease(ADbg_Case_t *Case_p);
+
+/*******************************************************************************
+ * The test case definitions
+ ******************************************************************************/
+static uint8 Parameters1_1[3] = {2, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_A2_GetPacketLength, 1, 9, ADbg_A2_GetPacketLength, Parameters1_1);
+static uint8 Parameters1_2[3] = {2, VOIDPTR, BYTE};
+ADBG_CASE_DEFINE(Test_A2_IsValidHeader, 2, 9, ADbg_A2_IsValidHeader, Parameters1_2);
+static uint8 Parameters1_3[3] = {2, VOIDPTR, BYTE};
+ADBG_CASE_DEFINE(Test_A2_IsReceivedHeader, 3, 9, ADbg_A2_IsReceivedHeader, Parameters1_3);
+
+static uint8 Parameters2_1[3] = {2, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_A2_Network_Initialize, 4, 9, ADbg_A2_Network_Initialize, Parameters2_1);
+static uint8 Parameters2_2[3] = {2, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_A2_Network_Shutdown, 5, 9, ADbg_A2_Network_Shutdown, Parameters2_2);
+static uint8 Parameters2_3[4] = {3, WORDPTR, WORD, WORDPTR};
+ADBG_CASE_DEFINE(Test_A2_Network_PacketAllocate, 6, 9, ADbg_A2_Network_PacketAllocate, Parameters2_3);
+static uint8 Parameters2_4[4] = {3, WORDPTR, WORD, WORDPTR};
+ADBG_CASE_DEFINE(Test_A2_Network_PacketRelease, 7, 9, ADbg_A2_Network_PacketRelease, Parameters2_4);
+
+static uint8 Parameters3_1[3] = {2, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_R15_GetPacketLength, 8, 9, ADbg_R15_GetPacketLength, Parameters3_1);
+static uint8 Parameters3_2[3] = {2, VOIDPTR, BYTE};
+ADBG_CASE_DEFINE(Test_R15_IsValidHeader, 9, 9, ADbg_R15_IsValidHeader, Parameters3_2);
+static uint8 Parameters3_3[3] = {2, WORDPTR, BYTE};
+ADBG_CASE_DEFINE(Test_R15_IsReceivedHeader, 10, 9, ADbg_R15_IsReceivedHeader, Parameters3_3);
+static uint8 Parameters3_4[5] = {4, VOIDPTR, BYTE, BYTE, BYTE};
+ADBG_CASE_DEFINE(Test_R15_IsValidExtendedHeader, 11, 9, ADbg_R15_IsValidExtendedHeader, Parameters3_4);
+
+static uint8 Parameters4_1[3] = {2, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_R15_Network_Initialize, 12, 9, ADbg_R15_Network_Initialize, Parameters4_1);
+static uint8 Parameters4_2[3] = {2, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_R15_Network_Shutdown, 13, 9, ADbg_R15_Network_Shutdown, Parameters4_2);
+static uint8 Parameters4_3[4] = {3, VOIDPTR, BYTE, WORD};
+ADBG_CASE_DEFINE(Test_R15_Network_CreateUniqueKey, 14, 9, ADbg_R15_Network_CreateUniqueKey, Parameters4_3);
+static uint8 Parameters4_4[4] = {3, WORDPTR, WORD, WORDPTR};
+ADBG_CASE_DEFINE(Test_R15_Network_PacketAllocate, 15, 9, ADbg_R15_Network_PacketAllocate, Parameters4_4);
+static uint8 Parameters4_5[4] = {3, WORDPTR, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_R15_Network_PacketRelease, 16, 9, ADbg_R15_Network_PacketRelease, Parameters4_5);
+
+/*******************************************************************************
+* The test case suite definition
+******************************************************************************/
+ADBG_SUITE_DEFINE_BEGIN(TestCase_CNH1605205, 0, 9)
+
+ADBG_SUITE_ENTRY(Test_A2_GetPacketLength)
+ADBG_SUITE_ENTRY(Test_A2_IsValidHeader)
+ADBG_SUITE_ENTRY(Test_A2_IsReceivedHeader)
+
+ADBG_SUITE_ENTRY(Test_A2_Network_Initialize)
+ADBG_SUITE_ENTRY(Test_A2_Network_Shutdown)
+ADBG_SUITE_ENTRY(Test_A2_Network_PacketAllocate)
+ADBG_SUITE_ENTRY(Test_A2_Network_PacketRelease)
+
+ADBG_SUITE_ENTRY(Test_R15_GetPacketLength)
+ADBG_SUITE_ENTRY(Test_R15_IsValidHeader)
+ADBG_SUITE_ENTRY(Test_R15_IsReceivedHeader)
+ADBG_SUITE_ENTRY(Test_R15_IsValidExtendedHeader)
+
+ADBG_SUITE_ENTRY(Test_R15_Network_Initialize)
+ADBG_SUITE_ENTRY(Test_R15_Network_Shutdown)
+ADBG_SUITE_ENTRY(Test_R15_Network_CreateUniqueKey)
+ADBG_SUITE_ENTRY(Test_R15_Network_PacketAllocate)
+ADBG_SUITE_ENTRY(Test_R15_Network_PacketRelease)
+
+ADBG_SUITE_DEFINE_END();
+
+/*******************************************************************************
+ * Case runner
+ ******************************************************************************/
+void Do_CNH1605205_Module_Test_Run(ADbg_MainModule_t *MainModule_p)
+{
+ ADbg_Module_t *Module_p = Do_ADbg_Module_Create(TestCase_CNH1605205, NULL, MainModule_p->Command_p, MainModule_p->Result_p);
+ Do_ADbg_InModule_Command(Module_p);
+ Do_ADbg_Module_Destroy(Module_p);
+}
+/*******************************************************************************
+ * Test cases
+ ******************************************************************************/
+/**
+ * This function will test function:
+ * A2_GetPacketLength.
+ * Function used in: Test_A2_GetPacketLength.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_A2_GetPacketLength(ADbg_Case_t *Case_p)
+{
+ uint32 Result = 0;
+ A2_Header_t *Header_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Header_p = Do_ADbg_GetDataPointer(sizeof(A2_Header_t *), (void **)&Var_p);
+
+ Result = A2_GetPacketLength(Header_p);
+ Do_ADbg_Assert((uint32)(*Var_p) == Result, Case_p);
+
+ if (NULL != Header_p) {
+ free(Header_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * A2_IsValidHeader.
+ * Function used in: Test_A2_IsValidHeader.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_A2_IsValidHeader(ADbg_Case_t *Case_p)
+{
+ boolean Result = TRUE;
+ void *Data_p = NULL;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Data_p = Do_ADbg_GetDataPointer(sizeof(void *), (void **)&Var_p);
+
+ Result = A2_IsValidHeader(Data_p);
+ Do_ADbg_Assert((boolean)(*Var_p) == Result, Case_p);
+
+ if (NULL != Data_p) {
+ free(Data_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * A2_IsReceivedHeader.
+ * Function used in: Test_A2_IsReceivedHeader.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_A2_IsReceivedHeader(ADbg_Case_t *Case_p)
+{
+ boolean Result = TRUE;
+ A2_Inbound_t *In_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ In_p = Do_ADbg_GetDataPointer(sizeof(A2_Inbound_t *), (void **)&Var_p);
+
+ Result = A2_IsReceivedHeader(In_p);
+ Do_ADbg_Assert((boolean)(*Var_p) == Result, Case_p);
+
+ if (NULL != In_p) {
+ free(In_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * A2_Network_Initialize.
+ * Function used in: Test_A2_Network_Initialize.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_A2_Network_Initialize(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+
+ Result = A2_Network_Initialize(Communication_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * A2_Network_Shutdown.
+ * Function used in: Test_A2_Network_Shutdown.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_A2_Network_Shutdown(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+
+ Result = A2_Network_Shutdown(Communication_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * A2_Network_PacketAllocate.
+ * Function used in: Test_A2_Network_PacketAllocate.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_A2_Network_PacketAllocate(ADbg_Case_t *Case_p)
+{
+ A2_PacketMeta_t *Result = NULL;
+ Communication_t *Communication_p;
+ int BufferSize = 0;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+
+ Do_ADbg_GetDataVar(sizeof(int), &Var_p, &BufferSize);
+
+ Result = A2_Network_PacketAllocate(Communication_p, BufferSize);
+ Do_ADbg_Assert((A2_PacketMeta_t *)(*Var_p) != Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * A2_Network_PacketRelease.
+ * Function used in: Test_A2_Network_PacketRelease.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_A2_Network_PacketRelease(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ A2_PacketMeta_t *Meta_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+ Meta_p = Do_ADbg_GetDataPointer(sizeof(A2_PacketMeta_t *), (void **)&Var_p);
+
+ Result = A2_Network_PacketRelease(Communication_p, Meta_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+
+ if (NULL != Meta_p) {
+ free(Meta_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_GetPacketLength.
+ * Function used in: Test_R15_GetPacketLength.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_GetPacketLength(ADbg_Case_t *Case_p)
+{
+ uint32 Result = 0;
+ R15_Header_t *Header_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Header_p = Do_ADbg_GetDataPointer(sizeof(R15_Header_t *), (void **)&Var_p);
+
+ Result = R15_GetPacketLength(Header_p);
+ Do_ADbg_Assert((uint32)(*Var_p) == Result, Case_p);
+
+ if (NULL != Header_p) {
+ free(Header_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_IsValidHeader.
+ * Function used in: Test_R15_IsValidHeader.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_IsValidHeader(ADbg_Case_t *Case_p)
+{
+ boolean Result = FALSE;
+ void *Data_p = NULL;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Data_p = Do_ADbg_GetDataPointer(sizeof(void *), (void **)&Var_p);
+
+ Result = R15_IsValidHeader(Data_p);
+ Do_ADbg_Assert((boolean)(*Var_p) != Result, Case_p);
+
+ if (NULL != Data_p) {
+ free(Data_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_IsReceivedHeader.
+ * Function used in: Test_R15_IsReceivedHeader.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_IsReceivedHeader(ADbg_Case_t *Case_p)
+{
+ boolean Result = FALSE;
+ R15_Inbound_t *In_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ In_p = Do_ADbg_GetDataPointer(sizeof(R15_Inbound_t *), (void **)&Var_p);
+
+ Result = R15_IsReceivedHeader(In_p);
+ Do_ADbg_Assert((boolean)(*Var_p) != Result, Case_p);
+
+ if (NULL != In_p) {
+ free(In_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_IsValidExtendedHeader.
+ * Function used in: Test_R15_IsValidExtendedHeader.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_IsValidExtendedHeader(ADbg_Case_t *Case_p)
+{
+ boolean Result = FALSE;
+ void *Data_p = NULL;
+ uint8 Length = 0;
+ uint8 Checksum = 0;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Data_p = Do_ADbg_GetDataPointer(sizeof(void *), (void **)&Var_p);
+
+ Do_ADbg_GetDataVar(sizeof(uint8), &Var_p, &Length);
+ Do_ADbg_GetDataVar(sizeof(uint8), &Var_p, &Checksum);
+
+ Result = R15_IsValidExtendedHeader(Data_p, Length, Checksum);
+ Do_ADbg_Assert((boolean)(*Var_p) != Result, Case_p);
+
+ if (NULL != Data_p) {
+ free(Data_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_Network_Initialize.
+ * Function used in: Test_R15_Network_Initialize.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_Network_Initialize(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+
+ Result = R15_Network_Initialize(Communication_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_Network_Shutdown.
+ * Function used in: Test_R15_Network_Shutdown.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_Network_Shutdown(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+
+ Result = R15_Network_Shutdown(Communication_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_Network_CreateUniqueKey.
+ * Function used in: Test_R15_Network_CreateUniqueKey.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_Network_CreateUniqueKey(ADbg_Case_t *Case_p)
+{
+ uint32 Result = 0;
+ void *Packet_p = NULL;
+ uint8 ExternalKey = 0;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Packet_p = Do_ADbg_GetDataPointer(sizeof(void *), (void **)&Var_p);
+
+ Result = R15_Network_CreateUniqueKey(Packet_p, ExternalKey);
+ Do_ADbg_Assert((uint32)(*Var_p) != Result, Case_p);
+
+ if (NULL != Packet_p) {
+ free(Packet_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_Network_PacketAllocate.
+ * Function used in: Test_R15_Network_PacketAllocate.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_Network_PacketAllocate(ADbg_Case_t *Case_p)
+{
+ PacketMeta_t *Result = NULL;
+ Communication_t *Communication_p;
+ uint8 BufferSize = 0;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+
+ Result = R15_Network_PacketAllocate(Communication_p, BufferSize);
+ Do_ADbg_Assert((PacketMeta_t *)(*Var_p) != Result, Case_p);
+
+ if (NULL != Communication_p) {
+ free(Communication_p);
+ }
+}
+
+/**
+ * This function will test function:
+ * R15_Network_PacketRelease.
+ * Function used in: Test_R15_Network_PacketRelease.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_R15_Network_PacketRelease(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ PacketMeta_t *Meta_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t *), (void **)&Var_p);
+ Meta_p = Do_ADbg_GetDataPointer(sizeof(PacketMeta_t *), (void **)&Var_p);
+
+ Result = R15_Network_PacketRelease(Communication_p, Meta_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ if (NULL != Meta_p) {
+ free(Meta_p);
+ }
+}
+
+/** @} */
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205.h b/lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205.h
new file mode 100644
index 0000000..3c593bb
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205.h
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef ADBG_CNH1605205_H_
+#define ADBG_CNH1605205_H_
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+
+/* @} */
+#endif /*ADBG_CNH1605205_H_*/
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205_utilities.c b/lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205_utilities.c
new file mode 100644
index 0000000..abc7563
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205_utilities.c
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+/**
+ * @file ADbg_cnh1605205_utilities.c
+ *
+ * @brief Interface functions for CNH1605205 module.
+ *
+ * This file consist of interface functions for setting preconditions
+ * for automatic testing functions from CNH1605205 module.
+ */
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "r_adbg.h"
+#include "r_adbg_int_function.h"
+#include "r_adbg_int_group.h"
+#include "r_adbg_command.h"
+#include "r_adbg_module.h"
+#include "r_communication_service.h"
+#include "ADbg_cnh1605205_utilities.h"
+
+/*******************************************************************************
+ * The interface functions declarations
+ ******************************************************************************/
+
+static void ADbg_IntGroup1_CNH1605205_Group(ADbg_Module_t *Module_p);
+/** Functions used for set the global variables. */
+static void ADbg_Test_Function1_CNH1605205(ADbg_IntFunction_t *IntFunction_p);
+
+/*******************************************************************************
+ * The interface group definitions
+ ******************************************************************************/
+//ADBG_INTERFACE_GROUP_DEFINE(InterfaceGroupName, InterfaceGroupId, ModuleId, InterfaceFunctionRunner)
+ADBG_INTERFACE_GROUP_DEFINE(Test_IntGroup1_CNH1605205_Group, 1, 9, ADbg_IntGroup1_CNH1605205_Group);
+
+/*******************************************************************************
+ * The interface function definitions
+ ******************************************************************************/
+
+static uint8 Param1[2] = {1, WORD};
+static uint8 Param2[4];
+ADBG_INTERFACE_FUNCTION_DEFINE(Test_Function1_CNH1605205, 1, 1, 9, ADbg_Test_Function1_CNH1605205, Param1, Param2);
+
+/*******************************************************************************
+ * The interface group suite definition
+ ******************************************************************************/
+//ADBG_INTERFACE_GROUP_SUITE_DEFINE_BEGIN(TestIntGroup_CNH1605205, 0, ModuleId)
+ADBG_INTERFACE_GROUP_SUITE_DEFINE_BEGIN(IntGroup_CNH1605205, 0, 9)
+
+//ADBG_INTERFACE_GROUP_SUITE_ENTRY(InterfaceGroupName)
+ADBG_INTERFACE_GROUP_SUITE_ENTRY(Test_IntGroup1_CNH1605205_Group)
+
+ADBG_INTERFACE_GROUP_SUITE_DEFINE_END();
+
+/*******************************************************************************
+ * The interface functions suites definition
+ ******************************************************************************/
+//ADBG_INTERFACE_FUNCTION_SUITE_DEFINE_BEGIN(TestIntFunctionSuiteName, 0, IntGroupId, ModuleId)
+
+ADBG_INTERFACE_FUNCTION_SUITE_DEFINE_BEGIN(IntGroup1_CNH1605205, 0, 1, 9)
+
+ADBG_INTERFACE_FUNCTION_SUITE_ENTRY(Test_Function1_CNH1605205) //InterfaceFunctionName
+
+ADBG_INTERFACE_FUNCTION_SUITE_DEFINE_END();
+
+/*******************************************************************************
+ * Interface group runner
+ ******************************************************************************/
+void Do_CNH1605205_Module_Interface_Run(ADbg_MainModule_t *MainModule_p)
+{
+ ADbg_Module_t *Module_p = Do_ADbg_Module_Create(NULL, IntGroup_CNH1605205, MainModule_p->Command_p, MainModule_p->Result_p);
+ Do_ADbg_InModule_Command(Module_p);
+ Do_ADbg_Module_Destroy(Module_p);
+}
+
+/*******************************************************************************
+ * Interface functions from group1 runner
+ ******************************************************************************/
+static void ADbg_IntGroup1_CNH1605205_Group(ADbg_Module_t *Module_p)
+{
+ ADbg_IntGroup_t *IntGroup1_p = Do_ADbg_IntGroup_Create(IntGroup1_CNH1605205, Module_p->Command_p, Module_p->Result_p);
+ Do_ADbg_InIntGroup_Command(IntGroup1_p);
+ Do_ADbg_IntGroup_Destroy(IntGroup1_p);
+}
+
+/**
+ * @brief Interface function.
+ *
+ * This function...
+ *
+ * @param [in] IntFunction_p is pointer.
+ * @return void.
+ */
+static void ADbg_Test_Function1_CNH1605205(ADbg_IntFunction_t *IntFunction_p)
+{
+ uint32 Param;
+
+ //...
+ Do_ADbg_SetAndRecoveryCondition((void *)&Param, Param2, sizeof(uint32), IntFunction_p);
+}
+
+/* @} */
diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205_utilities.h b/lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205_utilities.h
new file mode 100644
index 0000000..632ab89
--- /dev/null
+++ b/lcmodule/source/cnh1605205_ldr_network_layer/test_cases/ADbg_cnh1605205_utilities.h
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef ADBG_CNH1605205_UTILITIES_H_
+#define ADBG_CNH1605205_UTILITIES_H_
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+
+/* @} */
+#endif /*ADBG_CNH1605205_UTIILITIES_H_*/
diff --git a/lcmodule/source/cnh1605551_ldr_utilities/debug_subsystem/r_debug_subsystem.h b/lcmodule/source/cnh1605551_ldr_utilities/debug_subsystem/r_debug_subsystem.h
new file mode 100644
index 0000000..8ab63cf
--- /dev/null
+++ b/lcmodule/source/cnh1605551_ldr_utilities/debug_subsystem/r_debug_subsystem.h
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _R_DEBUG_SUBSYTEM_H_
+#define _R_DEBUG_SUBSYTEM_H_
+
+/**
+ * @addtogroup ldr_utilities
+ * @{
+ * @addtogroup debug_subsystem
+ * @{
+ * This module handles putting the debug messages into debug queue.
+ * @li Inserting messages in debug queue is re-entrant process.
+ * @li Reading from debug queue is performed by call of PC side.
+ * @li This module provide circular storage of printout messages. This
+ * means that in cases of queue overflowing the oldest messages will be
+ * overwritten by the newest messages.
+ * @li For Windows Loader this feature is currently not supported.
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+#include "t_debug_subsystem.h"
+
+/*******************************************************************************
+ * Defines
+ ******************************************************************************/
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+#define printf(...) lcm_printf(__VA_ARGS__)
+#else
+/**
+ * This define replace printf function with ddebug_printf variadic macro.
+ */
+#define printf ddebug_printf
+#endif /*CFG_ENABLE_LOADER_TYPE*/
+
+/**
+ * Function-like macro. This macro will write messages in debug queue. Also this
+ * macro take care about initialization of debug queue.
+ */
+#define ddebug_printf(...) debug_printf(__VA_ARGS__)
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+#ifndef CFG_ENABLE_LOADER_TYPE
+void lcm_printf(const char *format, ...);
+#else
+/**
+ * Calls function 'circular_printf'. If debug queue is not initialized this
+ * function takes care for initialization and than redidrect input parameters to
+ * 'circular_printf' function.
+ *
+ * @param [in] *format The string constant format provides a description of the
+ * output, with placeholders marked by "%" escape
+ * characters, to specify both the relative location and the
+ * type of output that the function should produce.(Standard
+ * definition for library 'printf' function).
+ * @return None.
+ */
+void debug_printf(const char *format, ...);
+
+/**
+ * This function collect all messages from debug queue and copy them inside one
+ * memory space (buffer). First printout message in resulting buffer will be
+ * first printout that is accepted and last message in buffer is last message
+ * received by the time that this function is called.
+ *
+ * @param[in, out] Data_pp Point to pointer that should be initialized to point
+ * on outgoing buffer.
+ *
+ * @return Number of characters successfully readied from debug
+ * queue.
+ */
+uint32 Do_ReadDebugQueue(void **Data_pp);
+
+/**
+ * This function destroys debug queue including all memory spaces allocated for
+ * debug messages(printouts).
+ *
+ * @param[in] Queue_pp Pointer to the debug queue structure to destroy.
+ * @return none.
+ */
+void Do_DestroyDebugQueue(void **const Queue_pp);
+#endif /*CFG_ENABLE_LOADER_TYPE*/
+
+/** @} */
+/** @} */
+#endif /*_R_DEBUG_SUBSYTEM_H_*/
diff --git a/lcmodule/source/cnh1605551_ldr_utilities/debug_subsystem/t_debug_subsystem.h b/lcmodule/source/cnh1605551_ldr_utilities/debug_subsystem/t_debug_subsystem.h
new file mode 100644
index 0000000..5e398f7
--- /dev/null
+++ b/lcmodule/source/cnh1605551_ldr_utilities/debug_subsystem/t_debug_subsystem.h
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _T_DEBUG_SUBSYTEM_H_
+#define _T_DEBUG_SUBSYTEM_H_
+
+/**
+ * @addtogroup ldr_utilities
+ * @{
+ * @addtogroup debug_subsytem
+ * @{
+ */
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+/** Number of messages that can be inserted in debug queue */
+#define MAX_NUMBER_OF_MESSAGES (1000)
+
+/** Type of debug output channel */
+typedef enum {
+ OUTPUT_CHANNEL_DEBUG_BUFFER = 0,
+ OUTPUT_CHANNEL_UART0,
+} Debug_Output_Channel_t;
+
+/** @} */
+/** @} */
+#endif /*_T_DEBUG_SUBSYTEM_H_*/
diff --git a/lcmodule/source/cnh1605551_ldr_utilities/include/r_debug_macro.h b/lcmodule/source/cnh1605551_ldr_utilities/include/r_debug_macro.h
new file mode 100644
index 0000000..43f9e88
--- /dev/null
+++ b/lcmodule/source/cnh1605551_ldr_utilities/include/r_debug_macro.h
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _R_DEBUG_MACRO_H_
+#define _R_DEBUG_MACRO_H_
+
+/**
+ * @addtogroup ldr_utilities
+ * @{
+ * @addtogroup debug_macro
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+#include "r_debug.h"
+#ifdef CFG_ENABLE_PRINT_SERVER
+#include "r_debug_subsystem.h"
+#endif
+
+#define IRQ_MASK 0x00000080
+#define FIQ_MASK 0x00000040
+#define INT_MASK (IRQ_MASK | FIQ_MASK)
+
+#if !defined(UART_DEBUG_PORT) && defined(MACH_TYPE_STN8500)
+#define UART_DEBUG_PORT 2
+#endif
+
+#if !defined(UART_DEBUG_PORT) && defined(MACH_TYPE_DB5700)
+#define UART_DEBUG_PORT 0
+#endif
+
+/*******************************************************************************
+ * 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__))
+#define INT_DISABLE()
+#else
+#ifdef MACH_TYPE_DB5700
+#define INT_DISABLE() \
+ register int r0; \
+ __asm("MRS r0, CPSR"); \
+ __asm("ORR r0, r0, #INT_MASK"); \
+ __asm("MSR CPSR_c, r0");
+#else
+#ifdef MACH_TYPE_STN8500
+#define INT_DISABLE() \
+ __asm__ __volatile__ ("MRS r0, CPSR \n\t" \
+ "ORR r0, r0, %[mask] \n\t" \
+ "MSR CPSR_c, r0" \
+ : :[mask]"r"(INT_MASK): "r0", "cc");
+#endif
+#endif
+#endif
+
+/*******************************************************************************
+ * Macros for handling fatal and non - fatal errors.
+ ******************************************************************************/
+#ifndef ENABLE_DEBUG
+#define VERIFY(Condition,ErrorCode)\
+ do \
+ { \
+ if(!(Condition)) \
+ { \
+ ReturnValue = (ErrorCode); \
+ goto ErrorExit; \
+ } \
+ } while(0)
+
+#define VERIFY_NO_DEBUG(Condition,ErrorCode) VERIFY(Condition,ErrorCode)
+
+#ifndef CFG_ENABLE_ADBG_LOADER
+
+#define ASSERT(Condition)\
+ do \
+ { \
+ if(!(Condition)) \
+ { \
+ {\
+ INT_DISABLE()\
+ }\
+ while(1); \
+ } \
+ } while(0)
+
+#define ASSERT_NO_DEBUG(Condition) ASSERT(Condition)
+
+#else//CFG_ENABLE_ADBG_LOADER
+
+#define ASSERT(Condition)\
+ do \
+ { \
+ if(!(Condition)) \
+ { \
+ } \
+ } while(0)
+
+#define ASSERT_NO_DEBUG(Condition) ASSERT(Condition)
+
+#endif //CFG_ENABLE_ADBG_LOADER
+
+#else //ENABLE_DEBUG
+
+/* VERIFY macro definition
+* Verifies the condition and sets the appropriate return value
+* if needed before branching the execution to ErrorExit
+* This macro prints out debug info string indicating
+* verification failure */
+#define VERIFY(Condition,ErrorCode)\
+ do \
+ { \
+ if(!(Condition)) \
+ { \
+ ReturnValue = (ErrorCode); \
+ A_(printf("%s (%d): ** Verification failed! Error:(%d) **\n",__FILE__,__LINE__,(ErrorCode));)\
+ goto ErrorExit; \
+ } \
+ } while(0)
+
+/* NO-DEBUG version of the VERIFY macro
+ * Verifies the condition and sets the appropriate return value
+ * if needed before branching the execution to ErrorExit
+ * This macro does not print out debug info string indicating
+ * verification failure */
+#define VERIFY_NO_DEBUG(Condition,ErrorCode)\
+ do \
+ { \
+ if(!(Condition)) \
+ { \
+ ReturnValue = (ErrorCode); \
+ goto ErrorExit; \
+ } \
+ } while(0)
+
+#ifndef CFG_ENABLE_ADBG_LOADER
+
+#define ASSERT(Condition)\
+ do \
+ { \
+ if(!(Condition)) \
+ { \
+ A_(printf("%s (%d): ** Assert failed **\n",__FILE__, __LINE__);)\
+ {\
+ INT_DISABLE()\
+ }\
+ while(1); \
+ } \
+ } while(0)
+
+#define ASSERT_NO_DEBUG(Condition)\
+ do \
+ { \
+ if(!(Condition)) \
+ { \
+ {\
+ INT_DISABLE()\
+ }\
+ while(1); \
+ } \
+ } while(0)
+
+#else//CFG_ENABLE_ADBG_LOADER
+
+#define ASSERT(Condition)\
+ do \
+ { \
+ if(!(Condition))\
+ { \
+ A_(printf("%s (%d): ** Assert failed **\n",__FILE__, __LINE__);)\
+ } \
+ } while(0)
+
+#define ASSERT_NO_DEBUG(Condition)\
+ do \
+ { \
+ } while(0)
+
+#endif //CFG_ENABLE_ADBG_LOADER
+
+#endif //ENABLE_DEBUG
+
+/** @} */
+/** @} */
+#endif /*_R_DEBUG_MACRO_H_*/
diff --git a/lcmodule/source/cnh1605551_ldr_utilities/include/r_memmory_utils.h b/lcmodule/source/cnh1605551_ldr_utilities/include/r_memmory_utils.h
new file mode 100644
index 0000000..fb4d54f
--- /dev/null
+++ b/lcmodule/source/cnh1605551_ldr_utilities/include/r_memmory_utils.h
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _R_MEMMORY_UTILS_H_
+#define _R_MEMMORY_UTILS_H_
+
+/**
+ * @addtogroup ldr_utilities
+ * @{
+ * @addtogroup memmory_utils
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <stdlib.h>
+#include "error_codes.h"
+#include "t_basicdefinitions.h"
+#ifdef CFG_ENABLE_LOADER_TYPE
+#include "cpu_support.h"
+
+/*******************************************************************************
+ * Macro that release allocated memory space in heap.
+ ******************************************************************************/
+#define BUFFER_FREE(Buffer) \
+if (NULL != (Buffer)) \
+{ \
+ CPU_Irq_State_t IRQ_status; \
+ \
+ IRQ_status = CPU_IrqDisable();\
+ free(Buffer); \
+ (Buffer) = NULL; \
+ \
+ if (IRQ_status == CPU_IRQ_ENABLE)\
+ {\
+ CPU_IrqEnable();\
+ }\
+}
+#else //CFG_ENABLE_LOADER_TYPE
+#define BUFFER_FREE(Buffer) \
+if (NULL != (Buffer)) \
+{ \
+ free(Buffer); \
+ (Buffer) = NULL; \
+}
+#endif // CFG_ENABLE_LOADER_TYPE
+
+/**
+ * Macro that check alignment. If variable is not aligned it set the status
+ * variable ReturnValue to appropriate error code and send the function to error
+ * label.
+ *
+ * @param [in] x Variable for alignemend check.
+ *
+ * @sigbased No - Macro
+ */
+#define IS_ALIGNED(x) if(((x) & 3)) \
+ { \
+ ReturnValue = E_UNALIGNED_DATA; \
+ goto ErrorExit; \
+ } \
+
+/** @} */
+/** @} */
+#endif /*_R_MEMMORY_UTILS_H_*/
diff --git a/lcmodule/source/cnh1605551_ldr_utilities/include/r_queue.h b/lcmodule/source/cnh1605551_ldr_utilities/include/r_queue.h
new file mode 100644
index 0000000..06e9d17
--- /dev/null
+++ b/lcmodule/source/cnh1605551_ldr_utilities/include/r_queue.h
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _R_QUEUE_H_
+#define _R_QUEUE_H_
+
+/**
+ * @addtogroup ldr_utilities
+ * @{
+ * @addtogroup queue
+ * @{
+ * Implementation of FIFO queue.
+ * Functions which names begin with Do_Fifo_* are non-reentrant.
+ * Functions which names begin with Do_RFifo_* are reentrant.
+ * Functions that are not interrupt safe are faster than the interrupt safe
+ * functions.
+ *
+ * @remark None of the functions check the sanity of the input parameters.
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_queue.h"
+#include "error_codes.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+/**
+ * @brief Creates a queue.
+ *
+ * @param [in] Object_p Pointer to LCM instance context.
+ * @param [out] Queue_pp After execution points to the allocated space
+ * for the queue.
+ * @param [in] MaxLength The maximum number of entries in the queue.
+ * @param [in] DestroyElement Pointer to user defined function that
+ * deallocates resources allocated for the
+ * elements in the queue. NULL if there is no need
+ * for deallocating resource.
+ */
+void Do_Fifo_Create(void *Object_p,
+ void **const Queue_pp,
+ const uint32 MaxLength,
+ void (*DestroyElement)(void *Element_p));
+
+/**
+ * @brief Releases any resources associated with the specified queue structure.
+ *
+ * @param [in] Object_p Pointer to LCM instance context.
+ * @param [in,out] Queue_pp Pointer to the queue structure to destroy.
+ */
+void Do_Fifo_Destroy(void *Object_p, void **const Queue_pp);
+
+/**
+ * @brief Enqueueing of pointers.
+ *
+ * @note Enqueueing and dequeueing are mutually reentrant, and all functions are
+ * reentrant across different queues, but enqueueing on the same queue is
+ * not necessarily reentrant.
+ *
+ * @param [in] Object_p - Pointer to LCM instance context.
+ * @param [in] Queue_p - The queue to append to.
+ * @param [in] Value_p - The value to enqueue.
+ * @return E_SUCCESS - The function completed successfully.
+ *
+ * @return E_FAILED_TO_STORE_IN_FIFO - Faliled to store data in fifo.
+ */
+ErrorCode_e Do_Fifo_Enqueue(void *Object_p,
+ void *const Queue_p,
+ void *const Value_p);
+
+/**
+ * @brief Dequeueing of pointers.
+ *
+ * Dequeueing function of a reentrant, interrupt-safe FIFO queue.
+ *
+ * @note Enqueueing and dequeueing are mutually reentrant, and all functions are
+ * reentrant across different queues, but dequeueing on the same queue is
+ * not necessarily reentrant.
+ *
+ * @param [in] Object_p Pointer to LCM instance context.
+ * @param [in] Queue_p The queue to take an item from.
+ *
+ * @return The first pointer in the queue on success or NULL if
+ * the queue is empty. Note that an enqueued NULL
+ * pointer will be de-queued as a NULL pointer.
+ */
+void *Do_Fifo_Dequeue(void *Object_p, void *const Queue_p);
+
+/**
+ * @brief Registers an event listener for the specified queue.
+ *
+ * @note Only one listener per queue and event type is allowed.
+ * @note A function invocation does not guarantee that the state of the queue is
+ * the same as the end-transition state, only that such a transition has
+ * happened.
+ *
+ * @param [in] Object_p Pointer to LCM instance context.
+ * @param [in] Queue_p The queue for which to register a callback.
+ * @param [in] Type The type of event to register the callback for.
+ * A value of EMPTY indicates that the specified callback
+ * function should be called each time queue has
+ * transitioned from a non-empty state to an empty state.
+ * A value of NONEMPTY indicates that the callback func.
+ * should be called each time the queue has transitioned
+ * from an empty to a non-empty state.
+ * @param [in] Callback The function to call when the specified event occurs
+ * or NULL to unregister a previously registered function.
+ * @param [in] Param_p Parameter to pass to the callback function.
+ * @return The previously registered callback function for this
+ * type.
+ * @return NULL If no callback was previously registered.
+ */
+QueueCallback_fn Do_Fifo_SetCallback(void *Object_p, void *const Queue_p,
+ const QueueCallbackType_e Type,
+ const QueueCallback_fn Callback,
+ void *const Param_p);
+
+/**
+ * @brief Determines the empty-status of the queue.
+ *
+ * @param [in] Object_p Pointer to LCM instance context.
+ * @param [in] Queue_p The queue to inspect.
+ * @return TRUE If Fifo is empty or
+ * @return FALSE If Fifo is not empty.
+ */
+boolean Do_Fifo_IsEmpty(void *Object_p, const void *const Queue_p);
+
+/**
+ * @brief Checks if the provided element is member of the fifo.
+ *
+ * @param [in] Object_p Pointer to LCM instance context.
+ * @param [in] Queue_p The queue to search for element.
+ * @param [in] Value_p The element to be searched in the queue.
+ * @param [in] Match Function that checks if two elements match.
+ * @retval TRUE If the element is member of the fifo.
+ * @retval FALSE If the element is not member of the fifo.
+ */
+boolean Do_Fifo_IsMember(void *Object_p,
+ const void *const Queue_p,
+ void *Value_p,
+ boolean(*Match)(void *Value1_p, void *Value2_p));
+
+/**
+ * @brief Returns the number of elements in the queue.
+ *
+ * @param [in] Object_p Pointer to LCM instance context.
+ * @param [in] Queue_p Pointer to the queue.
+ * @return Number of elements in the queue.
+ */
+int Do_Fifo_GetNrOfElements(void *Object_p, const void *const Queue_p);
+
+
+/**
+ * @brief Creates a queue.
+ *
+ * @param [in] Object_p Pointer to LCM instance context.
+ * @param [out] Queue_pp After execution points to the allocated
+ * space for the queue.
+ * @param [in] MaxLength The maximum number of entries in the queue.
+ * @param [in] DestroyElement Pointer to user defined function that deallocates
+ * resources allocated for the elements in the
+ * queue. NULL if there is no need for deallocating
+ * resource.
+ */
+void Do_RFifo_Create(void *Object_p,
+ void **const Queue_pp,
+ const uint32 MaxLength,
+ void (*DestroyElement)(void *Element_p));
+
+/**
+ * @brief Releases any resources associated with the specified queue structure.
+ *
+ * @param [in] Object_p - Pointer to LCM instance context.
+ * @param [in,out] Queue_pp - Pointer to the queue structure to destroy.
+ */
+void Do_RFifo_Destroy(void *Object_p, void **const Queue_pp);
+
+/**
+ * @brief Enqueueing of pointers.
+ *
+ * Enqueueing function of a re-entrant, interrupt-safe FIFO queue.
+ *
+ * @param [in] Object_p - Pointer to LCM instance context.
+ * @param [in] Queue_p - The queue to append to.
+ * @param [in] Value_p - The value to enqueue.
+ * @return E_SUCCESS - The function completed successfully.
+ *
+ * @return E_FAILED_TO_STORE_IN_FIFO - Faliled to store data in fifo.
+ */
+ErrorCode_e Do_RFifo_Enqueue(void *Object_p,
+ void *const Queue_p,
+ void *const Value_p);
+
+/**
+ * @brief Dequeueing of pointers.
+ *
+ * Dequeueing function of a reentrant, interrupt-safe FIFO queue.
+ *
+ * @param [in] Object_p Pointer to LCM instance context.
+ * @param [in] Queue_p The queue to take an item from.
+ * @return The first pointer in the queue on success or NULL if
+ * the queue is empty. Note that an enqueued NULL-pointer
+ * will be de - queued as a NULL pointer.
+ */
+void *Do_RFifo_Dequeue(void *Object_p, void *const Queue_p);
+
+/**
+ * @brief Registers an event listener for the specified queue.
+ *
+ * @note Only one listener per queue and event type is allowed.
+ * @note A function invocation does not guarantee that the state of the queue is
+ * the same as the end-transition state, only that such a transition has
+ * happened.
+ *
+ * @param [in] Object_p Pointer to LCM instance context.
+ * @param [in] Queue_p The queue for which to register a callback.
+ * @param [in] Type The type of event to register the callback for.
+ * - A value of EMPTY indicates that the specified
+ * callback function should be called each time queue has
+ * transitioned from a non-empty state to an empty state.
+ * - A value of NONEMPTY indicates that the callback
+ * function should be called each time the queue has
+ * transitioned from an empty to a non-empty state.
+ * @param [in] Callback The function to call when the specified event occurs
+ * or NULL to unregister a previously registered func.
+ * @param [in] Param_p Parameter to pass to the callback function.
+ * @return The previously registered callback function for this
+ * type.
+ * @return NULL If no callback was previously registered.
+ */
+QueueCallback_fn Do_RFifo_SetCallback(void *Object_p, void *const Queue_p,
+ const QueueCallbackType_e Type,
+ const QueueCallback_fn Callback,
+ void *const Param_p);
+
+/**
+ * @brief Determines the empty-status of the queue.
+ *
+ * @param [in] Object_p Pointer to LCM instance context.
+ * @param [in] Queue_p The queue to inspect.
+ * @retval TRUE If Fifo is empty or FALSE if is not empty.
+ */
+boolean Do_RFifo_IsEmpty(void *Object_p, const void *const Queue_p);
+
+/**
+ * @brief Checks if the provided element is member of the fifo.
+ *
+ * @param [in] Object_p Pointer to LCM instance context.
+ * @param [in] Queue_p The queue to search for element.
+ * @param [in] Value_p The element to be searched in the queue.
+ * @param [in] Match Function that checks if two elements match.
+ * @retval TRUE If the element is member of the fifo.
+ * @retval FALSE If the element is not member of the fifo.
+ */
+boolean Do_RFifo_IsMember(void *Object_p,
+ const void *const Queue_p,
+ void *Value_p,
+ boolean(*Match)(void *Value1_p, void *Value2_p));
+
+/**
+ * @brief Returns the number of elements in the queue.
+ *
+ * @param [in] Object_p Pointer to LCM instance context.
+ * @param [in] Queue_p Pointer to the queue.
+ * @return Number of elements in the queue.
+ */
+int Do_RFifo_GetNrOfElements(void *Object_p, const void *const Queue_p);
+
+/** @} */
+/** @} */
+#endif /*_R_QUEUE_H_*/
diff --git a/lcmodule/source/cnh1605551_ldr_utilities/include/r_serialization.h b/lcmodule/source/cnh1605551_ldr_utilities/include/r_serialization.h
new file mode 100644
index 0000000..b0cebd6
--- /dev/null
+++ b/lcmodule/source/cnh1605551_ldr_utilities/include/r_serialization.h
@@ -0,0 +1,380 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _R_SERIALIZATION_H_
+#define _R_SERIALIZATION_H_
+
+/**
+ * @addtogroup ldr_utilities
+ * @{
+ * @addtogroup serialization
+ * @{
+ * This module contains functions for serialization of data.
+ * @n The reason for having this kind of functions is to ease the
+ * manipulation of data and to simplify the code.
+ * @n The functions are divided in three groups:@n
+ * @li get_* functions:
+ * Used for extracting data from a memory location specified
+ * by the input pointer.
+ * @li put_* functions:
+ * Used for placing data at the memory location specified by the input
+ * pointer.
+ * @li skip_* functions:
+ * Used for skipping the data, without changing it.
+ * @n After call to anyone of this functions the input pointer is
+ * incremented for the number of bytes that are extracted, placed or
+ * skipped.
+ *
+ * @remark None of the functions perform a sanity check of the input
+ * parameters. It is the responsibility of the developer to make sure
+ * that the arguments passed to these functions are valid.
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+#include "t_serialization.h"
+#include "command_ids.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+/**
+ * @brief Reads 1 byte from @p data_pp.
+ *
+ * Reads 1 byte from @p *data_pp and increases
+ * @p *data_pp for 1 byte.
+ *
+ * @param [in,out] data_pp Source.
+ * @return An @p uint8 from @p *data_pp.
+ */
+uint8 get_uint8(void **data_pp);
+
+/**
+ * @brief Reads 2 bytes from @p data_pp.
+ *
+ * Reads @p 2 bytes from @p *data_pp and increases
+ * @p *data_pp by 2 bytes. The bytes are considered to
+ * be in Little Endian order.
+ *
+ * @param [in,out] data_pp Source.
+ * @return An @p uint16 from @p *data_pp.
+ */
+uint16 get_uint16_le(void **data_pp);
+
+/**
+ * @brief Reads 2 bytes from @p data_pp.
+ *
+ * Reads 2 bytes from @p *data_pp and increases
+ * @p *data_pp by 2 bytes. The bytes are considered to
+ * be in Big Endian order.
+ *
+ * @param [in,out] data_pp Source.
+ * @return An @p uint16 from @p *data_pp.
+ */
+uint16 get_uint16_be(void **data_pp);
+
+/**
+ * @brief Reads 4 bytes from @p data_pp.
+ *
+ * Reads 4 bytes from @p *data_pp and increases
+ * @p *data_pp by 4 bytes. The bytes are considered to
+ * be in Little Endian order.
+ *
+ * @param [in,out] data_pp Source.
+ * @return An @p uint32 from @p *data_pp.
+ */
+uint32 get_uint32_le(void **data_pp);
+
+/**
+ * @brief Reads 4 bytes from @p data_pp.
+ *
+ * Reads 8 bytes from @p *data_pp and increases
+ * @p *data_pp by 8 bytes. The bytes are considered to
+ * be in Little Endian order.
+ *
+ * @param [in,out] data_pp Source.
+ * @return An @p uint64 from @p *data_pp.
+ */
+uint64 get_uint64_le(void **data_pp);
+
+/**
+ * @brief Reads 4 bytes from @p data_pp.
+ *
+ * Reads 4 bytes from @p *data_pp. The bytes are considered to
+ * be in Little Endian order.
+ *
+ * @param [in,out] data_pp Source.
+ * @return An @p uint32 from @p *data_pp.
+ */
+uint32 get_uint32_string_le(void **data_pp);
+
+/**
+ * @brief Reads 4 bytes from @p data_pp.
+ *
+ * Reads 4 bytes from @p *data_pp and increases
+ * @p *data_pp by 4 bytes. The bytes are considered to
+ * be in Big Endian order.
+ *
+ * @param [in,out] data_pp Source.
+ * @return An @p uint32 from @p *data_pp.
+ */
+uint32 get_uint32_be(void **data_pp);
+
+/**
+ * @brief Writes 1 byte to @p data_pp.
+ *
+ * Writes 1 byte to @p *data_pp and increases
+ * @p *data_pp by 1 byte.
+ *
+ * @param [in,out] data_pp Destination.
+ * @param [in] v Value.
+ * @return void.
+ */
+void put_uint8(void **data_pp,
+ uint8 v);
+
+/**
+ * @brief Writes 2 bytes to @p data_pp.
+ *
+ * Writes 2 byte to @p *data_pp and increases
+ * @p *data_pp by 2 byte. The bytes are written
+ * in Little Endian Order.
+ *
+ * @param [in,out] data_pp Destination.
+ * @param [in] v Value.
+ * @return void.
+ */
+void put_uint16_le(void **data_pp,
+ uint16 v);
+
+/**
+ * @brief Writes 2 bytes to @p data_pp.
+ *
+ * Writes 2 byte to @p *data_pp and increases
+ * @p *data_pp by 2 byte. The bytes are written
+ * in Big Endian Order.
+ *
+ * @param [in,out] data_pp Destination.
+ * @param [in] v Value.
+ * @return void.
+ */
+void put_uint16_be(void **data_pp,
+ uint16 v);
+
+/**
+ * @brief Writes 4 bytes to @p data_pp.
+ *
+ * Writes 4 byte to @p *data_pp and increases
+ * @p *data_pp by 4 byte. The bytes are written
+ * in Little Endian Order.
+ *
+ * @param [in,out] data_pp Destination.
+ * @param [in] v Value.
+ * @return void.
+ */
+void put_uint32_le(void **data_pp,
+ uint32 v);
+
+/**
+ * @brief Writes 4 bytes to @p data_pp.
+ *
+ * Writes 4 byte to @p *data_pp and increases
+ * @p *data_pp by 4 byte. The bytes are written
+ * in Big Endian Order.
+ *
+ * @param [in,out] data_pp Destination.
+ * @param [in] v Value.
+ * @return void.
+ */
+void put_uint32_be(void **data_pp,
+ uint32 v);
+
+/**
+ * @brief Writes 8 bytes to @p data_pp.
+ *
+ * Writes 8 byte to @p *data_pp and increases
+ * @p *data_pp by 4 byte. The bytes are written
+ * in Little Endian Order.
+ *
+ * @param [in,out] data_pp Destination.
+ * @param [in] v Value.
+ * @return void.
+ */
+void put_uint64_le(void **data_pp,
+ uint64 v);
+
+/**
+ * @brief Writes 8 bytes to @p data_pp.
+ *
+ * Writes 8 byte to @p *data_pp and increases
+ * @p *data_pp by 8 byte. The bytes are written
+ * in Big Endian Order.
+ *
+ * @param [in,out] data_pp Destination.
+ * @param [in] v Value.
+ * @return void.
+ */
+void put_uint64_be(void **data_pp,
+ uint64 v);
+
+/**
+ * @brief Skips 1 byte from @p data_pp.
+ *
+ * Skips 1 byte from data_pp, and increases @p data_pp
+ * for 1 byte.
+ *
+ * @param [in,out] data_pp Destination.
+ * @return void.
+ */
+void skip_uint8(void **data_pp);
+
+/**
+ * @brief Skips 2 byte from @p data_pp.
+ *
+ * Skips 2 byte from data_pp, and increases @p data_pp
+ * for 2 byte.
+ *
+ * @param [in,out] data_pp Destination.
+ * @return void.
+ */
+void skip_uint16(void **data_pp);
+
+/**
+ * @brief Skips 4 byte from @p data_pp.
+ *
+ * Skips 4 byte from data_pp, and increases @p data_pp
+ * for 4 byte.
+ *
+ * @param [in,out] data_pp Destination.
+ * @return void.
+ */
+void skip_uint32(void **data_pp);
+
+/**
+ * @brief Copies bytes from @p data_pp to @p target_p.
+ *
+ * Copies @p length bytes from @p data_pp to @p target_p,
+ * increasing @p data_pp by @p length.
+ *
+ * @param [in,out] data_pp Source.
+ * @param [out] target_p Destination.
+ * @param [in] length Length of block.
+ * @return void.
+ */
+void get_block(const void **data_pp,
+ void *target_p,
+ uint32 length);
+
+/**
+ * @brief Copies bytes from @p source_p to @p data_pp.
+ *
+ * Copies @p length bytes from @p source_p to @p data_pp, increasing
+ * @p data_pp by @p length.
+ *
+ * @param [in,out] data_pp Source.
+ * @param [out] source_p Destination.
+ * @param [in] length Length of block.
+ * @return void.
+ */
+void put_block(void **data_pp,
+ const void *source_p,
+ uint32 length);
+
+/**
+ * @brief Copies bytes from @p source_p to @p data_pp.
+ *
+ * First is copied Length of the buffer (source_p) in the data_pp then.
+ * is copied @p length bytes from @p source_p to @p data_pp, increasing
+ * @p data_pp by @p length.
+ *
+ * @param [in,out] data_pp Source.
+ * @param [out] source_p Destination.
+ * @param [in] length Length of block.
+ * @return void.
+ */
+void put_string(void **data_pp,
+ const void *source_p,
+ uint32 length);
+
+/**
+ * @brief Skips a block of length @p length from @p data_pp.
+ *
+ * Skips a block of length @p length from @p data_pp.
+ *
+ * @param [in,out] data_pp Source.
+ * @param [in] length Length of block.
+ * @return void.
+ */
+void skip_block(void **data_pp,
+ uint32 length);
+
+/**
+ * @brief Skips a block of length of the string from @p data_pp.
+ *
+ * @param [in,out] data_pp Source.
+ * @return Pointer to where data_pp was before calling this function.
+ */
+char *skip_str(void **data_pp);
+
+
+/**
+ * @brief Get directory entries length...TODO: should be explained.
+ *
+ * @param [out] source_p Source.
+ * @param [in] DirectoryEntriesCount Entry counter.
+ * @return Entry length.
+ */
+uint32 get_directory_entries_len(const DirEntry_t *source_p,
+ uint32 DirectoryEntriesCount);
+
+/**
+ * @brief Serialize directory entries...TODO: should be explained.
+ *
+ * @param [out] data_pp /...TODO: should be explained.
+ * @param [in] source_p Source.
+ * @param [in] DirectoryEntriesCount Entry counter.
+ * @return void.
+ */
+void serialize_directory_entries(void **data_pp,
+ const DirEntry_t *source_p,
+ uint32 DirectoryEntriesCount);
+
+/**
+ * @brief Get device entry length...TODO: should be explained.
+ *
+ * @param [out] source_p Source.
+ * @param [in] DeviceEntriesCount Entry counter.
+ * @return Entry length.
+ */
+uint32 get_device_entries_len(const ListDevice_t *source_p,
+ uint32 DeviceEntriesCount);
+
+/**
+ * @brief Serialize device entries...TODO: should be explained.
+ *
+ * @param [out] data_pp /...TODO: should be explained.
+ * @param [in] source_p Source.
+ * @param [in] DeviceEntriesCount Entry counter.
+ * @return void.
+ */
+void serialize_device_entries(void **data_pp,
+ const ListDevice_t *source_p,
+ uint32 DeviceEntriesCount);
+
+/**
+ * @brief Serialize device entries...TODO: should be explained.
+ *
+ * @param [out] data_pp /...TODO: should be explained.
+ * @param [in] source_p Source.
+ * @param [in] length length of source string.
+ * @return void.
+ */
+void insert_string(char **data_pp, const char *source_p, uint32 length);
+
+/** @} */
+/** @} */
+#endif /*_R_SERIALIZATION_H_*/
diff --git a/lcmodule/source/cnh1605551_ldr_utilities/include/t_queue.h b/lcmodule/source/cnh1605551_ldr_utilities/include/t_queue.h
new file mode 100644
index 0000000..f6250b6
--- /dev/null
+++ b/lcmodule/source/cnh1605551_ldr_utilities/include/t_queue.h
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _T_QUEUE_H_
+#define _T_QUEUE_H_
+
+/**
+ * @addtogroup ldr_utilities
+ * @{
+ * @addtogroup queue
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/** type of queue callback functions. */
+typedef enum {
+ QUEUE_EMPTY,
+ QUEUE_NONEMPTY
+} QueueCallbackType_e;
+
+/**
+ * Typedef of callback function used for the queue.
+ * One callback function is used when the fifo is empty,
+ * and another when the fifo is nonempty.
+ * These function are set by calling Do_Fifo_SetCallback.
+ *
+ * @param [in] Queue_p pointer to a valid queue(One that is created using
+ * Do_Fifo_Create).
+ * @param [in] Param_p additional parameters to the function.
+ * @return None.
+ */
+typedef void (*QueueCallback_fn)(const void *const Queue_p, void *Param_p);
+
+/** @} */
+/** @} */
+#endif /*T_QUEUE_H_*/
diff --git a/lcmodule/source/cnh1605551_ldr_utilities/include/t_serialization.h b/lcmodule/source/cnh1605551_ldr_utilities/include/t_serialization.h
new file mode 100644
index 0000000..0a8299e
--- /dev/null
+++ b/lcmodule/source/cnh1605551_ldr_utilities/include/t_serialization.h
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _T_SERIALIZATION_H_
+#define _T_SERIALIZATION_H_
+
+/**
+ * @addtogroup ldr_utilities
+ * @{
+ * @addtogroup serialization
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/** By default we use Little Endian ordering, this macro is declared to simplify
+ the calling of the function. */
+#define get_uint16 get_uint16_le
+/** By default we use Little Endian ordering, this macro is declared to simplify
+ the calling of the function. */
+#define get_uint32 get_uint32_le
+/** By default we use Little Endian ordering, this macro is declared to simplify
+ the calling of the function. */
+#define put_uint16 put_uint16_le
+/** By default we use Little Endian ordering, this macro is declared to simplify
+ the calling of the function. */
+#define put_uint32 put_uint32_le
+
+/** @} */
+/** @} */
+#endif /*T_SERIALIZATION_H_*/
diff --git a/lcmodule/source/cnh1605551_ldr_utilities/source/serialization.c b/lcmodule/source/cnh1605551_ldr_utilities/source/serialization.c
new file mode 100644
index 0000000..3b6377f
--- /dev/null
+++ b/lcmodule/source/cnh1605551_ldr_utilities/source/serialization.c
@@ -0,0 +1,329 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/*
+ * @addtogroup ldr_utilities
+ * @{
+ * @addtogroup serialization
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "r_serialization.h"
+#include <string.h>
+#include <stdlib.h>
+#include "r_debug_macro.h"
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+void get_block(const void **data_pp, void *target_p, uint32 length)
+{
+ memcpy(target_p, *data_pp, length);
+ *(const uint8 **)data_pp += length;
+}
+
+uint8 get_uint8(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **)data_pp;
+ *(const uint8 **)data_pp += sizeof(uint8);
+ return d[0];
+}
+
+uint16 get_uint16_le(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **)data_pp;
+ *(const uint8 **)data_pp += sizeof(uint16);
+ return (d[1] << 8) | d[0];
+}
+
+uint16 get_uint16_be(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **)data_pp;
+ *(const uint8 **)data_pp += sizeof(uint16);
+ return (d[0] << 8) | d[1];
+}
+
+uint32 get_uint32_le(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **) data_pp;
+ *(const uint8 **)data_pp += sizeof(uint32);
+ return ((d[3] << 8 | d[2]) << 8 | d[1]) << 8 | d[0];
+}
+
+uint64 get_uint64_le(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **) data_pp;
+ *(const uint8 **)data_pp += sizeof(uint64);
+ return (((((((uint64)d[7] << 8 | d[6]) << 8 | d[5]) << 8 | d[4]) << 8 | d[3]) << 8 | d[2]) << 8 | d[1]) << 8 | d[0];
+}
+
+uint32 get_uint32_string_le(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **) data_pp;
+ //*(const uint8 **)data_pp += sizeof(uint32);
+ return ((d[3] << 8 | d[2]) << 8 | d[1]) << 8 | (d[0] + sizeof(uint32));
+}
+
+uint32 get_uint32_be(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **) data_pp;
+ *(const uint8 **)data_pp += sizeof(uint32);
+ return ((d[0] << 8 | d[1]) << 8 | d[2]) << 8 | d[3];
+}
+
+uint32 get_directory_entries_len(const DirEntry_t *source_p, uint32 DirectoryEntriesCount)
+{
+ uint32 EntriesLen = 0;
+ uint32 i = 0;
+
+ if (DirectoryEntriesCount > 0) {
+ for (i = 0; i < DirectoryEntriesCount; i++) {
+ EntriesLen += get_uint32_string_le((void **)&source_p[i].Name_p);
+ EntriesLen += sizeof(uint32) + sizeof(uint32) + sizeof(uint64);
+ }
+ }
+
+ return EntriesLen;
+}
+
+void serialize_directory_entries(void **data_pp, const DirEntry_t *source_p, uint32 DirectoryEntriesCount)
+{
+ uint32 NameLength = 0;
+ uint32 i = 0;
+
+ if (DirectoryEntriesCount > 0) {
+ for (i = 0; i < DirectoryEntriesCount; i++) {
+ NameLength = get_uint32_string_le((void **)&source_p[i].Name_p);
+ memcpy(*data_pp, source_p[i].Name_p, NameLength);
+ *(const uint8 **)data_pp += NameLength;
+ memcpy(*data_pp, &source_p[i].Size, sizeof(uint64));
+ *(const uint8 **)data_pp += sizeof(uint64);
+ memcpy(*data_pp, &source_p[i].Mode, sizeof(uint32));
+ *(const uint8 **)data_pp += sizeof(uint32);
+ memcpy(*data_pp, &source_p[i].Time, sizeof(uint32));
+ *(const uint8 **)data_pp += sizeof(uint32);
+ }
+ }
+}
+
+uint32 get_device_entries_len(const ListDevice_t *source_p, uint32 DeviceEntriesCount)
+{
+ uint32 EntriesLen = 0;
+ uint32 i = 0;
+
+ if (DeviceEntriesCount > 0) {
+ for (i = 0; i < DeviceEntriesCount; i++) {
+ if (NULL != source_p[i].Path_p) {
+ EntriesLen += get_uint32_string_le((void **)&source_p[i].Path_p);
+ } else {
+ EntriesLen += sizeof(uint32);
+ }
+
+ if (NULL != source_p[i].Type_p) {
+ EntriesLen += get_uint32_string_le((void **)&source_p[i].Type_p);
+ } else {
+ EntriesLen += sizeof(uint32);
+ }
+
+ EntriesLen += sizeof(uint64) + sizeof(uint64) + sizeof(uint64);
+ }
+ }
+
+ return EntriesLen;
+}
+
+void serialize_device_entries(void **data_pp, const ListDevice_t *source_p, uint32 DeviceEntriesCount)
+{
+ uint32 PathLen = 0;
+ uint32 TypeLen = 0;
+ uint32 i = 0;
+
+ if (DeviceEntriesCount > 0) {
+ for (i = 0; i < DeviceEntriesCount; i++) {
+ if (NULL != source_p[i].Path_p) {
+ PathLen = get_uint32_string_le((void **)&source_p[i].Path_p);
+ memcpy(*data_pp, source_p[i].Path_p, PathLen);
+ *(const uint8 **)data_pp += PathLen;
+ } else {
+ memset(*data_pp, 0x00, sizeof(char *));
+ *(const uint8 **)data_pp += sizeof(char *);
+ }
+
+ if (NULL != source_p[i].Type_p) {
+ TypeLen = get_uint32_string_le((void **)&source_p[i].Type_p);
+ memcpy(*data_pp, source_p[i].Type_p, TypeLen);
+ *(const uint8 **)data_pp += TypeLen;
+ } else {
+ memset(*data_pp, 0x00, sizeof(char *));
+ *(const uint8 **)data_pp += sizeof(char *);
+ }
+
+ memcpy(*data_pp, &source_p[i].BlockSize, sizeof(uint64));
+ *(const uint8 **)data_pp += sizeof(uint64);
+ memcpy(*data_pp, &source_p[i].Start, sizeof(uint64));
+ *(const uint8 **)data_pp += sizeof(uint64);
+ memcpy(*data_pp, &source_p[i].Length, sizeof(uint64));
+ *(const uint8 **)data_pp += sizeof(uint64);
+ }
+ }
+}
+
+void put_block(void **data_pp, const void *source_p, uint32 length)
+{
+ if (length > 0) {
+ memcpy(*data_pp, source_p, length);
+ *(const uint8 **)data_pp += length;
+ }
+}
+
+void put_string(void **data_pp, const void *source_p, uint32 length)
+{
+ if (length > 0) {
+ memcpy(*data_pp, &length, sizeof(uint32));
+ *(const uint8 **)data_pp += sizeof(uint32);
+ memcpy(*data_pp, source_p, length);
+ *(const uint8 **)data_pp += length;
+ }
+}
+
+void put_uint8(void **data_pp, uint8 v)
+{
+ **(uint8 **) data_pp = v;
+ *(uint8 **) data_pp += sizeof(uint8);
+}
+
+void put_uint16_le(void **data_pp, uint16 v)
+{
+ uint8 *d = *(uint8 **) data_pp;
+ d[0] = v & 0xff;
+ d[1] = v >> 8;
+ *(uint8 **)data_pp += sizeof(uint16);
+}
+
+void put_uint16_be(void **data_pp, uint16 v)
+{
+ uint8 *d = *(uint8 **) data_pp;
+ d[1] = v & 0xff;
+ d[0] = v >> 8;
+ *(uint8 **)data_pp += sizeof(uint16);
+}
+
+void put_uint32_le(void **data_pp, uint32 v)
+{
+ uint8 *d = *(uint8 **) data_pp;
+ uint8 *v_p = (uint8 *)&v;
+ d[0] = v_p[0];
+ d[1] = v_p[1];
+ d[2] = v_p[2];
+ d[3] = v_p[3];
+ *(uint8 **)data_pp += sizeof(uint32);
+}
+
+void put_uint32_be(void **data_pp, uint32 v)
+{
+ uint8 *d = *(uint8 **) data_pp;
+ uint8 *v_p = (uint8 *)&v;
+ d[3] = v_p[0];
+ d[2] = v_p[1];
+ d[1] = v_p[2];
+ d[0] = v_p[3];
+ *(uint8 **)data_pp += sizeof(uint32);
+}
+
+void put_uint64_le(void **data_pp, uint64 v)
+{
+ uint8 *d = *(uint8 **) data_pp;
+ uint8 *v_p = (uint8 *)&v;
+ d[0] = v_p[0];
+ d[1] = v_p[1];
+ d[2] = v_p[2];
+ d[3] = v_p[3];
+ d[4] = v_p[4];
+ d[5] = v_p[5];
+ d[6] = v_p[6];
+ d[7] = v_p[7];
+ *(uint8 **)data_pp += sizeof(uint32);
+ *(uint8 **)data_pp += sizeof(uint32);
+}
+
+void put_uint64_be(void **data_pp, uint64 v)
+{
+ uint8 *d = *(uint8 **) data_pp;
+ uint8 *v_p = (uint8 *)&v;
+ d[7] = v_p[0];
+ d[6] = v_p[1];
+ d[5] = v_p[2];
+ d[4] = v_p[3];
+ d[3] = v_p[4];
+ d[2] = v_p[5];
+ d[1] = v_p[6];
+ d[0] = v_p[7];
+ *(uint8 **)data_pp += sizeof(uint32);
+ *(uint8 **)data_pp += sizeof(uint32);
+}
+
+void skip_uint8(void **data_pp)
+{
+ *(const uint8 **)data_pp += sizeof(uint8);
+}
+
+void skip_uint16(void **data_pp)
+{
+ *(const uint8 **)data_pp += sizeof(uint16);
+}
+
+void skip_uint32(void **data_pp)
+{
+ *(const uint8 **)data_pp += sizeof(uint32);
+}
+
+void skip_block(void **data_pp, uint32 length)
+{
+ *(const uint8 **)data_pp += length;
+}
+
+char *skip_str(void **data_pp)
+{
+ char *Result_p = NULL;
+ uint32 StrLength;
+
+ ASSERT(NULL != data_pp);
+ Result_p = *(char **)data_pp;
+ ASSERT(NULL != Result_p);
+ StrLength = get_uint32_le(data_pp);
+ *(char **)data_pp += StrLength;
+ return Result_p;
+}
+
+char *get_strdup(void *String_p)
+{
+ char *Result_p;
+ uint32 StrLength = strlen((char *)String_p) + 1;
+
+ Result_p = (char *)malloc(StrLength);
+ ASSERT(Result_p != NULL);
+
+ strncpy(Result_p, (char *)String_p, StrLength);
+ Result_p[StrLength - 1] = 0;
+ return Result_p;
+}
+
+void insert_string(char **data_pp, const char *source_p, uint32 length)
+{
+ *data_pp = NULL;
+
+ *data_pp = (char *)malloc(sizeof(uint32) + length);
+ ASSERT(NULL != *data_pp);
+
+ memcpy(*data_pp, &length, sizeof(uint32));
+ memcpy(*data_pp + sizeof(uint32), source_p, length);
+}
+
+/* @} */
+/* @} */
+
diff --git a/lcmodule/source/cnh1605720_ldr_time_utilities/include/t_time_utilities.h b/lcmodule/source/cnh1605720_ldr_time_utilities/include/t_time_utilities.h
new file mode 100644
index 0000000..5346679
--- /dev/null
+++ b/lcmodule/source/cnh1605720_ldr_time_utilities/include/t_time_utilities.h
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _T_TIME_UTILITIES_H_
+#define _T_TIME_UTILITIES_H_
+/**
+ * @addtogroup ldr_time_utilities
+ * @{
+ */
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/** MAX defined timers */
+#define MAX_TIMERS 100
+
+/** defined type of function pointer to the handle function */
+typedef void (*HandleFunction_t)(void *Param_p, void *Timer_p, void *Data_p);
+
+/**
+ * Structure of timer data
+ */
+typedef struct {
+ uint32 Time; /**< Requested for timer time.*/
+ uint32 PeriodicalTime; /**< Requested periodical time for timer.*/
+ HandleFunction_t HandleFunction_p; /**< Callback function*/
+ void *Data_p; /**< Pointer to data. */
+ void *Param_p; /**< Extra parameters. */
+ uint32 Set_Time; /**< Used for debugging purposes only. */
+ uint32 Set_System_Time; /**< Used for debugging purposes only. */
+} Timer_t;
+
+/**
+ * Header for buffer of timers
+ */
+typedef struct {
+ uint32 MaxTimers;
+ uint32 ActiveTimers;
+ Timer_t *Timers_p;
+} TimerHeader_t;
+
+/** @} */
+#endif /*_T_TIME_UTILITIES_H_*/
diff --git a/lcmodule/source/cnh1605721_ldr_security_algorithms/include/t_security_algorithms.h b/lcmodule/source/cnh1605721_ldr_security_algorithms/include/t_security_algorithms.h
new file mode 100644
index 0000000..5bae6c1
--- /dev/null
+++ b/lcmodule/source/cnh1605721_ldr_security_algorithms/include/t_security_algorithms.h
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _T_SECURITY_ALGORITHMS_H_
+#define _T_SECURITY_ALGORITHMS_H_
+/**
+ * \addtogroup ldr_security_algorithms
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_basicdefinitions.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+/** Defined value for HASH error. */
+#define HASH_ERROR 0xffffffff
+
+/** Length of SHA256 algorithm results */
+#define SHA256_LENGTH 32
+
+/** Length of CRC16 algorithm results */
+#define CRC16_LENGTH 2
+
+/** */
+#define MAX_NR_IN_QUEUE_TOKENS 16
+
+/** */
+typedef void (*HashCallback_fn)(void *Data_p, uint32 Length, uint8 *Hash_p, void *Param_p);
+
+/** Type of hash algorithm */
+typedef enum {
+ HASH_SHA256 = 0x0001, /**< 4LSB SHA-256 algorithm */
+ HASH_CRC16 = 0x0002, /**< CRC16 */
+ HASH_SIMPLE_XOR = 0x0003, /**< 4LSB Simple XOR algorithm */
+ HASH_NONE = 0x0004 /**< Communication is not hash secured */
+} HashType_e;
+
+/** @} */
+#endif /*_T_SECURITY_ALGORITHMS_H_*/
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_command_ids_h.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_command_ids_h.xsl
new file mode 100644
index 0000000..2c5a686
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_command_ids_h.xsl
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+<import href="a2_common.xsl"/>
+
+<output method="text" indent="no"/>
+<strip-space elements="*"/>
+<param name="target" />
+
+<template match="/commandspec">/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _A2_COMMAND_IDS_H
+#define _A2_COMMAND_IDS_H
+#include "t_basicdefinitions.h"
+
+TYPEDEF_ENUM {
+<apply-templates select="group" mode="id"/>} ENUM8(A2_GroupId_e);
+
+typedef enum {
+<apply-templates select="group/command" mode="id"/>} A2_CommandId_e;
+
+<apply-templates select="typedef" />
+#endif /* _A2_COMMAND_IDS_H */
+</template>
+
+<template match="typedef">
+typedef struct <value-of select="interface/@name" />_s
+{
+<apply-templates select="value" />}<value-of select="interface/@name" />_t;
+</template>
+
+<template match="value">
+ <text> </text>
+ <choose>
+ <when test="@type='string'">
+ char *<text> </text><value-of select="@name" />; /**&lt; <value-of select="text()" /> */
+ </when>
+ <when test="@type='uint32'">
+ <value-of select="@type" /><text> </text><value-of select="@name" />; /**&lt; <value-of select="text()" /> */
+ </when>
+ <when test="@type='uint64'">
+ <value-of select="@type" /><text> </text><value-of select="@name" />; /**&lt; <value-of select="text()" /> */
+ </when>
+ </choose>
+ <if test="position() = last()"><text></text>
+ </if>
+</template>
+
+<template match="group" mode="id">
+ <text> </text><call-template name="groupid" /> = <value-of select="@number" />, /**&lt; <value-of select="@name" /> */
+</template>
+
+<template match="group[last()]" mode="id">
+ <text> </text><call-template name="groupid" /> = <value-of select="@number" /> /**&lt; <value-of select="@name" /> */
+</template>
+
+<template match="command" mode="id">
+ <text> </text><call-template name="commandid" /> = <value-of select="@number" />, /**&lt; <value-of select="@name" /> */
+</template>
+
+<template match="group[last()]/command[last()]" mode="id">
+ <text> </text><call-template name="commandid" /> = <value-of select="@number" /> /**&lt; <value-of select="@name" /> */
+</template>
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_command_marshal.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_command_marshal.xsl
new file mode 100644
index 0000000..d50b0d5
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_command_marshal.xsl
@@ -0,0 +1,251 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
+
+<import href="a2_common.xsl"/>
+
+<output method="text"/>
+<strip-space elements="*"/>
+<param name="target"/>
+
+<template match="group/documentation" mode="marshal">
+/*
+ * <value-of select="normalize-space(.)"/>
+ */
+</template>
+
+<template match="group/documentation" mode="unmarshal">
+ /*
+ * <value-of select="normalize-space(.)"/>
+ */
+</template>
+
+<template name="unmarshal">
+<param name="name"/>
+<param name="direction"/>
+<choose>
+ <when test="@flag='true'">
+#ifdef CFG_ENABLE_ADBG_LOADER</when>
+</choose>
+<choose>
+<when test="name($direction)='input'">
+ /* Command <value-of select="../@name"/> / <value-of select="@name"/> (<value-of select="../@number"/> / <value-of select="@number"/>) */
+ case A2_COMMAND(FALSE, <call-template name="groupid"><with-param name="path" select=".."/></call-template>, <call-template name="commandid"/>):
+ {
+ <apply-templates select="input/value" mode="deserialize_size" />
+
+ <apply-templates select="input/value" mode="deserialize" />
+ Status = <value-of select="$name" />(Session<if test="count(input/value) > 0">, </if><apply-templates select="input/value" mode="call" />);
+ <apply-templates select="input/value" mode="clean"/>
+ }
+ break;
+</when>
+<when test="name($direction)='output'">
+ /* Response to <value-of select="../@name"/> / <value-of select="@name"/> (<value-of select="../@number"/> / <value-of select="@number"/>) */
+ case A2_COMMAND(TRUE, <call-template name="groupid"><with-param name="path" select=".."/></call-template>, <call-template name="commandid"/>):
+ {
+ <apply-templates select="output/value" mode="deserialize_size" />
+
+ <apply-templates select="output/value" mode="deserialize" />
+ Status = <value-of select="$name" />(Session<if test="count(output/value) > 0">, </if><apply-templates select="output/value" mode="call"></apply-templates>);
+ <apply-templates select="output/value" mode="clean"/>
+ }
+ break;
+</when>
+</choose>
+<choose>
+ <when test="@flag='true'">#endif
+ </when>
+</choose>
+</template>
+
+
+<template match="/commandspec">
+/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+#include &lt;string.h&gt;
+
+#include "t_command_protocol.h"
+#include "r_debug.h"
+#include "r_communication_service.h"
+#include "commands.h"
+#include "command_ids.h"
+#include "commands_impl.h"
+#include "a2_commands.h"
+#include "a2_command_ids.h"
+#include "a2_commands_impl.h"
+#include "custom_commands.h"
+#include "error_codes.h"
+#include "r_serialization.h"
+#include "r_a2_protocol.h"
+#include "r_command_protocol.h"
+#include "audit.h"
+
+#ifdef CFG_ENABLE_ADBG_LOADER
+#include "r_adbg_command.h"
+#endif
+
+#define A2_COMMAND(response, group, id) ((((int)(response)) &lt;&lt; 30) | (((int)(group)) &lt;&lt; 16) | ((int)(id)))
+#define A2_COMMANDDATA(TypeP,ApplicationP,CommandP,SessionP,SizeP) \
+ memset((uint8*)&amp;CmdData, 0x00, sizeof(CommandData_t)); \
+ CmdData.Type = TypeP; \
+ CmdData.ApplicationNr = ApplicationP; \
+ CmdData.CommandNr = CommandP; \
+ CmdData.SessionNr = SessionP; \
+ CmdData.Payload.Size = SizeP; \
+ CmdData.Payload.Data_p = NULL; \
+ CmdData.Payload.Data_p = (uint8 *)malloc(SizeP); \
+ if(NULL == CmdData.Payload.Data_p) \
+ { \
+ A_(printf("command_marshal.c (%d): ** memory allocation failed! **\n",__LINE__);) \
+ return E_ALLOCATE_FAILED; \
+ }\
+
+#define A2_COMMANDDATAOUT(TypeP,ApplicationP,CommandP,SizeP) \
+ memset((uint8*)&amp;CmdData, 0x00, sizeof(CommandData_t)); \
+ CmdData.Type = TypeP; \
+ CmdData.ApplicationNr = ApplicationP; \
+ CmdData.CommandNr = CommandP; \
+ CmdData.SessionNr = 0; \
+ CmdData.Payload.Size = SizeP; \
+ CmdData.Payload.Data_p = NULL; \
+ if(SizeP !=0)\
+ {\
+ CmdData.Payload.Data_p = (uint8 *)malloc( SizeP); \
+ if(NULL == CmdData.Payload.Data_p) \
+ { \
+ A_(printf("command_marshal.c (%d): ** memory allocation failed! **\n",__LINE__);) \
+ return E_ALLOCATE_FAILED; \
+ }\
+ }
+
+//static uint16 Session;
+
+//void disable_interrupt(void)
+//{
+//#ifndef WIN32
+///* todo implement this */
+////#warning This is disable_interrupt
+//#endif
+//}
+//void enable_interrupt(void)
+//{
+//#ifndef WIN32
+///* todo implement this */
+////#warning This is enable_interrupt
+//#endif
+//}
+
+ErrorCode_e Do_A2_CEH_Call(void *Object_p, CommandData_t * CmdData_p)
+{
+ ErrorCode_e Status = E_GENERAL_FATAL_ERROR;
+// uint32 PL_GRSize = 0;
+ ErrorCode_e ResponseStatus = E_SUCCESS;
+ boolean response = FALSE;
+// CommandPermissionList_t* CmdPermission_p;
+ void *Data_p = CmdData_p-&gt;Payload.Data_p;
+ uint16 Session = CmdData_p-&gt;SessionNr;
+
+ if (CmdData_p-&gt;Type == PROTO_CTRL_MSG)
+ {
+ response = TRUE;
+// PL_GRSize = CmdData_p-&gt;Payload.Size;
+// ResponseStatus = (ErrorCode_e)get_uint16(&amp;Data_p);
+ }
+
+ Session = CmdData_p-&gt;SessionNr;
+
+// CmdPermission_p = GetAuditData(CmdData_p);
+
+ switch(A2_COMMAND(response, CmdData_p-&gt;ApplicationNr, CmdData_p-&gt;CommandNr))
+ {
+ <apply-templates select="group" mode="unmarshal"/>
+ default:
+ {
+ Status = Do_CustomCEH_Call(CmdData_p);
+ if (E_SUCCESS != Status)
+ {
+ Status = Do_System_ShutDownImpl( Session);
+ }
+ }
+ break;
+ }
+
+ return Status;
+}
+
+ <apply-templates select="group" mode="marshal"/>
+
+</template>
+
+<template match="group/command" mode="marshal">
+<choose>
+ <when test="@flag='true'">
+#ifdef CFG_ENABLE_ADBG_LOADER</when>
+</choose>
+ <if test="contains(@source, 'ME')">
+ErrorCode_e <value-of select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />(<choose><when test="count(input/value) > 0"><apply-templates select="input/value" mode="declare" /></when><otherwise>void</otherwise></choose>)
+{
+ ErrorCode_e Answer;
+ CommandData_t CmdData;
+ void *Data_p;
+ uint32 PLSize =0;
+ <apply-templates select="input/value" mode="serialize_size_declaration" />
+
+ <apply-templates select="input/value" mode="serialize_size"/>
+ A2_COMMANDDATAOUT(COMMAND_TYPE, <call-template name="groupidmain"/>, <call-template name="commandid"/>, PLSize);
+ Data_p = CmdData.Payload.Data_p;
+ (void)(Data_p); //XVSZOAN Temporary solution!
+ <apply-templates select="input/value" mode="serialize"/>
+ Answer = Do_A2_Command_Send(GlobalCommunication_p, &amp;CmdData);
+ if(NULL != CmdData.Payload.Data_p)
+ free(CmdData.Payload.Data_p);
+ return Answer;
+}
+</if>
+ <if test="contains(@source, 'PC')">
+ErrorCode_e <value-of select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />(uint16 Session<if test="count(output/value) > 0">, </if><apply-templates select="output/value" mode="declare"></apply-templates>)
+{
+ ErrorCode_e Answer;
+ CommandData_t CmdData;
+ void *Data_p;
+ uint32 PLSize =0;
+ <apply-templates select="output/value" mode="serialize_size_declaration" />
+ <apply-templates select="output/value" mode="serialize_size"/>
+ A2_COMMANDDATA( GENERAL_RESPONSE, <call-template name="groupidmain"/>, <call-template name="commandid"/>, Session, PLSize);
+ Data_p = CmdData.Payload.Data_p;
+
+ <apply-templates select="output/value" mode="serialize"/>
+ Answer = Do_A2_Command_Send(GlobalCommunication_p, &amp;CmdData);
+ if(NULL != CmdData.Payload.Data_p)
+ free(CmdData.Payload.Data_p);
+ return Answer;
+}
+ </if>
+<choose>
+ <when test="@flag='true'">#endif
+ </when>
+</choose>
+</template>
+
+<template match="group/command" mode="unmarshal">
+ <if test="contains(@source, 'PC')">
+ <call-template name="unmarshal">
+ <with-param name="name" select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="input"/>
+ </call-template>
+ </if>
+ <if test="contains(@source, 'ME')">
+ <call-template name="unmarshal">
+ <with-param name="name" select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="output"/>
+ </call-template>
+ </if>
+</template>
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_commands.xml b/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_commands.xml
new file mode 100644
index 0000000..b2ad470
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_commands.xml
@@ -0,0 +1,637 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<?xml-stylesheet type="text/xml" href="a2_command_ids_h.xsl"?>
+<?xml-stylesheet type="text/xml" href="a2_command_marshal.xsl"?>
+<?xml-stylesheet type="text/xml" href="a2_commands_h.xsl"?>
+<?xml-stylesheet type="text/xml" href="a2_commands_impl_h.xsl"?>
+<?xml-stylesheet type="text/xml" href="a2_common.xsl"?>
+
+
+<commandspec>
+
+ <AuthenticationList>
+ <value number="1" name="A1">A1</value>
+ <value number="2" name="CA">CA</value>
+ </AuthenticationList>
+
+ <PermissionList>
+ <value number="0" name="Permission1">Permission1</value>
+ <value number="2" name="Permission2">Permission2</value>
+ <value number="3" name="Permission3">Permission3</value>
+ <value number="4" name="Permission4">Permission4</value>
+ <value number="5" name="Permission5">Permission5</value>
+ <value number="6" name="Permission6">Permission6</value>
+ <value number="7" name="Permission7">Permission7</value>
+ <value number="8" name="Permission8">Permission8</value>
+ <value number="9" name="Permission9">Permission9</value>
+ <value number="10" name="Permission10">Permission10</value>
+ </PermissionList>
+
+<!--
+ Predefine generic type of data are: uint32, string and buffer.
+ All A2 commands use only one buffer as an input and one buffer as an output parametar.
+ !!!!! IMPORTANT !!!!!
+ All new types of data (structures or vectors of structures) that need to be defined should first be reviewed and approved by:
+ Hans Holmberg (QHANHOL) for loaders, Mikael Sjolen XX for PTK and Daniel Chong for PA.
+ -->
+
+ <group number="1" name="A2 System group">
+ <documentation>
+ A2 System commands group (0x01)
+ </documentation>
+ <interface type="loader" name="A2_System"/>
+
+ <command number="101" name="TestCommand" source="PC">
+ <interface type="loader" name="TestCommand"/>
+ <documentation>
+ Performs controlled power down of the ME.
+ </documentation>
+ <input>
+ <value type="uint32" name="EnglandLength"/>
+ <value type="string" name="Sweden"/>
+ <value type="uint32" name="GermanyLength"/>
+ <value type="uint32" name="France"/>
+ <value type="buffer" name="Germany" length="GermanyLength"/>
+ <value type="buffer" name="England" length="EnglandLength"/>
+ </input>
+ <output>
+ <value type="uint32" name="AfricaLength"/>
+ <value type="string" name="Europa"/>
+ <value type="uint32" name="America"/>
+ <value type="string" name="Asia"/>
+ <value type="buffer" name="Africa" length="AfricaLength"/>
+ </output>
+ </command>
+
+ <command number="1" name="Shutdown" source="PC">
+ <interface type="loader" name="Shutdown"/>
+ <documentation>
+ The Loader shuts down in a controlled fashion and proceeds to shut down the ME itself.
+ </documentation>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ShutdownIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="ShutdownOutLenght">Loader version length</value>
+ <value type="buffer" name="ShutdownOut" length="ShutdownOutLenght">No data</value>
+ </output>
+ </command>
+
+ <command number="2" name="Loader Version" source="PC">
+ <interface type="loader" name="LoaderVersion"/>
+ <documentation>
+ The Loader Version command is sent by the PC to request version information from the loader. The ME responds with a Loader Version information coded as ASCII characters in the data field.
+ </documentation>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="LoaderVersionIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="LVLength">Loader version length</value>
+ <value type="buffer" name="LoaderVersionOut" length="LVLength">Loader version identifier</value>
+ </output>
+ </command>
+
+ <command number="3" name="Protocol Version" source="PC">
+ <interface type="loader" name="ProtocolVersion"/>
+ <documentation>
+ The Protocol Version command is sent by the PC to request the application protocol version information from the loader. The ME responds with two bytes holding the major and the minor version respectively.
+ </documentation>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ProtocolVersionIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="PVLength">Protocol version length</value>
+ <value type="buffer" name="ProtocolVersionOut" length="PVLength">Protocol version identifier</value>
+ </output>
+ </command>
+
+ <command number="5" name="System Supported Command groups" source="PC">
+ <interface type="loader" name="SupportedCommandGroups"/>
+ <documentation>
+ The Loader returns a list of implemented command groups and whether they are permitted to execute in the current Loader state.
+ </documentation>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="CommandGroupsIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="CommandGroupsOutLength">Supported Groups length</value>
+ <value type="buffer" name="CommandGroupsOut" length="CommandGroupsOutLength">Each byte of the string represents a supported command group.</value>
+ </output>
+ </command>
+
+ <command number="6" name="Get Platform Property" source="PC">
+ <interface type="loader" name="GetPlatformProperty"/>
+ <documentation>
+ This command is sent by the PC to request a Platform Property, by sending a PropertyID in the data field. The ME responds with the Property value.
+ </documentation>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="GetPropertyIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="GetPropertyOutLength">The size of the PropertyValue depends on the PropertyID</value>
+ <value type="buffer" name="GetPropertyOut" length="GetPropertyOutLength"/>
+ </output>
+ </command>
+
+ <command number="8" name="Get Memory Property" source="PC">
+ <interface type="loader" name="GetMemoryProperty"/>
+ <documentation>
+ This command is sent by the PC to request a Memory Property. The ME responds with the Memory Property value.
+ </documentation>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="GetMemPropertyIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="GetMemPropertyOutLength">The size of the PropertyValue depends on the PropertyID</value>
+ <value type="buffer" name="GetMemPropertyOut" length="GetMemPropertyOutLength"/>
+ </output>
+ </command>
+
+ <command number="9" name="Set Memory Property" source="PC">
+ <interface type="loader" name="SetMemoryProperty"/>
+ <documentation>
+ This command is sent by the PC to set a Memory Property.
+ </documentation>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="SetMemPropertyIn" length="CmdData_p-&gt;Payload.Size">The MemoryPropertyPayload buffer holds the Memory Propertiy ID and the Memory Property value. The size of the MemoryPropertyValue depends on the PropertyID</value>
+ </input>
+ <output>
+ <value type="uint32" name="SetMemPropertyOutLength">The size of the PropertyValue depends on the PropertyID</value>
+ <value type="buffer" name="SetMemPropertyOut" length="SetMemPropertyOutLength"/>
+ </output>
+ </command>
+
+ <command number="15" name="Read Security Data" source="PC">
+ <interface type="loader" name="ReadSecurityData"/>
+ <documentation>
+ This command is used in a Flashless bridge configuration. It returns the Static data and all dinamic variables cretaed during the signing process.
+ </documentation>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="SecurityDataIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="SecurityDataOutLength"/>
+ <value type="buffer" name="SecurityDataOut" length="SecurityDataOutLength"/>
+ </output>
+ </command>
+
+ <command number="17" name="Loader on Loader" source="PC">
+ <interface type="loader" name="LoaderOnLoader"/>
+ <documentation>
+ This command is used to transfer a new Loader to the ME. The data should hold either Header or Payload.
+ </documentation>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="LOLIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="LOLOutLength"/>
+ <value type="buffer" name="LOLOut" length="LOLOutLength"/>
+ </output>
+ </command>
+
+ <command number="19" name="Reset" source="PC">
+ <interface type="loader" name="Reset"/>
+ <documentation>
+ The Reset command is used to instruct the Loader to reset the ME. Upon receiving this command, the Loader shuts down in a controlled fashion and restarts the ME.
+ </documentation>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ResetIn" length="CmdData_p-&gt;Payload.Size">The ResetTimeout value is in ms.</value>
+ </input>
+ <output>
+ <value type="uint32" name="ResetOutLength"/>
+ <value type="buffer" name="ResetOut" length="ResetOutLength"/>
+ </output>
+ </command>
+
+ <command number="20" name="Simlock Authentication Request" source="PC">
+ <interface type="loader" name="SimlockAuthenticationRequest"/>
+ <documentation>
+ This command is sent by the PC to set the SIM Lock Keys.
+ </documentation>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="SIMLockAuthReqIn" length="CmdData_p-&gt;Payload.Size">There are 12 SIM Lock Keys, each represented with a 16 bytes long string.</value>
+ </input>
+ <output>
+ <value type="uint32" name="SIMLockAuthReqOutLength"/>
+ <value type="buffer" name="SIMLockAuthReqOut" length="SIMLockAuthReqOutLength"/>
+ </output>
+ </command>
+
+</group>
+
+<group number="2" name="A2 Flash group">
+ <documentation>
+ A2 Flash Commands group (0x02)
+ </documentation>
+ <interface type="loader" name="A2_Flash"/>
+
+ <command number="1" name="Verify Signed Header" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="VerifySignedHeader"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="VerifyHeaderIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="VerifyHeaderOutLength"/>
+ <value type="buffer" name="VerifyHeaderOut" length="VerifyHeaderOutLength"/>
+ </output>
+ </command>
+
+ <command number="2" name="Software Block Address" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="SoftwareBlockAddress"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="SoftBlockAddIn" length="CmdData_p-&gt;Payload.Size">There are two parameters in the input buffer: Start address and Block size, both 4 bytes long.</value>
+ </input>
+ <output>
+ <value type="uint32" name="SoftBlockAddOutLength"/>
+ <value type="buffer" name="SoftBlockAddOut" length="SoftBlockAddOutLength"/>
+ </output>
+ </command>
+
+ <command number="3" name="Program Flash" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="ProgramFlash"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ProgramFlashIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="ProgramFlashOutLength"/>
+ <value type="buffer" name="ProgramFlashOut" length="ProgramFlashOutLength"/>
+ </output>
+ </command>
+
+ <command number="4" name="Verify Software Flash" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="VerifySoftwareFlash"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="VerifySoftwareFlashIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="VerifySoftwareFlashOutLength"/>
+ <value type="buffer" name="VerifySoftwareFlashOut" length="VerifySoftwareFlashOutLength"/>
+ </output>
+ </command>
+
+ <command number="5" name="Dump Flash Image" flag="true1" source="PC">
+ <documentation>
+ This command is used to readp from the flash. The input parameters buffer holds: Logical Unit number = 4 bits, Start address = 28 bits and End address = 4 bytes.
+ </documentation>
+ <interface type="loader" name="DumpFlashImage"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="DumpFlashImageIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="DumpFlashImageOutLength"/>
+ <value type="buffer" name="DumpFlashImageOut" length="DumpFlashImageOutLength"/>
+ </output>
+ </command>
+
+ </group>
+
+ <group number="3" name="A2 GDFS group">
+ <documentation>
+ A2 GDFS Commands Group (0x03)
+ </documentation>
+ <interface type="loader" name="A2_GDFS"/>
+
+ <command number="1" name="Get GDFS Property" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="GetGDFSProperty"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="GetGDFSPropertyIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="GetGDFSPropertyOutLength"/>
+ <value type="buffer" name="GetGDFSPropertyOut" length="GetGDFSPropertyOutLength"/>
+ </output>
+ </command>
+
+ </group>
+
+ <group number="4" name="File system group">
+ <documentation>
+ A2 File system commands Group (0x04)
+ </documentation>
+ <interface type="loader" name="A2_File_System"/>
+
+ <command number="1" name="Get File System Property" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="GetFileSystemProperty"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="GetFSPropertyIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="GetFSPropertyOutLength"/>
+ <value type="buffer" name="GetFSPropertyOut" length="GetFSPropertyOutLength"/>
+ </output>
+ </command>
+
+ </group>
+
+ <group number="5" name="Signature group">
+ <documentation>
+ A2 Signature Commands Group (0x05)
+ </documentation>
+ <interface type="loader" name="A2_Signature"/>
+
+ <command number="1" name="Set Control Keys" flag="true1" source="PC">
+ <documentation>
+ This command is used to write the SIM Lock control keys.
+ </documentation>
+ <interface type="loader" name="SetControlKeys"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="SetControlKeysIn" length="CmdData_p-&gt;Payload.Size">There are 12 SIM Lock Keys, each represented with a 16 bytes long string.</value>
+ </input>
+ <output>
+ <value type="uint32" name="SetControlKeysOutLength"/>
+ <value type="buffer" name="SetControlKeysOut" length="SetControlKeysOutLength"/>
+ </output>
+ </command>
+
+ <command number="2" name="Set Platform Property" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="SetPlatformProperty"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="SetPlatformPropertyIn" length="CmdData_p-&gt;Payload.Size">The SetPlatformPropertyIn buffer holds the Platform Property ID and the Platform property value. The size of the Platform Property ID is 4 bytes and the size of the Platform Property Value depends on the PropertyID</value>
+ </input>
+ <output>
+ <value type="uint32" name="SetPlatformPropertyOutLength"/>
+ <value type="buffer" name="SetPlatformPropertyOut" length="SetPlatformPropertyOutLength"/>
+ </output>
+ </command>
+
+ <command number="3" name="Write and Lock OTP" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="WriteAndLockOTP"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="WriteAndLockOTPIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="WriteAndLockOTPOutLength"/>
+ <value type="buffer" name="WriteAndLockOTPOut" length="WriteAndLockOTPOutLength"/>
+ </output>
+ </command>
+
+ <command number="4" name="Write Default Data" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="WriteDefaultData"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="WriteDefaultDataIn" length="CmdData_p-&gt;Payload.Size">The WriteDefaultDataIn buffer holds the Unit number,the Unit size and Unit data</value>
+ </input>
+ <output>
+ <value type="uint32" name="WriteDefaultDataOutLength"/>
+ <value type="buffer" name="WriteDefaultDataOut" length="WriteDefaultDataOutLength"/>
+ </output>
+ </command>
+
+ <command number="5" name="Write Full Signature" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="WriteFullSignature"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="WriteFullSignIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="WriteFullSignOutLength"/>
+ <value type="buffer" name="WriteFullSignOut" length="WriteFullSignOutLength"/>
+ </output>
+ </command>
+
+ <command number="6" name="Write CID" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="WriteCID"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="WriteCIDIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="WriteCIDOutLength"/>
+ <value type="buffer" name="WriteCIDOut" length="WriteCIDOutLength"/>
+ </output>
+ </command>
+
+ <command number="7" name="Write Test Signature" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="WriteTestSignature"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="WriteTestSignIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="WriteTestSignOutLength"/>
+ <value type="buffer" name="WriteTestSignOut" length="WriteTestSignOutLength"/>
+ </output>
+ </command>
+
+ <command number="8" name="Erase Security Data" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="EraseSecurityData"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="EraseSecDataIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="EraseSecDataOutLength"/>
+ <value type="buffer" name="EraseSecDataOut" length="EraseSecDataOutLength"/>
+ </output>
+ </command>
+
+ <command number="9" name="Key Sharing Stage 1 Request" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="KeySharingStage1Request"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="KeySharStage1ReqIn" length="CmdData_p-&gt;Payload.Size">The KeySharStage1ReqIn buffer holds the Version (1 byte), the ID (4 bytes) and Random Value (24 bytes)</value>
+ </input>
+ <output>
+ <value type="uint32" name="KeySharStage1ReqOutLength"/>
+ <value type="buffer" name="KeySharStage1ReqOut" length="KeySharStage1ReqOutLength"/>
+ </output>
+ </command>
+
+ <command number="10" name="Key Sharing Stage 2 Request" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="KeySharingStage2Request"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="KeySharStage2ReqIn" length="CmdData_p-&gt;Payload.Size">The KeySharStage2ReqIn buffer holds the ID (4 bytes), the Cipher (1 byte), the CertificateLength (4 bytes) and Certificate (CertificateLength)</value>
+ </input>
+ <output>
+ <value type="uint32" name="KeySharStage2ReqOutLength"/>
+ <value type="buffer" name="KeySharStage2ReqOut" length="KeySharStage2ReqOutLength"/>
+ </output>
+ </command>
+
+ <command number="11" name="Key Sharing Stage 3 Request" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="KeySharingStage3Request"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="KeySharStage3ReqIn" length="CmdData_p-&gt;Payload.Size">The KeySharStage3ReqIn buffer holds the ID (4 bytes), C2 (16 bytes) and MAC (20 bytes).</value>
+ </input>
+ <output>
+ <value type="uint32" name="KeySharStage3ReqOutLength"/>
+ <value type="buffer" name="KeySharStage3ReqOut" length="KeySharStage3ReqOutLength"/>
+ </output>
+ </command>
+
+ <command number="12" name="DRM Secure Storage Request" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="DRMSecureStorageRequest"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="DRMSecStorReqIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="DRMSecStorReqOutLength"/>
+ <value type="buffer" name="DRMSecStorReqOut" length="DRMSecStorReqOutLength"/>
+ </output>
+ </command>
+
+ <command number="14" name="Verify Control Keys" flag="true1" source="PC">
+ <documentation>
+ This command is used to compare received SIM Lock keys against the SIM Lock keys stored in the ME.
+ </documentation>
+ <interface type="loader" name="VerifyControlKeys"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="VerifyControlKeysIn" length="CmdData_p-&gt;Payload.Size">There are 12 SIM Lock Keys, each represented with a 16 bytes long string.</value>
+ </input>
+ <output>
+ <value type="uint32" name="VerifyControlKeysOutLength"/>
+ <value type="buffer" name="VerifyControlKeysOut" length="VerifyControlKeysOutLength"/>
+ </output>
+ </command>
+
+ <command number="16" name="Secure Storage Request" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="SecureStorageRequest"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="SecStorReqIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="SecStorReqOutLength"/>
+ <value type="buffer" name="SecStorReqOut" length="SecStorReqOutLength"/>
+ </output>
+ </command>
+
+ </group>
+
+ <group number="7" name="Reset group">
+ <documentation>
+ A2 Reset Commands group (0x07)
+ </documentation>
+
+ <interface type="loader" name="A2_Reset"/>
+
+ <command number="1" name="Init Request" flag="true1" source="PC">
+ <interface type="loader" name="InitRequest"/>
+ <documentation>
+ </documentation>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="InitRequestIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="InitRequestOutLength"/>
+ <value type="buffer" name="InitRequestOut" length="InitRequestOutLength"/>
+ </output>
+ </command>
+
+ <command number="2" name="Update Request" flag="true1" source="PC">
+ <interface type="loader" name="UpdateRequest"/>
+ <documentation>
+ </documentation>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="UpdateRequestIn" length="CmdData_p-&gt;Payload.Size"/>
+ </input>
+ <output>
+ <value type="uint32" name="UpdateRequestOutLength"/>
+ <value type="buffer" name="UpdateRequestOut" length="UpdateRequestOutLength"/>
+ </output>
+ </command>
+
+ </group>
+
+ <group number="16" name="Control massage">
+ <documentation>
+ A2 Control massage (0x10)
+ </documentation>
+
+ <interface type="loader" name="A2_Control"/>
+
+ <command number="1" name="Loader Started" source="ME">
+ <interface type="loader" name="LoaderStarted"/>
+ <documentation>
+ </documentation>
+ <input>
+ <value type="uint32" name="LoaderStartedInLength"/>
+ <value type="buffer" name="LoaderStartedIn" length="LoaderStartedInLength"/>
+ </input>
+ <output>
+ <value type="buffer" name="LoaderStartedOut" length="CmdData_p-&gt;Payload.Size"/>
+ </output>
+ </command>
+
+ <command number="5" name="Loader Not Started" source="ME">
+ <interface type="loader" name="LoaderNotStarted"/>
+ <documentation>
+ </documentation>
+ <input>
+ <value type="uint32" name="LoaderNotStartedInLength"/>
+ <value type="buffer" name="LoaderNotStartedIn" length="LoaderNotStartedInLength"/>
+ </input>
+ <output>
+ <value type="buffer" name="LoaderNotStartedOut" length="CmdData_p-&gt;Payload.Size"/>
+ </output>
+ </command>
+
+ </group>
+
+</commandspec>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_commands_h.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_commands_h.xsl
new file mode 100644
index 0000000..974ea90
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_commands_h.xsl
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
+
+<import href="a2_common.xsl"/>
+
+<output method="text"/>
+<strip-space elements="*"/>
+<param name="target"/>
+
+<template match="/commandspec">/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _A2_COMMANDS_H
+#define _A2_COMMANDS_H
+#include &quot;error_codes.h&quot;
+#include &quot;t_a2_protocol.h&quot;
+#include "a2_command_ids.h"
+
+ErrorCode_e Do_A2_CEH_Call(void *Object_p, CommandData_t *CmdData_p);
+<apply-templates select="group"/>
+#endif /* _A2_COMMANDS_H */
+</template>
+
+<template match="group/command">
+ <if test="contains(@source, &apos;ME&apos;)">
+ <call-template name="prototype">
+ <with-param name="name" select="concat(&apos;Do_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name)"/>
+ <with-param name="ref" select="concat(&apos;Done_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name, &apos;Impl&apos;)"/>
+ <with-param name="direction" select="input"/>
+ <with-param name="source" select="&apos;ME&apos;"/>
+ </call-template>
+ </if>
+ <if test="contains(@source, &apos;PC&apos;)">
+ <call-template name="prototype">
+ <with-param name="name" select="concat(&apos;Done_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name)"/>
+ <with-param name="ref" select="concat(&apos;Do_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name, &apos;Impl&apos;)"/>
+ <with-param name="direction" select="output"/>
+ <with-param name="source" select="&apos;PC&apos;"/>
+ </call-template>
+ </if>
+</template>
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_commands_impl_h.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_commands_impl_h.xsl
new file mode 100644
index 0000000..88526b7
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_commands_impl_h.xsl
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" >
+
+<import href="a2_common.xsl"/>
+
+<output method="text"/>
+<strip-space elements="*"/>
+<param name="target" />
+
+<template match="/commandspec">/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _A2_COMMANDS_IMPL_H
+#define _A2_COMMANDS_IMPL_H
+#include "error_codes.h"
+<apply-templates select="group" />
+#endif /* _A2_COMMANDS_IMPL_H */
+</template>
+
+<template match="group/documentation">
+/*
+ * <value-of select="normalize-space(.)"/>
+ */
+</template>
+
+<template match="group/command">
+ <if test="contains(@source, 'PC')">
+ <call-template name="prototype">
+ <with-param name="name" select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="ref" select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />
+ <with-param name="direction" select="input" />
+ <with-param name="source" select="'PC'" />
+ </call-template>
+ </if>
+ <if test="contains(@source, 'ME')">
+ <call-template name="prototype">
+ <with-param name="name" select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="ref" select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />
+ <with-param name="direction" select="output" />
+ <with-param name="source" select="'PC'" />
+ </call-template>
+ </if>
+</template>
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_common.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_common.xsl
new file mode 100644
index 0000000..bf771b7
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/a2_common.xsl
@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" >
+
+<!-- Ugly name-mangling templates. upper-case() did not work in this
+ implementation -->
+<template name="groupidmain">
+ <param name="path" select="../." />
+ <value-of select="concat('GROUP_', translate($path/interface[@type='loader']/@name,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'))" />
+</template>
+
+
+<template name="groupid">
+ <param name="path" select="." />
+ <value-of select="concat('GROUP_', translate($path/interface[@type='loader']/@name,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'))" />
+</template>
+
+<template name="commandid">
+ <param name="path" select="." />
+ <value-of select="translate(concat('COMMAND_', $path/../interface[@type='loader']/@name, '_', $path/interface[@type='loader']/@name),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
+</template>
+
+<template match="value" mode="deserialize">
+ <choose>
+ <when test="@type='uint32'"><text> </text><value-of select="@name" /> = CmdData_p-&gt;Payload.Size;
+ </when>
+ <when test="@type='uint64'"><text> </text><value-of select="@name" /> = get_uint64_le(&amp;Data_p);
+ </when>
+ <when test="@type='string'"><text> </text><value-of select="@name" /> = skip_str(&amp;Data_p);
+ </when>
+ <when test="@type='buffer' and @length!='*'"><text> </text><value-of select="@name" /> = Data_p;
+ </when>
+ </choose>
+ <if test="position() = last()"><text>
+ </text>
+
+
+
+
+
+
+ </if>
+</template>
+
+<template match="value" mode="deserialize_size">
+ <choose>
+ <when test="@type='uint32'"> uint32 <value-of select="@name" />;
+ </when>
+ <when test="@type='uint64'"> uint64 <value-of select="@name" />;
+ </when>
+ <when test="@type='string'"> char *<value-of select="@name" />;
+ </when>
+ <when test="@type='buffer' and @length!='*'"> void *<value-of select="@name" />;
+ </when>
+ </choose>
+ <if test="position() = last()"><text>
+ </text>
+ </if>
+</template>
+
+<template match="value" mode="serialize">
+ <choose>
+ <when test="@type='uint32'">
+ </when>
+ <when test="@type='uint64'"> put_uint64_le(&amp;Data_p, <value-of select="@name" />);
+ </when>
+ <when test="@type='string'"> put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);
+ </when>
+ <when test="@type='buffer' and @length='*'"> put_block(&amp;Data_p, <value-of select="@name" />, <value-of select="@name" />PLSize);
+ </when>
+ <when test="@type='buffer' and @length!='*'"> put_block(&amp;Data_p, <value-of select="@name" />, <value-of select="@length" />);
+ </when>
+ <when test="@type='SupportedCommand' and @length!='*'"> put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);
+ </when>
+ <when test="@type='ListDevice' and @length!='*'"> put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);
+ </when>
+ <when test="@type='DirEntry' and @length!='*'"> put_entries(&amp;Data_p, <value-of select="@name" />, <value-of select="@length" />);<!--put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);-->
+ </when>
+ <when test="@type='Cipher' and @length!='*'"> put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);
+ </when>
+ </choose>
+ <if test="position() = last()"><text></text>
+ </if>
+</template>
+
+<template match="value" mode="serialize_size">
+ <choose>
+ <when test="@type='uint32'">
+ </when>
+ <when test="@type='uint64'"> PLSize += sizeof(uint64);
+ </when>
+ <when test="@type='string'"> PLSize += PLSize<value-of select="@name" /> = get_uint32_string_le((void**)&amp;<value-of select="@name" />);
+ </when>
+ <when test="@type='buffer' and @length!='*'"> PLSize += <value-of select="@length" />;
+ </when>
+ <when test="@type='SupportedCommand' and @length!='*'"> PLSize += PLSize<value-of select="@name" /> = <value-of select="@length" /> * sizeof(SupportedCommand_t);
+ </when>
+ <when test="@type='ListDevice' and @length!='*'"> PLSize += PLSize<value-of select="@name" /> = <value-of select="@length" /> * sizeof(ListDevice_t);
+ </when>
+ <when test="@type='DirEntry' and @length!='*'"> PLSize += get_entries_len(<value-of select="@name" />, <value-of select="@length" />); <!--PLSize<value-of select="@name" /> = <value-of select="@length" /> * sizeof(DirEntry_t);-->
+ </when>
+ <when test="@type='Cipher' and @length!='*'"> PLSize += PLSize<value-of select="@name" /> = <value-of select="@length" /> * sizeof(Cipher_t);
+ </when>
+ </choose>
+ <if test="position() = last()"><text></text>
+ </if>
+</template>
+
+<template match="value" mode="serialize_size_declaration">
+ <choose>
+ <when test="@type='string'">uint32 PLSize<value-of select="@name" /> = 0;
+ </when>
+ <when test="@type='SupportedCommand'">uint32 PLSize<value-of select="@name" /> = 0;
+ </when>
+ <when test="@type='ListDevice'">uint32 PLSize<value-of select="@name" /> = 0;
+ </when>
+ <!--<when test="@type='DirEntry'">uint32 PLSize<value-of select="@name" /> = 0;
+ </when>-->
+ <when test="@type='Cipher'">uint32 PLSize<value-of select="@name" /> = 0;
+ </when>
+ </choose>
+ <if test="position() = last()"><text></text>
+ </if>
+</template>
+
+<template match="value" mode="perm">
+ <if test="position() > 1">,
+ </if>
+ <value-of select="@ref" />
+</template>
+
+<template match="value" mode="auth">
+ <if test="position() > 1">,
+ </if>
+ <value-of select="@ref" />
+</template>
+
+<template match="value" mode="permnumber">
+ <if test="position() = last()">
+ <value-of select="position()" />
+ </if>
+</template>
+
+<template match="value" mode="authnumber">
+ <if test="position() = last()">
+ <value-of select="position()" />
+ </if>
+</template>
+
+<template match="value" mode="clean">
+<choose>
+ <when test="@type='string'"></when>
+</choose>
+</template>
+
+<template match="value" mode="document">
+ * @param [in] <value-of select="@name" /><text> </text><value-of select="text()" />
+<if test="position() = last()">
+ * </if>
+</template>
+
+<template match="value" mode="declare">
+ <if test="position() > 1">, </if>
+<choose>
+ <when test="@type='uint32'">const uint32 <value-of select="@name" /></when>
+ <when test="@type='uint64'">const uint64 <value-of select="@name" /></when>
+ <when test="@type='string'">const char *<value-of select="@name" /></when>
+ <when test="@type='buffer' and @length='*'">int <value-of select="@name" />Length, const void *<value-of select="@name" /></when>
+ <when test="@type='buffer' and @length!='*'"> void *<value-of select="@name" /></when>
+ <when test="@type='SupportedCommand' and @length!='*'">SupportedCommand_t <value-of select="@name" />[]</when>
+ <when test="@type='ListDevice' and @length!='*'">ListDevice_t <value-of select="@name" />[]</when>
+ <when test="@type='DirEntry' and @length!='*'">DirEntry_t <value-of select="@name" />[]</when>
+ <when test="@type='Cipher' and @length!='*'">Cipher_t <value-of select="@name" />[]</when>
+</choose>
+</template>
+
+<template match="value" mode="call">
+ <if test="position() > 1">, </if>
+<choose>
+ <when test="@type='uint32'"><value-of select="@name" /></when>
+ <when test="@type='uint64'"><value-of select="@name" /></when>
+ <when test="@type='string'"><value-of select="@name" /></when>
+ <when test="@type='buffer' and @length='*'"><value-of select="@name" />Length, <value-of select="@name" /></when>
+ <when test="@type='buffer' and @length!='*'"><value-of select="@name" /></when>
+</choose>
+</template>
+
+<template match="group/documentation">
+/*
+ * <value-of select="normalize-space(.)"/>
+ */
+</template>
+
+<template name="prototype">
+<param name="name" />
+<param name="direction" />
+<param name="source" />
+<param name="ref" />
+<choose>
+<when test="name($direction)='input' and contains($source, 'PC')">
+/**
+ * <value-of select="normalize-space(./documentation/text())"/>
+ * \see <value-of select="$ref"/>
+ * Call source: <value-of select="$source"/>
+ * <apply-templates select="input/value" mode="document" />
+ * @return ErrorCode_e ...
+ */
+ErrorCode_e <value-of select="$name"/>(uint16 Session<if test="count(input/value) > 0">, </if><apply-templates select="input/value" mode="declare"/>);</when>
+<when test="name($direction)='input' and contains($source, 'ME')">
+/**
+ * <value-of select="normalize-space(./documentation/text())"/>
+ * \see <value-of select="$ref"/>
+ * Call source: <value-of select="$source"/>
+ * <apply-templates select="input/value" mode="document" />
+ * @return ErrorCode_e ...
+ */
+ErrorCode_e <value-of select="$name"/>(<choose><when test="count(input/value) > 0"><apply-templates select="input/value" mode="declare"/></when><otherwise>void</otherwise></choose>);</when>
+<when test="name($direction)='output'">
+/**
+ * Response to \see <value-of select="$ref"/>
+ * Call source: <value-of select="$source"/>
+ *
+ * @param [in] Status Completion status code.
+ * <apply-templates select="output/value" mode="document" />
+ * @return ErrorCode_e ...
+ */
+ErrorCode_e <value-of select="$name"/>(uint16 Session<if test="count(output/value) > 0">, </if><apply-templates select="output/value" mode="declare"></apply-templates>);</when>
+</choose>
+<text>
+</text>
+</template>
+
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/audit_c.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/audit_c.xsl
new file mode 100644
index 0000000..fbc00fc
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/audit_c.xsl
@@ -0,0 +1,323 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" >
+
+<import href="common.xsl"/>
+
+<output method="text"/>
+<strip-space elements="*"/>
+<param name="target" />
+
+<param name="supportedCommands" />
+<variable name="supported_commands" select="document($supportedCommands)/commandspec"/>
+
+<template match="group/documentation" mode="array">
+<variable name="group" select="../@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
+/*
+ * <value-of select="normalize-space(.)"/>
+ */
+</if>
+</template>
+
+<template match="group/documentation" mode="autharray">
+<variable name="group" select="../@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
+/*
+ * <value-of select="normalize-space(.)"/>
+ */
+</if>
+</template>
+
+
+<template match="group/documentation" mode="staticarray">
+<variable name="group" select="../@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
+ /*
+ * <value-of select="normalize-space(.)"/>
+ */
+</if>
+</template>
+
+<template name="staticarray">
+<param name="name" />
+<param name="direction" />
+<choose>
+<when test="name($direction)='input'">
+ /* Command <value-of select="../@name" /> / <value-of select="@name" /> (<value-of select="../@number" /> / <value-of select="@number" />) */
+</when>
+<when test="name($direction)='output'">
+ /* Response to <value-of select="../@name" /> / <value-of select="@name" /> (<value-of select="../@number" /> / <value-of select="@number" />) */
+</when>
+</choose>
+ {
+ <call-template name="groupid" ><with-param name="path" select=".."/></call-template>,
+ <call-template name="commandid" />,
+ <variable name="group" select="../@number" />
+ <variable name="command" select="@number" />
+ <choose>
+ <when test='not($supported_commands/group[@number=$group]/command[@number=$command]/permissions)'>
+ <choose>
+ <when test="permissions"><text> </text><apply-templates select="permissions/value" mode="permnumber" />,
+ </when>
+ <otherwise> 0,
+ </otherwise>
+ </choose>
+ <choose>
+ <when test="permissions"> PermArray_<value-of select="concat(../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />,
+ </when>
+ <otherwise> NULL,
+ </otherwise>
+ </choose>
+ </when>
+ <otherwise>
+ <choose>
+ <when test="$supported_commands/group[@number=$group]/command[@number=$command]/permissions"><text> </text><apply-templates select="$supported_commands/group[@number=$group]/command[@number=$command]/permissions/value" mode="permnumber" />,
+ </when>
+ <otherwise> 0,
+ </otherwise>
+ </choose>
+ <choose>
+ <when test="$supported_commands/group[@number=$group]/command[@number=$command]/permissions"> PermArray_<value-of select="concat(../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />,
+ </when>
+ <otherwise> NULL,
+ </otherwise>
+ </choose>
+ </otherwise>
+ </choose>
+ <choose>
+ <when test="authentication"><text> </text><apply-templates select="authentication/value" mode="authnumber" />,
+ </when>
+ <otherwise> 0,
+ </otherwise>
+ </choose>
+ <choose>
+ <when test="authentication"> AuthArray_<value-of select="concat(../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />,
+ </when>
+ <otherwise> NULL,
+ </otherwise>
+ </choose>
+ <choose>
+ <when test="authentication">
+ <choose>
+ <when test="./authentication/@depandancy='and'"> 1,
+ </when>
+ <when test="./authentication/@depandancy='or'"> 2,
+ </when>
+ <when test="./authentication/@depandancy='xor'"> 3,
+ </when>
+ </choose>
+ </when>
+ <otherwise> 0,
+ </otherwise>
+ </choose>
+ <choose>
+ <when test="authentication"><text> </text><value-of select="./authentication/@factory"/>,
+ </when>
+ <otherwise> FALSE,
+ </otherwise>
+ </choose>
+ <choose>
+ <when test="authentication"><text> </text><value-of select="./authentication/@rd"/>,
+ </when>
+ <otherwise> FALSE,
+ </otherwise>
+ </choose>
+ <choose>
+ <when test="authentication"><text> </text><value-of select="./authentication/@product"/>,
+ </when>
+ <otherwise> FALSE,
+ </otherwise>
+ </choose>
+ <choose>
+ <when test="authentication"><text> </text><value-of select="./authentication/@service"/>,
+ </when>
+ <otherwise> FALSE,
+ </otherwise>
+ </choose> NULL
+ },
+</template>
+
+
+<template match="/commandspec">/* $Copyright ST-Ericsson 2010 $ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+#include &lt;string.h&gt;
+
+#include "t_command_protocol.h"
+#include "r_debug.h"
+#include "r_communication_service.h"
+#include "commands.h"
+#include "command_ids.h"
+#include "commands_impl.h"
+#include "error_codes.h"
+#include "r_serialization.h"
+#include "r_command_protocol.h"
+#include "audit.h"
+
+#ifdef CFG_ENABLE_AUDIT_CMD
+#include "r_loader_sec_lib.h"
+#endif
+
+#ifdef CFG_ENABLE_ADBG_LOADER
+#include "r_adbg_command.h"
+#endif
+
+/*
+ * Command Permissions Vectors.
+ */
+<apply-templates select="group" mode="array"/>
+/*
+ * Command Authentication Vectors.
+ */
+<apply-templates select="group" mode="autharray"/>
+
+CommandPermissionList_t CommandPermissionList[]=
+{<apply-templates select="group" mode="staticarray"/>
+ /* End of array */
+ {
+ 0,
+ (CommandId_e)0,
+ 0,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ FALSE,
+ FALSE,
+ FALSE,
+ FALSE,
+ NULL
+ }
+};
+
+CommandPermissionList_t * GetAuditData(CommandData_t * CmdData_p)
+{
+/*
+ boolean A1_Authentication = FALSE;
+ boolean CA_Authentication = FALSE;
+
+ boolean A1_Factory = FALSE;
+ boolean A1_RD = FALSE;
+ boolean A1_Product = FALSE;
+ boolean A1_Service = FALSE;
+
+ uint8 A1_depandancy = 0x00;
+
+ uint32 AuthenticationVector = 0; */
+ int CounterList = 0;
+
+ while(CommandPermissionList[CounterList].Group != 0)
+ {
+ if(CmdData_p-&gt;ApplicationNr==CommandPermissionList[CounterList].Group &amp;&amp; CmdData_p-&gt;CommandNr==CommandPermissionList[CounterList].Command)
+ {
+ CommandPermissionList[CounterList].DataParam_p = CmdData_p-&gt;Payload.Data_p;
+ return (&amp;CommandPermissionList[CounterList]);
+ }
+ CounterList++;
+ }
+ return NULL;
+}
+
+#ifdef CFG_ENABLE_AUDIT_CMD
+ErrorCode_e CommandAudit(CommandData_t * CmdData_p)
+{
+ ErrorCode_e ReturnValue = E_GENERAL_FATAL_ERROR;
+ CommandPermissionList_t* CmdPermission_p = NULL;
+
+ CmdPermission_p = GetAuditData(CmdData_p);
+ if(NULL == CmdPermission_p)
+ {
+ ReturnValue = E_UNSUPPORTED_CMD;
+ goto ErrorExit;
+ }
+
+ ReturnValue = (ErrorCode_e)Do_LoaderSecLib_Audit_Permission_Levels(CmdPermission_p);
+ if(ReturnValue != E_SUCCESS)
+ {
+ ReturnValue = E_AUDITING_FAILED;
+ }
+
+ErrorExit:
+ return ReturnValue;
+}
+#endif
+</template>
+
+<template match="group/command" mode="array">
+<variable name="group" select="../@number" />
+<variable name="command" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
+ <variable name="group" select="../@number" />
+ <variable name="command" select="@number" />
+<if test="contains(@source, 'ME') and not(contains(@source, 'PC')) and permissions">
+CommandPermission_e PermArray_<value-of select="concat(../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />[] =
+{
+ <choose>
+ <when test='not($supported_commands/group[@number=$group]/command[@number=$command]/permissions)'><apply-templates select="permissions/value" mode="perm" />
+ </when>
+ <otherwise>
+ <apply-templates select="$supported_commands/group[@number=$group]/command[@number=$command]/permissions/value" mode="perm" />
+ </otherwise>
+ </choose>
+};
+</if>
+<if test="contains(@source, 'PC') and permissions">
+CommandPermission_e PermArray_<value-of select="concat( ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />[] =
+{
+ <choose>
+ <when test='not($supported_commands/group[@number=$group]/command[@number=$command]/permissions)'><apply-templates select="permissions/value" mode="perm" />
+ </when>
+ <otherwise>
+ <apply-templates select="$supported_commands/group[@number=$group]/command[@number=$command]/permissions/value" mode="perm" />
+ </otherwise>
+ </choose>
+};
+</if>
+</if>
+</template>
+
+<template match="group/command" mode="autharray">
+<variable name="group" select="../@number" />
+<variable name="command" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
+<if test="contains(@source, 'ME') and not(contains(@source, 'PC')) and authentication">
+CommandAuthentication_e AuthArray_<value-of select="concat(../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />[] =
+{
+ <apply-templates select="authentication/value" mode="auth" />
+};
+</if>
+<if test="contains(@source, 'PC') and authentication">
+CommandAuthentication_e AuthArray_<value-of select="concat( ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />[] =
+{
+ <apply-templates select="authentication/value" mode="auth" />
+};
+</if>
+</if>
+</template>
+
+
+<template match="group/command" mode="staticarray">
+<variable name="group" select="../@number" />
+<variable name="command" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
+<if test="contains(@source, 'PC') and not(contains(@source, 'ME'))">
+<call-template name="staticarray">
+ <with-param name="name" select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="input" />
+</call-template>
+</if>
+<if test="contains(@source, 'ME')">
+<call-template name="staticarray">
+ <with-param name="name" select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="output" />
+</call-template>
+</if>
+</if>
+</template>
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/audit_h.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/audit_h.xsl
new file mode 100644
index 0000000..27b11cd
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/audit_h.xsl
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" >
+
+<output method="text"/>
+<strip-space elements="*"/>
+<param name="target" />
+
+<template match="/commandspec">
+/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _AUDIT_H
+#define _AUDIT_H
+#include "t_command_protocol.h"
+#include "command_ids.h"
+
+/**
+ * @addtogroup ldr_LCM
+ * Error codes for internal loader commands.
+ * @{
+ */
+<apply-templates select="AuthenticationList" />
+
+<apply-templates select="PermissionList" />
+
+typedef struct CommandPermissionList_s
+{
+ GroupId_e Group;
+ CommandId_e Command;
+ int CommmandPermissionLength;
+ CommandPermission_e *CommmandPermmision_p;
+ int ComandAuthenticationLength;
+ CommandAuthentication_e *CommandAuthentication_p;
+ int Depandancy;
+ boolean factory;
+ boolean rd;
+ boolean product;
+ boolean service;
+ uint8 *DataParam_p;
+}CommandPermissionList_t;
+
+CommandPermissionList_t * GetAuditData(CommandData_t * CmdData_p);
+ErrorCode_e CommandAudit(CommandData_t * CmdData_p);
+#endif /* _AUDIT_H */
+</template>
+
+<template match="AuthenticationList">
+TYPEDEF_ENUM {
+<apply-templates select="value" />}ENUM8(CommandAuthentication_e);
+</template>
+
+
+<template match="PermissionList">
+TYPEDEF_ENUM {
+<apply-templates select="value" />}ENUM8(CommandPermission_e);
+</template>
+
+<template match="value">
+<text> </text><value-of select="@name" /> = <value-of select="@number" />, /**&lt; <value-of select="text()" /> */
+</template>
+
+<template match="value[last()]">
+<text> </text><value-of select="@name" /> = <value-of select="@number" /> /**&lt; <value-of select="text()" /> */
+</template>
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/ces_commands_c.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/ces_commands_c.xsl
new file mode 100644
index 0000000..4ab37c4
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/ces_commands_c.xsl
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
+
+<import href="common.xsl"/>
+
+<output method="text" indent="no"/>
+<strip-space elements="*"/>
+<param name="target" />
+<param name="supportedCommands" />
+<variable name="supported_commands" select="document($supportedCommands)/commandspec"/>
+
+<template match="command">
+<variable name="group" select="../@number" />
+<variable name="command" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
+<if test='contains(@supportedcmdtype, "longrunning")'>
+<text> </text>{
+<text> </text>NULL,
+<text> </text><value-of select="../interface/@name"/>_<value-of select="interface/@name"/>Repeat,
+<text> </text><call-template name="commandid"/>,
+<text> </text>1
+<text> </text>},
+</if>
+</if>
+</template>
+
+<template match="group" mode="CommandsList">
+<variable name="group" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
+<if test='contains(@supportedcmdtype, "longrunning")'>
+CommandInformation_t Generic<value-of select="interface/@name"/>GroupCommandsList[]=
+{
+<apply-templates select="command" />
+ {
+ NULL,
+ <value-of select="interface/@name"/>_ErrorHandlerRepeat,
+ COMMAND_ERRORHANDLER,
+ 1
+ },
+ /* ADD MORE COMMANDS */
+ /*stop block. it can not be removed*/
+ {
+ NULL,
+ NULL,
+ 0xFF,
+ 1
+ }
+};
+</if>
+</if>
+</template>
+
+<template match="group" mode="ActiveApplications">
+<variable name="group" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
+<if test='contains(@supportedcmdtype, "longrunning")'>
+<text> </text>{
+<text> </text><call-template name="groupid" />,
+<text> </text>0,
+<text> </text>Generic<value-of select="interface/@name"/>GroupCommandsList
+<text> </text>},
+</if>
+</if>
+</template>
+
+<template match="/commandspec">
+/*******************************************************************************
+ * $Copyright ST-Ericsson 2010 $
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_module
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+#include &lt;string.h&gt;
+
+#include &quot;ces_commands.h&quot;
+#include &quot;t_command_exec_service.h&quot;
+#include &quot;command_ids.h&quot;
+#include &quot;command_execution_control.h&quot;
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+/*
+ * Commands that need command execution service
+ */
+<apply-templates select="group" mode="CommandsList" />
+
+ApplicationInfo_t ActiveApplications[]=
+{
+<apply-templates select="group" mode="ActiveApplications" />
+/* ADD MORE APPLICATIONS HERE */
+};
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+uint32 Get_ApplicationInfoSize(void)
+{
+ return sizeof(ApplicationInfo_t);
+}
+
+uint32 Get_ActiveApplicationsSize(void)
+{
+ return sizeof(ActiveApplications);
+}
+
+/*@}*/
+</template>
+
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/ces_commands_h.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/ces_commands_h.xsl
new file mode 100644
index 0000000..b425fc6
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/ces_commands_h.xsl
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
+
+<output method="text" indent="no"/>
+<strip-space elements="*"/>
+<param name="target" />
+<param name="supportedCommands" />
+<variable name="supported_commands" select="document($supportedCommands)/commandspec"/>
+
+<template match="command">
+<variable name="group" select="../@number" />
+<variable name="command" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
+<if test='contains(@supportedcmdtype, "longrunning")'>ErrorCode_e <value-of select="../interface/@name"/>_<value-of select="interface/@name"/>Repeat(void* ExecutionContext_p);
+</if>
+</if>
+</template>
+
+<template match="group">
+<variable name="group" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
+<apply-templates select="command"/><if test='contains(@supportedcmdtype, "longrunning")'>ErrorCode_e <value-of select="interface/@name"/>_ErrorHandlerRepeat(void* ExecutionContext_p);
+</if><text>
+</text>
+</if>
+</template>
+
+<template match="/commandspec">
+/*******************************************************************************
+ * $Copyright ST-Ericsson 2010 $
+ ******************************************************************************/
+#ifndef _CES_COMMANDS_H_
+#define _CES_COMMANDS_H_
+/**
+ * @addtogroup ldr_communication_module
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include &quot;error_codes.h&quot;
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+<apply-templates select="group"/>uint32 Get_ApplicationInfoSize(void);
+uint32 Get_ActiveApplicationsSize(void);
+
+/*@}*/
+#endif /*_CES_COMMANDS_H_*/
+</template>
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/command_ids_h.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/command_ids_h.xsl
new file mode 100644
index 0000000..a310b65
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/command_ids_h.xsl
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+<import href="common.xsl"/>
+
+<output method="text" indent="no"/>
+<strip-space elements="*"/>
+<param name="target" />
+<param name="supportedCommands" />
+<variable name="supported_commands" select="document($supportedCommands)/commandspec"/>
+
+<template match="/commandspec">/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _COMMAND_IDS_H
+#define _COMMAND_IDS_H
+#include "t_basicdefinitions.h"
+
+TYPEDEF_ENUM {
+<apply-templates select="group" mode="id"/>} ENUM8(GroupId_e);
+
+typedef enum {
+<apply-templates select="group/command" mode="id"/>} CommandId_e;
+
+<apply-templates select="typedef" />
+#endif /* _COMMAND_IDS_H */
+</template>
+
+<template match="typedef">
+typedef struct <value-of select="interface/@name" />_s
+{
+<apply-templates select="value" />}<value-of select="interface/@name" />_t;
+</template>
+
+<template match="value">
+ <text> </text>
+ <choose>
+ <when test="@type='string'">
+ char *<text> </text><value-of select="@name" />; /**&lt; <value-of select="text()" /> */
+ </when>
+ <when test="@type='uint32'">
+ <value-of select="@type" /><text> </text><value-of select="@name" />; /**&lt; <value-of select="text()" /> */
+ </when>
+ <when test="@type='uint64'">
+ <value-of select="@type" /><text> </text><value-of select="@name" />; /**&lt; <value-of select="text()" /> */
+ </when>
+ </choose>
+ <if test="position() = last()"><text></text>
+ </if>
+</template>
+
+<template match="group" mode="id">
+<variable name="group" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
+ <text> </text><call-template name="groupid" /> = <choose> <when test="@number&lt;10"> <value-of select="substring-after(@number, '0')" /> </when> <otherwise> <value-of select="@number"/> </otherwise> </choose>, /**&lt; <value-of select="@name" /> */
+</if>
+</template>
+
+<template match="group[last()]" mode="id">
+<variable name="group" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
+ <text> </text><call-template name="groupid" /> = <choose> <when test="@number&lt;10"> <value-of select="substring-after(@number, '0')" /> </when> <otherwise> <value-of select="@number"/> </otherwise> </choose> /**&lt; <value-of select="@name" /> */
+</if>
+</template>
+
+<template match="command" mode="id">
+<variable name="group" select="../@number" />
+<variable name="command" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
+ <text> </text><call-template name="commandid" /> = <value-of select="@number" />, /**&lt; <value-of select="@name" /> */
+</if>
+</template>
+
+<template match="group[last()]/command[last()]" mode="id">
+<variable name="group" select="../@number" />
+<variable name="command" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
+ <text> </text><call-template name="commandid" /> = <value-of select="@number" /> /**&lt; <value-of select="@name" /> */
+</if>
+</template>
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/command_marshal.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/command_marshal.xsl
new file mode 100644
index 0000000..e351827
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/command_marshal.xsl
@@ -0,0 +1,354 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
+
+<import href="common.xsl"/>
+
+<output method="text"/>
+<strip-space elements="*"/>
+<param name="target"/>
+<param name="supportedCommands" />
+<variable name="supported_commands" select="document($supportedCommands)/commandspec"/>
+
+<template match="group/documentation" mode="marshal">
+<variable name="group" select="../@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
+/*
+ * <value-of select="normalize-space(.)"/>
+ */
+</if>
+</template>
+
+<template match="group/documentation" mode="unmarshal">
+<variable name="group" select="../@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
+ /*
+ * <value-of select="normalize-space(.)"/>
+ */
+</if>
+</template>
+
+<template name="unmarshal">
+<param name="name"/>
+<param name="direction"/>
+
+<choose>
+ <when test="@flag='true'">
+#ifdef CFG_ENABLE_ADBG_LOADER</when>
+</choose>
+<choose>
+ <when test="@flag='true1'">
+#ifdef CFG_ENABLE_AUDIT_CMD</when>
+</choose>
+<choose>
+ <when test="@flagbitsset='trueset'">
+#ifndef CFG_ENABLE_WRITEBITS_CMD</when>
+</choose>
+<choose>
+ <when test="@flagwritebits='truewrite'">
+#ifdef CFG_ENABLE_WRITEBITS_CMD</when>
+</choose>
+<choose>
+<when test="name($direction)='input'">
+ /* Command <value-of select="../@name"/> / <value-of select="@name"/> (<value-of select="../@number"/> / <value-of select="@number"/>) */
+ case COMMAND(FALSE, <call-template name="groupid"><with-param name="path" select=".."/></call-template>, <call-template name="commandid"/>):
+ {
+ <apply-templates select="input/value" mode="deserialize_size" />
+
+ <apply-templates select="input/value" mode="deserialize" />
+ Status = <value-of select="$name" />(Session<if test="count(input/value) > 0">, </if><apply-templates select="input/value" mode="call" />);
+ <apply-templates select="input/value" mode="clean"/>
+ }
+ break;
+</when>
+<when test="name($direction)='output'">
+ /* Response to <value-of select="../@name"/> / <value-of select="@name"/> (<value-of select="../@number"/> / <value-of select="@number"/>) */
+ case COMMAND(TRUE, <call-template name="groupid"><with-param name="path" select=".."/></call-template>, <call-template name="commandid"/>):
+ {
+ <apply-templates select="output/value" mode="deserialize_size" />
+
+ ResponseStatus = (ErrorCode_e)get_uint32_le(&amp;Data_p);
+ <apply-templates select="output/value" mode="deserialize" />
+ Status = <value-of select="$name" />(Session, ResponseStatus<if test="count(output/value) > 0">, </if><apply-templates select="output/value" mode="call"></apply-templates>);
+ <apply-templates select="output/value" mode="clean"/>
+ }
+ break;
+</when>
+</choose>
+
+<choose>
+ <when test="@flagbitsset='trueset'">#endif
+ </when>
+</choose>
+<choose>
+ <when test="@flagwritebits='truewrite'">#endif
+ </when>
+</choose>
+<choose>
+ <when test="@flag='true1'">#endif
+ </when>
+</choose>
+<choose>
+ <when test="@flag='true'">#endif
+ </when>
+</choose>
+</template>
+
+
+<template match="/commandspec">/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+#include &lt;string.h&gt;
+
+#include "t_command_protocol.h"
+#include "r_debug.h"
+#include "r_communication_service.h"
+#include "commands.h"
+#include "custom_commands.h"
+#include "command_ids.h"
+#include "commands_impl.h"
+#include "error_codes.h"
+#include "r_serialization.h"
+#include "r_command_protocol.h"
+#ifdef CFG_ENABLE_ADBG_LOADER
+#include "r_adbg_applications.h"
+#endif
+
+#ifdef CFG_ENABLE_AUDIT_CMD
+#include "audit.h"
+#endif
+
+#ifdef CFG_ENABLE_ADBG_LOADER
+#include "r_adbg_command.h"
+#endif
+
+#define COMMAND(response, group, id) ((((int)(response)) &lt;&lt; 30) | (((int)(group)) &lt;&lt; 16) | ((int)(id)))
+#define COMMANDDATA(TypeP,ApplicationP,CommandP,SessionP,SizeP)\
+ memset((uint8*)&amp;CmdData, 0x00, sizeof(CommandData_t));\
+ CmdData.Type = TypeP;\
+ CmdData.ApplicationNr = ApplicationP;\
+ CmdData.CommandNr = CommandP;\
+ CmdData.SessionNr = SessionP;\
+ CmdData.Payload.Size = SizeP;\
+ CmdData.Payload.Data_p = NULL;\
+ CmdData.Payload.Data_p = (uint8*)malloc(SizeP);\
+ if (NULL == CmdData.Payload.Data_p)\
+ {\
+ A_(printf("command_marshal.c (%d): ** memory allocation failed! **\n",__LINE__);)\
+ return E_ALLOCATE_FAILED;\
+ }\
+
+#define COMMANDDATAOUT(TypeP,ApplicationP,CommandP,SizeP)\
+ memset((uint8*)&amp;CmdData, 0x00, sizeof(CommandData_t));\
+ CmdData.Type = TypeP;\
+ CmdData.ApplicationNr = ApplicationP;\
+ CmdData.CommandNr = CommandP;\
+ CmdData.SessionNr = 0;\
+ CmdData.Payload.Size = SizeP;\
+ CmdData.Payload.Data_p = NULL;\
+ if (0 != SizeP)\
+ {\
+ CmdData.Payload.Data_p = (uint8 *)malloc( SizeP);\
+ if (NULL == CmdData.Payload.Data_p)\
+ {\
+ A_(printf("command_marshal.c (%d): ** memory allocation failed! **\n",__LINE__);)\
+ return E_ALLOCATE_FAILED;\
+ }\
+ }
+
+//static uint16 Session;
+
+void disable_interrupt(void)
+{
+#ifndef WIN32
+/* todo implement this */
+//#warning This is disable_interrupt
+#endif
+}
+void enable_interrupt(void)
+{
+#ifndef WIN32
+/* todo implement this */
+//#warning This is enable_interrupt
+#endif
+}
+
+ErrorCode_e Do_CEH_Call(void *Object_p, CommandData_t *CmdData_p)
+{
+ ErrorCode_e Status = E_GENERAL_FATAL_ERROR;
+// uint32 PL_GRSize = 0;
+ ErrorCode_e ResponseStatus = E_GENERAL_FATAL_ERROR;
+ boolean response = FALSE;
+// CommandPermissionList_t* CmdPermission_p;
+ void *Data_p = CmdData_p-&gt;Payload.Data_p;
+ uint16 Session = CmdData_p-&gt;SessionNr;
+
+ if (CmdData_p-&gt;Type == GENERAL_RESPONSE_PACKAGE)
+ {
+ response = TRUE;
+// PL_GRSize = CmdData_p-&gt;Payload.Size;
+// ResponseStatus = (ErrorCode_e)get_uint16(&amp;Data_p);
+ }
+
+#ifdef CFG_ENABLE_AUDIT_CMD
+ if(COMMAND_TYPE == CmdData_p-&gt;Type)
+ {
+ ErrorCode_e AuditResponse = CommandAudit(CmdData_p);
+ CommandData_t CmdData = {0};
+ uint32 PLSize = sizeof(ErrorCode_e);
+
+ if (E_SUCCESS != AuditResponse)
+ {
+ memset((uint8*)&amp;CmdData, 0x00, sizeof(CommandData_t));
+
+ CmdData.Type = GENERAL_RESPONSE;
+ CmdData.CommandNr = CmdData_p-&gt;CommandNr;
+ CmdData.ApplicationNr = CmdData_p-&gt;ApplicationNr;
+ CmdData.SessionNr = CmdData_p-&gt;SessionNr;
+ CmdData.Payload.Size = PLSize;
+ CmdData.Payload.Data_p = NULL;
+ CmdData.Payload.Data_p = (uint8*)malloc(PLSize);
+ if (NULL == CmdData.Payload.Data_p)
+ {
+ A_(printf("command_marshal.c (%d): ** memory allocation failed! **\n",__LINE__);)
+ return E_ALLOCATE_FAILED;
+ }
+
+ Data_p = CmdData.Payload.Data_p;
+ put_uint32(&amp;Data_p, AuditResponse);
+
+ Status = Do_R15_Command_Send(GlobalCommunication_p, &amp;CmdData);
+ if (NULL != CmdData.Payload.Data_p)
+ {
+ free(CmdData.Payload.Data_p);
+ }
+
+ if (E_SUCCESS != Status)
+ {
+ return Status;
+ }
+
+ if (E_UNSUPPORTED_CMD == AuditResponse)
+ {
+ Status = Do_System_ShutDownImpl(CmdData.SessionNr);
+ }
+ return Status;
+ }
+ }
+#endif
+
+ switch(COMMAND(response, CmdData_p-&gt;ApplicationNr, CmdData_p-&gt;CommandNr))
+ {
+ <apply-templates select="group" mode="unmarshal"/>
+ default:
+ {
+ Status = Do_CustomCEH_Call(CmdData_p);
+ if (E_SUCCESS != Status)
+ {
+ Status = Do_System_ShutDownImpl(Session);
+ }
+ }
+ break;
+ }
+
+ return Status;
+}
+
+ <apply-templates select="group" mode="marshal"/>
+
+</template>
+
+<template match="group/command" mode="marshal">
+<variable name="group" select="../@number" />
+<variable name="command" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
+<choose>
+ <when test="@flag='true'">
+#ifdef CFG_ENABLE_ADBG_LOADER</when>
+</choose>
+ <if test="contains(@source, 'ME')">
+ErrorCode_e <value-of select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />(<choose><when test="count(input/value) > 0"><apply-templates select="input/value" mode="declare" /></when><otherwise>void</otherwise></choose>)
+{
+ ErrorCode_e Answer;
+ CommandData_t CmdData;
+ void *Data_p;
+ uint32 PLSize =0;
+ <apply-templates select="input/value" mode="serialize_size_declaration" />
+
+ <apply-templates select="input/value" mode="serialize_size"/>
+ COMMANDDATAOUT(COMMAND_TYPE, <call-template name="groupidmain"/>, <call-template name="commandid"/>, PLSize);
+ Data_p = CmdData.Payload.Data_p;
+ (void)(Data_p); //XVSZOAN Temporary solution!
+ <apply-templates select="input/value" mode="serialize"/>
+ Answer = Do_R15_Command_Send(GlobalCommunication_p, &amp;CmdData);
+ if(NULL != CmdData.Payload.Data_p)
+ free(CmdData.Payload.Data_p);
+ return Answer;
+}
+</if>
+ <if test="contains(@source, 'PC')">
+ErrorCode_e <value-of select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />(uint16 Session, ErrorCode_e Status<if test="count(output/value) > 0">, </if><apply-templates select="output/value" mode="declare"></apply-templates>)
+{
+ ErrorCode_e Answer;
+ CommandData_t CmdData;
+ void *Data_p;
+ uint32 PLSize =0;
+ <apply-templates select="output/value" mode="serialize_size_declaration" />
+ PLSize += sizeof(ErrorCode_e);
+ <apply-templates select="output/value" mode="serialize_size"/>
+ COMMANDDATA(GENERAL_RESPONSE, <call-template name="groupidmain"/>, <call-template name="commandid"/>, Session, PLSize);
+ Data_p = CmdData.Payload.Data_p;
+
+ put_uint32(&amp;Data_p, Status);
+ <apply-templates select="output/value" mode="serialize"/>
+ <choose>
+ <when test="@ADbg!='true'">
+#ifdef CFG_ENABLE_ADBG_LOADER
+ Answer = ReleaseADbg_AppFunc(Status);</when>
+ </choose>
+ Answer = E_SUCCESS;
+ <choose>
+ <when test="@ADbg!='true'">
+#else </when>
+ </choose>
+ Answer = Do_R15_Command_Send(GlobalCommunication_p, &amp;CmdData);
+ <choose>
+ <when test="@ADbg!='true'">
+#endif</when>
+ </choose>
+ if(NULL != CmdData.Payload.Data_p)
+ free(CmdData.Payload.Data_p);
+ return Answer;
+}
+ </if>
+<choose>
+<when test="@flag='true'">#endif
+</when>
+</choose>
+</if>
+</template>
+
+<template match="group/command" mode="unmarshal">
+<variable name="group" select="../@number" />
+<variable name="command" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
+ <if test="contains(@source, 'PC')">
+ <call-template name="unmarshal">
+ <with-param name="name" select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="input"/>
+ </call-template>
+ </if>
+ <if test="contains(@source, 'ME')">
+ <call-template name="unmarshal">
+ <with-param name="name" select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="output"/>
+ </call-template>
+ </if>
+</if>
+</template>
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/commands.xml b/lcmodule/source/cnh1606344_ldr_communication_module/config/commands.xml
new file mode 100644
index 0000000..4274666
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/commands.xml
@@ -0,0 +1,1191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<?xml-stylesheet type="text/xml" href="command_ids_h.xsl"?>
+<?xml-stylesheet type="text/xml" href="command_marshal.xsl"?>
+<?xml-stylesheet type="text/xml" href="commands_h.xsl"?>
+<?xml-stylesheet type="text/xml" href="commands_impl_h.xsl"?>
+<?xml-stylesheet type="text/xml" href="common.xsl"?>
+
+
+<commandspec>
+
+ <typedef>
+ <interface type="loader" name="SupportedCommand"/>
+ <value type="uint32" name="Group">Application Group number</value>
+ <value type="uint32" name="Command">Command number</value>
+ <value type="uint32" name="Permitted">Permission value</value>
+ </typedef>
+
+ <typedef>
+ <interface type="loader" name="ListDevice"/>
+ <value type="string" name="Path_p">Absolute device path pointing of the described device</value>
+ <value type="string" name="Type_p">Type of the device</value>
+ <value type="uint64" name="BlockSize">Size of the smallest addressable unit in the device in bytes</value>
+ <value type="uint64" name="Start">Offset in bytes of the start of the device relative to its parents offset 0 with a granularity of its parents block size</value>
+ <value type="uint64" name="Length">Length of the device in bytes</value>
+ </typedef>
+
+ <typedef>
+ <interface type="loader" name="DirEntry"/>
+ <value type="string" name="Name_p">Name of file or directory</value>
+ <value type="uint64" name="Size">Size of file or directory</value>
+ <value type="uint32" name="Mode">Indicator if it is file or directory</value>
+ <value type="uint32" name="Time">Time of last modification</value>
+ </typedef>
+
+ <typedef>
+ <interface type="loader" name="Cipher"/>
+ <value type="string" name="Name_p">supported ciphers</value>
+ </typedef>
+
+ <AuthenticationList>
+ <value number="1" name="A1">A1</value>
+ <value number="2" name="CA">CA</value>
+ </AuthenticationList>
+
+ <PermissionList>
+ <value number="0" name="ServiceModeLevel">ServiceModeLevel</value>
+ <value number="1" name="FlashModeLevel">FlashModeLevel</value>
+ <value number="64" name="AdvanceServiceModeLevel">AdvanceServiceModeLevel</value>
+ <value number="65" name="LimitedProductionModeLevel">LimitedProductionModeLevel</value>
+ <value number="66" name="VeryLimitedProductionModeLevel">VeryLimitedProductionModeLevel</value>
+ <value number="127" name="ProductionModeLevel">ProductionModeLevel</value>
+ </PermissionList>
+
+<!--
+ Predefine generic type of data are: uint32, string and buffer.
+ !!!!! IMPORTANT !!!!!
+ All new types of data (structures or vectors of structures) that need to be defined should first be reviewed and approved by:
+ Hans Holmberg (QHANHOL) for loaders, Mikael Sjolen XX for PTK and Daniel Chong for PA.
+ -->
+
+ <group number="01" name="System application" supportedcmdtype="longrunning,shortrunning">
+ <documentation>
+ System commands group (0x01)
+ </documentation>
+ <interface type="loader" name="System"/>
+
+ <command number="1" name="Loader Start-up Status" ADbg="false" source="ME">
+ <interface type="loader" name="LoaderStartUpStatus"/>
+ <documentation>
+ The Loader Start-up Status command is sent by the ME to notify the host that it has started. The Status parameter indicates in what mode the Loader started.
+ </documentation>
+ <input>
+ <value type="uint32" name="Status">0 = started successfully, 1 = failed to start (lack of permissions), 2 = software module failed to initialize</value>
+ <value type="string" name="LoaderVersion_p">Loader version identifier</value>
+ <value type="string" name="ProtocolVersion_p">Protocol version identifier</value>
+ </input>
+ <output>
+ </output>
+ </command>
+
+ <command number="3" name="System Reboot" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <interface type="loader" name="Reboot"/>
+ <documentation>
+ The Reboot command is used to instruct the Loader to reset the ME. Upon receiving this command, the Loader shuts down in a controlled fashion and restarts the ME. The Mode parameter is used to select the mode of reset.
+ </documentation>
+ <input>
+ <value type="uint32" name="Mode">0 = normal restart, 1 = restart in service mode, 2 = restart with JTAG debugging enabled, 3 = restart in service mode and with JTAG debugging enabled</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="4" name="System Shutdown" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <interface type="loader" name="ShutDown"/>
+ <documentation>
+ The Loader shuts down in a controlled fashion and proceeds to shut down the ME itself.
+ </documentation>
+ <input>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="5" name="System Supported Command" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <interface type="loader" name="SupportedCommands"/>
+ <documentation>
+ The Loader returns a list of implemented commands and whether they are permitted to execute in the current Loader state. Further fine-grained permission controls might also deny execution of a specific command.
+ </documentation>
+ <input>
+ </input>
+ <output>
+ <value type="uint32" name="CommandCount">Number of implemented commands</value>
+ <value type="SupportedCommand" name="Commands" length="CommandCount">An array of command identifiers. The Permitted field indicates whether the command can be executed at the current time (non-zero value means allowed)</value>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="6" name="System Execute Software" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <interface type="loader" name="ExecuteSoftware"/>
+ <documentation>
+ Receive, verify and execute software, which can be a signed Loader. After having sent this command, the ME will attempt to read the software payload data from the host using the Bulk protocol or from the flash file system depending on the selected path.
+ </documentation>
+ <input>
+ <value type="uint32" name="ExecuteMode">Execute mode: 1 = execution from specified address, 2 = first load the software then execute.</value>
+ <value type="string" name="SourcePath_p">File system or Bulk id path</value>
+ <value type="uint64" name="Length">Total length of the execute software file</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="7" name="System Authenticate" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <interface type="loader" name="Authenticate"/>
+ <documentation>
+ This command is used to escalate the privileges of the operator. Two modes of authentication are available by default; Control Key authentication and Certificate based authentication. The authentication command sets the loader in a specific authentication context when it takes control over the command flow. After receiving the authentication command, the Loader will send the appropriate request for information to the PC.
+ </documentation>
+ <input>
+ <value type="uint32" name="Type">Authentication type: 0 = Control Key authentication, 1 = Certificate authentication.</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="8" name="System Get Control Keys" ADbg="false" source="ME">
+ <interface type="loader" name="GetControlKeys"/>
+ <documentation>
+ This command is used by the Loader to retrieve the SimLock Control Keys from the host in order to authenticate a user. The command is used in authentication context.
+ </documentation>
+ <input>
+ </input>
+ <output>
+ <value type="string" name="NLCKLock_p"/>
+ <value type="string" name="NSLCKLock_p"/>
+ <value type="string" name="SPLCKLock_p"/>
+ <value type="string" name="CLCKLock_p"/>
+ <value type="string" name="PCKLock_p"/>
+ <value type="string" name="ESLCKLock_p"/>
+ <value type="string" name="NLCKUnlock_p"/>
+ <value type="string" name="NSLCKUnlock_p"/>
+ <value type="string" name="SPLCKUnlock_p"/>
+ <value type="string" name="CLCKUnlock_p"/>
+ <value type="string" name="PCKUnlock_p"/>
+ <value type="string" name="ESLCKUnlock_p"/>
+ </output>
+ </command>
+
+ <command number="9" name="System Authentication Challenge" ADbg="false" source="ME">
+ <interface type="loader" name="AuthenticationChallenge"/>
+ <documentation>
+ This command is used by the Loader to perform a certificate authentication. The command is only used in authentication context.
+ </documentation>
+ <input>
+ <value type="uint32" name="ChallengeBlockLength">Authentication Challenge buffer length</value>
+ <value type="buffer" name="ChallengeBlock_p" length="ChallengeBlockLength">Authentication Challenge that must be signed using the correct certificate and returned to the Loader</value>
+ </input>
+ <output>
+ <value type="uint32" name="ResponseBlockLength">Updated authentication challenge buffer length</value>
+ <value type="buffer" name="ResponseBlock_p" length="ResponseBlockLength">Signed authentication challenge together with the requested permissions.</value>
+ </output>
+ </command>
+
+ <command number="10" name="System Collect Data" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <interface type="loader" name="CollectData"/>
+ <documentation>
+ This command is used to collect printouts (debug data) and measurements results.
+ </documentation>
+ <input>
+ <value type="uint32" name="Type">Type of requested data.</value>
+ </input>
+ <output>
+ <value type="uint32" name="DataLenght">Length of output buffer.</value>
+ <value type="buffer" name="CollectedData_p" length="DataLenght">Output data buffer. Contain debug data (printouts) or measurement data.</value>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="11" name="System Get Progress Status" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <interface type="loader" name="GetProgressStatus"/>
+ <documentation>
+ This command is used by the Loader to get the minimal progress status from all running commands.
+ </documentation>
+ <input>
+ </input>
+ <output>
+ <value type="uint32" name="ProgressStatus">Command progress status presented in percent.</value>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="12" name="Set System Time" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <interface type="loader" name="SetSystemTime"/>
+ <documentation>
+ The Set System Time command is used to instruct the Loader to use real world time and date during its run time. Upon receiving this command, the Loader sets internal Real Time Clock. This command can be issued more then once by PC tool.
+ </documentation>
+ <input>
+ <value type="uint32" name="EpochTime">Number of seconds since January 1, 1970 (midnight UTC/GMT).</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="13" name="Switch Communication Device" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <interface type="loader" name="SwitchCommunicationDevice"/>
+ <documentation>
+ This command is used to instruct the Loader to switch to a new communication device.
+ </documentation>
+ <input>
+ <value type="uint32" name="Device">Communication device number to switch to.</value>
+ <value type="uint32" name="DeviceParam">Communication device parameters.</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="14" name="System Get Control Keys Data" ADbg="false" source="ME">
+ <interface type="loader" name="GetControlKeysData"/>
+ <documentation>
+ This command is used by the Loader to retrieve the SimLock Control Keys data buffer from the host in order to authenticate a user. The command is used in authentication context.
+ </documentation>
+ <input>
+ </input>
+ <output>
+ <value type="uint32" name="iDataSize">Length of output buffer.</value>
+ <value type="buffer" length="iDataSize" name="SIMLockKeysData_p">Data buffer with all SIMLock keys.</value>
+ </output>
+ </command>
+ </group>
+
+ <group number="02" name="Flash application" supportedcmdtype="longrunning,shortrunning">
+ <documentation>
+ Flash Commands group (0x02)
+ </documentation>
+ <interface type="loader" name="Flash"/>
+ <command number="1" name="Process File" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ This command is used to initiate a flashing session. The Type argument is used to select the type of file to process and Length parameter defines the total size of the file.
+ </documentation>
+ <interface type="loader" name="ProcessFile"/>
+ <input>
+ <value type="uint64" name="Length">Total length of the opened file</value>
+ <value type="string" name="Type_p">Type of the opened file. Currently the only supported type is x-empflash/flasharchive </value>
+ <value type="string" name="SourcePath_p">File system or Bulk id path</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="2" name="List Devices" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ The Loader returns a list of detected block devices. A block device can be a physical device ( flash0 , mmc0 , usb0 ), a logical device ( cabs0 , mbbs0 ) or a file system volume ( boot , sys ). Together they form paths on the form /flash0/mbbs0 or /flash1/cabs1/vfat .
+ </documentation>
+ <interface type="loader" name="ListDevices"/>
+ <input>
+ </input>
+ <output>
+ <value type="uint32" name="DeviceCount">Indicates the number of returned devices</value>
+ <value type="ListDevice" name="Devices" length="DeviceCount">Absolute device path, Type of the device, Block Size, Start address of the device, Length of the device</value>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="3" name="Dump Area" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ This command is used to initiate a Dump session.
+ </documentation>
+ <interface type="loader" name="DumpArea"/>
+ <input>
+ <value type="string" name="Path_p">Path to the device to dump.</value>
+ <value type="uint64" name="Start">Start of the dump relative to the start of the device indicated by Path in bytes. Actual start is determined by the Mode parameter.</value>
+ <value type="uint64" name="Length">Length of the dump in bytes. Actual length is determined by the Mode parameter.</value>
+ <value type="string" name="TargetPath_p">File system or bulk id path.</value>
+ <value type="uint32" name="RedundantArea">If set to 0 dump flash including redundant area, if set to 1 dump flash without redundant area.</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="4" name="Erase Area" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ This command is used to erase a flash device or part of a flash device.
+ </documentation>
+ <interface type="loader" name="EraseArea"/>
+ <input>
+ <value type="string" name="Path_p">Path to the device to erase.</value>
+ <value type="uint64" name="Start">Start of the dump relative to the start of the device indicated by Path in bytes. This must be a multiple of the block size of the device.</value>
+ <value type="uint64" name="Length">Length of the dump in bytes. This must be a multiple of the block size of the device.</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="5" name="Flash RAW" ADbg = "false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ This command is used to flash raw flash image.
+ </documentation>
+ <interface type="loader" name="FlashRaw" />
+ <input>
+ <value type="uint64" name="Start">Address where RAW image should be written. This must be a multiple of the block size of the device.</value>
+ <value type="uint64" name="Length">Length of RAW data in bytes</value>
+ <value type="uint32" name="Device">Target flash device.[0,1]</value>
+ <value type="string" name="SourcePath_p">Bulk id path</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref ="A1"/>
+ <value ref ="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ </group>
+
+ <group number="03" name="File system operations" supportedcmdtype="longrunning,shortrunning">
+ <documentation>
+ File System Commands Group (0x03)
+ </documentation>
+ <interface type="loader" name="File_System_Operations"/>
+ <command number="2" name="Volume Properties" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Retrieve properties of the specified file system volume
+ </documentation>
+ <interface type="loader" name="VolumeProperties"/>
+ <input>
+ <value type="string" name="DevicePath_p">Path of file system volume</value>
+ </input>
+ <output>
+ <value type="string" name="FS_Type_p">File system type</value>
+ <value type="uint64" name="Size">Total size of the file system (in bytes)</value>
+ <value type="uint64" name="Free">Available space (in bytes)</value>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="3" name="Format Volume" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Formats an unmounted file system volume. This operation fails if the volume is currently in use.
+ </documentation>
+
+ <interface type="loader" name="FormatVolume"/>
+ <input>
+ <value type="string" name="DevicePath_p">Device path of the file system volume</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="4" name="List Directory" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ List files and directories residing in a specified path
+ </documentation>
+ <interface type="loader" name="ListDirectory"/>
+ <input>
+ <value type="string" name="Path_p">File system path</value>
+ </input>
+ <output>
+ <value type="uint32" name="EntriesCount">Number of directory entries</value>
+ <value type="DirEntry" name="Entries" length="EntriesCount">Name and Size of file or directory, Mode as indicator if it is file or directory, Time of last modification</value>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="5" name="Move File" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Moves or renames a file.
+ </documentation>
+ <interface type="loader" name="MoveFile"/>
+ <input>
+ <value type="string" name="SourcePath_p">File system path (source)</value>
+ <value type="string" name="DestinationPath_p">File system path (destination)</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="6" name="Delete File" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Deletes the specified file or directory. The Loader will only delete empty directories.
+ </documentation>
+ <interface type="loader" name="DeleteFile"/>
+ <input>
+ <value type="string" name="TargetPath_p">File system path</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="7" name="Copy File" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Copies a file from the PC to the ME, between two directories or file systems on the ME or from the ME to the PC.
+ </documentation>
+ <interface type="loader" name="CopyFile"/>
+ <input>
+ <value type="string" name="SourcePath_p">File system or bulk id path (source)</value>
+ <value type="string" name="DestinationPath_p">File system or bulk id path (destination)</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="8" name="Create Directory" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Creates a directory
+ </documentation>
+ <interface type="loader" name="CreateDirectory"/>
+ <input>
+ <value type="string" name="TargetPath_p">File system path</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="9" name="Properties (Stat)" ADbg="false" source="PC,ME" supportedcmdtype="longrunning">
+ <documentation>
+ Retrieves the properties of a file or directory
+ </documentation>
+ <interface type="loader" name="Properties"/>
+ <input>
+ <value type="string" name="TargetPath_p">File system path</value>
+ </input>
+ <output>
+ <value type="uint32" name="Mode">File Type and Access restrictions descriptor (see 5.1)</value>
+ <value type="uint64" name="Size">File size in bytes</value>
+ <value type="uint32" name="MTime">Last modification time stamp</value>
+ <value type="uint32" name="ATime">Last access time stamp</value>
+ <value type="uint32" name="CTime">Creation time stamp</value>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="10" name="Change Access (Chmod)" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Changes the access permissions of a path
+ </documentation>
+ <interface type="loader" name="ChangeAccess"/>
+ <input>
+ <value type="string" name="TargetPath_p">File system path</value>
+ <value type="uint32" name="Access">New access permissions</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="11" name="Read Load Modules Manifests" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Read all manifests in elf files and send it to PC
+ </documentation>
+ <interface type="loader" name="ReadLoadModulesManifests"/>
+ <input>
+ <value type="string" name="TargetPath_p">File system path</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ </group>
+
+ <group number="04" name="OTP" supportedcmdtype="longrunning,shortrunning">
+ <documentation>
+ OTP handling commands Group (0x04)
+ </documentation>
+ <interface type="loader" name="OTP"/>
+
+ <command number="1" name="Read Bits" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Reads the specified bits from the OTP
+ </documentation>
+ <interface type="loader" name="ReadBits"/>
+ <input>
+ <value type="uint32" name="OTP_id">Indicates which OTP memory is to be read</value>
+ <value type="uint32" name="Start">Starting offset in bits</value>
+ <value type="uint32" name="Length">Length of read in bits</value>
+ </input>
+ <output>
+ <value type="uint32" name="BitsLength">Length of read bits</value>
+ <value type="uint32" name="DataBitsLength">Length of the DataBits buffer</value>
+ <value type="buffer" name="DataBits_p" length="DataBitsLength">A left-adjusted buffer of the read data. Padded with zeroes. Length of returned value (in bytes), equal to floor((Length + 7) / 8). </value>
+ <value type="uint32" name="LockStatusBitsLength">Length of the LockStatus of read bits</value>
+ <value type="uint32" name="LockStatusLength">Length of the LockStatus buffer</value>
+ <value type="buffer" name="LockStatus_p" length="LockStatusLength">A left-adjusted buffer of the lock status of each read bit. Padded with zeroes. Length of returned value (in bytes), equal to floor((Length + 7) / 8). </value>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="2" name="Set Bits" flagbitsset="trueset" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Writes and locks the specified bits in the OTP
+ </documentation>
+ <interface type="loader" name="SetBits"/>
+ <input>
+ <value type="uint32" name="OTP_id">Indicates which OTP memory is to be read</value>
+ <value type="uint32" name="Start">Starting offset in bits</value>
+ <value type="uint32" name="BitsLength">Length of write in bits</value>
+ <value type="uint32" name="DataBitsLength">Length of DataBits buffer</value>
+ <value type="buffer" name="DataBits_p" length="DataBitsLength">Left-adjusted byte buffer containing the data to be written. Only Length bits will be written.</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="3" name="Write and Lock OTP" flagbitsset="trueset" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Writes and locks the specified bits in the OTP
+ </documentation>
+ <interface type="loader" name="WriteAndLock"/>
+ <input>
+ <value type="uint32" name="OTP_id">Indicates which OTP memory is to be written and locked</value>
+ <value type="uint32" name="ForceWrite">If = 0 - Write only complete lockable areas. If != 0 Write complete lockable areas even if not all bit are received in cache. </value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="4" name="Store Secure Object" flagbitsset="trueset" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Installs Secure objects into OTP or Flash
+ </documentation>
+ <interface type="loader" name="StoreSecureObject"/>
+ <input>
+ <value type="string" name="SourcePath">File system or bulk id path</value>
+ <value type="uint32" name="SecureObjectDestination">Secure Object destination address</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ </group>
+
+ <group number="05" name="Parameter Storage" supportedcmdtype="longrunning,shortrunning">
+ <documentation>
+ Parameter Storage Commands Group (0x05)
+ </documentation>
+ <interface type="loader" name="ParameterStorage"/>
+
+ <command number="1" name="Read Global Data Unit" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Reads the specified unit from Global Data area
+ </documentation>
+ <interface type="loader" name="ReadGlobalDataUnit"/>
+ <input>
+ <value type="string" name="DevicePath_p">GD storage area to read from (gdfs, trim area)</value>
+ <value type="uint32" name="Unit_id">Unit id to read</value>
+ </input>
+ <output>
+ <value type="uint32" name="DataBuffLength">Length of the Data buffer</value>
+ <value type="buffer" name="DataBuff_p" length="DataBuffLength">The read data</value>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="2" name="Write Global Data Unit" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Writes the specified unit to Global Data area
+ </documentation>
+ <interface type="loader" name="WriteGlobalDataUnit"/>
+ <input>
+ <value type="string" name="DevicePath_p">GD storage area to write to (gdfs, trim area)</value>
+ <value type="uint32" name="Unit_id">Unit id to write</value>
+ <value type="uint32" name="DataBuffLength">Length of the Data buffer</value>
+ <value type="buffer" name="DataBuff_p" length="DataBuffLength">The data to write</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="3" name="Read Global Data Set" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Reads a complete Global Data area
+ </documentation>
+ <interface type="loader" name="ReadGlobalDataSet"/>
+ <input>
+ <value type="string" name="DevicePath_p">GD storage area to read (gdfs, trim area)</value>
+ <value type="string" name="TargetPath_p">File system or bulk id path indicating the destination of the read operation</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="4" name="Write Global Data Set" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Writes a complete Global Data area
+ </documentation>
+ <interface type="loader" name="WriteGlobalDataSet"/>
+ <input>
+ <value type="string" name="DevicePath_p">GD storage area to write (gdfs, trim area)</value>
+ <value type="uint64" name="DataLength">Data Length when is used bulk transfer </value>
+ <value type="string" name="SourcePath_p">File system or bulk id path indicating the source of the write operation</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="5" name="Erase Global Data Set" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Erases a complete Global Data area
+ </documentation>
+ <interface type="loader" name="EraseGlobalDataSet"/>
+ <input>
+ <value type="string" name="DevicePath_p">GD storage area to erase (gdfs, trim area)</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ </group>
+
+ <group number="06" name="Security" supportedcmdtype="longrunning,shortrunning">
+ <documentation>
+ Security settings Commands Group (0x06)
+ </documentation>
+ <interface type="loader" name="Security"/>
+
+ <command number="1" name="Set Domain" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Set the ME domain
+ </documentation>
+ <interface type="loader" name="SetDomain"/>
+ <input>
+ <value type="uint32" name="Domain">Target domain</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="2" name="Get Domain" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Get the ME domain
+ </documentation>
+ <interface type="loader" name="GetDomain"/>
+ <input>
+ </input>
+ <output>
+ <value type="uint32" name="CurrentDomain">The ME Domain</value>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="3" name="Get Properties" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Reads a security data unit (such as a secure static or dynamic data unit)
+ </documentation>
+ <interface type="loader" name="GetProperties"/>
+ <input>
+ <value type="uint32" name="Unit_id">Unit id to read</value>
+ </input>
+ <output>
+ <value type="uint32" name="DataBuffLength">Length of the Data buffer</value>
+ <value type="buffer" name="DataBuff_p" length="DataBuffLength">The unit data</value>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="4" name="Set Properties" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Writes a security data unit (such as a secure static or dynamic data unit)
+ </documentation>
+ <interface type="loader" name="SetProperties"/>
+ <input>
+ <value type="uint32" name="Unit_id">Unit id to write</value>
+ <value type="uint32" name="DataBuffLength">Length of the Data buffer</value>
+ <value type="buffer" name="DataBuff_p" length="DataBuffLength">The data to write</value>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="5" name="Bind Properties" ADbg="false" source="PC" supportedcmdtype="longrunning">
+ <documentation>
+ Associates all security data units with the current ME
+ </documentation>
+ <interface type="loader" name="BindProperties"/>
+ <input>
+ </input>
+ <output>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ </group>
+
+ <group number="08" name="ADbg application" supportedcmdtype="shortrunning">
+ <documentation>
+ ADbg test suite (automatic test tool)
+ </documentation>
+
+ <interface type="loader" name="ADbg"/>
+
+ <command number="1" name="List all modules, test cases and its parameters " flag="true" ADbg="true" source="PC">
+ <interface type="loader" name="ListCase"/>
+ <documentation>
+ List all modules, test cases and its parameters
+ </documentation>
+ <input>
+ </input>
+ <output>
+ <value type="uint32" name="CmdDataLength"/>
+ <value type="buffer" name="CmdDataPayLoad_p" length="CmdDataLength">CmdData</value>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="2" name="List all modules, interface groups, interface functions and its parameters " flag="true" ADbg="true" source="PC">
+ <interface type="loader" name="ListInterface"/>
+ <documentation>
+ List all modules, interface groups, interface functions and its parameters
+ </documentation>
+ <input>
+ </input>
+ <output>
+ <value type="uint32" name="CmdDataLength"/>
+ <value type="buffer" name="CmdDataPayLoad_p" length="CmdDataLength">CmdData</value>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="3" name="Set test case precondition " flag="true" ADbg="true" source="PC">
+ <interface type="loader" name="SetPrecondition"/>
+ <documentation>
+ Set test case precondition
+ </documentation>
+ <input>
+ <value type="uint32" name="ModuleId">ModuleId</value>
+ <value type="uint32" name="IntGroupId">IntGroupId</value>
+ <value type="uint32" name="IntFunctionId">IntFunctionId</value>
+ <value type="uint32" name="RecoveryFlag">RecoveryFlag</value>
+ <value type="uint32" name="PreconditionLength"/>
+ <value type="buffer" name="Precondition_p" length="PreconditionLength">Precondition_p</value>
+ </input>
+ <output>
+
+
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="4" name="Recovery test case condition " flag="true" ADbg="true" source="PC">
+ <interface type="loader" name="RecoveryCondition"/>
+ <documentation>
+ Recovery test case condition
+ </documentation>
+ <input>
+ <value type="uint32" name="ModuleId">ModuleId</value>
+ <value type="uint32" name="IntGroupId">IntGroupId</value>
+ <value type="uint32" name="IntFunctionId">IntFunctionId</value>
+ </input>
+ <output>
+
+
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="5" name="Run test case " flag="true" ADbg="true" source="PC">
+ <interface type="loader" name="Run"/>
+ <documentation>
+ Run test case
+ </documentation>
+ <input>
+ <value type="uint32" name="ModuleId">ModuleId</value>
+ <value type="uint32" name="CaseId">CaseId</value>
+ <value type="uint32" name="PreconditionLength"/>
+ <value type="buffer" name="Precondition_p" length="PreconditionLength">Precondition_p</value>
+ </input>
+ <output>
+ <value type="uint32" name="AssertStatus"/>
+
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ <command number="6" name="Protocol test case " flag="true" ADbg="true" source="PC">
+ <interface type="loader" name="ProtocolTest"/>
+ <documentation>
+ Protocol test case
+ </documentation>
+ <input>
+ <value type="uint32" name="NrOfRetransmission">NrOfRetransmission</value>
+ <value type="uint32" name="Type">Type</value>
+ </input>
+ <output>
+ <value type="uint32" name="ProtocolTestStatus"/>
+ </output>
+ <authentication depandancy="or" factory="TRUE" rd="TRUE" product="TRUE" service="TRUE">
+ <value ref="A1"/>
+ <value ref="CA"/>
+ </authentication>
+ <permissions>
+ <value ref="ServiceModeLevel"/>
+ <value ref="FlashModeLevel"/>
+ <value ref="AdvanceServiceModeLevel"/>
+ <value ref="ProductionModeLevel"/>
+ <value ref="LimitedProductionModeLevel"/>
+ <value ref="VeryLimitedProductionModeLevel"/>
+ </permissions>
+ </command>
+
+ </group>
+</commandspec>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/commands_h.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/commands_h.xsl
new file mode 100644
index 0000000..0893fda
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/commands_h.xsl
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
+
+<import href="common.xsl"/>
+
+<output method="text"/>
+<strip-space elements="*"/>
+<param name="target"/>
+<param name="supportedCommands" />
+<variable name="supported_commands" select="document($supportedCommands)/commandspec"/>
+
+<template match="/commandspec">/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _COMMANDS_H
+#define _COMMANDS_H
+#include &quot;error_codes.h&quot;
+#include &quot;t_command_protocol.h&quot;
+#include "command_ids.h"
+
+ErrorCode_e Do_CEH_Call(void *Object_p, CommandData_t *CmdData_p);
+<apply-templates select="group"/>
+#endif /* _COMMANDS_H */
+</template>
+
+<template match="group/command">
+<variable name="group" select="../@number" />
+<variable name="command" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
+ <if test="contains(@source, &apos;ME&apos;)">
+ <call-template name="prototype">
+ <with-param name="name" select="concat(&apos;Do_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name)"/>
+ <with-param name="ref" select="concat(&apos;Done_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name, &apos;Impl&apos;)"/>
+ <with-param name="direction" select="input"/>
+ <with-param name="source" select="&apos;ME&apos;"/>
+ </call-template>
+ </if>
+ <if test="contains(@source, &apos;PC&apos;)">
+ <call-template name="prototype">
+ <with-param name="name" select="concat(&apos;Done_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name)"/>
+ <with-param name="ref" select="concat(&apos;Do_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name, &apos;Impl&apos;)"/>
+ <with-param name="direction" select="output"/>
+ <with-param name="source" select="&apos;PC&apos;"/>
+ </call-template>
+ </if>
+</if>
+</template>
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/commands_impl_h.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/commands_impl_h.xsl
new file mode 100644
index 0000000..650a032
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/commands_impl_h.xsl
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" >
+
+<import href="common.xsl"/>
+
+<output method="text"/>
+<strip-space elements="*"/>
+<param name="target" />
+<param name="supportedCommands" />
+<variable name="supported_commands" select="document($supportedCommands)/commandspec"/>
+
+<template match="/commandspec">/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _COMMANDS_IMPL_H
+#define _COMMANDS_IMPL_H
+#include "error_codes.h"
+<apply-templates select="group" />
+#endif /* _COMMANDS_IMPL_H */
+</template>
+
+<template match="group/documentation">
+<variable name="group" select="../@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
+/*
+ * <value-of select="normalize-space(.)"/>
+ */
+</if>
+</template>
+
+<template match="group/command">
+<variable name="group" select="../@number" />
+<variable name="command" select="@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]/command[@number=$command]'>
+ <if test="contains(@source, 'PC')">
+ <call-template name="prototype">
+ <with-param name="name" select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="ref" select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />
+ <with-param name="direction" select="input" />
+ <with-param name="source" select="'PC'" />
+ </call-template>
+ </if>
+ <if test="contains(@source, 'ME')">
+ <call-template name="prototype">
+ <with-param name="name" select="concat('Done_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="ref" select="concat('Do_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />
+ <with-param name="direction" select="output" />
+ <with-param name="source" select="'PC'" />
+ </call-template>
+ </if>
+</if>
+</template>
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/common.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/common.xsl
new file mode 100644
index 0000000..591d99b
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/common.xsl
@@ -0,0 +1,246 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" >
+
+<param name="supportedCommands" />
+<variable name="supported_commands" select="document($supportedCommands)/commandspec"/>
+
+<!-- Ugly name-mangling templates. upper-case() did not work in this
+ implementation -->
+<template name="groupidmain">
+ <param name="path" select="../." />
+ <value-of select="concat('GROUP_', translate($path/interface[@type='loader']/@name,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'))" />
+</template>
+
+<template name="groupid">
+ <param name="path" select="." />
+ <value-of select="concat('GROUP_', translate($path/interface[@type='loader']/@name,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'))" />
+</template>
+
+<template name="commandid">
+ <param name="path" select="." />
+ <value-of select="translate(concat('COMMAND_', $path/../interface[@type='loader']/@name, '_', $path/interface[@type='loader']/@name),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
+</template>
+
+<template match="value" mode="deserialize">
+ <choose>
+ <when test="@type='uint32'"><text> </text><value-of select="@name" /> = get_uint32_le(&amp;Data_p);
+ </when>
+ <when test="@type='uint64'"><text> </text><value-of select="@name" /> = get_uint64_le(&amp;Data_p);
+ </when>
+ <when test="@type='string'"><text> </text><value-of select="@name" /> = skip_str(&amp;Data_p);
+ </when>
+ <when test="@type='buffer' and @length!='*'"><text> </text><value-of select="@name" /> = Data_p;
+ skip_block( &amp;Data_p, <value-of select="@length" />);
+ </when>
+ </choose>
+ <if test="position() = last()"><text>
+ </text>
+
+
+
+
+
+
+ </if>
+</template>
+
+<template match="value" mode="deserialize_size">
+ <choose>
+ <when test="@type='uint32'"> uint32 <value-of select="@name" />;
+ </when>
+ <when test="@type='uint64'"> uint64 <value-of select="@name" />;
+ </when>
+ <when test="@type='string'"> char *<value-of select="@name" />;
+ </when>
+ <when test="@type='buffer' and @length!='*'"> void *<value-of select="@name" />;
+ </when>
+ </choose>
+ <if test="position() = last()"><text>
+ </text>
+ </if>
+</template>
+
+<template match="value" mode="serialize">
+ <choose>
+ <when test="@type='uint32'">put_uint32_le(&amp;Data_p, <value-of select="@name" />);
+ </when>
+ <when test="@type='uint64'">put_uint64_le(&amp;Data_p, <value-of select="@name" />);
+ </when>
+ <when test="@type='string'">put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);
+ </when>
+ <when test="@type='buffer' and @length='*'">put_block(&amp;Data_p, <value-of select="@name" />, <value-of select="@name" />PLSize);
+ </when>
+ <when test="@type='buffer' and @length!='*'">put_block(&amp;Data_p, <value-of select="@name" />, <value-of select="@length" />);
+ </when>
+ <when test="@type='SupportedCommand' and @length!='*'">if (<value-of select="@name" /> != NULL)
+ {
+ put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);
+ }
+ </when>
+ <when test="@type='ListDevice' and @length!='*'">serialize_device_entries(&amp;Data_p, <value-of select="@name" />, <value-of select="@length" />);<!--put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);-->
+ </when>
+ <when test="@type='DirEntry' and @length!='*'">serialize_directory_entries(&amp;Data_p, <value-of select="@name" />, <value-of select="@length" />);<!--put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);-->
+ </when>
+ <when test="@type='Cipher' and @length!='*'">put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);
+ </when>
+ </choose>
+ <if test="position() = last()"><text></text>
+ </if>
+</template>
+
+<template match="value" mode="serialize_size">
+ <choose>
+ <when test="@type='uint32'">PLSize += sizeof(uint32);
+ </when>
+ <when test="@type='uint64'">PLSize += sizeof(uint64);
+ </when>
+ <when test="@type='string'">PLSize += PLSize<value-of select="@name" /> = get_uint32_string_le((void**)&amp;<value-of select="@name" />);
+ </when>
+ <when test="@type='buffer' and @length!='*'">PLSize += <value-of select="@length" />;
+ </when>
+ <when test="@type='SupportedCommand' and @length!='*'">PLSize += PLSize<value-of select="@name" /> = <value-of select="@length" /> * sizeof(SupportedCommand_t);
+ </when>
+ <when test="@type='ListDevice' and @length!='*'">PLSize += get_device_entries_len(<value-of select="@name" />, <value-of select="@length" />); <!--PLSize<value-of select="@name" /> = <value-of select="@length" /> * sizeof(DirEntry_t);-->
+ </when>
+ <when test="@type='DirEntry' and @length!='*'">PLSize += get_directory_entries_len(<value-of select="@name" />, <value-of select="@length" />); <!--PLSize<value-of select="@name" /> = <value-of select="@length" /> * sizeof(DirEntry_t);-->
+ </when>
+ <when test="@type='Cipher' and @length!='*'">PLSize += PLSize<value-of select="@name" /> = <value-of select="@length" /> * sizeof(Cipher_t);
+ </when>
+ </choose>
+ <if test="position() = last()"><text></text>
+ </if>
+</template>
+
+<template match="value" mode="serialize_size_declaration">
+ <choose>
+ <when test="@type='string'">uint32 PLSize<value-of select="@name" /> = 0;
+ </when>
+ <when test="@type='SupportedCommand'">uint32 PLSize<value-of select="@name" /> = 0;
+ </when>
+ <!--<when test="@type='ListDevice'">uint32 PLSize<value-of select="@name" /> = 0;
+ </when>-->
+ <!--<when test="@type='DirEntry'">uint32 PLSize<value-of select="@name" /> = 0;
+ </when>-->
+ <when test="@type='Cipher'">uint32 PLSize<value-of select="@name" /> = 0;
+ </when>
+ </choose>
+ <if test="position() = last()"><text></text>
+ </if>
+</template>
+
+<template match="value" mode="perm">
+ <if test="position() > 1">,
+ </if>
+ <value-of select="@ref" />
+</template>
+
+<template match="value" mode="auth">
+ <if test="position() > 1">,
+ </if>
+ <value-of select="@ref" />
+</template>
+
+<template match="value" mode="permnumber">
+ <if test="position() = last()">
+ <value-of select="position()" />
+ </if>
+</template>
+
+<template match="value" mode="authnumber">
+ <if test="position() = last()">
+ <value-of select="position()" />
+ </if>
+</template>
+
+<template match="value" mode="clean">
+<choose>
+ <when test="@type='string'"></when>
+</choose>
+</template>
+
+<template match="value" mode="document">
+ * @param [in] <value-of select="@name" /><text> </text><value-of select="text()" />
+<if test="position() = last()">
+ * </if>
+</template>
+
+<template match="value" mode="declare">
+ <if test="position() > 1">, </if>
+<choose>
+ <when test="@type='uint32'">const uint32 <value-of select="@name" /></when>
+ <when test="@type='uint64'">const uint64 <value-of select="@name" /></when>
+ <when test="@type='string'">const char *<value-of select="@name" /></when>
+ <when test="@type='buffer' and @length='*'">int <value-of select="@name" />Length, const void *<value-of select="@name" /></when>
+ <when test="@type='buffer' and @length!='*'"> void *<value-of select="@name" /></when>
+ <when test="@type='SupportedCommand' and @length!='*'">SupportedCommand_t <value-of select="@name" />[]</when>
+ <when test="@type='ListDevice' and @length!='*'">ListDevice_t <value-of select="@name" />[]</when>
+ <when test="@type='DirEntry' and @length!='*'">DirEntry_t <value-of select="@name" />[]</when>
+ <when test="@type='Cipher' and @length!='*'">Cipher_t <value-of select="@name" />[]</when>
+</choose>
+</template>
+
+<template match="value" mode="call">
+ <if test="position() > 1">, </if>
+<choose>
+ <when test="@type='uint32'"><value-of select="@name" /></when>
+ <when test="@type='uint64'"><value-of select="@name" /></when>
+ <when test="@type='string'"><value-of select="@name" /></when>
+ <when test="@type='buffer' and @length='*'"><value-of select="@name" />Length, <value-of select="@name" /></when>
+ <when test="@type='buffer' and @length!='*'"><value-of select="@name" /></when>
+</choose>
+</template>
+
+<template match="group/documentation">
+<variable name="group" select="../@number" />
+<if test='$target="lcm" or $supported_commands/group[@number=$group]'>
+/*
+ * <value-of select="normalize-space(.)"/>
+ */
+</if>
+</template>
+
+<template name="prototype">
+<param name="name" />
+<param name="direction" />
+<param name="source" />
+<param name="ref" />
+<choose>
+<when test="name($direction)='input' and contains($source, 'PC')">
+/**
+ * <value-of select="normalize-space(./documentation/text())"/>
+ * \see <value-of select="$ref"/>
+ * Call source: <value-of select="$source"/>
+ * @param [in] Session Input session.<apply-templates select="input/value" mode="document" />
+ * @return ErrorCode_e ...
+ */
+ErrorCode_e <value-of select="$name"/>(uint16 Session<if test="count(input/value) > 0">, </if><apply-templates select="input/value" mode="declare"/>);</when>
+<when test="name($direction)='input' and contains($source, 'ME')">
+/**
+ * <value-of select="normalize-space(./documentation/text())"/>
+ * \see <value-of select="$ref"/>
+ * Call source: <value-of select="$source"/>
+ * <apply-templates select="input/value" mode="document" />
+ * @return ErrorCode_e ...
+ */
+ErrorCode_e <value-of select="$name"/>(<choose><when test="count(input/value) > 0"><apply-templates select="input/value" mode="declare"/></when><otherwise>void</otherwise></choose>);</when>
+<when test="name($direction)='output'">
+/**
+ * Response to \see <value-of select="$ref"/>
+ * Call source: <value-of select="$source"/>
+ * @param [in] Session Transfered input session.
+ * @param [in] Status Completion status code.
+ * <apply-templates select="output/value" mode="document" />
+ * @return ErrorCode_e ...
+ */
+ErrorCode_e <value-of select="$name"/>(uint16 Session, ErrorCode_e Status<if test="count(output/value) > 0">, </if><apply-templates select="output/value" mode="declare"></apply-templates>);</when>
+</choose>
+<text>
+</text>
+</template>
+
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/error_codes.xml b/lcmodule/source/cnh1606344_ldr_communication_module/config/error_codes.xml
new file mode 100644
index 0000000..549b369
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/error_codes.xml
@@ -0,0 +1,873 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<commandspec>
+ <status>
+ <!--
+ * General Fatal 0-50
+ * General non-fatal 51-99
+ -->
+ <value number="0" name="E_SUCCESS" fatal="false" short="Operation successful."> Operation finished successfully.</value>
+ <value number="1" name="E_GENERAL_FATAL_ERROR" fatal="true" short="General Failure."> Unknown error.</value>
+ <value number="2" name="E_ALLOCATE_FAILED" fatal="true" short="Failed to allocate memory."> Try to reset the loader and if problem still exist, report it.</value>
+
+ <value number="51" name="E_INVALID_INPUT_PARAMETERS" fatal="false" short="The expected value into the function was incorrect."> Check the input parameters in the command that you try to execute. Repeat operation. Report if problem is not solved.</value>
+ <value number="52" name="E_INVALID_CURRDATE_STRING_LENGTH" fatal="false" short="Indicate that the currdate string array variable has invalid length."> Try to reset the loader and if problem still exist, report this error.</value>
+ <value number="53" name="E_UNALIGNED_DATA" fatal="false" short="Indicate that a variable is not aligned."> Try to reset the loader and if still exist the problem, report this error.</value>
+
+ <!--
+ * IO Fatal 100-150
+ * IO non-fatal 151-199
+ -->
+ <value number="100" name="E_VECTOR_CREATE_FAIL" fatal="true" short="Failed to create vector in IO Layer.">Internal malicious state detected in IO layer. Report this problem.</value>
+ <value number="101" name="E_VECTOR_DESTROY_FAIL" fatal="true" short="Failed to destroy vector in IO Layer.">Internal malicious state detected in IO layer. Report this problem.</value>
+ <value number="151" name="E_GENERAL_IO_ERROR" fatal="false" short="Unknown IO error.">Internal malicious state detected in IO layer. Report this problem.</value>
+ <value number="152" name="E_IO_FAILED_TO_READ" fatal="false" short="IO failed to read from source.">Internal malicious state detected in IO layer. Report this problem.</value>
+ <value number="153" name="E_IO_FAILED_TO_WRITE" fatal="false" short="IO failed to write to destination.">Internal malicious state detected in IO layer. Report this problem.</value>
+ <value number="154" name="E_IO_FAILED_TO_CLOSE" fatal="false" short="IO failed to close media.">Internal malicious state detected in IO layer. Report this problem.</value>
+ <value number="155" name="E_IO_FAILED_TO_OPEN" fatal="false" short="IO failed to open media.">Internal malicious state detected in IO layer. Report this problem.</value>
+ <value number="156" name="E_IO_FAILED_TO_GET_LENGTH" fatal="false" short="IO failed to get length of media.">Internal malicious state detected in IO layer. Report this problem.</value>
+
+ <!--
+ * Communication Fatal 200-250
+ * Communication non-fatal 251-299
+ -->
+ <value number="200" name="E_GENERAL_COMMUNICATION_ERROR" fatal="false" short="General communication error.">Check the communication cable and restart the loader.</value>
+ <value number="201" name="E_FAILED_TO_START_BULK_SESSION" fatal="true" short="Failed to start bulk session.">Try to reset the loader and if still exist the problem, report this error.</value>
+ <value number="202" name="E_FAILED_TO_CLOSE_BULK_SESSION" fatal="true" short="Failed to initialize the transport layer.">Try to reset the loader and if still exist the problem, report this error.</value>
+ <value number="203" name="E_FAILED_TO_FIND_CHUNK_DATA_BLOCK" fatal="true" short="Failed to find chunk data block.">Try to reset the loader and if still exist the problem, report this error.</value>
+ <value number="204" name="E_FAILED_TO_INIT_COM_DEVICE" fatal="true" short="Failed to reinitialize communication device.">Try to reset the loader and if still exist the problem, report this error. Possible hardware problem.</value>
+ <value number="205" name="E_FAILED_TO_USE_COM_DEVICE" fatal="true" short="Failed to use communication device.">Communication device do not respond and try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="206" name="E_FAILED_TO_ALLOCATE_COMM_BUFFER" fatal="true" short="Failed to allocate communication buffer.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="207" name="E_FAILED_TO_FLUSH_RXFIFO" fatal="true" short="Failed to flush RX FIFO.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="208" name="E_RETRANSMITION_FAILED" fatal="true" short="Retransmission failed. After MAX_RESENDS attempt, failed to send packet.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="209" name="E_COMMAND_NO_ERROR" fatal="true" short="Stopped command error sequence."> Reset the loader. Report if problem still exist.</value>
+ <value number="210" name="E_FAILED_TO_RELEASE_COMM_BUFFER" fatal="true" short="Failed to release communication buffer.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="211" name="E_FAILED_TO_INTIALIZE_TIMER_FUNCTIONS" fatal="true" short="Failed to initialize timer functions.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="212" name="E_FAILED_TO_INTIALIZE_QUEUE_FUNCTIONS" fatal="true" short="Failed to initialize queue functions.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="213" name="E_DMA_INIT_ERROR" fatal="true" short="Failed to initialize DMA.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="214" name="E_FAILED_TO_STOP_DMA" fatal="true" short="Failed to stop DMA channel.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="215" name="E_FAILED_TO_OPEN_DMA_CHANNEL" fatal="true" short="Failed to open DMA channel.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="216" name="E_FAILED_TO_SET_DMA_CHANNEL_TYPE" fatal="true" short="Failed to set DMA channel type.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="217" name="E_FAILED_TO_SET_DMA_CHANNEL_MODE" fatal="true" short="Failed to set DMA channel mode.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="218" name="E_FAILED_TO_OPEN_DMA_PIPE" fatal="true" short="Failed to open DMA pipe.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="219" name="E_FAILED_TO_SET_DMA_IT_LOGIC" fatal="true" short="Failed to set DMA interrupt logic.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="220" name="E_FAILED_TO_CLOSE_DMA_PIPE" fatal="true" short="Failed to close DMA pipe.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="221" name="E_FAILED_TO_CLOSE_DMA_CHANNEL" fatal="true" short="Failed to close DMA channel.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="222" name="E_FAILED_TO_CONFIG_SRC_DMA_DEVICE" fatal="true" short="Failed to configure DMA source device.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="223" name="E_FAILED_TO_UPDATE_DMA_SRC_MEMORY_BUFFER" fatal="true" short="Failed to update DMA source memory buffer.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="224" name="E_FAILED_TO_CONFIG_DEST_DMA_DEVICE" fatal="true" short="Failed to configure DMA destination device.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="225" name="E_FAILED_TO_UPDATE_DMA_DEST_MEMORY_BUFFER" fatal="true" short="Failed to update DMA destination memory buffer.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="226" name="E_FAILED_TO_RUN_DMA" fatal="true" short="Failed to run DMA transfer.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="251" name="E_INVALID_BULK_MODE" fatal="false" short="Invalid bulk mode.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="252" name="E_FAILED_TO_FIND_COMM_BUFFER" fatal="false" short="Failed to find communication buffer.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="253" name="E_INVALID_TYPE_OF_BUFFER" fatal="false" short="Invalid type of buffer.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="254" name="E_COM_DEVICE_BUSY" fatal="false" short="Communication device is busy.">Current transfer is not finished.</value>
+ <value number="255" name="E_NOT_FOUND_ELEMENT_IN_RETRANSMISSION_LIST" fatal="false" short="The element in retransmission list is not found.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="256" name="E_FAILED_READING_FROM_BULK" fatal="false" short="Failed to read from bulk.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="257" name="E_FAILED_WRITING_TO_BULK" fatal="false" short="Failed to write to bulk.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="258" name="E_FAILED_TO_GET_UART_DESCRIPTOR" fatal="false" short="Failed to get UART descriptor.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="259" name="E_FAILED_TO_GET_USB_DESCRIPTOR" fatal="false" short="Failed to get USB descriptor.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="260" name="E_INVALID_BULK_SESSION_ID" fatal="false" short="Invalid bulk session ID is used.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="261" name="E_PREVIOUS_BULK_SESSION_IS_NOT_CLOSED" fatal="false" short="Previous bulk session not closed.">Try to reset the loader. If the problem still exist, report this error.</value>
+ <value number="262" name="E_INVALID_BULK_PROTOCOL_STATE" fatal="false" short="Invalid bulk protocol state.">Try to reset the loader. If the problem still exist, report this error.</value>
+
+ <!--
+ * Signature Fatal 300-350
+ * Signature non-fatal 351-399
+ -->
+ <value number="351" name="E_UNKNWON_PROPERTY" fatal="false" short="Unknown property id.">Check the input value of the command that you try to execute.</value>
+
+ <!--
+ * Services Fatal 400-450
+ * Services non-fatal 451-499
+ -->
+ <value number="451" name="E_CYCLIC_GRAPH" fatal="false" short="Cyclic graph in services detected."> Some internal error occurred and you need to reset the loader to avoid further unpredictable behaviour.</value>
+ <value number="452" name="E_SERVICE_NOT_SUPPORTED" fatal="false" short="The service is not supported."> Some internal error occurred and you need to reset the loader to avoid further unpredictable behaviour.</value>
+ <value number="453" name="E_INCONSISTENCY_IN_SERVICES" fatal="false" short="Inconsistency in services is detected."> Some internal error occurred and you need to reset the loader to avoid further unpredictable behaviour.</value>
+ <value number="454" name="E_SERVICE_IN_USE" fatal="false" short="The service is in use and can't be stopped."> Some internal error occurred and you need to reset the loader to avoid further unpredictable behaviour.</value>
+ <value number="455" name="E_UNREGISTER_BDM_SERVICE_FAILED" fatal="false" short="Unregistering of Block Device Manager Service failed."> Some internal error occurred and you need to reset the loader to avoid further unpredictable behaviour.</value>
+ <value number="456" name="E_UNREGISTER_BAM_SERVICE_FAILED" fatal="false" short="Unregistering of Boot Area Manager Service failed."> Some internal error occurred and you need to reset the loader to avoid further unpredictable behaviour.</value>
+ <value number="457" name="E_UNREGISTER_COPS_SERVICE_FAILED" fatal="false" short="Unregistering of COPS Data Manager Service failed."> Some internal error occurred and you need to reset the loader to avoid further unpredictable behaviour.</value>
+ <value number="458" name="E_UNREGISTER_FS_SERVICE_FAILED" fatal="false" short="Unregistering of File System Manager Service failed."> Some internal error occurred and you need to reset the loader to avoid further unpredictable behaviour.</value>
+ <value number="459" name="E_UNREGISTER_FPD_SERVICE_FAILED" fatal="false" short="Unregistering of Flash Physical Driver Service failed."> Some internal error occurred and you need to reset the loader to avoid further unpredictable behaviour.</value>
+ <value number="460" name="E_UNREGISTER_GD_SERVICE_FAILED" fatal="false" short="Unregistering of Global Data Manager Service failed."> Some internal error occurred and you need to reset the loader to avoid further unpredictable behaviour.</value>
+
+ <!--
+ * Zip Parser Fatal 500-550
+ * Zip Parser non-fatal 551-599
+ -->
+ <value number="551" name="E_GENERAL_ZIP_ERROR" fatal="false" short="General error."> Possible error in zip format.Verify that the zip is not corrupted,otherwise report the problem.</value>
+ <value number="552" name="E_ZIP_FAILED_TO_CREATE_CONTEXT" fatal="false" short=" Failed to parse the zip."> Possible error in zip format.Verify that the zip is not corrupted,otherwise report the problem.</value>
+ <value number="553" name="E_ZIP_FAILED_TO_OPEN_FILE" fatal="false" short=" Failed to open file from the zip.">Possible error in zip format.Verify that the zip is not corrupted,otherwise report the problem.</value>
+
+ <!--
+ * System Fatal 600-650
+ * System non-fatal 651-699
+ -->
+ <value number="600" name="E_FILESYS_APP_INIT_FAILURE" fatal="true" short="Failed to initialize the file system application.">Internal error.Reset loader.Report if problem still exist.</value>
+ <value number="601" name="E_NO_FILESYSTEM_PROPERTY" fatal="true" short="Failed to start file system."> Verify that archive is successfuly flashed.Reset loader. Report if problem still exist.</value>
+ <value number="602" name="E_UNDEFINED_AUTHENTICATION_TYPE" fatal="true" short="Undefined authentication type.">Check the authentication type. The loader supports authentication with CA certificate and control keyes.Repeat authentiacton. Report if problem still exist.</value>
+ <value number="651" name="E_RTC_TIME_NOT_ACCURATE" fatal="false" short="System Time is not properly set."> Default system time is used.Set the Time properly. Report if problem still exist.</value>
+ <value number="652" name="E_RTC_INTIALIZATION_FAILED" fatal="false" short="Hardware error ocure during initialization of RTC."> Report this problem</value>
+
+ <!--
+ * Flash Fatal 700-750
+ * Flash non-fatal 751-799
+ -->
+ <value number="751" name="E_DIFFERENT_FLASHLAYOUT" fatal="false" short="Different flashlayout."> You must erase the flash before flashing archive with different flashlayout.</value>
+ <value number="752" name="E_EMPTY_FILE_IN_ARCHIVE" fatal="false" short="Archive contain empty file."> Check files in flash archive. Empty files not allowed.</value>
+ <value number="753" name="E_UNKNOWN_COMM_DEVICE" fatal="false" short="Unknown communication device was detected."> Try to restart the loader and if still exist the problem, report this error.</value>
+ <value number="754" name="E_FLASH_APP_INTERNAL_ERROR" fatal="false" short="Internal during execution of flash commands."> Try to erase flash and restart the loader and if problem still exist, report it.</value>
+ <value number="755" name="E_DEVICE_NAME_TOO_LONG" fatal="false" short="Device name is too long."> Try to erase flash and restart the loader and if problem still exist, report it.</value>
+ <value number="756" name="E_FLASH_ARCHIVE_MISMATCH" fatal="false" short="Mismatch between archieve that is flashed and previosly flashed one."> During previous flashing some fail condition occurs. Reflash same archieve again before try a new one.</value>
+ <value number="757" name="E_UNSUPPORTED_FLASH_TYPE" fatal="false" short="Flash memory device type is not supported."> Try to use loaders with support for memory device attached to DBB. If loaders does not exist, fire CR in FIDO to get loaders that support that memory.</value>
+ <value number="758" name="E_FPD_NOT_CONFIGURED" fatal="false" short= "Flash physical driver is not configured."> Check MEMCONF settings in flash archive.</value>
+ <value number="759" name="E_INVALID_SIZE_IN_MEMCONF" fatal="false" short= "MEMCONF boot record contain invalid TotalSize field."> Check MEMCONF settings in flash archive. Very likely flash archive is built for ME with flash device with larger capacity</value>
+ <value number="760" name="E_ARCHIVE_TO_LARGE" fatal="false" short= "Flash archive larger than available space in BDM."> Check CABS settings in flash archive. Very likely flash archive is built for ME with flash device with larger capacity</value>
+ <value number="761" name="E_ENTRY_NOT_FOUND_IN_FLASHLAYOUT" fatal="false" short="Entry not found in flashlayout file.">Entry stated in manifest file is not found in flashlayout file. All entries in manifest must be defined in flashlayout file.</value>
+ <value number="762" name="E_MISMATCH_MANIFEST_FLASHLAYOUT" fatal="false" short="Mismatch between manifest and flashlayout.">Entry start address in manifest and flashlayout are not equal.</value>
+ <value number="763" name="E_INVALID_SUBTOC_PARAMETERS" fatal="false" short="SUBTOC is invalid.">SUBTOC parameters are not valid.</value>
+ <value number="764" name="E_FAILED_TO_READ_SUBTOC" fatal="false" short="Reading SUBTOC from flash failed.">Reading SUBTOC from flash failed.</value>
+ <value number="765" name="E_OVERLAPPING_PARTITIONS_FOUND" fatal="false" short="Overlapping partitions found in the archive.">Overlapping partitions found in the archive.</value>
+ <value number="766" name="E_PARTITION_NOT_FOUND" fatal="false" short="Partition not found in TOC.">Partition not found in TOC.</value>
+ <value number="767" name="E_FLASHLAYOUT_NULL" fatal="false" short="Flashlayout data equals NULL.">Flashlayout data equals NULL.</value>
+ <value number="768" name="E_INVALID_TOC_TYPE" fatal="false" short="Invalid TOC type supplied during TOC list creation.">Loader internal error. Report this issue to loaders team.</value>
+ <value number="769" name="E_TOC_HANDLER_INPUT_DATA_EMPTY" fatal="false" short="TOC list cannot be created because supplied buffer is empty.">Input buffer in create TOC list functionality is filled from empty location.</value>
+ <value number="770" name="E_TOC_HANDLER_INPUT_DATA_CORRUPTED" fatal="false" short="TOC list cannot be created because supplied buffer contains corrupted data."> Report this issue to loaders team.</value>
+ <value number="771" name="E_TOC_LIST_CORRUPTED" fatal="false" short="TOC list cannot be created. Some malicious state occurs.">Erase flash and try all procedure once again. If problem still exist report it to loaders team.</value>
+ <value number="772" name="E_TOC_BOOT_AREA_EMPTY" fatal="false" short="TOC list cannot be created. Boot area is empty.">Flash archive first before using some TOC operations.</value>
+ <value number="773" name="E_BOOT_AREA_NOT_FOUND" fatal="false" short="Boot Area not found.">There is no boot area on flash, nor in the archive you are trying to flash.</value>
+ <value number="774" name="E_MISMATCH_MANIFEST_TOC" fatal="false" short="Mismatch between manifest and TOC.">Entry start address or flash device in manifest are not equal to TOC.</value>
+ <value number="775" name="E_FILE_TOO_LARGE" fatal="false" short="File too large.">The file is too large to fit in the partition. Increase the partition size and try to flash the file again. If problem still exist, report it</value>
+ <value number="776" name="E_FILE_OUT_OF_BOOT_AREA" fatal="false" short="File outside of boot area">The file is too large to fit in the boot area.</value>
+ <value number="777" name="E_DUMP_OUT_OF_FLASH_RANGE" fatal="false" short="Dump outside of flash range">The requested dump size is outside of the flash range, available flash range is dumped.</value>
+
+ <!--
+ * File management Fatal 900-950
+ * File management non-fatal 951-999
+ -->
+ <value number="951" name="E_PATH_NOT_EXISTS" fatal="false" short="Path not exist."> Verify that supplied path is valid. Repeat operation. Report if problem still exist.</value>
+ <value number="952" name="E_CLOSE_FILE" fatal="false" short="Failed to close a file in the file system."> Repeat operation. If still doesn't work reset loader. If that does not resolve problem report it.</value>
+ <value number="953" name="E_INSUFFICENT_SPACE" fatal="false" short="Not enough memory space for desired operation."> Use Volume Properties command to check if enough memory space exists. Report problem in case of information mismatch.</value>
+ <value number="954" name="E_REMOVE_FILE" fatal="false" short="Failed to remove a file from the file system."> Check the access of the file. Repeat operation. If problem still exist possible file system corruption and you need to reset the loader. Report if problem is not solved.</value>
+ <value number="955" name="E_RENAME_FILE" fatal="false" short="Failed to rename a file from the file system."> Check the access of the file. Repeat operation. If problem still exist possible file system corruption and you need to reset the loader. Report if problem is not solved.</value>
+ <value number="956" name="E_CREATE_DIR" fatal="false" short="Failed to create a new directory in the file system."> Use Volume Properties command to check if enough memory space exists. Repeat operation or reset loader. If problem still exist possible file system corruption. Report the problem.</value>
+ <value number="957" name="E_REMOVE_DIRECTORY" fatal="false" short="Failed to remove directory."> Check the access of the file. Repeat operation. If problem still exist possible file system corruption and you need to reset the loader. Report if problem is not solved.</value>
+ <value number="958" name="E_FREE_SPACE" fatal="false" short="No free space left."> Use Volume Properties command to check if enough memory space exists. Report problem in case of information mismatch.</value>
+ <value number="959" name="E_ITEM_STAT" fatal="false" short="Failed to retrieve status data."> Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="960" name="E_CLOSE_DIRECTORY" fatal="false" short="Failed to close a directory in the file system."> Internal error. Possible file system corruption. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="961" name="E_MOUNT_VOLUME" fatal="false" short="Failed to mount volume in the file system."> Internal error. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="962" name="E_READ_DIRECTORY" fatal="false" short="Failed to read directory in the file system."> Check the access of the file and check input parameters. Repeat operation. If problem still exist possible file system corruption and you need to reset the loader. Report if problem is not solved.</value>
+ <value number="963" name="E_FS_IO" fatal="false" short="Input/output error."> Internal error. Check input parameters. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="964" name="E_FS_ARGUMENT_LIST_2BIG" fatal="false" short="Argument list too long."> Internal error. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="965" name="E_FS_BAD_FILE_DESC" fatal="false" short="Bad file descriptor."> Internal error. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="966" name="E_FS_ACCESS" fatal="false" short="Permission denied."> In order to perform operation first change file access permissions and than repeat operation. Report if problem still exist.</value>
+ <value number="967" name="E_FS_BAD_ADDRESS" fatal="false" short="Bad address."> Check input parameters. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="968" name="E_FS_FILE_EXIST" fatal="false" short="File exists."> Check input parameters. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="969" name="E_FS_NOT_DIR" fatal="false" short="Not a directory."> Check input parameters. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="970" name="E_FS_IS_DIR" fatal="false" short="Is a directory."> Check input parameters. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="971" name="E_FS_FILE_TOO_LARGE" fatal="false" short="File too large."> Check input parameters. Use Volume Properties command to check if enough memory space exists. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="972" name="E_FS_READ_ONLY_FS" fatal="false" short="Read-only file system."> Operation is not allowed.</value>
+ <value number="973" name="E_FS_OPER_NOT_SUPP" fatal="false" short="Operation not supported."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="974" name="E_FS_NAME_TOO_LONG" fatal="false" short="File name too long."> Repeat operation with correct input parameters. Report if problem still exist.</value>
+ <value number="975" name="E_FS_OPERATION_CANCELED" fatal="false" short="Operation canceled."> Internal error. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="976" name="E_FS_FAIL" fatal="false" short="Cannot start operation."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="977" name="E_FS_INTERNAL" fatal="false" short="Internal error."> Reset loader. Report if problem still exist.</value>
+ <value number="978" name="E_FS_NOT_MOUNTED" fatal="false" short="Volume not mounted."> Requested volume not exist. Check input parameters. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="979" name="E_FS_NOT_PERMITED" fatal="false" short="Operation not permitted."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="980" name="E_FS_NO_SUCH_FILE_OR_DIR" fatal="false" short="No such file or directory."> Check input parameters. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="981" name="E_FS_NOT_EXIST" fatal="false" short="Specified FS does not exist."> Check input parameters. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="982" name="E_FS_UNKNOWN_ERROR" fatal="false" short="Error is unknown."> Internal error. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="983" name="E_FAILED_WRITING_TO_FILE" fatal="false" short="Failed to write to file."> Internal error. Check input parameters. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="984" name="E_FAILED_READING_FROM_FILE" fatal="false" short="Failed to read from the specified file."> Internal error. Check input parameters. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="985" name="E_ACCESS_DENIED" fatal="false" short="The access permission attributes do not allow operation."> Change the access and repeat operation. If problem still exist possible file system corruption and you need to reset the loader. Report if problem is not solved.</value>
+ <value number="986" name="E_CANNOT_OPEN_FILE" fatal="false" short="Can not open the specified file."> Check input parameters. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="987" name="E_FAILED_TO_STOP_FS" fatal="false" short="Can not stop file system."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="988" name="E_FILE_NAME_TOO_LONG" fatal="false" short="File name is too long."> Correct the file name. Repeat operation or reset loader. Report if problem still exist.</value>
+ <value number="989" name="E_FAILED_TO_FIND_ELF_SECTION" fatal="false" short="Can not find elf section."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="990" name="E_MAX_NUMBER_OF_MOUNTED_VOLUMES_EXCEEDED" fatal="false" short="Unable to mount volume due to exceeding the maximum number of allowed volumes.">First check the defined number of volumes in the flasharchive. If it is lower than maximum allowed volumes repeat the operation or reset loader. Report if problem still exist </value>
+ <value number="991" name="E_NO_MOUNTED_DEVICES_ARE_FOUND" fatal="false" short="Information message that no mounted devices are found."> This message can be issued in case when is detected that loader is trying to unmount zero mounted devices.</value>
+
+ <!--
+ * Command Auditing and execution Fatal 1000-1050
+ * Command Auditing and execution non-fatal 1051-1099
+ -->
+ <value number="1000" name="E_NOT_FREE_CMD_SPACE" fatal="true" short="Index for new command is not founded in execution queue."> Internal limitation. Wait some time and then try again.</value>
+ <value number="1001" name="E_INVALID_INPUT_PARAMETER" fatal="true" short="Invalid input parameter"> Reset loader. If problem still exist report it.</value>
+ <value number="1002" name="E_UNSUPPORTED_CMD" fatal="true" short="The loader does not support the requested command."> Check your authentication level. Some command need authentication. Verify that you are sending correct command.</value>
+ <value number="1003" name="E_UNSUPPORTED_GROUP" fatal="true" short="The loader does not support the requested group."> Check your authentication level. Verify that you are sending command from existing group.</value>
+ <value number="1051" name="E_INVALID_COMMAND_SIZE" fatal="false" short="The size of the command is invalid."> Check the command payload. If payload is fine, report this problem</value>
+ <value number="1052" name="E_OVERLOAD_COMMAND_TABLE" fatal="false" short="Too many commands are registered."> It is not allowed more than 5 commands to be registered.</value>
+ <value number="1053" name="E_COMMAND_ALREADY_REGISTERED" fatal="false" short="Command has already registered in execution queue.">It is not allowed the command to be registerd more than once in execution queue</value>
+ <value number="1054" name="E_AUDITING_FAILED" fatal="false" short=" Command auditing failed."> You should be authenticate with appropriate permission level in order to execute this command.</value>
+
+ <!--
+ * Timers Fatal 1200-1250
+ * Timers non-fatal 1251-1299
+ -->
+ <value number="1251" name="E_NONEXIST_TIMER" fatal="false" short="Timer with the specified index does not exist.">Internal error.Report this problem</value>
+ <value number="1252" name="E_FAILED_TO_SET_TIMER" fatal="false" short="Failed to start the timer.">Internal error. Report this problem</value>
+ <value number="1253" name="E_TIMER_INIT_FAILED" fatal="false" short="Timer initialization failed.">Internal error. Report this problem</value>
+ <value number="1254" name="E_TIMER_IRQ_CONF_FAILED" fatal="false"> short="Timer interrupt configure failed.">Internal error. Report this problem</value>
+
+ <!--
+ * Parameter Fatal 1300-1350
+ * Parameter non-fatal 1351-1399
+ -->
+ <value number="1351" name="E_GD_INVALID_UNIT_SIZE" fatal="false" short="GD/GDFS: Error in specifying unit size."> Check input parameters. Repeat command.</value>
+ <value number="1352" name="E_GD_LL_ILLEGAL_SIZE" fatal="false" short="GD/GDFS: Size too large for the block."> Internal error. Check input parameters. Repeat command.</value>
+ <value number="1353" name="E_GD_LL_WRITE_FAILED" fatal="false" short="GD/GDFS: Write failed on FLASH device level."> Try to reset the loader and repeat operation. If problem still exist, report it.</value>
+ <value number="1354" name="E_GD_LL_ERASE_FAILED" fatal="false" short="GD/GDFS: Erase failed on FLASH device level."> Try to reset the loader and repeat operation. If problem still exist, report it.</value>
+ <value number="1355" name="E_GD_LL_UNKNOWN_DEVICE" fatal="false" short="GD/GDFS: FLASH device unknown."> Possible error in flash driver configuration. Try to reset the loader and if problem still exist, report it.</value>
+ <value number="1356" name="E_GD_STARTUP_LOG_BLK_MISSING" fatal="false" short="GD/GDFS: Logical block not found during start-up scan."> Possible wrong configuration or memory corruption. Try to reset the loader and if problem still exist, report it.</value>
+ <value number="1357" name="E_GD_STARTUP_DUPLICATE_LOG_BLK" fatal="false" short="GD/GDFS: Duplicate instances of same logical block."> Internal error or memory corruption. Try to reset the loader and if problem still exist, report it.</value>
+ <value number="1358" name="E_GD_ERASE_ILLEGAL_BLK_NR" fatal="false" short="GD/GDFS: Attempt to erase non-existing physical block."> Internal error. Try to reset the loader and if problem still exist, report it.</value>
+ <value number="1359" name="E_GD_FG_UNIT_NOT_FOUND" fatal="false" short="GD/GDFS: Requested unit not found, probably never written or has been deleted."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+ <value number="1360" name="E_GD_FG_UNIT_SIZE_MISMATCH" fatal="false" short="GD/GDFS: Attempt to access a unit outside its beyond its end."> Check input parameters. Repeat command.</value>
+ <value number="1361" name="E_GD_FG_ILLEGAL_LOG_BLK_NR" fatal="false" short="GD/GDFS: Attempt to access a logical block that does not exist. (Hardware, fatal)."> Check input parameters. Restart loader and if problem doesn't solved, report it.</value>
+ <value number="1362" name="E_GD_FG_ILLEGAL_PHYS_BLK_NR" fatal="false" short="GD/GDFS: Attempt to access a physical block that does not exist (internal error)."> Reset loader. Report if problem doesn't solved.</value>
+ <value number="1363" name="E_GD_FG_BLK_FULL" fatal="false" short="GD/GDFS: Attempted to write more data to a block than could be fitted into one FLASH block."> Check input parameters. Reset loader and if problem doesn't solved reset loader.</value>
+ <value number="1364" name="E_GD_FG_NO_BLK_FREE" fatal="false" short="GD/GDFS: Internal error (no free blocks are available)."> There's no more space available. Check input parameters and try to repeat same operation. Report if problem does't solved.</value>
+ <value number="1365" name="E_GD_FG_UNIT_CHECKSUM" fatal="false" short="GD/GDFS: The checksum or a unit being read is wrong."> Internal error. Try to repeat command. Report if problem still exist.</value>
+ <value number="1366" name="E_GD_FG_NOT_DIRECT_BLOCK" fatal="false" short="GD/GDFS: Block is not direct."> Internal error. Try to repeat command. Report if problem still exist.</value>
+ <value number="1367" name="E_GD_FG_NOT_FREE_BLOCK" fatal="false" short="GD/GDFS: For some reason, a free block could not be properly erased."> Internal error. Try to repeat command and reset loader. Report if problem still exist.</value>
+ <value number="1368" name="E_GD_FG_ILLEGAL_SIZE" fatal="false" short="GD/GDFS: The size of a unit being written exceeds the maximum limit of a unit."> Internal error. Try to repeat command and reset loader. Report if problem still exist.</value>
+ <value number="1369" name="E_GD_E_FG_FREE_AREA_DIRTY" fatal="false" short="GD/GDFS: The startup check found non-FF bytes in unused range within a block."> Internal error. Try to repeat command and reset loader. Report if problem still exist.</value>
+ <value number="1370" name="E_GD_FG_SYNC_FAILED" fatal="false" short="GD/GDFS: Failed to synchronize."> Reset loader. If problem doesn't solved report it.</value>
+ <value number="1371" name="E_GD_NOT_OPEN" fatal="false" short="GD/GDFS: Tried to access data although GD was in closed state."> Reset loader. If problem doesn't solved report it.</value>
+ <value number="1372" name="E_GD_NOT_ALLOWED" fatal="false" short="GD/GDFS: Operation not allowed in the current mode."> Reset loader. If problem doesn't solved report it.</value>
+ <value number="1373" name="E_GD_ALREADY_OPEN" fatal="false" short="GD/GDFS: Tried to open or format when GD was already opened."> Reset loader. If problem doesn't solved report it.</value>
+ <value number="1374" name="E_GD_FRONKENSTIENS_PATTERN_MISMATCH" fatal="false" short="GD/GDFS: The id mark of the GDVAR file does not match the data in the flash. Fatal and makes GD read only."> Reset loader. If problem doesn't solved report it.</value>
+ <value number="1375" name="E_GD_ILLEGAL_ALIGNMENT" fatal="false" short="GD/GDFS: Tried to erase at an address that was not aligned to a flash block boundary. Internal error."> Reset loader. If problem doesn't solved report it.</value>
+ <value number="1376" name="E_GD_ILLEGAL_SIZE" fatal="false" short="GD/GDFS: The operation may not be performed with the specified size. Tried to write a to large unit."> Check input parameters. Retry command. If problem doesn't solved reset loader. Report this problem if this not help.</value>
+ <value number="1377" name="E_GD_ACCESS_DENIED" fatal="false" short="GD/GDFS: Operation not allowed. Flash device protected. Possible wrong flash driver configuration."> Reset loader. If problem doesn't solved report it.</value>
+ <value number="1378" name="E_GD_ILLEGAL_INDEX" fatal="false" short="GD/GDFS: Illegal GD index."> Reset loader. If problem doesn't solved report it.</value>
+ <value number="1379" name="E_GD_MEMORY_ALLOCATION_FAILED" fatal="false" short="GD/GDFS: Fatal. Failed to allocate dynamic memory."> Reset loader. If problem doesn't solved report it.</value>
+ <value number="1380" name="E_GD_MISSING_CONFIG" fatal="false" short="GD/GDFS: Missing configuration parameter."> Reset loader. If problem doesn't solved report it.</value>
+ <value number="1381" name="E_GD_ILLEGAL_CONFIG" fatal="false" short="GD/GDFS: Illegal configuration."> Reset loader. If problem doesn't solved report it.</value>
+ <value number="1382" name="E_GD_TRANSACTION_LOG_CORRUPT" fatal="false" short="GD/GDFS: The transaction log used for tracking updates to GD contents is corrupt and prevents roll-back from working properly."> Reset loader. If problem doesn't solved report it.</value>
+
+ <value number="1383" name="E_CSPSA_RESULT_E_INVALID_KEY" fatal="false" short="Error, parameter key not valid."> Loader internal problem. Report this issue.</value>
+ <value number="1384" name="E_CSPSA_RESULT_E_OUT_OF_SPACE" fatal="false" short="Error, there is not space enough on memory media to update the parameter area."> Loader internal problem. Report this issue.</value>
+ <value number="1385" name="E_CSPSA_RESULT_E_NO_VALID_IMAGE" fatal="false" short="Error, no valid CSPSA image found."> Loader internal problem. Report this issue.</value>
+ <value number="1386" name="E_CSPSA_RESULT_E_MEDIA_INACCESSIBLE" fatal="false" short="Memory media could not be accessed."> Loader internal problem. Report this issue.</value>
+ <value number="1387" name="E_CSPSA_RESULT_E_READ_ONLY" fatal="false" short="Image is read-only."> Loader internal problem. Report this issue.</value>
+ <value number="1388" name="E_CSPSA_RESULT_E_READ_ERROR" fatal="false" short="Error occurred while reading from media."> Loader internal problem. Report this issue.</value>
+ <value number="1389" name="E_CSPSA_RESULT_E_WRITE_ERROR" fatal="false" short="Error occurred while writing to media."> Loader internal problem. Report this issue.</value>
+ <value number="1390" name="E_CSPSA_RESULT_UNDEFINED" fatal="false" short="Represents an undefined value of this enum."> Loader internal problem. Report this issue.</value>
+ <value number="1391" name="E_CSPSA_RESULT_E_END_OF_DATA" fatal="false" short="No more parameters, end of data has been reached."> Loader internal problem. Report this issue.</value>
+ <value number="1392" name="E_CSPSA_RESULT_E_OPEN_ERROR" fatal="false" short="Parameter storage area could not be opened (media error)."> Loader internal problem. Report this issue.</value>
+ <value number="1393" name="E_CSPSA_RESULT_E_ALREADY_EXISTS" fatal="false" short="Parameter storage area with same name was already registered."> Loader internal problem. Report this issue.</value>
+ <value number="1394" name="E_CSPSA_RESULT_E_OUT_OF_MEMORY" fatal="false" short="There was not enough memory to perform the operation."> Loader internal problem. Report this issue.</value>
+ <value number="1395" name="E_CSPSA_RESULT_E_BAD_PARAMETER" fatal="false" short="Error because of bad input parameter.">Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+
+ <value number="1399" name="E_GD_NO_DATA_TO_READ" fatal="false" short="GD: No data to read."> Write something to GD before attempting to read from it. Report this problem if you are shore that GD is not empty.</value>
+
+ <!--
+ * Block device Fatal 1400-1450
+ * Block device non-fatal 1451-1499
+ -->
+ <value number="1451" name="E_BDM_W_NO_MORE_GC_POSSIBLE" fatal="false" short="BDM: No more garbage collection is possible."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1452" name="E_BDM_UNIT_STARTED" fatal="false" short="BDM: Unit has already been started."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1453" name="E_BDM_UNIT_NOT_STARTED" fatal="false" short="BDM: Unit has not yet been started."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1454" name="E_BDM_NOT_CONFIGURED" fatal="false" short="BDM: Has not been configured yet."> Check is archive was flashed. If not, flash archive. If problem still exist reset loader and report the problem.</value>
+ <value number="1455" name="E_BDM_STARTUP_FAILED" fatal="false" short="BDM: Startup failed."> Check is archive was flashed. If not, flash archive. If problem still exist reset loader and report the problem.</value>
+ <value number="1456" name="E_BDM_SHUTDOWN_FAILED" fatal="false" short="BDM: Shutdown failed."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1457" name="E_BDM_WRITE_FAILED" fatal="false" short="BDM: An error occurred while writing."> Possible error in flash driver. Try to reset the loader and if problem still exist, report it.</value>
+ <value number="1458" name="E_BDM_READ_FAILED" fatal="false" short="BDM: An error occurred while reading"> Possible error in flash driver. Try to reset the loader and if problem still exist, report it.</value>
+ <value number="1459" name="E_BDM_ERASE_FAILED" fatal="false" short="BDM: An error occurred while erasing."> Possible error in flash driver. Try to reset the loader and if problem still exist, report it.</value>
+ <value number="1460" name="E_BDM_JUNK_FAILED" fatal="false" short="BDM: An error occurred while junking."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1461" name="E_BDM_GC_FAILED" fatal="false" short="BDM: An error occurred while garbage collecting."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1462" name="E_BDM_GET_INFO_FAILED" fatal="false" short="BDM: An error occurred while retrieving info about a BDM unit."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1463" name="E_BDM_WRITE_NOT_SUPPORTED" fatal="false" short="BDM: Write not supported.">Writing was attempted when compiled as read-only.</value>
+ <value number="1464" name="E_BDM_JUNK_NOT_SUPPORTED" fatal="false" short="BDM: Junk not supported.">Junking was attempted when compiled as read-only.</value>
+ <value number="1465" name="E_BDM_GC_NOT_SUPPORTED" fatal="false" short="BDM: Garbage collection not supported.">Garbage collection was attempted when compiled as read-only.</value>
+ <value number="1466" name="E_BDM_SYNC_FAILED" fatal="false" short="BDM: Synchronize failed."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1467" name="E_BDM_NOT_SUPPORTED" fatal="false" short="BDM: Function not supported."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1468" name="E_BDM_PAUSED" fatal="false" short="BDM: Paused.">Error returned when using os-free code when calling any other method then resume or shutdown when BDM is in the paused state.</value>
+ <value number="1469" name="E_BDM_NOT_PAUSED" fatal="false" short="BDM: Not paused.">Returned when calling resume when BDM is not in the paused state (In the os-free case).</value>
+ <value number="1470" name="E_BDM_FINDING_BAM_BLOCKS" fatal="false" short="BDM: BAM blocks not found."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1471" name="E_BDM_BAD_PARAM" fatal="false" short="BDM: Argument invalid or out of range."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1472" name="E_BDM_FORMAT_FAILED" fatal="false" short="BDM: Formatting failed."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1473" name="E_BDM_INVALID_UNIT" fatal="false" short="BDM: The unit number is out of range."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+ <value number="1474" name="E_BDM_INVALID_CONFIG" fatal="false" short="BDM: Some part of the configuration is invalid."> Possible error in flash archive. Check the archive. Flash the correct archive. Report if problem still exist.</value>
+ <value number="1475" name="E_BDM_PRE_FLASH_FINISHED" fatal="false" short="BDM: No more preflash blocks can be fetched."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1476" name="E_BDM_PRE_FLASH_TERMINATE_FAILED" fatal="false" short="BDM: Termination of preflash failed."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1477" name="E_BDM_OUT_OF_MEM" fatal="false" short="BDM: Could not allocate enough memory."> Internal error. Reset loader. Report if problem still exist.</value>
+
+ <value number="1481" name="E_BDM_XSR_CRITICAL_ERROR" fatal="false" short="BDM XSR: Critical error."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1482" name="E_BDM_XSR_INVALID_PARAMS" fatal="false" short="BDM XSR: Invalid parameters."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+ <value number="1483" name="E_BDM_XSR_PARTITION_NOT_OPENED" fatal="false" short="BDM XSR: Could not open partition."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1484" name="E_BDM_XSR_UNFORMATTED_FLASH" fatal="false" short="BDM XSR: Unformatted flash."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1485" name="E_BDM_XSR_ALLOCATION_ERROR" fatal="false" short="BDM XSR: Failed to allocate."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1486" name="E_BDM_XSR_INVALID_PARTITION" fatal="false" short="BDM XSR: Invalid partition."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+ <value number="1487" name="E_BDM_XSR_READ_ERROR" fatal="false" short="BDM XSR: An error occurred while reading."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1488" name="E_BDM_XSR_WRITE_ERROR" fatal="false" short="BDM XSR: An error occurred while writing."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1489" name="E_BDM_XSR_ERASE_ERROR" fatal="false" short="BDM XSR: An error occurred while erasing."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1490" name="E_BDM_XSR_DEVICE_ERROR" fatal="false" short="BDM XSR: Device error."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1491" name="E_BDM_XSR_GOODBLOCK" fatal="false" short="BDM XSR: Good block."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+ <value number="1492" name="E_BDM_XSR_BADBLOCK" fatal="false" short="BDM XSR: Bad block."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+
+ <!--
+ * Boot area Fatal 1500-1550
+ * Boot area non-fatal 1551-1619
+ -->
+ <value number="1551" name="E_BAM_NOT_CONFIGURED" fatal="false" short="BAM: Is not configured."> Check is archive was flashed. If not, flash archive. If problem still exist reset loader and report the problem.</value>
+ <value number="1552" name="E_BAM_ERR_UNSUPPORTED_PAGE_SIZE" fatal="false" short="BAM: Unsupported page size."> Possible wrong configuration in flash archive. Check the archive. Flash the correct archive. If problem still exist report the problem.</value>
+ <value number="1553" name="E_BAM_ERR_ERASING_BLOCK" fatal="false" short="BAM: Erase block could not be properly erased."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1554" name="E_BAM_ERR_OUT_OF_MEMORY" fatal="false" short="BAM: Not enough free memory to serve request."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1555" name="E_BAM_ERR_CHECKING_BADNESS" fatal="false" short="BAM: There was a problem checking if a block was bad or not."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1556" name="E_BAM_ERR_FINDING_BLOCK" fatal="false" short="BAM: Reserved block could not be found."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+ <value number="1557" name="E_BAM_ERR_READING_PAGE" fatal="false" short="BAM: An error occurred while reading a page in a block."> Possible error in flash driver. Try to reset the loader and if problem still exist, report it.</value>
+ <value number="1558" name="E_BAM_ERR_MARKING_BLOCK_BAD" fatal="false" short="BAM: A block went bad and BAM could not mark it as bad properly."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1559" name="E_BAM_ERR_READING_OUTSIDE_BLOCK" fatal="false" short="BAM: Read would result in a read beyond end of reserved block."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+ <value number="1560" name="E_BAM_ERR_UNCORRECTABLE_ERROR" fatal="false" short="BAM: An uncorrectable read error occurred while reading block."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1561" name="E_BAM_ERR_WRITING_PAGE" fatal="false" short="BAM: An error occurred while writing a page to a reserved block."> Possible error in flash driver. Try to reset the loader and if problem still exist, report it.</value>
+ <value number="1562" name="E_BAM_ERR_WRITING_BLOCK" fatal="false" short="BAM: An error occurred while writing to a reserved block."> Possible error in flash driver. Try to reset the loader and if problem still exist, report it.</value>
+ <value number="1563" name="E_BAM_ERR_RESCUING_BLOCK" fatal="false" short="BAM: There was a problem rescuing a block that went bad during the request."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1564" name="E_BAM_ERR_CONFIG_MISSING" fatal="false" short="BAM: No configuration was given."> Check is archive was flashed. If not, flash archive. If problem still exist reset loader and report the problem.</value>
+ <value number="1565" name="E_BAM_ERR_ALREADY_STARTED" fatal="false" short="BAM: Has already been started."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1566" name="E_BAM_ERR_NOT_STARTED" fatal="false" short="BAM: Has not been started yet."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1567" name="E_BAM_ERR_UNSUPPORTED_OPERATION" fatal="false" short="BAM: Requested operation is not supported."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1568" name="E_BAM_ERR_CORRUPT_STATE" fatal="false" short="BAM: Internal state has been corrupted."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1569" name="E_BAM_ERR_UNSUPPORTED_MEDIA" fatal="false" short="BAM: The configured media type is not supported."> Possible wrong configuration in flash archive. Check the archive. Flash the correct archive. If problem still exist report the problem.</value>
+ <value number="1570" name="E_BAM_ERR_UNSUPPORTED_REDUNDANT_AREA_SIZE" fatal="false" short="BAM: Unsupported redundant area size."> Possible wrong configuration in flash archive. Check the archive. Flash the correct archive. If problem still exist report the problem.</value>
+ <value number="1571" name="E_BAM_ERR_READING_BLOCK" fatal="false" short="BAM: Reading block failed."> Possible error in flash driver. Try to reset the loader and if problem still exist, report it.</value>
+ <value number="1572" name="E_BAM_ERR_SHUTTING_DOWN" fatal="false" short="BAM: Shutting down failed."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1573" name="E_BAM_ERR_UNINITIALIZING" fatal="false" short="BAM: An error occurred with uninitializing."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1574" name="E_BAM_ERR_INVALID_OFFSET" fatal="false" short="BAM: Invalid offset."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1575" name="E_BAM_ERR_INVALID_SIZE" fatal="false" short="BAM: Invalid size."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+ <value number="1576" name="E_BAM_ERR_RETRIEVING_INFO" fatal="false" short="BAM: Retrieving info failed."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1577" name="E_BAM_ERR_INVALID_CONFIG" fatal="false" short="BAM: Invalid configuration."> Possible wrong configuration in flash archive. Check the archive. Flash the correct archive. If problem still exist report the problem.</value>
+ <value number="1578" name="E_BAM_ERR_ERASING_ALL_BLOCKS" fatal="false" short="BAM: An error occurred while erasing all blocks."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1579" name="E_BAM_ERR_BLOCK_MARKED_BAD" fatal="false" short="BAM: Block was marked as bad while doing an operation."> Repeat operation. If problem still exist reset the loader. Report if the problem is not solved.</value>
+ <value number="1580" name="E_BAM_ERR_VALIDATING_START_BLOCK" fatal="false" short="BAM: Can not assure that start block configuration refers to a block boundary."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1581" name="E_BAM_ERR_FAILED_TO_GET_MEMORYTECHNOLOGY" fatal="false" short="BAM: Unable the query FAM about the memory technology used in the memory we are trying to initialize BAM on."></value>
+ <value number="1582" name="E_BAM_ERR_BLOCK_RESCUED" fatal="false" short="BAM: Block rescue failed."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1583" name="E_BAM_ERR_DETERMINING_BBM" fatal="false" short="BAM: Failed to determine what BBM type configuration has been written to flash."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1584" name="E_BAM_ERR_SET_ECC_LENGTH" fatal="false" short="BAM: Failed to set the length to use with HW ECC acceleration."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1585" name="E_BAM_ERR_INVALID_BBM_TYPE" fatal="false" short="BAM: Invalid BBM type."> Possible wrong configuration in flash archive. Check the archive. Flash the correct archive. If problem still exist report the problem.</value>
+ <value number="1586" name="E_BAM_ERR_BOOT_BDM_CONFIG_FAILED" fatal="false" short="BAM: Failed to configure boot block device management."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1587" name="E_BAM_ERR_BOOT_BDM_STARTUP_FAILED" fatal="false" short="BAM: Failed to startup boot block device management."> Possible missing configuration for BDM. Check is archive was flashed. If not, flash archive. If problem still exist reset loader and report the problem.</value>
+ <value number="1588" name="E_BAM_ERR_BOOT_BDM_INSTANCE_NOT_FOUND" fatal="false" short="BAM: Boot block device management instance not found."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1589" name="E_BAM_ERR_BOOT_BDM_BLOCKS_NOT_FOUND" fatal="false" short="BAM: Boot block device management blocks not found."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1590" name="E_BAM_ERR_BOOT_BDM_NOT_STARTED" fatal="false" short="BAM: Boot block device management not started. Requested operation require BDM to be started."> Internal error. Report the problem.</value>
+ <value number="1591" name="E_BAM_ERR_UNIT_OUT_OF_RANGE" fatal="false" short="BAM: Unit is out of range."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+ <value number="1592" name="E_BAM_ERR_BDM_STARTUP_FAILED" fatal="false" short="BAM: Block device management startup failed."> Possible missing configuration for BDM. Check is archive was flashed. If not, flash archive. If problem still exist reset loader and report the problem.</value>
+ <value number="1593" name="E_BAM_ERR_BLOCK_NOT_ERASED" fatal="false" short="BAM: Block not erased."> Repeat operation. If problem still exist reset the loader. Report if the problem is not solved.</value>
+
+ <value number="1601" name="E_BAM_ONLD_CRITICAL_ERROR" fatal="false" short="BAM ONLD: Critical error."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1602" name="E_BAM_ONLD_INVALID_PARAMS" fatal="false" short="BAM ONLD: Invalid parameters."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+ <value number="1603" name="E_BAM_ONLD_INITIALISATION_ERROR" fatal="false" short="BAM ONLD: Initialisation error."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1604" name="E_BAM_ONLD_READ_ERROR" fatal="false" short="BAM ONLD: An error occurred while reading."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1605" name="E_BAM_ONLD_WRITE_ERROR" fatal="false" short="BAM ONLD: An error occurred while writing."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1606" name="E_BAM_ONLD_ERASE_ERROR" fatal="false" short="BAM ONLD: An error occurred while erasing."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1607" name="E_BAM_ONLD_DEVICE_ERROR" fatal="false" short="BAM ONLD: Device error."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1608" name="E_BAM_ONLD_GOODBLOCK" fatal="false" short="BAM ONLD: Good block."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+ <value number="1609" name="E_BAM_ONLD_BADBLOCK" fatal="false" short="BAM ONLD: Bad block."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+
+ <!--
+ * Cops data Fatal 1620-1650
+ * Cops data non-fatal 1651-1699
+ -->
+ <value number="1651" name="E_COPS_MEMORY_ALLOC_FAILED" fatal="false" short="COPS: Memory allocation failed."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1652" name="E_COPS_DATA_TAMPERED" fatal="false" short="COPS: Data is tempered."> Check the file that you want to bind. Repeat operation. Report if problem still exist.</value>
+ <value number="1653" name="E_COPS_IMEI_MISSMATCH" fatal="false" short="COPS: IMEI missmatch.">IMEI in the OTP differs from the IMEI in the COPS data.</value>
+ <value number="1654" name="E_COPS_OTP_LOCKED" fatal="false" short="COPS: OTP is locked.">It is not allowed to write in already locked OTP area</value>
+ <value number="1655" name="E_COPS_MAC_FUNCTION_LOCKED_DOWN" fatal="false" short="COPS: Function for calculating MAC is locked down."> Restart loader. Report if problem still exist.</value>
+ <value number="1656" name="E_COPS_AUTHENTICATION_FAILED" fatal="false" short="COPS: Authentication failed.">Be sure that authentication is performed with valid data.(Correct Certificate, Domain, Control Keys)</value>
+ <value number="1657" name="E_COPS_DATA_NOT_PRESENT" fatal="false" short="COPS: Default Data is not present."> Execute Bind Properties command first and than repeat operation. Report if problem still exist.</value>
+ <value number="1658" name="E_COPS_IMEI_UPDATE_NOT_ALLOWED" fatal="false" short="COPS: IMEI update is not allowed."> Check if IMEI changeable is set in OTP. Report this issue if IMEI changeable is set and requested operation can not be executed.</value>
+ <value number="1659" name="E_COPS_LOCK_PERMANENTLY_DISABLED" fatal="false" short="COPS: Locking of SIMLocks is disabled.">lock is disabled or already locked.</value>
+ <value number="1660" name="E_COPS_NO_ATTEMPTS_LEFT" fatal="false" short="COPS: No more attempts for verification left."> Check the validation of the certificate or control keys.</value>
+ <value number="1661" name="E_COPS_INCORRECT_CONTROLKEY" fatal="false" short="COPS: Control key is not correct."> Control keys that you try to authenticate and control keys from Default Data missmach.</value>
+ <value number="1662" name="E_COPS_TOO_SHORT_CONTROLKEY" fatal="false" short="COPS: Control key is too short."> Valid length is 8-16 bytes. Repeat operation with valid control keys. Report if problem still exist.</value>
+ <value number="1663" name="E_COPS_TOO_LONG_CONTROLKEY" fatal="false" short="COPS: Control key is too long.">Valid length is 8-16 bytes. Repeat operation with valid control keys. Report if problem still exist.</value>
+ <value number="1664" name="E_COPS_INVALID_CONTROLKEY" fatal="false" short="COPS: Control key is not valid."> Check the control keys. Repeat operation with valid control keys. Report if problem still exist.</value>
+ <value number="1665" name="E_COPS_TIMER_RUNNING" fatal="false" short="COPS: Timer is running.">For the appropiate LockType timer is already running.</value>
+ <value number="1666" name="E_COPS_SIM_ERROR" fatal="false" short="COPS: SIM error.">Check that the SIM is active. If the SIM is active be sure that you are entering correct SIM Pin. Report if problem still exist</value>
+ <value number="1667" name="E_COPS_LOCKING_FAILED" fatal="false" short="COPS: Locking failed.">Be sure that the SIM data conatains valid data for IMSI, GID1 and GID2</value>
+ <value number="1668" name="E_COPS_OTA_UNLOCK_IMEI_MISMATCH" fatal="false" short="COPS: OTA unlock IMEI mismatch.">IMEI in the OTP differs from the IMEI in the COPS data.</value>
+ <value number="1669" name="E_COPS_INCORRECT_IMSI" fatal="false" short="COPS: Incorrect IMSI.">IMSI on interface doesn't match SIM IMSI</value>
+ <value number="1670" name="E_COPS_PARAMETER_ERROR" fatal="false" short="COPS: Parameter error."> Check the input parameters. Repeat operation. Report if problem still exist.</value>
+ <value number="1671" name="E_COPS_BUFFER_TOO_SMALL" fatal="false" short="COPS: Memory buffer is too small."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1672" name="E_COPS_FORBIDDEN_PARAMETER_ID" fatal="false" short="COPS: Parameter is not allowed."> Check the input parameters. Repeat operation. Report if problem still exist.</value>
+ <value number="1673" name="E_COPS_UNKNOWN_PARAMETER_ID" fatal="false" short="COPS: Parameter can not be recognised."> Check the input parameters. Repeat operation. Report if problem still exist.</value>
+ <value number="1674" name="E_COPS_ARGUMENT_ERROR" fatal="false" short="COPS: Argument error!"> Verify the input parameters. Repeat operation. Report if problem still exist.</value>
+ <value number="1698" name="E_COPS_VERIFY_FAILED" fatal="false" short="COPS: Failed to verify internal data.">Reset loader. Report if problem still exist.</value>
+ <value number="1699" name="E_COPS_UNDEFINED_ERROR" fatal="false" short="COPS: Undefined error."> Internal error. Reset loader. Report if problem still exist.</value>
+
+ <!--
+ * PD NAND Fatal 1700-1750
+ * PD NAND non-fatal 1751-1799
+ -->
+ <value number="1751" name="E_PD_NAND_RESULT_BIT_ERROR_CORRECTED" fatal="false" short="PD NAND: A bit error was detected and corrected."> Repeat operation. Report if problem still exist.</value>
+ <value number="1752" name="E_PD_NAND_RESULT_UNCORRECTABLE_BIT_ERROR" fatal="false" short="PD NAND: An uncorrectable bit error was detected."> Repeat operation. Report if problem still exist.</value>
+ <value number="1753" name="E_PD_NAND_RESULT_BAD_PARAMETER" fatal="false" short="PD NAND: The function could not perform the requested operation due to a bad parameter."> Repeat operation. Report if problem still exist.</value>
+ <value number="1754" name="E_PD_NAND_RESULT_HW_ERROR" fatal="false" short="PD NAND: A hardware error occurred."> Reset loader. Report if problem still exist.</value>
+ <value number="1755" name="E_PD_NAND_RESULT_INTERNAL_ERROR" fatal="false" short="PD NAND: A module internal error has occurred. The module has reach an unexpected state or request."> Reset loader. Report if problem still exist.</value>
+ <value number="1756" name="E_PD_NAND_RESULT_BUSY" fatal="false" short="PD NAND: Busy flag was returned.">If T_PD_NAND_CONFIG_FLAG_BLOCKING_MUTEX is not set, a call to NAND PD may return with this busy flag.</value>
+ <value number="1757" name="E_PD_NAND_RESULT_READING_ERASED_PAGE" fatal="false" short="PD NAND: Attempting to read erased page."> Repeat operation. Report if problem still exist.</value>
+ <value number="1758" name="E_PD_NAND_RESULT_NUMBER_OF_ITEMS" fatal="false" short="PD NAND: Number of valid states of this type."> Repeat operation. Report if problem still exist.</value>
+ <value number="1759" name="E_PD_NAND_RESULT_UNDEFINED" fatal="false" short="PD NAND: Represents an undefined value of this type."> Repeat operation. Report if problem still exist.</value>
+
+ <!--
+ * Trim Area non-fatal 1851-1899
+ -->
+
+ <value number="1851" name="E_GD_TA_BASE" fatal="false" short="GD/TA: TA base."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1852" name="E_GD_TA_UNKNOWN_PARTITION" fatal="false" short="GD/TA: Unknown partition."> Check input parameters. Repeat operation with the correct input parameters. Report if problem still exist.</value>
+ <value number="1853" name="E_GD_TA_UNKNOWN_CONFIG" fatal="false" short="GD/TA: Unknown configuration."> Possible wrong or missing configuration in flash archive. Check the archive. Flash the correct archive. If problem still exist report the problem.</value>
+ <value number="1854" name="E_GD_TA_ILLOGICAL_CONFIGURATION" fatal="false" short="GD/TA: Ilogical configuration."> Possible wrong configuration in flash archive. Check the archive. Flash the correct archive. If problem still exist report the problem.</value>
+ <value number="1855" name="E_GD_TA_UNKNOWN_MEMORY_TYPE" fatal="false" short="GD/TA: Unknown memory type."> Possible wrong configuration in flash archive. Check the archive. Flash the correct archive. If problem still exist report the problem.</value>
+ <value number="1856" name="E_GD_TA_WRONG_PARAMETER" fatal="false" short="GD/TA: Wrong parameter."> Check input parameters. Repeat operation with the correct input parameters. Report if problem still exist.</value>
+ <value number="1857" name="E_GD_TA_OUT_OF_MEMORY" fatal="false" short="GD/TA: Out of memory."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1858" name="E_GD_TA_INVALID_ADRESS" fatal="false" short="GD/TA: Invalid adress."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1859" name="E_GD_TA_UNUSED_ADRESS" fatal="false" short="GD/TA: Unused adress."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="1860" name="E_GD_TA_UNIT_NOT_FOUND" fatal="false" short="GD/TA: Unit not found."> No data was written in the specified unit. Write data to the unit and than perform read operation. Report if problem still exist.</value>
+ <value number="1861" name="E_GD_TA_NOT_IMPLEMENTED" fatal="false" short="GD/TA: TA is not supported."></value>
+ <value number="1862" name="E_GD_TA_FAIL" fatal="false" short="GD/TA: TA fail."> Internal error. Reset loader. Report if problem still exist.</value>
+
+ <value number="1863" name="E_GD_UNKNOWN_UNIT_NAME" fatal="false" short="GD: Unknown unit name."> Check input parameters. Requested unit is not supported. Repeat operation with the correct input parameters. Report if problem still exist.</value>
+ <value number="1864" name="E_GD_LAST" fatal="false" short="GD: Last enumeration (last valid + 1)."> Reset loader. If problem doesn't solved report it.</value>
+
+ <!--
+ * Loader utilities Fatal 1900-1950
+ * Loader utilities non-fatal 1951-1999
+ -->
+ <value number="1900" name="E_FAILED_TO_STORE_IN_FIFO" fatal="true" short="Failed to store data in FIFO."> Reset loader.</value>
+ <value number="1951" name="E_FAILED_TO_SET_COMM_DEVICES" fatal="false" short="Failed to set parameters of communications devices."> Reset loader. If problem does'n solved report it.</value>
+ <value number="1952" name="E_FAILED_TO_STORE_IN_STACK" fatal="false" short="Failed to store in stack."> Reset loader. If problem does'n solved report it.</value>
+ <value number="1954" name="E_ZIP_PARSER_FILE_NOT_FOUND" fatal="false" short="The requested file is not found in the specified Zip archive."> Check ZIP archive. Reset loader. If problem doesn't solved, report it.</value>
+ <value number="1955" name="E_ELF_FILE_FORMAT" fatal="false" short="The requested file is not an elf file."> Check input parameters. Repeat operation with correct input.</value>
+ <value number="1956" name="E_ELF_OPEN_SECTION" fatal="false" short="Can not open elf section."> Possible damaged elf file. Retry operation and reset loader. If problem doesn't solved report it.</value>
+ <value number="1957" name="E_NAME_TOO_LONG" fatal="false" short="The name of parameter is too long."> Check input parameters. Retry operation.</value>
+ <value number="1958" name="E_BOOTRECORDS_MISMATCH" fatal="false" short="Error in boot records."> Some information in boot image doesn't agree. Check software that you flash.</value>
+ <value number="1959" name="E_BOOTRECORD_EMPTY" fatal="false" short="Boot record is empty and operation cannot be executed."> Internal error. Reset loader. If problem doesn't solved, report it.</value>
+ <value number="1960" name="E_INVALID_BOOTRECORD_IMAGE" fatal="false" short="Boot record image is not valid."> Invalid boot image. Check software that you flash.</value>
+ <value number="1961" name="E_BOOTRECORD_FULL" fatal="false" short="Boot record has no space to accept new boot record."> Internal limitation. Report this problem.</value>
+ <value number="1962" name="E_BOOTRECORD_NOT_EXIST" fatal="false" short="Boot record not exist."> The boot record with that ID is never written.</value>
+ <value number="1963" name="E_BOOTRECORD_WRITE_FAILED" fatal="false" short="Writing failed."> The boot record with that ID was not written.</value>
+ <value number="1964" name="E_BOOTRECORD_UNALIGNED_DATA" fatal="false" short="Boot record data is unaligned."> For successfully writing in flash boot record must be a multiple of four bytes.</value>
+ <value number="1965" name="E_CONTENT_TYPE" fatal="false" short="Content type to long."> Check manifest file from flash archive. Repeat operation with correct flash archive. Report if problem still exist.</value>
+ <value number="1966" name="E_DEVICE_TYPE" fatal="false" short="Device type to long."> Check manifest file from flash archive. Repeat operation with correct flash archive. Report if problem still exist.</value>
+ <value number="1967" name="E_NUMBER_OF_TARGET_DEVICES" fatal="false" short="Number of target devices to big.">Internal error. Reset the loader. Report if problem still exist.</value>
+ <value number="1968" name="E_DESCRIPTION_TOO_LONG" fatal="false" short="Description field too long.">Internal error. Reset the loader. Report if problem still exist.</value>
+
+ <!--
+ * Loader ADBG Fatal 2000-2050
+ * Loader ADBG non-fatal 2051-2099
+ -->
+ <value number="2000" name="E_MODULE_NOT_FOUND" fatal="true" short="Testing this module currently not supported in ADbg."> Check the module number and try again.</value>
+ <value number="2001" name="E_MODULE_LIST_EMPTY" fatal="true" short="There isn't any module available for testing."> Use List Cases command to see available modules for testing.</value>
+ <value number="2002" name="E_CASE_NOT_FOUND" fatal="true" short="Specified case can not be found."> Use List Cases command to see available test cases.</value>
+ <value number="2003" name="E_CASE_LIST_EMPTY" fatal="true" short="There isn't any test cases in specified module."> Use List Cases command to see available test cases.</value>
+ <value number="2004" name="E_INT_GROUP_NOT_FOUND" fatal="true" short="Specified internal group can not be found."> Use List Interface command to see available internal groups.</value>
+ <value number="2005" name="E_INT_GROUP_LIST_EMPTY" fatal="true" short="There isn't any internal group.">Use List Interface command to see if is any available internal group.</value>
+ <value number="2006" name="E_INT_FUNCTION_NOT_FOUND" fatal="true" short="Specified interface function cannot be found."> Use List Interface command to see if specified internal function exist.</value>
+ <value number="2007" name="E_INT_FUNCTION_LIST_EMPTY" fatal="true" short="There isn't any interface function in interface group."> Use List Interface command to see if there's any available internal function.</value>
+ <value number="2008" name="E_PRECONDITION_IS_ALREADY_SET" fatal="true" short="Request for setting precondition that is already set."> Precondition is already set. If you want to change it, recover precondition, and than set it again.</value>
+ <value number="2009" name="E_PRECONDITION_IS_NOT_SET" fatal="true" short="Request to recover condition that is not changed."> You cannot recover condition that is not set before. There's no need of any further activities in order to resolve this problem. Loader will work fine.</value>
+
+ <!--
+ * OTP applications Fatal 2100-2150
+ * OTP applications non-fatal 2151-2199
+ -->
+ <value number="2100" name="E_INIT_OTP_PD_FAILED" fatal="true" short="Failed to initialize OTD driver."> Internal error. Reset loader. Report if problem still exist</value>
+ <value number="2101" name="E_READING_OTP_FAILED" fatal="true" short="Failed to read data from OTP."> Internal error. Reset loader. Report if problem still exist</value>
+ <value number="2102" name="E_WRITTING_OTP_FAILED" fatal="true" short="Failed to write data in OTP."> Internal error.Possible hardware malfunction. Please report this problem immediately</value>
+ <value number="2103" name="E_INVALID_CID_VALUE" fatal="true" short="Trying to write invalid CID in OTP."> The value for CID must be in the range from 19 to 16384.0 value is also alowed CID value</value>
+ <value number="2104" name="E_INIT_OTP_LD_FAILED" fatal="true" short="Failed to initialize OTD logical driver."> Internal error. Reset loader. Report if problem still exist</value>
+ <value number="2105" name="E_OTP_AREA_LOCKED" fatal="true" short="Requested OTP area is already locked."> It is not allowed to write in already locked OTP area</value>
+
+ <!--
+ * Security applications Fatal 2200-2250
+ * Security applications non-fatal 2251-2299
+ -->
+ <value number="2251" name="E_SEC_APP_PROPERTY_NOT_FOUND" fatal="true" short="App property cannot be found.">If specified property cannot be found by COPS module.</value>
+ <value number="2252" name="E_SEC_APP_IMEI_NOT_CHANGABLE" fatal="true" short="IMEI not changeable.">If user try to change IMEI in COPS while IMEI is set as non - changeable in OTP area.</value>
+ <value number="2253" name="E_SEC_APP_OPERATION_DENIED" fatal="true" short="Security operation denied.">If some security operation cannot be accomplished due to various reasons.</value>
+ <value number="2254" name="E_SEC_APP_UNABLE_TO_READ_BS_PARAMETERS" fatal="true" short="Incorrect Boot Stage Parameter vector.">.</value>
+ <value number="2255" name="E_SEC_APP_ROM_ERROR_CRITICAL" fatal="true" short="Critical error in ROM has occurred.">Reset loader. Report if problem still exist.</value>
+ <value number="2256" name="E_SEC_APP_ROM_ERROR" fatal="true" short="Unexpected ROM error.">Reset loader. Report if problem still exist.</value>
+ <value number="2257" name="E_SEC_APP_PATCH_EXISTS" fatal="true" short="ROM Patch is already installed.">If you are trying to install flash patch ,please make sure that version of ROM patch is greater than already installed. Reinstallation of OTP patch is not allowed.</value>
+ <value number="2258" name="E_SEC_APP_PATCH_REINSTALLED" fatal="true" short="Operation successful."> ROM Patch in Flash is successfuly reinstalled.</value>
+ <value number="2259" name="E_SEC_APP_ROOTKEY_EXISTS" fatal="true" short="RootKey is already installed.">.Please make sure that version of Root key is the same with already installed</value>
+ <value number="2260" name="E_SEC_APP_ROOTKEY_REINSTALLED" fatal="true" short="Operation successful."> Root Key is successfuly reinstalled.</value>
+
+ <!--
+ * Trim Area Fatal 2300-2350
+ * Trim Area non-fatal 2351-2499
+ -->
+ <value number="2351" name="E_TA_WRONG_PARTITION" fatal="false" short="TA: Unknown partition."> Check input parameters. Repeat operation with the correct input parameters. Report if problem still exist.</value>
+ <value number="2352" name="E_TA_ILLOGICAL_CONFIGURATION" fatal="false" short="TA: Configuration error."> Possible wrong configuration in flash archive. Check the archive. Flash the correct archive. If problem still exist report the problem.</value>
+ <value number="2353" name="E_TA_UNKNOWN_MEMORY_TYPE" fatal="false" short="TA: Unsupported memory type."> Possible wrong configuration in flash archive. Check the archive. Flash the correct archive. If problem still exist report the problem.</value>
+ <value number="2354" name="E_TA_WRONG_PARAMETER" fatal="false" short="TA: Wrong parameter."> Check input parameters. Repeat operation with the correct input parameters. Report if problem still exist.</value>
+ <value number="2355" name="E_TA_OUT_OF_MEMORY" fatal="false" short="TA: No heap memory left."> Internal error. Reset loader. Report if problem still exist</value>
+ <value number="2356" name="E_TA_INVALID_ADRESS" fatal="false" short="TA: Invalid address."> Internal error. Reset loader. Report if problem still exist</value>
+ <value number="2357" name="E_TA_UNUSED_ADRESS" fatal="false" short="TA: Unused address."> Internal error. Reset loader. Report if problem still exist</value>
+ <value number="2358" name="E_TA_UNIT_NOT_FOUND" fatal="false" short="TA: Unit was not found."> No data was written in the specified unit. Write data to the unit and than perform read operation. Report if problem still exist.</value>
+ <value number="2359" name="E_TA_WRONG_SIZE" fatal="false" short="TA: Wrong size when reading unit."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="2360" name="E_TA_INSUFFICIANT_SPACE" fatal="false" short="TA: Not enough space to flush the Trim Area."> Internal error. Reset loader. Report if problem still exist</value>
+ <value number="2361" name="E_TA_UNKNOWN_PARTITION" fatal="false" short="TA: Unknown partition."> Check input parameters. Repeat operation with the correct input parameters. Report if problem still exist.</value>
+ <value number="2362" name="E_TA_FAIL" fatal="false" short="TA: Fail."> Internal error. Reset loader. Report if problem still exist.</value>
+
+ <value number="2460" name="E_TA_MEDIA_ERROR" fatal="false" short="TA: Media error."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="2461" name="E_TA_NOT_CONFIGURED" fatal="false" short="TA: Error occurs during configuration."> Possible wrong or missing configuration in flash archive. Check the archive. Flash the correct archive. If problem still exist report the problem.</value>
+
+ <!--
+ * Recovery applications Fatal 2500-2550
+ * Recovery applications non-fatal 2551-2599
+ -->
+ <value number="2500" name="E_REQUEST_DENIED" fatal="true" short="Request for change operation denied."> Init request is twice called and state is changed. Should be sent Update request then can be used Init request again.</value>
+ <value number="2501" name="E_UNDEFINED_CHANGE_OPERATION" fatal="true" short="Requested change operation is not supported."> Use the implemented change operation.</value>
+
+ <!--
+ * PD CFI Flash Fatal 2600-2650
+ * PD CFI Flash non-fatal 2651-2699
+ -->
+
+ <value number="2651" name="E_PD_CFI_IN_PROGRESS" fatal="false" short="PD CFI: The operation is in progress. Additional poll calls must be done."></value>
+ <value number="2652" name="E_PD_CFI_UNKNOWN_REQUEST" fatal="false" short="PD CFI: Type not recognized."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="2653" name="E_PD_CFI_HARDWARE_ERROR" fatal="false" short="PD CFI: Operation could not be completed because of a hardware malfunction."> It is possible that part of the operation has been carried out.</value>
+ <value number="2654" name="E_PD_CFI_NOT_SUPPORTED" fatal="false" short="PD CFI: The driver does not implement the requested function."> Internal error. Report the problem.</value>
+ <value number="2655" name="E_PD_CFI_PARAMETER_ERROR" fatal="false" short="PD CFI: Invalid parameter value."> Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+ <value number="2656" name="E_PD_CFI_PROTECTED" fatal="false" short="PD CFI: The requested flash address is protected from the requested type of access."> Check input parameters. Repeat operation. Report if problem still exist.</value>
+ <value number="2657" name="E_PD_CFI_UNSUPPORTED_DEVICE" fatal="false" short="PD CFI: Flash devices not supported by this driver.">Possible hardware malfunction, or error in HW configuration.Reset loader,report if problem still exist. </value>
+ <value number="2658" name="E_PD_CFI_OPERATION_COMPLETE" fatal="false" short="PD CFI: Requested operation was not suspended as it has completed.">Operation is completed.</value>
+ <value number="2659" name="E_PD_CFI_HARDWARE_NOT_DETECTED" fatal="false" short="PD CFI: NOR memory was not detected on current configuration.">NOR memory is not present or some hardware malfunction occurred.</value>
+
+ <!--
+ * HSI Driver HSI_BSC_Result_t - Error codes for all functions (offset 2700)
+ * HSI Driver Fatal 2700-2724
+ * HSI Driver Non-Fatal 2725-2749
+ -->
+ <value number="2701" name="E_HSI_BSC_RESULT_FAILED" fatal="true" short="General Error.">It is possible to failed to initialize the communication device.Reset loader.Report if problem still exist</value>
+ <value number="2702" name="E_HSI_BSC_RESULT_FAILED_INVALIDARGS" fatal="true" short="Invalid arguments.">.Check input parameters. Retry operation. If problem still exist reset loader. Report if problem doesn't solved.</value>
+ <value number="2703" name="E_HSI_BSC_RESULT_FAILED_NOTSUPPORTED" fatal="true" short="Implementation is removed."> Implementation it is not supported anymore.</value>
+ <value number="2704" name="E_HSI_BSC_RESULT_FAILED_HSIERR" fatal="true" short="HSI internal error.">Buffer with unaligned length is requested to be transfered or device driver is confiured to use unsupported frame size.</value>
+ <value number="2705" name="E_HSI_BSC_RESULT_FAILED_BUSY" fatal="true" short="Communication device is busy.">Current transfer is not finished.</value>
+
+ <!--
+ * HSI Driver HSI_BSC_Error_t - Error codes for error callbacks (offset 2750)
+ * HSI Driver Error Callback Fatal 2750-2774
+ * HSI Driver Error Callback Non-Fatal 2775-2799
+ -->
+ <value number="2751" name="E_HSI_BSC_ERROR_SIGNAL" fatal="true" short="Signal error.">Simultaneous data and flag transaction.</value>
+ <value number="2752" name="E_HSI_BSC_ERROR_TIMEOUT" fatal="true" short="Timeout error.">Incorrect number of bits received.</value>
+ <value number="2753" name="E_HSI_BSC_ERROR_BREAK" fatal="true" short="Break received.">.Reset loader.Report if problem still exist.</value>
+ <value number="2754" name="E_HSI_BSC_ERROR_RECEIVE" fatal="true" short="Receive buffer is not provided.">Reset loader.Report if problem still exist.</value>
+ <value number="2755" name="E_HSI_BSC_ERROR_TRANSMIT" fatal="true" short="Transmit buffer is not provided.">Reset loader.Report if problem still exist.</value>
+
+ <!--
+ * Security Library Fatal 4000-4050
+ * Security Library non-fatal 4051-4250
+ -->
+ <value number="4000" name="E_LOADER_SEC_LIB_CHIP_ID_INVALID" fatal="true" short="Invalid input parameters.">The verification of ChipID list failed.</value>
+ <value number="4096" name="E_LOADER_SEC_LIB_INVALID_PARAMETER_TO_FUNC" fatal="true" short="Invalid input parameters.">The function that was called did not have correct parameters passed.</value>
+ <value number="4120" name="E_LOADER_SEC_LIB_FAILURE" fatal="true" short="Failure.">Some unexpected error occurs.Reset the loader.If problem does'n solved report it</value>
+ <value number="4121" name="E_LOADER_SEC_LIB_HASH_LIST_HASH_FAILURE" fatal="true" short="hash list verification failed.">The verification of hash list in Loader Security Library failed.</value>
+ <value number="4122" name="E_LOADER_SEC_LIB_HEADER_VERIFICATION_FAILURE" fatal="true" short="Header verification failed. ">The verification of the header has failed.</value>
+ <value number="4123" name="E_LOADER_SEC_LIB_HEADER_VERIFIED" fatal="true" short="Successful verification of the header">Successful verification of the header.</value>
+ <value number="4124" name="E_LOADER_SEC_LIB_VERIFY_FAILURE" fatal="true" short="Unsuccessful verification."> Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="4150" name="E_LOADER_SEC_LIB_INIT_CALLED_TWICE" fatal="true" short="The security library init function has been called 2 times.">Restart the loader.</value>
+ <value number="4180" name="E_LOADER_SEC_LIB_MEMORY_RELEASE_FAILED" fatal="true" short="Memory release failed.">Restart the loader.</value>
+ <value number="4181" name="E_LOADER_SEC_LIB_MEMORY_ALLOCATION_FAILED" fatal="true" short="Memory allocation failed.">Restart the loader.</value>
+ <value number="4182" name="E_LOADER_SEC_LIB_DATA_BLOCK_EXIST" fatal="true" short="Data block exist in the linked list.">nternal error. Reset loader. Report if problem still exist.</value>
+ <value number="4183" name="E_LOADER_SEC_LIB_DATA_BLOCK_DO_NOT_EXIST" fatal="true" short="Data block do not exist in the linked list.">nternal error. Reset loader. Report if problem still exist.</value>
+ <value number="4184" name="E_LOADER_SEC_LIB_INVALID_AUTHENTICATION_TYPE" fatal="true" short="Invalid authentication type."> Try to use the appropriate authentication type (control key or CA certificate).</value>
+ <value number="4185" name="E_LOADER_SEC_LIB_EXCEEDED_NUMBER_OF_AUTHENTICATION" fatal="true" short="Exceeded number of authentication. Loader will be shut downed.">Restart the laoder and use the correct control keys or CA certificate to authenticate.</value>
+ <value number="4186" name="E_LOADER_SEC_LIB_ESB_MAC_INIT_FAILED" fatal="true" short="Initialization of ESB block for MAC calculation failed.">Possible error in hardware configuration, or hardware malfunction.Reset loader. Report if problem still exist.</value>
+ <value number="4187" name="E_LOADER_SEC_LIB_ESB_MAC_UPDATE_FAILED" fatal="true" short="MAC update with ESB block failed.">Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="4188" name="E_LOADER_SEC_LIB_ESB_MAC_FINAL_FAILED" fatal="true" short="MAC finalize with ESB block failed.">Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="4189" name="E_LOADER_SEC_LIB_ESB_MAC_NOT_VERIFIED" fatal="true" short="MAC verification with ESB block failed.">Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="4190" name="E_LOADER_SEC_LIB_ESB_DOWNLOCK_FAILED" fatal="true" short="ESB downlock failed.">Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="4191" name="E_LOADER_SEC_LIB_CONTROL_KEY_VERIFICATION_FAILURE" fatal="true" short="Control key verification failed."> Verify that authentication is performed with correct control keys, otherwise report this error.</value>
+ <value number="4192" name="E_LOADER_SEC_LIB_CA_CERTIFICATE_VERIFICATION_FAILURE" fatal="true" short="CA certificate verification failed.">Verify that CA certifiacte which is used is valid and appropiate for the HW on which authentication is performed,otherwise report this error.</value>
+ <value number="4193" name="E_LOADER_SEC_LIB_X509_ERROR_IN_CERTIFICATE" fatal="true" short="X509 certificate error.">An error ocured while parsing X.509 certificate. Check that certificate structure is valid.</value>
+ <value number="4194" name="E_LOADER_SEC_LIB_COPS_INIT_FAILED" fatal="true" short="COPS initialization failed.">Internal error. Reset loader. Report if problem still exist</value>
+ <value number="4195" name="E_LOADER_SEC_LIB_COPS_PROTECT_DATA_INIT_FAILED" fatal="true" short="COPS protect data initialization failed.">Internal error. Reset loader. Report if problem still exis</value>
+ <value number="4196" name="E_LOADER_SEC_LIB_COPS_DATA_READ_FAILED" fatal="true" short="COPS data read failed.">Verify that Bind properties is already performed. Report if problem still exist</value>
+ <value number="4197" name="E_LOADER_SEC_LIB_COPS_DATA_WRITE_FAILED" fatal="true" short="COPS data write failed.">Verify that the data is correct and flash is not corupted. Report if problem still exist</value>
+ <value number="4198" name="E_LOADER_SEC_LIB_READ_OTP_FAILED" fatal="true" short="Reading OTP data failed.">Internal error.Please reset the loader and try again.Please report if problem still exist.</value>
+ <value number="4199" name="E_LOADER_SEC_LIB_WRITE_OTP_FAILED" fatal="true" short="Writing OTP data failed.">Internal error. Possible hardware malfunction. Please report this problem immediately.</value>
+ <value number="4200" name="E_LOADER_SEC_LIB_LOCK_OTP_FAILED" fatal="true" short="Locking OTP data failed.">Internal error.Possible hardware malfunction. Please report this problem immediately.</value>
+ <value number="4201" name="E_LOADER_SEC_LIB_UNPACKING_IMEI_FAILED" fatal="true" short="Unpacking IMEI data failed.">Internal error. Reset loader. Report if problem still exist</value>
+ <value number="4202" name="E_LOADER_SEC_LIB_PACKING_IMEI_FAILED" fatal="true" short="Packing IMEI data failed.">Internal error. Reset loader. Report if problem still exist></value>
+ <value number="4203" name="E_LOADER_SEC_LIB_OTP_ALREADY_LOCKED" fatal="true" short="OTP is already locked.">You are not allowed to write in already locked OTP area.</value>
+ <value number="4204" name="E_LOADER_SEC_LIB_INVALID_CID_VALUE" fatal="true" short="CID value is out of range.">The value for CID must be in the range from 19 to 16384.0 value is also alowed CID value.</value>
+ <value number="4205" name="E_LOADER_SEC_LIB_OTP_LOCKBITS_MISSMATCH" fatal="true" short="OTP lock bits have different values.">Reset loader. Report if problem still exist</value>
+ <value number="4206" name="E_LOADER_SEC_LIB_WRITING_BOOTRECORD_FAILED" fatal="true" short="Failed to write in boot records.">Internal error. Reset loader. Report if problem still exist</value>
+ <value number="4207" name="E_LOADER_SEC_LIB_UNSUPPORTED_NO_DEBUG_HW" fatal="true" short="No debug hardware detected.">Internal error. Reset loader. Report if problem still exist</value>
+ <value number="4208" name="E_LOADER_SEC_LIB_CHANGE_OPERATION_NOT_SUPPORTED" fatal="true" short="Requested change operation is not supported or not allowed.">Check the authentication level and try again. Report if problem still exist</value>
+ <value number="4209" name="E_LOADER_SEC_LIB_INVALID_CHANGE_OPERATION" fatal="true" short="Invalid change operation.">Internal error. Reset loader. Report if problem still exist.</value>
+ <value number="4210" name="E_LOADER_SEC_LIB_RWIMEI_NOT_ALLOWED" fatal="true" short="Rewriteable IMEI is not allowed to change.">Check if IMEI changeable is set in OTP. Report this issue if IMEI changeable is set and requested operation can not be executed.</value>
+ <value number="4211" name="E_LOADER_SEC_LIB_REQUEST_DENIED" fatal="true" short="Request for change operation is denied.">Check the authentication level and try again. Report if problem still exist</value>
+ <value number="4212" name="E_LOADER_SEC_LIB_BOOT_BLOCK_DO_NOT_EXIST" fatal="true" short="Boot record do not exist.">If boot block is corrupted or do not exist, processFile command should be used to flash the new boot record or recovery domain data to generate the boot record template.</value>
+ <value number="4213" name="E_LOADER_SEC_LIB_CORRUPTED_DOMAIN_DATA" fatal="true" short="Corrupted or do not exist domain data in boot block.">If domain data are corrupted or do not exist should be use the bind properties command or recover domain data to generate the new domain data.</value>
+ <value number="4214" name="E_LOADER_SEC_LIB_INVALID_DOMAIN" fatal="true" short="Invalid domain.">Select appropriated domain.</value>
+ <value number="4215" name="E_LOADER_SEC_LIB_INVALID_CHALLENGE_DATA_BLOCK" fatal="true" short="Invalid challenge data block.">Verify that challene data block is created properly.</value>
+ <value number="4216" name="E_LOADER_SEC_LIB_NO_DEBUG_HW_NOT_ALLOWED" fatal="true" short="Not allowed operation on NoDebug HW.">Cuurent opertaion can be executed only on Debug HW.</value>
+
+ <!--
+ * Emulator Fatal 4300-4350
+ * Emulator non-fatal 4351-4399
+ -->
+ <value number="4300" name="E_FIFO_OVERFLOW" fatal="true" short="UART FIFO overflow."> Reset loader. Report if problem still exist.</value>
+ <value number="4301" name="E_FIFO_UNDERFLOW" fatal="true" short="UART FIFO underflow.">Reset loader. Report if problem still exist.</value>
+ <value number="4302" name="E_OBJECT_NULL" fatal="true" short="Null pointer to Object.">Reset loader. Report if problem still exist.</value>
+ <value number="4303" name="E_POINTER_NOT_NULL" fatal="true" short="Pointer is not NULL.">Reset loader. Report if problem still exist.</value>
+ <value number="4304" name="E_UNRECOGNIZED_STATE" fatal="true" short="The state in the State Machine is invalid.">Reset loader. Report if problem stil exist.</value>
+ <value number="4305" name="E_UNKNOWN_MANUFACTURER_ID" fatal="true" short="The provided manufacturer ID is not valid.">Possible error in HW configuration. Try to reset the loader and if problem still exist, report it.</value>
+ <value number="4306" name="E_UNKNOWN_DEVICE_ID" fatal="true" short="The provided device ID is not valid.">Possible error in HW configuration. Try to reset the loader and if problem still exist, report it.</value>
+ <value number="4308" name="E_INVALID_A01_FORMAT" fatal="true" short="Something wrong with the A01 file containing the flash image.">Verify that the flash image is valid, otherwise report the problem. </value>
+ <value number="4309" name="E_A01_BUFFER_FULL" fatal="true" short="Buffer holding the data from the A01 file is full.">Reset loader. Report if problem still exist.</value>
+ <value number="4350" name="E_CONFIG_FILE_NOT_SPECIFIED" fatal="false" short="Configuration file for the emulator is not specified."> The loader will start with the default settings.</value>
+
+ <!--
+ * R13 and lower versions
+ * Error codes translation
+ -->
+ <value number="5000" name="A2_E_SUCCESS" fatal="true" short="Operation successful.">.</value>
+ <value number="5001" name="A2_E_PROP_NOT_SUPPORTED" fatal="true" short="The property is not supported.">The selected property is not supported by the loader.</value>
+ <value number="5002" name="A2_E_PROP_READ_ONLY" fatal="true" short="The property is read only.">.</value>
+ <value number="5003" name="A2_E_PROP_INVALID" fatal="true" short="The property value is invalid.">.Property value does not exist.</value>
+ <value number="5004" name="A2_E_AUTH_DECLINED" fatal="true" short="Authentication declined. The ME is automatically shut down after sending this.">.</value>
+ <value number="5005" name="A2_E_AUTH_UNSUPPORTED" fatal="true" short="The authentication type is not supported.">.</value>
+ <value number="5006" name="A2_E_ALLOCATE_FAILED" fatal="true" short="Failed to allocate memory.">Internal error. Reset loader. If problem doesn't solved, report it.</value>
+ <value number="5007" name="A2_E_INVALID_TIME" fatal="true" short="Invalid time specified.">Specify the correct time.</value>
+ <value number="5008" name="A2_E_UNKNWON_PROPERTY" fatal="true" short="Unknown property id.">Check if property id exists.</value>
+ <value number="5009" name="A2_E_START_AAIF_FAILED" fatal="true" short="Failed to start the AAIF in the loader on loader.">.</value>
+ <value number="5010" name="A2_E_UNSUPPORTED_CMD" fatal="true" short="Unsupported command.">This command is not supported.</value>
+ <value number="5011" name="A2_E_POINTER_NOT_ALIGNED" fatal="true" short="Pointer not aligned.">Internal error. Reset loader.</value>
+ <value number="5012" name="A2_E_ERROR_WRITING_BOOTRECORD" fatal="true" short="Writing of the boot record failed.">.</value>
+ <value number="5013" name="A2_E_INVALID_CURRDATE_STRING_LENGTH" fatal="true" short="String data length is invalid.">Check if input parameters are in the correct format.</value>
+ <value number="5014" name="A2_E_NO_COMMAND_GROUPS_DEFINED" fatal="true" short="Unknown command group.">The command group is not supported. Check the command documentation.</value>
+ <value number="5015" name="A2_E_READ_OTP_FAILED" fatal="true" short="Read OTP failed.">Reset loader. If problem doesn't solved, report it.</value>
+ <value number="5016" name="A2_E_COMMAND_IS_NOT_IMPLEMENTED" fatal="true" short="Specified command is not implemented.">.</value>
+ <value number="5017" name="A2_E_FAILED_TO_GET_ASIC_COPS_SETTINGS" fatal="true" short="Failed to get ASIC COPS setting.">.</value>
+ <value number="5018" name="A2_E_FAILED_TO_SET_PLAT_PROP" fatal="true" short="Failed to set platform properties.">Restart loader, if the problem still exists report it.</value>
+ <value number="5019" name="A2_E_MEMORY_FAILED" fatal="true" short="Memory fail.">Restart loader, if the problem still exists report it.</value>
+ <value number="5020" name="A2_E_JTAG_UNLOCK_FAILED" fatal="true" short="JTAG unlock fail.">.</value>
+ <value number="5021" name="A2_E_AUTOCONFIGURE_FLASH" fatal="true"></value>
+ <value number="5022" name="A2_E_E_GET_FIRST_FLASH_DEV" fatal="true"></value>
+ <value number="5023" name="A2_E_E_FAILED_INIT_COPS_LIB" fatal="true" short="Failed to initialize COPS library.">Restart loader, if the problem still exists report it.</value>
+ <value number="5024" name="A2_E_OTP_SECURITY_ERROR" fatal="true" short="OTP security error.">.</value>
+ <value number="5025" name="A2_E_I2C_BUS_SECURITY_ERROR" fatal="true" short="I2C bus security error.">.</value>
+ <value number="5026" name="A2_E_GET_STATIC_DATA_FAILED" fatal="true" short="Can't get static data.">.</value>
+ <value number="5027" name="A2_E_STORE_MAC_TO_BOOTIMAGE_FAILED" fatal="true" short="Failed to store MAC in boot image.">.</value>
+ <value number="5028" name="A2_E_SEC_GENERAL_COPS_LIB_ERROR" fatal="true" short="General COPS error.">.</value>
+ <value number="5029" name="A2_E_HASH_VERIFICATION_ERROR" fatal="true" short="Hash verification failed.">.</value>
+ <value number="5030" name="A2_E_READ_FLASH_FAILED" fatal="true" short="Failed to read hash.">.</value>
+ <value number="5031" name="A2_E_APP_HANDSHAKE_FAILED" fatal="true" short="Processors handshake failed.">.</value>
+ <value number="5032" name="A2_E_BOOTIMAGE_MEMCONF_INVALID" fatal="true" short="Invalid memconfig in boot image.">.</value>
+ <value number="5033" name="A2_E_BOOTIMAGE_SIGNATURE_FAILED" fatal="true" short="Boot image signature failed.">.</value>
+ <value number="5034" name="A2_E_BOOTIMAGE_FAILED_TO_READ_IMAGE" fatal="true" short="Failed to read image.">.</value>
+ <value number="5035" name="A2_E_BOOTIMAGE_FAILED_ALLOCATE_MEM" fatal="true" short="Failed to allocate memory.">.</value>
+ <value number="5036" name="A2_E_BOOTIMAGE_INVALID_PARAM" fatal="true" short="Boot image invalid parametars.">.</value>
+ <value number="5037" name="A2_E_BOOTIMAGE_INVALID_LENGTH" fatal="true" short="Boot image has invalid length.">.</value>
+ <value number="5038" name="A2_E_BOOTIMAGE_MACED_HEADER_SIZE_ZERO" fatal="true" short="Header size is zero.">.</value>
+ <value number="5039" name="A2_E_FLASH_RESULT_DEVICE_PROTECTED" fatal="true" short="The flash device was protected.">.</value>
+ <value number="5040" name="A2_E_FLASH_RESULT_WRITE_SUSPENDED" fatal="true" short="The last write process was suspended.">.</value>
+ <value number="5041" name="A2_E_FLASH_RESULT_VOLTAGE_RANGE_ERROR" fatal="true" short="The voltage range is invalid.">.</value>
+ <value number="5042" name="A2_E_FLASH_RESULT_PROGRAM_ERROR" fatal="true" short="Failed to write to the flash device.">.</value>
+ <value number="5043" name="A2_E_FLASH_RESULT_ERASE_ERROR" fatal="true" short="Failed to erase a block in the flash device.">.</value>
+ <value number="5044" name="A2_E_FLASH_RESULT_ERASE_SUSPENDED" fatal="true" short="The erase process was suspended.">.</value>
+ <value number="5045" name="A2_E_FLASH_RESULT_COMMAND_SEQUENCE_ERROR" fatal="true" short="The sequence of the flash commands was invalid.">.</value>
+ <value number="5046" name="A2_E_FLASH_RESULT_OPERATION_NOT_SUPPORTED" fatal="true" short="Operation was not supported in flashdriver.">.</value>
+ <value number="5047" name="A2_E_FLASH_RESULT_INVALID_PARAMETER" fatal="true" short="Invalid in-parameter specified when reading/writing to flash.">.</value>
+ <value number="5048" name="A2_E_FLASH_RESULT_NO_FLASH_DEVICE" fatal="true" short="No flash device was found on the physical address.">.</value>
+ <value number="5049" name="A2_E_FLASH_RESULT_CONFIGURATION_ERROR" fatal="true" short="Configuration error of flash device.">.</value>
+ <value number="5050" name="A2_E_FLASH_RESULT_INVALID_STARTADDRESS" fatal="true" short="Invalid start address of the parameter.">.</value>
+ <value number="5051" name="A2_E_FLASH_RESULT_INVALID_PHYSICAL_ADDRESS" fatal="true" short="Invalid physical address of the parameter.">.</value>
+ <value number="5052" name="A2_E_FLASH_RESULT_INVALID_DATALENGTH" fatal="true" short="The data length of the parameter is invalid.">.</value>
+ <value number="5053" name="A2_E_FLASH_RESULT_GETREGION_ERROR" fatal="true" short="Invalid flash region specified.">.</value>
+ <value number="5054" name="A2_E_FLASH_RESULT_NULL_POINTER_BUF" fatal="true" short="A buffer was NULL.">.</value>
+ <value number="5055" name="A2_E_FLASH_RESULT_NAND_READ_FAILED" fatal="true" short="Failed to read from the NAND flash.">.</value>
+ <value number="5056" name="A2_E_FLASH_RESULT_NAND_PAGE_SIZE_UNSUPPORTED" fatal="true" short="The nand page size is unsupported.">.</value>
+ <value number="5057" name="A2_E_FLASH_RESULT_WRITE_ERROR" fatal="true" short="Failed to write to the flash device.">.</value>
+ <value number="5058" name="A2_E_FLASH_RESULT_READ_ID_ERROR" fatal="true" short="Failed to read the device ID from the flash device.">.</value>
+ <value number="5059" name="A2_E_FLASH_RESULT_HARDWARE_ERROR" fatal="true" short="Hardware error in the flash status.">.</value>
+ <value number="5060" name="A2_E_FLASH_RESULT_READ_FROM_FLASH" fatal="true" short="Failed to read from the flash device.">.</value>
+ <value number="5061" name="A2_E_FLASH_RESULT_ADD_NEW_DEVICE" fatal="true" short="Failed to add a new instance of a flash device.">.</value>
+ <value number="5062" name="A2_E_FLASH_RESULT_OTP_UNSUPPORTED_IN_FLASH" fatal="true" short="OTP is not support in the current flash device.">.</value>
+ <value number="5063" name="A2_E_FLASH_RESULT_OTP_TOO_SMALL" fatal="true" short="The OTP size is to small for the length requested.">.</value>
+ <value number="5064" name="A2_E_FLASH_RESULT_OTP_READ_FAILED" fatal="true" short="Failed to read the OTP area in the flash device.">.</value>
+ <value number="5065" name="A2_E_FLASH_RESULT_INVALID_FLASH_TYPE" fatal="true" short="The flash type is unknown.">.</value>
+ <value number="5066" name="A2_E_FLASH_RESULT_NAND_FLUSH_ERROR" fatal="true" short="Failed to flush the NAND write buffer.">.</value>
+ <value number="5067" name="A2_E_FLASH_RESULT_NOR_FLUSH_ERROR" fatal="true" short="Failed to flush the NOR write buffer.">.</value>
+ <value number="5068" name="A2_E_INVALID_LOL_STATE" fatal="true" short="Invalid Loader on loader state.">.</value>
+ <value number="5069" name="A2_E_INVALID_STATUS_LOLSTATE" fatal="true" short="Invalid loader on loader status.">.</value>
+ <value number="5070" name="A2_E_WRITE_STATIC_DATA" fatal="true" short="Write static data failed.">.</value>
+ <value number="5071" name="A2_E_HEADER_NOT_VERIFIED_YET" fatal="true" short="Header is still not verified.">.</value>
+ <value number="5072" name="A2_E_ALL_BLOCKS_VERIFIED_FAILED" fatal="true" short="Blocks verification failed.">.</value>
+ <value number="5073" name="A2_E_HANDSHAKE_WITH_APP_SIDE" fatal="true" short="Handshake with App side failed.">.</value>
+ <value number="5074" name="A2_E_READ_STATIC_DATA" fatal="true" short="Failed to read static data.">.</value>
+ <value number="5075" name="A2_E_ENABLE_CLOCK_HARDWARE_FAILED" fatal="true" short="Failed to enable clock hardware.">.</value>
+ <value number="5076" name="A2_E_ENABLE_BLOCK_HARDWARE_FAILED" fatal="true" short="Failed to enable block hardware.">.</value>
+ <value number="5077" name="A2_E_NO_HEADER_TO_MAC_IN_BOOT" fatal="true" short="Indicates that the loader did not find any header in the bootimage records that could be MAC'ed.">.</value>
+ <value number="5078" name="A2_E_MMU_SETUP" fatal="true" short="MMU setup failed.">.</value>
+ <value number="5079" name="A2_E_INVALID_COMMAND_SIZE" fatal="true" short="Invalid command size.">.</value>
+ <value number="5080" name="A2_E_HASH_LIST_LENGTH_INVALID" fatal="true" short="Invalid hash list length.">.</value>
+ <value number="5081" name="A2_E_INVALID_INPUT_PARAMETERS" fatal="true" short="Invalid input parameters.">.</value>
+ <value number="5082" name="A2_E_FAILED_SETUP_MSL_DRIVER" fatal="true" short="MSL driver setup failed.">.</value>
+ <value number="5083" name="A2_E_REQUEST_DENIED" fatal="true" short="Request denied.">.</value>
+ <value number="5084" name="A2_E_ASIC_FUSES_INVALID" fatal="true" short="Fuses for the ASIC are invalid.">.</value>
+ <value number="5085" name="A2_E_STATIC_DATA_NOT_CHECKED" fatal="true" short="Static data is not checked.">.</value>
+ <value number="5086" name="A2_E_COPS_DATA_MAN_INIT" fatal="true" short="Failed to initialize the cops data man, this can be caused by an corrupt boot image. You probably just need to flash a platform software to get it work.">.</value>
+ <value number="5087" name="A2_E_UART_DRIVER_ERROR" fatal="true" short="UART driver error.">.</value>
+ <value number="5088" name="A2_E_INVALID_DOMAIN_FOR_LOADER_TYPE" fatal="true" short="Loader type is not compatible with this domain.">.</value>
+ <value number="5089" name="A2_E_FUNCTIONALITY_NOT_IN_PRODUCT" fatal="true" short="Functionality not supported.">.</value>
+ <value number="5090" name="A2_E_DEFALT_DATA_NOT_FOUND" fatal="true" short="Default data can not be found.">.</value>
+ <value number="5091" name="A2_E_FAILED_TO_MAC_HEADER" fatal="true" short="Failed to send the header to access side to be MAC'ed, could be something wrong with the header.">.</value>
+ <value number="5092" name="A2_E_APP_PRELOADER_NOT_STARTED" fatal="true" short="App preloader not started.">.</value>
+ <value number="5093" name="A2_E_INVALID_DEST_ADDRESS" fatal="true" short="Invalid destination address.">.</value>
+ <value number="5094" name="A2_E_SYS_APP_INIT_FAILURE" fatal="true" short="Failed to initialize the system application.">.</value>
+ <value number="5095" name="A2_E_FLASH_APP_INIT_FAILURE" fatal="true" short="Failed to initialize the flash application.">.</value>
+ <value number="5096" name="A2_E_SIGNATURE_APP_INIT_FAILURE" fatal="true" short="Failed to initialize the signature application.">.</value>
+ <value number="5097" name="A2_E_RESET_APP_INIT_FAILURE" fatal="true" short="Failed to initialize the reset application.">.</value>
+ <value number="5098" name="A2_E_INT_SEC_APP_INIT_FAILURE" fatal="true" short="Failed to initialize the internal security application.">.</value>
+ <value number="5099" name="A2_E_COPS_DATA_MAN_FORMAT" fatal="true" short="COPS data man Format.">.</value>
+ <value number="5100" name="A2_E_COPS_DATA_MAN_WRITE" fatal="true" short="COPS data man write.">.</value>
+ <value number="5101" name="A2_E_COPS_DATA_MAN_FLUSH" fatal="true" short="Failed to Flush the memory into the security partition.">.</value>
+ <value number="5102" name="A2_E_COPS_DATA_MAN_GETBLOCKSIZE" fatal="true" short="Failed to get the block size of a unit in the security partition.">.</value>
+ <value number="5103" name="A2_E_COPS_DATA_MAN_READBLOCK" fatal="true" short="Failed to read an index from the security partition.">.</value>
+ <value number="5104" name="A2_E_INVALID_FLASH_VAR_LENGTH" fatal="true" short="The bytes left to program should be less than a NAND page.">.</value>
+ <value number="5105" name="A2_E_BOOTIMAGE_TOO_BIG" fatal="true" short="Boot image is too big.">.</value>
+ <value number="5106" name="A2_E_GDFS_APP_INIT_FAILURE" fatal="true" short="App GD init failed.">.</value>
+ <value number="5107" name="A2_E_FILESYS_APP_INIT_FAILURE" fatal="true" short="Failed to initialize the file system.">.</value>
+ <value number="5108" name="A2_E_INVALID_SOURCE_DEST_ADDRESS" fatal="true" short="Invalid source or destination address.">.</value>
+ <value number="5109" name="A2_E_INVALID_RESPONSE_COMMAND" fatal="true" short="Invalid Response command number on the internal security command group, was expecting command 0xFF.">.</value>
+ <value number="5110" name="A2_E_INVALID_RESP_TO_CMD" fatal="true" short="The internal sec command response should have responded to another command.">.</value>
+ <value number="5111" name="A2_E_VERIFICATION_OF_WRITTEN_DATA_FAILED" fatal="true" short="The data programmed into flash was not the same as the data received!">.</value>
+ <value number="5112" name="A2_E_INVALID_NAND_PADMUX_SETTING" fatal="true" short="The PADMUX configuration has not been set.">.</value>
+ <value number="5113" name="A2_E_FLASH_DRIVER_FAILED_SET_BOOT_ADDR" fatal="true" short="Failed to set the start boot address, this address are used to read the static data.">.</value>
+ <value number="5114" name="A2_E_FLASH_BOOT_IS_NOT_EMPTY" fatal="true" short="if the static data was not found, the flash should be empty!">.</value>
+ <value number="5115" name="A2_E_BOOTIMAGE_PMC_NOT_NEEDED" fatal="true" short="This error code informs that found boot container holds information that is not PMC protected.">.</value>
+ <value number="5116" name="A2_E_UNSUPPORTED_PMC" fatal="true" short="The PMC ID is not supported.">.</value>
+ <value number="5117" name="A2_E_FSVN_VS_PMC" fatal="true" short="The PMC ID is not coordinated with FSVN.">.</value>
+ <value number="5118" name="A2_E_WRONG_PMC_START_COUNT" fatal="true" short="PMC start count to high or zero.">.</value>
+ <value number="5119" name="A2_E_UNSUITABLE_PMC_FOR_LOCATION" fatal="true" short="Unsuitable PMC for the location.">.</value>
+ <value number="5120" name="A2_E_PMC_MISSING" fatal="true" short="The PMC can not be found.">.</value>
+ <value number="5121" name="A2_E_VERSION_NOT_ACCEPTED" fatal="true" short="FSVN is too low.">.</value>
+ <value number="5122" name="A2_E_PMC_OVERFLOWN" fatal="true" short="All steps of the PMC are destroyed.">.</value>
+ <value number="5123" name="A2_E_PMC_ONCE_REQUIRED" fatal="true" short="New version of once protected module attempted to be loaded without ARB flag set.">.</value>
+ <value number="5124" name="A2_E_PMC_BAD_N_OF_STEPS" fatal="true" short="Unsuitable number of steps within PMC.">.</value>
+ <value number="5125" name="A2_E_UNIT_MISSING" fatal="true" short="Dynamyc variable is missing.">.</value>
+ <value number="5126" name="A2_E_UNIT_TO_BIG" fatal="true" short="Dynamyc variable found is to big.">.</value>
+ <value number="5127" name="A2_E_PARTMAN_READ_ERROR" fatal="true" short="Error reading partition manger status.">.</value>
+ <value number="5128" name="A2_E_PARTMAN_INIT_ERROR" fatal="true" short="Error initializing partition manger.">.</value>
+ <value number="5129" name="A2_E_BOOTIMAGE_INVALID_ALLIGNMENT" fatal="true" short="Boot container size is not word alligned.">.</value>
+ <value number="5130" name="A2_E_BOOTIMAGE_INSUFFICIENT_CONTAINERS" fatal="true" short="Not enough boot containers are allocated.">.</value>
+ <value number="5131" name="A2_E_BOOTIMAGE_INVALID_CONTAINER_TYPE" fatal="true" short="Invalid boot container type. At this position other type of container is expected.">.</value>
+ <value number="5132" name="A2_E_DATA_LENGTH_IS_NOT_ALIGNED" fatal="true" short="The data size must be aligned to 512 bytes when reading or writing pages to/from the NAND.">.</value>
+ <value number="5133" name="A2_E_LOADER_SWINIT_JTAG_UNLOCK_FAILED" fatal="true" short="TEST JTAG EANBLENODEBUG.">.</value>
+ <value number="5134" name="A2_E_BOOTIMAGE_RECORD_NOT_FOUND" fatal="true" short="Required record is not found in the boot containers.">.</value>
+ <value number="5135" name="A2_E_BUFFER_OVERFLOW" fatal="true" short="Buffer overflow.">Buffer is not big enough.</value>
+ <value number="5136" name="A2_E_BUFFER_NOT_ALLOCATED" fatal="true" short="Buffer has not been allocated.">.</value>
+ <value number="5137" name="A2_E_WRONG_DATA_SIZE" fatal="true" short="Size of data has an unexpected value.">.</value>
+ <value number="5138" name="A2_E_NO_STATIC_DATA_IN_BOOTIMAGE" fatal="true" short="Static data in boot record is corrupted.">.</value>
+ <value number="5139" name="A2_E_NOT_ALLOWED_TO_FLASH" fatal="true" short="Not allowed to flash this block.">.</value>
+ <value number="5140" name="A2_E_UNABLE_TO_CHANGE_MMU_SETTINGS" fatal="true" short="Unable to change MMU settings.">Error encountered when loader tried to change MMU setting.</value>
+ <value number="5141" name="A2_E_INVALID_HW_FOR_LOADER_SETTINGS" fatal="true" short="Loader settings are not compatible with loader settings.">Error encountered when loader tried to startup on invalid Hardware.</value>
+ <value number="5142" name="A2_E_CABS_START_FAILED" fatal="true"></value>
+ <value number="5143" name="A2_E_CABS_READ_ERROR" fatal="true"></value>
+ <value number="5144" name="A2_E_CABS_WRITE_ERROR" fatal="true"></value>
+ <value number="5145" name="A2_E_ELF_DECODE_GENERAL_ERROR" fatal="true"></value>
+ <value number="5146" name="A2_E_ELF_INVALID_PARAMETER" fatal="true"></value>
+ <value number="5147" name="A2_E_PARTMAN_INIT_FAILED" fatal="true"></value>
+ <value number="5148" name="A2_E_PARTMAN_WRITE_FAILED" fatal="true"></value>
+ <value number="5149" name="A2_E_PARTMAN_READ_FAILED" fatal="true"></value>
+ <value number="5150" name="A2_E_PARTMAN_ERASE_ERROR" fatal="true"></value>
+ <value number="5151" name="A2_E_MBBS_CONFIG_ERROR" fatal="true"></value>
+ <value number="5152" name="A2_E_MBBS_READ_ERROR" fatal="true"></value>
+ <value number="5153" name="A2_E_MBBS_WRITE_ERROR" fatal="true"></value>
+ <value number="5154" name="A2_E_MBBS_ERASE_ERROR" fatal="true"></value>
+ <value number="5155" name="A2_E_FLASH_HW_CONFIG" fatal="true"></value>
+ <value number="5156" name="A2_E_VSP_IS_NOT_ALLOWED" fatal="true" short="Virtual security partition is not allowed in this configuration.">.</value>
+ <value number="5157" name="A2_E_VSP_WRITE_STATIC_DATA" fatal="true" short="Failed to write static data to virtual security partition.">.</value>
+ <value number="5158" name="A2_E_VSP_READ_STATIC_DATA" fatal="true" short="Failed to read static data from virtual security partition.">.</value>
+ <value number="5159" name="A2_E_VSP_NOT_FORMATED" fatal="true" short="Virtual security partition is not initialized.">.</value>
+ <value number="5160" name="A2_E_VSP_UNSUPPORTED_UNIT_TYPE" fatal="true" short="Unit type is out of range in virtual security partition.">.</value>
+ <value number="5161" name="A2_E_GET_DYNAMIC_DATA_FAILED" fatal="true" short="Could not get the dynamic data from the security library.">.</value>
+ <value number="5162" name="A2_E_FLASH_RESULT_PARTITION_TABLE_FLASHED" fatal="true" short="Partition table repaired!! Please load file again.">.</value>
+ <value number="5163" name="A2_E_FLASH_RESULT_PARTITION_TABLE_NOT_FLASHED" fatal="true" short="Partition table is damaged!">Loaded file does not contain a valid partition table. Please load a file containing partition table.</value>
+ <value number="5164" name="A2_E_FLASH_RESULT_READ_FROM_PARTITION_TABLE" fatal="true" short="Partition table is damaged.">.</value>
+ <value number="5165" name="A2_E_BOOTIMAGE_PARTITION_RECORD_NOT_FOUND" fatal="true" short="Partition table record is not found in the boot containers.">.</value>
+ <value number="5166" name="A2_E_CORRUPT_STATIC_DATA_IN_BOOT_BLOCK" fatal="true" short="Static data in boot block is corrupt.">.</value>
+ <value number="5167" name="A2_E_MBBS_BBM_TYPE_CONFLICT" fatal="true" short="MBBS and BBM type conflict.">.</value>
+ <value number="5168" name="A2_E_EXECUTION_NOT_PERMITTED" fatal="true" short="Execution of this command is not allowed in the current domain with current authentication state.">.</value>
+ <value number="5169" name="A2_E_EXECUTION_NOT_PERMITTED_WARNING" fatal="true" short="Execution of this command is not allowed in the current domain with current authentication state.">Non fatal error.</value>
+ <value number="5171" name="A2_E_UNABLE_TO_INITIALIZE_LCD" fatal="true" short="Error during initialization of LCD drivers.">.</value>
+ <value number="5172" name="A2_E_LCD_NOT_INITIALIZED" fatal="true" short="LCD is not initialized.">.</value>
+ <value number="5173" name="A2_E_UNABLE_TO_DISPLAY_DATA_ON_LCD" fatal="true" short="Unrecoverable error during BMP image is processed.">.</value>
+ <value number="5174" name="A2_E_NETWORK_BUFFER_CORRUPTED" fatal="true" short="The network buffer area is corrupted.">.</value>
+
+ <value number="5200" name="A2_E_TOO_MENY_FRAGMENTS" fatal="true"></value>
+ <value number="5201" name="A2_E_FAILED_TO_GET_APPLICATION" fatal="true"></value>
+
+ <value number="9096" name="A2_E_SECURITY_LIBRARY_ERROR_BEGIN" fatal="true"></value>
+ <value number="9300" name="A2_E_SECURITY_LIBRARY_ERROR_END" fatal="true"></value>
+
+ <!--
+ * FILE SYSTEM ERRORS
+ -->
+ <value number="5301" name="A2_E_UNSUPPORTED_PROPERTY" fatal="true" short="Unsupported file system property.">.</value>
+ <value number="5302" name="A2_E_READ_ONLY" fatal="true" short="The property is read only.">.</value>
+ <value number="5303" name="A2_E_INVALLID_PROPERTY_SPECIFIED" fatal="true" short="The specified property value was invalid.">.</value>
+ <value number="5304" name="A2_E_ACCESS_DENIED" fatal="true" short="The access permission attributes do not allow operation.">.</value>
+ <value number="5305" name="A2_E_FORMATTING_FS" fatal="true" short="The file system is formatting.">.</value>
+ <value number="5306" name="A2_E_PATH_NOT_EXISTS" fatal="true" short="The path does not exist.">.</value>
+ <value number="5307" name="A2_E_PATH_ALREADY_EXISTS" fatal="true" short="The path already exists.">.</value>
+ <value number="5308" name="A2_E_PATH_READ_ONLY" fatal="true" short="The path is read only.">.</value>
+ <value number="5309" name="A2_E_INSUFFICENT_SPACE" fatal="true" short="Insufficient space.">.</value>
+ <value number="5310" name="A2_E_DIRECTORY_NOT_EMPTY" fatal="true" short="The directory is not empty.">.</value>
+ <value number="5311" name="A2_E_INVALID_RESTRICTION_SPECIFIED" fatal="true" short="Invalid access restrictions specified.">.</value>
+ <value number="5312" name="A2_E_NO_FILESYSTEM_PROPERTY" fatal="true" short="No file system property.">.</value>
+ <value number="5313" name="A2_E_FILE_NOT_EXISTS" fatal="true" short="The file does not exist.">.</value>
+ <value number="5314" name="A2_E_CHANGE_DIR" fatal="true" short="Failed to change directory.">.</value>
+ <value number="5315" name="A2_E_CHMOD" fatal="true" short="Failed to set new CH mod.">.</value>
+ <value number="5316" name="A2_E_GWD" fatal="true" short="Failed to get the current directory.">.</value>
+ <value number="5317" name="A2_E_OPEN_FILE" fatal="true" short="Failed to open a file in the file system.">.</value>
+ <value number="5318" name="A2_E_ITEM_STAT" fatal="true" short="Failed to read the stat from file.">.</value>
+ <value number="5319" name="A2_E_LIST_VOL" fatal="true" short="Failed to list volumes.">.</value>
+ <value number="5320" name="A2_E_FREE_SPACE" fatal="true" short="No free space left.">.</value>
+ <value number="5321" name="A2_E_CLOSE_FILE" fatal="true" short="Failed to close a file in the filesystem.">.</value>
+ <value number="5322" name="A2_E_CLOSE_DIRECTORY" fatal="true" short="Failed to close the directory.">.</value>
+ <value number="5323" name="A2_E_REMOVE_FILE" fatal="true" short="Failed to remove a file from the filesystem.">.</value>
+ <value number="5324" name="A2_E_RENAME_FILE" fatal="true" short="Failed to rename a file in the filesystem.">.</value>
+ <value number="5325" name="A2_E_CREATE_DIR" fatal="true" short="Failed to create a new directory in the filesystem.">.</value>
+ <value number="5326" name="A2_E_REMOVE_DIRECTORY" fatal="true" short="Failed to remove a directory from the file system.">.</value>
+ <value number="5327" name="A2_E_WRITE_FILE" fatal="true" short="Failed to write a file to the file system.">.</value>
+ <value number="5328" name="A2_E_INVALID_SFA_STATE" fatal="true" short="The state of the SFA programming is incorrect.">.</value>
+ <value number="5329" name="A2_E_READ_FILE" fatal="true" short="Failed to read a file from the file system.">.</value>
+ <value number="61797" name="A2_E_CORE_SUPERV" fatal="true"></value>
+ <value number="66166" name="A2_E_MEM_ALLOC" fatal="true"></value>
+
+ <!--
+ * GDFS Error codes
+ -->
+ <value number="5401" name="A2_E_GDFS_UNSUPPORTED_PROPERTY" fatal="true" short="Unsupported GDFS property.">.</value>
+ <value number="5402" name="A2_E_GDFS_READ_ONLY" fatal="true" short="The GDFS property is read only.">.</value>
+ <value number="5403" name="A2_E_GDFS_PROPERTY_VALUE_INVALID" fatal="true" short="The property value is invalid.">.</value>
+ <value number="5404" name="A2_E_GDFS_INVALID_START_PROPERTY" fatal="true" short="Invalid start property.">.</value>
+ <value number="5405" name="A2_E_GDFS_NOT_STARTED" fatal="true" short="GDFS has not been started yet.">.</value>
+ <value number="5406" name="A2_E_GDFS_FAILED_TO_FORMAT" fatal="true" short="Failed to format the GDFS area.">.</value>
+ <value number="5407" name="A2_E_GDFS_NOT_FORMATTED" fatal="true" short="GDFS is not formatted, as it should be.">.</value>
+ <value number="5408" name="A2_E_GDFS_INVALID_BLOCK_UNIT_SPECIFIED" fatal="true" short="Invalid Block unit number.">.</value>
+ <value number="5409" name="A2_E_GDFS_NO_CONFIGURATION_FOUND" fatal="true" short="Could not find any GDFS configuration from the platform software in flash.">.</value>
+ <value number="5410" name="A2_E_GDFS_CLOSE" fatal="true" short="Failed to close the GDFS area.">.</value>
+ <value number="5411" name="A2_E_GDFS_OPEN" fatal="true" short="Failed to open the GDFS area.">.</value>
+ <value number="5412" name="A2_E_GDFS_INVALID_UNIT_SIZE" fatal="true" short="Invalid GDFS UNIT size(size=0).">.</value>
+ <value number="5413" name="A2_E_GDFS_WRITE_TO_UNIT_FAILED" fatal="true" short="Failed to write to the specified unit.">.</value>
+ <value number="5414" name="A2_E_GDFS_FAILED_TO_READ_FROM_UNIT" fatal="true" short="Failed to read from the specified unit.">.</value>
+ <value number="5415" name="A2_E_GDFS_EMPTY" fatal="true" short="Failed read access on an empty GDFS.">.</value>
+
+ <value number="70535" name="A2_E_GENERAL_FATAL_ERROR" fatal="true"></value>
+
+ <value number="80009" name="E_DUMMY_CODE" fatal="true">Request for recovery condition for condition that is not changed.</value>
+ </status>
+</commandspec>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/errorcode_h.xsl b/lcmodule/source/cnh1606344_ldr_communication_module/config/errorcode_h.xsl
new file mode 100644
index 0000000..a0e4136
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/errorcode_h.xsl
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
+
+<output method="text"/>
+<strip-space elements="*"/>
+<param name="target"/>
+
+<template match="/commandspec">/* $Copyright$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _ERRORCODE_H
+#define _ERRORCODE_H
+
+
+/**
+ * @addtogroup ldr_LCM
+ * Error codes for internal loader commands.
+ * @{
+ */
+
+/*************************************************************************
+* Includes
+*************************************************************************/
+#include &quot;t_basicdefinitions.h&quot;
+
+#define A2_ERROR_CODES_OFFSET 5000
+/**
+ * Internal loader command error codes. Possible range 0x0000 - 0x0FFE (4094).
+ */
+
+
+/**
+ * Table for Error groups range
+ *
+ * General Fatal 0-50
+ * General non-fatal 51-99
+ *
+ * IO Fatal 100-150
+ * IO non-fatal 151-199
+ *
+ * Communication Fatal 200-250
+ * Communication non-fatal 251-299
+ *
+ * Signature Fatal 300-350
+ * Signature non-fatal 351-399
+ *
+ * Authentication Fatal 400-450
+ * Authentication non-fatal 451-499
+ *
+ * COPS General Fatal 500-550
+ * COPS General non-fatal 551-599
+ *
+ * System Fatal 600-650
+ * System non-fatal 651-699
+ *
+ * Flash Fatal 700-750
+ * Flash non-fatal 751-799
+ *
+ * Parameters Fatal 800-850
+ * Parameters non-fatal 851-899
+ *
+ * File management Fatal 900-950
+ * File management non-fatal 951-999
+ *
+ * Command Auditing and execution Fatal 1000-1050
+ * Command Auditing and execution non-fatal 1051-1099
+ *
+ * Emulation Fatal 1100-1150
+ * Emulation non-fatal 1151-1199
+ *
+ * Timers Fatal 1200-1250
+ * Timers non-fatal 1251-1299
+ *
+ * CABS Fatal 1300-1350
+ * CABS non-fatal 1351-1399
+ *
+ * GDFS Fatal 1400-1450
+ * GDFS non-fatal 1451-1499
+ *
+ * Antirollback Fatal 1500-1550
+ * Antirollback non-fatal 1551-1599
+ *
+ * Memory and Boot Fatal 1600-1650
+ * Memory and Boot non-fatal 1651-1699
+ *
+ * @todo this should be removed and error codes should be remaped.
+ * The same applies to Emulator errors.
+ *
+ * Job Handler Fatal 1700-1750
+ * Job Handler non-fatal 1751-1799
+ *
+ * Emulator Fatal 1800-1850
+ * Emulator non-fatal 1851-1899
+ *
+ * Loader utilities Fatal 1900-1950
+ * Loader utilities non-fatal 1951-1999
+ */
+
+<apply-templates select="status"/>
+#endif /* _ERRORCODE_H */
+</template>
+
+<template match="status">
+typedef enum {
+<apply-templates select="value"/>} ErrorCode_e;
+</template>
+
+<template match="value">
+ <text> </text><value-of select="@name"/> = <value-of select="@number"/>, /**&lt; <value-of select="@short"/> */
+</template>
+
+<template match="value[last()]">
+ <text> </text><value-of select="@name"/> = <value-of select="@number"/> /**&lt; <value-of select="@short"/> */
+</template>
+
+</stylesheet>
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/include/r_a2_family.h b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_a2_family.h
new file mode 100644
index 0000000..614aaa9
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_a2_family.h
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _INCLUSION_GUARD_R_A2_FAMILY_H_
+#define _INCLUSION_GUARD_R_A2_FAMILY_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup a2_family
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_a2_family.h"
+#include "error_codes.h"
+#include "t_communication_service.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+#define A2_TRANSPORT(x) (&((A2_FamilyContext_t *) (x)->FamilyContext_p)->Transport)
+#define A2_NETWORK(x) (&((A2_FamilyContext_t *) (x)->FamilyContext_p)->Network)
+#define A2_SPEEDFLASH(x) (((volatile A2_SpeedflashContext_t*)&((A2_FamilyContext_t *) (x)->FamilyContext_p)->Speedflash))
+
+/**
+ * A2 family protocols initialization.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e A2_Family_Init(Communication_t *Communication_p);
+
+/**
+ * A2 family protocols shutdown.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e A2_Family_Shutdown(Communication_t *Communication_p);
+
+/*
+ * A2 Cancel Receiver.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] PacketsBeforeTransferStop Number of packets that will be transmited before stopping the transmition.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e A2_CancelReceiver(Communication_t *Communication_p, uint8 PacketsBeforeTransferStop);
+
+/** @} */
+/** @} */
+#endif //_INCLUSION_GUARD_R_A2_FAMILY_H_
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
new file mode 100644
index 0000000..5b23f2d
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_communication_service.h
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _INCLUSION_GUARD_R_COMMUNICATION_SERVICE_H_
+#define _INCLUSION_GUARD_R_COMMUNICATION_SERVICE_H_
+/**
+ * @addtogroup ldr_communication_module Loader communication module
+ * The Loader Communication module is introduced with the intention of sharing
+ * code and bridging the gap between Loaders and the tools using Loaders.
+ * By having a module that exposes an interface to both Loaders and tools and
+ * this interface are generated from a common specification, we can more easily
+ * change and version control the interface.
+ *
+ * @{
+ *
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "c_system.h"
+#include "error_codes.h"
+#include "t_communication_service.h"
+
+#if (defined(WIN32) || defined(__CYGWIN__))
+
+#ifdef LCM_EXPORTS
+#define LCM_API __declspec(dllexport) // export DLL information
+#else //LCM_EXPORTS
+#define LCM_API __declspec(dllimport) // import DLL information
+#endif // LCM_EXPORTS
+
+#elif defined(__linux__)
+
+#ifdef LCM_EXPORTS
+#define LCM_API __attribute__((visibility("default")))
+#else //LCM_EXPORTS
+#define LCM_API
+#endif // LCM_EXPORTS
+
+#elif defined(CFG_ENABLE_LOADER_TYPE)
+
+#define LCM_API
+
+#endif // WIN32
+
+#define QUEUE(x,y) x->Functions_p->QueueFunctions_p->y
+#define TIMER(x,y) x->Functions_p->TimerFunctions_p->y
+#define BUFFER(x,y) x->Functions_p->BufferFunctions_p->y
+#define OBJECT_BUFFER(x) x->Functions_p->BufferFunctions_p->Object_p
+#define OBJECT_TIMER(x) x->Functions_p->TimerFunctions_p->Object_p
+#define OBJECT_QUEUE(x) x->Functions_p->QueueFunctions_p->Object_p
+#define OBJECT_HASH(x) x->HashDevice_p->Object_p
+#define OBJECT_CEH_CALL(x) x->Object_p
+
+extern Communication_t* GlobalCommunication_p;
+
+extern Communication_t DebugCommunication;
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif // #ifdef __cplusplus
+ /**
+ * Initialize an instance of the communication module.
+ *
+ * Given the initial family, already initialized hash device descriptor
+ * and communication device descriptor, a new instance of the
+ * communication module is created and bound to use the provided devices.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] Family Initial protocol family.
+ * @param [in] HashDevice_p The device to use for checksum
+ * calculations and verifications.
+ * @param [in] *CommunicationDevice_p The device to use for network
+ * transmission.
+ * @param [in] CommandCallback_p Collback function for command handling.
+ *
+ * @retval E_SUCCESS If the module instance is successfully
+ * initialized. A protocol family dependant error
+ * code otherwise.
+ */
+ LCM_API ErrorCode_e Do_Communication_Initialize(void *Object_p, Communication_t **Communication_pp, Family_t Family, HashDevice_t *HashDevice_p, CommunicationDevice_t *CommunicationDevice_p, Do_CEH_Call_t CommandCallback_p, BuffersInterface_t *Buffers_p, TimersInterface_t *Timers_p, QueueInterface_t *Queue_p);
+
+ /**
+ * Shutdown an instance of the communication module.
+ *
+ * Shutdown the initialized protocol family, cancel current transmission and
+ * receiving data thru the communication device and shutdown the transport and
+ * network layer.
+ *
+ * @param [in,out] Communication_pp Communication module context.
+ *
+ * @retval E_SUCCESS If the module instance is successfully
+ * shut down. A protocol family dependant error
+ * code otherwise.
+ */
+ LCM_API ErrorCode_e Do_Communication_Shutdown(Communication_t **Communication_pp);
+
+ /**
+ * Poll the network for inbound packets.
+ *
+ * When a packet is received it is put on the inbound queue. This
+ * function should be called whenever there is time to handle a new
+ * packet. It passes all the elements in the queue to the family
+ * specific polling function, one by one.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ *
+ * @retval E_SUCCESS If all packets are successfully handled. A
+ * protocol family dependant error code otherwise.
+ */
+ LCM_API ErrorCode_e Do_Communication_Poll(Communication_t *Communication_p);
+
+ /**
+ * Change the current protocol family.
+ *
+ * Shuts down the old protocol family and initializes the new one.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Family New protocol family identifier.
+ * @param [in] CEHCallback Callback that will handle the commands.
+ *
+ * @retval E_SUCCESS If the family is successfully changed. A
+ * protocol family dependant error code otherwise.
+ */
+ LCM_API ErrorCode_e Do_Communication_SetFamily(Communication_t *Communication_p, Family_t Family, Do_CEH_Call_t CEHCallback);
+
+ /**
+ * Function for sending packet.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] InputData_p Pointer to the data for tranmission.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_ALLOCATE_COMM_BUFFER Failed to allocate communication
+ * buffer.
+ */
+ LCM_API ErrorCode_e Do_Communication_Send(Communication_t *Communication_p, void *InputData_p);
+
+ /**
+ * Function for setting the timeouts in the protocols.
+ *
+ * Timeouts that should be set depend of the protocol family. Some protocol
+ * family do not have timeouts.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] TimeoutData_p Pointer to the data with all timeouts.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ LCM_API ErrorCode_e Do_Communication_SetProtocolTimeouts(Communication_t *Communication_p, void *TimeoutData_p);
+
+ /**
+ * Function for getting the timeouts in the protocols.
+ *
+ * Timeouts that should be get depend of the protocol family. Some protocol
+ * family do not have timeouts.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [out] TimeoutData_p Return data with all timeouts.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ LCM_API ErrorCode_e Do_Communication_GetProtocolTimeouts(Communication_t *Communication_p, void *TimeoutData_p);
+
+ /**
+ * Function for getting the communication device for the given LCM instance.
+ *
+ * If communication is Singleton the function can be called with NULL
+ * pointer for Communication_p.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [out] CommunicationDevice_pp Pointer to the initialized communication
+ * device for the given LCM context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMTERS In case when communicaiton is not Singleton
+ * and Communication_p is NULL pointer.
+ */
+ LCM_API ErrorCode_e Do_Communication_GetCommunicationDevice(Communication_t *Communication_p, CommunicationDevice_t** CommunicationDevice_pp);
+
+ /**
+ * Function for setting the communication device for the given LCM instance.
+ *
+ * If communication is Singleton the function can be called with NULL
+ * pointer for Communication_p.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [out] CommunicationDevice_p Pointer to the initialized communication
+ * device to be set for the given LCM context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMTERS In case when communicaiton is not Singleton
+ * and Communication_p is NULL pointer.
+ */
+ LCM_API ErrorCode_e Do_Communication_SetCommunicationDevice(Communication_t *Communication_p, CommunicationDevice_t* CommunicationDevice_p);
+
+ /*
+ * Cancek Receiving new packets
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] PacketsBeforeReceiverStop Number of packets to be send before stopping the receiver.
+ *
+ * @retval E_SUCCESS If all packets are successfully handled. A
+ * protocol family dependant error code otherwise.
+ */
+ LCM_API ErrorCode_e Do_Communication_Cancel_Receiver(Communication_t *Communication_p, uint8 PacketsBeforeReceiverStop);
+
+#ifdef __cplusplus
+};
+#endif // #ifdef __cplusplus
+
+/**
+ *
+ */
+void Do_CommunicationInternalErrorHandler(const ErrorCode_e IntError);
+
+/** @} */
+#endif // _INCLUSION_GUARD_R_COMMUNICATION_SERVICE_H_
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/include/r_measurement_tool.h b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_measurement_tool.h
new file mode 100644
index 0000000..25884b8
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_measurement_tool.h
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef R_MEASUREMENT_TOOL_H_
+#define R_MEASUREMENT_TOOL_H_
+/**
+ * @addtogroup ldr_communication_module
+ * @{
+ * @addtogroup measurement_serv Measurement services
+ * Measurement functions is tool for performance measurement. Can be used
+ * for flashing performance, communication performance and i.t.c.
+ *
+ * @{
+ *
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "t_basicdefinitions.h"
+#include "t_measurement_tool.h"
+#include "error_codes.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+#define MP(x, y, z) Do_Measurement_AddMeasurementData( x, Do_Timer_ReadTime(NULL,x->TimerId), y, z);
+#define MFINISH(x) Do_Measurement_CompleteResults( x);
+/**
+ * Initialization of measurement module.
+ *
+ * @param [in] MeasurementData_p Pointer to curren measurement data block.
+ *
+ * @retval E_SUCCESS If initialization is done.
+ */
+ErrorCode_e Do_Measurment_Init(Measurement_t *MeasurementData_p);
+
+/**
+ * This function create general measurement data block.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] MeasurementData_pp Pointer to the created measurement data block.
+ * @param [in] Type Type of measurement.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_ALLOCATE_FAILED If failed to allocate session measurement
+ * data block.
+ */
+ErrorCode_e Do_Measurement_CreateMeasurementData(Communication_t *Communication_p, Measurement_t **MeasurementData_pp, uint32 Type);
+
+/**
+ * This function collect all data from measurement buffer.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in, out] Data_pp Point to pointer that should be initialized to point
+ * on outgoing buffer.
+ *
+ * @return Number of characters successfully readied from measurement
+ * buffer.
+ */
+uint32 Do_Measurement_GetMeasurementData(Communication_t *Communication_p, uint8 **Data_pp);
+
+/**
+ * This function create measurement data block for bulk session.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] SessionMeasurement_pp Pointer to the created session
+ * measurement data block.
+ * @param [in] PreviousSessionDataBlock_p Pointer to the previouse session
+ * measurement data block.
+ * @param [in] ChunkNr Number of chunks in this session.
+ * @param [in] Session Session number.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_ALLOCATE_FAILED If failed to allocate session measurement
+ * data block.
+ */
+ErrorCode_e Do_Measurement_CreateSessionMeasurementData(Communication_t *Communication_p,
+ SessionMeasurement_t **SessionMeasurement_pp,
+ SessionMeasurement_t *PreviousSessionDataBlock_p,
+ uint32 ChunkNr, uint32 Session);
+
+/**
+ * This function create measurement data block for measure chunks transfer.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] ChunkMeasurement_pp Pointer to the created chunk
+ * measurement data block.
+ * @param [in] PreviousChunkDataBlock_p Pointer to the previouse chunk
+ * measurement data block.
+ * @param [in] ChunkId Chunk ID.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_ALLOCATE_FAILED If failed to allocate session measurement
+ * data block.
+ */
+ErrorCode_e Do_Measurement_CreateChunkMeasurementData(Communication_t *Communication_p,
+ ChunkMeasurement_t **ChunkMeasurement_pp,
+ ChunkMeasurement_t *PreviousChunkDataBlock_p,
+ uint32 ChunkId);
+/**
+ * This function destroy measurement data block for bulk session.
+ *
+ * @param [in] MeasurementData_pp Pointer to the measurement data block.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_Measurement_DestroySessionMeasurementData(SessionMeasurement_t **MeasurementData_pp);
+
+/**
+ * This function destroy measurement data block for bulk chunks.
+ *
+ * @param [in] MeasurementData_pp Pointer to the main measurement data block.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_Measurement_DestroyChunkMeasurementData(ChunkMeasurement_t **MeasurementData_pp);
+
+/**
+ * This function destroy general measurement data block.
+ *
+ * @param [in] MeasurementData_pp Pointer to the main measurement data block.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_Measurement_DestroyMeasurementData(Measurement_t **MeasurementData_pp);
+
+/**
+ * This function make zero reference for all measured data.
+ *
+ * @param [in] MeasurementData_p Pointer to the main measurement data block.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_Measurement_ZeroReferenceMeasurementData(Measurement_t *MeasurementData_p);
+
+/**
+ * This function add measured time in specified measurement data block.
+ *
+ * @param [in] MeasurementData_p Pointer to the main measurement data block.
+ * @param [in] Time Measured time.
+ * @param [in] ChunkID Chunk ID
+ * @param [in] Parameter Parameter in the measurement data block.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_Measurement_AddMeasurementData(Measurement_t *MeasurementData_p, uint32 Time, uint32 ChunkID, MeasurementParameter_t Parameter);
+
+/**
+ *
+ */
+ErrorCode_e Do_Measurement_CompleteResults(Measurement_t *Measurement_p);
+
+/** @} */
+/** @} */
+#endif /* R_MEASUREMENT_TOOL_H_ */
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/include/r_protrom_family.h b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_protrom_family.h
new file mode 100644
index 0000000..a5498c6
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_protrom_family.h
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _INCLUSION_GUARD_R_PROTROM_FAMILY_H_
+#define _INCLUSION_GUARD_R_PROTROM_FAMILY_H_
+/**
+ * @addtogroup ldr_communication_module
+ * @{
+ * @addtogroup protrom_family Protrom Family
+ * The PROTROM family include only one protocol PROTROM used for
+ * communication between the ROM code and PC tool. This module include
+ * protrom transport layer and protrom network layer for handling protrom
+ * protocol.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_protrom_protocol.h"
+#include "error_codes.h"
+#include "t_communication_service.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+#define PROTROM_TRANSPORT(x) (&((Protrom_FamilyContext_t *) (x)->FamilyContext_p)->Transport)
+#define PROTROM_NETWORK(x) (&((Protrom_FamilyContext_t *) (x)->FamilyContext_p)->Network)
+
+/**
+ * Protrom family protocols initialization.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e Protrom_Family_Init(Communication_t *Communication_p);
+
+/**
+ * Protrom family protocols sutdown.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e Protrom_Family_Shutdown(Communication_t *Communication_p);
+
+/*
+ * Protrom Cancel Transmition.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] PacketsBeforeTransferStop Number of packets that will be transmited before stopping the transmition.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e Protrom_CancelReceiver(Communication_t *Communication_p, uint8 PacketsBeforeTransferStop);
+/** @} */
+/** @} */
+#endif //_INCLUSION_GUARD_R_PROTROM_FAMILY_H_
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/include/r_r15_family.h b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_r15_family.h
new file mode 100644
index 0000000..7e6d2f6
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_r15_family.h
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _INCLUSION_GUARD_R_R15_FAMILY_H_
+#define _INCLUSION_GUARD_R_R15_FAMILY_H_
+/**
+ * @addtogroup ldr_communication_module
+ * @{
+ * @addtogroup R15_family
+ * The R15 protocol family include two protocols COMMAND and BULK. Command
+ * protocol is used for sending commands between the ME and PC tool in both
+ * direction. This module include R15 transport layer and R15 network layer
+ * for handling R15 prtocols.
+ *
+ * @{
+ *
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_r15_family.h"
+#include "error_codes.h"
+#include "t_communication_service.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+#define R15_TRANSPORT(x) (&((R15_FamilyContext_t *) (x)->FamilyContext_p)->Transport)
+#define R15_NETWORK(x) (&((R15_FamilyContext_t *) (x)->FamilyContext_p)->Network)
+#define R15_TIMEOUTS(x) (&((R15_FamilyContext_t *) (x)->FamilyContext_p)->Timeouts)
+
+/**
+ * R15 family protocols initialization.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e R15_Family_Init(Communication_t *Communication_p);
+
+/**
+ * R15 family protocols sutdown.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e R15_Family_Shutdown(Communication_t *Communication_p);
+
+/*
+ * R15 Cancel Transmition.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] PacketsBeforeTransferStop Number of packets that will be transmited before stopping the transmition.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e R15_CancelReceiver(Communication_t *Communication_p, uint8 PacketsBeforeTransferStop);
+/** @} */
+/** @} */
+#endif // _INCLUSION_GUARD_R_R15_FAMILY_H_
+
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/include/r_z_family.h b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_z_family.h
new file mode 100644
index 0000000..8bb577f
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/include/r_z_family.h
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef INCLUSION_GUARD_R_Z_FAMILY_H
+#define INCLUSION_GUARD_R_Z_FAMILY_H
+/**
+ * @addtogroup ldr_communication_module
+ * @{
+ * @addtogroup Z_family Z protocol family
+ * The Z family include only one protocol, Z protocol, used for
+ * communication between the ROM code and PC tool. This module include
+ * Z transport layer and Z network layer for handling Z protocol. The Z
+ * network layer receive and send byte by byte because the format of the
+ * Z protocol do not have one strict format.
+ *
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_z_protocol.h"
+#include "error_codes.h"
+#include "t_communication_service.h"
+#include "t_z_network.h"
+
+/*******************************************************************************
+ * Declaration of functions
+ ******************************************************************************/
+
+#define Z_TRANSPORT(x) (&((Z_FamilyContext_t *) (x)->FamilyContext_p)->Transport)
+#define Z_NETWORK(x) (&((Z_FamilyContext_t *) (x)->FamilyContext_p)->Network)
+
+/**
+ * Z family protocols initialization.
+ *
+ * Z transport and Z network layer will be initialized.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e Z_Family_Init(Communication_t *Communication_p);
+
+/**
+ * Z family protocols shutdown.
+ *
+ * Z transport and Z network layer will be shutdown.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e Z_Family_Shutdown(Communication_t *Communication_p);
+
+/*
+ * Z family Cancel Transmition.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] PacketsBeforeTransferStop Number of packets that will be transmited before stopping the transmition.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e Z_CancelReceiver(Communication_t *Communication_p, uint8 PacketsBeforeTransferStop);
+
+/** @} */
+/** @} */
+#endif //INCLUSION_GUARD_R_Z_FAMILY_H
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/include/t_a2_family.h b/lcmodule/source/cnh1606344_ldr_communication_module/include/t_a2_family.h
new file mode 100644
index 0000000..05351d6
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/include/t_a2_family.h
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _INCLUSION_GUARD_T_A2_FAMILY_H_
+#define _INCLUSION_GUARD_T_A2_FAMILY_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup A2_family
+ * @{
+ *
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "t_a2_transport.h"
+#include "t_a2_network.h"
+#include "t_a2_speedflash.h"
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+/** Structure with timeouts for A2 protocol. */
+typedef struct {
+ uint32 TACK; /**< Time for network packet acknowledge. */
+} A2_Timeouts_t;
+
+/**
+ * A2 family context.
+ * Context structures for A2 transport layer and network layer.
+ */
+typedef struct {
+ A2_TransportContext_t Transport;
+ A2_NetworkContext_t Network;
+ A2_SpeedflashContext_t Speedflash;
+ A2_Timeouts_t Timeouts;
+} A2_FamilyContext_t;
+
+
+/** @} */
+/** @} */
+#endif // _INCLUSION_GUARD_T_A2_FAMILY_H_
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/include/t_communication_service.h b/lcmodule/source/cnh1606344_ldr_communication_module/include/t_communication_service.h
new file mode 100644
index 0000000..3b686cc
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/include/t_communication_service.h
@@ -0,0 +1,346 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _INCLUSION_GUARD_T_COMMUNICATION_SERVICE_H_
+#define _INCLUSION_GUARD_T_COMMUNICATION_SERVICE_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ *
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "c_system.h"
+#include "t_basicdefinitions.h"
+#include "error_codes.h"
+#include "t_security_algorithms.h"
+#include "t_command_protocol.h"
+#include "t_queue.h"
+#include "t_time_utilities.h"
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+#ifdef WIN32
+#include <windows.h>
+#endif
+#endif
+
+
+/*******************************************************************************
+ * Types, constants and external variables
+ ******************************************************************************/
+/* Defined protocol families */
+typedef enum {
+ R15_FAMILY = 0, /*< R15 protocol family. */
+ A2_FAMILY = 1, /*< A2 protocol family. */
+#ifndef CFG_ENABLE_LOADER_TYPE
+ TI_FAMILY = 2, /*< TI protocol family. */
+ PROTROM_FAMILY = 3, /*< PROTROM protocol family. */
+ Z_FAMILY = 4 /*< Z protocol family. */
+#endif
+} Family_t;
+
+typedef void (*CommunicationCallback_t)(const void *Data_p, const uint32 Length, void *Param_p);
+typedef void (*HashCallback_t)(void *Data_p, const uint32 Length, uint8 *Hash_p, void *Param_p);
+typedef boolean(*DeviceRead_fn)(void *Data_p, uint32 Length, CommunicationCallback_t Callback_fn, void *Param_p);
+typedef ErrorCode_e(*DeviceWrite_fn)(void *Data_p, uint32 Length, CommunicationCallback_t Callback_fn, void *Param_p);
+typedef ErrorCode_e(*DeviceCancel_fn)(void *Param_p);
+typedef void (*HashDeviceCancel_fn)(void *Object_p, void **Param_p);
+typedef void (*DeviceCalculate_fn)(void *Object_p, HashType_e Type, void *Data_p, const uint32 Length, uint8 *Hash_p, HashCallback_t Callback_fn, void *Param_p);
+
+/** definition of Buffer interface functions */
+typedef ErrorCode_e(*BuffersInit_t)(void *Object_p);
+typedef void *(*BufferAllocate_t)(void *Object_p, int BufferSize);
+typedef ErrorCode_e(*BufferRelease_t)(void *Object_p, void *Buffer_p, int BufferSize);
+typedef uint32(*BuffersAvailable_t)(void *Object_p, int BufferSize);
+typedef void (*BuffersDeinit_t)(void *Object_p);
+
+
+/** definition of Timer interface functions */
+typedef ErrorCode_e(*TimersInit_t)(void *Object_p, uint32 Timers);
+typedef uint32(*TimerGet_t)(void *Object_p, Timer_t *Timer_p);
+typedef ErrorCode_e(*TimerRelease_t)(void *Object_p, uint32 TimerKey);
+typedef uint32(*ReadTime_t)(void *Object_p, uint32 TimerKey);
+typedef uint32(*GetSystemTime_t)(void *Object_p);
+
+/** definition of Queue interface functions */
+typedef void (*FifoCreate_t)(void *Object_p, void **const Queue_pp, const uint32 MaxLength, void (*DestroyElement)(void *Element_p));
+typedef void (*FifoDestroy_t)(void *Object_p, void **const Queue_pp);
+typedef ErrorCode_e(*FifoEnqueue_t)(void *Object_p, void *const Queue_p, void *const Value_p);
+typedef void *(*FifoDequeue_t)(void *Object_p, void *const Queue_p);
+typedef QueueCallback_fn(*Fifo_SetCallback_t)(void *Object_p, void *const Queue_p,
+ const QueueCallbackType_e Type,
+ const QueueCallback_fn Callback,
+ void *const Param_p);
+typedef boolean(*Fifo_IsEmpty_t)(void *Object_p, const void *const Queue_p);
+typedef boolean(*Fifo_IsMember_t)(void *Object_p, const void *const Queue_p, void *Value_p, boolean(*Match)(void *Value1_p, void *Value2_p));
+typedef int (*Fifo_GetNrOfElements_t)(void *Object_p, const void *const Queue_p);
+
+typedef void (*RFifoCreate_t)(void *Object_p, void **const Queue_pp, const uint32 MaxLength, void (*DestroyElement)(void *Element_p));
+typedef void (*RFifoDestroy_t)(void *Object_p, void **const Queue_pp);
+typedef ErrorCode_e(*RFifoEnqueue_t)(void *Object_p, void *const Queue_p, void *const Value_p);
+typedef void *(*RFifoDequeue_t)(void *Object_p, void *const Queue_p);
+typedef QueueCallback_fn(*RFifo_SetCallback_t)(void *Object_p, void *const Queue_p,
+ const QueueCallbackType_e Type,
+ const QueueCallback_fn Callback,
+ void *const Param_p);
+typedef boolean(*RFifo_IsEmpty_t)(void *Object_p, const void *const Queue_p);
+typedef boolean(*RFifo_IsMember_t)(void *Object_p, const void *const Queue_p, void *Value_p, boolean(*Match)(void *Value1_p, void *Value2_p));
+typedef int (*RFifo_GetNrOfElements_t)(void *Object_p, const void *const Queue_p);
+
+typedef ErrorCode_e(*Do_CEH_Call_t)(void *Object_p, CommandData_t *CmdData_p);
+
+
+/** Structure with pointers to buffer interface functions */
+typedef struct {
+ BuffersInit_t BuffersInit_Fn; /**< Pointer to function for Buffers
+ initialization. */
+ BufferAllocate_t BufferAllocate_Fn; /**< Pointer to function for Buffer
+ allocation. */
+ BufferRelease_t BufferRelease_Fn; /**< Pointer to function for Buffer
+ releasing.*/
+ BuffersAvailable_t BuffersAvailable_Fn; /**< Pointer to function for check
+ for available buffers with
+ specified size of buffers. */
+ BuffersDeinit_t BuffersDeinit_Fn; /**< Pointer to function for Buffers
+ de-initialization. */
+ void *Object_p; /**< Pointer for instancing. It is
+ used in the PC application, but
+ in the loaders is always NULL */
+} BuffersInterface_t;
+
+
+/** Structure with pointers to timer interface functions */
+typedef struct {
+ TimersInit_t TimersInit_Fn; /**< Pointer to function for Timers
+ initialization. */
+ TimerGet_t TimerGet_Fn; /**< Pointer to function for creating and
+ starting timer. */
+ TimerRelease_t TimerRelease_Fn; /**< Pointer to function for removing
+ defined timer. */
+ ReadTime_t ReadTime_Fn; /**< Pointer to function for read time from
+ specified timer. */
+ GetSystemTime_t GetSystemTime_Fn; /**< Pointer to function for read curent
+ sytem time. */
+ void *Object_p; /**< Pointer for instancing. It is used in
+ the PC application, but in the loaders
+ is always NULL */
+} TimersInterface_t;
+
+/** Structure with pointers to queue interface functions */
+typedef struct {
+ FifoCreate_t FifoCreate_Fn; /**< Pointer to function
+ for Fifo creating.*/
+ FifoDestroy_t FifoDestroy_Fn; /**< Pointer to function
+ for Fifo destroying.*/
+ FifoEnqueue_t FifoEnqueue_Fn; /**< Pointer to function
+ for enqueue packet in
+ the fifo. */
+ FifoDequeue_t FifoDequeue_Fn; /**< Pointer to function
+ for dequeue packet
+ from the fifo. */
+ Fifo_SetCallback_t Fifo_SetCallback_Fn; /**< Pointer to function
+ for registers an event
+ listener for the
+ specified queue.*/
+ Fifo_IsEmpty_t Fifo_IsEmpty_Fn; /**< Pointer to function
+ for check, is Fifo
+ empty.*/
+ Fifo_IsMember_t Fifo_IsMember_Fn; /**< Pointer to function
+ for Checks if the
+ provided element is
+ member of the fifo*/
+ Fifo_GetNrOfElements_t Fifo_GetNrOfElements_Fn; /**< Pointer to function
+ for reading the number
+ of elements in the
+ Fifo.*/
+
+ RFifoCreate_t RFifoCreate_Fn; /**< Pointer to function
+ for Fifo creating.
+ First all interrupts
+ are disabled,
+ function executed and
+ then all interrupt
+ enabled. */
+ RFifoDestroy_t RFifoDestroy_Fn; /**< Pointer to function
+ for Fifo destroing.
+ First all interrupts
+ are disabled,
+ function executed and
+ then all interrupt
+ enabled. */
+ RFifoEnqueue_t RFifoEnqueue_Fn; /**< Pointer to function
+ for enqueue packet in
+ the fifo. First all
+ interrupts are
+ disabled, function
+ executed and then all
+ interrupt enabled. */
+ RFifoDequeue_t RFifoDequeue_Fn; /**< Pointer to function
+ for dequeue packet
+ from the fifo. First
+ all interrupts are
+ disabled, function
+ executed and then all
+ interrupt enabled. */
+ RFifo_SetCallback_t RFifo_SetCallback_Fn; /**< Pointer to function
+ for setting two
+ callback functions
+ used by the FIFO.
+ First all interrupts
+ are disabled,
+ function executed and
+ then all interrupt
+ enabled. */
+ RFifo_IsEmpty_t RFifo_IsEmpty_Fn; /**< Pointer to function
+ for for check, is Fifo
+ empty. First all
+ interrupts are
+ disabled, function
+ executed and then all
+ interrupt enabled. */
+ RFifo_IsMember_t RFifo_IsMember_Fn; /**< Pointer to function
+ for checks if the
+ provided element is
+ member of the fifo.
+ First all interrupts
+ are disabled,
+ function executed and
+ then all interrupt
+ enabled. */
+ RFifo_GetNrOfElements_t RFifo_GetNrOfElements_Fn; /**< Pointer to function
+ for reading the number
+ of elements in the
+ Fifo. First all
+ interrupts are
+ disabled, function
+ executed and then all
+ interrupt enabled. */
+ void *Object_p; /**<Pointer for instancing.
+ It is used in the PC
+ application, but in the
+ loaders is always NULL.*/
+} QueueInterface_t;
+
+/**
+ * Interface structures for buffers, timers and queue.
+ * Structure contain all interface functions for buffers, timers and
+ * queue manipulating.
+ */
+typedef struct {
+ BuffersInterface_t *BufferFunctions_p; /**< Pointer to buffer interface
+ structure. */
+ QueueInterface_t *QueueFunctions_p; /**< Pointer to queue interface
+ structure. */
+ TimersInterface_t *TimerFunctions_p; /**< Pointer to timers interface
+ structure. */
+} FunctionInterface_t;
+
+/**
+ * Interface structure for communication device.
+ * Structure contain all functions for communication device manipulating.
+ */
+typedef struct {
+ DeviceRead_fn Read; /**< Pointer to function for read data from
+ communication device. */
+ DeviceWrite_fn Write; /**< Pointer to function for write data thru the
+ communication device. */
+ DeviceCancel_fn Cancel; /**< Pointer to function for caneling current
+ communcation with communiation device. */
+ void *Context_p; /**< Pointer to Device description data. */
+} CommunicationDevice_t;
+
+/**
+ * Interface structure for HASH device.
+ * Structure contain all functions for HASH device manipulating.
+ */
+typedef struct {
+ DeviceCalculate_fn Calculate; /**< Pointer to function for calculation. */
+ HashDeviceCancel_fn Cancel; /**< Pointer to function for cancel of
+ calculation. */
+ void *Object_p; /**< Pointer for instancing. It is used in the
+ PC application, but in the loaders is
+ always NULL.*/
+} HashDevice_t;
+
+/**
+ * Holds information about a command that is placed (or will be placed) in
+ * the command execution queue.
+ */
+typedef struct ExecutionContext_s {
+ void *Command_p; /**< Pointer to command register structure
+ containing information for initialization
+ and execution of the command.*/
+ void *LocalState_p; /**< If needed holds information internal to the
+ command, else it is NULL.*/
+ boolean Running; /**< Indicates the state of the command that is
+ registered in the Command Execution Service.*/
+ CommandData_t Received; /**< Holds data for the received command. */
+ Result_t Result; /**< Pointer to structure that holds command
+ status and command data, including payload
+ or output data.*/
+ uint32 Progress; /**< Command completed in percent. */
+} ExecutionContext_t;
+
+
+/** Communication context.*/
+typedef struct {
+ void *Inbound_p; /**< Pointer to structure for
+ handling incomming
+ packets.*/
+ void *Outbound_p; /**< Pointer to structure for
+ handling outgoing
+ packets.*/
+ HashDevice_t *HashDevice_p; /**< Pointer to Hash device
+ descriptor. */
+ CommunicationDevice_t *CommunicationDevice_p; /**< Pointer to Communication
+ device descriptor. */
+ struct FamilyDescriptor_s *Family_p; /**< Pointer to interface
+ structure for protocol
+ family. */
+ void *FamilyContext_p; /**< Pointer to current
+ protocol family context.*/
+ uint8 *BackupCommBuffer_p; /**< Pointer to backup
+ buffer.*/
+ uint32 BackupCommBufferSize; /**< Size of the backup
+ buffer.*/
+ FunctionInterface_t *Functions_p; /**< Pointer to interface
+ functions for buffers,
+ timers and queue.*/
+ Do_CEH_Call_t Do_CEH_Call_Fn; /**< Pointer to calback
+ function for handling
+ commands received thru
+ the LCM.*/
+ void *Object_p; /**< Pointer for instancing.
+ It is used in the PC
+ application, but in the
+ loaders is always NULL.*/
+ HashType_e CurrentFamilyHash; /**< Hashing algorithm that
+ is used by the family
+ which is active at the
+ moment. */
+} Communication_t;
+
+/** Structure for initialization and manipulation of protocol family */
+typedef struct FamilyDescriptor_s {
+ /**< Pointer to Interface function for protocol family initialization. */
+ ErrorCode_e(*FamilyInit_fn)(Communication_t *Communication_p);
+ /**< Pointer to Interface function for protocol family de-initialization. */
+ ErrorCode_e(*FamilyShutdown_fn)(Communication_t *Communication_p);
+ /**< Pointer to Pooling function in curren protocol family. */
+ ErrorCode_e(*Process_fn)(Communication_t *Communication_p);
+ /**< Pointer to function for sending packets.*/
+ ErrorCode_e(*Send_fn)(Communication_t *Communication_p, void *InputData_p);
+ /**< Pointer to function for setting communication timeouts for current protocol family. */
+ ErrorCode_e(*SetProtocolTimeouts_fn)(Communication_t *Communication_p, void *TimeoutData_p);
+ /**< Pointer to function for getting communication timeouts from current protocol family. */
+ ErrorCode_e(*GetProtocolTimeouts_fn)(Communication_t *Communication_p, void *TimeoutData_p);
+ /**< Pointer to function for stopping the transmition pool after sending the specified number of packets. */
+ ErrorCode_e(*CancelReceiver_fn)(Communication_t *Communication_p, uint8 PacketsBeforeTransferStop);
+} FamilyDescriptor_t;
+
+/** @} */
+#endif // _INCLUSION_GUARD_T_COMMUNICATION_SERVICE_H_
+
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/include/t_measurement_tool.h b/lcmodule/source/cnh1606344_ldr_communication_module/include/t_measurement_tool.h
new file mode 100644
index 0000000..bdc2022
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/include/t_measurement_tool.h
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef T_MEASUREMENT_TOOL_H_
+#define T_MEASUREMENT_TOOL_H_
+
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup measurement_serv
+ * @{
+ *
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "t_basicdefinitions.h"
+#include "t_time_utilities.h"
+
+/** */
+typedef enum {
+ FLASH_VIA_BULK_TRANSFER,
+} MeasurementType_t;
+
+/** Type of parameters for measurement. */
+typedef enum {
+ START_SESSION_TIME,
+ END_SESSION_TIME,
+ RECEIVED_CHUNK_TIME ,
+ START_FLASH_CHUNK_TIME,
+ END_FLASH_CHUNK_TIME,
+ START_COMMAND_TIME,
+ END_COMMAND_TIME,
+} MeasurementParameter_t;
+
+/** Structure for Chunk Data measurement */
+typedef struct ChunkMeasurement_s {
+ struct ChunkMeasurement_s *PreviousDataBlock_p;
+ uint32 ChunkId;
+ uint32 ReceivedChunkTime;
+ uint32 StartFlashChunkTime;
+ uint32 EndFlashChunkTime;
+ struct ChunkMeasurement_s *NextDataBlock_p;
+} ChunkMeasurement_t;
+
+/** structure for Session measurement */
+typedef struct SessionMeasurement_s {
+ struct SessionMeasurement_s *PreviousDataBlock_p;
+ uint32 SessionId;
+ uint32 OpenSessionTime;
+ uint32 CloseSessionTime;
+ uint32 ChunkNr;
+ ChunkMeasurement_t *ChunkMeasurement_p;
+ struct SessionMeasurement_s *NextDataBlock_p;
+} SessionMeasurement_t;
+
+/** structure for fllash file procedure measurement */
+typedef struct ProcesFileMeasurement_s {
+ struct ProcesFileMeasurement_s *PreviousBlock_p;
+ uint32 OpenTime;
+ uint32 CloseTime;
+ struct ProcesFileMeasurement_s *NextBlock_p;
+} ProcesFileMeasurement_t;
+
+/** Measurement data context structure*/
+typedef struct {
+ uint32 SessionNr;
+ SessionMeasurement_t *SessionMeasurement_p;
+ ProcesFileMeasurement_t *ProcesFileMeasurement_p;
+} MeasurementDataContext_t;
+
+/** Structure for global data measurement */
+typedef struct {
+ uint32 Type;
+ uint32 TimerId;
+ uint32 StartCommandTime;
+ uint32 EndCommandTime;
+ MeasurementDataContext_t *MeasurementData_p;
+ Timer_t Timer;
+ uint32 ResultLength;
+ uint8 *Result_p;
+} Measurement_t;
+
+/** @} */
+/** @} */
+#endif /* T_MEASUREMENT_TOOL_H_ */
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/include/t_r15_family.h b/lcmodule/source/cnh1606344_ldr_communication_module/include/t_r15_family.h
new file mode 100644
index 0000000..66575f5
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/include/t_r15_family.h
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _INCLUSION_GUARD_T_R15_FAMILY_H_
+#define _INCLUSION_GUARD_T_R15_FAMILY_H_
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup R15_family
+ * @{
+ *
+ */
+
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+#include "t_r15_transport_layer.h"
+#include "t_r15_network_layer.h"
+
+/** Strucure with timeouts for R15 protocols. */
+typedef struct {
+ uint32 TCACK ; /**< Time for command packet acknowledge. */
+ uint32 TBCR; /**< Time for bulk command packet to be recieved.*/
+ uint32 TBDR; /**< Time for bulk data packet to be received. */
+} R15_Timeouts_t;
+
+/**
+ * R15 family context.
+ * Context structures for R15 transport layer and network layer.
+ */
+typedef struct {
+ R15_TransportContext_t Transport;
+ R15_NetworkContext_t Network;
+ R15_Timeouts_t Timeouts;
+} R15_FamilyContext_t;
+
+
+/** @} */
+/** @} */
+#endif // _INCLUSION_GUARD_T_R15_FAMILY_H_
+
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/source/a2_family.c b/lcmodule/source/cnh1606344_ldr_communication_module/source/a2_family.c
new file mode 100644
index 0000000..83f155e
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/source/a2_family.c
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup loader_communication_module
+ * @{
+ * @addtogroup a2_family
+ * @{
+ * @addtogroup a2_protocol
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "r_a2_family.h"
+#include "r_a2_network.h"
+#include "r_a2_header.h"
+#include "r_a2_transport.h"
+#include "r_debug_macro.h"
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+
+/*
+ * A2 family protocols initialization.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e A2_Family_Init(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_INVALID_INPUT_PARAMETERS;
+
+ VERIFY(NULL != Communication_p, E_INVALID_INPUT_PARAMETERS);
+
+ Communication_p->FamilyContext_p = malloc(sizeof(A2_FamilyContext_t));
+ VERIFY(NULL != Communication_p->FamilyContext_p, E_ALLOCATE_FAILED);
+
+ A2_SPEEDFLASH(Communication_p)->State = A2_SPEEDFLASH_INACTIVE;
+ A2_SPEEDFLASH(Communication_p)->LastBlock = FALSE;
+ A2_SPEEDFLASH(Communication_p)->Outbound_p = NULL;
+ A2_SPEEDFLASH(Communication_p)->OutboundSize = 0;
+ Communication_p->CurrentFamilyHash = HASH_CRC16;
+
+ if (NULL != Communication_p->BackupCommBuffer_p) {
+ if (Communication_p->BackupCommBufferSize <= A2_HEADER_LENGTH) {
+ memcpy(A2_NETWORK(Communication_p)->Inbound.Scratch, Communication_p->BackupCommBuffer_p, Communication_p->BackupCommBufferSize);
+ A2_NETWORK(Communication_p)->Inbound.ReqData = A2_HEADER_LENGTH - Communication_p->BackupCommBufferSize;
+ A2_NETWORK(Communication_p)->Inbound.ReqBuffOffset = Communication_p->BackupCommBufferSize;
+ A2_NETWORK(Communication_p)->Inbound.RecBackupData = Communication_p->BackupCommBufferSize;
+ Communication_p->BackupCommBufferSize = 0;
+ } else {
+ memcpy(A2_NETWORK(Communication_p)->Inbound.Scratch, Communication_p->BackupCommBuffer_p, A2_HEADER_LENGTH);
+ Communication_p->BackupCommBufferSize = Communication_p->BackupCommBufferSize - A2_HEADER_LENGTH;
+ A2_NETWORK(Communication_p)->Inbound.RecBackupData = A2_HEADER_LENGTH;
+ }
+
+ C_(printf("a2_family.c(%d) BackupBuffer=0x%x Size=%d\n", __LINE__, Communication_p->BackupCommBuffer_p, Communication_p->BackupCommBufferSize);)
+ A2_NETWORK(Communication_p)->Inbound.State = A2_RECEIVE_HEADER;
+ A2_NETWORK(Communication_p)->Inbound.Target_p = A2_NETWORK(Communication_p)->Inbound.Scratch;
+ A2_NETWORK(Communication_p)->Inbound.LCM_Error = E_SUCCESS;
+ } else {
+ Communication_p->BackupCommBufferSize = 0;
+ }
+
+ A2_NETWORK(Communication_p)->Inbound.StopTransfer = FALSE;
+
+ ReturnValue = A2_Network_Initialize(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+ErrorExit:
+ return ReturnValue;
+}
+
+
+/*
+ * A2 family protocols sutdown.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e A2_Family_Shutdown(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_INVALID_INPUT_PARAMETERS;
+
+ VERIFY(NULL != Communication_p, E_INVALID_INPUT_PARAMETERS);
+
+ if (NULL != Communication_p->BackupCommBuffer_p) {
+ free(Communication_p->BackupCommBuffer_p);
+ Communication_p->BackupCommBuffer_p = NULL;
+ }
+
+ Communication_p->BackupCommBuffer_p = (uint8 *)malloc(A2_HEADER_LENGTH);
+ VERIFY(NULL != Communication_p->BackupCommBuffer_p, E_ALLOCATE_FAILED);
+ memcpy(Communication_p->BackupCommBuffer_p, A2_NETWORK(Communication_p)->Inbound.Scratch, A2_HEADER_LENGTH);
+ Communication_p->BackupCommBufferSize = A2_HEADER_LENGTH;
+
+ C_(printf("a2_family.c(%d) BackupBuffer=0x%x, Size=%d \n", __LINE__, Communication_p->BackupCommBuffer_p, Communication_p->BackupCommBufferSize);)
+
+ Communication_p->CurrentFamilyHash = HASH_NONE;
+
+ ReturnValue = A2_Network_Shutdown(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+
+ErrorExit:
+
+ if (NULL != Communication_p) {
+ if (NULL != Communication_p->FamilyContext_p) {
+ free(Communication_p->FamilyContext_p);
+ Communication_p->FamilyContext_p = NULL;
+ }
+ }
+
+ A_(printf("a2_family.c(%d) ErrorCode=%d\n", __LINE__, ReturnValue);)
+
+ return ReturnValue;
+}
+
+/*
+ * A2 Cancel Transmition.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] PacketsBeforeTransferStop Number of packets that will be transmited before stopping the transmition.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e A2_CancelReceiver(Communication_t *Communication_p, uint8 PacketsBeforeReceiverStop)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+
+ VERIFY(NULL != Communication_p, E_INVALID_INPUT_PARAMETERS);
+
+ A2_NETWORK(Communication_p)->Inbound.PacketsBeforeReceiverStop = PacketsBeforeReceiverStop;
+ A2_NETWORK(Communication_p)->Inbound.StopTransfer = TRUE;
+
+ErrorExit:
+ A_(printf("protrom_family.c(%d) ErrorCode=%d\n", __LINE__, ReturnValue);)
+ return ReturnValue;
+}
+
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/source/communication_service.c b/lcmodule/source/cnh1606344_ldr_communication_module/source/communication_service.c
new file mode 100644
index 0000000..342cb1b
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/source/communication_service.c
@@ -0,0 +1,583 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <string.h>
+#include "error_codes.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include "r_debug.h"
+#include "r_debug_macro.h"
+#include "r_r15_family.h"
+#include "r_r15_transport_layer.h"
+#include "r_r15_network_layer.h"
+#include "r_communication_service.h"
+#include "r_basicdefinitions.h"
+#include "r_memmory_utils.h"
+
+#ifdef CFG_ENABLE_A2_FAMILY
+#include "r_a2_family.h"
+#include "r_a2_transport.h"
+#endif
+#ifndef CFG_ENABLE_LOADER_TYPE
+#include "r_protrom_family.h"
+#include "r_z_family.h"
+#include "r_protrom_transport.h"
+#include "r_z_transport.h"
+#endif
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+#define QUEUE_SIZE 32
+
+Communication_t GlobalCommunication = {0};
+Communication_t* GlobalCommunication_p = &GlobalCommunication;
+
+static FamilyDescriptor_t ProtocolFamilies[] = {
+ {
+ R15_Family_Init,
+ R15_Family_Shutdown,
+ R15_Transport_Poll,
+ R15_Transport_Send,
+ R15_SetProtocolTimeouts,
+ R15_GetProtocolTimeouts,
+ R15_CancelReceiver
+ },
+ {
+#ifdef CFG_ENABLE_A2_FAMILY
+ A2_Family_Init,
+ A2_Family_Shutdown,
+ A2_Transport_Poll,
+ A2_Transport_Send,
+ NULL,
+ NULL,
+ A2_CancelReceiver
+#else
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+#endif
+ },
+#ifndef CFG_ENABLE_LOADER_TYPE
+ {
+ // we do not support TI protocol family
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ Protrom_Family_Init,
+ Protrom_Family_Shutdown,
+ Protrom_Transport_Poll,
+ Protrom_Transport_Send,
+ NULL,
+ NULL,
+ Protrom_CancelReceiver
+ },
+ {
+ Z_Family_Init,
+ Z_Family_Shutdown,
+ Z_Transport_Poll,
+ Z_Transport_Send,
+ NULL,
+ NULL,
+ Z_CancelReceiver
+ }
+#endif
+};
+
+#define MAX_FAMILY (sizeof(ProtocolFamilies) / sizeof(ProtocolFamilies[0]))
+
+/*******************************************************************************
+ * Delaration of internal functions
+ ******************************************************************************/
+
+static BuffersInterface_t *CreateBufferInterfaceHelpper(BuffersInterface_t *Buffers_p);
+static TimersInterface_t *CreateTimerInterfaceHelpper(TimersInterface_t *Timers_p);
+static QueueInterface_t *CreateQueueInterfaceHelpper(QueueInterface_t *Queue_p);
+
+static void DestroyBufferInterface(const Communication_t *const Communication_p);
+static void DestroyTimerInterface(const Communication_t *const Communication_p);
+static void DestroyQueueInterface(const Communication_t *const Communication_p);
+FamilyDescriptor_t *GetFamily(Family_t Family);
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+/*
+ * Initialize an instance of the communication module.
+ *
+ * Given the initial family, already initialized hash device descriptor
+ * and communication device descriptor, a new instance of the
+ * communication module is created and bound to use the provided devices.
+ *
+ * @param [in,out] Communication_p Communication module context.
+ * @param [in] Family Initial protocol family.
+ * @param [in] HashDevice_p The device to use for checksum
+ * calculations and verifications.
+ * @param [in] *CommunicationDevice_p The device to use for network
+ * transmission.
+ * @param [in] CommandCallback_p Collback function for command handling.
+ *
+ * @retval E_SUCCESS If the module instance is successfully
+ * initialized. A protocol family dependant error
+ * code otherwise.
+ */
+ErrorCode_e Do_Communication_Initialize(void *Object_p, Communication_t **Communication_pp, Family_t Family, HashDevice_t *HashDevice_p, CommunicationDevice_t *CommunicationDevice_p, Do_CEH_Call_t CommandCallback_p, BuffersInterface_t *Buffers_p, TimersInterface_t *Timers_p, QueueInterface_t *Queue_p)
+{
+ ErrorCode_e ReturnValue = E_INVALID_INPUT_PARAMETERS;
+ Communication_t *Communication_p = NULL;
+
+ VERIFY((NULL != HashDevice_p) && (NULL != CommunicationDevice_p), E_INVALID_INPUT_PARAMETERS);
+
+#ifdef CFG_ENABLE_COMMUNICATION_SINGLETON
+ Communication_p = GlobalCommunication_p;
+#else
+ VERIFY(NULL != Communication_pp, E_INVALID_INPUT_PARAMETERS);
+
+ Communication_p = (Communication_t *)malloc(sizeof(Communication_t));
+ VERIFY(NULL != Communication_p, E_ALLOCATE_FAILED);
+ memset(Communication_p, 0, sizeof(Communication_t));
+
+ Communication_p->Object_p = Object_p;
+ *Communication_pp = Communication_p;
+#endif
+
+ Communication_p->Functions_p = (FunctionInterface_t *)malloc(sizeof(FunctionInterface_t));
+
+ VERIFY(NULL != Communication_p->Functions_p, E_ALLOCATE_FAILED);
+
+ /* init buffer functions*/
+ Communication_p->Functions_p->BufferFunctions_p = CreateBufferInterfaceHelpper(Buffers_p);
+
+ VERIFY(NULL != Communication_p->Functions_p->BufferFunctions_p, E_FAILED_TO_ALLOCATE_COMM_BUFFER);
+
+ /* init Timer functions*/
+ Communication_p->Functions_p->TimerFunctions_p = CreateTimerInterfaceHelpper(Timers_p);
+
+ VERIFY(NULL != Communication_p->Functions_p->TimerFunctions_p, E_FAILED_TO_INTIALIZE_TIMER_FUNCTIONS);
+
+ /* init Queue functions*/
+ Communication_p->Functions_p->QueueFunctions_p = CreateQueueInterfaceHelpper(Queue_p);
+
+ VERIFY(NULL != Communication_p->Functions_p->QueueFunctions_p, E_FAILED_TO_INTIALIZE_QUEUE_FUNCTIONS);
+
+ /* TODO: FIFO init can fail, but there's currently no way of detecting it */
+ QUEUE(Communication_p, FifoCreate_Fn)(OBJECT_QUEUE(Communication_p), &Communication_p->Inbound_p, QUEUE_SIZE, NULL);
+ QUEUE(Communication_p, FifoCreate_Fn)(OBJECT_QUEUE(Communication_p), &Communication_p->Outbound_p, QUEUE_SIZE, NULL);
+
+ Communication_p->CommunicationDevice_p = CommunicationDevice_p;
+ Communication_p->HashDevice_p = HashDevice_p;
+ Communication_p->HashDevice_p->Object_p = HashDevice_p->Object_p;
+ Communication_p->CurrentFamilyHash = HASH_NONE;
+ Communication_p->BackupCommBufferSize = 0;
+
+ ReturnValue = Do_Communication_SetFamily(Communication_p, Family, CommandCallback_p);
+
+ C_(printf("#---------------------------------------------------------\n");)
+ C_(printf("# Loader Communication Module Started!\n");)
+ C_(printf("#---------------------------------------------------------\n");)
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Shutdown an instance of the communication module.
+ *
+ * Shutdown the initialized protocol family, cancel current transmission and
+ * receiving data thru the communication device and shutdown the transport and
+ * network layer.
+ *
+ * @param [in,out] Communication_pp Communication module context.
+ *
+ * @retval E_SUCCESS If the module instance is successfully
+ * shut down. A protocol family dependant error
+ * code otherwise.
+ */
+ErrorCode_e Do_Communication_Shutdown(Communication_t **Communication_pp)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ Communication_t *Communication_p = NULL;
+
+ VERIFY((NULL != Communication_pp) && (NULL != *Communication_pp), E_INVALID_INPUT_PARAMETERS);
+
+ Communication_p = *Communication_pp;
+
+ (void)Communication_p->CommunicationDevice_p->Cancel(Communication_p->CommunicationDevice_p);
+ Communication_p->HashDevice_p->Cancel(OBJECT_HASH(Communication_p), (void **)&Communication_p->HashDevice_p);
+
+ if (NULL != Communication_p->Family_p) {
+ ReturnValue = Communication_p->Family_p->FamilyShutdown_fn(Communication_p);
+ }
+
+ QUEUE(Communication_p, FifoDestroy_Fn)(OBJECT_QUEUE(Communication_p), &Communication_p->Inbound_p);
+ QUEUE(Communication_p, FifoDestroy_Fn)(OBJECT_QUEUE(Communication_p), &Communication_p->Outbound_p);
+
+ DestroyBufferInterface(Communication_p);
+ DestroyTimerInterface(Communication_p);
+ DestroyQueueInterface(Communication_p);
+ free(Communication_p->Functions_p);
+
+ memset(Communication_p, 0, sizeof(Communication_t));
+
+ if (NULL != Communication_p->BackupCommBuffer_p) {
+ free(Communication_p->BackupCommBuffer_p);
+ Communication_p->BackupCommBuffer_p = NULL;
+ Communication_p->BackupCommBufferSize = 0;
+ }
+
+ free(Communication_p);
+ Communication_p = NULL;
+ *Communication_pp = NULL;
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Change the current protocol family.
+ *
+ * Shuts down the old protocol family and initializes the new one.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Family New protocol family identifier.
+ * @param [in] CEHCallback Callback that will handle the commands.
+ *
+ * @retval E_SUCCESS If the family is successfully changed. A
+ * protocol family dependant error code otherwise.
+ */
+ErrorCode_e Do_Communication_SetFamily(Communication_t *Communication_p, Family_t Family, Do_CEH_Call_t CEHCallback)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ FamilyDescriptor_t *Family_p = GetFamily(Family);
+
+ VERIFY(NULL != Family_p, E_INVALID_INPUT_PARAMETERS);
+
+ if (NULL != Communication_p->Family_p) {
+ (void)Communication_p->CommunicationDevice_p->Cancel(Communication_p);
+ ReturnValue = Communication_p->Family_p->FamilyShutdown_fn(Communication_p);
+
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+ }
+
+ Communication_p->Family_p = Family_p;
+ Communication_p->Do_CEH_Call_Fn = CEHCallback;
+
+ ReturnValue = Communication_p->Family_p->FamilyInit_fn(Communication_p);
+ErrorExit:
+ return ReturnValue;
+}
+
+
+/*
+ * Poll the network for inbound packets.
+ *
+ * When a packet is received it is put on the inbound queue. This
+ * function should be called whenever there is time to handle a new
+ * packet. It passes all the elements in the queue to the family
+ * specific polling function, one by one.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ *
+ * @retval E_SUCCESS If all packets are successfully handled. A
+ * protocol family dependant error code otherwise.
+ */
+ErrorCode_e Do_Communication_Poll(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_GENERAL_COMMUNICATION_ERROR;
+
+ VERIFY(NULL != Communication_p->Family_p, ReturnValue);
+
+ ReturnValue = Communication_p->Family_p->Process_fn(Communication_p);
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Function for sending packet.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] InputData_p Pointer to the data for tranmission.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_FAILED_TO_ALLOCATE_COMM_BUFFER Failed to allocate communication
+ * buffer.
+ */
+ErrorCode_e Do_Communication_Send(Communication_t *Communication_p, void *InputData_p)
+{
+ ErrorCode_e ReturnValue = E_GENERAL_COMMUNICATION_ERROR;
+
+ VERIFY(NULL != Communication_p->Family_p, ReturnValue);
+
+ (void)Communication_p->Family_p->Send_fn(Communication_p, InputData_p);
+
+ ReturnValue = E_SUCCESS;
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Function for setting the timeouts in the protocols.
+ *
+ * Timeouts that should be set depend of the protocol family. Some protocol
+ * family do not have timeouts.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] TimeoutData_p Pointer to the data with all timeouts.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_Communication_SetProtocolTimeouts(Communication_t *Communication_p, void *TimeoutData_p)
+{
+ ErrorCode_e ReturnValue = E_GENERAL_COMMUNICATION_ERROR;
+
+ VERIFY(NULL != Communication_p->Family_p, ReturnValue);
+
+ (void)Communication_p->Family_p->SetProtocolTimeouts_fn(Communication_p, TimeoutData_p);
+
+ ReturnValue = E_SUCCESS;
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Function for getting the timeouts in the protocols.
+ *
+ * Timeouts that should be get depend of the protocol family. Some protocol
+ * family do not have timeouts.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [out] TimeoutData_p Return data with all timeouts.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_Communication_GetProtocolTimeouts(Communication_t *Communication_p, void *TimeoutData_p)
+{
+ ErrorCode_e ReturnValue = E_GENERAL_COMMUNICATION_ERROR;
+
+ VERIFY(NULL != Communication_p->Family_p, ReturnValue);
+
+ (void)Communication_p->Family_p->GetProtocolTimeouts_fn(Communication_p, TimeoutData_p);
+
+ ReturnValue = E_SUCCESS;
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Function for getting the communication device for the given LCM instance.
+ *
+ * If communication is Singleton the function can be called with NULL pointer
+ * for Communication_p.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [out] CommunicationDevice_pp Pointer to the initialized communication
+ * device for the given LCM context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMTERS In case when communicaiton is not Singleton
+ * and Communication_p is NULL pointer.
+ */
+ErrorCode_e Do_Communication_GetCommunicationDevice(Communication_t *Communication_p, CommunicationDevice_t** CommunicationDevice_pp)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ VERIFY(NULL != Communication_p && CommunicationDevice_pp != NULL, E_INVALID_INPUT_PARAMETERS);
+
+ *CommunicationDevice_pp = Communication_p->CommunicationDevice_p;
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Function for setting the communication device for the given LCM instance.
+ *
+ * If communication is Singleton the function can be called with NULL pointer
+ * for Communication_p.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [out] CommunicationDevice_p Pointer to the initialized communication
+ * device to be set for the given LCM context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMTERS In case when communicaiton is not Singleton
+ * and Communication_p is NULL pointer.
+ */
+ErrorCode_e Do_Communication_SetCommunicationDevice(Communication_t *Communication_p, CommunicationDevice_t* CommunicationDevice_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ VERIFY(NULL != Communication_p && CommunicationDevice_p != NULL, E_INVALID_INPUT_PARAMETERS);
+
+ Communication_p->CommunicationDevice_p = CommunicationDevice_p;
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Cancek Receiving new packets
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] PacketsBeforeReceiverStop Number of packets to be send before stopping the receiver.
+ *
+ * @retval E_SUCCESS If all packets are successfully handled. A
+ * protocol family dependant error code otherwise.
+ */
+ErrorCode_e Do_Communication_Cancel_Receiver(Communication_t *Communication_p, uint8 PacketsBeforeReceiverStop)
+{
+ ErrorCode_e ReturnValue = E_GENERAL_COMMUNICATION_ERROR;
+
+ VERIFY(NULL != Communication_p->Family_p, ReturnValue);
+
+ ReturnValue = Communication_p->Family_p->CancelReceiver_fn(Communication_p, PacketsBeforeReceiverStop);
+
+ErrorExit:
+ return ReturnValue;
+}
+
+void Do_CommunicationInternalErrorHandler(const ErrorCode_e IntError)
+{
+#ifndef PRINT_A_
+ IDENTIFIER_NOT_USED(IntError);
+#endif
+ A_(printf("# Error Code: 0x%X !\n", IntError);)
+ A_(printf("# Loader stoped!\n");)
+ A_(printf("#---------------------------------------------------------\n");)
+
+ /* coverity[no_escape] */
+ while (1);
+}
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+static BuffersInterface_t *CreateBufferInterfaceHelpper(BuffersInterface_t *Buffers_p)
+{
+ BuffersInterface_t *BufferFunctions_p = (BuffersInterface_t *)malloc(sizeof(BuffersInterface_t));
+
+ if (NULL == BufferFunctions_p) {
+ return NULL;
+ }
+
+ BufferFunctions_p->BuffersInit_Fn = Buffers_p->BuffersInit_Fn;
+ BufferFunctions_p->BufferAllocate_Fn = Buffers_p->BufferAllocate_Fn;
+ BufferFunctions_p->BufferRelease_Fn = Buffers_p->BufferRelease_Fn;
+ BufferFunctions_p->BuffersAvailable_Fn = Buffers_p->BuffersAvailable_Fn;
+ BufferFunctions_p->BuffersDeinit_Fn = Buffers_p->BuffersDeinit_Fn;
+#ifndef CFG_ENABLE_LOADER_TYPE
+ BufferFunctions_p->Object_p = Buffers_p->Object_p;
+#endif
+
+ return BufferFunctions_p;
+}
+
+static TimersInterface_t *CreateTimerInterfaceHelpper(TimersInterface_t *Timers_p)
+{
+ TimersInterface_t *TimerFunctions_p = (TimersInterface_t *)malloc(sizeof(TimersInterface_t));
+
+ if (NULL == TimerFunctions_p) {
+ return NULL;
+ }
+
+ TimerFunctions_p->TimersInit_Fn = Timers_p->TimersInit_Fn;
+ TimerFunctions_p->TimerGet_Fn = Timers_p->TimerGet_Fn;
+ TimerFunctions_p->TimerRelease_Fn = Timers_p->TimerRelease_Fn;
+ TimerFunctions_p->ReadTime_Fn = Timers_p->ReadTime_Fn;
+ TimerFunctions_p->GetSystemTime_Fn = Timers_p->GetSystemTime_Fn;
+#ifndef CFG_ENABLE_LOADER_TYPE
+ TimerFunctions_p->Object_p = Timers_p->Object_p;
+#endif
+
+ return TimerFunctions_p;
+}
+
+static QueueInterface_t *CreateQueueInterfaceHelpper(QueueInterface_t *Queue_p)
+{
+ QueueInterface_t *QueueFunctions_p = (QueueInterface_t *)malloc(sizeof(QueueInterface_t));
+
+ if (NULL == QueueFunctions_p) {
+ return NULL;
+ }
+
+ QueueFunctions_p->FifoCreate_Fn = Queue_p->FifoCreate_Fn;
+ QueueFunctions_p->FifoDestroy_Fn = Queue_p->FifoDestroy_Fn;
+ QueueFunctions_p->FifoEnqueue_Fn = Queue_p->FifoEnqueue_Fn;
+ QueueFunctions_p->FifoDequeue_Fn = Queue_p->FifoDequeue_Fn;
+ QueueFunctions_p->Fifo_SetCallback_Fn = Queue_p->Fifo_SetCallback_Fn;
+ QueueFunctions_p->Fifo_IsEmpty_Fn = Queue_p->Fifo_IsEmpty_Fn;
+ QueueFunctions_p->Fifo_IsMember_Fn = Queue_p->Fifo_IsMember_Fn;
+ QueueFunctions_p->Fifo_GetNrOfElements_Fn = Queue_p->Fifo_GetNrOfElements_Fn;
+
+ QueueFunctions_p->RFifoCreate_Fn = Queue_p->RFifoCreate_Fn;
+ QueueFunctions_p->RFifoDestroy_Fn = Queue_p->RFifoDestroy_Fn;
+ QueueFunctions_p->RFifoEnqueue_Fn = Queue_p->RFifoEnqueue_Fn;
+ QueueFunctions_p->RFifoDequeue_Fn = Queue_p->RFifoDequeue_Fn;
+ QueueFunctions_p->RFifo_SetCallback_Fn = Queue_p->RFifo_SetCallback_Fn;
+ QueueFunctions_p->RFifo_IsEmpty_Fn = Queue_p->RFifo_IsEmpty_Fn;
+ QueueFunctions_p->RFifo_IsMember_Fn = Queue_p->RFifo_IsMember_Fn;
+ QueueFunctions_p->RFifo_GetNrOfElements_Fn = Queue_p->RFifo_GetNrOfElements_Fn;
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+ QueueFunctions_p->Object_p = Queue_p->Object_p;
+#endif
+ return QueueFunctions_p;
+}
+
+static void DestroyBufferInterface(const Communication_t *const Communication_p)
+{
+ if (NULL != Communication_p->Functions_p->BufferFunctions_p) {
+ free(Communication_p->Functions_p->BufferFunctions_p);
+ Communication_p->Functions_p->BufferFunctions_p = NULL;
+ }
+}
+
+static void DestroyTimerInterface(const Communication_t *const Communication_p)
+{
+ if (NULL != Communication_p->Functions_p->TimerFunctions_p) {
+ free(Communication_p->Functions_p->TimerFunctions_p);
+ Communication_p->Functions_p->TimerFunctions_p = NULL;
+ }
+}
+
+static void DestroyQueueInterface(const Communication_t *const Communication_p)
+{
+ if (NULL != Communication_p->Functions_p->QueueFunctions_p) {
+ free(Communication_p->Functions_p->QueueFunctions_p);
+ Communication_p->Functions_p->QueueFunctions_p = NULL;
+ }
+}
+
+FamilyDescriptor_t *GetFamily(Family_t Family)
+{
+ uint32 IntFamily = (uint32)Family;
+
+ if (IntFamily > (MAX_FAMILY - 1)) {
+ return NULL;
+ }
+
+ return (FamilyDescriptor_t *)&ProtocolFamilies[Family];
+}
+
+/** @}*/
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/source/measurement_tool.c b/lcmodule/source/cnh1606344_ldr_communication_module/source/measurement_tool.c
new file mode 100644
index 0000000..29c678d
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/source/measurement_tool.c
@@ -0,0 +1,658 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <string.h>
+#include "t_basicdefinitions.h"
+#include "r_communication_service.h"
+#include "r_measurement_tool.h"
+#include "r_time_utilities.h"
+#include "r_serialization.h"
+#include "r_debug_macro.h"
+#include "r_memmory_utils.h"
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+
+Measurement_t *Measurement_p;
+
+static ChunkMeasurement_t *GetLastChunkDataBlock(ChunkMeasurement_t *ChunkMeasurement_p);
+static SessionMeasurement_t *GetLastSessionDataBlock(SessionMeasurement_t *SessionMeasurement_p);
+static ChunkMeasurement_t *FindChunkDataBlock(ChunkMeasurement_t *Measurement_p, uint32 ChunkID);
+static uint32 CalculateSizeOfResults(SessionMeasurement_t *DataMeasurement_p, uint32 Type, uint32 *SessionNr_pp);
+static void SessionDataSerialize(uint8 **Data_pp, SessionMeasurement_t *SessData_p, uint32 *Length_p);
+static void ChunkDataSerialize(uint8 **Data_pp, ChunkMeasurement_t *ChunkData_p, uint32 *Length_p);
+static ErrorCode_e CompleteBulkFlashResults(Measurement_t *Measurement_p);
+static void TimerMeasurmentHandler(void *Data_p, void *Timer_p, void *Param_p);
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+/*
+ * Initialization of measurement module.
+ *
+ * @param [in] Measurement_p Pointer to curren measurement data block.
+ *
+ * @retval E_SUCCESS If initialization is done.
+ */
+ErrorCode_e Do_Measurement_Init(Measurement_t *Measurement_p)
+{
+ return E_SUCCESS;
+}
+
+/*
+ * This function create general measurement data block.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Measurement_pp Pointer to the created measurement data block.
+ * @param [in] Type Type of measurement.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_ALLOCATE_FAILED If failed to allocate session measurement
+ * data block.
+ */
+ErrorCode_e Do_Measurement_CreateMeasurementData(Communication_t *Communication_p, Measurement_t **Measurement_pp, uint32 Type)
+{
+ ErrorCode_e ReturnValue = E_ALLOCATE_FAILED;
+
+ if (NULL != *Measurement_pp) {
+ ReturnValue = Do_Measurement_DestroyMeasurementData(Measurement_pp);
+
+ if (E_SUCCESS != ReturnValue) {
+ return ReturnValue;
+ }
+ }
+
+ *Measurement_pp = (Measurement_t *)malloc(sizeof(Measurement_t));
+
+ if (NULL == *Measurement_pp) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ (*Measurement_pp)->MeasurementData_p = malloc(sizeof(MeasurementDataContext_t));
+
+ if (NULL == (*Measurement_pp)->MeasurementData_p) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ (*Measurement_pp)->MeasurementData_p->SessionNr = 0;
+ (*Measurement_pp)->MeasurementData_p->SessionMeasurement_p = NULL;
+ (*Measurement_pp)->MeasurementData_p->ProcesFileMeasurement_p = NULL;
+ (*Measurement_pp)->Timer.Time = 3600000;
+ (*Measurement_pp)->Timer.Time = 3600000;
+ (*Measurement_pp)->Timer.PeriodicalTime = 0;
+ (*Measurement_pp)->Timer.HandleFunction_p = TimerMeasurmentHandler;
+ (*Measurement_pp)->TimerId = Do_Timer_TimerGet(NULL, &(*Measurement_pp)->Timer);
+ (*Measurement_pp)->StartCommandTime = 0;
+ (*Measurement_pp)->EndCommandTime = 0;
+ (*Measurement_pp)->Type = Type;
+ (*Measurement_pp)->ResultLength = 0;
+ (*Measurement_pp)->Result_p = NULL;
+ return E_SUCCESS;
+}
+
+/*
+ * This function create general measurement data block.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] Data_pp Pointer to the data block.
+ * @param [in] DataLength_p Pointer to the data block length.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_ALLOCATE_FAILED If failed to allocate session measurement
+ * data block.
+ */
+uint32 Do_Measurement_GetMeasurementData(Communication_t *Communication_p, uint8 **Data_pp)
+{
+ if (NULL == Measurement_p || 0 == Measurement_p->ResultLength || NULL == Measurement_p->Result_p) {
+ return 0;
+ }
+
+ *Data_pp = (uint8 *)malloc(Measurement_p->ResultLength);
+ ASSERT(NULL != *Data_pp);
+ memcpy((uint8 *)*Data_pp, Measurement_p->Result_p, Measurement_p->ResultLength);
+ return Measurement_p->ResultLength;
+}
+
+/*
+ * This function create measurement data block for bulk session.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] SessionMeasurement_pp Pointer to the created session
+ * measurement data block.
+ * @param [in] PreviousSessionDataBlock_p Pointer to the previouse session
+ * measurement data block.
+ * @param [in] ChunkNr Number of chunks in this session.
+ * @param [in] Session Session number.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_ALLOCATE_FAILED If failed to allocate session measurement
+ * data block.
+ */
+ErrorCode_e Do_Measurement_CreateSessionMeasurementData(Communication_t *Communication_p,
+ SessionMeasurement_t **SessionMeasurement_pp,
+ SessionMeasurement_t *PreviousSessionDataBlock_p,
+ uint32 ChunkNr, uint32 Session)
+{
+ ChunkMeasurement_t *ChunkDataBlock_p = NULL;
+ SessionMeasurement_t **NewSessionDataBlock_pp = NULL;
+ SessionMeasurement_t *LastSessionMeasurement_p = NULL;
+ uint32 i;
+ ErrorCode_e ReturnValue = E_ALLOCATE_FAILED;
+
+ if (*SessionMeasurement_pp != NULL) {
+ LastSessionMeasurement_p = GetLastSessionDataBlock(*SessionMeasurement_pp);
+ NewSessionDataBlock_pp = &LastSessionMeasurement_p->NextDataBlock_p;
+ } else {
+ NewSessionDataBlock_pp = SessionMeasurement_pp;
+ }
+
+ *NewSessionDataBlock_pp = (SessionMeasurement_t *)malloc(sizeof(SessionMeasurement_t));
+
+ if (NULL == *SessionMeasurement_pp) {
+ return ReturnValue;
+ }
+
+ (*NewSessionDataBlock_pp)->PreviousDataBlock_p = LastSessionMeasurement_p;
+ (*NewSessionDataBlock_pp)->SessionId = Session;
+ (*NewSessionDataBlock_pp)->ChunkNr = ChunkNr;
+ (*NewSessionDataBlock_pp)->OpenSessionTime = 0;
+ (*NewSessionDataBlock_pp)->CloseSessionTime = 0;
+ (*NewSessionDataBlock_pp)->ChunkMeasurement_p = NULL;
+ (*NewSessionDataBlock_pp)->NextDataBlock_p = NULL;
+
+ for (i = 0; i < ChunkNr; i++) {
+ ReturnValue = Do_Measurement_CreateChunkMeasurementData(Communication_p, &(*NewSessionDataBlock_pp)->ChunkMeasurement_p, ChunkDataBlock_p, i);
+ }
+
+ return ReturnValue;
+}
+
+/*
+ * This function create measurement data block for measure chunks transfer.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] ChunkMeasurement_pp Pointer to the created chunk
+ * measurement data block.
+ * @param [in] PreviousChunkDataBlock_p Pointer to the previouse chunk
+ * measurement data block.
+ * @param [in] ChunkId Chunk ID.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_ALLOCATE_FAILED If failed to allocate session measurement
+ * data block.
+ */
+ErrorCode_e Do_Measurement_CreateChunkMeasurementData(Communication_t *Communication_p,
+ ChunkMeasurement_t **ChunkMeasurement_pp,
+ ChunkMeasurement_t *PreviousChunkDataBlock_p,
+ uint32 ChunkId)
+{
+ ChunkMeasurement_t **NewChunkDataBlock_pp = NULL;
+ ChunkMeasurement_t *LastChunkMeasurement_p = NULL;
+
+ if (*ChunkMeasurement_pp != NULL) {
+ LastChunkMeasurement_p = GetLastChunkDataBlock(*ChunkMeasurement_pp);
+ NewChunkDataBlock_pp = &(LastChunkMeasurement_p)->NextDataBlock_p;
+ } else {
+ NewChunkDataBlock_pp = ChunkMeasurement_pp;
+ }
+
+ *NewChunkDataBlock_pp = (ChunkMeasurement_t *)malloc(sizeof(ChunkMeasurement_t));
+
+ if (NULL == *NewChunkDataBlock_pp) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ (*NewChunkDataBlock_pp)->PreviousDataBlock_p = LastChunkMeasurement_p;
+ (*NewChunkDataBlock_pp)->ChunkId = ChunkId;
+ (*NewChunkDataBlock_pp)->ReceivedChunkTime = 0;
+ (*NewChunkDataBlock_pp)->StartFlashChunkTime = 0;
+ (*NewChunkDataBlock_pp)->EndFlashChunkTime = 0;
+ (*NewChunkDataBlock_pp)->NextDataBlock_p = NULL;
+ return E_SUCCESS;
+}
+
+/*
+ * This function destroy measurement data block for bulk session.
+ *
+ * @param [in] Measurement_pp Pointer to the measurement data block.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_Measurement_DestroySessionMeasurementData(SessionMeasurement_t **SessionMeasurement_pp)
+{
+ ErrorCode_e ReturnValue;
+ SessionMeasurement_t *LastSessionDataBlock_p = NULL;
+
+ if (*SessionMeasurement_pp != NULL) {
+ LastSessionDataBlock_p = GetLastSessionDataBlock(*SessionMeasurement_pp);
+
+ do {
+ *SessionMeasurement_pp = LastSessionDataBlock_p->PreviousDataBlock_p;
+ /* free the all chunks in the session data block */
+ ReturnValue = Do_Measurement_DestroyChunkMeasurementData(&LastSessionDataBlock_p->ChunkMeasurement_p);
+
+ if (ReturnValue != E_SUCCESS) {
+ return ReturnValue;
+ }
+
+ /* free the session data block */
+ free(LastSessionDataBlock_p);
+ LastSessionDataBlock_p = *SessionMeasurement_pp;
+ } while (LastSessionDataBlock_p->PreviousDataBlock_p != NULL);
+
+ /* free the all chunks in the last session data block */
+ ReturnValue = Do_Measurement_DestroyChunkMeasurementData(&LastSessionDataBlock_p->ChunkMeasurement_p);
+
+ if (ReturnValue != E_SUCCESS) {
+ return ReturnValue;
+ }
+
+ /* free the last session data block */
+ free(LastSessionDataBlock_p);
+ }
+
+ return E_SUCCESS;
+}
+
+/*
+ * This function destroy measurement data block for bulk chunks.
+ *
+ * @param [in] Measurement_pp Pointer to the main measurement data block.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_Measurement_DestroyChunkMeasurementData(ChunkMeasurement_t **ChunkMeasurement_pp)
+{
+ ChunkMeasurement_t *LastChunkDataBlock_p = NULL;
+ ChunkMeasurement_t *TmpLastChunkDataBlock_p = NULL;
+
+ if (*ChunkMeasurement_pp != NULL) {
+ LastChunkDataBlock_p = GetLastChunkDataBlock(*ChunkMeasurement_pp);
+ TmpLastChunkDataBlock_p = LastChunkDataBlock_p->PreviousDataBlock_p;
+ free(LastChunkDataBlock_p);
+
+ while (TmpLastChunkDataBlock_p != NULL) {
+ /* free the chunk data block */
+ LastChunkDataBlock_p = TmpLastChunkDataBlock_p;
+ TmpLastChunkDataBlock_p = LastChunkDataBlock_p->PreviousDataBlock_p;
+ free(LastChunkDataBlock_p);
+ }//while(TmpLastChunkDataBlock_p != NULL);
+
+ // while(LastChunkDataBlock_p->PreviousDataBlock_p != NULL)
+ // {
+ // *ChunkMeasurement_pp = LastChunkDataBlock_p->PreviousDataBlock_p;
+ // /* free the chunk data block */
+ // free(LastChunkDataBlock_p);
+ // LastChunkDataBlock_p = *ChunkMeasurement_pp;
+ // }
+ /* free the last chunk data block */
+ //free(*ChunkMeasurement_pp);
+ }
+
+ return E_SUCCESS;
+}
+
+/*
+ * This function destroy general measurement data block.
+ *
+ * @param [in] Measurement_pp Pointer to the main measurement data block.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_Measurement_DestroyMeasurementData(Measurement_t **Measurement_pp)
+{
+ ErrorCode_e ReturnValue = E_INVALID_INPUT_PARAMETERS;
+
+ if (NULL == *Measurement_pp) {
+ return ReturnValue;
+ }
+
+ switch ((*Measurement_pp)->Type) {
+ case FLASH_VIA_BULK_TRANSFER:
+
+ /* free the all created session data blocks */
+ if (NULL != (*Measurement_pp)->MeasurementData_p) {
+ if (NULL != (*Measurement_pp)->MeasurementData_p->SessionMeasurement_p) {
+ ReturnValue = Do_Measurement_DestroySessionMeasurementData(&(*Measurement_pp)->MeasurementData_p->SessionMeasurement_p);
+ (*Measurement_pp)->MeasurementData_p->SessionMeasurement_p = NULL;
+ }
+
+ ReturnValue = E_SUCCESS;
+ //free((*Measurement_pp)->MeasurementData_p->ProcesFileMeasurement_p);
+ //free((*Measurement_pp)->MeasurementData_p);
+ }
+
+ if (E_SUCCESS != ReturnValue) {
+ return ReturnValue;
+ }
+
+ break;
+
+ default:
+ //...
+ break;
+ }
+
+ //free(*Measurement_pp);
+ return ReturnValue;
+}
+
+/*
+ * This function make zero reference for all measured data.
+ *
+ * @param [in] Measurement_p Pointer to the main measurement data block.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_Measurement_ZeroReferenceMeasurementData(Measurement_t *Measurement_p)
+{
+ return E_SUCCESS;
+}
+
+/*
+ * This function add measured time in specified measurement data block.
+ *
+ * @param [in] Measurement_p Pointer to the main measurement data block.
+ * @param [in] Time Measured time.
+ * @param [in] ChunkID Chunk ID
+ * @param [in] Parameter Parameter in the measurement data block.
+ *
+ * @retval E_SUCCESS After successful execution.
+ */
+ErrorCode_e Do_Measurement_AddMeasurementData(Measurement_t *Measurement_p, uint32 Time, uint32 ChunkID, MeasurementParameter_t Parameter)
+{
+ ErrorCode_e ReturnValue = E_FAILED_TO_FIND_CHUNK_DATA_BLOCK;
+ uint32 NewTime;
+ SessionMeasurement_t *SessionMeasurement_p = GetLastSessionDataBlock(Measurement_p->MeasurementData_p->SessionMeasurement_p);
+ ChunkMeasurement_t *ChankDataBlock_p = NULL;
+ NewTime = Measurement_p->Timer.Time - Time;
+
+ switch (Parameter) {
+ case START_SESSION_TIME:
+ SessionMeasurement_p->OpenSessionTime = NewTime;
+ ReturnValue = E_SUCCESS;
+ break;
+ case END_SESSION_TIME:
+ SessionMeasurement_p->CloseSessionTime = NewTime;
+ ReturnValue = E_SUCCESS;
+ break;
+ case RECEIVED_CHUNK_TIME :
+ ChankDataBlock_p = FindChunkDataBlock(SessionMeasurement_p->ChunkMeasurement_p, ChunkID);
+
+ if (ChankDataBlock_p != NULL) {
+ ChankDataBlock_p->ReceivedChunkTime = NewTime;
+ ReturnValue = E_SUCCESS;
+ }
+
+ break;
+ case START_FLASH_CHUNK_TIME:
+ ChankDataBlock_p = FindChunkDataBlock(SessionMeasurement_p->ChunkMeasurement_p, ChunkID);
+
+ if (ChankDataBlock_p != NULL) {
+ ChankDataBlock_p->StartFlashChunkTime = NewTime;
+ ReturnValue = E_SUCCESS;
+ }
+
+ break;
+ case END_FLASH_CHUNK_TIME:
+ ChankDataBlock_p = FindChunkDataBlock(SessionMeasurement_p->ChunkMeasurement_p, ChunkID);
+
+ if (ChankDataBlock_p != NULL) {
+ ChankDataBlock_p->EndFlashChunkTime = NewTime;
+ ReturnValue = E_SUCCESS;
+ }
+
+ break;
+ case START_COMMAND_TIME:
+ Measurement_p->StartCommandTime = NewTime;
+ ReturnValue = E_SUCCESS;
+ break;
+ case END_COMMAND_TIME:
+ Measurement_p->EndCommandTime = NewTime;
+ ReturnValue = E_SUCCESS;
+ break;
+ default:
+ //…
+ break;
+ }
+
+ return ReturnValue;
+}
+
+/*
+ *
+ */
+ErrorCode_e Do_Measurement_CompleteResults(Measurement_t *Measurement_p)
+{
+ ErrorCode_e ReturnValue = E_FAILED_TO_FIND_CHUNK_DATA_BLOCK;
+ //SessionMeasurement_t * TmpSessData_p = NULL;
+ //uint8* Data_p = NULL;
+ uint32 Size = 0;
+
+ switch (Measurement_p->Type) {
+ case FLASH_VIA_BULK_TRANSFER:
+ Size = CalculateSizeOfResults(Measurement_p->MeasurementData_p->SessionMeasurement_p, Measurement_p->Type, (uint32 *)&Measurement_p->MeasurementData_p->SessionNr);
+
+ if (Size != 0) {
+ Size += 2 * sizeof(uint32);
+ BUFFER_FREE(Measurement_p->Result_p);
+
+ Measurement_p->Result_p = (uint8 *)malloc(Size);
+ // ASSERT(NULL != Measurement_p->Result_p);
+ Measurement_p->ResultLength = Size;
+
+ /* get result from the list of the session data blocks */
+ ReturnValue = CompleteBulkFlashResults(Measurement_p);
+ } else {
+ Measurement_p->ResultLength = Size;
+ BUFFER_FREE(Measurement_p->Result_p);
+
+ Measurement_p->Result_p = NULL;
+ ReturnValue = E_SUCCESS;
+ }
+
+ break;
+ default:
+ //...
+ break;
+ }
+
+ return ReturnValue;
+}
+
+/*******************************************************************************
+ * Definition of internal functions
+ ******************************************************************************/
+/*
+ * This function create Timer callback.
+ *
+ * @param [in] Data_p Pointer to data.
+ * @param [in] Timer_p Pointer to timer.
+ * @param [in] Param_p Pointer to parameter.
+ *
+ */
+void TimerMeasurmentHandler(void *Data_p, void *Timer_p, void *Param_p)
+{
+ ASSERT(FALSE);
+}
+
+/*
+ * This function search the requested chunk data block in the list of the chunk
+ * data blocks.
+ *
+ * @param [in] Measurement_p Pointer to the main measurement data block.
+ * @param [in] ChunkID Chunk ID for requested chunk data block.
+ *
+ * @retval pointer Pointer to the requested chunk data block.
+ * @retval NULL If the list of the chunk data blocks is empty.
+ */
+static ChunkMeasurement_t *FindChunkDataBlock(ChunkMeasurement_t *Measurement_p, uint32 ChunkID)
+{
+ ChunkMeasurement_t *TmpData_p = Measurement_p;
+
+ if (TmpData_p != NULL) {
+ while ((TmpData_p->NextDataBlock_p != NULL) && (TmpData_p->ChunkId != ChunkID)) {
+ TmpData_p = TmpData_p->NextDataBlock_p;
+ }
+ }
+
+ return TmpData_p;
+}
+
+/*
+ * Get last chunk data block from the list of the chunk data blocks.
+ *
+ * @param [in] ChunkMeasurement_p Pointer to the main measurement data block.
+ *
+ * @retval pointer Pointer to the last chunk data block.
+ * @retval NULL If the list of the chunk data blocks is empty.
+ */
+static ChunkMeasurement_t *GetLastChunkDataBlock(ChunkMeasurement_t *ChunkMeasurement_p)
+{
+ ChunkMeasurement_t *TmpData_p = ChunkMeasurement_p;
+
+ if (TmpData_p != NULL) {
+ while (TmpData_p->NextDataBlock_p != NULL) {
+ TmpData_p = TmpData_p->NextDataBlock_p;
+ }
+ }
+
+ return TmpData_p;
+}
+
+/*
+ * Get last session data block from the list of the chunk data blocks.
+ *
+ * @param [in] ChunkMeasurement_p Pointer to the main measurement data block.
+ *
+ * @retval pointer Pointer to the last chunk data block.
+ * @retval NULL If the list of the chunk data blocks is empty.
+ */
+static SessionMeasurement_t *GetLastSessionDataBlock(SessionMeasurement_t *SessionMeasurement_p)
+{
+ SessionMeasurement_t *TmpData_p = SessionMeasurement_p;
+
+ if (TmpData_p != NULL) {
+ while (TmpData_p->NextDataBlock_p != NULL) {
+ TmpData_p = TmpData_p->NextDataBlock_p;
+ }
+ }
+
+ return TmpData_p;
+}
+
+
+static ErrorCode_e CompleteBulkFlashResults(Measurement_t *Measurement_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+ SessionMeasurement_t *TmpSessData_p = Measurement_p->MeasurementData_p->SessionMeasurement_p;
+ ChunkMeasurement_t *TmpChunkData_p = NULL;
+ uint8 *Data_p = Measurement_p->Result_p;
+
+ if (TmpSessData_p != NULL) {
+ memcpy(Data_p , (uint8 *)&Measurement_p->Type , sizeof(uint32));
+ memcpy(Data_p + sizeof(uint32), (uint8 *)&Measurement_p->MeasurementData_p->SessionNr, sizeof(uint32));
+ Data_p += 2 * sizeof(uint32);
+ //Measurement_p->ResultLength ++;
+ //SessionDataSerialize(&Data_p, TmpSessData_p, &Measurement_p->ResultLength);
+ TmpChunkData_p = TmpSessData_p->ChunkMeasurement_p;
+
+ //while(TmpSessData_p->NextDataBlock_p != NULL)
+ while (TmpSessData_p != NULL) {
+ SessionDataSerialize(&Data_p, TmpSessData_p, &Measurement_p->ResultLength);
+ TmpChunkData_p = TmpSessData_p->ChunkMeasurement_p;
+
+ if (TmpChunkData_p != NULL) {
+ ChunkDataSerialize(&Data_p, TmpChunkData_p, &Measurement_p->ResultLength);
+
+ while (TmpChunkData_p->NextDataBlock_p != NULL) {
+ TmpChunkData_p = TmpChunkData_p->NextDataBlock_p;
+ ChunkDataSerialize(&Data_p, TmpChunkData_p, &Measurement_p->ResultLength);
+ }
+ }
+
+ TmpSessData_p = TmpSessData_p->NextDataBlock_p;
+ }
+ }
+
+ return ReturnValue;
+}
+
+
+static void SessionDataSerialize(uint8 **Data_pp, SessionMeasurement_t *SessData_p, uint32 *Length_p)
+{
+ put_uint32_le((void **)Data_pp, SessData_p->SessionId);
+ *Length_p++;
+ put_uint32_le((void **)Data_pp, SessData_p->OpenSessionTime);
+ *Length_p++;
+ put_uint32_le((void **)Data_pp, SessData_p->CloseSessionTime);
+ *Length_p++;
+ put_uint32_le((void **)Data_pp, SessData_p->ChunkNr);
+ *Length_p++;
+}
+
+
+static void ChunkDataSerialize(uint8 **Data_pp, ChunkMeasurement_t *ChunkData_p, uint32 *Length_p)
+{
+ put_uint32_le((void **)Data_pp, ChunkData_p->ChunkId);
+ *Length_p++;
+ put_uint32_le((void **)Data_pp, ChunkData_p->ReceivedChunkTime);
+ *Length_p++;
+ put_uint32_le((void **)Data_pp, ChunkData_p->StartFlashChunkTime);
+ *Length_p++;
+ put_uint32_le((void **)Data_pp, ChunkData_p->EndFlashChunkTime);
+ *Length_p++;
+}
+
+/*
+ * Calculate size of the results.
+ *
+ * @param [in] DataMeasurement_p Pointer to the main measurement data block.
+ * @param [in] Type Type of measurement data block.
+ *
+ * @retval Size Size of the results.
+ * @retval 0 If the list of the chunk data blocks is empty.
+ */
+static uint32 CalculateSizeOfResults(SessionMeasurement_t *DataMeasurement_p, uint32 Type, uint32 *SessionNr_p)
+{
+ SessionMeasurement_t *TmpData_p = DataMeasurement_p;
+ uint32 Size = 0;
+
+ switch (Type) {
+ case FLASH_VIA_BULK_TRANSFER:
+
+ if (TmpData_p != NULL) {
+ *SessionNr_p = 0;
+
+ //(SessionMeasurement_t*)TmpData_p = ((SessionMeasurement_t*)TmpData_p)->NextDataBlock_p;
+ //while(((SessionMeasurement_t*)TmpData_p)->NextDataBlock_p != NULL)
+ while (TmpData_p != NULL) {
+ Size = Size + (((SessionMeasurement_t *)TmpData_p)->ChunkNr * 4 * sizeof(uint32));
+ Size += (4 * sizeof(uint32));
+ //(SessionMeasurement_t*)TmpData_p = ((SessionMeasurement_t*)TmpData_p)->NextDataBlock_p;
+ TmpData_p = (SessionMeasurement_t *)TmpData_p->NextDataBlock_p;
+ (*SessionNr_p)++;
+ }
+ }
+
+ break;
+ default:
+ Size = 0;
+ break;
+
+ }
+
+ return Size;
+}
+
+/** @} */
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/source/protrom_family.c b/lcmodule/source/cnh1606344_ldr_communication_module/source/protrom_family.c
new file mode 100644
index 0000000..ec4c468
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/source/protrom_family.c
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup protrom_family
+ * @{
+ * @addtogroup protrom_protocol
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <stdlib.h>
+#include <string.h>
+
+#include "r_protrom_family.h"
+#include "r_protrom_network.h"
+#include "r_protrom_header.h"
+#include "r_protrom_transport.h"
+#include "r_debug_macro.h"
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+/*
+ * Protrom family protocols initialization.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e Protrom_Family_Init(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_INVALID_INPUT_PARAMETERS;
+
+ VERIFY(NULL != Communication_p, E_INVALID_INPUT_PARAMETERS);
+
+ Communication_p->FamilyContext_p = malloc(sizeof(Protrom_FamilyContext_t));
+ VERIFY(NULL != Communication_p->FamilyContext_p, E_ALLOCATE_FAILED);
+
+ Communication_p->CurrentFamilyHash = HASH_CRC16;
+ PROTROM_NETWORK(Communication_p)->Inbound.StopTransfer = FALSE;
+
+ if (NULL != Communication_p->BackupCommBuffer_p) {
+ if (Communication_p->BackupCommBufferSize <= PROTROM_HEADER_LENGTH) {
+ memcpy(PROTROM_NETWORK(Communication_p)->Inbound.Scratch, Communication_p->BackupCommBuffer_p, Communication_p->BackupCommBufferSize);
+ PROTROM_NETWORK(Communication_p)->Inbound.ReqData = PROTROM_HEADER_LENGTH - Communication_p->BackupCommBufferSize;
+ PROTROM_NETWORK(Communication_p)->Inbound.ReqBuffOffset = Communication_p->BackupCommBufferSize;
+ PROTROM_NETWORK(Communication_p)->Inbound.RecBackupData = Communication_p->BackupCommBufferSize;
+ Communication_p->BackupCommBufferSize = 0;
+ } else {
+ memcpy(PROTROM_NETWORK(Communication_p)->Inbound.Scratch, Communication_p->BackupCommBuffer_p, PROTROM_HEADER_LENGTH);
+ Communication_p->BackupCommBufferSize = Communication_p->BackupCommBufferSize - PROTROM_HEADER_LENGTH;
+ PROTROM_NETWORK(Communication_p)->Inbound.RecBackupData = PROTROM_HEADER_LENGTH;
+ }
+
+ C_(printf("protrom_family.c(%d) BackupBuffer=0x%x Size=%d\n", __LINE__, Communication_p->BackupCommBuffer_p, Communication_p->BackupCommBufferSize);)
+ PROTROM_NETWORK(Communication_p)->Inbound.State = PROTROM_RECEIVE_HEADER;
+ PROTROM_NETWORK(Communication_p)->Inbound.Target_p = PROTROM_NETWORK(Communication_p)->Inbound.Scratch;
+ } else {
+ Communication_p->BackupCommBufferSize = 0;
+ }
+
+ ReturnValue = Protrom_Network_Initialize(Communication_p);
+
+ErrorExit:
+ A_(printf("protrom_family.c(%d) ErrorCode=%d\n", __LINE__, ReturnValue);)
+ return ReturnValue;
+}
+
+/*
+ * Protrom family protocols sutdown.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e Protrom_Family_Shutdown(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+
+ VERIFY(NULL != Communication_p, E_INVALID_INPUT_PARAMETERS);
+
+ if (NULL != Communication_p->BackupCommBuffer_p) {
+ free(Communication_p->BackupCommBuffer_p);
+ }
+
+ Communication_p->BackupCommBuffer_p = (uint8 *)malloc(PROTROM_HEADER_LENGTH);
+ VERIFY(NULL != Communication_p->BackupCommBuffer_p, E_ALLOCATE_FAILED);
+ memcpy(Communication_p->BackupCommBuffer_p, PROTROM_NETWORK(Communication_p)->Inbound.Scratch, PROTROM_HEADER_LENGTH);
+ Communication_p->BackupCommBufferSize = PROTROM_HEADER_LENGTH;
+ C_(printf("protrom_family.c(%d) BackupBuffer=0x%x Size=%d\n", __LINE__, Communication_p->BackupCommBuffer_p, Communication_p->BackupCommBufferSize);)
+
+ Communication_p->CurrentFamilyHash = HASH_NONE;
+
+ ReturnValue = Protrom_Network_Shutdown(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+
+ErrorExit:
+
+ if (NULL != Communication_p) {
+ if (NULL != Communication_p->FamilyContext_p) {
+ free(Communication_p->FamilyContext_p);
+ Communication_p->FamilyContext_p = NULL;
+ }
+ }
+
+ A_(printf("protrom_family.c(%d) ErrorCode=%d\n", __LINE__, ReturnValue);)
+
+ return ReturnValue;
+}
+
+/*
+ * Protrom Cancel Transmition.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] PacketsBeforeTransferStop Number of packets that will be transmited before stopping the transmition.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e Protrom_CancelReceiver(Communication_t *Communication_p, uint8 PacketsBeforeReceiverStop)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+
+ printf("Protrom_CancelReceiver called ...\n");
+
+ VERIFY(NULL != Communication_p, E_INVALID_INPUT_PARAMETERS);
+
+ PROTROM_NETWORK(Communication_p)->Inbound.PacketsBeforeReceiverStop = PacketsBeforeReceiverStop;
+ PROTROM_NETWORK(Communication_p)->Inbound.StopTransfer = TRUE;
+
+ErrorExit:
+ A_(printf("protrom_family.c(%d) ErrorCode=%d\n", __LINE__, ReturnValue);)
+ return ReturnValue;
+}
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/source/r15_family.c b/lcmodule/source/cnh1606344_ldr_communication_module/source/r15_family.c
new file mode 100644
index 0000000..baf1d7a
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/source/r15_family.c
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "r_r15_family.h"
+#include "r_r15_transport_layer.h"
+#include "r_r15_network_layer.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "r_debug_macro.h"
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+/*
+ * R15 family protocols initialization.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e R15_Family_Init(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_INVALID_INPUT_PARAMETERS;
+
+ VERIFY(NULL != Communication_p, E_INVALID_INPUT_PARAMETERS);
+
+ Communication_p->FamilyContext_p = malloc(sizeof(R15_FamilyContext_t));
+ VERIFY(NULL != Communication_p->FamilyContext_p, E_ALLOCATE_FAILED);
+
+#ifndef CFG_ENABLE_LOADER_TYPE
+ Communication_p->CurrentFamilyHash = HASH_NONE;
+#else
+#ifdef DISABLE_SECURITY
+ Communication_p->CurrentFamilyHash = HASH_NONE;
+#else
+ Communication_p->CurrentFamilyHash = HASH_SHA256;
+#endif
+#endif
+
+ R15_NETWORK(Communication_p)->Inbound.StopTransfer = FALSE;
+
+ if (NULL != Communication_p->BackupCommBuffer_p) {
+ if (Communication_p->BackupCommBufferSize <= HEADER_LENGTH) {
+ memcpy(R15_NETWORK(Communication_p)->Inbound.Scratch, Communication_p->BackupCommBuffer_p, Communication_p->BackupCommBufferSize);
+ R15_NETWORK(Communication_p)->Inbound.ReqData = HEADER_LENGTH - Communication_p->BackupCommBufferSize;
+ R15_NETWORK(Communication_p)->Inbound.ReqBuffOffset = Communication_p->BackupCommBufferSize;
+ R15_NETWORK(Communication_p)->Inbound.RecBackupData = Communication_p->BackupCommBufferSize;
+ Communication_p->BackupCommBufferSize = 0;
+ } else {
+ memcpy(R15_NETWORK(Communication_p)->Inbound.Scratch, Communication_p->BackupCommBuffer_p, HEADER_LENGTH);
+ Communication_p->BackupCommBufferSize = Communication_p->BackupCommBufferSize - HEADER_LENGTH;
+ R15_NETWORK(Communication_p)->Inbound.RecBackupData = HEADER_LENGTH;
+ }
+
+ C_(printf("r15_family.c(%d) BackupBuffer=0x%x Size=%d\n", __LINE__, Communication_p->BackupCommBuffer_p, Communication_p->BackupCommBufferSize);)
+ R15_NETWORK(Communication_p)->Inbound.State = RECEIVE_HEADER;
+ R15_NETWORK(Communication_p)->Inbound.Target_p = R15_NETWORK(Communication_p)->Inbound.Scratch;
+ R15_NETWORK(Communication_p)->Inbound.LCM_Error = E_SUCCESS;
+ } else {
+ Communication_p->BackupCommBufferSize = 0;
+ }
+
+ ReturnValue = R15_Transport_Initialize(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+
+ ReturnValue = R15_Network_Initialize(Communication_p);
+
+ErrorExit:
+ A_(printf("r15_family.c(%d) ErrorCode=%d\n", __LINE__, ReturnValue);)
+ return ReturnValue;
+}
+
+
+/*
+ * R15 family protocols sutdown.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e R15_Family_Shutdown(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_INVALID_INPUT_PARAMETERS;
+
+ VERIFY(NULL != Communication_p, E_INVALID_INPUT_PARAMETERS);
+
+ if (NULL != Communication_p->BackupCommBuffer_p) {
+ free(Communication_p->BackupCommBuffer_p);
+ Communication_p->BackupCommBuffer_p = NULL;
+ }
+
+ Communication_p->BackupCommBuffer_p = (uint8 *)malloc(HEADER_LENGTH + BULK_EXTENDED_HEADER_LENGTH);
+ VERIFY(NULL != Communication_p->BackupCommBuffer_p, E_ALLOCATE_FAILED);
+ memcpy(Communication_p->BackupCommBuffer_p, R15_NETWORK(Communication_p)->Inbound.Scratch, HEADER_LENGTH + BULK_EXTENDED_HEADER_LENGTH);
+ Communication_p->BackupCommBufferSize = HEADER_LENGTH + BULK_EXTENDED_HEADER_LENGTH;
+ C_(printf("r15_family.c(%d) BackupBuffer=0x%x, Size=%d \n", __LINE__, Communication_p->BackupCommBuffer_p, Communication_p->BackupCommBufferSize);)
+
+ Communication_p->CurrentFamilyHash = HASH_NONE;
+
+ ReturnValue = R15_Transport_Shutdown(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+
+ ReturnValue = R15_Network_Shutdown(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+
+ErrorExit:
+
+ if (NULL != Communication_p) {
+ if (NULL != Communication_p->FamilyContext_p) {
+ free(Communication_p->FamilyContext_p);
+ Communication_p->FamilyContext_p = NULL;
+ }
+ }
+
+ A_(printf("r15_family.c(%d) ErrorCode=%d\n", __LINE__, ReturnValue);)
+
+ return ReturnValue;
+}
+
+/*
+ * R15 Cancel Transmition.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] PacketsBeforeTransferStop Number of packets that will be transmited before stopping the transmition.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e R15_CancelReceiver(Communication_t *Communication_p, uint8 PacketsBeforeReceiverStop)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+
+ VERIFY(NULL != Communication_p, E_INVALID_INPUT_PARAMETERS);
+
+ R15_NETWORK(Communication_p)->Inbound.PacketsBeforeReceiverStop = PacketsBeforeReceiverStop;
+ R15_NETWORK(Communication_p)->Inbound.StopTransfer = TRUE;
+
+ErrorExit:
+ A_(printf("protrom_family.c(%d) ErrorCode=%d\n", __LINE__, ReturnValue);)
+ return ReturnValue;
+}
+
+/** @} */
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/source/z_family.c b/lcmodule/source/cnh1606344_ldr_communication_module/source/z_family.c
new file mode 100644
index 0000000..ee090c9
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/source/z_family.c
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * @addtogroup ldr_communication_serv
+ * @{
+ * @addtogroup Z_family
+ * @{
+ * @addtogroup Z_protocol
+ * @{
+ */
+
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <stdlib.h>
+#include <string.h>
+
+#include "r_z_family.h"
+#include "r_z_protocol.h"
+#include "r_z_network.h"
+#include "r_z_transport.h"
+#include "r_debug_macro.h"
+
+/*******************************************************************************
+ * File scope types, constants and variables
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+/*
+ * Z family protocols initialization.
+ *
+ * Z transport and Z network layer will be initialized.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e Z_Family_Init(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_INVALID_INPUT_PARAMETERS;
+
+ if (NULL == Communication_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ if (NULL != Communication_p->BackupCommBuffer_p) {
+ free(Communication_p->BackupCommBuffer_p);
+ Communication_p->BackupCommBuffer_p = NULL;
+ }
+
+ Communication_p->BackupCommBufferSize = 0;
+
+ Communication_p->FamilyContext_p = malloc(sizeof(Z_FamilyContext_t));
+
+ if (NULL == Communication_p->FamilyContext_p) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ Communication_p->CurrentFamilyHash = HASH_NONE;
+ Z_NETWORK(Communication_p)->Inbound.StopTransfer = FALSE;
+
+ ReturnValue = Z_Transport_Initialize(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+
+ ReturnValue = Z_Network_Initialize(Communication_p);
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Z family protocols shutdown.
+ *
+ * Z transport and Z network layer will be shutdown.
+ *
+ * @param [in] Communication_p Communication module context.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e Z_Family_Shutdown(Communication_t *Communication_p)
+{
+ ErrorCode_e ReturnValue = E_INVALID_INPUT_PARAMETERS;
+
+ if (NULL == Communication_p) {
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ ReturnValue = Z_Transport_Shutdown(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+
+ ReturnValue = Z_Network_Shutdown(Communication_p);
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);
+ free(Communication_p->FamilyContext_p);
+ Communication_p->FamilyContext_p = NULL;
+
+ if (NULL != Communication_p->BackupCommBuffer_p) {
+ free(Communication_p->BackupCommBuffer_p);
+ Communication_p->BackupCommBuffer_p = NULL;
+ }
+
+ Communication_p->BackupCommBufferSize = 0;
+ Communication_p->CurrentFamilyHash = HASH_NONE;
+
+ErrorExit:
+
+ return ReturnValue;
+}
+
+/*
+ * Z family Cancel Transmition.
+ *
+ * @param [in] Communication_p Communication module context.
+ * @param [in] PacketsBeforeTransferStop Number of packets that will be transmited before stopping the transmition.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS Invalid input parameter.
+ */
+ErrorCode_e Z_CancelReceiver(Communication_t *Communication_p, uint8 PacketsBeforeReceiverStop)
+{
+ ErrorCode_e ReturnValue = E_SUCCESS;
+
+ VERIFY(NULL != Communication_p, E_INVALID_INPUT_PARAMETERS);
+
+ Z_NETWORK(Communication_p)->Inbound.PacketsBeforeReceiverStop = PacketsBeforeReceiverStop;
+ Z_NETWORK(Communication_p)->Inbound.StopTransfer = TRUE;
+
+ErrorExit:
+ A_(printf("protrom_family.c(%d) ErrorCode=%d\n", __LINE__, ReturnValue);)
+ return ReturnValue;
+}
+
+/** @} */
+/** @} */
+/** @} */
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344.c b/lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344.c
new file mode 100644
index 0000000..79845d6
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344.c
@@ -0,0 +1,289 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+/**
+ * @file ADbg_cnh1606344.c
+ *
+ * @brief Test cases for CNH1606344 module.
+ *
+ * This file consist of test cases for autometic testing functions from
+ * CNH1606344 module.
+ */
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "r_adbg.h"
+#include "r_adbg_assert.h"
+#include "r_adbg_case.h"
+#include "r_adbg_module.h"
+#include "r_adbg_command.h"
+#include "r_communication_service.h"
+#include "r_memmory_utils.h"
+
+/*******************************************************************************
+ * The test case functions declarations
+ ******************************************************************************/
+// A2_Family
+
+// Communication_service
+static void ADbg_Do_Communication_Initialize(ADbg_Case_t *Case_p);
+static void ADbg_Do_Communication_Shutdown(ADbg_Case_t *Case_p);
+static void ADbg_Do_Communication_SetFamily(ADbg_Case_t *Case_p);
+static void ADbg_Do_Communication_Poll(ADbg_Case_t *Case_p);
+static void ADbg_Do_Communication_Send(ADbg_Case_t *Case_p);
+static void ADbg_Do_Communication_SetProtocolTimeouts(ADbg_Case_t *Case_p);
+static void ADbg_Do_Communication_GetProtocolTimeouts(ADbg_Case_t *Case_p);
+
+// Protrom_family
+
+/*******************************************************************************
+ * The test case definitions
+ ******************************************************************************/
+// A2_Family
+
+// Communication_service
+static uint8 Parameters2_1[7] = {6, WORDPTR, WORD, WORDPTR, WORDPTR, WORD, WORD};
+ADBG_CASE_DEFINE(Test_Do_Communication_Initialize, 1, 15, ADbg_Do_Communication_Initialize, Parameters2_1);
+static uint8 Parameters2_2[3] = {2, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_Do_Communication_Shutdown, 2, 15, ADbg_Do_Communication_Shutdown, Parameters2_2);
+static uint8 Parameters2_3[5] = {4, WORDPTR, WORD, WORD, WORD};
+ADBG_CASE_DEFINE(Test_Do_Communication_SetFamily, 3, 15, ADbg_Do_Communication_SetFamily, Parameters2_3);
+static uint8 Parameters2_4[2] = {1, WORDPTR};
+ADBG_CASE_DEFINE(Test_Do_Communication_Poll, 4, 15, ADbg_Do_Communication_Poll, Parameters2_4);
+static uint8 Parameters2_5[4] = {3, WORDPTR, VOIDPTR, WORD};
+ADBG_CASE_DEFINE(Test_Do_Communication_Send, 5, 15, ADbg_Do_Communication_Send, Parameters2_5);
+static uint8 Parameters2_6[4] = {3, WORDPTR, VOIDPTR, WORD};
+ADBG_CASE_DEFINE(Test_Do_Communication_SetProtocolTimeouts, 6, 15, ADbg_Do_Communication_SetProtocolTimeouts, Parameters2_6);
+static uint8 Parameters2_7[4] = {3, WORDPTR, VOIDPTR, WORD};
+ADBG_CASE_DEFINE(Test_Do_Communication_GetProtocolTimeouts, 7, 15, ADbg_Do_Communication_GetProtocolTimeouts, Parameters2_7);
+
+/*******************************************************************************
+* The test case suite definition
+******************************************************************************/
+ADBG_SUITE_DEFINE_BEGIN(TestCase_CNH1606344, 0, 15)
+
+// A2_Family
+
+// Communication_service
+ADBG_SUITE_ENTRY(Test_Do_Communication_Initialize)
+ADBG_SUITE_ENTRY(Test_Do_Communication_Shutdown)
+ADBG_SUITE_ENTRY(Test_Do_Communication_SetFamily)
+ADBG_SUITE_ENTRY(Test_Do_Communication_Poll)
+ADBG_SUITE_ENTRY(Test_Do_Communication_Send)
+ADBG_SUITE_ENTRY(Test_Do_Communication_SetProtocolTimeouts)
+ADBG_SUITE_ENTRY(Test_Do_Communication_GetProtocolTimeouts)
+
+ADBG_SUITE_DEFINE_END();
+
+/*******************************************************************************
+ * Case runner
+ ******************************************************************************/
+void Do_CNH1606344_Module_Test_Run(ADbg_MainModule_t *MainModule_p)
+{
+ ADbg_Module_t *Module_p = Do_ADbg_Module_Create(TestCase_CNH1606344, NULL, MainModule_p->Command_p, MainModule_p->Result_p);
+ Do_ADbg_InModule_Command(Module_p);
+ Do_ADbg_Module_Destroy(Module_p);
+}
+/*******************************************************************************
+ * Test cases
+ ******************************************************************************/
+// A2_Family
+
+// Communication_service
+/**
+ * This function will test function:
+ * Do_Communication_Initialize.
+ * Function used in: Test_Do_Communication_Initialize.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_Initialize(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ Family_t Family;
+ HashDevice_t *HashDevice_p;
+ CommunicationDevice_t *CommunicationDevice_p;
+ Do_CEH_Call_t CommandCallback_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+
+ Do_ADbg_GetDataVar(sizeof(Family_t), &Var_p, &Family);
+
+ HashDevice_p = Do_ADbg_GetDataPointer(sizeof(HashDevice_t), (void **)&Var_p);
+ CommunicationDevice_p = Do_ADbg_GetDataPointer(sizeof(CommunicationDevice_t), (void **)&Var_p);
+
+ Do_ADbg_GetDataVar(sizeof(Do_CEH_Call_t), &Var_p, &CommandCallback_p);
+
+ Result = Do_Communication_Initialize(Communication_p, Family, HashDevice_p, CommunicationDevice_p, CommandCallback_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+ BUFFER_FREE(HashDevice_p);
+ BUFFER_FREE(CommunicationDevice_p);
+
+}
+
+/**
+ * This function will test function:
+ * Do_Communication_Shutdown.
+ * Function used in: Test_Do_Communication_Shutdown.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_Shutdown(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t **Communication_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+
+ Result = Do_Communication_Shutdown(Communication_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+}
+
+/**
+ * This function will test function:
+ * Do_Communication_SetFamily.
+ * Function used in: Test_Do_Communication_SetFamily.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_SetFamily(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ Family_t Family;
+ uint8 *Var_p = NULL;
+ Do_CEH_Call_t CEHCallback = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+
+ Do_ADbg_GetDataVar(sizeof(Family_t), &Var_p, &Family);
+ Do_ADbg_GetDataVar(sizeof(Do_CEH_Call_t), &Var_p, &CEHCallback);
+
+ Result = Do_Communication_SetFamily(Communication_p, Family, CEHCallback);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+}
+
+/**
+ * This function will test function:
+ * Do_Communication_Poll.
+ * Function used in: Test_Do_Communication_Poll.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_Poll(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+
+ Do_Communication_Poll(Communication_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+}
+
+/**
+ * This function will test function:
+ * Do_Communication_Send.
+ * Function used in: Test_Do_Communication_Send.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_Send(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ void *InputData_p = NULL;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+ InputData_p = Do_ADbg_GetDataPointer(sizeof(void *), (void **)&Var_p);
+
+ Result = Do_Communication_Send(Communication_p, InputData_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+ BUFFER_FREE(InputData_p);
+
+}
+
+/**
+ * This function will test function:
+ * Do_Communication_SetProtocolTimeouts.
+ * Function used in: Test_Do_Communication_SetProtocolTimeouts.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_SetProtocolTimeouts(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ void *TimeoutData_p = NULL;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+ TimeoutData_p = Do_ADbg_GetDataPointer(sizeof(void *), (void **)&Var_p);
+
+ Result = Do_Communication_SetProtocolTimeouts(Communication_p, TimeoutData_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+ BUFFER_FREE(TimeoutData_p);
+}
+
+/**
+ * This function will test function:
+ * Do_Communication_GetProtocolTimeouts.
+ * Function used in: Test_Do_Communication_GetProtocolTimeouts.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_GetProtocolTimeouts(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ void *TimeoutData_p = NULL;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+ TimeoutData_p = Do_ADbg_GetDataPointer(sizeof(void *), (void **)&Var_p);
+
+ Result = Do_Communication_GetProtocolTimeouts(Communication_p, &TimeoutData_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+ BUFFER_FREE(TimeoutData_p);
+}
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344.h b/lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344.h
new file mode 100644
index 0000000..02d6a9a
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344.h
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef ADBG_CNH1606344_H_
+#define ADBG_CNH1606344_H_
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+
+/* @} */
+#endif /*ADBG_CNH1606344_H_*/
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344_utilities.c b/lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344_utilities.c
new file mode 100644
index 0000000..82c0606
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344_utilities.c
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+/**
+ * @file ADbg_cnh1606344_utilities.c
+ *
+ * @brief Interface functions for CNH1606344 module.
+ *
+ * This file consist of interface functions for setting preconditions
+ * for automatic testing functions from CNH1606344 module.
+ */
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "r_adbg.h"
+#include "r_adbg_int_function.h"
+#include "r_adbg_int_group.h"
+#include "r_adbg_command.h"
+#include "r_adbg_module.h"
+#include "r_communication_service.h"
+#include "ADbg_cnh1606344_utilities.h"
+
+/*******************************************************************************
+ * The interface functions declarations
+ ******************************************************************************/
+
+static void ADbg_IntGroup1_CNH1606344_Group(ADbg_Module_t *Module_p);
+/** Functions used for set the global variables. */
+static void ADbg_Test_Function1_CNH1606344(ADbg_IntFunction_t *IntFunction_p);
+
+/*******************************************************************************
+ * The interface group definitions
+ ******************************************************************************/
+//ADBG_INTERFACE_GROUP_DEFINE(InterfaceGroupName, InterfaceGroupId, ModuleId, InterfaceFunctionRunner)
+ADBG_INTERFACE_GROUP_DEFINE(Test_IntGroup1_CNH1606344_Group, 1, 15, ADbg_IntGroup1_CNH1606344_Group);
+
+/*******************************************************************************
+ * The interface function definitions
+ ******************************************************************************/
+
+static uint8 Param1[2] = {1, WORD};
+static uint8 Param2[4];
+ADBG_INTERFACE_FUNCTION_DEFINE(Test_Function1_CNH1606344, 1, 1, 15, ADbg_Test_Function1_CNH1606344, Param1, Param2);
+
+/*******************************************************************************
+ * The interface group suite definition
+ ******************************************************************************/
+//ADBG_INTERFACE_GROUP_SUITE_DEFINE_BEGIN(TestIntGroup_CNH1606344, 0, ModuleId)
+ADBG_INTERFACE_GROUP_SUITE_DEFINE_BEGIN(IntGroup_CNH1606344, 0, 15)
+
+//ADBG_INTERFACE_GROUP_SUITE_ENTRY(InterfaceGroupName)
+ADBG_INTERFACE_GROUP_SUITE_ENTRY(Test_IntGroup1_CNH1606344_Group)
+
+ADBG_INTERFACE_GROUP_SUITE_DEFINE_END();
+
+/*******************************************************************************
+ * The interface functions suites definition
+ ******************************************************************************/
+//ADBG_INTERFACE_FUNCTION_SUITE_DEFINE_BEGIN(TestIntFunctionSuiteName, 0, IntGroupId, ModuleId)
+
+ADBG_INTERFACE_FUNCTION_SUITE_DEFINE_BEGIN(IntGroup1_CNH1606344, 0, 1, 15)
+
+ADBG_INTERFACE_FUNCTION_SUITE_ENTRY(Test_Function1_CNH1606344) //InterfaceFunctionName
+
+ADBG_INTERFACE_FUNCTION_SUITE_DEFINE_END();
+
+/*******************************************************************************
+ * Interface group runner
+ ******************************************************************************/
+void Do_CNH1606344_Module_Interface_Run(ADbg_MainModule_t *MainModule_p)
+{
+ ADbg_Module_t *Module_p = Do_ADbg_Module_Create(NULL, IntGroup_CNH1606344, MainModule_p->Command_p, MainModule_p->Result_p);
+ Do_ADbg_InModule_Command(Module_p);
+ Do_ADbg_Module_Destroy(Module_p);
+}
+
+/*******************************************************************************
+ * Interface functions from group1 runner
+ ******************************************************************************/
+static void ADbg_IntGroup1_CNH1606344_Group(ADbg_Module_t *Module_p)
+{
+ ADbg_IntGroup_t *IntGroup1_p = Do_ADbg_IntGroup_Create(IntGroup1_CNH1606344, Module_p->Command_p, Module_p->Result_p);
+ Do_ADbg_InIntGroup_Command(IntGroup1_p);
+ Do_ADbg_IntGroup_Destroy(IntGroup1_p);
+}
+
+/**
+ * @brief Interface function.
+ *
+ * This function...
+ *
+ * @param [in] IntFunction_p is pointer.
+ * @return void.
+ */
+static void ADbg_Test_Function1_CNH1606344(ADbg_IntFunction_t *IntFunction_p)
+{
+ uint32 Param;
+
+ //...
+ Do_ADbg_SetAndRecoveryCondition((void *)&Param, Param2, sizeof(uint32), IntFunction_p);
+}
+
+/* @} */
diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344_utilities.h b/lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344_utilities.h
new file mode 100644
index 0000000..4b65b3b
--- /dev/null
+++ b/lcmodule/source/cnh1606344_ldr_communication_module/test_cases/ADbg_cnh1606344_utilities.h
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef ADBG_CNH1606344_UTILITIES_H_
+#define ADBG_CNH1606344_UTILITIES_H_
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+
+/* @} */
+#endif /*ADBG_CNH1606344_UTIILITIES_H_*/
diff --git a/lcmodule/source/legacy_compatibility/c_compiler.h b/lcmodule/source/legacy_compatibility/c_compiler.h
new file mode 100644
index 0000000..90799b1
--- /dev/null
+++ b/lcmodule/source/legacy_compatibility/c_compiler.h
@@ -0,0 +1,124 @@
+/******************************************************************************
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+******************************************************************************/
+#ifndef _C_COMPILER_H
+#define _C_COMPILER_H
+
+/*************************************************************************
+*
+* HEADER SPECIFICATION
+*
+* $Workfile: c_compiler.h $
+*
+**************************************************************************
+*
+* DESCRIPTION:
+*
+* This file contains macros that determines current compiler
+*
+*
+**************************************************************************
+*
+* REVISION HISTORY:
+*
+* $Log: \LD_FuncBlocks_012\cnh160692_exec_pltf_srv_swbp\inc\c_compiler.h $
+ *
+ * Version: ...\cnh160692_r1a_dev\3 12 Mar 2002 14:21 (GMT) QCSSTZI
+ * rename p_compiler to c_compiler.
+ *
+ * Version: ...\cnh160692_r1a_dev\2 10 Jan 2002 12:35 (GMT) QCSSTZI
+ * Updated to reflect R4A013 on the old module (cnh1010024)
+ *
+ * Version: ...\cnh1010024_r4a_dev\1 11 Sep 2001 07:34 (GMT) QCSPAAB
+ * Merge to Valentina (R4)
+ *
+ * Version: ...\cnh1010024\1 14 Nov 2000 15:30 (GMT) ECSJENE
+ * Merge to start new dev-branch for the Mia project.
+ *
+ * Version: ...\cnh1010024_r2a_dev\4 05 Oct 2000 06:25 (GMT) ECSSTMA
+ * Macro to remove non_banked directive.
+ *
+ * Version: ...\cnh1010024_r2a_dev\3 19 Sep 2000 12:38 (GMT) QCSLAIS
+ * Compiler warnings work around.
+ *
+ * Version: ...\cnh1010024_r2a_dev\2 22 May 2000 08:25 (GMT) ECSSTMA
+ * Accept LINT as being one among the compilers.
+ *
+ * Version: ...\cnh1010024_r2a_dev\1 16 May 2000 12:19 (GMT) QCSLAIS
+ * Created file compiler.h which determines current compiler and target
+*
+**************************************************************************/
+
+#if defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__)
+/* COMPILER IS FROM IAR */
+#if ((__TID__ >> 8) & 0x7f) == 23
+/* TARGET IS Z80 */
+#define COMPILER_IAR_Z80
+#elif ((__TID__ >> 8) & 0x7f) == 90
+/* TARGET IS AVR */
+#define COMPILER_IAR_AVR /* Preferred */
+#define COMPILER_AVR
+#define AT90S
+#elif ((__TID__ >> 8) & 0x7f) == 0x4f
+/* TARGET IS ARM */
+#define COMPILER_IAR_ARM /* Preferred */
+#define COMPILER_ARM
+#define ARM
+#else
+#error Unknown IAR compiler
+#endif
+#elif defined(_WIN32)
+/* TARGET IS Win32 */
+#define COMPILER_MSDEV
+#define __arm
+#define __pcs
+#define __no_init
+#elif defined(__arm)
+/* TARGET IS ARM */
+#define COMPILER_ARM_ARM /* Preferred */
+#define COMPILER_ARM
+#define ARM
+#elif defined(__GNUC__)
+#ifdef __arm__
+#define COMPILER_GCC_ARM
+#elif defined(__linux__)
+/* TARGET IS LINUX */
+#define COMPILER_GCC
+#endif
+#elif defined(__IAR_SYSTEMS_ASM__)
+#elif defined(_lint)
+#else
+#error Unknown compiler
+#endif
+
+/*
+ * Some compiler bug work arounds.
+ */
+
+/*
+ * Avoid ARM compiler error when comparing NULL with a pointer
+ * by defining NULL as NULL pointer.
+ */
+#if defined(COMPILER_ARM_ARM) && !defined(NULL)
+#ifdef __cplusplus
+#define NULL 0
+#else
+#define NULL ((void *)0)
+#endif
+#endif
+
+/*
+ * Some modules still use the unused banked prefix.
+ */
+#ifndef banked
+#define banked
+#endif
+
+#ifndef non_banked
+#define non_banked
+#endif
+
+#endif // _C_COMPILER_H
diff --git a/lcmodule/source/legacy_compatibility/c_system.h b/lcmodule/source/legacy_compatibility/c_system.h
new file mode 100644
index 0000000..fe65751
--- /dev/null
+++ b/lcmodule/source/legacy_compatibility/c_system.h
@@ -0,0 +1,34 @@
+#ifndef INCLUSION_GUARD_C_SYSTEM_H
+#define INCLUSION_GUARD_C_SYSTEM_H
+
+/*************************************************************************
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+**************************************************************************
+*
+* DESCRIPTION:
+*
+* System configuration include file. This file must be the first
+* file included by every source (*.c) file in the system
+*
+*************************************************************************/
+
+/*************************************************************************
+* Includes
+*************************************************************************/
+
+#include "c_compiler.h"
+
+//#include "product.h"
+
+/*************************************************************************
+* Types, constants and external variables
+*************************************************************************/
+
+
+
+#endif // INCLUSION_GUARD_C_SYSTEM_H
+
+
+
+
diff --git a/lcmodule/source/legacy_compatibility/r_basicdefinitions.h b/lcmodule/source/legacy_compatibility/r_basicdefinitions.h
new file mode 100644
index 0000000..35bf0bc
--- /dev/null
+++ b/lcmodule/source/legacy_compatibility/r_basicdefinitions.h
@@ -0,0 +1,168 @@
+/******************************************************************************
+* $Workfile: r_basicdefinitions.h $
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+* DESCRIPTION:
+*
+* Portable types used for a consistent target platform.
+* The name should make it totally clear as to what they are used for.
+*
+*
+*/
+
+#ifndef _R_BASICDEFINITIONS_H
+#define _R_BASICDEFINITIONS_H
+
+#include "t_basicdefinitions.h"
+
+/********************
+* General macro's
+* These should be moved to a utility header when we have a good file name put it in.
+*********************/
+/**
+ * Returns the smallest value of x and y.
+ *
+ * @param [in] x Value of any scalar type
+ * @param [in] y Value of any scalar type
+ *
+ * @return The return type obeys the rules regarding binary conversion of the
+ * programming language C.
+ *
+ * @sigbased No - Macro, parameters expand more than one time
+ */
+#ifndef MIN
+#define MIN(val1, val2) (((val1) < (val2)) ? (val1) : (val2))
+#endif
+
+/**
+ * Returns the largest value of x and y.
+ *
+ * @param [in] x Value of any scalar type
+ * @param [in] y Value of any scalar type
+ *
+ * @return The return type obeys the rules regarding binary conversion of the
+ * programming language C.
+ *
+ * @sigbased No - Macro, parameters expand more than one time
+ */
+#ifndef MAX
+#define MAX(val1, val2) (((val1) > (val2)) ? (val1) : (val2))
+#endif
+
+/**
+ * The return value is evaluated at compile time, not at run-time. The return
+ * value can be used as dimension parameter in other declarations of other
+ * arrays. The return value can however not be used in expressions evaluated in
+ * pre-processor directives (e.g. #if (ElementsOf(a) > 10)) since it is based on
+ * the sizeof() operator.
+ *
+ * @param [in] a Must be an array variable or array type
+ *
+ * @return Number of elements in the array passed as parameter.
+ *
+ * @sigbased No - Macro, parameters expand more than one time
+ */
+#ifndef ElementsOf
+#define ElementsOf(array) (sizeof(array) / sizeof(array[0]))
+#endif
+
+
+/*****************************
+* Macro's to extract bytes from uint16 or sint16
+******************************/
+/**
+ * Used to retrieve the least significant 8 bits of a 16 bit word.
+ *
+ * @param [in] w A value of type uint16
+ *
+ * @return Returns value of type uint8 representing the low byte of the value
+ * passed as parameter.
+ *
+ * @sigbased No - Macro
+ */
+#define INT16_LBYTE(i) (uint8)((i) & 0xFF)
+
+/**
+ * Used to retrieve the most significant 8 bits of a 16 bit word.
+ *
+ * @param [in] w A value of type uint16
+ *
+ * @return Returns value of type uint8 representing the high byte of the value
+ * passed as parameter.
+ *
+ * @sigbased No - Macro
+ */
+#define INT16_HBYTE(i) (uint8)((i) >> 8)
+
+/*****************************
+* Macro's to build int16 from two bytes (low & high)
+******************************/
+/**
+ * Used to form a 16 bit signed value from two 8 bit values. The result will
+ * be negative if the most significant bit (MSB) of the HighByte parameter is
+ * a one, otherwise positive.
+ *
+ * @param [in] LowByte Defines the value that will be in the low byte of the
+ * returned sint16 value.
+ * @param [in] HighByte Defines the value that will be in the high byte of the
+ * returned sint16 value.
+ *
+ * @return Returns value of type sint16 constructed from two byte values.
+ *
+ * @sigbased No - Macro
+ */
+#define BYTES_TO_SINT16(l,h) (sint16)((h << 8) + l)
+
+/**
+ * Used to form a 16 bit unsigned value from two 8 bit values.
+ *
+ * @param [in] LowByte Defines the value that will be in the low byte of the
+ * returned sint16 value.
+ * @param [in] HighByte Defines the value that will be in the high byte of the
+ * returned sint16 value.
+ *
+ * @return Returns value of type uint16 constructed from two byte values.
+ *
+ * @sigbased No - Macro
+ */
+#define BYTES_TO_UINT16(l,h) (uint16)((h << 8) + l)
+
+/*
+**========================================================================
+**
+** MACRO TO AVOID WARNINGS FOR UNUSED PARAMETERS OR VARIABLE
+**
+** Example of use:
+**
+** int MyFunc(int p)
+** {
+** int a = 42;
+** NOT_USED(p); // This line must be placed after declaration of local variables.
+**
+** return a;
+** }
+**
+**========================================================================
+*/
+
+
+#ifdef IDENTIFIER_NOT_USED
+#undef IDENTIFIER_NOT_USED
+#endif
+
+//#define IDENTIFIER_NOT_USED(p) if (sizeof(&p)) {}
+// this seems to work better under lint:
+/**
+ * Should be used to "touch" a variable or a formal parameter that is intentionally
+ * not used and thereby avoid compiler warnings.
+ *
+ * @param [in] Id A symbol that represents a variable that is not used, usually a
+ * formal parameter.
+ *
+ * @sigbased No - Macro
+ */
+#define IDENTIFIER_NOT_USED(P) (void)(P);
+
+#endif //_R_BASICDEFINITIONS_H
diff --git a/lcmodule/source/legacy_compatibility/r_debug.h b/lcmodule/source/legacy_compatibility/r_debug.h
new file mode 100644
index 0000000..6c6c280
--- /dev/null
+++ b/lcmodule/source/legacy_compatibility/r_debug.h
@@ -0,0 +1,360 @@
+#ifndef INCLUSION_GUARD_R_DEBUG_H
+#define INCLUSION_GUARD_R_DEBUG_H
+
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include <stdio.h>
+#include "t_basicdefinitions.h"
+
+/* Disable printouts if debug subsystem is disabled */
+#ifndef ENABLE_DEBUG
+#define DISABLE_PRINT_ALL_
+#endif
+
+// Disable flags ( "command line #undef" )
+#ifdef DISABLE_PRINT_A_
+#undef PRINT_A_
+#endif
+#ifdef DISABLE_PRINT_B_
+#undef PRINT_B_
+#endif
+#ifdef DISABLE_PRINT_C_
+#undef PRINT_C_
+#endif
+#ifdef DISABLE_PRINT_ALL_
+#undef PRINT_C_
+#undef PRINT_B_
+#undef PRINT_A_
+#endif
+
+#if defined(PRINT_A_)
+#define PRINT_LEVEL_A_
+#endif
+
+#if defined(PRINT_B_)
+#define PRINT_LEVEL_B_
+#endif
+
+#if defined(PRINT_C_)
+#define PRINT_LEVEL_C_
+#endif
+
+#if defined(PRINT_A_) || defined(PRINT_B_)
+#define PRINT_LEVEL_A_B_
+#endif
+
+#if defined(PRINT_A_) || defined(PRINT_C_)
+#define PRINT_LEVEL_A_C_
+#endif
+
+#if defined(PRINT_B_) || defined(PRINT_C_)
+#define PRINT_LEVEL_B_C_
+#endif
+
+#if defined(PRINT_A_) || defined(PRINT_B_) || defined(PRINT_C_)
+#define PRINT_LEVEL_A_B_C_
+#endif
+
+#define A_(_PAR_)
+#define A_ASSERT_(exp)
+#define B_(_PAR_)
+#define B_ASSERT_(exp)
+#define C_(_PAR_)
+#define C_ASSERT_(exp)
+#define A_B_(p)
+#define A_B_ASSERT_(bool)
+#define A_C_(p)
+#define A_C_ASSERT_(bool)
+#define B_C_(p)
+#define B_C_ASSERT_(bool)
+#define A_B_C_(p)
+#define A_B_C_ASSERT_(bool)
+
+#ifdef _WIN32
+//#pragma message("COMPILING FOR WIN32")
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+ int _TraceEnter(int Level);
+ void _TraceExit(int Level);
+ void _TraceAssert(void *, void *, unsigned);
+#ifdef __cplusplus
+} // extern "C" {
+#endif
+
+#define _ABCTRACE(_PAR_, _ABC_) if (_TraceEnter(_ABC_)) {_PAR_; _TraceExit(_ABC_);}
+#define _ASSERT(exp) (void)( (exp) || (_TraceAssert(#exp, __FILE__, __LINE__), 0) )
+
+#ifdef PRINT_A_
+#undef A_
+#define A_(_PAR_) _ABCTRACE(_PAR_, 'A')
+#undef A_ASSERT_
+#define A_ASSERT_(exp) _ASSERT(exp)
+#endif
+#ifdef PRINT_B_
+#undef B_
+#define B_(_PAR_) _ABCTRACE(_PAR_, 'B')
+#undef B_ASSERT_
+#define B_ASSERT_(exp) _ASSERT(exp)
+#endif
+#ifdef PRINT_C_
+#undef C_
+#define C_(_PAR_) _ABCTRACE(_PAR_, 'C')
+#undef C_ASSERT_
+#define C_ASSERT_(exp) _ASSERT(exp)
+#endif
+#ifdef PRINT_LEVEL_A_B_
+#undef A_B_
+#define A_B_(_PAR_) _ABCTRACE(_PAR_, 'A')
+#undef A_B__ASSERT_
+#define A_B__ASSERT_(exp) _ASSERT(exp)
+#endif
+#ifdef PRINT_LEVEL_A_C_
+#undef A_C_
+#define A_C_(_PAR_) _ABCTRACE(_PAR_, 'A')
+#undef A_C_ASSERT_
+#define A_C_ASSERT_(exp) _ASSERT(exp)
+#endif
+#ifdef PRINT_LEVEL_B_C_
+#undef B_C_
+#define B_C_(_PAR_) _ABCTRACE(_PAR_, 'B')
+#undef B_C_ASSERT_
+#define B_C_ASSERT_(exp) _ASSERT(exp)
+#endif
+#ifdef PRINT_LEVEL_A_B_C_
+#undef A_B_C_
+#define A_B_C_(_PAR_) _ABCTRACE(_PAR_, 'A')
+#undef A_B_C_ASSERT_
+#define A_B_C_ASSERT_(exp) _ASSERT(exp)
+#endif
+
+#ifndef PRINT_LEVEL_IS_SETTABLE
+// We Can remove this TRACE_IS_SETTABLE test when:
+// * We do not have constructions with functions inserted in A_ macro's like: A_(void foo(void);)
+// beacause an if statement will be prefixed to the _PAR_ experssion
+#ifdef PRINT_A_
+#undef A_
+#define A_(_PAR_) _PAR_
+#undef A_ASSERT_
+#define A_ASSERT_(exp) _ASSERT(exp)
+#endif
+#ifdef PRINT_B_
+#undef B_
+#define B_(_PAR_) _PAR_
+#undef B_ASSERT_
+#define B_ASSERT_(exp) _ASSERT(exp)
+#endif
+#ifdef PRINT_C_
+#undef C_
+#define C_(_PAR_) _PAR_
+#undef C_ASSERT_
+#define C_ASSERT_(exp) _ASSERT(exp)
+#endif
+#ifdef PRINT_LEVEL_A_B_
+#undef A_B_
+#define A_B_(_PAR_) _PAR_
+#undef A_B__ASSERT_
+#define A_B__ASSERT_(exp) _ASSERT(exp)
+#endif
+#ifdef PRINT_LEVEL_A_C_
+#undef A_C_
+#define A_C_(_PAR_) _PAR_
+#undef A_C_ASSERT_
+#define A_C_ASSERT_(exp) _ASSERT(exp)
+#endif
+#ifdef PRINT_LEVEL_B_C_
+#undef B_C_
+#define B_C_(_PAR_) _PAR_
+#undef B_C_ASSERT_
+#define B_C_ASSERT_(exp) _ASSERT(exp)
+#endif
+#ifdef PRINT_LEVEL_A_B_C_
+#undef A_B_C_
+#define A_B_C_(_PAR_) _PAR_
+#undef A_B_C_ASSERT_
+#define A_B_C_ASSERT_(exp) _ASSERT(exp)
+#endif
+#endif // PRINT_LEVEL_IS_SETTABLE
+
+#else // _WIN32
+
+#ifdef BSYS_ASSERT_CAUSE_DUMP
+extern void p_assert_dump(const char *, unsigned int);
+
+#define _ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ p_assert_dump(__FILE__, __LINE__); \
+ } \
+ } while (0)
+#else
+extern void p_assert_print(const char *, unsigned int);
+
+#define _ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ p_assert_print(__FILE__, __LINE__); \
+ } \
+ } while (0)
+#endif /* BSYS_ASSERT_CAUSE_DUMP */
+
+#undef A_
+#undef A_ASSERT_
+#ifdef PRINT_A_
+#define A_(p) p
+#define A_ASSERT_(bool) _ASSERT(bool)
+#else
+#define A_(p)
+#define A_ASSERT_(bool)
+#endif
+
+#undef B_
+#undef B_ASSERT_
+#ifdef PRINT_B_
+#define B_(p) p
+#define B_ASSERT_(bool) _ASSERT(bool)
+#else
+#define B_(p)
+#define B_ASSERT_(bool)
+#endif
+
+#undef C_
+#undef C_ASSERT_
+#ifdef PRINT_C_
+#define C_(p) p
+#define C_ASSERT_(bool) _ASSERT(bool)
+#else
+#define C_(p)
+#define C_ASSERT_(bool)
+#endif
+
+#undef A_B_
+#undef A_B_ASSERT_
+#ifdef PRINT_LEVEL_A_B_
+#define A_B_(p) p
+#define A_B_ASSERT_(bool) _ASSERT(bool)
+#else
+#define A_B_(p)
+#define A_B_ASSERT_(bool)
+#endif
+
+#undef A_C_
+#undef A_C_ASSERT_
+#ifdef PRINT_LEVEL_A_C_
+#define A_C_(p) p
+#define A_C_ASSERT_(bool) _ASSERT(bool)
+#else
+#define A_C_(p)
+#define A_C_ASSERT_(bool)
+#endif
+
+#undef B_C_
+#undef B_C_ASSERT_
+#ifdef PRINT_LEVEL_B_C_
+#define B_C_(p) p
+#define B_C_ASSERT_(bool) _ASSERT(bool)
+#else
+#define B_C_(p)
+#define B_C_ASSERT_(bool)
+#endif
+
+#undef A_B_C_
+#undef A_B_C_ASSERT_
+#ifdef PRINT_LEVEL_A_B_C_
+#define A_B_C_(p) p
+#define A_B_C_ASSERT_(bool) _ASSERT(bool)
+#else
+#define A_B_C_(p)
+#define A_B_C_ASSERT_(bool)
+#endif
+
+#endif // else _WIN32
+
+/*
+ * Obsolete TAE debugging. A_(), B_(), etc. should be used in new code.
+ */
+#if defined(PRINT_TA_)
+
+#define DbgTrace1(msg) printf(msg)
+#define DbgTrace2(msg,a1) printf(msg,a1)
+#define DbgTrace3(msg,a1,a2) printf(msg,a1,a2)
+#define DbgTrace4(msg,a1,a2,a3) printf(msg,a1,a2,a3)
+#define DbgTrace5(msg,a1,a2,a3,a4) printf(msg,a1,a2,a3,a4)
+#define DbgTrace6(msg,a1,a2,a3,a4,a5) printf(msg,a1,a2,a3,a4,a5)
+#define DbgTrace7(msg,a1,a2,a3,a4,a5,a6) printf(msg,a1,a2,a3,a4,a5,a6)
+#define DbgTrace8(msg,a1,a2,a3,a4,a5,a6,a7) printf(msg,a1,a2,a3,a4,a5,a6,a7)
+
+#else
+
+#define DbgTrace1(msg)
+#define DbgTrace2(msg,a1)
+#define DbgTrace3(msg,a1,a2)
+#define DbgTrace4(msg,a1,a2,a3)
+#define DbgTrace5(msg,a1,a2,a3,a4)
+#define DbgTrace6(msg,a1,a2,a3,a4,a5)
+#define DbgTrace7(msg,a1,a2,a3,a4,a5,a6)
+#define DbgTrace8(msg,a1,a2,a3,a4,a5,a6,a7)
+
+#endif
+
+#if defined(PRINT_TA_)
+
+#define LLPRE2(expr) do{ if(expr){ printf("WARNING: ");
+#define LLPOST2 }}while(0)
+
+#define DbgIf_Warn1(expr,msg) LLPRE2(expr) printf(msg); LLPOST2
+#define DbgIf_Warn2(expr,msg,a1) LLPRE2(expr) printf(msg,a1); LLPOST2
+#define DbgIf_Warn3(expr,msg,a1,a2) LLPRE2(expr) printf(msg,a1,a2); LLPOST2
+#define DbgIf_Warn4(expr,msg,a1,a2,a3) LLPRE2(expr) printf(msg,a1,a2,a3); LLPOST2
+#define DbgIf_Warn5(expr,msg,a1,a2,a3,a4) LLPRE2(expr) printf(msg,a1,a2,a3,a4); LLPOST2
+#define DbgIf_Warn6(expr,msg,a1,a2,a3,a4,a5) LLPRE2(expr) printf(msg,a1,a2,a3,a4,a5); LLPOST2
+#define DbgIf_Warn7(expr,msg,a1,a2,a3,a4,a5,a6) LLPRE2(expr) printf(msg,a1,a2,a3,a4,a5,a6); LLPOST2
+#define DbgIf_Warn8(expr,msg,a1,a2,a3,a4,a5,a6,a7) LLPRE2(expr) printf(msg,a1,a2,a3,a4,a5,a6,a7); LLPOST2
+
+#else
+
+#define DbgIf_Warn1(expr,msg)
+#define DbgIf_Warn2(expr,msg,a1)
+#define DbgIf_Warn3(expr,msg,a1,a2)
+#define DbgIf_Warn4(expr,msg,a1,a2,a3)
+#define DbgIf_Warn5(expr,msg,a1,a2,a3,a4)
+#define DbgIf_Warn6(expr,msg,a1,a2,a3,a4,a5)
+#define DbgIf_Warn7(expr,msg,a1,a2,a3,a4,a5,a6)
+#define DbgIf_Warn8(expr,msg,a1,a2,a3,a4,a5,a6,a7)
+
+#endif
+
+#define LLPRE3(expr) do{ if(expr){ printf("*FATAL* ");
+#if defined(PRINT_TA_)
+#define LLPOST3 LL_TerminateSystem(); }}while(0)
+#else
+#define LLPOST3 error(0xBABE); }}while(0)
+#endif
+
+#define DbgIf_Fatal1(expr,msg) LLPRE3(expr) printf(msg); LLPOST3
+#define DbgIf_Fatal2(expr,msg,a1) LLPRE3(expr) printf(msg,a1); LLPOST3
+#define DbgIf_Fatal3(expr,msg,a1,a2) LLPRE3(expr) printf(msg,a1,a2); LLPOST3
+#define DbgIf_Fatal4(expr,msg,a1,a2,a3) LLPRE3(expr) printf(msg,a1,a2,a3); LLPOST3
+#define DbgIf_Fatal5(expr,msg,a1,a2,a3,a4) LLPRE3(expr) printf(msg,a1,a2,a3,a4); LLPOST3
+#define DbgIf_Fatal6(expr,msg,a1,a2,a3,a4,a5) LLPRE3(expr) printf(msg,a1,a2,a3,a4,a5); LLPOST3
+#define DbgIf_Fatal7(expr,msg,a1,a2,a3,a4,a5,a6) LLPRE3(expr) printf(msg,a1,a2,a3,a4,a5,a6); LLPOST3
+#define DbgIf_Fatal8(expr,msg,a1,a2,a3,a4,a5,a6,a7) LLPRE3(expr) printf(msg,a1,a2,a3,a4,a5,a6,a7); LLPOST3
+
+
+
+// Map TA calls
+#define DbgTrace_HexDump(pData,nLength) BSYS_HexDump(pData,nLength,0)
+
+// Prototypes
+
+void BSYS_HexDump(const void *pData, int nLength, boolean DumpWithOffset);
+
+#endif // INCLUSION_GUARD_R_DEBUG_H
diff --git a/lcmodule/source/legacy_compatibility/t_basicdefinitions.h b/lcmodule/source/legacy_compatibility/t_basicdefinitions.h
new file mode 100644
index 0000000..8b453ff
--- /dev/null
+++ b/lcmodule/source/legacy_compatibility/t_basicdefinitions.h
@@ -0,0 +1,280 @@
+#ifndef INCLUSION_GUARD_T_BASICDEFINITIONS_H
+#define INCLUSION_GUARD_T_BASICDEFINITIONS_H
+
+/******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+*******************************************************************************
+*
+* $Workfile: t_basicdefinitions.h $
+*
+*******************************************************************************
+*
+* DESCRIPTION:
+*
+* Portable types used for a consistent target platform.
+* The name should make it totally clear as to what they are used for.
+*
+* For calculations:
+* -----------------
+* sint8 - signed integer 8 bits
+* uint8 - unsigned integer 8bits
+* sint16 - signed integer 16 bits
+* uint16 - unsigned integer 16 bits
+* sint32 - signed integer 32 bits
+* uint32 - unsigned integer 32 bits
+* MAX and MIN values for all integer types are also supported.
+*
+* Unsigned integer types for other purposes than calculations:
+* ------------------------------------------------------------
+* boolean - TRUE or FALSE
+*
+* Bitfield types to use in packed structs:
+* ----------------------------------------
+* sbitfield - signed bitfield
+* ubitfield - unsigned bitfield
+*
+* Bitmasks:
+* ---------
+* BIT_0 - unsigned integer of values 0x00000001
+* ...
+* BIT_31 - unsigned integer of values 0x80000000
+*
+* Enumeration:
+* ------------
+* TYPEDEF_ENUM - This macro should be used to start the defenition of a enumerated type
+* ENUM8(t) - uint8 enum
+* ENUM16(t) - uint16 enum
+* ENUM32(t) - uint32 enum
+* SIGNED_ENUM8(t) - sint8 enum
+* SIGNED_ENUM16(t) - sint16 enum
+* SIGNED_ENUM32(t) - sint32 enum
+*
+******************************************************************************/
+
+/********************
+* Include files
+*********************/
+
+#include "c_compiler.h"
+#include <limits.h>
+
+/********************
+* Portable data types
+*********************/
+
+#if defined(COMPILER_IAR_ARM) && (__VER__ >= 300)
+#define SINT64_SUPPORTED
+#define UINT64_SUPPORTED
+#define INT64_BASE_TYPE long long
+#elif defined(COMPILER_ARM_ARM)
+#define SINT64_SUPPORTED
+#define UINT64_SUPPORTED
+#define INT64_BASE_TYPE long long
+#elif defined(_WIN32)
+#define SINT64_SUPPORTED
+#define UINT64_SUPPORTED
+#define INT64_BASE_TYPE __int64
+#endif
+
+
+/** Type definition for a signed 8 bit data entity. */
+typedef signed char sint8;
+/** Type definition for an unsigned 8 bit data entity. */
+typedef unsigned char uint8;
+/** Type definition for a signed 16 bit data entity. */
+typedef signed short sint16;
+/** Type definition for an unsigned 16 bit data entity. */
+typedef unsigned short uint16;
+/** Type definition for a signed 32 bit data entity. */
+typedef signed int sint32;
+/** Type definition for an unsigned 32 bit data entity. */
+#if defined(_WIN32)
+typedef unsigned long uint32;
+#else
+typedef unsigned int uint32;
+#endif
+
+/**
+ * Type definition for a signed 64 bit data entity. Only available if the switch
+ * SINT64_SUPPORTED is defined.
+ */
+#ifdef SINT64_SUPPORTED
+typedef signed INT64_BASE_TYPE sint64;
+#endif
+
+/**
+ * Type definition for an unsigned 64 bit data entity. Only available if the
+ * switch UINT64_SUPPORTED is defined.
+ */
+#ifdef UINT64_SUPPORTED
+typedef unsigned INT64_BASE_TYPE uint64;
+#endif
+
+/*******************
+* MAX and MIN values
+********************/
+/** Minimum value for an entity of type sint8 */
+#define MIN_SINT8 (SCHAR_MIN)
+/** Maximum value for an entity of type sint8 */
+#define MAX_SINT8 (SCHAR_MAX)
+/** Maximum value for an entity of type uint8 */
+#define MAX_UINT8 (UCHAR_MAX)
+/** Minimum value for an entity of type sint16 */
+#define MIN_SINT16 (SHRT_MIN)
+/** Maximum value for an entity of type sint16 */
+#define MAX_SINT16 (SHRT_MAX)
+/** Maximum value for an entity of type uint16 */
+#define MAX_UINT16 (USHRT_MAX)
+/** Minimum value for an entity of type sint32 */
+#define MIN_SINT32 (LONG_MIN)
+/** Maximum value for an entity of type sint32 */
+#define MAX_SINT32 (LONG_MAX)
+/** Maximum value for an entity of type uint32 */
+#define MAX_UINT32 (ULONG_MAX)
+
+
+#ifdef SINT64_SUPPORTED
+/**
+ * Minimum value for an entity of type sint64. Only available if the switch
+ * SINT64_SUPPORTED is defined.
+ */
+#define MIN_SINT64 (-0x8000000000000000)
+/**
+ * Maximum value for an entity of type sint64. Only available if the switch
+ * SINT64_SUPPORTED is defined.
+ */
+#define MAX_SINT64 (0x7fffffffffffffff)
+#endif
+
+#ifdef UINT64_SUPPORTED
+/**
+ * Maximum value for an entity of type uint64. Only available if the switch
+ * UINT64_SUPPORTED is defined.
+ */
+#define MAX_UINT64 (0xffffffffffffffff)
+#endif
+
+/********************
+* boolean: TRUE/FALSE
+*********************/
+/** Type definition for a boolean/logical value */
+typedef uint8 boolean;
+
+#ifndef TRUE
+/** Value representing the boolean/logical value false. */
+#define FALSE 0
+/** Value representing the boolean/logical value true. */
+#define TRUE (!FALSE)
+#endif
+
+/******************************************
+* Portable bitfield definitions
+*******************************************/
+
+#if defined(COMPILER_IAR_AVR) || defined(COMPILER_IAR_ARM) || defined(_WIN32) || defined(COMPILER_ARM_ARM) || defined(COMPILER_GCC_ARM) || defined(COMPILER_GCC)
+/** Type definition to be used when implementing bit-fields that should hold
+ * signed values.
+ */
+typedef sint8 sbitfield;
+/** Type definition to be used when implementing bit-fields that should hold
+ * unsigned values.
+ */
+typedef uint8 ubitfield;
+#elif defined(_lint)
+typedef signed int sbitfield;
+typedef unsigned int ubitfield;
+#else
+#error Unknown preferred bitfield definition for this compiler
+#endif
+
+/*************************
+* Bit mask definitions
+**************************/
+
+/**
+* This sections defines a set of masks implemented as scalar unsigned values
+* that can be used to mask out bits of a scalar entity. The definitions are
+* named BIT_0 through BIT_31 and each implements the unsigned value of two to
+* the power of the value in the definitions name. E.g. BIT_0 implements the value of 1 while BIT_10 implements the value of 0x0400 (equals 1024 in decimal form).
+*/
+#define BIT_0 0x0001U
+#define BIT_1 0x0002U
+#define BIT_2 0x0004U
+#define BIT_3 0x0008U
+#define BIT_4 0x0010U
+#define BIT_5 0x0020U
+#define BIT_6 0x0040U
+#define BIT_7 0x0080U
+#define BIT_8 0x0100U
+#define BIT_9 0x0200U
+#define BIT_10 0x0400U
+#define BIT_11 0x0800U
+#define BIT_12 0x1000U
+#define BIT_13 0x2000U
+#define BIT_14 0x4000U
+#define BIT_15 0x8000U
+#define BIT_16 0x00010000UL
+#define BIT_17 0x00020000UL
+#define BIT_18 0x00040000UL
+#define BIT_19 0x00080000UL
+#define BIT_20 0x00100000UL
+#define BIT_21 0x00200000UL
+#define BIT_22 0x00400000UL
+#define BIT_23 0x00800000UL
+#define BIT_24 0x01000000UL
+#define BIT_25 0x02000000UL
+#define BIT_26 0x04000000UL
+#define BIT_27 0x08000000UL
+#define BIT_28 0x10000000UL
+#define BIT_29 0x20000000UL
+#define BIT_30 0x40000000UL
+#define BIT_31 0x80000000UL
+
+/*****************************
+* Macro's for fixed size enums
+*
+* Example of use:
+*
+* TYPEDEF_ENUM {
+* Def1,
+* ...,
+* Defn
+* }ENUM8 (MyEnum_t); // Or ENUM16 or ENUM32
+*
+******************************/
+/** This macro should be used to start the definition of an enumerated type. */
+#define TYPEDEF_ENUM enum
+/**
+ * This macro should be used to finalize the definition of an enumerated type
+ * "t" compatible with the uint8 data type described in section 3.1.1.
+ */
+#define ENUM8(t) ;typedef uint8 t
+/**
+ * This macro should be used to finalize the definition of an enumerated type
+ * "t" compatible with the uint16 data type described in section 3.1.1.
+ */
+#define ENUM16(t) ;typedef uint16 t
+/**
+ * This macro should be used to finalize the definition of an enumerated type
+ * "t" compatible with the uint32 data type described in section 3.1.1.
+ */
+#define ENUM32(t) ;typedef uint32 t
+/**
+ * This macro should be used to finalize the definition of an enumerated type
+ * "t" compatible with the sint8 data type described in section 3.1.1.
+ */
+#define SIGNED_ENUM8(t) ;typedef sint8 t
+/**
+ * This macro should be used to finalize the definition of an enumerated type
+ * "t" compatible with the sint16 data type described in section 3.1.1.
+ */
+#define SIGNED_ENUM16(t) ;typedef sint16 t
+/**
+ * This macro should be used to finalize the definition of an enumerated type
+ * "t" compatible with the sint32 data type described in section 3.1.1.
+ */
+#define SIGNED_ENUM32(t) ;typedef sint32 t
+
+#endif // INCLUSION_GUARD_T_BASICDEFINITIONS_H
+
diff --git a/lcmodule/source/resource.h b/lcmodule/source/resource.h
new file mode 100644
index 0000000..e894c26
--- /dev/null
+++ b/lcmodule/source/resource.h
@@ -0,0 +1,21 @@
+/******************************************************************************
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+******************************************************************************/
+
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by LCM.rc
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 101
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/lcmodule/source/serialization.c b/lcmodule/source/serialization.c
new file mode 100644
index 0000000..717f847
--- /dev/null
+++ b/lcmodule/source/serialization.c
@@ -0,0 +1,323 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/*
+ * @addtogroup ldr_utilities
+ * @{
+ * @addtogroup serialization
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "r_serialization.h"
+#include <string.h>
+#include <stdlib.h>
+#include "r_debug_macro.h"
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+void get_block(const void **data_pp, void *target_p, uint32 length)
+{
+ memcpy(target_p, *data_pp, length);
+ *(const uint8 **)data_pp += length;
+}
+
+uint8 get_uint8(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **)data_pp;
+ *(const uint8 **)data_pp += sizeof(uint8);
+ return d[0];
+}
+
+uint16 get_uint16_le(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **)data_pp;
+ *(const uint8 **)data_pp += sizeof(uint16);
+ return (d[1] << 8) | d[0];
+}
+
+uint16 get_uint16_be(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **)data_pp;
+ *(const uint8 **)data_pp += sizeof(uint16);
+ return (d[0] << 8) | d[1];
+}
+
+uint32 get_uint32_le(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **) data_pp;
+ *(const uint8 **)data_pp += sizeof(uint32);
+ return ((d[3] << 8 | d[2]) << 8 | d[1]) << 8 | d[0];
+}
+
+uint64 get_uint64_le(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **) data_pp;
+ *(const uint8 **)data_pp += sizeof(uint64);
+ return (((((((uint64)d[7] << 8 | d[6]) << 8 | d[5]) << 8 | d[4]) << 8 | d[3]) << 8 | d[2]) << 8 | d[1]) << 8 | d[0];
+}
+
+uint32 get_uint32_string_le(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **) data_pp;
+ //*(const uint8 **)data_pp += sizeof(uint32);
+ return ((d[3] << 8 | d[2]) << 8 | d[1]) << 8 | (d[0] + sizeof(uint32));
+}
+
+uint32 get_uint32_be(void **data_pp)
+{
+ const uint8 *d = *(const uint8 **) data_pp;
+ *(const uint8 **)data_pp += sizeof(uint32);
+ return ((d[0] << 8 | d[1]) << 8 | d[2]) << 8 | d[3];
+}
+
+void put_block(void **data_pp, const void *source_p, uint32 length)
+{
+ if (length > 0) {
+ memcpy(*data_pp, source_p, length);
+ *(const uint8 **)data_pp += length;
+ }
+}
+
+void put_string(void **data_pp, const void *source_p, uint32 length)
+{
+ if (length > 0) {
+ memcpy(*data_pp, &length, sizeof(uint32));
+ *(const uint8 **)data_pp += sizeof(uint32);
+ memcpy(*data_pp, source_p, length);
+ *(const uint8 **)data_pp += length;
+ }
+}
+
+void put_uint8(void **data_pp, uint8 v)
+{
+ **(uint8 **) data_pp = v;
+ *(uint8 **) data_pp += sizeof(uint8);
+}
+
+void put_uint16_le(void **data_pp, uint16 v)
+{
+ uint8 *d = *(uint8 **) data_pp;
+ d[0] = v & 0xff;
+ d[1] = v >> 8;
+ *(uint8 **)data_pp += sizeof(uint16);
+}
+
+void put_uint16_be(void **data_pp, uint16 v)
+{
+ uint8 *d = *(uint8 **) data_pp;
+ d[1] = v & 0xff;
+ d[0] = v >> 8;
+ *(uint8 **)data_pp += sizeof(uint16);
+}
+
+void put_uint32_le(void **data_pp, uint32 v)
+{
+ uint8 *d = *(uint8 **) data_pp;
+ uint8 *v_p = (uint8 *)&v;
+ d[0] = v_p[0];
+ d[1] = v_p[1];
+ d[2] = v_p[2];
+ d[3] = v_p[3];
+ *(uint8 **)data_pp += sizeof(uint32);
+}
+
+void put_uint32_be(void **data_pp, uint32 v)
+{
+ uint8 *d = *(uint8 **) data_pp;
+ uint8 *v_p = (uint8 *)&v;
+ d[3] = v_p[0];
+ d[2] = v_p[1];
+ d[1] = v_p[2];
+ d[0] = v_p[3];
+ *(uint8 **)data_pp += sizeof(uint32);
+}
+
+void put_uint64_le(void **data_pp, uint64 v)
+{
+ uint8 *d = *(uint8 **) data_pp;
+ uint8 *v_p = (uint8 *)&v;
+ d[0] = v_p[0];
+ d[1] = v_p[1];
+ d[2] = v_p[2];
+ d[3] = v_p[3];
+ d[4] = v_p[4];
+ d[5] = v_p[5];
+ d[6] = v_p[6];
+ d[7] = v_p[7];
+ *(uint8 **)data_pp += sizeof(uint32);
+ *(uint8 **)data_pp += sizeof(uint32);
+}
+
+void put_uint64_be(void **data_pp, uint64 v)
+{
+ uint8 *d = *(uint8 **) data_pp;
+ uint8 *v_p = (uint8 *)&v;
+ d[7] = v_p[0];
+ d[6] = v_p[1];
+ d[5] = v_p[2];
+ d[4] = v_p[3];
+ d[3] = v_p[4];
+ d[2] = v_p[5];
+ d[1] = v_p[6];
+ d[0] = v_p[7];
+ *(uint8 **)data_pp += sizeof(uint32);
+ *(uint8 **)data_pp += sizeof(uint32);
+}
+
+void skip_uint8(void **data_pp)
+{
+ *(const uint8 **)data_pp += sizeof(uint8);
+}
+
+void skip_uint16(void **data_pp)
+{
+ *(const uint8 **)data_pp += sizeof(uint16);
+}
+
+void skip_uint32(void **data_pp)
+{
+ *(const uint8 **)data_pp += sizeof(uint32);
+}
+
+void skip_block(void **data_pp, uint32 length)
+{
+ *(const uint8 **)data_pp += length;
+}
+
+char *skip_str(void **data_pp)
+{
+ char *Result_p = NULL;
+ uint32 StrLength;
+
+ ASSERT(NULL != data_pp);
+ Result_p = *(char **)data_pp;
+ ASSERT(NULL != Result_p);
+ StrLength = get_uint32_le(data_pp);
+ *(char **)data_pp += StrLength;
+ return Result_p;
+}
+
+char *get_strdup(void *String_p)
+{
+ char *Result_p;
+ uint32 StrLength = strlen((char *)String_p) + 1;
+
+ Result_p = (char *)malloc(StrLength);
+ ASSERT(Result_p != NULL);
+
+ strncpy(Result_p, (char *)String_p, StrLength);
+ Result_p[StrLength - 1] = 0;
+ return Result_p;
+}
+
+void insert_string(char **data_pp, const char *source_p, uint32 length)
+{
+ *data_pp = NULL;
+
+ *data_pp = (char *)malloc(sizeof(uint32) + length);
+ ASSERT(NULL != *data_pp);
+
+ memcpy(*data_pp, &length, sizeof(uint32));
+ memcpy(*data_pp + sizeof(uint32), source_p, length);
+}
+
+#if defined(CFG_ENABLE_LOADER_SERIALIZATION)
+uint32 get_directory_entries_len(const DirEntry_t *source_p, uint32 DirectoryEntriesCount)
+{
+ uint32 EntriesLen = 0;
+ uint32 i = 0;
+
+ for (i = 0; i < DirectoryEntriesCount; i++) {
+ EntriesLen += get_uint32_string_le((void **)&source_p[i].Name_p);
+ EntriesLen += sizeof(uint32) + sizeof(uint32) + sizeof(uint64);
+ }
+
+ return EntriesLen;
+}
+
+void serialize_directory_entries(void **data_pp, const DirEntry_t *source_p, uint32 DirectoryEntriesCount)
+{
+ uint32 NameLength = 0;
+ uint32 i = 0;
+
+ for (i = 0; i < DirectoryEntriesCount; i++) {
+ NameLength = get_uint32_string_le((void **)&source_p[i].Name_p);
+ memcpy(*data_pp, source_p[i].Name_p, NameLength);
+ *(const uint8 **)data_pp += NameLength;
+ memcpy(*data_pp, &source_p[i].Size, sizeof(uint64));
+ *(const uint8 **)data_pp += sizeof(uint64);
+ memcpy(*data_pp, &source_p[i].Mode, sizeof(uint32));
+ *(const uint8 **)data_pp += sizeof(uint32);
+ memcpy(*data_pp, &source_p[i].Time, sizeof(uint32));
+ *(const uint8 **)data_pp += sizeof(uint32);
+ }
+}
+
+uint32 get_device_entries_len(const ListDevice_t *source_p, uint32 DeviceEntriesCount)
+{
+ uint32 EntriesLen = 0;
+ uint32 i = 0;
+
+ for (i = 0; i < DeviceEntriesCount; i++) {
+ if (NULL != source_p[i].Path_p) {
+ EntriesLen += get_uint32_string_le((void **)&source_p[i].Path_p);
+ } else {
+ EntriesLen += sizeof(uint32);
+ }
+
+ if (NULL != source_p[i].Type_p) {
+ EntriesLen += get_uint32_string_le((void **)&source_p[i].Type_p);
+ } else {
+ EntriesLen += sizeof(uint32);
+ }
+
+ EntriesLen += sizeof(uint64) + sizeof(uint64) + sizeof(uint64);
+ }
+
+ return EntriesLen;
+}
+
+void serialize_device_entries(void **data_pp, const ListDevice_t *source_p, uint32 DeviceEntriesCount)
+{
+ uint32 PathLen = 0;
+ uint32 TypeLen = 0;
+ uint32 i = 0;
+
+ for (i = 0; i < DeviceEntriesCount; i++) {
+ if (NULL != source_p[i].Path_p) {
+ PathLen = get_uint32_string_le((void **)&source_p[i].Path_p);
+ memcpy(*data_pp, source_p[i].Path_p, PathLen);
+ *(const uint8 **)data_pp += PathLen;
+ } else {
+ memset(*data_pp, 0x00, sizeof(char *));
+ *(const uint8 **)data_pp += sizeof(char *);
+ }
+
+ if (NULL != source_p[i].Type_p) {
+ TypeLen = get_uint32_string_le((void **)&source_p[i].Type_p);
+ memcpy(*data_pp, source_p[i].Type_p, TypeLen);
+ *(const uint8 **)data_pp += TypeLen;
+ } else {
+ memset(*data_pp, 0x00, sizeof(char *));
+ *(const uint8 **)data_pp += sizeof(char *);
+ }
+
+ memcpy(*data_pp, &source_p[i].BlockSize, sizeof(uint64));
+ *(const uint8 **)data_pp += sizeof(uint64);
+ memcpy(*data_pp, &source_p[i].Start, sizeof(uint64));
+ *(const uint8 **)data_pp += sizeof(uint64);
+ memcpy(*data_pp, &source_p[i].Length, sizeof(uint64));
+ *(const uint8 **)data_pp += sizeof(uint64);
+ }
+}
+#endif
+
+/* @} */
+/* @} */
+
diff --git a/lcmodule/test_cases/ADbg_cnh1606344.c b/lcmodule/test_cases/ADbg_cnh1606344.c
new file mode 100644
index 0000000..d4b1c96
--- /dev/null
+++ b/lcmodule/test_cases/ADbg_cnh1606344.c
@@ -0,0 +1,287 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+/**
+ * @file ADbg_cnh1606344.c
+ *
+ * @brief Test cases for CNH1606344 module.
+ *
+ * This file consist of test cases for autometic testing functions from
+ * CNH1606344 module.
+ */
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "r_adbg.h"
+#include "r_adbg_assert.h"
+#include "r_adbg_case.h"
+#include "r_adbg_module.h"
+#include "r_adbg_command.h"
+#include "r_communication_service.h"
+#include "r_memmory_utils.h"
+
+/*******************************************************************************
+ * The test case functions declarations
+ ******************************************************************************/
+// A2_Family
+
+// Communication_service
+static void ADbg_Do_Communication_Initialize(ADbg_Case_t *Case_p);
+static void ADbg_Do_Communication_Shutdown(ADbg_Case_t *Case_p);
+static void ADbg_Do_Communication_SetFamily(ADbg_Case_t *Case_p);
+static void ADbg_Do_Communication_Poll(ADbg_Case_t *Case_p);
+static void ADbg_Do_Communication_Send(ADbg_Case_t *Case_p);
+static void ADbg_Do_Communication_SetProtocolTimeouts(ADbg_Case_t *Case_p);
+static void ADbg_Do_Communication_GetProtocolTimeouts(ADbg_Case_t *Case_p);
+
+// Protrom_family
+
+/*******************************************************************************
+ * The test case definitions
+ ******************************************************************************/
+// A2_Family
+
+// Communication_service
+static uint8 Parameters2_1[7] = {6, WORDPTR, WORD, WORDPTR, WORDPTR, WORD, WORD};
+ADBG_CASE_DEFINE(Test_Do_Communication_Initialize, 1, 15, ADbg_Do_Communication_Initialize, Parameters2_1);
+static uint8 Parameters2_2[3] = {2, WORDPTR, WORD};
+ADBG_CASE_DEFINE(Test_Do_Communication_Shutdown, 2, 15, ADbg_Do_Communication_Shutdown, Parameters2_2);
+static uint8 Parameters2_3[4] = {3, WORDPTR, WORD, WORD};
+ADBG_CASE_DEFINE(Test_Do_Communication_SetFamily, 3, 15, ADbg_Do_Communication_SetFamily, Parameters2_3);
+static uint8 Parameters2_4[2] = {1, WORDPTR};
+ADBG_CASE_DEFINE(Test_Do_Communication_Poll, 4, 15, ADbg_Do_Communication_Poll, Parameters2_4);
+static uint8 Parameters2_5[4] = {3, WORDPTR, VOIDPTR, WORD};
+ADBG_CASE_DEFINE(Test_Do_Communication_Send, 5, 15, ADbg_Do_Communication_Send, Parameters2_5);
+static uint8 Parameters2_6[4] = {3, WORDPTR, VOIDPTR, WORD};
+ADBG_CASE_DEFINE(Test_Do_Communication_SetProtocolTimeouts, 6, 15, ADbg_Do_Communication_SetProtocolTimeouts, Parameters2_6);
+static uint8 Parameters2_7[4] = {3, WORDPTR, VOIDPTR, WORD};
+ADBG_CASE_DEFINE(Test_Do_Communication_GetProtocolTimeouts, 7, 15, ADbg_Do_Communication_GetProtocolTimeouts, Parameters2_7);
+
+/*******************************************************************************
+* The test case suite definition
+******************************************************************************/
+ADBG_SUITE_DEFINE_BEGIN(TestCase_CNH1606344, 0, 15)
+
+// A2_Family
+
+// Communication_service
+ADBG_SUITE_ENTRY(Test_Do_Communication_Initialize)
+ADBG_SUITE_ENTRY(Test_Do_Communication_Shutdown)
+ADBG_SUITE_ENTRY(Test_Do_Communication_SetFamily)
+ADBG_SUITE_ENTRY(Test_Do_Communication_Poll)
+ADBG_SUITE_ENTRY(Test_Do_Communication_Send)
+ADBG_SUITE_ENTRY(Test_Do_Communication_SetProtocolTimeouts)
+ADBG_SUITE_ENTRY(Test_Do_Communication_GetProtocolTimeouts)
+
+ADBG_SUITE_DEFINE_END();
+
+/*******************************************************************************
+ * Case runner
+ ******************************************************************************/
+void Do_CNH1606344_Module_Test_Run(ADbg_MainModule_t *MainModule_p)
+{
+ ADbg_Module_t *Module_p = Do_ADbg_Module_Create(TestCase_CNH1606344, NULL, MainModule_p->Command_p, MainModule_p->Result_p);
+ Do_ADbg_InModule_Command(Module_p);
+ Do_ADbg_Module_Destroy(Module_p);
+}
+/*******************************************************************************
+ * Test cases
+ ******************************************************************************/
+// A2_Family
+
+// Communication_service
+/**
+ * This function will test function:
+ * Do_Communication_Initialize.
+ * Function used in: Test_Do_Communication_Initialize.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_Initialize(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ Family_t Family;
+ HashDevice_t *HashDevice_p;
+ CommunicationDevice_t *CommunicationDevice_p;
+ Do_CEH_Call_t CommandCallback_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+
+ Do_ADbg_GetDataVar(sizeof(Family_t), &Var_p, &Family);
+
+ HashDevice_p = Do_ADbg_GetDataPointer(sizeof(HashDevice_t), (void **)&Var_p);
+ CommunicationDevice_p = Do_ADbg_GetDataPointer(sizeof(CommunicationDevice_t), (void **)&Var_p);
+
+ Do_ADbg_GetDataVar(sizeof(Do_CEH_Call_t), &Var_p, &CommandCallback_p);
+
+ Result = Do_Communication_Initialize(Communication_p, Family, HashDevice_p, CommunicationDevice_p, CommandCallback_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+ BUFFER_FREE(HashDevice_p);
+ BUFFER_FREE(CommunicationDevice_p);
+
+}
+
+/**
+ * This function will test function:
+ * Do_Communication_Shutdown.
+ * Function used in: Test_Do_Communication_Shutdown.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_Shutdown(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+
+ Result = Do_Communication_Shutdown(Communication_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+}
+
+/**
+ * This function will test function:
+ * Do_Communication_SetFamily.
+ * Function used in: Test_Do_Communication_SetFamily.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_SetFamily(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ Family_t Family;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+
+ Do_ADbg_GetDataVar(sizeof(Family_t), &Var_p, &Family);
+
+ Result = Do_Communication_SetFamily(Communication_p, Family);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+}
+
+/**
+ * This function will test function:
+ * Do_Communication_Poll.
+ * Function used in: Test_Do_Communication_Poll.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_Poll(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+
+ Do_Communication_Poll(Communication_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+}
+
+/**
+ * This function will test function:
+ * Do_Communication_Send.
+ * Function used in: Test_Do_Communication_Send.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_Send(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ void *InputData_p = NULL;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+ InputData_p = Do_ADbg_GetDataPointer(sizeof(void *), (void **)&Var_p);
+
+ Result = Do_Communication_Send(Communication_p, InputData_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+ BUFFER_FREE(InputData_p);
+
+}
+
+/**
+ * This function will test function:
+ * Do_Communication_SetProtocolTimeouts.
+ * Function used in: Test_Do_Communication_SetProtocolTimeouts.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_SetProtocolTimeouts(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ void *TimeoutData_p = NULL;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+ TimeoutData_p = Do_ADbg_GetDataPointer(sizeof(void *), (void **)&Var_p);
+
+ Result = Do_Communication_SetProtocolTimeouts(Communication_p, TimeoutData_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+ BUFFER_FREE(TimeoutData_p);
+}
+
+/**
+ * This function will test function:
+ * Do_Communication_GetProtocolTimeouts.
+ * Function used in: Test_Do_Communication_GetProtocolTimeouts.
+ *
+ * @param [in] Case_p is pointer.
+ * @return void.
+ */
+static void ADbg_Do_Communication_GetProtocolTimeouts(ADbg_Case_t *Case_p)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Communication_t *Communication_p;
+ void *TimeoutData_p = NULL;
+ uint8 *Var_p = NULL;
+
+ Var_p = Case_p->Command_p->Data_p;
+ Communication_p = Do_ADbg_GetDataPointer(sizeof(Communication_t), (void **)&Var_p);
+ TimeoutData_p = Do_ADbg_GetDataPointer(sizeof(void *), (void **)&Var_p);
+
+ Result = Do_Communication_GetProtocolTimeouts(Communication_p, &TimeoutData_p);
+ Do_ADbg_Assert((ErrorCode_e)(*Var_p) == Result, Case_p);
+
+ BUFFER_FREE(Communication_p);
+ BUFFER_FREE(TimeoutData_p);
+}
diff --git a/lcmodule/test_cases/ADbg_cnh1606344.h b/lcmodule/test_cases/ADbg_cnh1606344.h
new file mode 100644
index 0000000..02d6a9a
--- /dev/null
+++ b/lcmodule/test_cases/ADbg_cnh1606344.h
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef ADBG_CNH1606344_H_
+#define ADBG_CNH1606344_H_
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+
+/* @} */
+#endif /*ADBG_CNH1606344_H_*/
diff --git a/lcmodule/test_cases/ADbg_cnh1606344_utilities.c b/lcmodule/test_cases/ADbg_cnh1606344_utilities.c
new file mode 100644
index 0000000..82c0606
--- /dev/null
+++ b/lcmodule/test_cases/ADbg_cnh1606344_utilities.c
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+/**
+ * @file ADbg_cnh1606344_utilities.c
+ *
+ * @brief Interface functions for CNH1606344 module.
+ *
+ * This file consist of interface functions for setting preconditions
+ * for automatic testing functions from CNH1606344 module.
+ */
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "r_adbg.h"
+#include "r_adbg_int_function.h"
+#include "r_adbg_int_group.h"
+#include "r_adbg_command.h"
+#include "r_adbg_module.h"
+#include "r_communication_service.h"
+#include "ADbg_cnh1606344_utilities.h"
+
+/*******************************************************************************
+ * The interface functions declarations
+ ******************************************************************************/
+
+static void ADbg_IntGroup1_CNH1606344_Group(ADbg_Module_t *Module_p);
+/** Functions used for set the global variables. */
+static void ADbg_Test_Function1_CNH1606344(ADbg_IntFunction_t *IntFunction_p);
+
+/*******************************************************************************
+ * The interface group definitions
+ ******************************************************************************/
+//ADBG_INTERFACE_GROUP_DEFINE(InterfaceGroupName, InterfaceGroupId, ModuleId, InterfaceFunctionRunner)
+ADBG_INTERFACE_GROUP_DEFINE(Test_IntGroup1_CNH1606344_Group, 1, 15, ADbg_IntGroup1_CNH1606344_Group);
+
+/*******************************************************************************
+ * The interface function definitions
+ ******************************************************************************/
+
+static uint8 Param1[2] = {1, WORD};
+static uint8 Param2[4];
+ADBG_INTERFACE_FUNCTION_DEFINE(Test_Function1_CNH1606344, 1, 1, 15, ADbg_Test_Function1_CNH1606344, Param1, Param2);
+
+/*******************************************************************************
+ * The interface group suite definition
+ ******************************************************************************/
+//ADBG_INTERFACE_GROUP_SUITE_DEFINE_BEGIN(TestIntGroup_CNH1606344, 0, ModuleId)
+ADBG_INTERFACE_GROUP_SUITE_DEFINE_BEGIN(IntGroup_CNH1606344, 0, 15)
+
+//ADBG_INTERFACE_GROUP_SUITE_ENTRY(InterfaceGroupName)
+ADBG_INTERFACE_GROUP_SUITE_ENTRY(Test_IntGroup1_CNH1606344_Group)
+
+ADBG_INTERFACE_GROUP_SUITE_DEFINE_END();
+
+/*******************************************************************************
+ * The interface functions suites definition
+ ******************************************************************************/
+//ADBG_INTERFACE_FUNCTION_SUITE_DEFINE_BEGIN(TestIntFunctionSuiteName, 0, IntGroupId, ModuleId)
+
+ADBG_INTERFACE_FUNCTION_SUITE_DEFINE_BEGIN(IntGroup1_CNH1606344, 0, 1, 15)
+
+ADBG_INTERFACE_FUNCTION_SUITE_ENTRY(Test_Function1_CNH1606344) //InterfaceFunctionName
+
+ADBG_INTERFACE_FUNCTION_SUITE_DEFINE_END();
+
+/*******************************************************************************
+ * Interface group runner
+ ******************************************************************************/
+void Do_CNH1606344_Module_Interface_Run(ADbg_MainModule_t *MainModule_p)
+{
+ ADbg_Module_t *Module_p = Do_ADbg_Module_Create(NULL, IntGroup_CNH1606344, MainModule_p->Command_p, MainModule_p->Result_p);
+ Do_ADbg_InModule_Command(Module_p);
+ Do_ADbg_Module_Destroy(Module_p);
+}
+
+/*******************************************************************************
+ * Interface functions from group1 runner
+ ******************************************************************************/
+static void ADbg_IntGroup1_CNH1606344_Group(ADbg_Module_t *Module_p)
+{
+ ADbg_IntGroup_t *IntGroup1_p = Do_ADbg_IntGroup_Create(IntGroup1_CNH1606344, Module_p->Command_p, Module_p->Result_p);
+ Do_ADbg_InIntGroup_Command(IntGroup1_p);
+ Do_ADbg_IntGroup_Destroy(IntGroup1_p);
+}
+
+/**
+ * @brief Interface function.
+ *
+ * This function...
+ *
+ * @param [in] IntFunction_p is pointer.
+ * @return void.
+ */
+static void ADbg_Test_Function1_CNH1606344(ADbg_IntFunction_t *IntFunction_p)
+{
+ uint32 Param;
+
+ //...
+ Do_ADbg_SetAndRecoveryCondition((void *)&Param, Param2, sizeof(uint32), IntFunction_p);
+}
+
+/* @} */
diff --git a/lcmodule/test_cases/ADbg_cnh1606344_utilities.h b/lcmodule/test_cases/ADbg_cnh1606344_utilities.h
new file mode 100644
index 0000000..4b65b3b
--- /dev/null
+++ b/lcmodule/test_cases/ADbg_cnh1606344_utilities.h
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef ADBG_CNH1606344_UTILITIES_H_
+#define ADBG_CNH1606344_UTILITIES_H_
+
+/*
+ * @addtogroup ADbg
+ * @{
+ */
+
+
+/* @} */
+#endif /*ADBG_CNH1606344_UTIILITIES_H_*/
diff --git a/lcmodule/tools/xalan-j_2_7_1/.dummy_file b/lcmodule/tools/xalan-j_2_7_1/.dummy_file
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/lcmodule/tools/xalan-j_2_7_1/.dummy_file
@@ -0,0 +1 @@
+
diff --git a/lcmodule/win_binaries/LCM.dll b/lcmodule/win_binaries/LCM.dll
new file mode 100755
index 0000000..fdc0ab1
--- /dev/null
+++ b/lcmodule/win_binaries/LCM.dll
Binary files differ