summaryrefslogtreecommitdiff
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
Initial contribution of loader_communication
ST-Ericsson ID: 326913 ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10204 Change-Id: I171cfc2ee458a8a0a91a1916137d131f0f7ecee5
-rw-r--r--.gitignore12
-rw-r--r--Android.mk288
-rw-r--r--LICENSE.txt24
-rw-r--r--LICENSE_SHA2.txt37
-rw-r--r--Makefile332
-rw-r--r--README.txt9
-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
-rw-r--r--source/CEH/CmdResult.cpp31
-rw-r--r--source/CEH/CmdResult.h77
-rw-r--r--source/CEH/ProtromRpcInterface.cpp272
-rw-r--r--source/CEH/ProtromRpcInterface.h79
-rw-r--r--source/CEH/ZRpcInterface.cpp142
-rw-r--r--source/CEH/ZRpcInterface.h38
-rw-r--r--source/CEH/a2_commands_impl.cpp122
-rw-r--r--source/CEH/commands_impl.cpp402
-rw-r--r--source/CEH/commands_types.h65
-rw-r--r--source/LCDriver.cpp595
-rw-r--r--source/LCDriver.h824
-rw-r--r--source/LCDriver.rc116
-rw-r--r--source/LCDriver.vcproj966
-rw-r--r--source/LCDriverEntry.cpp45
-rw-r--r--source/LCDriverInterface.cpp55
-rw-r--r--source/LCDriverInterface.h50
-rw-r--r--source/LCDriverMethods.cpp2574
-rw-r--r--source/LCDriverMethods.h265
-rw-r--r--source/LCDriverThread.cpp84
-rw-r--r--source/LCDriverThread.h55
-rw-r--r--source/LCM/Buffers.cpp264
-rw-r--r--source/LCM/Buffers.h83
-rw-r--r--source/LCM/Hash.cpp197
-rw-r--r--source/LCM/Hash.h47
-rw-r--r--source/LCM/Queue.cpp291
-rw-r--r--source/LCM/Queue.h53
-rw-r--r--source/LCM/Timer.cpp267
-rw-r--r--source/LCM/Timer.h97
-rw-r--r--source/LCM/include/c_compiler.h127
-rw-r--r--source/LCM/include/c_system.h34
-rw-r--r--source/LCM/include/error_codes.h740
-rwxr-xr-xsource/LCM/include/t_a2_protocol.h48
-rw-r--r--source/LCM/include/t_basicdefinitions.h286
-rw-r--r--source/LCM/include/t_bulk_protocol.h155
-rw-r--r--source/LCM/include/t_command_protocol.h73
-rw-r--r--source/LCM/include/t_communication_service.h344
-rw-r--r--source/LCM/include/t_protrom_header.h63
-rw-r--r--source/LCM/include/t_protrom_network.h98
-rw-r--r--source/LCM/include/t_protrom_transport.h44
-rw-r--r--source/LCM/include/t_queue.h45
-rw-r--r--source/LCM/include/t_r15_header.h102
-rw-r--r--source/LCM/include/t_r15_network_layer.h309
-rw-r--r--source/LCM/include/t_security_algorithms.h44
-rw-r--r--source/LCM/include/t_time_utilities.h43
-rw-r--r--source/LcmInterface.cpp260
-rw-r--r--source/LcmInterface.h129
-rw-r--r--source/api_wrappers/linux/CCriticalSection.h52
-rw-r--r--source/api_wrappers/linux/CEventObject.cpp66
-rw-r--r--source/api_wrappers/linux/CEventObject.h40
-rw-r--r--source/api_wrappers/linux/CSemaphore.cpp55
-rw-r--r--source/api_wrappers/linux/CSemaphore.h26
-rw-r--r--source/api_wrappers/linux/CSemaphoreQueue.cpp121
-rw-r--r--source/api_wrappers/linux/CSemaphoreQueue.h67
-rw-r--r--source/api_wrappers/linux/CSimpleQueue.h26
-rw-r--r--source/api_wrappers/linux/CThreadWrapper.cpp119
-rw-r--r--source/api_wrappers/linux/CThreadWrapper.h36
-rw-r--r--source/api_wrappers/linux/CWaitableObject.cpp17
-rw-r--r--source/api_wrappers/linux/CWaitableObject.h24
-rw-r--r--source/api_wrappers/linux/CWaitableObjectCollection.cpp67
-rw-r--r--source/api_wrappers/linux/CWaitableObjectCollection.h26
-rw-r--r--source/api_wrappers/linux/LinuxApiWrappers.h20
-rw-r--r--source/api_wrappers/linux/OS.cpp88
-rw-r--r--source/api_wrappers/linux/OS.h107
-rw-r--r--source/api_wrappers/linux/Types.h21
-rw-r--r--source/api_wrappers/windows/WinApiWrappers.h347
-rw-r--r--source/config/a2_command_ids_h.xsl60
-rw-r--r--source/config/a2_commands.xml1259
-rw-r--r--source/config/a2_commands_h.xsl78
-rw-r--r--source/config/a2_commands_impl_h.xsl72
-rw-r--r--source/config/a2_commands_marshal_cpp.xsl236
-rw-r--r--source/config/a2_common.xsl227
-rw-r--r--source/config/command_ids_h.xsl64
-rw-r--r--source/config/commands.xml1165
-rw-r--r--source/config/commands_h.xsl68
-rw-r--r--source/config/commands_impl_h.xsl67
-rw-r--r--source/config/commands_marshal_cpp.xsl211
-rw-r--r--source/config/common.xsl262
-rw-r--r--source/config/lcdriver_error_codes.xml114
-rw-r--r--source/config/lcdriver_error_codes_h.xsl72
-rw-r--r--source/resource.h21
-rw-r--r--source/security_algorithms/SecurityAlgorithms.cpp18
-rw-r--r--source/security_algorithms/SecurityAlgorithms.h20
-rw-r--r--source/security_algorithms/sha/sha2.cpp1064
-rw-r--r--source/security_algorithms/sha/sha2.h197
-rw-r--r--source/utilities/BulkHandler.cpp286
-rw-r--r--source/utilities/BulkHandler.h81
-rw-r--r--source/utilities/CaptiveThreadObject.cpp51
-rw-r--r--source/utilities/CaptiveThreadObject.h57
-rwxr-xr-xsource/utilities/Error.h25
-rw-r--r--source/utilities/Event.h27
-rw-r--r--source/utilities/LockLessQueue.h98
-rw-r--r--source/utilities/Logger.cpp36
-rw-r--r--source/utilities/Logger.h33
-rw-r--r--source/utilities/MemMappedFile.cpp205
-rw-r--r--source/utilities/MemMappedFile.h41
-rw-r--r--source/utilities/ObjectList.h286
-rw-r--r--source/utilities/Serialization.cpp325
-rw-r--r--source/utilities/Serialization.h63
-rwxr-xr-xwin_binaries/LCDriver_CNH1606432.dllbin0 -> 172032 bytes
-rwxr-xr-xwin_binaries/LCM.dllbin0 -> 81920 bytes
236 files changed, 43945 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..242f035
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,12 @@
+lcmodule/.config
+.config
+cov_data
+cov_inter
+target/
+autogen/
+*Debug/
+*Release/
+*.ncb
+*.sln
+*.suo
+*.user
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..939b038
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,288 @@
+# If FLASHKIT_INSTALL_PATH is set it is assumed to be part of a flashkit build
+# in the forest, otherwise it is assumed to be a build of loader_communication
+# to use together with MFA
+ifeq ($(FLASHKIT_INSTALL_PATH),)
+ PRIVATE_BUILDTYPE_FLASHKIT=false
+else
+ PRIVATE_BUILDTYPE_FLASHKIT=true
+endif
+
+ifeq ($(PRIVATE_BUILDTYPE_FLASHKIT), true)
+#Build of loader_communication for flashkit
+#Android makefile to build loader communication as a part of Android Build
+include $(CLEAR_VARS)
+
+.phony: config-lcm build-lcm install-lcm config-lcd build-lcd install-lcd clean-lcm distclean-lcm clean-lcd distclean-lcd clobber
+
+#Source location
+PRIVATE_LC_TOOLS_PATH := $(abspath $(TOOLS_PATH))
+PRIVATE_LC_LOADERS_DIR := $(PRIVATE_LC_TOOLS_PATH)/platform/flash_kit/loaders
+
+PRIVATE_LC_LCM_DIR := $(PRIVATE_LC_TOOLS_PATH)/platform/flash_kit/loader_communication/lcmodule
+PRIVATE_LC_LCD_DIR := $(PRIVATE_LC_TOOLS_PATH)/platform/flash_kit/loader_communication
+
+#Output
+PRIVATE_LC_FLASH_KIT_TOOL_DIR := $(FLASHKIT_INSTALL_BASE)/flashkit
+
+PRIVATE_LC_LCM_OUT_DIR = $(abspath $(TOP))/$(TARGET_OUT_INTERMEDIATES)/FLASHKIT/LCM
+PRIVATE_LC_LCD_OUT_DIR = $(abspath $(TOP))/$(TARGET_OUT_INTERMEDIATES)/FLASHKIT/LCD
+
+PRIVATE_LC_LCM_INSTALLDIR := $(abspath $(TOP))/$(TARGET_OUT_INTERMEDIATES)/FLASHKIT/LOADERS/loader_communication_module
+PRIVATE_LC_LCMLIB_INSTALLDIR := $(PRIVATE_LC_FLASH_KIT_TOOL_DIR)/flash-tool-backend/native/
+PRIVATE_LC_LCD_INSTALLDIR := $(PRIVATE_LC_FLASH_KIT_TOOL_DIR)/flash-tool-backend/native/
+
+#Other flags
+PRIVATE_LC_LCD_FLAGS := LCD_INSTALLDIR=$(PRIVATE_LC_LCD_INSTALLDIR) PATH=$(PATH)
+
+PRIVATE_LC_LCM_FLAGS := LCM_PATH=$(PRIVATE_LC_LCM_DIR) LOADER_DIR=$(PRIVATE_LC_LOADERS_DIR) \
+ LCMLIB_INSTALLDIR=$(PRIVATE_LC_LCMLIB_INSTALLDIR) \
+ LCMLDR_INSTALLDIR=$(PRIVATE_LC_LCM_INSTALLDIR) PATH=$(PATH)
+
+#LCM TARGETS
+.PHONY: config-lcm
+config-lcm:
+ mkdir -p $(PRIVATE_LC_LCMLIB_INSTALLDIR)
+ mkdir -p $(PRIVATE_LC_LCM_OUT_DIR)
+ $(MAKE) -C $(PRIVATE_LC_LCM_DIR) $(PRIVATE_LC_LCM_FLAGS) CONFIG_DIR=$(PRIVATE_LC_LCM_OUT_DIR) BUILDFOLDER=$(PRIVATE_LC_LCM_OUT_DIR) config
+
+.PHONY: build-lcm
+build-lcm: config-lcm
+ $(MAKE) -C $(PRIVATE_LC_LCM_DIR) $(PRIVATE_LC_LCM_FLAGS) CONFIG_DIR=$(PRIVATE_LC_LCM_OUT_DIR) build
+
+.PHONY: install-lcm
+install-lcm: build-lcm
+ $(MAKE) -C $(PRIVATE_LC_LCM_DIR) $(PRIVATE_LC_LCM_FLAGS) CONFIG_DIR=$(PRIVATE_LC_LCM_OUT_DIR) install
+
+.PHONY: clean-lcm
+clean-lcm:
+ $(MAKE) -C $(PRIVATE_LC_LCM_DIR) $(PRIVATE_LC_LCM_FLAGS) CONFIG_DIR=$(PRIVATE_LC_LCM_OUT_DIR) clean
+
+.PHONY: distclean-lcm
+distclean-lcm:
+ $(MAKE) -C $(PRIVATE_LC_LCM_DIR) $(PRIVATE_LC_LCM_FLAGS) CONFIG_DIR=$(PRIVATE_LC_LCM_OUT_DIR) distclean
+
+#LCD TARGETS
+.PHONY: config-lcd
+config-lcd:
+ mkdir -p $(PRIVATE_LC_LCD_INSTALLDIR)
+ mkdir -p $(PRIVATE_LC_LCD_OUT_DIR)
+ $(MAKE) -C $(PRIVATE_LC_LCD_DIR) $(PRIVATE_LC_LCD_FLAGS) CONFIG_DIR=$(PRIVATE_LC_LCD_OUT_DIR) BUILDFOLDER=$(PRIVATE_LC_LCD_OUT_DIR) config
+
+.PHONY: build-lcd
+build-lcd: config-lcd
+ $(MAKE) -C $(PRIVATE_LC_LCD_DIR) $(PRIVATE_LC_LCD_FLAGS) CONFIG_DIR=$(PRIVATE_LC_LCD_OUT_DIR) build
+
+.PHONY: install-lcd
+install-lcd: build-lcd
+ $(MAKE) -C $(PRIVATE_LC_LCD_DIR) $(PRIVATE_LC_LCD_FLAGS) CONFIG_DIR=$(PRIVATE_LC_LCD_OUT_DIR) install
+
+.PHONY: clean-lcd
+clean-lcd:
+ $(MAKE) -C $(PRIVATE_LC_LCD_DIR) $(PRIVATE_LC_LCD_FLAGS) CONFIG_DIR=$(PRIVATE_LC_LCD_OUT_DIR) clean
+
+.PHONY: distclean-lcd
+distclean-lcd:
+ $(MAKE) -C $(PRIVATE_LC_LCD_DIR) $(PRIVATE_LC_LCD_FLAGS) CONFIG_DIR=$(PRIVATE_LC_LCD_OUT_DIR) distclean
+
+clean clobber: clean-lcm clean-lcd
+
+st-ericsson-flashkit: config-lcm build-lcm install-lcm config-lcd build-lcd install-lcd
+
+else
+#MFA build of loader_communication
+#Android makefile to build loader communication as an Android shared library object
+
+# build liblcdriver.so
+LOCAL_PATH := $(my-dir)
+XSL_LOCAL_PATH := $(LOCAL_PATH)
+
+# Path for the tool used for automatic code generation
+PRIVATE_CLASSPATH := $(LOCAL_PATH)/lcmodule/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_NAME := libSecurityAlgorithms.a
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := STATIC_LIBRARY
+LOCAL_PREBUILT_LIBS:= \
+ source/security_algorithms/ARM/$(LOCAL_MODULE_NAME)
+include $(BUILD_MULTI_PREBUILT)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := liblcdriver
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+
+# Automatic Code Generation
+LOCAL_AUTO_DIR := $(local-intermediates-dir)/source/autogen
+LOCAL_CONFIG_PATH := $(LOCAL_PATH)/source/config
+
+# Generate lcdriver_error_codes.h
+GEN := $(LOCAL_AUTO_DIR)/lcdriver_error_codes.h
+$(GEN) : $(shell mkdir -p $(LOCAL_AUTO_DIR))
+$(GEN) : PRIVATE_INPUT_XML := $(LOCAL_CONFIG_PATH)/lcdriver_error_codes.xml
+$(GEN) : PRIVATE_INPUT_XSL = $(XSL_LOCAL_PATH)/source/config/$(patsubst %.h,%_h.xsl,$(patsubst %.cpp,%_cpp.xsl,$(@F)))
+$(GEN) : $(PRIVATE_INPUT_XML) $(PRIVATE_INPUT_XSL)
+$(GEN) : PRIVATE_CUSTOM_TOOL = java -classpath $(PRIVATE_CLASSPATH) -in $(PRIVATE_INPUT_XML) -xsl $(PRIVATE_INPUT_XSL) -out $@ -PARAM target lcm
+$(GEN) :
+ $(transform-generated-source)
+ @echo $@
+
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+# Generate a2_command_ids.h, a2_commands.h, a2_commands_impl.h, and a2_commands_marshal.cpp
+GEN := $(LOCAL_AUTO_DIR)/a2_command_ids.h $(LOCAL_AUTO_DIR)/a2_commands.h $(LOCAL_AUTO_DIR)/a2_commands_impl.h $(LOCAL_AUTO_DIR)/a2_commands_marshal.cpp
+$(GEN) : $(shell mkdir -p $(LOCAL_AUTO_DIR))
+$(GEN) : PRIVATE_INPUT_XML := $(LOCAL_CONFIG_PATH)/a2_commands.xml
+$(GEN) : PRIVATE_INPUT_XSL = $(XSL_LOCAL_PATH)/source/config/$(patsubst %.h,%_h.xsl,$(patsubst %.cpp,%_cpp.xsl,$(@F)))
+$(GEN) : $(PRIVATE_INPUT_XML) $(PRIVATE_INPUT_XSL)
+$(GEN) : PRIVATE_CUSTOM_TOOL = java -classpath $(PRIVATE_CLASSPATH) -in $(PRIVATE_INPUT_XML) -xsl $(PRIVATE_INPUT_XSL) -out $@ -PARAM target lcm
+$(GEN) :
+ $(transform-generated-source)
+ @echo $@
+
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+# Generate command_ids.h, commands.h, commands_impl.h, and commands_marshal.cpp
+GEN := $(LOCAL_AUTO_DIR)/command_ids.h $(LOCAL_AUTO_DIR)/commands.h $(LOCAL_AUTO_DIR)/commands_impl.h $(LOCAL_AUTO_DIR)/commands_marshal.cpp
+$(GEN) : $(shell mkdir -p $(LOCAL_AUTO_DIR))
+$(GEN) : PRIVATE_INPUT_XML := $(LOCAL_CONFIG_PATH)/commands.xml
+$(GEN) : PRIVATE_INPUT_XSL = $(XSL_LOCAL_PATH)/source/config/$(patsubst %.h,%_h.xsl,$(patsubst %.cpp,%_cpp.xsl,$(@F)))
+$(GEN) : $(PRIVATE_INPUT_XML) $(PRIVATE_INPUT_XSL)
+$(GEN) : PRIVATE_CUSTOM_TOOL = java -classpath $(PRIVATE_CLASSPATH) -in $(PRIVATE_INPUT_XML) -xsl $(PRIVATE_INPUT_XSL) -out $@ -PARAM target lcm
+$(GEN) :
+ $(transform-generated-source)
+ @echo $@
+
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+LOCAL_SRC_FILES := \
+ source/utilities/Serialization.cpp\
+ source/utilities/Logger.cpp\
+ source/utilities/MemMappedFile.cpp\
+ source/utilities/CaptiveThreadObject.cpp\
+ source/utilities/BulkHandler.cpp\
+ source/CEH/ProtromRpcInterface.cpp\
+ source/CEH/commands_impl.cpp\
+ source/CEH/a2_commands_impl.cpp\
+ source/CEH/ZRpcInterface.cpp\
+ source/CEH/CmdResult.cpp\
+ source/LcmInterface.cpp\
+ source/LCDriverThread.cpp\
+ source/LCDriverMethods.cpp\
+ source/LCDriverEntry.cpp\
+ source/LCDriver.cpp\
+ source/LCM/Hash.cpp\
+ source/LCM/Buffers.cpp\
+ source/LCM/Queue.cpp\
+ source/LCM/Timer.cpp\
+ source/api_wrappers/linux/CThreadWrapper.cpp\
+ source/api_wrappers/linux/CWaitableObject.cpp\
+ source/api_wrappers/linux/CSemaphore.cpp\
+ source/api_wrappers/linux/CSemaphoreQueue.cpp\
+ source/api_wrappers/linux/CEventObject.cpp\
+ source/api_wrappers/linux/CWaitableObjectCollection.cpp\
+ source/api_wrappers/linux/OS.cpp\
+ source/LCDriverInterface.cpp
+
+LOCAL_C_INCLUDES := \
+ $(TOP)/external/stlport/stlport\
+ $(TOP)/bionic\
+ $(TOP)/bionic/libc/include\
+ $(LOCAL_PATH)/source\
+ $(LOCAL_PATH)/source/api_wrappers/linux\
+ $(LOCAL_PATH)/source/utilities\
+ $(LOCAL_PATH)/source/LCM\
+ $(LOCAL_PATH)/source/LCM/include\
+ $(LOCAL_PATH)/source/security_algorithms\
+ $(LOCAL_PATH)/source/CEH\
+ $(LOCAL_AUTO_DIR)
+
+LOCAL_CFLAGS := -Wall -fPIC -fvisibility=hidden -fno-strict-aliasing -DLCDRIVER_EXPORTS
+
+LOCAL_SHARED_LIBRARIES := libc libdl libstlport
+
+LOCAL_WHOLE_STATIC_LIBRARIES := libSecurityAlgorithms
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+
+# build liblcm.so
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := liblcm
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_AUTO_DIR := $(local-intermediates-dir)/lcmodule/source/autogen
+LOCAL_CONFIG_PATH := $(LOCAL_PATH)/lcmodule/source/cnh1606344_ldr_communication_module/config
+
+# Generate error_codes.h
+GEN := $(LOCAL_AUTO_DIR)/error_codes.h
+$(GEN) : $(shell mkdir -p $(LOCAL_AUTO_DIR))
+$(GEN) : PRIVATE_INPUT_XML := $(LOCAL_CONFIG_PATH)/error_codes.xml
+$(GEN) : PRIVATE_INPUT_XSL := $(LOCAL_CONFIG_PATH)/errorcode_h.xsl
+$(GEN) : $(PRIVATE_INPUT_XML) $(PRIVATE_INPUT_XSL)
+$(GEN) : PRIVATE_CUSTOM_TOOL = java -classpath $(PRIVATE_CLASSPATH) -in $(PRIVATE_INPUT_XML) -xsl $(PRIVATE_INPUT_XSL) -out $@ -PARAM target lcm
+$(GEN) :
+ $(transform-generated-source)
+ @echo $@
+
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+# Generate command_ids.h and commands.h
+GEN := $(LOCAL_AUTO_DIR)/command_ids.h $(LOCAL_AUTO_DIR)/commands.h
+$(GEN) : $(shell mkdir -p $(LOCAL_AUTO_DIR))
+$(GEN) : PRIVATE_INPUT_XML := $(LOCAL_CONFIG_PATH)/commands.xml
+$(GEN) : PRIVATE_INPUT_XSL = $(LOCAL_CONFIG_PATH)/$(patsubst %.h,%_h.xsl,$(patsubst %.cpp,%_cpp.xsl,$(@F)))
+$(GEN) : $(PRIVATE_INPUT_XML) $(PRIVATE_INPUT_XSL)
+$(GEN) : PRIVATE_CUSTOM_TOOL = java -classpath $(PRIVATE_CLASSPATH) -in $(PRIVATE_INPUT_XML) -xsl $(PRIVATE_INPUT_XSL) -out $@ -PARAM target lcm
+$(GEN) :
+ $(transform-generated-source)
+ @echo $@
+
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+LOCAL_SRC_FILES := \
+ lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c\
+ lcmodule/source/cnh1605204_ldr_transport_layer/source/command_protocol.c\
+ lcmodule/source/cnh1605204_ldr_transport_layer/source/protrom_protocol.c\
+ lcmodule/source/cnh1605204_ldr_transport_layer/source/protrom_transport.c\
+ lcmodule/source/cnh1605204_ldr_transport_layer/source/r15_transport_layer.c\
+ lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_transport.c\
+ lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_protocol.c\
+ lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_speedflash.c\
+ lcmodule/source/cnh1605204_ldr_transport_layer/source/z_transport.c\
+ lcmodule/source/cnh1605205_ldr_network_layer/source/a2_header.c\
+ lcmodule/source/cnh1605205_ldr_network_layer/source/a2_network.c\
+ lcmodule/source/cnh1605205_ldr_network_layer/source/r15_header.c\
+ lcmodule/source/cnh1605205_ldr_network_layer/source/r15_network_layer.c\
+ lcmodule/source/cnh1605205_ldr_network_layer/source/z_network.c\
+ lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_header.c\
+ lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_network.c\
+ lcmodule/source/cnh1606344_ldr_communication_module/source/communication_service.c\
+ lcmodule/source/cnh1606344_ldr_communication_module/source/protrom_family.c\
+ lcmodule/source/cnh1606344_ldr_communication_module/source/z_family.c\
+ lcmodule/source/cnh1606344_ldr_communication_module/source/r15_family.c\
+ lcmodule/source/cnh1606344_ldr_communication_module/source/a2_family.c\
+ lcmodule/source/serialization.c
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/lcmodule/source/legacy_compatibility/\
+ $(LOCAL_PATH)/lcmodule/source/cnh1605204_ldr_transport_layer/include/\
+ $(LOCAL_PATH)/lcmodule/source/cnh1605205_ldr_network_layer/include/\
+ $(LOCAL_PATH)/lcmodule/source/cnh1606344_ldr_communication_module/include/\
+ $(LOCAL_PATH)/lcmodule/source/cnh1605720_ldr_time_utilities/include/\
+ $(LOCAL_PATH)/lcmodule/source/cnh1605551_ldr_utilities/include/\
+ $(LOCAL_PATH)/lcmodule/source/cnh1605551_ldr_utilities/communication_abstraction/\
+ $(LOCAL_PATH)/lcmodule/source/cnh1605203_ldr_communication_buffer/include/\
+ $(LOCAL_PATH)/lcmodule/source/cnh1605721_ldr_security_algorithms/include/\
+ $(LOCAL_AUTO_DIR)
+
+LOCAL_CFLAGS := -Wall -fPIC -fvisibility=hidden -fno-strict-aliasing -DUINT64_SUPPORTED -DSINT64_SUPPORTED -DINT64_BASE_TYPE="long long" -DCFG_ENABLE_A2_FAMILY -DLCM_EXPORTS
+
+LOCAL_SHARED_LIBRARIES := libc
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..d162af8
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,24 @@
+Copyright (c) 2011, ST-Ericsson SA
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the ST-Ericsson SA nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL ST-Ericsson SA BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/LICENSE_SHA2.txt b/LICENSE_SHA2.txt
new file mode 100644
index 0000000..78531c8
--- /dev/null
+++ b/LICENSE_SHA2.txt
@@ -0,0 +1,37 @@
+Following products has been used by loader_communication:
+
+* sha2 (http://fxr.watson.org/fxr/source/crypto/sha2.c?v=OPENBSD)
+
+The rest of the file contains the license terms for sha2
+
+******************************************************************************
+
+FILE: sha2.h, sha2.cpp,
+AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/
+
+Copyright (c) 2000-2001, Aaron D. Gifford
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. Neither the name of the copyright holder nor the names of contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..58c3b55
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,332 @@
+ifeq ($(CONFIG_DIR),)
+ config_file=./.config
+else
+ config_file=$(CONFIG_DIR)/.config
+endif
+-include $(config_file)
+
+XALAN_PATH:=./lcmodule/tools/xalan-j_2_7_1/
+LCD_CONFIG:=./source/config/
+WIN_BINARIES=./win_binaries/
+
+LIBSRC := \
+ source/utilities/Serialization.cpp\
+ source/utilities/Logger.cpp\
+ source/utilities/MemMappedFile.cpp\
+ source/utilities/CaptiveThreadObject.cpp\
+ source/utilities/BulkHandler.cpp\
+ source/CEH/ProtromRpcInterface.cpp\
+ source/CEH/commands_impl.cpp\
+ source/CEH/a2_commands_impl.cpp\
+ source/CEH/ZRpcInterface.cpp\
+ source/CEH/CmdResult.cpp\
+ source/LcmInterface.cpp\
+ source/LCDriverThread.cpp\
+ source/LCDriverMethods.cpp\
+ source/LCDriverEntry.cpp\
+ source/LCDriver.cpp\
+ source/LCM/Hash.cpp\
+ source/LCM/Buffers.cpp\
+ source/LCM/Queue.cpp\
+ source/LCM/Timer.cpp\
+ source/api_wrappers/linux/CThreadWrapper.cpp\
+ source/api_wrappers/linux/CWaitableObject.cpp\
+ source/api_wrappers/linux/CSemaphore.cpp\
+ source/api_wrappers/linux/CSemaphoreQueue.cpp\
+ source/api_wrappers/linux/CEventObject.cpp\
+ source/api_wrappers/linux/CWaitableObjectCollection.cpp\
+ source/api_wrappers/linux/OS.cpp\
+ source/LCDriverInterface.cpp\
+ source/security_algorithms/SecurityAlgorithms.cpp\
+ source/security_algorithms/sha/sha2.cpp\
+ $(AUTO_DIR_LIB)/commands_marshal.cpp\
+ $(AUTO_DIR_LIB)/a2_commands_marshal.cpp\
+
+LIBOBJ_x32 := $(addprefix $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/, $(notdir $(LIBSRC:.cpp=.o)))
+LIBOBJ_x64 := $(addprefix $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/, $(notdir $(LIBSRC:.cpp=.o)))
+
+AUTOGEN_FILES := $(AUTO_DIR_LIB)/command_ids.h\
+ $(AUTO_DIR_LIB)/commands.h\
+ $(AUTO_DIR_LIB)/commands_impl.h\
+ $(AUTO_DIR_LIB)/commands_marshal.cpp\
+ $(AUTO_DIR_LIB)/lcdriver_error_codes.h\
+ $(AUTO_DIR_LIB)/a2_command_ids.h\
+ $(AUTO_DIR_LIB)/a2_commands.h\
+ $(AUTO_DIR_LIB)/a2_commands_impl.h\
+ $(AUTO_DIR_LIB)/a2_commands_marshal.cpp
+
+
+#include directories
+INCLUDES := \
+ -Isource\
+ -Isource/api_wrappers/linux\
+ -Isource/utilities\
+ -Isource/LCM\
+ -Isource/LCM/include\
+ -Isource/security_algorithms\
+ -Isource/CEH\
+ -Isource/security_algorithms/sha\
+ -I$(AUTO_DIR_LIB)
+
+# C++ compiler flags (-g -O2 -Wall)
+CXXFLAGS := -c -O2 -Wall -fPIC -fvisibility=hidden -fno-strict-aliasing -DLCDRIVER_EXPORTS -D_FILE_OFFSET_BITS=64
+
+LDFLAGS := -fPIC -fvisibility=hidden -lpthread -lrt -ldl -shared -Wl,-soname,liblcdriver.so
+
+LBITS := $(shell getconf LONG_BIT)
+ifeq ($(LBITS),64)
+#
+# do 64 bit stuff here, like set some CFLAGS
+#
+CXXFLAGS += -DLINUX_64
+build: configfile setup_folders $(LIB_x32) $(LIB_x64)
+else
+#
+# do 32 bit stuff here
+#
+CXXFLAGS += -DLINUX_32
+build: configfile setup_folders $(LIB_x32)
+endif
+
+$(LIB_x32): $(LIBOBJ_x32)
+ $(CXX) $(LDFLAGS) -m32 -o $(LIB_x32) $(addprefix $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/, $(^F))
+
+$(LIB_x64): $(LIBOBJ_x64)
+ $(CXX) $(LDFLAGS) -o $(LIB_x64) $(addprefix $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/, $(^F))
+
+#
+# Source files build
+#
+$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/utilities/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/CEH/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/LCM/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/api_wrappers/linux/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: $(AUTO_DIR_LIB)/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/security_algorithms/sha/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: source/security_algorithms/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -m32 -c $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F)
+
+###
+$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/utilities/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/CEH/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/LCM/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/api_wrappers/linux/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/security_algorithms/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: source/security_algorithms/sha/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)
+
+$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: $(AUTO_DIR_LIB)/%.cpp $(AUTOGEN_FILES)
+ @mkdir -p $(dir $@)
+ $(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F)
+
+#Autogen files
+$(AUTO_DIR_LIB)/command_ids.h: $(LCD_CONFIG)commands.xml $(LCD_CONFIG)command_ids_h.xsl | setup_folders
+ @echo "Generating autogen $(AUTO_DIR_LIB)/command_ids.h..."
+ @java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)commands.xml -xsl $(LCD_CONFIG)command_ids_h.xsl -out $(AUTO_DIR_LIB)/command_ids.h
+
+$(AUTO_DIR_LIB)/commands.h: $(LCD_CONFIG)commands.xml $(LCD_CONFIG)commands_h.xsl | setup_folders
+ @echo "Generating autogen $(AUTO_DIR_LIB)/commands.h..."
+ @java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)commands.xml -xsl $(LCD_CONFIG)commands_h.xsl -out $(AUTO_DIR_LIB)/commands.h
+
+$(AUTO_DIR_LIB)/commands_impl.h: $(LCD_CONFIG)commands.xml $(LCD_CONFIG)commands_impl_h.xsl | setup_folders
+ @echo "Generating autogen $(AUTO_DIR_LIB)/commands_impl.h..."
+ @java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)commands.xml -xsl $(LCD_CONFIG)commands_impl_h.xsl -out $(AUTO_DIR_LIB)/commands_impl.h
+
+$(AUTO_DIR_LIB)/commands_marshal.cpp: $(LCD_CONFIG)commands.xml $(LCD_CONFIG)commands_marshal_cpp.xsl | setup_folders
+ @echo "Generating autogen $(AUTO_DIR_LIB)/commands_marshal.cpp..."
+ @java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)commands.xml -xsl $(LCD_CONFIG)commands_marshal_cpp.xsl -out $(AUTO_DIR_LIB)/commands_marshal.cpp
+
+$(AUTO_DIR_LIB)/lcdriver_error_codes.h: $(LCD_CONFIG)lcdriver_error_codes.xml $(LCD_CONFIG)lcdriver_error_codes_h.xsl | setup_folders
+ @echo "Generating autogen $(AUTO_DIR_LIB)/lcdriver_error_codes.h..."
+ @java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)lcdriver_error_codes.xml -xsl $(LCD_CONFIG)lcdriver_error_codes_h.xsl -out $(AUTO_DIR_LIB)/lcdriver_error_codes.h
+
+$(AUTO_DIR_LIB)/a2_command_ids.h: $(LCD_CONFIG)a2_commands.xml $(LCD_CONFIG)a2_command_ids_h.xsl | setup_folders
+ @echo "Generating autogen $(AUTO_DIR_LIB)/a2_command_ids.h..."
+ @java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)a2_commands.xml -xsl $(LCD_CONFIG)a2_command_ids_h.xsl -out $(AUTO_DIR_LIB)/a2_command_ids.h
+
+$(AUTO_DIR_LIB)/a2_commands.h: $(LCD_CONFIG)a2_commands.xml $(LCD_CONFIG)a2_commands_h.xsl | setup_folders
+ @echo "Generating autogen $(AUTO_DIR_LIB)/a2_commands.h..."
+ @java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)a2_commands.xml -xsl $(LCD_CONFIG)a2_commands_h.xsl -out $(AUTO_DIR_LIB)/a2_commands.h
+
+$(AUTO_DIR_LIB)/a2_commands_impl.h: $(LCD_CONFIG)a2_commands.xml $(LCD_CONFIG)a2_commands_impl_h.xsl | setup_folders
+ @echo "Generating autogen $(AUTO_DIR_LIB)/a2_commands_impl.h..."
+ @java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)a2_commands.xml -xsl $(LCD_CONFIG)a2_commands_impl_h.xsl -out $(AUTO_DIR_LIB)/a2_commands_impl.h
+
+$(AUTO_DIR_LIB)/a2_commands_marshal.cpp: $(LCD_CONFIG)a2_commands.xml $(LCD_CONFIG)a2_commands_marshal_cpp.xsl | setup_folders
+ @echo "Generating autogen $(AUTO_DIR_LIB)/a2_commands_marshal.cpp..."
+ @java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)a2_commands.xml -xsl $(LCD_CONFIG)a2_commands_marshal_cpp.xsl -out $(AUTO_DIR_LIB)/a2_commands_marshal.cpp
+
+#setting up needed folders
+$(BUILDFOLDER): | configfile
+ @mkdir -p $@ 2> /dev/null
+
+$(BUILDFOLDER)/.builddummy: | $(BUILDFOLDER)
+ @touch $@
+
+$(AUTO_DIR_LIB): | configfile
+ @mkdir -p $@ 2> /dev/null
+
+$(AUTO_DIR_LIB)/.autodirdummy: | $(AUTO_DIR_LIB)
+ @touch $@
+
+$(LCD_INSTALLDIR): | configfile
+ @mkdir -p $@ 2> /dev/null
+
+$(LCD_INSTALLDIR)/.installdummy: | $(LCD_INSTALLDIR)
+ @touch $@
+
+.PHONY: setup_folders
+setup_folders: validatevariables
+setup_folders: $(BUILDFOLDER)/.builddummy $(AUTO_DIR_LIB)/.autodirdummy $(LCD_INSTALLDIR)/.installdummy
+ @echo $< > /dev/null
+
+.PHONY: validatevariables
+validatevariables: configfile
+ $(if $(CXX),, $(error "CXX not set"))
+ $(if $(BUILDFOLDER),, $(error "BUILDFOLDER not set"))
+ $(if $(AUTO_DIR_LIB),, $(error "AUTO_DIR_LIB 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 $(LCD_INSTALLDIR),, $(error "LCD_INSTALLDIR 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: AUTO_DIR_LIB :=$(BUILDFOLDER)/autogen/
+config: LIB_x32 := $(BUILDFOLDER)/liblcdriver.so
+config: LIB_x64 := $(BUILDFOLDER)/liblcdriver_x64.so
+config: LIB_x32_OBJ_DIR := x32
+config: LIB_x64_OBJ_DIR := x64
+config: CXX := $(CROSS_PREFIX)g++
+config: LCD_INSTALLDIR := /tmp/
+config:
+ @echo Generating config file...
+ @rm -f $(config_file)
+ @touch $(config_file)
+ @echo CXX: $(CXX)
+ @echo "CXX := $(CXX)" >> $(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 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 LCD_INSTALLDIR: $(LCD_INSTALLDIR)
+ @echo "LCD_INSTALLDIR := $(LCD_INSTALLDIR)" >> $(config_file)
+
+install: build
+ install -m 0755 -t $(LCD_INSTALLDIR) $(BUILDFOLDER)/liblcdriver.so
+ifeq ($(LBITS),64)
+ install -m 0755 -t $(LCD_INSTALLDIR) $(BUILDFOLDER)/liblcdriver_x64.so
+endif
+ install -m 0755 -t $(LCD_INSTALLDIR) $(WIN_BINARIES)/*.dll
+
+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 $(AUTO_DIR_LIB), \
+ @rm -f $(AUTO_DIR_LIB)/*.cpp \
+ @rm -f $(AUTO_DIR_LIB)/*.h,)
+ $(if $(LCD_INSTALLDIR), \
+ @rm -f $(LCD_INSTALLDIR)/liblcdriver.so,)
+ifeq ($(LBITS),64)
+ $(if $(LCD_INSTALLDIR), \
+ @rm -f $(LCD_INSTALLDIR)/liblcdriver_x64.so,)
+endif
+ $(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/README.txt b/README.txt
new file mode 100644
index 0000000..04d8a68
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,9 @@
+Before building the loader communication you need to download Xalan Processor
+and copy it to ./lcmodule/tools/xalan-j_2_7_1 folder.
+
+We've been using version 2.7.1 and here is how the contents of
+./lcmodule/tools/xalan-j_2_7_1 folder looks like:
+serializer.jar
+xalan.jar
+xercesImpl.jar
+xml-apis.jar
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
diff --git a/source/CEH/CmdResult.cpp b/source/CEH/CmdResult.cpp
new file mode 100644
index 0000000..2cc9b23
--- /dev/null
+++ b/source/CEH/CmdResult.cpp
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include "CmdResult.h"
+#include "Serialization.h"
+
+CmdResult::CmdResult()
+{
+ System_LoaderStartupStatus_Status = 0;
+
+ FileSystem_Properties_Mode = 0;
+ FileSystem_Properties_Size = 0;
+ FileSystem_Properties_MTime = 0;
+ FileSystem_Properties_ATime = 0;
+ FileSystem_Properties_CTime = 0;
+ FileSystem_VolumeProperties_Size = 0;
+ FileSystem_VolumeProperties_Free = 0;
+
+ GeneralResponse_Session = 0;
+
+ Security_GetDomain_WrittenDomain = 0;
+
+ A2_MaxLoaderPacketSize = 0;
+}
+
+CmdResult::~CmdResult()
+{
+}
+
diff --git a/source/CEH/CmdResult.h b/source/CEH/CmdResult.h
new file mode 100644
index 0000000..3fc6f99
--- /dev/null
+++ b/source/CEH/CmdResult.h
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _CMDRESULT_H_
+#define _CMDRESULT_H_
+
+#include "commands_types.h"
+#include "error_codes.h"
+#include "LCDriver.h"
+#include <vector>
+
+class CmdResult
+{
+public:
+ CmdResult();
+ virtual ~CmdResult();
+
+ //Session id for General Response.
+ uint32 GeneralResponse_Session;
+
+ // Copy of data received in Protrom Protocol
+ std::vector<uint8> ProtromPayloadData;
+
+ //Output data for System_LoaderStartupStatus.
+ uint32 System_LoaderStartupStatus_Status;
+ std::string System_LoaderStartupStatus_LoaderVersion;
+ std::string System_LoaderStartupStatus_ProtocolVersion;
+
+ //Output data for System_SupportedCommands.
+ std::vector<TSupportedCmd> System_SupportedCommands_CmdList;
+
+ //Output data for System_CollectData.
+ std::string System_CollectedData;
+
+ //Output data for Authentication Challenge.
+ std::vector<uint8> System_AuthenticationChallenge_Buffer;
+
+ //Output data for Flash_ListDevices.
+ std::vector<TDevicesInternal> Flash_ListDevices_Devices;
+
+ //Output data for FileSystem_VolumeProperties.
+ std::string FileSystem_VolumeProperties_FSType;
+ uint64 FileSystem_VolumeProperties_Size;
+ uint64 FileSystem_VolumeProperties_Free;
+
+ //Output data for FileSystem_ListDirectory.
+ std::vector<TEntriesInternal> FileSystem_ListDirectory_Entries;
+
+ //Output data for FileSystem_Properties.
+ int FileSystem_Properties_Mode;
+ uint64 FileSystem_Properties_Size;
+ int FileSystem_Properties_MTime;
+ int FileSystem_Properties_ATime;
+ int FileSystem_Properties_CTime;
+
+ //Output data for OTP_ReadBits.
+ std::vector<uint8> OTP_ReadBits_DataBuffer;
+ std::vector<uint8> OTP_ReadBits_StatusBuffer;
+
+ //Output data for ReadGlobalDataUnit.
+ std::vector<uint8> ParameterStorage_ReadGlobalDataUnit_DataBuffer;
+
+ //Output data for Security_GetDomain.
+ int Security_GetDomain_WrittenDomain;
+
+ //Output data for Security_GetProperties.
+ std::vector<uint8> Security_GetProperties_DataBuffer;
+
+ // A2 Protocol Outputs
+ uint32 A2_MaxLoaderPacketSize;
+ std::string A2_LoaderVersion;
+};
+
+#endif // _CMDRESULT_H_
+
diff --git a/source/CEH/ProtromRpcInterface.cpp b/source/CEH/ProtromRpcInterface.cpp
new file mode 100644
index 0000000..aa75334
--- /dev/null
+++ b/source/CEH/ProtromRpcInterface.cpp
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#include "ProtromRpcInterface.h"
+#include "t_protrom_transport.h"
+#include "Serialization.h"
+
+ProtromRpcInterface::ProtromRpcInterface(CmdResult *CmdResult, LcmInterface *LcmInterface)
+{
+ PROTROM_Payload = new uint8[0x10000];
+ cancelDeviceOnResult_ = false;
+ cmdResult_ = CmdResult;
+ lcmInterface_ = LcmInterface;
+ commDevice_ = NULL;
+}
+
+ProtromRpcInterface::~ProtromRpcInterface()
+{
+ ProtromQueue.SignalEvent();
+ delete[] PROTROM_Payload;
+}
+
+ErrorCode_e ProtromRpcInterface::Do_CEH_Callback(CommandData_t *CmdData_p)
+{
+ uint8 *Data_p = (uint8 *)CmdData_p->Payload.Data_p;
+
+ TProtromInfo *pInfo = new TProtromInfo;
+ pInfo->Length = CmdData_p->Payload.Size;
+ pInfo->DataP = new uint8[pInfo->Length];
+ memcpy(pInfo->DataP, Data_p, pInfo->Length);
+
+ int Pdu = *(Data_p + 7); //Get PDU number
+
+ switch (Pdu) {
+ case PROTROM_PDU_RESULT: {
+ pInfo->ReceivedPdu = PROTROM_PDU_RESULT;
+ pInfo->Status = DoneRPC_PROTROM_ResultImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_READY_TO_RECEIVE: {
+ pInfo->ReceivedPdu = PROTROM_PDU_READY_TO_RECEIVE;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_ERROR_DATA: {
+ pInfo->ReceivedPdu = PROTROM_PDU_ERROR_DATA;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+
+
+ case PROTROM_PDU_SECURITY_DATA_RES: {
+ pInfo->ReceivedPdu = PROTROM_PDU_SECURITY_DATA_RES;
+ pInfo->Status = DoneRPC_PROTROM_ReadSecurityDataImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_DOMAIN_DATA_REQ: {
+ pInfo->ReceivedPdu = PROTROM_PDU_DOMAIN_DATA_REQ;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_DOMAIN_DATA: {
+ pInfo->ReceivedPdu = PROTROM_PDU_DOMAIN_DATA;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_SECURITY_DATA_REQ: {
+ pInfo->ReceivedPdu = PROTROM_PDU_SECURITY_DATA_REQ;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_ROOT_KEY_REQ: {
+ pInfo->ReceivedPdu = PROTROM_PDU_ROOT_KEY_REQ;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_ROOT_KEY_DATA: {
+ pInfo->ReceivedPdu = PROTROM_PDU_ROOT_KEY_DATA;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_PATCH_REQ: {
+ pInfo->ReceivedPdu = PROTROM_PDU_PATCH_REQ;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_PATCH_DATA: {
+ pInfo->ReceivedPdu = PROTROM_PDU_PATCH_DATA;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_PATCH_DATA_FINAL: {
+ pInfo->ReceivedPdu = PROTROM_PDU_PATCH_DATA_FINAL;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_HEADER_OK_SW_REV: {
+ pInfo->ReceivedPdu = PROTROM_PDU_HEADER_OK_SW_REV;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_SW_REV_DATA: {
+ pInfo->ReceivedPdu = PROTROM_PDU_SW_REV_DATA;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_WDOG_RESET: {
+ pInfo->ReceivedPdu = PROTROM_PDU_WDOG_RESET;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+
+ case PROTROM_PDU_DATA_NOT_FOUND: {
+ pInfo->ReceivedPdu = PROTROM_PDU_DATA_NOT_FOUND;
+ pInfo->Status = DoneRPC_PROTROM_ReadyToReceiveImpl(*CmdData_p);
+ }
+ break;
+ }
+
+ ProtromQueue.AddRequest(static_cast<void *>(pInfo));
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e ProtromRpcInterface::DoRPC_PROTROM_ResultPdu(int Status)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Protrom_SendData_LP_t Data;
+ Protrom_Header_t Header;
+
+ Header.PayloadLength = 2; // PDU + Status
+ Data.Header_p = &Header; // PROTROM header
+ Data.Payload_p = PROTROM_Payload; // pointer to the payload data
+ PROTROM_Payload[0] = 0x04; // Result PDU 0x04.
+ PROTROM_Payload[1] = Status; // Status
+
+ Result = lcmInterface_->CommunicationSend(&Data);
+
+ return Result;
+}
+
+ErrorCode_e ProtromRpcInterface::DoRPC_PROTROM_SendLoaderHeader(unsigned char *pFile, uint32 Size)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Protrom_SendData_LP_t Data;
+ Protrom_Header_t Header;
+
+ Header.PayloadLength = 1 + (uint16)Size; // PDU + Header payload + padding.
+ Data.Header_p = &Header; // PROTROM header
+ Data.Payload_p = PROTROM_Payload; // pointer to the payload data
+
+ //Copy PDU and header data to Payload
+ PROTROM_Payload[0] = 0x01; //Header PDU 0x01
+
+ memcpy(PROTROM_Payload + 1, pFile, Size); //Copy header data
+
+ Result = lcmInterface_->CommunicationSend(&Data);
+
+ return Result;
+}
+
+ErrorCode_e ProtromRpcInterface::DoRPC_PROTROM_SendLoaderPayload(unsigned char *pFile, uint32 Size)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Protrom_SendData_LP_t Data;
+ Protrom_Header_t Header;
+
+ Header.PayloadLength = 1 + (uint16)Size; // PDU + Headeer payload.
+ Data.Header_p = &Header; // PROTROM header
+ Data.Payload_p = PROTROM_Payload; // pointer to the payload data
+
+ //Copy PDU and header data to Payload
+ PROTROM_Payload[0] = 0x02; //Payload PDU 0x02
+
+ memcpy(PROTROM_Payload + 1, pFile, Size); //Copy payload data
+
+ Result = lcmInterface_->CommunicationSend(&Data);
+
+ return Result;
+}
+
+ErrorCode_e ProtromRpcInterface::DoRPC_PROTROM_SendLoaderFinalPayload(unsigned char *pFile, uint32 Size)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Protrom_SendData_LP_t Data;
+ Protrom_Header_t Header;
+
+ Header.PayloadLength = 1 + (uint16)Size; // PDU + Payload.
+ Data.Header_p = &Header; // PROTROM header
+ Data.Payload_p = PROTROM_Payload; // pointer to the payload data
+
+ //Copy PDU and header data to Payload
+ PROTROM_Payload[0] = 0x03; //Final payload PDU 0x03
+
+ memcpy(PROTROM_Payload + 1, pFile, Size);
+
+ Result = lcmInterface_->CommunicationSend(&Data);
+
+ return Result;
+}
+
+ErrorCode_e ProtromRpcInterface::DoRPC_PROTROM_ReadSecurityData(uint8 SecDataId)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ Protrom_SendData_LP_t Data;
+ Protrom_Header_t Header;
+
+ Header.PayloadLength = 2; // PDU + Payload.
+ Data.Header_p = &Header; // PROTROM header
+ Data.Payload_p = PROTROM_Payload; // pointer to the payload data
+
+ //Copy PDU and header data to Payload
+ PROTROM_Payload[0] = 0x08; // Security Data Request PDU 0x08
+ PROTROM_Payload[1] = SecDataId;
+
+ Result = lcmInterface_->CommunicationSend(&Data);
+
+ return Result;
+}
+
+ErrorCode_e ProtromRpcInterface::DoneRPC_PROTROM_ResultImpl(CommandData_t CmdData)
+{
+ uint8 *Payload_p = CmdData.Payload.Data_p + PROTROM_HEADER_LENGTH;
+
+ // skip PDU type
+ Payload_p++;
+
+ if (cancelDeviceOnResult_) {
+ commDevice_->Cancel(lcmInterface_->getLCMContext());
+ }
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e ProtromRpcInterface::DoneRPC_PROTROM_ReadSecurityDataImpl(CommandData_t CmdData)
+{
+ uint8 *Payload_p = CmdData.Payload.Data_p + PROTROM_HEADER_LENGTH;
+ size_t PayloadLength = CmdData.Payload.Size - PROTROM_HEADER_LENGTH - PROTROM_CRC_LENGTH;
+
+ // skip PDU type
+ Payload_p++;
+ PayloadLength--;
+
+ cmdResult_->ProtromPayloadData.clear();
+ cmdResult_->ProtromPayloadData = vector<uint8>(Payload_p, Payload_p + PayloadLength);
+ return E_SUCCESS;
+}
+
+ErrorCode_e ProtromRpcInterface::DoneRPC_PROTROM_ReadyToReceiveImpl(CommandData_t CmdData)
+{
+ return E_SUCCESS;
+}
+
+void ProtromRpcInterface::CancelDeviceOnResult(CommunicationDevice_t *commDevice)
+{
+ cancelDeviceOnResult_ = true;
+ commDevice_ = commDevice;
+}
diff --git a/source/CEH/ProtromRpcInterface.h b/source/CEH/ProtromRpcInterface.h
new file mode 100644
index 0000000..43ed46f
--- /dev/null
+++ b/source/CEH/ProtromRpcInterface.h
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _PROTROMRPCINTERFACE_H_
+#define _PROTROMRPCINTERFACE_H_
+
+#include "CmdResult.h"
+#include "LcmInterface.h"
+#ifdef _WIN32
+#include "WinApiWrappers.h"
+#else
+#include "CSimpleQueue.h"
+#endif
+
+/// <summary>
+/// PROTROM command definitions.
+/// </summary>
+typedef enum {
+ PROTROM_PDU_HEADER = 1,
+ PROTROM_PDU_PAYLOAD = 2,
+ PROTROM_PDU_PAYLOAD_FINAL = 3,
+ PROTROM_PDU_RESULT = 4,
+ PROTROM_PDU_READY_TO_RECEIVE = 5,
+ PROTROM_PDU_ERROR_DATA = 6,
+ PROTROM_PDU_SECURITY_DATA_REQ = 8,
+ PROTROM_PDU_SECURITY_DATA_RES = 9,
+ PROTROM_PDU_DOMAIN_DATA_REQ = 43,
+ PROTROM_PDU_DOMAIN_DATA = 44,
+ PROTROM_PDU_ROOT_KEY_REQ = 45,
+ PROTROM_PDU_ROOT_KEY_DATA = 46,
+ PROTROM_PDU_PATCH_REQ = 47,
+ PROTROM_PDU_PATCH_DATA = 48,
+ PROTROM_PDU_PATCH_DATA_FINAL = 49,
+ PROTROM_PDU_HEADER_OK_SW_REV = 51,
+ PROTROM_PDU_SW_REV_DATA = 52,
+ PROTROM_PDU_WDOG_RESET = 53,
+ PROTROM_PDU_DATA_NOT_FOUND = 100
+} PROTROMCommandId_e;
+
+struct TProtromInfo {
+ int ReceivedPdu;
+ void *DataP;
+ uint32 Length;
+ uint8 Status;
+};
+
+class ProtromRpcInterface
+{
+public:
+ ProtromRpcInterface(CmdResult *CmdResult, LcmInterface *LcmInterface);
+ virtual ~ProtromRpcInterface();
+
+ CSimpleQueue ProtromQueue;
+
+ //PROTROM-Protocol
+ ErrorCode_e DoRPC_PROTROM_ResultPdu(int Status);
+ ErrorCode_e DoRPC_PROTROM_SendLoaderHeader(unsigned char *pFile, uint32 Size);
+ ErrorCode_e DoRPC_PROTROM_SendLoaderPayload(unsigned char *pFile, uint32 Size);
+ ErrorCode_e DoRPC_PROTROM_SendLoaderFinalPayload(unsigned char *pFile, uint32 Size);
+ ErrorCode_e DoRPC_PROTROM_ReadSecurityData(uint8 SecDataId);
+
+ ErrorCode_e DoneRPC_PROTROM_ResultImpl(CommandData_t CmdData);
+ ErrorCode_e DoneRPC_PROTROM_ReadSecurityDataImpl(CommandData_t CmdData);
+ ErrorCode_e DoneRPC_PROTROM_ReadyToReceiveImpl(CommandData_t CmdData);
+
+ ErrorCode_e Do_CEH_Callback(CommandData_t *pCmdData);
+
+ void CancelDeviceOnResult(CommunicationDevice_t *commDevice);
+private:
+ uint8 *PROTROM_Payload;
+ bool cancelDeviceOnResult_;
+ CommunicationDevice_t *commDevice_;
+ CmdResult *cmdResult_;
+ LcmInterface *lcmInterface_;
+};
+
+#endif // _PROTROMRPCINTERFACE_H_
diff --git a/source/CEH/ZRpcInterface.cpp b/source/CEH/ZRpcInterface.cpp
new file mode 100644
index 0000000..5476e8f
--- /dev/null
+++ b/source/CEH/ZRpcInterface.cpp
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include "ZRpcInterface.h"
+
+ZRpcInterface::ZRpcInterface(CmdResult *CmdResult, LcmInterface *LcmInterface)
+{
+ Z_Payload = 0;
+ cmdResult_ = CmdResult;
+ lcmInterface_ = LcmInterface;
+
+ Z_IndataBuffer = new LockLessQueue(10);
+}
+
+ZRpcInterface::~ZRpcInterface()
+{
+ delete Z_IndataBuffer;
+ delete[] Z_Payload;
+}
+
+ErrorCode_e ZRpcInterface::Do_CEH_Callback(CommandData_t *CmdData_p)
+{
+ ErrorCode_e Status = E_GENERAL_FATAL_ERROR;
+
+ Status = DoneRPC_Z_ReadImpl(*CmdData_p);
+
+ return Status;
+}
+
+ErrorCode_e ZRpcInterface::DoRPC_Z_VersionRequest()
+{
+ ErrorCode_e Result = E_SUCCESS;
+
+ if (Z_Payload != 0) {
+ delete [] Z_Payload;
+ Z_Payload = 0;
+ }
+
+ Z_Payload = new uint8[2];
+ Z_Payload[0] = 0x01;
+ Z_Payload[1] = 0x3F;
+
+ Result = lcmInterface_->CommunicationSend(Z_Payload);
+
+ return Result;
+}
+
+ErrorCode_e ZRpcInterface::DoRPC_Z_SetBaudrate(int Baudrate)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ char Rate;
+
+ switch (Baudrate) {
+ case 9600:
+ Rate = '0';
+ break;
+
+ case 19200:
+ Rate = '1';
+ break;
+
+ case 38400:
+ Rate = '2';
+ break;
+
+ case 57600:
+ Rate = '3';
+ break;
+
+ case 115200:
+ Rate = '4';
+ break;
+
+ case 230400:
+ Rate = '5';
+ break;
+
+ case 460800:
+ Rate = '6';
+ break;
+
+ case 921600:
+ Rate = '7';
+ break;
+
+ case 1625000:
+ Rate = '8';
+ break;
+
+ default :
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ if (Z_Payload != 0) {
+ delete [] Z_Payload;
+ Z_Payload = 0;
+ }
+
+ Z_Payload = new uint8[3];
+
+ Z_Payload[0] = 0x02;
+ Z_Payload[1] = 'S';
+ Z_Payload[2] = Rate;
+
+ Result = lcmInterface_->CommunicationSend(Z_Payload);
+
+ return Result;
+}
+
+ErrorCode_e ZRpcInterface::DoRPC_Z_Exit_Z_Protocol()
+{
+ ErrorCode_e Result = E_SUCCESS;
+
+ if (Z_Payload != 0) {
+ delete [] Z_Payload;
+ Z_Payload = 0;
+ }
+
+ Z_Payload = new uint8[2];
+ Z_Payload[0] = 0x01;
+ Z_Payload[1] = 'Q';
+
+ Result = lcmInterface_->CommunicationSend(Z_Payload);
+
+ return Result;
+}
+
+ErrorCode_e ZRpcInterface::DoneRPC_Z_ReadImpl(CommandData_t CmdData)
+{
+ unsigned char Data_p = *CmdData.Payload.Data_p;
+ bool Full = false;
+
+ Z_IndataBuffer->Push(Data_p, &Full);
+
+ if (Full == true) {
+ return E_GENERAL_FATAL_ERROR;
+ }
+
+ return E_SUCCESS;
+}
diff --git a/source/CEH/ZRpcInterface.h b/source/CEH/ZRpcInterface.h
new file mode 100644
index 0000000..3d630c2
--- /dev/null
+++ b/source/CEH/ZRpcInterface.h
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _ZRPCINTERFACE_H_
+#define _ZRPCINTERFACE_H_
+
+#include "CmdResult.h"
+#include "LcmInterface.h"
+#include "LockLessQueue.h"
+
+class ZRpcInterface
+{
+public:
+ ZRpcInterface(CmdResult *CmdResult, LcmInterface *LcmInterface);
+ virtual ~ZRpcInterface();
+
+ //Circular buffer for received data when using Z-protocol.
+ LockLessQueue *Z_IndataBuffer;
+
+ //Z-Protocol
+ ErrorCode_e DoRPC_Z_VersionRequest();
+ ErrorCode_e DoRPC_Z_SetBaudrate(int Baudrate);
+ ErrorCode_e DoRPC_Z_Exit_Z_Protocol();
+
+ ErrorCode_e DoneRPC_Z_ReadImpl(CommandData_t CmdData);
+
+ ErrorCode_e Do_CEH_Callback(CommandData_t *pCmdData);
+
+private:
+ //Payload variable for z-protocol
+ uint8 *Z_Payload;
+ CmdResult *cmdResult_;
+ LcmInterface *lcmInterface_;
+};
+
+#endif // _ZRPCINTERFACE_H_
diff --git a/source/CEH/a2_commands_impl.cpp b/source/CEH/a2_commands_impl.cpp
new file mode 100644
index 0000000..6753145
--- /dev/null
+++ b/source/CEH/a2_commands_impl.cpp
@@ -0,0 +1,122 @@
+/*******************************************************************************
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*******************************************************************************/
+
+#include "a2_commands_impl.h"
+#include "Serialization.h"
+#include "CmdResult.h"
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoneRPC_A2_System_ShutdownImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoneRPC_A2_System_LoaderVersionImpl(uint16 Session, ErrorCode_e Status, int LoaderVersionOutPLSize, const void *LoaderVersionOut)
+{
+ if (0 == Status) {
+ cmdResult_->A2_LoaderVersion = string(static_cast<const char *>(LoaderVersionOut), LoaderVersionOutPLSize);
+ }
+
+ cmdResult_->GeneralResponse_Session = Session;
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoneRPC_A2_System_LoaderOnLoaderImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoneRPC_A2_System_ResetImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoneRPC_A2_Flash_VerifySignedHeaderImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoneRPC_A2_Flash_SoftwareBlockAddressImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoneRPC_A2_Flash_ProgramFlashImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoneRPC_A2_Flash_VerifySoftwareFlashImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoneRPC_A2_Flash_EraseFlashImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoneRPC_A2_Flash_SpeedflashImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoRPC_A2_Control_LoaderStartedImpl(uint16 Session, const uint32 MaxLoaderPacketSize)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ cmdResult_->A2_MaxLoaderPacketSize = MaxLoaderPacketSize;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoneRPC_A2_Control_PingImpl(uint16 Session)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoRPC_A2_Control_PongImpl(uint16 Session)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoneRPC_A2_Control_MaxPacketSizeImpl(uint16 Session, const uint16 MaxLoaderPacketSize)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ cmdResult_->A2_MaxLoaderPacketSize = MaxLoaderPacketSize;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::DoRPC_A2_Control_LoaderNotStartedImpl(uint16 Session, uint16 ErrorCode)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
diff --git a/source/CEH/commands_impl.cpp b/source/CEH/commands_impl.cpp
new file mode 100644
index 0000000..f08acb1
--- /dev/null
+++ b/source/CEH/commands_impl.cpp
@@ -0,0 +1,402 @@
+/*******************************************************************************
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*******************************************************************************/
+
+#include "commands_impl.h"
+#include "commands_types.h"
+#include "Serialization.h"
+#include "CmdResult.h"
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoRPC_System_LoaderStartUpStatusImpl(uint16 Session, const uint32 Status, const char *LoaderVersion_p, const char *ProtocolVersion_p)
+{
+ cmdResult_->System_LoaderStartupStatus_Status = Status;
+
+ uint32 size = Serialization::get_uint32_le((const void **)&LoaderVersion_p);
+ cmdResult_->System_LoaderStartupStatus_LoaderVersion = string(LoaderVersion_p, size);
+ size = Serialization::get_uint32_le((const void **)&ProtocolVersion_p);
+ cmdResult_->System_LoaderStartupStatus_ProtocolVersion = string(ProtocolVersion_p, size);
+
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_System_RebootImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_System_ShutDownImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_System_SupportedCommandsImpl(uint16 Session, ErrorCode_e Status, const uint32 CommandCount, SupportedCommand_t Commands[])
+{
+ if (0 == Status) {
+ cmdResult_->System_SupportedCommands_CmdList.clear();
+
+ for (size_t i = 0; i != CommandCount && Commands != NULL; ++i) {
+ TSupportedCmd cmd = { Commands[i].Group, Commands[i].Command, Commands[i].Permitted };
+ cmdResult_->System_SupportedCommands_CmdList.push_back(cmd);
+ }
+ }
+
+ delete[] Commands;
+
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_System_ExecuteSoftwareImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_System_AuthenticateImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoRPC_System_GetControlKeysImpl(uint16 Session)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoRPC_System_GetControlKeysDataImpl(uint16 Session)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+ return E_SUCCESS;
+}
+ErrorCode_e LoaderRpcInterfaceImpl::DoRPC_System_AuthenticationChallengeImpl(uint16 Session, const uint32 ChallengeBlockLength, const void *ChallengeBlock_p)
+{
+ cmdResult_->System_AuthenticationChallenge_Buffer.clear();
+ uint8 *CdbStart = (uint8 *)ChallengeBlock_p;
+ cmdResult_->System_AuthenticationChallenge_Buffer = vector<uint8>(CdbStart, CdbStart + ChallengeBlockLength);
+
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_System_CollectDataImpl(uint16 Session, ErrorCode_e Status, const uint32 DataLenght, const void *CollectedData_p)
+{
+
+
+ if (0 == Status) {
+ cmdResult_->System_CollectedData = string((const char *)CollectedData_p, DataLenght);
+ }
+
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_System_GetProgressStatusImpl(uint16 Session, ErrorCode_e Status, const uint32 ProgressStatus)
+{
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_System_SetSystemTimeImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_System_SwitchCommunicationDeviceImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_Flash_ProcessFileImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_Flash_ListDevicesImpl(uint16 Session, ErrorCode_e Status, const uint32 DeviceCount, ListDevice_t Devices[])
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_Flash_DumpAreaImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_Flash_EraseAreaImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_Flash_FlashRawImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_File_System_Operations_VolumePropertiesImpl(uint16 Session, ErrorCode_e Status, const char *FS_Type_p, const uint64 Size, const uint64 Free)
+{
+
+
+ if (0 == Status) {
+ uint32 size = Serialization::get_uint32_le((const void **)&FS_Type_p);
+ cmdResult_->FileSystem_VolumeProperties_FSType = string(FS_Type_p, size);
+ cmdResult_->FileSystem_VolumeProperties_Size = Size;
+ cmdResult_->FileSystem_VolumeProperties_Free = Free;
+ }
+
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_File_System_Operations_FormatVolumeImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_File_System_Operations_ListDirectoryImpl(uint16 Session, ErrorCode_e Status, const uint32 EntriesCount, DirEntry_t Entries[])
+{
+
+
+ if (0 == Status) {
+ cmdResult_->FileSystem_ListDirectory_Entries.clear();
+
+ for (size_t i = 0; i < EntriesCount; i++) {
+ TEntriesInternal directory = {
+ string(Entries[i].Name_p),
+ Entries[i].Size,
+ Entries[i].Mode,
+ Entries[i].Time
+ };
+ cmdResult_->FileSystem_ListDirectory_Entries.push_back(directory);
+
+ delete[] Entries[i].Name_p;
+ }
+ }
+
+ cmdResult_->GeneralResponse_Session = Session;
+
+ delete[] Entries;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_File_System_Operations_MoveFileImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_File_System_Operations_DeleteFileImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_File_System_Operations_CopyFileImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_File_System_Operations_CreateDirectoryImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_File_System_Operations_PropertiesImpl(uint16 Session, ErrorCode_e Status, const uint32 Mode, const uint64 Size, const uint32 MTime, const uint32 ATime, const uint32 CTime)
+{
+
+
+ if (0 == Status) {
+ cmdResult_->FileSystem_Properties_Mode = Mode;
+ cmdResult_->FileSystem_Properties_Size = Size;
+ cmdResult_->FileSystem_Properties_MTime = MTime;
+ cmdResult_->FileSystem_Properties_ATime = ATime;
+ cmdResult_->FileSystem_Properties_CTime = CTime;
+ }
+
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoRPC_File_System_Operations_PropertiesImpl(uint16 SessionOut, const char *TargetPath_p)
+{
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_File_System_Operations_ChangeAccessImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_File_System_Operations_ReadLoadModulesManifestsImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_OTP_ReadBitsImpl(uint16 Session, ErrorCode_e Status, const uint32 BitsLength, const uint32 DataBitsLength, const void *DataBits_p, const uint32 LockStatusBitsLength, const uint32 LockStatusLength, const void *LockStatus_p) // CommandData_t CmdData)
+{
+
+
+ if (0 == Status && DataBits_p != NULL && LockStatus_p != NULL) {
+ cmdResult_->OTP_ReadBits_DataBuffer.clear();
+ uint8 *BitsP = (uint8 *)DataBits_p;
+ cmdResult_->OTP_ReadBits_DataBuffer = vector<uint8>(BitsP, BitsP + DataBitsLength);
+
+ cmdResult_->OTP_ReadBits_StatusBuffer.clear();
+ BitsP = (uint8 *)LockStatus_p;
+ cmdResult_->OTP_ReadBits_StatusBuffer = vector<uint8>(BitsP, BitsP + LockStatusLength);
+ }
+
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_OTP_SetBitsImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_OTP_WriteAndLockImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_OTP_StoreSecureObjectImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_ParameterStorage_ReadGlobalDataUnitImpl(uint16 Session, ErrorCode_e Status, const uint32 DataBuffLength, const void *DataBuff_p)
+{
+
+
+ if (0 == Status && DataBuff_p != NULL) {
+ cmdResult_->ParameterStorage_ReadGlobalDataUnit_DataBuffer.clear();
+ uint8 *DataP = (uint8 *)DataBuff_p;
+ cmdResult_->ParameterStorage_ReadGlobalDataUnit_DataBuffer = vector<uint8>(DataP, DataP + DataBuffLength);
+ }
+
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_ParameterStorage_WriteGlobalDataUnitImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_ParameterStorage_ReadGlobalDataSetImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_ParameterStorage_WriteGlobalDataSetImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_ParameterStorage_EraseGlobalDataSetImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_Security_SetDomainImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_Security_GetDomainImpl(uint16 Session, ErrorCode_e Status, const uint32 CurrentDomain)
+{
+ if (0 == Status) {
+ cmdResult_->Security_GetDomain_WrittenDomain = CurrentDomain;
+ }
+
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_Security_GetPropertiesImpl(uint16 Session, ErrorCode_e Status, const uint32 DataBuffLength, const void *DataBuff_p)
+{
+ if (0 == Status && DataBuff_p != NULL) {
+ cmdResult_->Security_GetProperties_DataBuffer.clear();
+ uint8 *DataP = (uint8 *)DataBuff_p;
+ cmdResult_->Security_GetProperties_DataBuffer = vector<uint8>(DataP, DataP + DataBuffLength);
+ }
+
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_Security_SetPropertiesImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
+
+ErrorCode_e LoaderRpcInterfaceImpl::DoneRPC_Security_BindPropertiesImpl(uint16 Session, ErrorCode_e Status)
+{
+ cmdResult_->GeneralResponse_Session = Session;
+
+ return E_SUCCESS;
+}
diff --git a/source/CEH/commands_types.h b/source/CEH/commands_types.h
new file mode 100644
index 0000000..eec039c
--- /dev/null
+++ b/source/CEH/commands_types.h
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _COMMANDS_TYPES_H_
+#define _COMMANDS_TYPES_H_
+
+#include "t_basicdefinitions.h"
+#include "LCDriver.h"
+#include <string>
+
+/// <summary>
+/// Description of ME device.
+/// </summary>
+/// <param name="szPath">Absolute device path pointing at the described device.</param>
+/// <param name="iPathSize">Size of pchPath.</param>
+/// <param name="szType">Type of device.</param>
+/// <param name="iTypeSize">Size of pchType.</param>
+/// <param name="uiBlockSize">Size of the smallest addressable unit in the device [Byte].</param>
+/// <param name="uiStart">Offset [Byte] of the start of the device relative its parent's
+/// offset 0 with granularity of its parent's block size.</param>
+/// <param name="uiLength">Length of the device [Byte].</param>
+struct TDevicesInternal {
+ std::string Path;
+ std::string Type;
+ uint64 uiBlockSize;
+ uint64 uiStart;
+ uint64 uiLength;
+
+ operator TDevices() const {
+ TDevices tDevice = {
+ Path.c_str(),
+ Path.length(),
+ Type.c_str(),
+ Type.length(),
+ uiBlockSize,
+ uiStart,
+ uiLength
+ };
+
+ return tDevice;
+ }
+};
+
+struct TEntriesInternal {
+ std::string Name;
+ uint64 uiSize;
+ int iMode;
+ int iTime;
+
+ operator TEntries() const {
+ TEntries tEntry = {
+ Name.c_str(),
+ Name.length(),
+ uiSize,
+ iMode,
+ iTime
+ };
+
+ return tEntry;
+ }
+};
+
+#endif // _COMMANDS_TYPES_H_ \ No newline at end of file
diff --git a/source/LCDriver.cpp b/source/LCDriver.cpp
new file mode 100644
index 0000000..9ce9c25
--- /dev/null
+++ b/source/LCDriver.cpp
@@ -0,0 +1,595 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include "LCDriver.h"
+#include "lcdriver_error_codes.h"
+#include "LCDriverInterface.h"
+#include "Error.h"
+
+#define VERIFY_CONTEXT(c) \
+ do { \
+ if ((c) == NULL) \
+ return INTERFACE_OBJECT_POINTER_NULL; \
+ if ((c)->m_pObject == NULL) \
+ return INTERFACE_LC_METHODS_OBJECT_NULL; \
+ } while (0)
+
+#define VERIFY_CONTEXT_STARTED(c) \
+ do { \
+ VERIFY_CONTEXT(c); \
+ if (!(c)->isStarted) \
+ return INTERFACE_CONTEXT_NOT_STARTED; \
+ } while (0)
+
+/************************************************************************************************
+* API functions for LCDriver functionalities
+************************************************************************************************/
+LCDRIVER_API int __cdecl Initialize(LCDContext *pContext, const char *InterfaceId, void *Read_fn, void *Write_fn, void *Cancel_fn, void **Instance, void *Message_fn, const char *LCMLibPath, void *ProgressBar_fn)
+{
+ SetLCMLibPath(LCMLibPath);
+
+ int Result = CreateContext(pContext, InterfaceId);
+
+ if (0 != Result) {
+ return Result;
+ }
+
+ // check if we have context that was previously started
+ if (!(*pContext)->isStarted) {
+ ConfigureCommunicationDevice(*pContext, Read_fn, Write_fn, Cancel_fn);
+ SwitchProtocolFamily(*pContext, R15_PROTOCOL_FAMILY);
+ SetMessageCallback(*pContext, Message_fn);
+ SetProgressCallback(*pContext, ProgressBar_fn);
+
+ return StartContext(*pContext, Instance);
+ } else {
+ return 0;
+ }
+}
+
+LCDRIVER_API void __cdecl SetLCMLibPath(const char *LCMLibPath)
+{
+ LcmInterface::SetLCMLibPath(LCMLibPath);
+}
+
+LCDRIVER_API int __cdecl CreateContext(LCDContext *pContext, const char *InterfaceId)
+{
+ CLockCS CsLock(CLCDriverInterface::InitializationCS);
+
+ CLCDriverInterface *Context = NULL;
+ int ReturnValue = E_SUCCESS;
+
+ // Check pointer to pointer
+ VERIFY(NULL != pContext, INTERFACE_OBJECT_POINTER_TO_POINTER_NULL);
+
+ // Check if CLCDriverInterface already exists
+ VERIFY(NULL == *pContext, INTERFACE_OBJECT_ALREADY_EXISTS);
+
+ // Check context id
+ VERIFY(NULL != InterfaceId, INTERFACE_INTERFACEID_POINTER_NULL);
+
+ // Create new CLCDriverInterface
+ Context = new CLCDriverInterface();
+ VERIFY(NULL != Context, INTERFACE_COULD_NOT_CREATE_IFC_OBJECT);
+
+ strcpy_s(Context->m_szObjectId, InterfaceId);
+
+ // Check in the object list if this particular object has been created earlier.
+ Context->m_pObject = CLCDriverInterface::FindObject(Context->m_szObjectId);
+
+ // An object was found in the list
+ if (Context->m_pObject == NULL) {
+ // Create new CLCDriverMethods
+ Context->m_pObject = new CLCDriverMethods(InterfaceId);
+ VERIFY(NULL != Context->m_pObject, INTERFACE_COULD_NOT_CREATE_OBJECT);
+ }
+
+ // Add the object to the list to increase the reference counter
+ ReturnValue = CLCDriverInterface::AddObject(Context->m_pObject, Context->m_szObjectId);
+ VERIFY(0 == ReturnValue, INTERFACE_COULD_NOT_ADD_OBJECT_TO_LIST);
+
+ *pContext = Context;
+
+ return E_SUCCESS;
+ErrorExit:
+
+ // Delete the CLCDriverInterface
+ if (Context != NULL) {
+ if (Context->m_pObject != NULL) {
+ delete Context->m_pObject;
+ Context->m_pObject = NULL;
+ }
+
+ delete Context;
+ }
+
+ return ReturnValue;
+}
+
+LCDRIVER_API int __cdecl SwitchProtocolFamily(LCDContext Context, TFamily Family)
+{
+ VERIFY_CONTEXT(Context);
+
+ if (Context->isStarted) {
+ return Context->m_pObject->Do_SwitchProtocolFamily(Family);
+ } else {
+ return Context->m_pObject->SetInitialProtocolFamily(Family);
+ }
+}
+
+LCDRIVER_API int __cdecl ConfigureCommunicationDevice(LCDContext Context, void *Read_fn, void *Write_fn, void *Cancel_fn)
+{
+ VERIFY_CONTEXT(Context);
+
+ Context->m_pObject->ConfigureCommunicationDevice(Read_fn, Write_fn, Cancel_fn);
+ return 0;
+}
+
+LCDRIVER_API int __cdecl SetMessageCallback(LCDContext Context, void *Callback_fn)
+{
+ VERIFY_CONTEXT(Context);
+
+ Context->m_pObject->SetMessageCallback(Callback_fn);
+ return 0;
+}
+
+LCDRIVER_API int __cdecl SetProgressCallback(LCDContext Context, void *Callback_fn)
+{
+ VERIFY_CONTEXT(Context);
+
+ Context->m_pObject->SetProgressCallback(Callback_fn);
+ return 0;
+}
+
+LCDRIVER_API int __cdecl StartContext(LCDContext Context, void **Instance)
+{
+ VERIFY_CONTEXT(Context);
+
+ int Result = Context->m_pObject->Do_Initialize(Instance);
+
+ if (0 == Result) {
+ Context->isStarted = true;
+ }
+
+ return Result;
+}
+
+LCDRIVER_API int __cdecl DestroyContext(LCDContext *pContext)
+{
+ LCDContext Context = *pContext;
+ VERIFY_CONTEXT(Context);
+
+ delete Context;
+ *pContext = NULL;
+
+ return 0;
+}
+
+LCDRIVER_API int __cdecl Close(LCDContext Context)
+{
+ return DestroyContext(&Context);
+}
+
+LCDRIVER_API int __cdecl SetTimeouts(LCDContext Context, TR15Timeouts *R15_TOs, TLCDriverTimeouts *LCD_TOs)
+{
+ VERIFY_CONTEXT(Context);
+
+ return Context->m_pObject->SetPcTimeouts(R15_TOs, LCD_TOs);
+}
+
+LCDRIVER_API int __cdecl GetTimeouts(LCDContext Context, TR15Timeouts *R15_TOs, TLCDriverTimeouts *LCD_TOs)
+{
+ VERIFY_CONTEXT(Context);
+
+ return Context->m_pObject->GetPcTimeouts(R15_TOs, LCD_TOs);
+}
+
+LCDRIVER_API int __cdecl CancelCurrentLoaderCommand(LCDContext Context)
+{
+ VERIFY_CONTEXT(Context);
+
+ Context->m_pObject->CancelCurrentLoaderCommand();
+
+ return 0;
+}
+
+/************************************************************************************************
+* API functions for loader commands
+************************************************************************************************/
+LCDRIVER_API int __cdecl System_LoaderStartupStatus(LCDContext Context, char *pchVersion, int *piVersionSize, char *pchProtocol, int *piProtocolSize)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Done_System_LoaderStartupStatus(pchVersion, piVersionSize, pchProtocol, piProtocolSize);
+}
+
+LCDRIVER_API int __cdecl System_Reboot(LCDContext Context, int iMode)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_System_Reboot(iMode);
+}
+
+LCDRIVER_API int __cdecl System_Shutdown(LCDContext Context)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_System_Shutdown();
+}
+
+LCDRIVER_API int __cdecl System_SupportedCommands(LCDContext Context, TSupportedCmd *pCmdList, int *piCmdListSize)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_System_SupportedCommands(pCmdList, piCmdListSize);
+}
+
+LCDRIVER_API int __cdecl System_CollectData(LCDContext Context, int iType, int *piSize, char *pData)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_System_CollectData(iType, piSize, pData);
+}
+
+LCDRIVER_API int __cdecl System_ExecuteSoftware(LCDContext Context, const uint32 ExecuteMode, const char *pchDevicePath, int iUseBulk)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_System_ExecuteSoftware(ExecuteMode, pchDevicePath, iUseBulk);
+}
+
+LCDRIVER_API int __cdecl System_Authenticate(LCDContext Context, int iType, int *piSize, unsigned char *puchdata)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_System_Authenticate(iType, piSize, puchdata);
+}
+
+LCDRIVER_API int __cdecl System_GetControlKeys(LCDContext Context, TSIMLockKeys *pSIMLockKeys)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Done_System_GetControlKeys(pSIMLockKeys);
+}
+
+LCDRIVER_API int __cdecl System_GetControlKeysData(LCDContext Context, int iDataSize, unsigned char *pSIMLockKeysData)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Done_System_GetControlKeysData(iDataSize, pSIMLockKeysData);
+}
+
+LCDRIVER_API int __cdecl System_AuthenticationChallenge(LCDContext Context, unsigned char *puchChallengeData, int iDataSize)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Done_System_AuthenticationChallenge(iDataSize, puchChallengeData);
+}
+
+LCDRIVER_API int __cdecl System_SetSystemTime(LCDContext Context, uint32 uiEpochTime)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_System_SetSystemTime(uiEpochTime);
+}
+
+LCDRIVER_API int __cdecl System_SwitchCommunicationDevice(LCDContext Context, uint32 uiDevice, uint32 uiDeviceParam)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_System_SwitchCommunicationDevice(uiDevice, uiDevice);
+}
+
+LCDRIVER_API int __cdecl Flash_ProcessFile(LCDContext Context, const char *pchPath, const char *pchType, int iUseBulk, int iDeleteBuffers)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_Flash_ProcessFile(pchPath, pchType, iUseBulk, iDeleteBuffers);
+}
+
+LCDRIVER_API int __cdecl Flash_ListDevices(LCDContext Context, TDevices *pDevices, int *piDeviceSize)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_Flash_ListDevices(pDevices, piDeviceSize);
+}
+
+LCDRIVER_API int __cdecl Flash_DumpArea(LCDContext Context, const char *pchPathToDump, uint64 uiStart, uint64 uiLength, const char *pchFilePath, uint32 uiRedundantArea, int iUseBulk)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_Flash_DumpArea(pchPathToDump, uiStart, uiLength, pchFilePath, uiRedundantArea, iUseBulk);
+}
+
+LCDRIVER_API int __cdecl Flash_EraseArea(LCDContext Context, const char *pchPath, uint64 uiStart, uint64 uiLength)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_Flash_EraseArea(pchPath, uiStart, uiLength);
+}
+
+LCDRIVER_API int __cdecl Flash_FlashRaw(LCDContext Context, const char *pchPath, uint64 uiStart, uint64 uiLength, uint32 uiDevice, int iUseBulk, int iDeleteBuffers)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_Flash_FlashRaw(pchPath, uiStart, uiLength, uiDevice, iUseBulk, iDeleteBuffers);
+}
+
+LCDRIVER_API int __cdecl FileSystem_VolumeProperties(LCDContext Context, const char *pchDevicePath, char *pchFSType, int *piFSTypeSize, uint64 *puiSize, uint64 *puiFree)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_FileSystem_VolumeProperties(pchDevicePath, pchFSType, piFSTypeSize, puiSize, puiFree);
+}
+
+LCDRIVER_API int __cdecl FileSystem_FormatVolume(LCDContext Context, const char *pchDevicePath)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_FileSystem_FormatVolume(pchDevicePath);
+}
+
+LCDRIVER_API int __cdecl FileSystem_ListDirectory(LCDContext Context, const char *pchPath, TEntries *pEntries, int *piDeviceSize)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_FileSystem_ListDirectory(pchPath, pEntries, piDeviceSize);
+}
+
+LCDRIVER_API int __cdecl FileSystem_MoveFile(LCDContext Context, const char *pchSourcePath, const char *pchDestinationPath)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_FileSystem_MoveFile(pchSourcePath, pchDestinationPath);
+}
+
+LCDRIVER_API int __cdecl FileSystem_DeleteFile(LCDContext Context, const char *pchTargetPath)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_FileSystem_DeleteFile(pchTargetPath);
+}
+
+LCDRIVER_API int __cdecl FileSystem_CopyFile(LCDContext Context, const char *pchSourcePath, int iSourceUseBulk, const char *pchDestinationPath, int iDestinationUseBulk)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_FileSystem_CopyFile(pchSourcePath, iSourceUseBulk, pchDestinationPath, iDestinationUseBulk);
+}
+
+LCDRIVER_API int __cdecl FileSystem_CreateDirectory(LCDContext Context, const char *pchTargetPath)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_FileSystem_CreateDirectory(pchTargetPath);
+}
+
+LCDRIVER_API int __cdecl FileSystem_Properties(LCDContext Context, const char *pchTargetPath, uint32 *puiMode, uint64 *puiSize, int *piMTime, int *piATime, int *piCTime)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_FileSystem_Properties(pchTargetPath, puiMode, puiSize, piMTime, piATime, piCTime);
+}
+
+LCDRIVER_API int __cdecl FileSystem_ChangeAccess(LCDContext Context, const char *pchTargetPath, int iAccess)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_FileSystem_ChangeAccess(pchTargetPath, iAccess);
+}
+
+LCDRIVER_API int __cdecl FileSystem_ReadLoadModuleManifests(LCDContext Context, const char *pchTargetPath, const char *pchSourcePath)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_FileSystem_ReadLoadModuleManifests(pchTargetPath, pchSourcePath);
+}
+
+LCDRIVER_API int __cdecl OTP_ReadBits(LCDContext Context, int iOtpId, int iBitStart, int iBitLength, unsigned char *puchDataBuffer, int *piDataBufferSize, unsigned char *puchStatusBuffer, int *piStatusBufferSize)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_OTP_ReadBits(iOtpId, iBitStart, iBitLength, puchDataBuffer, piDataBufferSize, puchStatusBuffer, piStatusBufferSize);
+}
+
+LCDRIVER_API int __cdecl OTP_SetBits(LCDContext Context, int iOtpId, int iBitStart, int iBitLength, unsigned char *puchDataBuffer)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_OTP_SetBits(iOtpId, iBitStart, iBitLength, puchDataBuffer);
+}
+
+LCDRIVER_API int __cdecl OTP_WriteAndLock(LCDContext Context, int iOtpId, int iForceWrite)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_OTP_WriteAndLock(iOtpId, iForceWrite);
+}
+
+LCDRIVER_API int __cdecl ParameterStorage_ReadGlobalDataUnit(LCDContext Context, const char *pchGdfsId, int iUnit, unsigned char *puchDataBuffer, int *piSize)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_ParameterStorage_ReadGlobalDataUnit(pchGdfsId, iUnit, puchDataBuffer, piSize);
+}
+
+LCDRIVER_API int __cdecl ParameterStorage_WriteGlobalDataUnit(LCDContext Context, const char *pchGdfsId, int iUnit, unsigned char *puchDataBuffer, int iSize)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_ParameterStorage_WriteGlobalDataUnit(pchGdfsId, iUnit, puchDataBuffer, iSize);
+}
+
+LCDRIVER_API int __cdecl ParameterStorage_ReadGlobalDataSet(LCDContext Context, const char *pchGdfsId, const char *pchPath, int iUseBulk)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_ParameterStorage_ReadGlobalDataSet(pchGdfsId, pchPath, iUseBulk);
+}
+
+LCDRIVER_API int __cdecl ParameterStorage_WriteGlobalDataSet(LCDContext Context, const char *pchGdfsId, const char *pchPath, int iUseBulk)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_ParameterStorage_WriteGlobalDataSet(pchGdfsId, pchPath, iUseBulk);
+}
+
+LCDRIVER_API int __cdecl ParameterStorage_EraseGlobalDataSet(LCDContext Context, const char *pchGdfsId)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_ParameterStorage_EraseGlobalDataSet(pchGdfsId);
+}
+
+LCDRIVER_API int __cdecl Security_SetDomain(LCDContext Context, int iDomain)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_Security_SetDomain(iDomain);
+}
+
+LCDRIVER_API int __cdecl Security_GetDomain(LCDContext Context, int *piWrittenDomain)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_Security_GetDomain(piWrittenDomain);
+}
+
+LCDRIVER_API int __cdecl Security_GetProperties(LCDContext Context, int iUnitId, int *piSize, unsigned char *puchDataBuffer)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_Security_GetProperties(iUnitId, piSize, puchDataBuffer);
+}
+
+LCDRIVER_API int __cdecl Security_SetProperties(LCDContext Context, int iUnitId, int iSize, unsigned char *puchDataBuffer)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_Security_SetProperties(iUnitId, iSize, puchDataBuffer);
+}
+
+LCDRIVER_API int __cdecl Security_BindProperties(LCDContext Context)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_Security_BindProperties();
+}
+
+LCDRIVER_API int __cdecl Security_StoreSecureObject(LCDContext Context, const char *pchSourcePath, int iDestination, int iUseBulk)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_OTP_StoreSecureObject(pchSourcePath, iDestination, iUseBulk);
+}
+
+LCDRIVER_API int __cdecl A2_System_Shutdown(LCDContext Context)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_A2_System_Shutdown();
+}
+
+LCDRIVER_API int __cdecl A2_System_LoaderVersion(LCDContext Context, char *pchLoaderVersion, int *piSize, int iTargetCPU)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_A2_System_LoaderVersion(pchLoaderVersion, piSize, iTargetCPU);
+}
+
+LCDRIVER_API int __cdecl A2_System_LoaderOnLoader(LCDContext Context, const char *pchPath, int iPLOffset, int iHLOffset, int iTargetCPU)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_A2_System_LoaderOnLoader(pchPath, iPLOffset, iHLOffset, iTargetCPU);
+}
+
+LCDRIVER_API int __cdecl A2_System_Reset(LCDContext Context, int iTimeout)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_A2_System_Reset(iTimeout);
+}
+
+LCDRIVER_API int __cdecl A2_Flash_ProgramFlash(LCDContext Context, const char *pchPath, int iUseSpeedFlash)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_A2_Flash_ProgramFlash(pchPath, iUseSpeedFlash);
+}
+
+LCDRIVER_API int __cdecl A2_Flash_EraseFlash(LCDContext Context)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_A2_Flash_EraseFlash();
+}
+
+LCDRIVER_API int __cdecl A2_Control_LoaderStarted(LCDContext Context)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Done_A2_Control_LoaderStarted();
+}
+
+LCDRIVER_API int __cdecl SetProtocolFamily(LCDContext Context, const char *pchFamily)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ TFamily newFamily;
+
+ if (0 == strcmp(pchFamily, "R15_FAMILY")) {
+ newFamily = R15_PROTOCOL_FAMILY;
+ } else if (0 == strcmp(pchFamily, "PROTROM_FAMILY")) {
+ newFamily = PROTROM_PROTOCOL_FAMILY;
+ } else if (0 == strcmp(pchFamily, "NOPROT")) {
+ newFamily = Z_PROTOCOL_FAMILY;
+ } else if (0 == strcmp(pchFamily, "A2_FAMILY")) {
+ newFamily = A2_PROTOCOL_FAMILY;
+ } else {
+ return INVALID_INPUT_PARAMETERS;
+ }
+
+ return Context->m_pObject->Do_SwitchProtocolFamily(newFamily);
+}
+
+LCDRIVER_API int __cdecl Z_SetInServiceMode(LCDContext Context, unsigned int *puiChipId)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_Z_SetInServiceMode(puiChipId);
+}
+
+LCDRIVER_API int __cdecl Z_SetBaudrate(LCDContext Context, int iBaudrate)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_Z_SetBaudrate(iBaudrate);
+}
+
+LCDRIVER_API int __cdecl Z_Exit_Z_Protocol(LCDContext Context)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_Z_Exit_Z_Protocol();
+}
+
+LCDRIVER_API int __cdecl PROTROM_DownloadLoader(LCDContext Context, const char *pchPath, int iPLOffset, int iHLOffset, int iContinueProtRom)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ return Context->m_pObject->Do_PROTROM_DownloadLoader(pchPath, iPLOffset, iHLOffset, iContinueProtRom);
+}
+
+LCDRIVER_API int __cdecl PROTROM_ReadSecurityData(LCDContext Context, unsigned char uiSecDataId, unsigned char *puchDataBuffer, int *piDataLength)
+{
+ VERIFY_CONTEXT_STARTED(Context);
+
+ if (NULL == puchDataBuffer || 0 == piDataLength) {
+ return INVALID_INPUT_PARAMETERS;
+ }
+
+ return Context->m_pObject->Do_PROTROM_ReadSecurityData(uiSecDataId, puchDataBuffer, piDataLength);
+}
diff --git a/source/LCDriver.h b/source/LCDriver.h
new file mode 100644
index 0000000..dd746b7
--- /dev/null
+++ b/source/LCDriver.h
@@ -0,0 +1,824 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _LCDRIVER_H_
+#define _LCDRIVER_H_
+
+#if defined(_WIN32)
+#ifdef LCDRIVER_EXPORTS
+#define LCDRIVER_API __declspec(dllexport)
+#else
+#define LCDRIVER_API __declspec(dllimport)
+#endif
+
+typedef unsigned __int64 uint64;
+typedef unsigned long uint32;
+#elif defined(__linux__)
+#ifdef LCDRIVER_EXPORTS
+#define LCDRIVER_API __attribute__((visibility("default")))
+#else
+#define LCDRIVER_API
+#endif
+
+typedef unsigned long long uint64;
+typedef unsigned int uint32;
+
+#define __cdecl
+#else
+#error "Unknown platform"
+#endif
+
+typedef struct CLCDriverInterface *LCDContext;
+
+/// <summary>
+/// Command information.
+/// </summary>
+/// <param name="iGroup">Command group number.</param>
+/// <param name="iCommand">Command number.</param>
+/// <param name="iPermitted">Permition level.</param>
+typedef struct {
+ int iGroup;
+ int iCommand;
+ int iPermitted;
+} TSupportedCmd;
+
+/// <summary>
+/// Description of ME device.
+/// </summary>
+/// <param name="pchPath">Absolute device path pointing at the described device.</param>
+/// <param name="iPathSize">Size of pchPath.</param>
+/// <param name="pchType">Type of device.</param>
+/// <param name="iTypeSize">Size of pchType.</param>
+/// <param name="uiBlockSize">Size of the smallest addressable unit in the device [Byte].</param>
+/// <param name="uiStart">Offset [Byte] of the start of the device relative its parent's
+/// offset 0 with granularity of its parent's block size.</param>
+/// <param name="uiLength">Length of the device [Byte].</param>
+typedef struct {
+ const char *pchPath;
+ int iPathSize;
+ const char *pchType;
+ int iTypeSize;
+ uint64 uiBlockSize;
+ uint64 uiStart;
+ uint64 uiLength;
+} TDevices;
+
+/// <summary>
+/// Description of filesystem file or directory in ME.
+/// </summary>
+/// <param name="pchName">Name of file or directory.</param>
+/// <param name="iNameSize">Size of pchName.</param>
+/// <param name="uiSize">Size of file or directory.</param>
+/// <param name="iMode">Indicator of file or directory.</param>
+/// <param name="iTime">Time of last modification.</param>
+typedef struct {
+ const char *pchName;
+ int iNameSize;
+ uint64 uiSize;
+ int iMode;
+ int iTime;
+} TEntries;
+
+/// <summary>
+/// 12 SIM lock/unlock keys.
+/// </summary>
+/// <param name="pchNLCKLock">NLCKLock key.</param>
+/// <param name="pchNSLCKLock">NSLCKLock key.</param>
+/// <param name="pchSPLCKLock">SPLCKLock key.</param>
+/// <param name="pchCLCKLock">CLCKLock key.</param>
+/// <param name="pchPCKLock">PCKLock key.</param>
+/// <param name="pchESLCKLock">ESLCKLock key.</param>
+/// <param name="pchNLCKUnLock">NLCKUnLock key.</param>
+/// <param name="pchNSLCKUnLock">NSLCKUnLock key.</param>
+/// <param name="pchSPLCKUnLock">SPLCKUnLock key.</param>
+/// <param name="pchCLCKUnLock">CLCKUnLock key.</param>
+/// <param name="pchPCKUnLock">PCKUnLock key.</param>
+/// <param name="pchESLCKUnLock">ESLCKUnLock key.</param>
+typedef struct {
+ char *pchNLCKLock;
+ char *pchNSLCKLock;
+ char *pchSPLCKLock;
+ char *pchCLCKLock;
+ char *pchPCKLock;
+ char *pchESLCKLock;
+
+ char *pchNLCKUnLock;
+ char *pchNSLCKUnLock;
+ char *pchSPLCKUnLock;
+ char *pchCLCKUnLock;
+ char *pchPCKUnLock;
+ char *pchESLCKUnLock;
+} TSIMLockKeys;
+
+/// <summary>
+/// LCDriver time out.
+/// </summary>
+/// <param name="uiSTO">Startup TimeOut.</param>
+/// <param name="uiRTO">Response TimeOut.</param>
+typedef struct {
+ uint32 uiSTO;
+ uint32 uiRTO;
+} TLCDriverTimeouts;
+
+/// <summary>
+/// R15 protocol time out.
+/// </summary>
+/// <param name="TCACK">Time for command packet acknowledge.</param>
+/// <param name="TBCR">Time for bulk command packet to be recieved.</param>
+/// <param name="TBES">Time for bulk session end. NOTE: Starting from version R1J this timeout is not
+///used in LCM but it stays in LCDriver interface to avoid interface changes.</param>
+/// <param name="TBDR">Time for bulk data packet to be received.</param>
+typedef struct {
+ uint32 TCACK;
+ uint32 TBCR;
+ uint32 TBES;
+ uint32 TBDR;
+} TR15Timeouts;
+
+/// <summary>
+/// Protocol family.
+/// </summary>
+typedef enum {
+ /// <summary>R15 protocol family.</summary>
+ R15_PROTOCOL_FAMILY = 0,
+ /// <summary>A2 protocol family.</summary>
+ A2_PROTOCOL_FAMILY = 1,
+ /// <summary>PROTROM protocol family.</summary>
+ PROTROM_PROTOCOL_FAMILY = 3,
+ /// <summary>Z protocol family.</summary>
+ Z_PROTOCOL_FAMILY = 4
+} TFamily;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif // __cplusplus
+ /// <summary>
+ /// Initializes new instance of the LCD context.
+ ///
+ /// Deprecated.
+ /// Instead of this function please use: SetLCMLibPath, CreateContext, SwitchProtocolFamily, ConfigureCommunicationDevice,
+ /// SetMessageCallback, SetProgressCallback and StartContext. These new functions give separation between creation,
+ /// configuration and startup of the context.
+ /// </summary>
+ /// <param name="pContext">A pointer to a LCDContext where to store the newly created context or to put
+ /// the previously created context if the context with the specified interface id already exists.</param>
+ /// <param name="InterfaceId">A zero terminated string conaining the interface unique ID.</param>
+ /// <param name="Read_fn">A pointer to a communication device read function.</param>
+ /// <param name="Write_fn">A pointer to a communication device write function.</param>
+ /// <param name="Cancel_fn">A pointer to a communication device cancel function.</param>
+ /// <param name="Instance">A pointer to a pointer where to store the adress of the loader communication module instance.</param>
+ /// <param name="Message_fn">A pointer to a message loging function.</param>
+ /// <param name="LCMLibPath">A zero terminated string containing the path to the LCM library.</param>
+ /// <param name="ProgressBar_fn">A pointer to function which receives the progress updates.</param>
+ /// <returns>0 if OK, otherwise non-zero.</returns>
+ LCDRIVER_API int __cdecl Initialize(LCDContext *pContext, const char *InterfaceId, void *Read_fn, void *Write_fn, void *Cancel_fn, void **Instance, void *Message_fn, const char *LCMLibPath, void *ProgressBar_fn);
+
+ /// <summary>
+ /// Closes the LCD context.
+ ///
+ /// Deprecated.
+ /// Instead of this function please use DestroyContext which properly sets the LCD context to NULL to avoid further usage
+ /// of the destroyed context.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <returns>0 if OK, otherwise non-zero.</returns>
+ LCDRIVER_API int __cdecl Close(LCDContext Context);
+
+ /// <summary>
+ /// Sets the global LCM library path.
+ /// </summary>
+ /// <param name="LCMLibPath">A zero terminated string containing the path to the LCM library.</param>
+ LCDRIVER_API void __cdecl SetLCMLibPath(const char *LCMLibPath);
+
+ /// <summary>
+ /// Creates new LCD context with the specified interface ID.
+ /// </summary>
+ /// <param name="pContext">A pointer to a LCDContext where to store the newly created context or to put
+ /// the previously created context if the context with the specified interface id already exists.</param>
+ /// <param name="InterfaceId">A zero terminated string containing the interface unique ID.</param>
+ /// <returns>0 if OK, otherwise non-zero.</returns>
+ LCDRIVER_API int __cdecl CreateContext(LCDContext *pContext, const char *InterfaceId);
+
+ /// <summary>
+ /// Sets the initial family of not started context, or switches the protocol family of started context.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="Family">New family to be set.</param>
+ /// <returns>0 if OK, otherwise non-zero.</returns>
+ LCDRIVER_API int __cdecl SwitchProtocolFamily(LCDContext Context, TFamily Family);
+
+ /// <summary>
+ /// Configures the communication device to be used for the context.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="Read_fn">A pointer to a communication device read function.</param>
+ /// <param name="Write_fn">A pointer to a communication device write function.</param>
+ /// <param name="Cancel_fn">A pointer to a communication device cancel function.</param>
+ /// <returns>0 if OK, otherwise non-zero.</returns>
+ LCDRIVER_API int __cdecl ConfigureCommunicationDevice(LCDContext Context, void *Read_fn, void *Write_fn, void *Cancel_fn);
+
+ /// <summary>
+ /// Sets the callback for message loging.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="Callback_fn">A pointer to a message loging function.</param>
+ /// <returns>0 if OK, otherwise non-zero.</returns>
+ LCDRIVER_API int __cdecl SetMessageCallback(LCDContext Context, void *Callback_fn);
+
+ /// <summary>
+ /// Sets the callback for progress updates.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="Callback_fn">A pointer to function which receives the progress updates.</param>
+ /// <returns>0 if OK, otherwise non-zero.</returns>
+ LCDRIVER_API int __cdecl SetProgressCallback(LCDContext Context, void *Callback_fn);
+
+ /// <summary>
+ /// Starts the context. Should be called after the required parameters are previously configured.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="Instance">A pointer to a pointer where to store the adress of the started communication instance.</param>
+ /// <returns>0 if OK, otherwise non-zero.</returns>
+ LCDRIVER_API int __cdecl StartContext(LCDContext Context, void **Instance);
+
+ /// <summary>
+ /// Destroys the context. Should be called last after we are finished with the context.
+ /// </summary>
+ /// <param name="pContext">Pointer to LCDContext on which to execute the operation.
+ /// LCDContext is set to NULL after this function is called.</param>
+ /// <returns>0 if OK, otherwise non-zero.</returns>
+ LCDRIVER_API int __cdecl DestroyContext(LCDContext *pContext);
+
+ /// <summary>
+ /// Sets the LCD and R15 protocol timeouts.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="R15_TOs">Pointer to TR15Timeouts structure.</param>
+ /// <param name="LCD_TOs">Pointer to TLCDriverTimeouts structure.</param>
+ /// <returns>0 if OK, otherwise non-zero.</returns>
+ LCDRIVER_API int __cdecl SetTimeouts(LCDContext Context, TR15Timeouts *R15_TOs, TLCDriverTimeouts *LCD_TOs);
+
+ /// <summary>
+ /// Gets the LCD and R15 protocol timeouts.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="R15_TOs">Pointer to TR15Timeouts structure.</param>
+ /// <param name="LCD_TOs">Pointer to TLCDriverTimeouts structure.</param>
+ /// <returns>0 if OK, otherwise non-zero.</returns>
+ LCDRIVER_API int __cdecl GetTimeouts(LCDContext Context, TR15Timeouts *R15_TOs, TLCDriverTimeouts *LCD_TOs);
+
+ /// <summary>
+ /// Cancels the currently executing command.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <returns>0 if OK, otherwise non-zero.</returns>
+ LCDRIVER_API int __cdecl CancelCurrentLoaderCommand(LCDContext Context);
+
+ /// <summary>
+ /// 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.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchVersion">Loader version identifier.</param>
+ /// <param name="piVersionSize">Number of allocated bytes for version string.</param>
+ /// <param name="pchProtocol">Protocol version identifier.</param>
+ /// <param name="piProtocolSize">Number of allocated bytes for protocol string.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl System_LoaderStartupStatus(LCDContext Context, char *pchVersion, int *piVersionSize, char *pchProtocol, int *piProtocolSize);
+
+ /// <summary>
+ /// 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. The ME does not accept any further communication after a successful
+ /// response from this command has been returned.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="iMode">Indicates the mode of reset:
+ /// 0: indicates normal restart.
+ /// 1: indicates restart in service mode.
+ /// 2: indicates restart with JTAG debugging enabled.
+ /// 3: indicates restart in service mode and with JTAG debugging enabled.
+ /// </param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl System_Reboot(LCDContext Context, int iMode);
+
+ /// <summary>
+ /// The loader shuts down in a controlled fashion and proceeds to shut down the ME itself.
+ /// The ME does not accept any further communication after a successful response from this
+ /// command has been returned.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl System_Shutdown(LCDContext Context);
+
+ /// <summary>
+ /// The loader returns a list of implemented commands and whether they are permitted to
+ /// execute in the current loader state.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pCmdList">A list with supported commands.</param>
+ /// <param name="piCmdListSize">Number of commands in CmdList.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl System_SupportedCommands(LCDContext Context, TSupportedCmd *pCmdList, int *piCmdListSize);
+
+ /// <summary>
+ /// This command is used by the loader to extract debug, measurement or flashing status data.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="iType">Type of data to be extracted.</param>
+ /// <param name="piSize">Size of the collected data buffer.</param>
+ /// <param name="pData">Buffer to hold the collected data.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl System_CollectData(LCDContext Context, int iType, int *piSize, char *pData);
+
+ /// <summary>
+ /// Receive, verify and execute software, which can be a signed loader.
+ /// After having sent this command, the ME attempts to read the software
+ /// payload data from the host using the Bulk protocol or from the flash
+ /// file system depending on the selected path. The current loader does not
+ /// respond to communication after this command has been successfully executed.
+ /// If the executed software is another loader, communication can be resumed once the
+ /// Loader Started command has been received. A response of E_OPERATION_CANCELLED
+ /// indicates the operation was canceled.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="ExecuteMode">Execute mode: 1 = execution from specified address, 2 = first load the software then execute. </param>
+ /// <param name="pchDevicePath">Target path. If use bulk the path is on PC, else on ME.</param>
+ /// <param name="iUseBulk">If value = 1 -> source on PC, else source on ME.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl System_ExecuteSoftware(LCDContext Context, const uint32 ExecuteMode, const char *pchDevicePath, int iUseBulk);
+
+ /// <summary>
+ /// This command is used to escalate the privileges of the operator. Two ways 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 sends the appropriate request for information to the PC.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="iType">Authentication type:0 = control key authentication,1 = certificate authentication.</param>
+ /// <param name="piSize">Size of puchData.</param>
+ /// <param name="puchdata">Data challange. </param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl System_Authenticate(LCDContext Context, int iType, int *piSize, unsigned char *puchdata);
+
+ /// <summary>
+ /// This command is used by the loader to retrieve the SimLock control keys from the host to authenticate a user.
+ /// The command is used in the authentication context.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pSIMLockKeys">A struct with all lock/unlock keys.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl System_GetControlKeys(LCDContext Context, TSIMLockKeys *pSIMLockKeys);
+
+ /// <summary>
+ /// This command is used by the loader to retrieve the SimLock control keys data from the host to authenticate a user.
+ /// The command is used in the authentication context.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="SIMLockKeysData">SIMLockKeyData buffer that contain all SIMLock keys.</param>
+ /// <param name="iDataSize">SIMLockKeyData buffer size.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl System_GetControlKeysData(LCDContext Context, int iDataSize, unsigned char *pSIMLockKeysData);
+
+ /// <summary>
+ /// This command is used by the loader to perform a certificate authentication.
+ /// The command is only used in the authentication context.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="puchChallengeData">Authentication challenge. This challenge must be signed
+ /// using the correct certificate and returned to the loader.</param>
+ /// <param name="iDataSize">Authentication challenge buffer length.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl System_AuthenticationChallenge(LCDContext Context, unsigned char *puchChallengeData, int iDataSize);
+
+ /// <summary>
+ /// The Set System Time command is used to set the current epoch time for loader
+ /// to configure the real time clock and use it for file system operations.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="uiEpochTime">Number of seconds that have elapsed since January 1, 1970</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl System_SetSystemTime(LCDContext Context, uint32 uiEpochTime);
+
+ /// <summary>
+ /// This command is used to instruct the Loader to switch to a new communication device.
+ /// </summary>
+ /// <param name="uiDevice">Device ID of the communication device to switch to.</param>
+ /// <param name="uiDeviceParam">Communication device parameters.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl System_SwitchCommunicationDevice(LCDContext Context, uint32 uiDevice, uint32 uiDeviceParam);
+
+ /// <summary>
+ /// 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.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchPath">Target path. If iUseBulk = 1, path is on PC.</param>
+ /// <param name="pchType">Type of the opened file.</param>
+ /// <param name="iUseBulk">If to use bulk protocol. If target is on PC iUseBulk shall be 1.</param>
+ /// <param name="iDeleteBuffers">Specify if to delete bulk buffers after finish. 1 -> delete buffers. 0 -> don't delete buffers.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Flash_ProcessFile(LCDContext Context, const char *pchPath, const char *pchType, int iUseBulk, int iDeleteBuffers);
+
+ /// <summary>
+ /// This command is used by the client application program to obtain the device tree.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pDevices">A struct with information about one flash device.</param>
+ /// <param name="piDeviceSize">Number of flash devices, size of pDevices array.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Flash_ListDevices(LCDContext Context, TDevices *pDevices, int *piDeviceSize);
+
+ /// <summary>
+ /// This command is used to initiate a dump session.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchPathToDump">Path to the device to dump.</param>
+ /// <param name="uiStart">Start of the dump relative to the start of the device indicated by Path [Byte].</param>
+ /// <param name="uiLength">Length of the dump [Byte]. Actual length is determined by the device block size.</param>
+ /// <param name="pchFilePath">File path on PC to store dump data to.</param>
+ /// <param name="uiRedundantArea">0-> dump with redundant data, 1-> dump without redundant data.</param>
+ /// <param name="iUseBulk">1-> save dump data on PC, 0-> save dump data on ME.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Flash_DumpArea(LCDContext Context, const char *pchPathToDump, uint64 uiStart, uint64 uiLength, const char *pchFilePath, uint32 uiRedundantArea, int iUseBulk);
+
+ /// <summary>
+ /// This command is used to erase a flash device or part of a flash device.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchPath">Path to the device to erase.</param>
+ /// <param name="uiStart">Start of the erase relative to the start of the device
+ /// indicated by path [Byte]. This must be a multiple of the block size of the device.</param>
+ /// <param name="uiLength">Length of the dump [Byte]. This must be a multiple of the block size of the device.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Flash_EraseArea(LCDContext Context, const char *pchPath, uint64 uiStart, uint64 uiLength);
+
+ /// <summary>
+ /// This command is used to initiate a flashing of raw data.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchPath">Target path. If iUseBulk = 1, path is on PC.</param>
+ /// <param name="uiStart">Address where flashing should start.</param>
+ /// <param name="uiLength">Length of data to be flashed.</param>
+ /// <param name="uiDevice">Device ID number.</param>
+ /// <param name="iUseBulk">If to use bulk protocol. If target is on PC iUseBulk shall be 1.</param>
+ /// <param name="iDeleteBuffers">Specify if to delete bulk buffers after finish. 1 -> delete buffers. 0 -> don't delete buffers.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Flash_FlashRaw(LCDContext Context, const char *pchPath, uint64 uiStart, uint64 uiLength, uint32 uiDevice, int iUseBulk, int iDeleteBuffers);
+
+ /// <summary>
+ /// This command retrieves the properties of the specified file system volume. It is issued by the PC application.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchDevicePath">Path of file system volume.</param>
+ /// <param name="pchFSType">File system type.</param>
+ /// <param name="piFSTypeSize">Size of pchFSType array.</param>
+ /// <param name="puiSize">Total size of the file system [Byte].</param>
+ /// <param name="puiFree">Available space [Byte].</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl FileSystem_VolumeProperties(LCDContext Context, const char *pchDevicePath, char *pchFSType, int *piFSTypeSize, uint64 *puiSize, uint64 *puiFree);
+
+ /// <summary>
+ /// Formats unused file system volume specified in device path. This operation fails if the volume is currently in use.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchDevicePath">Device path of the file system volume.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl FileSystem_FormatVolume(LCDContext Context, const char *pchDevicePath);
+
+ /// <summary>
+ /// List files and directories residing in specified path.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchPath">File system path.</param>
+ /// <param name="pEntries">Struct with file and directory information.</param>
+ /// <param name="piDeviceSize">Number of files or directories, number of element in pEntries array.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl FileSystem_ListDirectory(LCDContext Context, const char *pchPath, TEntries *pEntries, int *piDeviceSize);
+
+ /// <summary>
+ /// This command moves a file from the source path to the destination path if the source and destination differ.
+ /// It also renames a file if the source path and the destination path are the same.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchSourcePath">File system path in ME to source.</param>
+ /// <param name="pchDestinationPath">File system path in ME to destination.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl FileSystem_MoveFile(LCDContext Context, const char *pchSourcePath, const char *pchDestinationPath);
+
+ /// <summary>
+ /// Delete the specified file or directory. The loader only deletes empty directories.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchTargetPath">File system path in ME.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl FileSystem_DeleteFile(LCDContext Context, const char *pchTargetPath);
+
+ /// <summary>
+ /// This command is used to do the following: Copy a file from the PC to the ME. Copy a file between two directories or file systems on the ME.
+ /// Copy a file from the ME to the PC.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchSourcePath">If iSourceUseBulk = 1 -> path on PC, else path on ME.</param>
+ /// <param name="iSourceUseBulk">If = 1 -> source on PC, else source on ME.</param>
+ /// <param name="pchDestinationPath">If iDestinationUseBulk = 1 -> path on PC, else path on ME.</param>
+ /// <param name="iDestinationUseBulk">If = 1 -> destination on PC, else destination on ME.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl FileSystem_CopyFile(LCDContext Context, const char *pchSourcePath, int iSourceUseBulk, const char *pchDestinationPath, int iDestinationUseBulk);
+
+ /// <summary>
+ /// This command is used to create a directory. It is issued by the PC application.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchTargetPath">File system path to target.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl FileSystem_CreateDirectory(LCDContext Context, const char *pchTargetPath);
+
+ /// <summary>
+ /// This command is used to retrieve the properties of a file or directory.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchTargetPath">File system path to target.</param>
+ /// <param name="puiMode">File type and access restrictions descriptor.</param>
+ /// <param name="puiSize">File size [Byte].</param>
+ /// <param name="piMTime">Last modification timestamp.</param>
+ /// <param name="piATime">Last access timestamp.</param>
+ /// <param name="piCTime">Creation timestamp.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl FileSystem_Properties(LCDContext Context, const char *pchTargetPath, uint32 *puiMode, uint64 *puiSize, int *piMTime, int *piATime, int *piCTime);
+
+ /// <summary>
+ /// This command is used to change the access permissions of a specified path.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchTargetPath">File system path to target.</param>
+ /// <param name="iAccess">New access permissions.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl FileSystem_ChangeAccess(LCDContext Context, const char *pchTargetPath, int iAccess);
+
+ /// <summary>
+ /// This command is used to read manifests contained in load modules at the specified path and send the data back over bulk protocol.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchTargetPath">Path on PC to save manifest.</param>
+ /// <param name="pchSourcePath">Load module(s) file system path.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl FileSystem_ReadLoadModuleManifests(LCDContext Context, const char *pchTargetPath, const char *pchSourcePath);
+
+
+ /// <summary>
+ /// This command is used to read the specified bits from the OTP.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="iOtpId">OTP area ID.</param>
+ /// <param name="iBitStart">Starting offset [bit].</param>
+ /// <param name="iBitLength">Length of read [bit].</param>
+ /// <param name="puchDataBuffer">Received OTP data.</param>
+ /// <param name="piDataBufferSize">Size of puchDataBuffer.</param>
+ /// <param name="puchStatusBuffer">Lock status for each read bit.</param>
+ /// <param name="piStatusBufferSize">Size of puchStatusBuffer.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl OTP_ReadBits(LCDContext Context, int iOtpId, int iBitStart, int iBitLength, unsigned char *puchDataBuffer, int *piDataBufferSize, unsigned char *puchStatusBuffer, int *piStatusBufferSize);
+
+ /// <summary>
+ /// This command stores the specified bits in the loader internal OTP structures in RAM, it does not write to OTP.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="iOtpId">OTP area ID.</param>
+ /// <param name="iBitStart">Starting offset [bit].</param>
+ /// <param name="iBitLength">Length of write [bit].</param>
+ /// <param name="puchDataBuffer">OTP data to write.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl OTP_SetBits(LCDContext Context, int iOtpId, int iBitStart, int iBitLength, unsigned char *puchDataBuffer);
+
+ /// <summary>
+ /// This command writes (burns) all data from loader internal OTP structures in RAM into the OTP fuse box.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="iOtpId">OTP area ID.</param>
+ /// <param name="iForceWrite">If true: write and lock all lockable areas even if not all bits are received in cache.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl OTP_WriteAndLock(LCDContext Context, int iOtpId, int iForceWrite);
+
+ /// <summary>
+ /// Reads a specified unit from the global data storage area/partition specified by the DevicePath parameter.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchGdfsId">GDFS ID.</param>
+ /// <param name="iUnit">Unit ID to read.</param>
+ /// <param name="puchDataBuffer">Received global data.</param>
+ /// <param name="piSize">Size of puchDataBuffer.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl ParameterStorage_ReadGlobalDataUnit(LCDContext Context, const char *pchGdfsId, int iUnit, unsigned char *puchDataBuffer, int *piSize);
+
+ /// <summary>
+ /// Writes a specified unit to the global data storage area/partition specified by the pchGdfsId parameter.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchGdfsId">GDFS ID.</param>
+ /// <param name="iUnit">Unit ID to write.</param>
+ /// <param name="puchDataBuffer">Global data to write.</param>
+ /// <param name="iSize">Size of puchDataBuffer.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl ParameterStorage_WriteGlobalDataUnit(LCDContext Context, const char *pchGdfsId, int iUnit, unsigned char *puchDataBuffer, int iSize);
+
+ /// <summary>
+ /// Reads the complete global data storage area/partition specified by the pchGdfsId parameter (reads all units at once).
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchGdfsId">GDFS ID.</param>
+ /// <param name="pchPath">If iUseBulk=1 -> path on PC to save data set to. Else path on ME.</param>
+ /// <param name="iUseBulk">1-> save global data on PC, 0-> save global data on ME.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl ParameterStorage_ReadGlobalDataSet(LCDContext Context, const char *pchGdfsId, const char *pchPath, int iUseBulk);
+
+ /// <summary>
+ /// Writes the complete global data storage area/partition specified by the pchGdfsId parameter (writes all units at once).
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchGdfsId">GDFS ID.</param>
+ /// <param name="pchPath">If iUseBulk=1 -> path on PC. Else path on ME</param>
+ /// <param name="iUseBulk">1-> global data source on PC, 0-> global data source on ME.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl ParameterStorage_WriteGlobalDataSet(LCDContext Context, const char *pchGdfsId, const char *pchPath, int iUseBulk);
+
+ /// <summary>
+ /// Erases the complete global data storage area/partition specified by the DevicePath parameter.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchGdfsId">GDFS ID.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl ParameterStorage_EraseGlobalDataSet(LCDContext Context, const char *pchGdfsId);
+
+
+ /// <summary>
+ /// This command is used to set the ME domain.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="iDomain">Target domain.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Security_SetDomain(LCDContext Context, int iDomain);
+
+ /// <summary>
+ /// This command is used to get the ME domain.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="piWrittenDomain">The ME current domain.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Security_GetDomain(LCDContext Context, int *piWrittenDomain);
+
+ /// <summary>
+ /// This command is used to read a security data unit (such as a secure static or dynamic data unit).
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="iUnitId">Unit ID to read.</param>
+ /// <param name="piSize">Size of puchDataBuffer.</param>
+ /// <param name="puchDataBuffer">The unit data.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Security_GetProperties(LCDContext Context, int iUnitId, int *piSize, unsigned char *puchDataBuffer);
+
+ /// <summary>
+ /// This command is used to write a security data unit (such as a secure static or dynamic data unit).
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="iUnitId">Unit ID to write.</param>
+ /// <param name="iSize">Size of puchDataBuffer.</param>
+ /// <param name="puchDataBuffer">The data to write.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Security_SetProperties(LCDContext Context, int iUnitId, int iSize, unsigned char *puchDataBuffer);
+
+ /// <summary>
+ /// This command associates all security data units with the current ME.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Security_BindProperties(LCDContext Context);
+
+ /// <summary>
+ /// This command installs a secure object to the Boot record or OTP area.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchSourcePath">If iUseBulk = 1 -> path on PC, else path on ME.</param>
+ /// <param name="iDestination">Secure object destination address on ME.</param>
+ /// <param name="iUseBulk">Source on PC -> iUseBulk= 1. Source on ME -> iUseBulk= 0.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Security_StoreSecureObject(LCDContext Context, const char *pchSourcePath, int iDestination, int iUseBulk);
+
+ /// <summary>
+ /// The A2 loader shuts down in a controlled fashion and proceeds to shut down the ME itself.
+ /// The ME does not accept any further communication after a successful response from this
+ /// command has been returned.
+ /// </summary>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl A2_System_Shutdown(LCDContext Context);
+
+ /// <summary>
+ /// The PC uses the Loader version command to request version information from the loader
+ /// The response holds the loader version information coded as ASCII characters in the data field
+ /// </summary>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl A2_System_LoaderVersion(LCDContext Context, char *pchLoaderVersion, int *piSize, int iTargetCPU);
+
+ /// <summary>
+ /// The Loader on loader command is used to transfer a new loader to the ME
+ /// When the header or payload has been sent, the loader responds with a GR using status codes.
+ /// </summary>
+ /// <returns> Status of the command.</returns>
+ LCDRIVER_API int __cdecl A2_System_LoaderOnLoader(LCDContext Context, const char *pchPath, int iPLOfset, int iHLOffset, int iTargetCPU);
+
+ /// <summary>
+ /// The Reset command will reset the phone using the watchdog reset functionality of the ARM processor.
+ /// </summary>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl A2_System_Reset(LCDContext Context, int iTimeout);
+
+ /// <summary>
+ /// The Program flash command is sent by the PC to write a block of data into the flash memory.
+ /// The block data is sent in the data field.
+ /// When a complete block has been transmitted the loader verifies the data and responds with a GR using status codes
+ /// </summary>
+ /// <returns> Status of the command.</returns>
+ LCDRIVER_API int __cdecl A2_Flash_ProgramFlash(LCDContext Context, const char *pchPath, int iUseSpeedFlash);
+
+ /// <summary>
+ /// The Erase flash command is used to erase the complete flash memory.
+ /// It checks what type of memory is used in the ME and erases the complete memory including the first memory block.
+ /// If more than one flash is attached, all of them will be erased
+ /// The loader responds with a GR using status codes
+ /// </summary>
+ /// <returns> Status of the command.</returns>
+ LCDRIVER_API int __cdecl A2_Flash_EraseFlash(LCDContext Context);
+
+ /// <summary>
+ /// The loader started message is sent from the ME to the PC as soon as the loader has started executing
+ /// and is ready to receive commands.
+ /// </summary>
+ /// <returns> Status of the command.</returns>
+ LCDRIVER_API int __cdecl A2_Control_LoaderStarted(LCDContext Context);
+
+ /// <summary>
+ /// Set protocol to use.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchFamily">Protocol to use. Valid values: R15_FAMILY, PROTROM_FAMILY, NOPROT</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl SetProtocolFamily(LCDContext Context, const char *pchFamily);
+
+ /// <summary>
+ /// Set ME in service mode and receive chip id.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="puiChipId">Received chip id.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Z_SetInServiceMode(LCDContext Context, unsigned int *puiChipId);
+
+ /// <summary>
+ /// Set communication baudrate when communicating via UART.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="iBaudrate">Baudrate to use. Valid values: 9600, 19200, 38400, 57600, 115200,
+ /// 230400, 460800, 921600, 1625000.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Z_SetBaudrate(LCDContext Context, int iBaudrate);
+
+ /// <summary>
+ /// Exit Z-protocol and start using PROTROM-protocol.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl Z_Exit_Z_Protocol(LCDContext Context);
+
+ /// <summary>
+ /// Download loader using PROTROM-protocol.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="pchPath">Path to loader on PC.</param>
+ /// <param name="iPLOffset">Offset in header to payload length.</param>
+ /// <param name="iHLOffset">Offset in header to header length.</param>
+ /// <param name="iContinueProtRom">1 -> continue use PROTROM-protocol after download the loader. O -> not use PROTROM-protocol after download the loader.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl PROTROM_DownloadLoader(LCDContext Context, const char *pchPath, int iPLOffset, int iHLOffset, int iContinueProtRom);
+
+ /// <summary>
+ /// Send intrinsic request to read security data using PROTROM-protocol.
+ /// </summary>
+ /// <param name="Context">LCD context on which to execute the operation.</param>
+ /// <param name="uiSecDataId">ID of the security data to be read with the intrinsic request.</param>
+ /// <param name="puchDataBuffer">Buffer where the read data will be stored.</param>
+ /// <param name="piDataLength">IN: Length of DataBuffer; OUT: Read data length.</param>
+ /// <returns>Status of the command.</returns>
+ LCDRIVER_API int __cdecl PROTROM_ReadSecurityData(LCDContext Context, unsigned char uiSecDataId, unsigned char *puchDataBuffer, int *piDataLength);
+
+ // Random SIMLock keys generation functions not related to communication
+ LCDRIVER_API int __cdecl Algorithms_SimGeneratorInit(void *Object, int SecurityLevel);
+ LCDRIVER_API int __cdecl Algorithms_SimGeneratorExit(void *Object);
+ LCDRIVER_API int __cdecl Algorithms_SimGeneratorCalculate(void *Object, unsigned char *ByteArray, uint32 ArraySize);
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif // _LCDRIVER_H_
diff --git a/source/LCDriver.rc b/source/LCDriver.rc
new file mode 100644
index 0000000..ec7b73a
--- /dev/null
+++ b/source/LCDriver.rc
@@ -0,0 +1,116 @@
+// 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
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.K.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 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 "000904b0"
+ BEGIN
+ VALUE "Comments", "Build date: 2011-05-18"
+ VALUE "CompanyName", "STEricsson AB"
+ VALUE "FileDescription", "LCDriver Dynamic Link Library"
+ VALUE "FileVersion", "1, 0, 0, 1"
+ VALUE "InternalName", "Loader Communication Driver"
+ VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2011"
+ VALUE "OriginalFilename", "LCDriver_CNH1606432.dll"
+ VALUE "PrivateBuild", "http://gerrit.lud.stericsson.com/gerrit/21155"
+ VALUE "ProductName", "CXC 173 0865, LCDriver DLL"
+ VALUE "ProductVersion", "Test Version"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x9, 1200
+ END
+END
+
+#endif // English (U.K.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/source/LCDriver.vcproj b/source/LCDriver.vcproj
new file mode 100644
index 0000000..d3906db
--- /dev/null
+++ b/source/LCDriver.vcproj
@@ -0,0 +1,966 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="LCDriver"
+ ProjectGUID="{E195BE97-0727-419C-931E-08C8B99AB884}"
+ RootNamespace="LCDriver"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="..\target"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="0"
+ WholeProgramOptimization="0"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D LITTLE_ENDIAN=1234 /D BIG_ENDIAN=4321 /D BYTE_ORDER=LITTLE_ENDIAN"
+ Optimization="0"
+ AdditionalIncludeDirectories="security_algorithms\sha;.;LCM;LCM\include;autogen;CEH;utilities;security_algorithms;api_wrappers\windows"
+ PreprocessorDefinitions="WIN32;WIN32_LEAN_AND_MEAN;_DEBUG;_WINDOWS;_USRDLL;LCDRIVER_EXPORTS;_MESSAGES;_BULKDEBUG;_TIMERDEBUG;_BUFFERDEBUG;_THREADDEBUG"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ CallingConvention="0"
+ CompileAs="2"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)\$(ProjectName)_CNH1606432.dll"
+ AdditionalLibraryDirectories=""
+ GenerateManifest="true"
+ ModuleDefinitionFile=""
+ GenerateDebugInformation="true"
+ SubSystem="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="..\target"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="0"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D LITTLE_ENDIAN=1234 /D BIG_ENDIAN=4321 /D BYTE_ORDER=LITTLE_ENDIAN"
+ AdditionalIncludeDirectories=".;LCM;LCM\include;autogen;CEH;utilities;security_algorithms;api_wrappers\windows;security_algorithms\sha"
+ PreprocessorDefinitions="WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_USRDLL;LCDRIVER_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)\$(ProjectName)_CNH1606432.dll"
+ Version=""
+ AdditionalLibraryDirectories="security_algorithms"
+ ModuleDefinitionFile=""
+ AddModuleNamesToAssembly=""
+ AssemblyLinkResource=""
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ ValidateIntelliSense="false"
+ OutputDocumentFile="..\target\$(TargetName).xml"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="ReleaseWithDebugMessages|Win32"
+ OutputDirectory="..\target"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="0"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=".;LCM;LCM\include;autogen;CEH;utilities;security_algorithms;api_wrappers\windows"
+ PreprocessorDefinitions="WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_USRDLL;LCDRIVER_EXPORTS;_MESSAGES;_BULKDEBUG;_TIMERDEBUG;_BUFFERDEBUG"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="SecurityAlgorithms.lib"
+ OutputFile="$(OutDir)\$(ProjectName)_CNH1606432.dll"
+ Version=""
+ AdditionalLibraryDirectories="security_algorithms"
+ ModuleDefinitionFile=""
+ SubSystem="2"
+ 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>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\LCDriver.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\LCDriverEntry.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\LCDriverInterface.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\LCDriverMethods.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\LCDriverThread.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="api_wrappers"
+ >
+ <File
+ RelativePath=".\api_wrappers\windows\WinApiWrappers.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\LCDriver.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCDriverInterface.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCDriverMethods.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCDriverThread.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LcmInterface.h"
+ >
+ </File>
+ <File
+ RelativePath=".\resource.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="autogen"
+ >
+ <File
+ RelativePath=".\autogen\a2_command_ids.h"
+ >
+ </File>
+ <File
+ RelativePath=".\autogen\a2_commands.h"
+ >
+ </File>
+ <File
+ RelativePath=".\autogen\a2_commands_impl.h"
+ >
+ </File>
+ <File
+ RelativePath=".\autogen\a2_commands_marshal.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\autogen\command_ids.h"
+ >
+ </File>
+ <File
+ RelativePath=".\autogen\commands.h"
+ >
+ </File>
+ <File
+ RelativePath=".\autogen\commands_impl.h"
+ >
+ </File>
+ <File
+ RelativePath=".\autogen\commands_marshal.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\autogen\lcdriver_error_codes.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="config"
+ >
+ <File
+ RelativePath=".\config\a2_command_ids_h.xsl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating a2_command_ids.h..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)a2_commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\a2_command_ids.h&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)a2_commands.xml&quot;"
+ Outputs="autogen\a2_command_ids.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating a2_command_ids.h..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)a2_commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\a2_command_ids.h&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)a2_commands.xml&quot;"
+ Outputs="autogen\a2_command_ids.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="ReleaseWithDebugMessages|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating a2_command_ids.h..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)a2_commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\a2_command_ids.h&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)a2_commands.xml&quot;"
+ Outputs="autogen\a2_command_ids.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\config\a2_commands.xml"
+ >
+ </File>
+ <File
+ RelativePath=".\config\a2_commands_h.xsl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating a2_commands.h..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)a2_commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\a2_commands.h&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)a2_commands.xml&quot;"
+ Outputs="autogen\a2_commands.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating a2_commands.h..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)a2_commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\a2_commands.h&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)a2_commands.xml&quot;"
+ Outputs="autogen\a2_commands.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="ReleaseWithDebugMessages|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating a2_commands.h..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)a2_commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\a2_commands.h&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)a2_commands.xml&quot;"
+ Outputs="autogen\a2_commands.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\config\a2_commands_impl_h.xsl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating a2_commands_impl.h..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)a2_commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\a2_commands_impl.h&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)a2_commands.xml&quot;"
+ Outputs="autogen\a2_commands_impl.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating a2_commands_impl.h..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)a2_commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\a2_commands_impl.h&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)a2_commands.xml&quot;"
+ Outputs="autogen\a2_commands_impl.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="ReleaseWithDebugMessages|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating a2_commands_impl.h..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)a2_commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\a2_commands_impl.h&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)a2_commands.xml&quot;"
+ Outputs="autogen\a2_commands_impl.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\config\a2_commands_marshal_cpp.xsl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating a2_commands_marshal.cpp..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)a2_commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\a2_commands_marshal.cpp&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)a2_commands.xml&quot;"
+ Outputs="autogen\a2_commands_marshal.cpp"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating a2_commands_marshal.cpp..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)a2_commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\a2_commands_marshal.cpp&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)a2_commands.xml&quot;"
+ Outputs="autogen\a2_commands_marshal.cpp"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="ReleaseWithDebugMessages|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating a2_commands_marshal.cpp..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)a2_commands.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\a2_commands_marshal.cpp&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)a2_commands.xml&quot;"
+ Outputs="autogen\a2_commands_marshal.cpp"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\config\a2_common.xsl"
+ >
+ </File>
+ <File
+ RelativePath=".\config\command_ids_h.xsl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating command_ids.h..."
+ CommandLine="java -classpath ..\lcmodule\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&#x0D;&quot;&#x0D;&#x0A;"
+ 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 ..\lcmodule\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&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\command_ids.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="ReleaseWithDebugMessages|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating command_ids.h..."
+ CommandLine="java -classpath ..\lcmodule\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&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\command_ids.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\config\commands.xml"
+ >
+ </File>
+ <File
+ RelativePath=".\config\commands_h.xsl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating commands.h..."
+ CommandLine="java -classpath ..\lcmodule\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&#x0D;&quot;&#x0D;&#x0A;"
+ 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 ..\lcmodule\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&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\commands.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="ReleaseWithDebugMessages|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating commands.h..."
+ CommandLine="java -classpath ..\lcmodule\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&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\commands.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\config\commands_impl_h.xsl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating commands_impl.h..."
+ CommandLine="java -classpath ..\lcmodule\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_impl.h&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\commands_impl.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating commands_impl.h..."
+ CommandLine="java -classpath ..\lcmodule\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_impl.h&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\commands_impl.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="ReleaseWithDebugMessages|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating commands_impl.h..."
+ CommandLine="java -classpath ..\lcmodule\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_impl.h&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\commands_impl.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\config\commands_marshal_cpp.xsl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating commands_marshal.cpp..."
+ CommandLine="java -classpath ..\lcmodule\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_marshal.cpp&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\commands_marshal.cpp"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating commands_marshal.cpp..."
+ CommandLine="java -classpath ..\lcmodule\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_marshal.cpp&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\commands_marshal.cpp"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="ReleaseWithDebugMessages|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating commands_marshal.cpp..."
+ CommandLine="java -classpath ..\lcmodule\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_marshal.cpp&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)commands.xml&quot;"
+ Outputs="autogen\commands_marshal.cpp"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\config\common.xsl"
+ >
+ </File>
+ <File
+ RelativePath=".\config\lcdriver_error_codes.xml"
+ >
+ </File>
+ <File
+ RelativePath=".\config\lcdriver_error_codes_h.xsl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating lcdriver_error_codes.h..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)lcdriver_error_codes.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\lcdriver_error_codes.h&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)lcdriver_error_codes.xml&quot;"
+ Outputs="autogen\lcdriver_error_codes.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating lcdriver_error_codes.h..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)lcdriver_error_codes.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\lcdriver_error_codes.h&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)lcdriver_error_codes.xml&quot;"
+ Outputs="autogen\lcdriver_error_codes.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="ReleaseWithDebugMessages|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating lcdriver_error_codes.h..."
+ CommandLine="java -classpath ..\lcmodule\tools\xalan-j_2_7_1\xalan.jar org.apache.xalan.xslt.Process -in &quot;$(InputDir)lcdriver_error_codes.xml&quot; -xsl &quot;$(InputPath)&quot; -out &quot;$(ProjectDir)\autogen\lcdriver_error_codes.h&#x0D;&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(InputDir)lcdriver_error_codes.xml&quot;"
+ Outputs="autogen\lcdriver_error_codes.h"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="LCM"
+ >
+ <File
+ RelativePath=".\LCM\Buffers.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\Buffers.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\Hash.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\Hash.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\Queue.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\Queue.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\Timer.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\Timer.h"
+ >
+ </File>
+ <Filter
+ Name="include"
+ >
+ <File
+ RelativePath=".\LCM\include\c_compiler.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\c_system.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\error_codes.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\t_a2_protocol.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\t_basicdefinitions.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\t_bulk_protocol.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\t_command_protocol.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\t_communication_service.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\t_protrom_header.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\t_protrom_network.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\t_protrom_transport.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\t_queue.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\t_r15_header.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\t_r15_network_layer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\t_security_algorithms.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LCM\include\t_time_utilities.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="security_algorithms"
+ >
+ <File
+ RelativePath=".\security_algorithms\SecurityAlgorithms.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\security_algorithms\SecurityAlgorithms.h"
+ >
+ </File>
+ <File
+ RelativePath=".\security_algorithms\simlockcode.h"
+ >
+ </File>
+ <Filter
+ Name="sha"
+ >
+ <File
+ RelativePath=".\security_algorithms\sha\sha2.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\security_algorithms\sha\sha2.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="CEH"
+ >
+ <File
+ RelativePath=".\CEH\a2_commands_impl.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\CEH\CmdResult.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\CEH\CmdResult.h"
+ >
+ </File>
+ <File
+ RelativePath=".\CEH\commands_impl.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\CEH\commands_types.h"
+ >
+ </File>
+ <File
+ RelativePath=".\CEH\ProtromRpcInterface.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\CEH\ProtromRpcInterface.h"
+ >
+ </File>
+ <File
+ RelativePath=".\CEH\ZRpcInterface.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\CEH\ZRpcInterface.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="utilities"
+ >
+ <File
+ RelativePath=".\utilities\BulkHandler.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\utilities\BulkHandler.h"
+ >
+ </File>
+ <File
+ RelativePath=".\utilities\CaptiveThreadObject.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\utilities\CaptiveThreadObject.h"
+ >
+ </File>
+ <File
+ RelativePath=".\utilities\Error.h"
+ >
+ </File>
+ <File
+ RelativePath=".\utilities\Event.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LcmInterface.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\utilities\LockLessQueue.h"
+ >
+ </File>
+ <File
+ RelativePath=".\utilities\Logger.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\utilities\Logger.h"
+ >
+ </File>
+ <File
+ RelativePath=".\utilities\MemMappedFile.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\utilities\MemMappedFile.h"
+ >
+ </File>
+ <File
+ RelativePath=".\utilities\ObjectList.h"
+ >
+ </File>
+ <File
+ RelativePath=".\utilities\Serialization.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\utilities\Serialization.h"
+ >
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\LCDriver.rc"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/source/LCDriverEntry.cpp b/source/LCDriverEntry.cpp
new file mode 100644
index 0000000..91bd189
--- /dev/null
+++ b/source/LCDriverEntry.cpp
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include "LCDriverMethods.h"
+#include "Buffers.h"
+
+void destroy(void);
+
+#ifdef _WIN32
+BOOL APIENTRY DllMain(HMODULE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved)
+{
+ switch (ul_reason_for_call) {
+ case DLL_PROCESS_ATTACH:
+ break;
+ case DLL_THREAD_ATTACH:
+ break;
+ case DLL_THREAD_DETACH:
+ break;
+ case DLL_PROCESS_DETACH:
+ destroy();
+ break;
+ }
+
+ return TRUE;
+}
+#else
+void __attribute__((destructor)) DllMain(void)
+{
+ destroy();
+}
+#endif
+
+//***********************************************************************************************
+// Name: destroy()
+// Desc: Destroy any remaining buffer data.
+//**********************************************************************************************/
+void destroy(void)
+{
+ Buffers::ReleaseAllBulkFiles();
+ LcmInterface::CloseLCMLibrary();
+}
diff --git a/source/LCDriverInterface.cpp b/source/LCDriverInterface.cpp
new file mode 100644
index 0000000..adda735
--- /dev/null
+++ b/source/LCDriverInterface.cpp
@@ -0,0 +1,55 @@
+/******************************************************************************
+*
+* File name: LCDriverInterface.cpp
+* Project: LoaderCommunicationDriver
+* Language: Visual C++
+* Description: Interface class.
+*
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+******************************************************************************/
+
+#include "LCDriverInterface.h"
+
+CCriticalSectionObject CLCDriverInterface::InitializationCS;
+CObjectList<CLCDriverMethods> CLCDriverInterface::ObjectList;
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+CLCDriverInterface::CLCDriverInterface()
+{
+ isStarted = false;
+ m_pObject = NULL;
+ m_szObjectId[0] = '\0';
+}
+
+CLCDriverInterface::~CLCDriverInterface()
+{
+ CLockCS CsLock(InitializationCS);
+
+ // Disconnect from the CLCDriverMethods object
+ if (m_pObject != NULL) {
+ if (ObjectList.Release(m_pObject) == 0) {
+ delete m_pObject;
+ m_pObject = NULL;
+ }
+ }
+}
+
+CLCDriverMethods *CLCDriverInterface::FindObject(const char *interfaceId)
+{
+ return ObjectList.Find(interfaceId);
+}
+
+void CLCDriverInterface::ReleaseObject(CLCDriverMethods *object)
+{
+ ObjectList.Release(object);
+}
+
+int CLCDriverInterface::AddObject(CLCDriverMethods *object, const char *interfaceId)
+{
+ return ObjectList.Add(object, interfaceId);
+}
diff --git a/source/LCDriverInterface.h b/source/LCDriverInterface.h
new file mode 100644
index 0000000..6265b0d
--- /dev/null
+++ b/source/LCDriverInterface.h
@@ -0,0 +1,50 @@
+/*******************************************************************************
+*
+* File name: LCDriverInterface.h
+* Project: LCDriver
+* Language: Visual C++
+* Description: Interface class.
+* Revision : R1A
+*
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*******************************************************************************/
+
+#ifndef _CLCDRIVERINTERFACE_H_
+#define _CLCDRIVERINTERFACE_H_
+
+#include "LCDriverMethods.h"
+#include "ObjectList.h"
+
+/// <summary>
+/// Interface class for functions agains loader command.
+/// </summary>
+struct CLCDriverInterface {
+public:
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ CLCDriverInterface();
+
+ /// <summary>
+ /// Destructor.
+ /// </summary>
+ virtual ~CLCDriverInterface();
+
+ // Public data members
+ CLCDriverMethods *m_pObject;
+ char m_szObjectId[25];
+ bool isStarted;
+
+ static CCriticalSectionObject InitializationCS;
+
+ static CLCDriverMethods *FindObject(const char *interfaceId);
+ static void ReleaseObject(CLCDriverMethods *object);
+ static int AddObject(CLCDriverMethods *object, const char *interfaceId);
+private:
+ static CObjectList<CLCDriverMethods> ObjectList;
+};
+
+#endif // _CLCDRIVERINTERFACE_H_
diff --git a/source/LCDriverMethods.cpp b/source/LCDriverMethods.cpp
new file mode 100644
index 0000000..fd07664
--- /dev/null
+++ b/source/LCDriverMethods.cpp
@@ -0,0 +1,2574 @@
+/*********************************************************************************************
+*
+* File name: LCDriverMethods.cpp
+* Project: LoaderCommunicationDriver
+* Language: Visual C++
+* Description: Implementation of all exported methods.
+*
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*********************************************************************************************/
+
+#include "LCDriverMethods.h"
+#include "lcdriver_error_codes.h"
+#include "LCDriverThread.h"
+#include "Error.h"
+#include "LcmInterface.h"
+#include "ZRpcInterface.h"
+#include "ProtromRpcInterface.h"
+#include "commands_impl.h"
+#include "a2_commands_impl.h"
+#include "Event.h"
+#ifdef _WIN32
+#include "WinApiWrappers.h"
+#else
+#include "LinuxApiWrappers.h"
+#include <cstdlib>
+#endif
+#include <sys/stat.h>
+#include <sys/types.h>
+
+const char *const CLCDriverMethods::BULK_PATH = "/COMM";
+
+// LCM timeouts structure to avoid LCD interface changes after removing bulk session end timeout
+struct LcmR15Timeouts {
+ uint32 TCACK;
+ uint32 TBCR;
+ uint32 TBDR;
+};
+
+extern ListDevice_t Devices[];
+extern uint32 DevicesNumber;
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+/// <summary>
+/// Constructor.
+/// </summary>
+/// <param name="pchInterfaceId">A zero terminated string containing the InterfaceId.</param>
+CLCDriverMethods::CLCDriverMethods(const char *pchInterfaceId):
+ m_EventQueue(256)
+{
+ m_pchId = new char[strlen(pchInterfaceId)+1];
+ strcpy_s(m_pchId, strlen(pchInterfaceId) + 1, pchInterfaceId);
+
+ m_pCommunicationDevice = new CommunicationDevice_t;
+ m_pCmdResult = new CmdResult();
+ m_pLcmInterface = new LcmInterface();
+ m_pZRpcFunctions = new ZRpcInterface(m_pCmdResult, m_pLcmInterface);
+ m_pProtromRpcFunctions = new ProtromRpcInterface(m_pCmdResult, m_pLcmInterface);
+ m_pLoaderRpcFunctions = new LoaderRpcInterfaceImpl(this, m_pCmdResult, m_pLcmInterface);
+ m_pA2LoaderRpcFunctions = new A2LoaderRpcInterfaceImpl(this, m_pCmdResult, m_pLcmInterface);
+
+ m_pTimer = new Timer();
+ m_pHash = new Hash();
+ m_pQueue = new Queue();
+ m_pBuffers = new Buffers();
+ m_pSerialization = new Serialization();
+ m_pLogger = new Logger(m_pLcmInterface->getLCMContext());
+ m_pBulkHandler = new BulkHandler(this, m_pBuffers, m_pLcmInterface, m_pLogger);
+
+ // default values for timeouts
+ m_Timeouts.uiRTO = 0xFFFFFFFF; // Typically 5000
+ m_Timeouts.uiSTO = 0xFFFFFFFF; // Typically 30000 i.e. 30 secs
+
+ m_CurrentProtocolFamily = R15_FAMILY;
+ m_iBulkProtocolMode = BULK_INACTIVE;
+
+ m_ProgressBarUpdate = 0;
+ m_uiBulkLength = 0;
+ m_uiBulkTransferred = 0;
+ m_pMainThread = 0;
+ m_pHashDevice = 0;
+ m_CurrentCEHCallback = 0;
+}
+
+/// <summary>
+/// Destructor.
+/// </summary>
+CLCDriverMethods::~CLCDriverMethods()
+{
+ m_EventQueue.SignalEvent();
+ OS::Sleep(200);
+
+ if (0 != m_pMainThread) {
+ m_pMainThread->EndCaptiveThread();
+ }
+
+ delete m_pMainThread;
+
+ if (0 != m_pLcmInterface) {
+ m_pLcmInterface->CommunicationShutdown();
+ }
+
+ delete m_pLcmInterface;
+ delete m_pCmdResult;
+ delete m_pZRpcFunctions;
+ delete m_pProtromRpcFunctions;
+ delete m_pLoaderRpcFunctions;
+ delete m_pA2LoaderRpcFunctions;
+
+ delete m_pCommunicationDevice;
+ delete m_pTimer;
+ delete m_pBuffers;
+ delete m_pHash;
+ delete m_pQueue;
+ delete m_pSerialization;
+
+ delete m_pLogger;
+ delete m_pBulkHandler;
+ delete[] m_pchId;
+}
+//----------------------------------------
+// Static callback functions for intercept only
+//----------------------------------------
+
+//----------------------------------------
+// Static methods
+//----------------------------------------
+
+ErrorCode_e CLCDriverMethods::TimerInit(void *pObject, uint32 uiTimers)
+{
+ Timer *pTimer = static_cast<Timer *>(pObject);
+ return pTimer->Init(uiTimers);
+}
+
+uint32 CLCDriverMethods::TimerGet(void *pObject, Timer_t *pTimer)
+{
+ Timer *pTimerLocal = static_cast<Timer *>(pObject);
+ return pTimerLocal->Get(pTimer);
+}
+
+ErrorCode_e CLCDriverMethods::TimerRelease(void *pObject, uint32 uiTimerKey)
+{
+ Timer *pTimer = static_cast<Timer *>(pObject);
+ return pTimer->Release(uiTimerKey);
+}
+
+uint32 CLCDriverMethods::TimerReadTime(void *pObject, uint32 uiTimerKey)
+{
+ Timer *pTimer = static_cast<Timer *>(pObject);
+ return pTimer->ReadTime(uiTimerKey);
+}
+
+uint32 CLCDriverMethods::TimerGetSystemTime(void *pObject)
+{
+ Timer *pTimer = static_cast<Timer *>(pObject);
+ return pTimer->GetSystemTime();
+}
+
+//--------------------------------------------
+void CLCDriverMethods::HashCancel(void *pObject, void **ppHashDevice)
+{
+ Hash *pHashObject = static_cast<Hash *>(pObject);
+ pHashObject->Cancel((HashDevice_t **)ppHashDevice);
+}
+
+void CLCDriverMethods::HashCalculate(void *pObject, HashType_e Type, void *pData, const uint32 uiLength, uint8 *pHash, HashCallback_fn fnCallback, void *pParam)
+{
+ Hash *pHashObject = static_cast<Hash *>(pObject);
+ pHashObject->Calculate(Type, pData, uiLength, pHash, fnCallback, pParam);
+}
+
+//----------------------------------------
+
+ErrorCode_e CLCDriverMethods::BuffersInit(void *pObject)
+{
+ Buffers *pBufferObject = static_cast<Buffers *>(pObject);
+ return pBufferObject->Init();
+}
+
+void *CLCDriverMethods::BufferAllocate(void *pObject, int iBufferSize)
+{
+ Buffers *pBufferObject = static_cast<Buffers *>(pObject);
+ return pBufferObject->Allocate(iBufferSize);
+}
+
+ErrorCode_e CLCDriverMethods::BufferRelease(void *pObject, void *pBuffer, int iBufferSize)
+{
+ Buffers *pBufferObject = static_cast<Buffers *>(pObject);
+ return pBufferObject->Release(pBuffer, iBufferSize);
+}
+
+uint32 CLCDriverMethods::BuffersAvailable(void *pObject, int iBufferSize)
+{
+ Buffers *pBufferObject = static_cast<Buffers *>(pObject);
+ return pBufferObject->Available(iBufferSize);
+}
+
+void CLCDriverMethods::BuffersDeinit(void *pObject)
+{
+ Buffers *pBufferObject = static_cast<Buffers *>(pObject);
+ pBufferObject->Deinit();
+}
+
+//----------------------------------------
+
+void CLCDriverMethods::QueueCreate(void *pObject, void **const ppQueue, const uint32 uiMaxLength, void (*pDestroyElement)(void *pElement))
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ pQueueLocal->RCreate(ppQueue, uiMaxLength, pDestroyElement);
+}
+void CLCDriverMethods::QueueDestroy(void *pObject, void **const ppQueue)
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ pQueueLocal->RDestroy(ppQueue);
+}
+
+ErrorCode_e CLCDriverMethods::QueueEnqueue(void *pObject, void *const ppQueue, void *const pValue)
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ return pQueueLocal->REnqueue(ppQueue, pValue);
+}
+
+void *CLCDriverMethods::QueueDequeue(void *pObject, void *const ppQueue)
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ return pQueueLocal->RDequeue(ppQueue);
+}
+
+QueueCallback_fn CLCDriverMethods::QueueSetCallback(void *pObject, void *const pQueue, const QueueCallbackType_e Type, const QueueCallback_fn fnCallback, void *const pParam)
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ return pQueueLocal->RSetCallback(pQueue, Type, fnCallback, pParam);
+}
+
+boolean CLCDriverMethods::QueueIsEmpty(void *pObject, const void *const pQueue)
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ return pQueueLocal->RIsEmpty(pQueue);
+}
+
+boolean CLCDriverMethods::QueueIsMember(void *pObject, const void *const pQueue, void *pValue, boolean(*Match)(void *pValue1, void *pValue2))
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ return pQueueLocal->RIsMember(pQueue, pValue, Match);
+}
+
+int CLCDriverMethods::QueueGetNrOfElements(void *pObject, const void *const pQueue)
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ return pQueueLocal->RGetNrOfElements(pQueue);
+}
+
+void CLCDriverMethods::RQueueCreate(void *pObject, void **const ppQueue, const uint32 uiMaxLength, void (*pDestroyElement)(void *pElement))
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ pQueueLocal->RCreate(ppQueue, uiMaxLength, pDestroyElement);
+}
+
+void CLCDriverMethods::RQueueDestroy(void *pObject, void **const ppQueue)
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ pQueueLocal->RDestroy(ppQueue);
+}
+
+ErrorCode_e CLCDriverMethods::RQueueEnqueue(void *pObject, void *const pQueue, void *const pValue)
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ return pQueueLocal->REnqueue(pQueue, pValue);
+}
+
+void *CLCDriverMethods::RQueueDequeue(void *pObject, void *const pQueue)
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ return pQueueLocal->RDequeue(pQueue);
+}
+
+QueueCallback_fn CLCDriverMethods::RQueueSetCallback(void *pObject, void *const pQueue, const QueueCallbackType_e Type, const QueueCallback_fn fnCallback, void *const pParam)
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ return pQueueLocal->RSetCallback(pQueue, Type, fnCallback, pParam);
+}
+
+boolean CLCDriverMethods::RQueueIsEmpty(void *pObject, const void *const pQueue)
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ return pQueueLocal->RIsEmpty(pQueue);
+}
+
+boolean CLCDriverMethods::RQueueIsMember(void *pObject, const void *const pQueue, void *pValue, boolean(*Match)(void *pValue1, void *pValue2))
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ return pQueueLocal->RIsMember(pQueue, pValue, Match);
+}
+
+int CLCDriverMethods::RQueueGetNrOfElements(void *pObject, const void *const pQueue)
+{
+ Queue *pQueueLocal = static_cast<Queue *>(pObject);
+ return pQueueLocal->RGetNrOfElements(pQueue);
+}
+
+//----------------------------------------
+
+ErrorCode_e CLCDriverMethods::CEHCallbackFunction(void *pObject, CommandData_t *pCmdData)
+{
+ CLCDriverMethods *pLcdMethods = static_cast<CLCDriverMethods *>(pObject);
+ return pLcdMethods->m_pLoaderRpcFunctions->Do_CEH_Callback(pCmdData);
+}
+
+ErrorCode_e CLCDriverMethods::CEH_Z_CallbackFunction(void *pObject, CommandData_t *pCmdData)
+{
+ CLCDriverMethods *pLcdMethods = static_cast<CLCDriverMethods *>(pObject);
+ return pLcdMethods->m_pZRpcFunctions->Do_CEH_Callback(pCmdData);
+}
+
+ErrorCode_e CLCDriverMethods::CEH_PROTROM_CallbackFunction(void *pObject, CommandData_t *pCmdData)
+{
+ CLCDriverMethods *pLcdMethods = static_cast<CLCDriverMethods *>(pObject);
+ return pLcdMethods->m_pProtromRpcFunctions->Do_CEH_Callback(pCmdData);
+}
+
+ErrorCode_e CLCDriverMethods::CEH_A2_CallbackFunction(void *pObject, CommandData_t *pCmdData)
+{
+ CLCDriverMethods *pLcdMethods = static_cast<CLCDriverMethods *>(pObject);
+ return pLcdMethods->m_pA2LoaderRpcFunctions->Do_CEH_Callback(pCmdData);
+}
+
+//----------------------------------------
+
+void CLCDriverMethods::BulkCommandReqCallback(void *pObject, uint16 *puiSession, uint32 *puiChunkSize, uint64 *puiOffset, uint32 *puiLength, boolean bAckRead)
+{
+ CLCDriverMethods *pLcdMethods = static_cast<CLCDriverMethods *>(pObject);
+ return pLcdMethods->m_pBulkHandler->HandleCommandRequest(*puiSession, *puiChunkSize, *puiOffset, *puiLength, bAckRead ? true : false);
+}
+
+void CLCDriverMethods::BulkDataReqCallback(void *pObject, uint16 *puiSession, uint32 *puiChunkSize, uint64 *puiOffset, uint32 *puiLength, uint64 *puiTotalLength, uint32 *puiTransferedLength)
+{
+ CLCDriverMethods *pLcdMethods = static_cast<CLCDriverMethods *>(pObject);
+ return pLcdMethods->Do_BulkDataReqCallback(puiSession, puiChunkSize, puiOffset, puiLength, puiTotalLength, puiTransferedLength);
+}
+
+void CLCDriverMethods::BulkDataEndOfDumpCallback(void *pObject)
+{
+ CLCDriverMethods *pLcdMethods = static_cast<CLCDriverMethods *>(pObject);
+ return pLcdMethods->Do_BulkDataEndOfDumpCallback();
+}
+
+////////////////////////////////////////////////////////////////////////
+///
+/// Exported methods
+///
+
+/// <summary>
+/// Initializes LCDriver.
+/// </summary>
+/// <param name="pfnRead">Callback to external Read function.</param>
+/// <param name="pfnWrite">Callback to external Write function.</param>
+/// <param name="pfnCancel">Callback to external Cancel function.</param>
+/// <param name="ppInstance">Method modifies value to point to this instance of m_pGlobalCommunicationLCDriver object.</param>
+/// <param name="pfnMessage">Callback to external Message function for outputting text.</param>
+/// <param name="pchLCMLibPath">Path to LCM module.</param>
+/// <param name="pfnProgressBarCallback">Callback to external ProgressBar function.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_Initialize(void **ppInstance)
+{
+#ifdef _MESSAGES
+ m_pBuffers->SetLogger(m_pLogger);
+ m_pQueue->SetLogger(m_pLogger);
+ m_pTimer->SetLogger(m_pLogger);
+ m_pSerialization->SetLogger(m_pLogger);
+#endif
+ int ReturnValue = E_SUCCESS;
+
+ // Setup Command Protocol buffer
+ m_pBuffers->Init();
+
+ BuffersInterface_t BufferFunctions;
+ TimersInterface_t TimerFunctions;
+ QueueInterface_t QueueFunctions;
+
+ // Setup timer struct
+ VERIFY_SUCCESS(SetupTimers(&TimerFunctions));
+
+ // Setup buffer struct
+ VERIFY_SUCCESS(SetupBuffers(&BufferFunctions));
+
+ // Setup queue struct
+ VERIFY_SUCCESS(SetupQueues(&QueueFunctions));
+
+ // Setup hash struct
+ VERIFY_SUCCESS(SetupHash());
+
+ if (NULL == m_pCommunicationDevice->Read || NULL == m_pCommunicationDevice->Write || NULL == m_pCommunicationDevice->Cancel) {
+ VERIFY_SUCCESS(CALLBACKS_NOT_CONFIGURED_CORRECTLY);
+ }
+
+ VERIFY_SUCCESS(m_pLcmInterface->CommunicationInitialize(this, m_CurrentProtocolFamily, m_pHashDevice, m_pCommunicationDevice, m_CurrentCEHCallback, &BufferFunctions, &TimerFunctions, &QueueFunctions));
+ *ppInstance = m_pLcmInterface->getLCMContext();
+
+ // Create main thread
+ if (m_pTimer) {
+ m_pMainThread = new CLCDriverThread(this);
+ } else {
+ VERIFY_SUCCESS(LCDRIVER_THREAD_NOT_STARTED);
+ }
+
+ // Initialize 32 timers for the moment (timer memory only allocated once for all instances)
+ TimerInit(m_pTimer, 32);
+
+ if (R15_FAMILY == m_CurrentProtocolFamily) {
+ m_pMainThread->TimerOn();
+ }
+
+ //Now start LCDriver thread
+ m_pMainThread->ResumeThread();
+
+ m_pLogger->log("LCDriver/LCM started ok!");
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// Set up Timers utility class required by LCM.
+/// </summary>
+/// <returns> Status of the command.</returns>
+ErrorCode_e CLCDriverMethods::SetupTimers(TimersInterface_t *pTimerFunctions)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ pTimerFunctions->GetSystemTime_Fn = static_cast<GetSystemTime_t>(TimerGetSystemTime);
+ pTimerFunctions->ReadTime_Fn = static_cast<ReadTime_t>(TimerReadTime);
+ pTimerFunctions->TimerGet_Fn = static_cast<TimerGet_t>(TimerGet);
+ pTimerFunctions->TimerRelease_Fn = static_cast<TimerRelease_t>(TimerRelease);
+ pTimerFunctions->TimersInit_Fn = static_cast<TimersInit_t>(TimerInit);
+ pTimerFunctions->Object_p = m_pTimer;
+ return Result;
+}
+
+/// <summary>
+/// Set up Buffer utility class required by LCM.
+/// </summary>
+/// <returns> Status of the command.</returns>
+ErrorCode_e CLCDriverMethods::SetupBuffers(BuffersInterface_t *pBufferFunctions)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ pBufferFunctions->BufferAllocate_Fn = static_cast<BufferAllocate_t>(BufferAllocate);
+ pBufferFunctions->BufferRelease_Fn = static_cast<BufferRelease_t>(BufferRelease);
+ pBufferFunctions->BuffersAvailable_Fn = static_cast<BuffersAvailable_t>(BuffersAvailable);
+ pBufferFunctions->BuffersDeinit_Fn = static_cast<BuffersDeinit_t>(BuffersDeinit);
+ pBufferFunctions->BuffersInit_Fn = static_cast<BuffersInit_t>(BuffersInit);
+ pBufferFunctions->Object_p = m_pBuffers;
+ return Result;
+}
+
+/// <summary>
+/// Set up Queue utility class required by LCM.
+/// </summary>
+/// <returns> Status of the command.</returns>
+ErrorCode_e CLCDriverMethods::SetupQueues(QueueInterface_t *pQueueFunctions)
+{
+ ErrorCode_e Result = E_SUCCESS;
+ pQueueFunctions->Fifo_GetNrOfElements_Fn = QueueGetNrOfElements;
+ pQueueFunctions->Fifo_IsEmpty_Fn = QueueIsEmpty;
+ pQueueFunctions->Fifo_IsMember_Fn = QueueIsMember;
+ pQueueFunctions->Fifo_SetCallback_Fn = QueueSetCallback;
+ pQueueFunctions->FifoCreate_Fn = QueueCreate;
+ pQueueFunctions->FifoDequeue_Fn = QueueDequeue;
+ pQueueFunctions->FifoDestroy_Fn = QueueDestroy;
+ pQueueFunctions->FifoEnqueue_Fn = QueueEnqueue;
+ pQueueFunctions->RFifo_GetNrOfElements_Fn = RQueueGetNrOfElements;
+ pQueueFunctions->RFifo_IsEmpty_Fn = RQueueIsEmpty;
+ pQueueFunctions->RFifo_IsMember_Fn = RQueueIsMember;
+ pQueueFunctions->RFifo_SetCallback_Fn = RQueueSetCallback;
+ pQueueFunctions->RFifoCreate_Fn = RQueueCreate;
+ pQueueFunctions->RFifoDequeue_Fn = RQueueDequeue;
+ pQueueFunctions->RFifoDestroy_Fn = RQueueDestroy;
+ pQueueFunctions->RFifoEnqueue_Fn = RQueueEnqueue;
+ pQueueFunctions->Object_p = m_pQueue;
+ return Result;
+}
+
+/// <summary>
+/// Set up Hash utility class required by LCM.
+/// </summary>
+/// <returns> Status of the command.</returns>
+ErrorCode_e CLCDriverMethods::SetupHash()
+{
+ m_pHashDevice = new HashDevice_t;
+
+ if (0 == m_pHashDevice) {
+ return E_ALLOCATE_FAILED;
+ }
+
+ m_pHashDevice->Calculate = HashCalculate;
+ m_pHashDevice->Cancel = HashCancel;
+ m_pHashDevice->Object_p = m_pHash;
+ return E_SUCCESS;
+}
+
+void CLCDriverMethods::CancelCurrentLoaderCommand()
+{
+ m_EventQueue.SignalEvent();
+}
+
+/// <summary>
+/// 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.
+/// </summary>
+/// <param name="pchVersion">Loader version identifier.</param>
+/// <param name="piVersionSize">Number of allocated bytes for version string.</param>
+/// <param name="pchProtocol">Protocol version identifier.</param>
+/// <param name="piProtocolSize">Number of allocated bytes for protocol string.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Done_System_LoaderStartupStatus(char *pchVersion, int *piVersionSize, char *pchProtocol, int *piProtocolSize)
+{
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(WaitForEvent(EVENT_CMD_RECEIVED, GROUP_SYSTEM, COMMAND_SYSTEM_LOADERSTARTUPSTATUS));
+ VERIFY_SUCCESS(m_pCmdResult->System_LoaderStartupStatus_Status);
+
+ //Copy output parameter from RPC class.
+ CopyStringToArray(m_pCmdResult->System_LoaderStartupStatus_LoaderVersion, pchVersion, piVersionSize);
+ CopyStringToArray(m_pCmdResult->System_LoaderStartupStatus_ProtocolVersion, pchProtocol, piProtocolSize);
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ *piVersionSize = 0;
+ *piProtocolSize = 0;
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// 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. The ME does not accept any further communication after a successful
+/// response from this command has been returned.
+/// </summary>
+/// <param name="iMode">Indicates the mode of reset:
+/// 0: indicates normal restart.
+/// 1: indicates restart in service mode.
+/// 2: indicates restart with JTAG debugging enabled.
+/// 3: indicates restart in service mode and with JTAG debugging enabled.
+/// </param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_System_Reboot(int iMode)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_System_Reboot(uiSessionOut, iMode));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// The loader returns a list of implemented commands and whether they are permitted to
+/// execute in the current loader state.
+/// </summary>
+/// <param name="pCmdList">A list with supported commands.</param>
+/// <param name="piCmdListSize">Number of commands in CmdList.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_System_SupportedCommands(TSupportedCmd *pCmdList, int *piCmdListSize)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_System_SupportedCommands(uiSessionOut));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SYSTEM, COMMAND_SYSTEM_SUPPORTEDCOMMANDS));
+
+ //Copy output parameter from RPC class.
+ *piCmdListSize = static_cast<int>(m_pCmdResult->System_SupportedCommands_CmdList.size());
+ CopyVectorToArray(m_pCmdResult->System_SupportedCommands_CmdList, pCmdList, piCmdListSize);
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ *piCmdListSize = 0;
+ }
+
+ return ReturnValue;
+}
+
+int CLCDriverMethods::Do_System_CollectData(int iType, int *piSize, char *pData)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_System_CollectData(uiSessionOut, iType));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SYSTEM, COMMAND_SYSTEM_COLLECTDATA));
+
+ //Copy output parameter from RPC class.
+ if (m_pCmdResult->System_CollectedData.length() > static_cast<size_t>(*piSize)) {
+ m_pCmdResult->System_CollectedData.erase(*piSize - 1);
+ }
+
+ strcpy_s(pData, *piSize, m_pCmdResult->System_CollectedData.c_str());
+ *piSize = m_pCmdResult->System_CollectedData.length();
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ *piSize = 0;
+ *pData = '\0';
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// Receive, verify and execute software, which can be a signed loader.
+/// After having sent this command, the ME attempts to read the software
+/// payload data from the host using the Bulk protocol or from the flash
+/// file system depending on the selected path. The current loader does not
+/// respond to communication after this command has been successfully executed.
+/// If the executed software is another loader, communication can be resumed once the
+/// Loader Started command has been received. A response of E_OPERATION_CANCELLED
+/// indicates the operation was canceled.
+/// </summary>
+/// <param name="pchDevicePath">Target path. If use bulk the path is on PC, else on ME.</param>
+/// <param name="iUseBulk">If value = 1 -> source on PC, else source on ME.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_System_ExecuteSoftware(const uint32 ExecuteMode, const char *pchDevicePath, int iUseBulk)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ if (1 == ExecuteMode) {
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_System_ExecuteSoftware(uiSessionOut, ExecuteMode, pchDevicePath, 0));
+
+ } else if (2 == ExecuteMode) {
+ if (iUseBulk) {
+ m_pLcmInterface->BulkSetCallbacks((void *)BulkCommandReqCallback, (void *)BulkDataReqCallback, (void *)BulkDataEndOfDumpCallback);
+ VERIFY_SUCCESS(m_pBuffers->AllocateBulkFile(pchDevicePath));
+ uint64 uiLength = m_pBuffers->GetBulkFileLength();
+ m_uiBulkLength = uiLength;
+ m_uiBulkTransferred = 0;
+ VERIFY_SUCCESS(m_pBulkHandler->Send(pchDevicePath));
+
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_System_ExecuteSoftware(uiSessionOut, ExecuteMode, BULK_PATH, uiLength));
+ //VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SYSTEM, COMMAND_SYSTEM_EXECUTESOFTWARE));
+ } else {
+ // TEMPORARY ONLY - QSJOMIK: CURRENTLY WE CANNOT KNOW THE SIZE OF FILE ON AN ME MEMORY CARD IF USEBULK=0 - DO WE NEED A PARAMETER??
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_System_ExecuteSoftware(uiSessionOut, ExecuteMode, pchDevicePath, 0));
+ //VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SYSTEM, COMMAND_SYSTEM_EXECUTESOFTWARE));
+ }
+
+ // reset session counters for this instance of the lcm
+ m_pLcmInterface->CommandResetSessionCounters();
+ } else {
+ ReturnValue = INVALID_EXECUTION_MODE;
+ }
+ //}
+
+ErrorExit:
+
+ if (iUseBulk) {
+ m_pBulkHandler->Finish();
+ m_pBuffers->ReleaseBulkFile();
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to escalate the privileges of the operator. Two ways 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 sends the appropriate request for information to the PC.
+/// </summary>
+/// <param name="iType">Authentication type:0 = control key authentication,1 = certificate authentication.</param>
+/// <param name="piSize">Size of puchData.</param>
+/// <param name="puchdata">Data challange. </param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_System_Authenticate(int iType, int *piSize, unsigned char *puchdata)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_System_Authenticate(uiSessionOut, iType));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED | EVENT_CMD_RECEIVED, GROUP_SYSTEM, COMMAND_SYSTEM_AUTHENTICATE));
+
+ if (0 != iType) {
+ CopyVectorToArray(m_pCmdResult->System_AuthenticationChallenge_Buffer, puchdata, piSize);
+ }
+
+ErrorExit:
+
+ if (0 != iType && E_SUCCESS != ReturnValue) {
+ *piSize = 0;
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used by the loader to retrieve the SimLock control keys from the host to authenticate a user.
+/// The command is used in the authentication context.
+/// </summary>
+/// <param name="pSIMLockKeys">A struct with all lock/unlock keys.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Done_System_GetControlKeys(TSIMLockKeys *pSIMLockKeys)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoneRPC_System_GetControlKeys(uiSessionOut, E_SUCCESS,
+ pSIMLockKeys->pchNLCKLock, pSIMLockKeys->pchNSLCKLock,
+ pSIMLockKeys->pchSPLCKLock, pSIMLockKeys->pchCLCKLock,
+ pSIMLockKeys->pchPCKLock, pSIMLockKeys->pchESLCKLock,
+ pSIMLockKeys->pchNLCKUnLock, pSIMLockKeys->pchNSLCKUnLock,
+ pSIMLockKeys->pchSPLCKUnLock, pSIMLockKeys->pchCLCKUnLock,
+ pSIMLockKeys->pchPCKLock, pSIMLockKeys->pchESLCKUnLock));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SYSTEM, COMMAND_SYSTEM_AUTHENTICATE));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used by the loader to retrieve the SimLock control keys data buffer from the host to authenticate a user.
+/// The command is used in the authentication context.
+/// </summary>
+/// <param name="SIMLockKeysData">SIMLockKeyData buffer that contain all SIMLock keys.</param>
+/// <param name="iDataSize">SIMLockKeyData buffer size.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Done_System_GetControlKeysData(int iDataSize, unsigned char *pSIMLockKeysData)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoneRPC_System_GetControlKeysData(uiSessionOut, E_SUCCESS,
+ iDataSize, pSIMLockKeysData));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SYSTEM, COMMAND_SYSTEM_AUTHENTICATE));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used by the loader to perform a certificate authentication.
+/// The command is only used in the authentication context.
+/// </summary>
+/// <param name="puchChallengeData">Authentication challenge. This challenge must be signed
+/// using the correct certificate and returned to the loader.</param>
+/// <param name="iDataSize">Authentication challenge buffer length.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Done_System_AuthenticationChallenge(int iDataSize, unsigned char *puchChallengeData)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoneRPC_System_AuthenticationChallenge(uiSessionOut, E_SUCCESS, iDataSize, puchChallengeData));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SYSTEM, COMMAND_SYSTEM_AUTHENTICATE));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// The Set System Time command is used to set the current epoch time for loader
+/// to configure the real time clock and use it for file system operations.
+/// </summary>
+/// <param name="EpochTime">
+/// Number of seconds that have elapsed since January 1, 1970
+/// </param>
+/// <returns>Status of the command.</returns>
+int CLCDriverMethods::Do_System_SetSystemTime(uint32 EpochTime)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_System_SetSystemTime(uiSessionOut, EpochTime));
+
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SYSTEM, COMMAND_SYSTEM_SETSYSTEMTIME));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to instruct the Loader to switch to a new communication device.
+/// </summary>
+/// <param name="Device">
+/// Device ID of the communication device to switch to.
+/// </param>
+/// <param name="DeviceParam">
+/// Communication device parameters.
+/// </param>
+/// <returns>Status of the command.</returns>
+int CLCDriverMethods::Do_System_SwitchCommunicationDevice(uint32 Device, uint32 DeviceParam)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_System_SwitchCommunicationDevice(uiSessionOut, Device, DeviceParam));
+
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SYSTEM, COMMAND_SYSTEM_SWITCHCOMMUNICATIONDEVICE));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// The loader shuts down in a controlled fashion and proceeds to shut down the ME itself.
+/// The ME does not accept any further communication after a successful response from this
+/// command has been returned.
+/// </summary>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_System_Shutdown()
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_System_ShutDown(uiSessionOut));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// 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.
+/// </summary>
+/// <param name="pchPath">Target path. If iUseBulk = 1, path is on PC.</param>
+/// <param name="pchType">Type of the opened file.</param>
+/// <param name="iUseBulk">If to use bulk protocol. If target is on PC iUseBulk shall be 1.</param>
+/// <param name="iDeleteBuffers">Specify whether to delete bulk buffers when finished. 1 -> delete buffers. 0 -> don't delete buffers.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_Flash_ProcessFile(const char *pchPath, const char *pchType, int iUseBulk, int iDeleteBuffers)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+#ifdef _BULKDEBUG
+ m_pLogger->log("BULK: Do_Flash_ProcessFile - DeleteBuffers = %d", iDeleteBuffers);
+#endif
+
+ if (iUseBulk) {
+ m_pLcmInterface->BulkSetCallbacks((void *)BulkCommandReqCallback, (void *)BulkDataReqCallback, (void *)BulkDataEndOfDumpCallback);
+ VERIFY_SUCCESS(m_pBuffers->AllocateBulkFile(pchPath));
+ uint64 uiLength = m_pBuffers->GetBulkFileLength();
+ m_uiBulkLength = uiLength;
+ m_uiBulkTransferred = 0;
+ VERIFY_SUCCESS(m_pBulkHandler->Send(pchPath));
+
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_Flash_ProcessFile(uiSessionOut, uiLength, pchType, BULK_PATH));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FLASH, COMMAND_FLASH_PROCESSFILE));
+ } else {
+ // QSJOMIK: CURRENTLY WE CANNOT KNOW THE SIZE OF FILE ON AN ME MEMORY CARD IF USEBULK=0 - SEND 0 FOR NOW
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_Flash_ProcessFile(uiSessionOut, 0, pchType, pchPath));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FLASH, COMMAND_FLASH_PROCESSFILE));
+ }
+
+ErrorExit:
+
+ if (iUseBulk) {
+ m_pBulkHandler->Finish();
+
+ if (0 != iDeleteBuffers) {
+ m_pBuffers->ReleaseBulkFile();
+ }
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used by the client application program to obtain the device tree.
+/// </summary>
+/// <param name="pDevices">A struct with information about one flash device.</param>
+/// <param name="piDeviceSize">Number of flash devices, size of pDevices array.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_Flash_ListDevices(TDevices *pDevices, int *piDeviceSize)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_Flash_ListDevices(uiSessionOut));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FLASH, COMMAND_FLASH_LISTDEVICES));
+
+ *piDeviceSize = DevicesNumber;
+
+ for (int i = 0; i < *piDeviceSize; ++i) {
+ pDevices[i].pchPath = Devices[i].Path_p;
+ pDevices[i].pchType = Devices[i].Type_p;
+
+ pDevices[i].iTypeSize = strlen(Devices[i].Type_p);
+ pDevices[i].iPathSize = strlen(Devices[i].Path_p);
+
+ pDevices[i].uiBlockSize = Devices[i].BlockSize;
+ pDevices[i].uiStart = Devices[i].Start;
+ pDevices[i].uiLength = Devices[i].Length;
+ }
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ *piDeviceSize = 0;
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to initiate a dump session.
+/// </summary>
+/// <param name="pchPathToDump">Path to the device to dump.</param>
+/// <param name="uiStart">Start of the dump relative to the start of the device indicated by Path [Byte].</param>
+/// <param name="uiLength">Length of the dump [Byte]. Actual length is determined by the device block size.</param>
+/// <param name="pchFilePath">File path on PC to store dump data to.</param>
+/// <param name="uiRedundantArea">Include redundant area in the dump.</param>
+/// <param name="iUseBulk">1-> save dump data on PC, 0-> save dump data on ME.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_Flash_DumpArea(const char *pchPathToDump, uint64 uiStart, uint64 uiLength, const char *pchFilePath, uint32 uiRedundantArea, int iUseBulk)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ if (iUseBulk) {
+ m_pLcmInterface->BulkSetCallbacks((void *)BulkCommandReqCallback, (void *)BulkDataReqCallback, (void *)BulkDataEndOfDumpCallback);
+ m_uiBulkLength = uiLength;
+ m_uiBulkTransferred = 0;
+ VERIFY_SUCCESS(m_pBulkHandler->Receive(pchFilePath));
+
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_Flash_DumpArea(uiSessionOut, pchPathToDump, uiStart, uiLength, BULK_PATH, uiRedundantArea));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FLASH, COMMAND_FLASH_DUMPAREA));
+ } else {
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_Flash_DumpArea(uiSessionOut, pchPathToDump, uiStart, uiLength, pchFilePath, uiRedundantArea));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FLASH, COMMAND_FLASH_DUMPAREA));
+ }
+
+ErrorExit:
+
+ if (iUseBulk) {
+ m_pBulkHandler->Finish();
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to erase a flash device or part of a flash device.
+/// </summary>
+/// <param name="pchPath">Path to the device to erase.</param>
+/// <param name="uiStart">Start of the erase relative to the start of the device
+/// indicated by path [Byte]. This must be a multiple of the block size of the device.</param>
+/// <param name="uiLength">Length of the dump [Byte]. This must be a multiple of the block size of the device.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_Flash_EraseArea(const char *pchPath, uint64 uiStart, uint64 uiLength)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_Flash_EraseArea(uiSessionOut, pchPath, uiStart, uiLength));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FLASH, COMMAND_FLASH_ERASEAREA));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to initiate a flashing of raw data. The type argument is
+/// used to select the type of file to process and Length parameter
+/// defines the total size of the file.
+/// </summary>
+/// <param name="Context">LCD context on which to execute the operation.</param>
+/// <param name="pchPath">Target path. If iUseBulk = 1, path is on PC.</param>
+/// <param name="uiStart">Address where flashing should start.</param>
+/// <param name="uiLength">Length of data to be flashed.</param>
+/// <param name="uiDevice">Device ID number.</param>
+/// <param name="iUseBulk">If to use bulk protocol. If target is on PC iUseBulk shall be 1.</param>
+/// <param name="iDeleteBuffers">Specify if to delete bulk buffers after finish. 1 -> delete buffers. 0 -> don't delete buffers.</param>
+/// <returns>Status of the command.</returns>
+int CLCDriverMethods::Do_Flash_FlashRaw(const char *pchPath, uint64 uiStart, uint64 uiLength, uint32 uiDevice, int iUseBulk, int iDeleteBuffers)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+#ifdef _BULKDEBUG
+ m_pLogger->log("BULK: Do_Flash_FlashRaw - DeleteBuffers = %d", iDeleteBuffers);
+#endif
+
+ if (iUseBulk) {
+ m_pLcmInterface->BulkSetCallbacks((void *)BulkCommandReqCallback, (void *)BulkDataReqCallback, (void *)BulkDataEndOfDumpCallback);
+ VERIFY_SUCCESS(m_pBuffers->AllocateBulkFile(pchPath));
+
+ uint64 uiFileLength = m_pBuffers->GetBulkFileLength();
+ VERIFY((uiLength <= uiFileLength), E_INVALID_INPUT_PARAMETERS);
+
+ m_uiBulkLength = uiLength;
+ m_uiBulkTransferred = 0;
+ VERIFY_SUCCESS(m_pBulkHandler->Send(pchPath));
+
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_Flash_FlashRaw(uiSessionOut, uiStart, uiLength, uiDevice, BULK_PATH));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FLASH, COMMAND_FLASH_FLASHRAW));
+ } else {
+ // CURRENTLY WE CANNOT KNOW THE SIZE OF FILE ON AN ME MEMORY CARD IF USEBULK=0 - SEND 0 FOR NOW
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_Flash_FlashRaw(uiSessionOut, uiStart, 0, uiDevice, pchPath));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FLASH, COMMAND_FLASH_FLASHRAW));
+ }
+
+ErrorExit:
+
+ if (iUseBulk) {
+ m_pBulkHandler->Finish();
+
+ if (0 != iDeleteBuffers) {
+ m_pBuffers->ReleaseBulkFile();
+ }
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command retrieves the properties of the specified file system volume. It is issued by the PC application.
+/// </summary>
+/// <param name="pchDevicePath">Path of file system volume.</param>
+/// <param name="pchFSType">File system type.</param>
+/// <param name="piFSTypeSize">Size of pchFSType array.</param>
+/// <param name="puiSize">Total size of the file system [Byte].</param>
+/// <param name="puiFree">Available space [Byte].</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_FileSystem_VolumeProperties(const char *pchDevicePath, char *pchFSType, int *piFSTypeSize, uint64 *puiSize, uint64 *puiFree)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_File_System_Operations_VolumeProperties(uiSessionOut, pchDevicePath));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FILE_SYSTEM_OPERATIONS, COMMAND_FILE_SYSTEM_OPERATIONS_VOLUMEPROPERTIES));
+
+ //Copy output parameter from RPC class.
+ if (m_pCmdResult->FileSystem_VolumeProperties_FSType.length() > static_cast<size_t>(*piFSTypeSize)) {
+ m_pCmdResult->FileSystem_VolumeProperties_FSType.erase(*piFSTypeSize - 1);
+ }
+
+ strcpy_s(pchFSType, *piFSTypeSize, m_pCmdResult->FileSystem_VolumeProperties_FSType.c_str());
+ *piFSTypeSize = m_pCmdResult->FileSystem_VolumeProperties_FSType.length();
+ *puiSize = m_pCmdResult->FileSystem_VolumeProperties_Size;
+ *puiFree = m_pCmdResult->FileSystem_VolumeProperties_Free;
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ *pchFSType = '\0';
+ *piFSTypeSize = 0;
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// Formats unused file system volume specified in device path. This operation fails if the volume is currently in use.
+/// </summary>
+/// <param name="pchDevicePath">Device path of the file system volume.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_FileSystem_FormatVolume(const char *pchDevicePath)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_File_System_Operations_FormatVolume(uiSessionOut, pchDevicePath));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FILE_SYSTEM_OPERATIONS, COMMAND_FILE_SYSTEM_OPERATIONS_FORMATVOLUME));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+
+/// <summary>
+/// List files and directories residing in specified path.
+/// </summary>
+/// <param name="pchPath">File system path.</param>
+/// <param name="pEntries">Struct with file and directory information.</param>
+/// <param name="piDeviceSize">Number of files or directories, number of element in pEntries array.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_FileSystem_ListDirectory(const char *pchPath, TEntries *pEntries, int *piDeviceSize)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_File_System_Operations_ListDirectory(uiSessionOut, pchPath));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FILE_SYSTEM_OPERATIONS, COMMAND_FILE_SYSTEM_OPERATIONS_LISTDIRECTORY));
+
+ //Copy output parameter from RPC class.
+ *piDeviceSize = static_cast<int>(m_pCmdResult->FileSystem_ListDirectory_Entries.size());
+ CopyVectorToArray(m_pCmdResult->FileSystem_ListDirectory_Entries, pEntries, piDeviceSize);
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ *piDeviceSize = 0;
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command moves a file from the source path to the destination path if the source and destination differ.
+/// It also renames a file if the source path and the destination path are the same.
+/// </summary>
+/// <param name="pchSourcePath">File system path in ME to source.</param>
+/// <param name="pchDestinationPath">File system path in ME to destination.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_FileSystem_MoveFile(const char *pchSourcePath, const char *pchDestinationPath)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_File_System_Operations_MoveFile(uiSessionOut, pchSourcePath, pchDestinationPath)); // DoRPC_FileSystem_MoveFile(&uiSessionOut, pchSourcePath, pchDestinationPath);
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FILE_SYSTEM_OPERATIONS, COMMAND_FILE_SYSTEM_OPERATIONS_MOVEFILE));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// Delete the specified file or directory. The loader only deletes empty directories.
+/// </summary>
+/// <param name="pchTargetPath">File system path in ME.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_FileSystem_DeleteFile(const char *pchTargetPath)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_File_System_Operations_DeleteFile(uiSessionOut, pchTargetPath));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FILE_SYSTEM_OPERATIONS, COMMAND_FILE_SYSTEM_OPERATIONS_DELETEFILE));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to do the following: Copy a file from the PC to the ME. Copy a file between two directories or file systems on the ME.
+/// Copy a file from the ME to the PC.
+/// </summary>
+/// <param name="pchSourcePath">If iSourceUseBulk = 1 -> path on PC, else path on ME.</param>
+/// <param name="iSourceUseBulk">If = 1 -> source on PC, else source on ME.</param>
+/// <param name="pchDestinationPath">If iDestinationUseBulk = 1 -> path on PC, else path on ME.</param>
+/// <param name="iDestinationUseBulk">If = 1 -> destination on PC, else destination on ME.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_FileSystem_CopyFile(const char *pchSourcePath, int iSourceUseBulk, const char *pchDestinationPath, int iDestinationUseBulk)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ if (iSourceUseBulk) { // PC -> ME
+ m_pLcmInterface->BulkSetCallbacks((void *)BulkCommandReqCallback, (void *)BulkDataReqCallback, (void *)BulkDataEndOfDumpCallback);
+ VERIFY_SUCCESS(m_pBuffers->AllocateBulkFile(pchSourcePath));
+ m_uiBulkLength = m_pBuffers->GetBulkFileLength();
+ m_uiBulkTransferred = 0;
+ VERIFY_SUCCESS(m_pBulkHandler->Send(pchSourcePath));
+
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_File_System_Operations_CopyFile(uiSessionOut, BULK_PATH, pchDestinationPath));
+
+ //Wait for stat command
+ VERIFY_SUCCESS(WaitForEvent(EVENT_CMD_RECEIVED, GROUP_FILE_SYSTEM_OPERATIONS, COMMAND_FILE_SYSTEM_OPERATIONS_PROPERTIES));
+
+ struct stat fileInfo;
+ stat(pchSourcePath, &fileInfo);
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoneRPC_File_System_Operations_Properties(uiSessionOut, E_SUCCESS, fileInfo.st_mode, fileInfo.st_size, (uint32)fileInfo.st_mtime, (uint32)fileInfo.st_atime, (uint32)fileInfo.st_ctime));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FILE_SYSTEM_OPERATIONS, COMMAND_FILE_SYSTEM_OPERATIONS_COPYFILE));
+ } else if (iDestinationUseBulk) { // ME -> PC
+ m_pLcmInterface->BulkSetCallbacks((void *)BulkCommandReqCallback, (void *)BulkDataReqCallback, (void *)BulkDataEndOfDumpCallback);
+ VERIFY_SUCCESS(m_pBulkHandler->Receive(pchDestinationPath));
+
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_File_System_Operations_CopyFile(uiSessionOut, pchSourcePath, BULK_PATH));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FILE_SYSTEM_OPERATIONS, COMMAND_FILE_SYSTEM_OPERATIONS_COPYFILE));
+ } else {
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_File_System_Operations_CopyFile(uiSessionOut, pchSourcePath, pchDestinationPath));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FILE_SYSTEM_OPERATIONS, COMMAND_FILE_SYSTEM_OPERATIONS_COPYFILE));
+ }
+
+ErrorExit:
+
+ if (iSourceUseBulk || iDestinationUseBulk) {
+ m_pBulkHandler->Finish();
+
+ if (iSourceUseBulk) {
+ m_pBuffers->ReleaseBulkFile();
+ }
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to create a directory. It is issued by the PC application.
+/// </summary>
+/// <param name="pchTargetPath">File system path to target.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_FileSystem_CreateDirectory(const char *pchTargetPath)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_File_System_Operations_CreateDirectory(uiSessionOut, pchTargetPath));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FILE_SYSTEM_OPERATIONS, COMMAND_FILE_SYSTEM_OPERATIONS_CREATEDIRECTORY));
+
+ErrorExit:
+ return ReturnValue;
+}
+/// <summary>
+/// This command is used to retrieve the properties of a file or directory.
+/// </summary>
+/// <param name="pchTargetPath">File system path to target.</param>
+/// <param name="puiMode">File type and access restrictions descriptor.</param>
+/// <param name="puiSize">File size [Byte].</param>
+/// <param name="piMTime">Last modification timestamp.</param>
+/// <param name="piATime">Last access timestamp.</param>
+/// <param name="piCTime">Creation timestamp.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_FileSystem_Properties(const char *pchTargetPath, uint32 *puiMode, uint64 *puiSize, int *piMTime, int *piATime, int *piCTime)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_File_System_Operations_Properties(uiSessionOut, pchTargetPath));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FILE_SYSTEM_OPERATIONS, COMMAND_FILE_SYSTEM_OPERATIONS_PROPERTIES));
+
+ //Copy output parameter from RPC class.
+ *puiMode = m_pCmdResult->FileSystem_Properties_Mode;
+ *puiSize = m_pCmdResult->FileSystem_Properties_Size;
+ *piMTime = m_pCmdResult->FileSystem_Properties_MTime;
+ *piATime = m_pCmdResult->FileSystem_Properties_ATime;
+ *piCTime = m_pCmdResult->FileSystem_Properties_CTime;
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to change the access permissions of a specified path.
+/// </summary>
+/// <param name="pchTargetPath">File system path to target.</param>
+/// <param name="iAccess">New access permissions.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_FileSystem_ChangeAccess(const char *pchTargetPath, int iAccess)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_File_System_Operations_ChangeAccess(uiSessionOut, pchTargetPath, iAccess));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FILE_SYSTEM_OPERATIONS, COMMAND_FILE_SYSTEM_OPERATIONS_CHANGEACCESS));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to read manifests contained in load modules at the specified path and send the data back over bulk protocol.
+/// </summary>
+/// <param name="pchTargetPath">Path on PC to save manifest.</param>
+/// <param name="pchSourcePath">Load module(s) file system path.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_FileSystem_ReadLoadModuleManifests(const char *pchTargetPath, const char *pchSourcePath)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ m_pLcmInterface->BulkSetCallbacks((void *)BulkCommandReqCallback, (void *)BulkDataReqCallback, (void *)BulkDataEndOfDumpCallback);
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pBulkHandler->Receive(pchTargetPath));
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_File_System_Operations_ReadLoadModulesManifests(uiSessionOut, pchSourcePath));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_FILE_SYSTEM_OPERATIONS, COMMAND_FILE_SYSTEM_OPERATIONS_READLOADMODULESMANIFESTS));
+
+ErrorExit:
+ m_pBulkHandler->Finish();
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to read the specified bits from the OTP.
+/// </summary>
+/// <param name="iOtpId">OTP area ID.</param>
+/// <param name="iBitStart">Starting offset [bit].</param>
+/// <param name="iBitLength">Length of read [bit].</param>
+/// <param name="puchDataBuffer">Received OTP data.</param>
+/// <param name="piDataBufferSize">Size of puchDataBuffer.</param>
+/// <param name="puchStatusBuffer">Lock status for each read bit.</param>
+/// <param name="piStatusBufferSize">Size of puchStatusBuffer.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_OTP_ReadBits(int iOtpId, int iBitStart, int iBitLength, unsigned char *puchDataBuffer, int *piDataBufferSize , unsigned char *puchStatusBuffer, int *piStatusBufferSize)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_OTP_ReadBits(uiSessionOut, iOtpId, iBitStart, iBitLength));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_OTP, COMMAND_OTP_READBITS));
+
+ //Copy output parameter from RPC class.
+ CopyVectorToArray(m_pCmdResult->OTP_ReadBits_DataBuffer, puchDataBuffer, piDataBufferSize);
+ CopyVectorToArray(m_pCmdResult->OTP_ReadBits_StatusBuffer, puchStatusBuffer, piStatusBufferSize);
+
+ //clean up
+ m_pCmdResult->OTP_ReadBits_DataBuffer.clear();
+ m_pCmdResult->OTP_ReadBits_StatusBuffer.clear();
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ *piDataBufferSize = 0;
+ *piStatusBufferSize = 0;
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command stores the specified bits in the loader internal OTP structures in RAM, it does not write to OTP.
+/// </summary>
+/// <param name="iOtpId">OTP area ID.</param>
+/// <param name="iBitStart">Starting offset [bit].</param>
+/// <param name="iBitLength">Length of write [bit].</param>
+/// <param name="puchDataBuffer">OTP data to write.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_OTP_SetBits(int iOtpId, int iBitStart, int iBitLength, unsigned char *puchDataBuffer)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ uint32 Bytes = 0;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ Bytes = (iBitLength + 7) / 8;
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_OTP_SetBits(uiSessionOut, iOtpId, iBitStart, iBitLength, Bytes, puchDataBuffer));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_OTP, COMMAND_OTP_SETBITS));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command writes (burns) all data from loader internal OTP structures in RAM into the OTP fuse box.
+/// </summary>
+/// <param name="iOtpId">OTP area ID.</param>
+/// <param name="iForceWrite">If true: write and lock all lockable areas even if not all bits are received in cache.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_OTP_WriteAndLock(int iOtpId, int iForceWrite)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_OTP_WriteAndLock(uiSessionOut, iOtpId, iForceWrite));
+
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_OTP, COMMAND_OTP_WRITEANDLOCK));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command installs a secure object to the Boot record or OTP area.
+/// </summary>
+/// <param name="pchSourcePath">If iUseBulk = 1 -> path on PC, else path on ME.</param>
+/// <param name="iDestination">Secure object destination address on ME.</param>
+/// <param name="iUseBulk">Source on PC -> iUseBulk= 1. Source on ME -> iUseBulk= 0.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_OTP_StoreSecureObject(const char *pchSourcePath, int iDestination, int iUseBulk)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ if (iUseBulk) {
+ m_pLcmInterface->BulkSetCallbacks((void *)BulkCommandReqCallback, (void *)BulkDataReqCallback, (void *)BulkDataEndOfDumpCallback);
+
+ VERIFY_SUCCESS(m_pBuffers->AllocateBulkFile(pchSourcePath));
+ m_uiBulkLength = m_pBuffers->GetBulkFileLength();
+ m_uiBulkTransferred = 0;
+ VERIFY_SUCCESS(m_pBulkHandler->Send(pchSourcePath));
+
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_OTP_StoreSecureObject(uiSessionOut, BULK_PATH, iDestination));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_OTP, COMMAND_OTP_STORESECUREOBJECT));
+ } else {
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_OTP_StoreSecureObject(uiSessionOut, pchSourcePath, iDestination));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_OTP, COMMAND_OTP_STORESECUREOBJECT));
+ }
+
+ErrorExit:
+
+ if (iUseBulk) {
+ m_pBulkHandler->Finish();
+ m_pBuffers->ReleaseBulkFile();
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// Reads a specified unit from the global data storage area/partition specified by the DevicePath parameter.
+/// </summary>
+/// <param name="iGdfsId">GDFS ID.</param>
+/// <param name="iUnit">Unit ID to read.</param>
+/// <param name="puchDataBuffer">Received global data.</param>
+/// <param name="piSize">Size of puchDataBuffer.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_ParameterStorage_ReadGlobalDataUnit(const char *pchGdfsId, int iUnit, unsigned char *puchDataBuffer, int *piSize)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_ParameterStorage_ReadGlobalDataUnit(uiSessionOut, pchGdfsId, iUnit));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_PARAMETERSTORAGE, COMMAND_PARAMETERSTORAGE_READGLOBALDATAUNIT));
+
+ //Copy output parameter from RPC class.
+ CopyVectorToArray(m_pCmdResult->ParameterStorage_ReadGlobalDataUnit_DataBuffer, puchDataBuffer, piSize);
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ *piSize = 0;
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// Writes a specified unit to the global data storage area/partition specified by the DevicePath parameter.
+/// </summary>
+/// <param name="iGdfsId">GDFS ID.</param>
+/// <param name="iUnit">Unit ID to write.</param>
+/// <param name="puchDataBuffer">Global data to write.</param>
+/// <param name="iSize">Size of puchDataBuffer.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_ParameterStorage_WriteGlobalDataUnit(const char *pchGdfsId, int iUnit, const unsigned char *puchDataBuffer, int iSize)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_ParameterStorage_WriteGlobalDataUnit(uiSessionOut, pchGdfsId, iUnit, iSize, (void *)puchDataBuffer));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_PARAMETERSTORAGE, COMMAND_PARAMETERSTORAGE_WRITEGLOBALDATAUNIT));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// Reads the complete global data storage area/partition specified by the DevicePath parameter (reads all units at once).
+/// </summary>
+/// <param name="iGdfsId">GDFS ID.</param>
+/// <param name="pchPath">If iUseBulk=1 -> path on PC to save data set to. Else path on ME.</param>
+/// <param name="iUseBulk">1-> save global data on PC, 0-> save global data on ME.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_ParameterStorage_ReadGlobalDataSet(const char *pchGdfsId, const char *pchPath, int iUseBulk)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ if (iUseBulk) {
+ m_pLcmInterface->BulkSetCallbacks((void *)BulkCommandReqCallback, (void *)BulkDataReqCallback, (void *)BulkDataEndOfDumpCallback);
+ VERIFY_SUCCESS(m_pBulkHandler->Receive(pchPath));
+
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_ParameterStorage_ReadGlobalDataSet(uiSessionOut, pchGdfsId, BULK_PATH));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_PARAMETERSTORAGE, COMMAND_PARAMETERSTORAGE_READGLOBALDATASET));
+ } else {
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_ParameterStorage_ReadGlobalDataSet(uiSessionOut, pchGdfsId, pchPath));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_PARAMETERSTORAGE, COMMAND_PARAMETERSTORAGE_READGLOBALDATASET));
+ }
+
+ErrorExit:
+
+ if (iUseBulk) {
+ m_pBulkHandler->Finish();
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// Writes the complete global data storage area/partition specified by the DevicePath parameter (writes all units at once).
+/// </summary>
+/// <param name="iGdfsId">GDFS ID.</param>
+/// <param name="pchPath">f iUseBulk=1 -> path on PC. Else path on ME</param>
+/// <param name="iUseBulk">1-> Global data source on PC, 0-> global data source on ME.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_ParameterStorage_WriteGlobalDataSet(const char *pchGdfsId, const char *pchPath, int iUseBulk)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ if (iUseBulk) {
+ VERIFY_SUCCESS(m_pBuffers->AllocateBulkFile(pchPath));
+ uint64 uiLength = m_pBuffers->GetBulkFileLength();
+ m_pLcmInterface->BulkSetCallbacks((void *)BulkCommandReqCallback, (void *)BulkDataReqCallback, (void *)BulkDataEndOfDumpCallback);
+ m_uiBulkLength = uiLength;
+ m_uiBulkTransferred = 0;
+ VERIFY_SUCCESS(m_pBulkHandler->Send(pchPath));
+
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_ParameterStorage_WriteGlobalDataSet(uiSessionOut, pchGdfsId, uiLength, BULK_PATH));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_PARAMETERSTORAGE, COMMAND_PARAMETERSTORAGE_WRITEGLOBALDATASET));
+ } else {
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_ParameterStorage_WriteGlobalDataSet(uiSessionOut, pchGdfsId, 0, pchPath));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_PARAMETERSTORAGE, COMMAND_PARAMETERSTORAGE_WRITEGLOBALDATASET));
+ }
+
+ErrorExit:
+
+ if (iUseBulk) {
+ m_pBulkHandler->Finish();
+ m_pBuffers->ReleaseBulkFile();
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// Erases the complete global data storage area/partition specified by the DevicePath parameter.
+/// </summary>
+/// <param name="iGdfsId">GDFS ID.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_ParameterStorage_EraseGlobalDataSet(const char *pchGdfsId)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_ParameterStorage_EraseGlobalDataSet(uiSessionOut, pchGdfsId));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_PARAMETERSTORAGE, COMMAND_PARAMETERSTORAGE_ERASEGLOBALDATASET));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to set the ME domain.
+/// </summary>
+/// <param name="iDomain">Target domain.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_Security_SetDomain(int iDomain)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_Security_SetDomain(uiSessionOut, iDomain));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SECURITY, COMMAND_SECURITY_SETDOMAIN));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to get the ME domain.
+/// </summary>
+/// <param name="piWrittenDomain">The ME current domain.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_Security_GetDomain(int *piWrittenDomain)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_Security_GetDomain(uiSessionOut));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SECURITY, COMMAND_SECURITY_GETDOMAIN));
+
+ //Copy output parameter from RPC class.
+ *piWrittenDomain = m_pCmdResult->Security_GetDomain_WrittenDomain;
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to read a security data unit (such as a secure static or dynamic data unit).
+/// </summary>
+/// <param name="iUnitId">Unit ID to read.</param>
+/// <param name="piSize">Size of puchDataBuffer.</param>
+/// <param name="puchDataBuffer">The unit data.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_Security_GetProperties(int iUnitId, int *piSize, unsigned char *puchDataBuffer)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_Security_GetProperties(uiSessionOut, iUnitId));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SECURITY, COMMAND_SECURITY_GETPROPERTIES));
+
+ //Copy output parameter from RPC class.
+ CopyVectorToArray(m_pCmdResult->Security_GetProperties_DataBuffer, puchDataBuffer, piSize);
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ *piSize = 0;
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command is used to write a security data unit (such as a secure static or dynamic data unit).
+/// </summary>
+/// <param name="iUnitId">Unit ID to write.</param>
+/// <param name="iSize">Size of puchDataBuffer.</param>
+/// <param name="puchDataBuffer">The data to write.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_Security_SetProperties(int iUnitId, int iSize, const unsigned char *puchDataBuffer)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_Security_SetProperties(uiSessionOut, iUnitId, iSize, (void *)puchDataBuffer));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SECURITY, COMMAND_SECURITY_SETPROPERTIES));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// This command associates all security data units with the current ME.
+/// </summary>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_Security_BindProperties()
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_Security_BindProperties(uiSessionOut));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SECURITY, COMMAND_SECURITY_BINDPROPERTIES));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// The A2 loader shuts down in a controlled fashion and proceeds to shut down the ME itself.
+/// The ME does not accept any further communication after a successful response from this
+/// command has been returned.
+/// </summary>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_A2_System_Shutdown()
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ m_pA2LoaderRpcFunctions->setTargetCpu(1);
+
+ VERIFY_SUCCESS(m_pA2LoaderRpcFunctions->DoRPC_A2_System_Shutdown(uiSessionOut));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// The PC uses the Loader version command to request version information from the loader
+/// The response holds the loader version information coded as ASCII characters in the data field
+/// </summary>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_A2_System_LoaderVersion(char *pchLoaderVersion, int *piSize, int iTargetCPU)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ m_pA2LoaderRpcFunctions->setTargetCpu(iTargetCPU);
+ VERIFY_SUCCESS(m_pA2LoaderRpcFunctions->DoRPC_A2_System_LoaderVersion(uiSessionOut));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_A2_SYSTEM, COMMAND_A2_SYSTEM_LOADERVERSION));
+
+ CopyStringToArray(m_pCmdResult->A2_LoaderVersion, pchLoaderVersion, piSize);
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ *piSize = 0;
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// The Protocol version command is sent by the PC to request application protocol version from the loader.
+/// The loader responds with a GR with the protocol version in the response field.
+/// The version is coded as: 1 byte Major version + 1 byte Minor version.
+/// </summary>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_A2_System_Reset(int iTimeout)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ m_pA2LoaderRpcFunctions->setTargetCpu(1);
+ VERIFY_SUCCESS(m_pA2LoaderRpcFunctions->DoRPC_A2_System_Reset(uiSessionOut, iTimeout));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// The Loader on loader command is used to transfer a new loader to the ME
+/// When the header or payload has been sent, the loader responds with a GR using status codes.
+/// </summary>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_A2_System_LoaderOnLoader(const char *pchPath, int iPLOffset, int iHLOffset, int iTargetCPU)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ MemMappedFile loaderFile;
+ uint32 loaderSize;
+ uint8 *loaderData = NULL;
+ uint32 LeftToSend;
+ size_t NumberOfPackets;
+ const uint32 PacketSize = m_pCmdResult->A2_MaxLoaderPacketSize - 17;
+ uint32 PayloadOffset;
+ const void *temp;
+ uint32 HL;
+ uint32 HL_Real;
+ uint32 PL;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(loaderFile.LoadFileData(pchPath));
+ loaderSize = static_cast<uint32>(loaderFile.GetFileSize());
+ loaderData = loaderFile.AllocateFileData(0, loaderSize);
+ VERIFY(0 != loaderData, loaderFile.GetError());
+
+ m_pA2LoaderRpcFunctions->setTargetCpu(iTargetCPU);
+
+ // get header length.
+ temp = loaderData + iHLOffset;
+ HL = m_pSerialization->get_uint32_le(&temp);
+ // pad to 8 byte (64 bit) alignments
+ HL_Real = (HL + 7) & ~7;
+
+ // calculate payload length
+ PL = loaderSize - HL_Real;
+
+ VERIFY_SUCCESS(m_pA2LoaderRpcFunctions->DoRPC_A2_System_LoaderOnLoader(uiSessionOut, HL_Real, loaderData));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_A2_SYSTEM, COMMAND_A2_SYSTEM_LOADERONLOADER));
+
+ NumberOfPackets = PL / PacketSize;
+
+ if (NumberOfPackets *PacketSize == PL) {
+ NumberOfPackets--;
+ }
+
+ PayloadOffset = HL_Real;
+
+ if (NumberOfPackets > 0) {
+ m_pA2LoaderRpcFunctions->setMorePackets(1);
+
+ for (size_t i = 0; i < NumberOfPackets; ++i) {
+ VERIFY_SUCCESS(m_pA2LoaderRpcFunctions->DoRPC_A2_System_LoaderOnLoader(uiSessionOut, PacketSize, loaderData + PayloadOffset));
+ PayloadOffset += PacketSize;
+ }
+
+ m_pA2LoaderRpcFunctions->setMorePackets(0);
+ }
+
+ // send last payload package
+ LeftToSend = PL - PayloadOffset + HL_Real;
+ VERIFY_SUCCESS(m_pA2LoaderRpcFunctions->DoRPC_A2_System_LoaderOnLoader(uiSessionOut, LeftToSend, loaderData + PayloadOffset));
+
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_A2_SYSTEM, COMMAND_A2_SYSTEM_LOADERONLOADER));
+
+ErrorExit:
+
+ if (0 != loaderData) {
+ loaderFile.ReleaseFileData(loaderData, 0, loaderSize);
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// The Program flash command is sent by the PC to write a block of data into the flash memory.
+/// The block data is sent in the data field.
+/// When a complete block has been transmitted the loader verifies the data and responds with a GR using status codes
+/// </summary>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_A2_Flash_ProgramFlash(const char *pchPath, int iUseSpeedFlash)
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ MemMappedFile softwareFile;
+ uint32 softwareSize;
+ uint8 *softwareData = 0;
+ const void *temp;
+ uint32 headerSize;
+ uint8 *payloadData;
+ uint32 leftToSend;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ softwareFile.LoadFileData(pchPath);
+ softwareSize = static_cast<uint32>(softwareFile.GetFileSize());
+ softwareData = softwareFile.AllocateFileData(0, softwareSize);
+ VERIFY(0 != softwareData, softwareFile.GetError());
+
+ // A2 header length offset = 80
+ temp = softwareData + 80;
+ headerSize = Serialization::get_uint32_le(&temp);
+ headerSize = (headerSize + 7) & ~7;
+
+ payloadData = softwareData + headerSize;
+
+ m_pA2LoaderRpcFunctions->setTargetCpu(2);
+ VERIFY_SUCCESS(m_pA2LoaderRpcFunctions->DoRPC_A2_Flash_VerifySignedHeader(uiSessionOut, headerSize, softwareData));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_A2_FLASH, COMMAND_A2_FLASH_VERIFYSIGNEDHEADER));
+
+ leftToSend = softwareSize - headerSize;
+
+ if (iUseSpeedFlash) {
+ temp = softwareData + 60; // start address is located at byte 60
+ uint32 startAddress = Serialization::get_uint32_le(&temp);
+
+ temp = softwareData + 28; // maximum block size is located at byte 28
+ uint32 subBlockSize = Serialization::get_uint32_le(&temp);
+
+ temp = softwareData + 64; // the software length (end address) is located at byte 64
+ uint32 endAddress = Serialization::get_uint32_le(&temp);
+
+ // speedflash command should be sent to ACC CPU
+ m_pA2LoaderRpcFunctions->setTargetCpu(1);
+
+ // start LCM speedflash mode
+ m_pLcmInterface->A2SpeedflashStart();
+
+ VERIFY_SUCCESS(m_pA2LoaderRpcFunctions->DoRPC_A2_Flash_Speedflash(uiSessionOut, startAddress, endAddress, subBlockSize));
+
+ while (leftToSend) {
+ Serialization::skip_uint32((const void **)&payloadData); //skip start address
+ Serialization::skip_uint32((const void **)&payloadData); //skip block size
+ leftToSend -= 8; // skip start address and block size in the image
+
+ subBlockSize = min(subBlockSize, leftToSend);
+
+ VERIFY_SUCCESS(WaitForEvent(EVENT_SPEEDFLASH, GROUP_A2_FLASH, COMMAND_A2_FLASH_SPEEDFLASH));
+
+ if (0 == leftToSend - subBlockSize) {
+ m_pLcmInterface->A2SpeedflashSetLastBlock();
+ }
+
+ VERIFY_SUCCESS(m_pLcmInterface->A2SpeedflashWriteBlock(payloadData, subBlockSize)); // send sub-block
+
+ payloadData += subBlockSize;
+ leftToSend -= subBlockSize;
+ }
+
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_A2_FLASH, COMMAND_A2_FLASH_SPEEDFLASH));
+ } else {
+ while (leftToSend) {
+ uint32 startAddress = Serialization::get_uint32_le((const void **)&payloadData);
+ uint32 blockSize = Serialization::get_uint32_le((const void **)&payloadData);
+ leftToSend -= 8; // skip start address and block size in the image
+ blockSize = min(blockSize, leftToSend);
+
+ VERIFY_SUCCESS(m_pA2LoaderRpcFunctions->DoRPC_A2_Flash_SoftwareBlockAddress(uiSessionOut, startAddress, blockSize));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_A2_FLASH, COMMAND_A2_FLASH_SOFTWAREBLOCKADDRESS));
+
+ VERIFY_SUCCESS(m_pA2LoaderRpcFunctions->DoRPC_A2_Flash_ProgramFlash(uiSessionOut, blockSize, payloadData));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_A2_FLASH, COMMAND_A2_FLASH_PROGRAMFLASH));
+
+ payloadData += blockSize;
+ leftToSend -= blockSize;
+ }
+ }
+
+ // verify flash command should be sent to APP CPU
+ m_pA2LoaderRpcFunctions->setTargetCpu(2);
+ VERIFY_SUCCESS(m_pA2LoaderRpcFunctions->DoRPC_A2_Flash_VerifySoftwareFlash(uiSessionOut));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_A2_FLASH, COMMAND_A2_FLASH_VERIFYSOFTWAREFLASH));
+
+ErrorExit:
+
+ if (0 != softwareData) {
+ softwareFile.ReleaseFileData(softwareData, 0, softwareSize);
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// The Erase flash command is used to erase the complete flash memory.
+/// It checks what type of memory is used in the ME and erases the complete memory including the first memory block.
+/// If more than one flash is attached, all of them will be erased
+/// The loader responds with a GR using status codes
+/// </summary>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_A2_Flash_EraseFlash()
+{
+ uint16 uiSessionOut = 0;
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ m_pA2LoaderRpcFunctions->setTargetCpu(2);
+ VERIFY_SUCCESS(m_pA2LoaderRpcFunctions->DoRPC_A2_Flash_EraseFlash(uiSessionOut));
+ VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_A2_FLASH, COMMAND_A2_FLASH_ERASEFLASH));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+int CLCDriverMethods::Done_A2_Control_LoaderStarted()
+{
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ VERIFY_SUCCESS(WaitForEvent(EVENT_CMD_RECEIVED, GROUP_A2_CONTROL, COMMAND_A2_CONTROL_LOADERSTARTED));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// Switch protocol family.
+/// </summary>
+/// <param name="family">New protocol family to use.</param>
+/// <returns>Status of the command.</returns>
+int CLCDriverMethods::Do_SwitchProtocolFamily(TFamily family)
+{
+ int ReturnValue = E_SUCCESS;
+ char strMessage[100] = {0};
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ m_pMainThread->TimerOff();
+
+ switch (family) {
+ case R15_PROTOCOL_FAMILY:
+ m_CurrentProtocolFamily = R15_FAMILY;
+ m_CurrentCEHCallback = static_cast<Do_CEH_Call_t>(CEHCallbackFunction);
+ strcat_s(strMessage, "Do_SetProtocolFamily(R15_FAMILY)");
+ m_pMainThread->TimerOn();
+ break;
+ case PROTROM_PROTOCOL_FAMILY:
+ m_CurrentProtocolFamily = PROTROM_FAMILY;
+ m_CurrentCEHCallback = static_cast<Do_CEH_Call_t>(CEH_PROTROM_CallbackFunction);
+ strcat_s(strMessage, "Do_SwitchProtocolFamily(PROTROM_FAMILY)");
+ break;
+ case Z_PROTOCOL_FAMILY:
+ m_CurrentProtocolFamily = Z_FAMILY;
+ m_CurrentCEHCallback = static_cast<Do_CEH_Call_t>(CEH_Z_CallbackFunction);
+ strcat_s(strMessage, "Do_SwitchProtocolFamily(Z_FAMILY)");
+ m_pZRpcFunctions->Z_IndataBuffer->Clear();
+ break;
+ case A2_PROTOCOL_FAMILY:
+ m_CurrentProtocolFamily = A2_FAMILY;
+ m_CurrentCEHCallback = static_cast<Do_CEH_Call_t>(CEH_A2_CallbackFunction);
+ strcat_s(strMessage, "Do_SwitchProtocolFamily(A2_FAMILY)");
+ //m_pMainThread->TimerOn();
+ break;
+ default:
+ return INVALID_INPUT_PARAMETERS;
+ }
+
+#ifdef _MESSAGES
+ m_pLogger->log(strMessage);
+#endif
+
+ VERIFY_SUCCESS(m_pMainThread->SetLcmFamily(m_CurrentProtocolFamily, m_CurrentCEHCallback));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// Set ME in service mode and receive chip id.
+/// </summary>
+/// <param name="puiChipId">Received chip id.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_Z_SetInServiceMode(unsigned int *puiChipId)
+{
+ int ReturnValue = E_SUCCESS;
+
+ time_t Start = 0;
+ time_t End = 0;
+ time_t ElapsedTime = 0;
+ bool bEmptyBuffer = false;
+ unsigned char uchReceivedByte;
+ unsigned char rguchReceivedChipId[8];
+ int iCount = 0;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ //Receive a 'z' character.
+ time(&Start);
+ time(&End);
+ ElapsedTime = End - Start;
+
+ while (ElapsedTime < 30) {
+ uchReceivedByte = m_pZRpcFunctions->Z_IndataBuffer->Pop(&bEmptyBuffer);
+
+ if ((bEmptyBuffer == false) && (uchReceivedByte == 'z')) {
+ break;
+ }
+
+ time(&End);
+ ElapsedTime = End - Start;
+ OS::Sleep(2);
+ }
+
+ if (ElapsedTime >= 30) {
+ VERIFY_SUCCESS(TIMEOUT_NO_Z_DETECTED);
+ }
+
+ //Send version request.
+ VERIFY_SUCCESS(m_pZRpcFunctions->DoRPC_Z_VersionRequest());
+
+ //Receive chip id.
+ time(&Start);
+ time(&End);
+ ElapsedTime = End - Start;
+
+ while (ElapsedTime < 30) {
+ uchReceivedByte = m_pZRpcFunctions->Z_IndataBuffer->Pop(&bEmptyBuffer);
+
+ if (bEmptyBuffer == false) {
+ rguchReceivedChipId[iCount++] = uchReceivedByte;
+
+ if (iCount == 8) {
+ break;
+ }
+ }
+
+ time(&End);
+ ElapsedTime = End - Start;
+
+ OS::Sleep(2);
+ }
+
+ if (ElapsedTime >= 30) {
+ VERIFY_SUCCESS(TIMEOUT_NO_CHIP_ID_DETECTED);
+ }
+
+ //Copy chip ID byte 1 and 2
+ *puiChipId = rguchReceivedChipId[0] << 8; //Major byte
+ *puiChipId += rguchReceivedChipId[1]; //Minor byte
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// Set communication baudrate when communicating via UART.
+/// </summary>
+/// <param name="iBaudrate">Baudrate to use. Valid values: 9600, 19200, 38400, 57600, 115200,
+/// 230400, 460800, 921600, 1625000.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_Z_SetBaudrate(int iBaudrate)
+{
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+ VERIFY_SUCCESS(m_pZRpcFunctions->DoRPC_Z_SetBaudrate(iBaudrate));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// Exit Z-protocol and start uing PROTROM-protocol.
+/// </summary>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_Z_Exit_Z_Protocol()
+{
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ m_pCommunicationDevice->Cancel(m_pLcmInterface->getLCMContext());
+
+ //Send exit z-protocol command.
+ VERIFY_SUCCESS(m_pZRpcFunctions->DoRPC_Z_Exit_Z_Protocol());
+
+ //Change protocol family to PROTROM
+ VERIFY_SUCCESS(Do_SwitchProtocolFamily(PROTROM_PROTOCOL_FAMILY));
+
+ //Receive PROTROM command PDU: PROTROM_PDU_READY_TO_RECEIVE.
+ VERIFY_SUCCESS(WaitForPROTROMResponseOrCancelOrTimeout(PROTROM_PDU_READY_TO_RECEIVE));
+
+ //Send PROTROOM command PDU:PROTROM_PDU_RESULT.
+ VERIFY_SUCCESS(m_pProtromRpcFunctions->DoRPC_PROTROM_ResultPdu(0));
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// Download loader using PROTROM-protocol.
+/// </summary>
+/// <param name="pchPath">Path to loader on PC.</param>
+/// <param name="iPLOffset">Offset in header to payload length.</param>
+/// <param name="iHLOffset">Offset in header to header length.</param>
+/// <param name="iContinueProtRom">1 -> continue use PROTROM-protocol after download the loader. O -> not use PROTROM-protocol after download the loader.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::Do_PROTROM_DownloadLoader(const char *pchPath, int iPLOffset, int iHLOffset, int iContinueProtRom)
+{
+ int ReturnValue = E_SUCCESS;
+
+ MemMappedFile loaderFile;
+ uint8 *loaderData;
+ const void *temp;
+ uint32 HL; //Header length.
+ uint32 HL_Real; //Header length + 32 bit alignment padding
+ uint32 PL; //Payload length.
+ const uint32 PacketSize = 64000;
+ size_t NumberOfPackets;
+ uint32 PayloadOffset;
+ uint32 LeftToSend;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ VERIFY_SUCCESS(loaderFile.LoadFileData(pchPath));
+ /* coverity[tainted_data_return] */
+ loaderData = loaderFile.AllocateFileData(0, loaderFile.GetFileSize());
+ VERIFY(0 != loaderData, loaderFile.GetError());
+
+ //Get header length.
+ temp = loaderData + iHLOffset;
+ HL = m_pSerialization->get_uint32_le(&temp);
+ HL_Real = (HL + 3) & ~3; //Pad to 4 byte (32 bit) alignments
+
+ //Get payload length.
+ temp = loaderData + iPLOffset;
+ PL = m_pSerialization->get_uint32_le(&temp);
+
+ VERIFY_SUCCESS(m_pProtromRpcFunctions->DoRPC_PROTROM_SendLoaderHeader(loaderData, HL_Real));
+
+ //Receive PROTROM command PDU: PROTROM_PDU_RESULT.
+ VERIFY_SUCCESS(WaitForPROTROMResponseOrCancelOrTimeout(PROTROM_PDU_RESULT));
+
+ //Download all packet beside one
+ NumberOfPackets = PL / PacketSize;
+
+ if (NumberOfPackets *PacketSize == PL) {
+ NumberOfPackets--;
+ }
+
+ PayloadOffset = HL_Real;
+
+ if (NumberOfPackets > 0) {
+ for (size_t i = 0; i < NumberOfPackets; ++i) {
+ VERIFY_SUCCESS(m_pProtromRpcFunctions->DoRPC_PROTROM_SendLoaderPayload(loaderData + PayloadOffset, PacketSize));
+ PayloadOffset += PacketSize;
+
+ //Receive PROTROM command PDU: PROTROM_PDU_RESULT.
+ VERIFY_SUCCESS(WaitForPROTROMResponseOrCancelOrTimeout(PROTROM_PDU_RESULT));
+ }
+ }
+
+ if (!iContinueProtRom) {
+ m_pProtromRpcFunctions->CancelDeviceOnResult(m_pCommunicationDevice);
+ m_pLcmInterface->CommunicationCancelReceiver(2);
+ }
+
+ //Send last payload package
+ LeftToSend = PL - PayloadOffset + HL_Real;
+
+ VERIFY_SUCCESS(m_pProtromRpcFunctions->DoRPC_PROTROM_SendLoaderFinalPayload(loaderData + PayloadOffset, LeftToSend));
+
+ loaderFile.ReleaseFileData(loaderData, 0, loaderFile.GetFileSize());
+
+ //If downloaded loader continues to use PROTROM protocol.
+ if (0 != iContinueProtRom) {
+ //Receive PROTROM command PDU: PROTROM_PDU_RESULT.
+ VERIFY_SUCCESS(WaitForPROTROMResponseOrCancelOrTimeout(PROTROM_PDU_RESULT));
+
+ //Receive PROTROM command PDU: PROTROM_PDU_READY_TO_RECEIVE.
+ VERIFY_SUCCESS(WaitForPROTROMResponseOrCancelOrTimeout(PROTROM_PDU_READY_TO_RECEIVE));
+
+ //Send result pdu.
+ VERIFY_SUCCESS(m_pProtromRpcFunctions->DoRPC_PROTROM_ResultPdu(0));
+ } else {
+ VERIFY_SUCCESS(WaitForPROTROMResponseOrCancelOrTimeout(PROTROM_PDU_RESULT));
+ }
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/// <summary>
+/// Send intrinsic request to read security data using PROTROM-protocol.
+/// </summary>
+/// <param name="uiSecDataId">ID of the security data to be read with the intrinsic request.</param>
+/// <param name="puchDataBuffer">Buffer where the read data will be stored.</param>
+/// <param name="piDataLength">IN: Length of DataBuffer; OUT: Read data length.</param>
+/// <returns>Status of the command.</returns>
+int CLCDriverMethods::Do_PROTROM_ReadSecurityData(uint8 uiSecDataId, unsigned char *puchDataBuffer, int *piDataLength)
+{
+ int ReturnValue = E_SUCCESS;
+
+ VERIFY_SUCCESS(IsMainThreadAlive());
+
+ VERIFY_SUCCESS(m_pProtromRpcFunctions->DoRPC_PROTROM_ReadSecurityData(uiSecDataId));
+
+ //Receive PROTROM command PDU: PROTROM_PDU_RESULT.
+ VERIFY_SUCCESS(WaitForPROTROMResponseOrCancelOrTimeout(PROTROM_PDU_SECURITY_DATA_RES));
+
+ CopyVectorToArray(m_pCmdResult->ProtromPayloadData, puchDataBuffer, piDataLength);
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ *piDataLength = 0;
+ }
+
+ return ReturnValue;
+}
+
+int CLCDriverMethods::SetInitialProtocolFamily(TFamily family)
+{
+ switch (family) {
+ case R15_PROTOCOL_FAMILY:
+ m_CurrentProtocolFamily = R15_FAMILY;
+ m_CurrentCEHCallback = CEHCallbackFunction;
+ break;
+ case PROTROM_PROTOCOL_FAMILY:
+ m_CurrentProtocolFamily = PROTROM_FAMILY;
+ m_CurrentCEHCallback = CEH_PROTROM_CallbackFunction;
+ break;
+ case Z_PROTOCOL_FAMILY:
+ m_CurrentProtocolFamily = Z_FAMILY;
+ m_CurrentCEHCallback = CEH_Z_CallbackFunction;
+ break;
+ case A2_PROTOCOL_FAMILY:
+ m_CurrentProtocolFamily = A2_FAMILY;
+ m_CurrentCEHCallback = CEH_A2_CallbackFunction;
+ break;
+ default:
+ return INVALID_INPUT_PARAMETERS;
+ }
+
+ return 0;
+}
+
+void CLCDriverMethods::ConfigureCommunicationDevice(void *Read_fn, void *Write_fn, void *Cancel_fn)
+{
+ m_pCommunicationDevice->Read = reinterpret_cast<DeviceRead_fn>(Read_fn);
+ m_pCommunicationDevice->Write = reinterpret_cast<DeviceWrite_fn>(Write_fn);
+ m_pCommunicationDevice->Cancel = reinterpret_cast<DeviceCancel_fn>(Cancel_fn);
+ m_pCommunicationDevice->Context_p = NULL;
+}
+
+void CLCDriverMethods::SetMessageCallback(void *Callback_fn)
+{
+ m_pLogger->setMessageCallback(reinterpret_cast<MessageCallback_t>(Callback_fn));
+}
+
+void CLCDriverMethods::SetProgressCallback(void *Callback_fn)
+{
+ m_ProgressBarUpdate = reinterpret_cast<ProgressBarCallback_t>(Callback_fn);
+}
+
+/// <summary>
+/// Set timeouts used by LCM and LCDriver.
+/// </summary>
+/// <param name="R15_TOs">LCM timeout data.</param>
+/// <param name="LCD_TOs">LCDriver timeout data.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::SetPcTimeouts(TR15Timeouts *R15_TOs, TLCDriverTimeouts *LCD_TOs)
+{
+ CLockCS TimeoutLock(m_SetTimeoutCS);
+
+ // if null, default values are used
+ if (LCD_TOs != NULL) {
+ m_Timeouts.uiRTO = LCD_TOs->uiRTO;
+ m_Timeouts.uiSTO = LCD_TOs->uiSTO;
+ }
+
+ if (m_CurrentProtocolFamily == R15_FAMILY) {
+ LcmR15Timeouts timeouts;
+ timeouts.TCACK = R15_TOs->TCACK;
+ timeouts.TBCR = R15_TOs->TBCR;
+ timeouts.TBDR = R15_TOs->TBDR;
+ return m_pLcmInterface->CommunicationSetProtocolTimeouts(static_cast<void *>(&timeouts));
+ } else {
+ return E_SUCCESS;
+ }
+}
+
+/// <summary>
+/// Get timeouts used by LCM and LCDriver.
+/// </summary>
+/// <param name="R15_TOs">LCM timeout data.</param>
+/// <param name="LCD_TOs">LCDriver timeout data.</param>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::GetPcTimeouts(TR15Timeouts *R15_TOs, TLCDriverTimeouts *LCD_TOs)
+{
+ int ReturnValue = E_SUCCESS;
+ LCD_TOs->uiRTO = m_Timeouts.uiRTO;
+ LCD_TOs->uiSTO = m_Timeouts.uiSTO;
+
+ if (m_CurrentProtocolFamily == R15_FAMILY) {
+ LcmR15Timeouts timeouts;
+ ReturnValue = m_pLcmInterface->CommunicationGetProtocolTimeouts(static_cast<void *>(&timeouts));
+
+ if (E_SUCCESS == ReturnValue) {
+ R15_TOs->TCACK = timeouts.TCACK;
+ R15_TOs->TBCR = timeouts.TBCR;
+ R15_TOs->TBDR = timeouts.TBDR;
+ R15_TOs->TBES = 0xFFFFFFFF;
+ }
+ } else {
+ R15_TOs->TBCR = 0;
+ R15_TOs->TBDR = 0;
+ R15_TOs->TBES = 0;
+ R15_TOs->TCACK = 0;
+ }
+
+ return ReturnValue;
+}
+
+/// <summary>
+/// Copies a vector to an array.
+/// </summary>
+/// <param name="Source">Source data.</param>
+/// <param name="pDestination">The destination to write data to.</param>
+/// <param name="piSize">Size of data to write.</param>
+/// <returns> Void.</returns>
+template <class T, class U>
+void CLCDriverMethods::CopyVectorToArray(const vector<T>& Source, U *pDestination, int *piSize)
+{
+ size_t copyLength = *piSize;
+
+ if (Source.size() < copyLength) {
+ copyLength = Source.size();
+ }
+
+ for (size_t i = 0; i < copyLength; i++) {
+ pDestination[i] = Source[i];
+ }
+
+ *piSize = static_cast<int>(copyLength);
+}
+
+void CLCDriverMethods::CopyStringToArray(string &Source, char *pDestination, int *piSize)
+{
+ if (Source.size() > static_cast<size_t>(*piSize)) {
+ // erase part of the string that won't fit in the buffer
+ Source.erase(*piSize - 1);
+ }
+
+ strcpy_s(pDestination, *piSize, Source.c_str());
+ *piSize = Source.size();
+}
+
+/// <summary>
+/// Check whether main thread is alive and perform other checks.
+/// </summary>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::IsMainThreadAlive()
+{
+ if (0 != m_pMainThread->ThreadIsDying()) {
+ if (m_pMainThread->ThreadIsDying() == 2) {
+ return LCDRIVER_THREAD_KILLED_WITH_SIGNAL_DEATH;
+ } else if (m_pMainThread->ThreadIsDying() == 3) {
+ return LCDRIVER_THREAD_KILLED_WITH_CANCEL;
+ } else {
+ return LCDRIVER_THREAD_KILLED;
+ }
+ }
+
+ return 0;
+}
+
+/// <summary>
+/// Wait for General Response from ME.
+/// </summary>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::WaitForEvent(uint32 event, int Group, int Command)
+{
+ int iResult;
+ Event *receivedEvent;
+ CLockCS TimeoutLock(m_SetTimeoutCS);
+
+ m_pLogger->log("WaitForEvent: Entering method. Event = 0x%08x, Timeout = %d", event, m_Timeouts.uiRTO);
+ RemoveResult result = m_EventQueue.RemoveHead(reinterpret_cast<void **>(&receivedEvent), m_Timeouts.uiRTO);
+
+ // always wait for error event
+ event |= EVENT_ERROR;
+
+ if (REMOVE_SUCCESS == result) {
+ switch (receivedEvent->event & event) {
+ case EVENT_GR_RECEIVED:
+ if (receivedEvent->group == Group &&
+ receivedEvent->command == Command) {
+ m_pLogger->log("WaitForEvent: General Response received. Number = %d", receivedEvent->command);
+ iResult = receivedEvent->error;
+ } else {
+ m_pLogger->log("Expected GR command # %d", Command);
+ m_pLogger->log("Expected GR application (group) # %d", Group);
+ m_pLogger->log("Received GR command # %d", receivedEvent->command);
+ m_pLogger->log("Received GR application (group) # %d", receivedEvent->group);
+ iResult = GENERAL_RESPONSE_COMMAND_NUMBER_ERROR;
+ }
+
+ break;
+ case EVENT_CMD_RECEIVED:
+ if ((receivedEvent->group == Group && receivedEvent->command == Command) ||
+ (Group == GROUP_SYSTEM && Command == COMMAND_SYSTEM_AUTHENTICATE)) {
+ m_pLogger->log("WaitForEvent: Expected command received");
+ iResult = 0;
+ } else {
+ m_pLogger->log("WaitForEvent: ERROR Unexpected command received");
+ iResult = COMMAND_NUMBER_ERROR;
+ }
+
+ break;
+ case EVENT_SPEEDFLASH:
+ m_pLogger->log("WaitForEvent: Speedflash request received.");
+ iResult = 0;
+ break;
+ case EVENT_ERROR:
+ iResult = receivedEvent->error;
+ break;
+ default:
+ iResult = UNEXPECTED_EVENT_RECEIVED;
+ break;
+ }
+ } else if (REMOVE_CANCEL == result) {
+ m_pLogger->log("WaitForEvent: Cancel received");
+ iResult = CANCEL_EVENT_RECEIVED;
+ } else if (REMOVE_TIMEOUT == result) {
+ m_pLogger->log("WaitForEvent: Timeout");
+ iResult = TIMEOUT;
+ } else {
+ m_pLogger->log("WaitForEvent: Unknown return value");
+ iResult = UNKNOWN_WAIT_RETURN_VALUE;
+ }
+
+ return iResult;
+}
+
+/// <summary>
+/// Wait for specific Protrom response.
+/// <param name="iReceivePdu">Which PDU to wait for.</param>
+/// </summary>
+/// <returns> Status of the command.</returns>
+int CLCDriverMethods::WaitForPROTROMResponseOrCancelOrTimeout(int iReceivePdu)
+{
+ int iResult;
+ bool Continue = false;
+ TProtromInfo *pInfo = 0;
+ CLockCS TimeoutLock(m_SetTimeoutCS);
+
+ do {
+ Continue = false;
+ m_pLogger->log("WaitForPROTROMResponseOrCancelOrTimeout: WAIT - expected PDU = %d", iReceivePdu);
+
+ RemoveResult result = m_pProtromRpcFunctions->ProtromQueue.RemoveRequest(reinterpret_cast<void **>(&pInfo), m_Timeouts.uiRTO);
+
+ if (REMOVE_SUCCESS == result) {
+ iResult = 0;
+
+ if (pInfo->ReceivedPdu != iReceivePdu) {
+ m_pLogger->log("WaitForPROTROMResponseOrCancelOrTimeout: RECEIVE - unexpected PDU %d", pInfo->ReceivedPdu);
+ Continue = true;
+ } else if (iReceivePdu == PROTROM_PDU_RESULT) {
+ //Check result from PDU_RESULT
+ if (pInfo->Status != 0) {
+ iResult = PROTROM_STATUS_NOT_OK;
+ }
+ }
+
+ delete[](uint8 *)pInfo->DataP;
+ delete pInfo;
+ } else if (REMOVE_CANCEL == result) {
+ m_pLogger->log("WaitForPROTROMResponseOrCancelOrTimeout: CANCEL");
+ iResult = CANCEL_EVENT_RECEIVED;
+ } else if (REMOVE_TIMEOUT == result) {
+ m_pLogger->log("WaitForPROTROMResponseOrCancelOrTimeout: TIMEOUT");
+ iResult = TIMEOUT;
+ } else {
+ m_pLogger->log("WaitForPROTROMResponseOrCancelOrTimeout: UNKNOWN");
+ iResult = UNKNOWN_WAIT_RETURN_VALUE;
+ }
+ } while (Continue);
+
+ return iResult;
+}
+
+void CLCDriverMethods::Do_BulkDataReqCallback(uint16 *Session_p, uint32 *ChunkSize_p, uint64 *Offset_p, uint32 *Length_p, uint64 *TotalLength_p, uint32 *TransferredLength_p)
+{
+ m_uiBulkTransferred += *ChunkSize_p;
+}
+
+void CLCDriverMethods::UpdateBulkProgress()
+{
+ if (NULL != m_ProgressBarUpdate) {
+ m_ProgressBarUpdate(m_pLcmInterface->getLCMContext(), m_uiBulkLength, m_uiBulkTransferred);
+ }
+}
+
+void CLCDriverMethods::Do_BulkDataEndOfDumpCallback()
+{
+#ifdef _BULKDEBUG
+ m_pLogger->log("BULK: END OF DUMP CALLBACK RECEIVED!");
+#endif
+}
+
+int CLCDriverMethods::MapLcmError(int error)
+{
+ switch (error) {
+ case E_RETRANSMITION_FAILED:
+ return LCM_RETRANSMISSION_ERROR;
+ case E_GENERAL_COMMUNICATION_ERROR:
+ return LCM_DEVICE_WRITE_ERROR;
+ default:
+ return error;
+ }
+}
+
+void CLCDriverMethods::SignalError(int error)
+{
+ Event *event = new Event(EVENT_ERROR, error);
+ m_EventQueue.AddTail(event);
+}
+
+void CLCDriverMethods::AddEvent(Event *newEvent)
+{
+ m_EventQueue.AddTail(newEvent);
+}
diff --git a/source/LCDriverMethods.h b/source/LCDriverMethods.h
new file mode 100644
index 0000000..7e048be
--- /dev/null
+++ b/source/LCDriverMethods.h
@@ -0,0 +1,265 @@
+/*******************************************************************************
+*
+* File name: LCDriverMethods.h
+* Project: LCDriver
+* Language: Visual C++
+* Description: Implementation of all exported methods.
+*
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*******************************************************************************/
+
+#ifndef _LCDRIVERMETHODS_H_
+#define _LCDRIVERMETHODS_H_
+
+#include "Buffers.h"
+#include "Queue.h"
+#include "Timer.h"
+#include "Hash.h"
+#include "Serialization.h"
+#include "Logger.h"
+#include "CmdResult.h"
+#include "LCDriverThread.h"
+#include "BulkHandler.h"
+#include "Event.h"
+
+class LcmInterface;
+class ZRpcInterface;
+class ProtromRpcInterface;
+class LoaderRpcInterfaceImpl;
+class A2LoaderRpcInterfaceImpl;
+
+typedef void (*ProgressBarCallback_t)(void *Communication_p, uint64 TotalLength, uint64 TransferredLength);
+
+/// <summary>
+/// Implementation class.
+/// </summary>
+class CLCDriverMethods
+{
+ friend class CLCDriverThread;
+public:
+ CLCDriverMethods(const char *pchInterfaceId);
+ virtual ~CLCDriverMethods();
+
+ int Do_Initialize(void **ppInstance);
+
+ int SetInitialProtocolFamily(TFamily family);
+ void ConfigureCommunicationDevice(void *Read_fn, void *Write_fn, void *Cancel_fn);
+ void SetMessageCallback(void *Callback_fn);
+ void SetProgressCallback(void *Callback_fn);
+
+ int SetPcTimeouts(TR15Timeouts *R15_TOs, TLCDriverTimeouts *LCD_TOs);
+ int GetPcTimeouts(TR15Timeouts *R15_TOs, TLCDriverTimeouts *LCD_TOs);
+
+ void CancelCurrentLoaderCommand();
+
+ // Loader methods
+ int Done_System_LoaderStartupStatus(char *pchVersion, int *piVersionSize, char *pchProtocol, int *piProtocolSize);
+ int Do_System_Reboot(int iMode);
+ int Do_System_Shutdown();
+ int Do_System_SupportedCommands(TSupportedCmd *pCmdList, int *piCmdListSize);
+ int Do_System_CollectData(int iType, int *piSize, char *pData);
+ int Do_System_ExecuteSoftware(const uint32 ExecuteMode,const char *pchDevicePath, int iUseBulk);
+ int Do_System_Authenticate(int iType, int *piSize, unsigned char *puchdata);
+ int Done_System_GetControlKeys(TSIMLockKeys *pSIMLockKeys);
+ int Done_System_GetControlKeysData(int iDataSize, unsigned char *pSIMLockKeysData);
+ int Done_System_AuthenticationChallenge(int iDataSize, unsigned char *puchChallengeData);
+ int Do_System_SetSystemTime(uint32 EpochTime);
+ int Do_System_SwitchCommunicationDevice(uint32 Device, uint32 DeviceParam);
+
+ int Do_Flash_ProcessFile(const char *pchPath, const char *pchType, int iUseBulk, int iDeleteBuffers);
+ int Do_Flash_ListDevices(TDevices *pDevices, int *piDeviceSize);
+ int Do_Flash_DumpArea(const char *pchPathToDump, uint64 uiStart, uint64 uiLength, const char *pchFilePath, uint32 RedundantArea, int iUseBulk);
+ int Do_Flash_EraseArea(const char *pchPath, uint64 uiStart, uint64 uiLength);
+ int Do_Flash_FlashRaw(const char *pchPath, uint64 uiStart, uint64 uiLength, uint32 uiDevice, int iUseBulk, int iDeleteBuffers);
+
+ int Do_FileSystem_VolumeProperties(const char *pchDevicePath, char *pchFSType, int *piFSTypeSize, uint64 *puiSize, uint64 *puiFree);
+ int Do_FileSystem_FormatVolume(const char *pchDevicePath);
+ int Do_FileSystem_ListDirectory(const char *pchPath, TEntries *pEntries, int *DeviceSize);
+ int Do_FileSystem_MoveFile(const char *pchSourcePath, const char *pchDestinationPath);
+ int Do_FileSystem_DeleteFile(const char *pchTargetPath);
+ int Do_FileSystem_CopyFile(const char *pchSourcePath, int iSourceUseBulk, const char *pchDestinationPath, int iDestinationUseBulk);
+ int Do_FileSystem_CreateDirectory(const char *pchTargetPath);
+ int Do_FileSystem_Properties(const char *pchTargetPath, uint32 *puiMode, uint64 *puiSize, int *piMTime, int *piATime, int *piCTime);
+ int Do_FileSystem_ChangeAccess(const char *pchTargetPath, int iAccess);
+ int Do_FileSystem_ReadLoadModuleManifests(const char *pchTargetPath, const char *pchSourcePath);
+
+ int Do_OTP_ReadBits(int iOtpId, int iBitStart, int iBitLength, unsigned char *puchDataBuffer, int *piDataBufferSize , unsigned char *puchStatusBuffer, int *piStatusBufferSize);
+ int Do_OTP_SetBits(int iOtpId, int iBitStart, int iBitLength, unsigned char *puchDataBuffer);
+ int Do_OTP_WriteAndLock(int iOtpId, int iForceWrite);
+ int Do_OTP_StoreSecureObject(const char *pchSourcePath, int iDestination, int iUseBulk);
+
+ int Do_ParameterStorage_ReadGlobalDataUnit(const char *pchGdfsId, int iUnit, unsigned char *puchDataBuffer, int *piSize);
+ int Do_ParameterStorage_WriteGlobalDataUnit(const char *pchGdfsId, int iUnit, const unsigned char *puchDataBuffer, int iSize);
+ int Do_ParameterStorage_ReadGlobalDataSet(const char *pchGdfsId, const char *pchPath, int iUseBulk);
+ int Do_ParameterStorage_WriteGlobalDataSet(const char *pchGdfsId, const char *pchPath, int iUseBulk);
+ int Do_ParameterStorage_EraseGlobalDataSet(const char *pchGdfsId);
+
+ int Do_Security_SetDomain(int iDomain);
+ int Do_Security_GetDomain(int *piWrittenDomain);
+ int Do_Security_GetProperties(int iUnitId, int *piSize, unsigned char *puchDataBuffer);
+ int Do_Security_SetProperties(int iUnitId, int iSize, const unsigned char *puchDataBuffer);
+ int Do_Security_BindProperties();
+
+ // A2 Protocol Methods
+ int Do_A2_System_Shutdown();
+ int Do_A2_System_LoaderVersion(char *pchLoaderVersion, int *piSize, int iTargetCPU);
+ int Do_A2_System_LoaderOnLoader(const char *pchPath, int iPLOffset, int iHLOffset, int iTargetCPU);
+ int Do_A2_System_Reset(int iTimeout);
+
+ int Do_A2_Flash_ProgramFlash(const char *pchPath, int iUseSpeedFlash);
+ int Do_A2_Flash_EraseFlash();
+
+ int Done_A2_Control_LoaderStarted();
+
+ // Z Protocol Methods
+ int Do_Z_SetInServiceMode(unsigned int *puiChipId);
+ int Do_Z_SetBaudrate(int iBaudrate);
+ int Do_Z_Exit_Z_Protocol();
+
+ // PROTROM Protocol Methods
+ int Do_PROTROM_DownloadLoader(const char *pchPath, int iPLOffset, int iHLOffset, int iContinueProtRom);
+ int Do_PROTROM_ReadSecurityData(uint8 uiSecDataId, unsigned char *puchDataBuffer, int *piDataLength);
+
+ int Do_SwitchProtocolFamily(TFamily family);
+
+private:
+ // Members
+ Buffers *m_pBuffers;
+ Queue *m_pQueue;
+ Timer *m_pTimer;
+ Hash *m_pHash;
+ Serialization *m_pSerialization;
+ Logger *m_pLogger;
+ BulkHandler *m_pBulkHandler;
+
+
+ HashDevice_t *m_pHashDevice;
+ CommunicationDevice_t *m_pCommunicationDevice;
+
+ // Utility setup methods
+ ErrorCode_e SetupTimers(TimersInterface_t *pTimerFunctions);
+ ErrorCode_e SetupBuffers(BuffersInterface_t *pBufferFunctions);
+ ErrorCode_e SetupQueues(QueueInterface_t *pQueueFunctions);
+ ErrorCode_e SetupHash();
+
+ CmdResult *m_pCmdResult;
+ LcmInterface *m_pLcmInterface;
+ ZRpcInterface *m_pZRpcFunctions;
+ ProtromRpcInterface *m_pProtromRpcFunctions;
+ LoaderRpcInterfaceImpl *m_pLoaderRpcFunctions;
+ A2LoaderRpcInterfaceImpl *m_pA2LoaderRpcFunctions;
+ CLCDriverThread *m_pMainThread;
+
+ //------------------------------------------
+ // Static methods for support modules: timers, hash, buffers and queue
+ //------------------------------------------
+public:
+ static ErrorCode_e TimerInit(void *pObject, uint32 uiTimers);
+ static uint32 TimerGet(void *pObject, Timer_t *pTimer);
+ static ErrorCode_e TimerRelease(void *pObject, uint32 uiTimerKey);
+ static uint32 TimerReadTime(void *pObject, uint32 uiTimerKey);
+ static uint32 TimerGetSystemTime(void *pObject);
+
+ static void HashCancel(void *pObject, void **ppHashDevice);
+ static void HashCalculate(void *pObject, HashType_e Type, void *pData, const uint32 uiLength, uint8 *pHash, HashCallback_fn fnCallback, void *pParam);
+ static uint32 HashGetLength(void *pObject, HashType_e Type);
+
+ static ErrorCode_e BuffersInit(void *pObject);
+ static void *BufferAllocate(void *pObject, int iBufferSize);
+ static ErrorCode_e BufferRelease(void *pObject, void *pBuffer, int iBufferSize);
+ static uint32 BuffersAvailable(void *pObject, int iBufferSize);
+ static void BuffersDeinit(void *pObject);
+
+ static void QueueCreate(void *pObject, void **const ppQueue, const uint32 uiMaxLength, void (*pDestroyElement)(void *pElement));
+ static void QueueDestroy(void *pObject, void **const ppQueue);
+ static ErrorCode_e QueueEnqueue(void *pObject, void *const ppQueue, void *const pValue);
+ static void *QueueDequeue(void *pObject, void *const ppQueue);
+ static QueueCallback_fn QueueSetCallback(void *pObject, void *const pQueue, const QueueCallbackType_e Type, const QueueCallback_fn fnCallback, void *const pParam);
+ static boolean QueueIsEmpty(void *pObject, const void *const pQueue);
+ static boolean QueueIsMember(void *pObject, const void *const pQueue, void *pValue, boolean(*Match)(void *pValue1, void *pValue2));
+ static int QueueGetNrOfElements(void *pObject, const void *const pQueue);
+ static void RQueueCreate(void *pObject, void **const ppQueue, const uint32 uiMaxLength, void (*pDestroyElement)(void *pElement));
+ static void RQueueDestroy(void *pObject, void **const ppQueue);
+ static ErrorCode_e RQueueEnqueue(void *pObject, void *const pQueue, void *const pValue);
+ static void *RQueueDequeue(void *pObject, void *const pQueue);
+ static QueueCallback_fn RQueueSetCallback(void *pObject, void *const pQueue, const QueueCallbackType_e Type, const QueueCallback_fn fnCallback, void *const pParam);
+ static boolean RQueueIsEmpty(void *pObject, const void *const pQueue);
+ static boolean RQueueIsMember(void *pObject, const void *const pQueue, void *pValue, boolean(*Match)(void *pValue1, void *pValue2));
+ static int RQueueGetNrOfElements(void *pObject, const void *const pQueue);
+
+ //-----------------------------------------
+ // Command Execution Handler callbacks
+ //-----------------------------------------
+ static ErrorCode_e CEHCallbackFunction(void *pObject, CommandData_t *pCmdData);
+ static ErrorCode_e CEH_PROTROM_CallbackFunction(void *pObject, CommandData_t *pCmdData);
+ static ErrorCode_e CEH_Z_CallbackFunction(void *pObject, CommandData_t *pCmdData);
+ static ErrorCode_e CEH_A2_CallbackFunction(void *pObject, CommandData_t *pCmdData);
+
+ //-----------------------------------------
+ // Bulk Transfer Protocol callbacks
+ //-----------------------------------------
+ static void BulkCommandReqCallback(void *pObject, uint16 *puiSession, uint32 *puiChunkSize, uint64 *puiOffset, uint32 *puiLength, boolean bAckRead);
+ void Do_BulkCommandReqCallback(uint16 *puiSession, uint32 *puiChunkSize, uint64 *puiOffset, uint32 *puiLength);
+
+ static void BulkDataReqCallback(void *pObject, uint16 *puiSession, uint32 *puiChunkSize, uint64 *puiOffset, uint32 *puiLength, uint64 *puiTotalLength, uint32 *puiTransferedLength);
+ void Do_BulkDataReqCallback(uint16 *puiSession, uint32 *puiChunkSize, uint64 *puiOffset, uint32 *puiLength, uint64 *puiTotalLength, uint32 *puiTransferedLength);
+
+ static void BulkDataEndOfDumpCallback(void *pObject);
+ void Do_BulkDataEndOfDumpCallback();
+
+ int MapLcmError(int error);
+
+ void SignalError(int error);
+ void AddEvent(Event *event);
+
+ //-----------------------------------------
+ // Other callbacks
+ //-----------------------------------------
+ ProgressBarCallback_t m_ProgressBarUpdate;
+ void UpdateBulkProgress();
+ //-----------------------------------------
+
+private:
+ char *m_pchId;
+
+ static const char *const BULK_PATH;
+ uint64 m_uiBulkLength;
+ uint64 m_uiBulkTransferred;
+
+ CSemaphoreQueue m_EventQueue;
+ CCriticalSectionObject m_GetNextCodeCS;
+
+ CCriticalSectionObject m_SetTimeoutCS;
+ TLCDriverTimeouts m_Timeouts;
+
+ //-----------------------------------------
+ // String and vector copy functions.
+ //-----------------------------------------
+ template<class T, class U>
+ void CopyVectorToArray(const std::vector<T>& Source, U *pDestination, int *piSize);
+
+ void CopyStringToArray(std::string &Source, char *pDestination, int *piSize);
+
+ //-----------------------------------------
+ // Wait functions
+ //-----------------------------------------
+ int WaitForEvent(uint32 event, int Group = 0, int Command = 0);
+ int WaitForPROTROMResponseOrCancelOrTimeout(int iReceivePdu);
+
+ //-----------------------------------------
+ // State variables
+ //-----------------------------------------
+ Family_t m_CurrentProtocolFamily;
+ Do_CEH_Call_t m_CurrentCEHCallback;
+ int m_iBulkProtocolMode;
+
+ //-----------------------------------------
+ // General functions
+ //-----------------------------------------
+ int IsMainThreadAlive();
+};
+
+#endif // _LCDRIVERMETHODS_H_
diff --git a/source/LCDriverThread.cpp b/source/LCDriverThread.cpp
new file mode 100644
index 0000000..4b492ad
--- /dev/null
+++ b/source/LCDriverThread.cpp
@@ -0,0 +1,84 @@
+/*******************************************************************************
+*
+* File name: LCDriverThread.cpp
+* Language: Visual C++
+* Description: Main loop for LCDriver
+*
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*******************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// File LCDriverThread.cpp
+
+#include "LCDriverThread.h"
+#include "LCDriverMethods.h"
+#include "lcdriver_error_codes.h"
+#include "Event.h"
+#ifdef _WIN32
+#include "WinApiWrappers.h"
+#endif
+
+CLCDriverThread::CLCDriverThread(CLCDriverMethods *lcdriverMethods):
+ lcdriverMethods_(lcdriverMethods),
+ timerOn_(false),
+ shutdown_(false)
+{
+}
+
+void CLCDriverThread::MainExecutionLoop()
+{
+ while (!shutdown_) {
+ // Limit the scope of the lock to avoid holding lock while sleeping. This
+ // solves the problem with starvation of other threads trying to lock LCMPollCS.
+ {
+ CLockCS lock(LCMPollCS);
+ lcdriverMethods_->m_pTimer->DoTimerHandler(timerOn_);
+
+ ErrorCode_e ReturnValue = lcdriverMethods_->m_pLcmInterface->CommunicationPoll();
+
+ if (E_SUCCESS != ReturnValue) {
+#ifdef _THREADDEBUG
+ lcdriverMethods_->m_pLogger->log("LCD MainThread: LCM polling ERROR = %d", ReturnValue);
+#endif
+
+ if (R15_FAMILY == lcdriverMethods_->m_CurrentProtocolFamily) {
+ lcdriverMethods_->SignalError(lcdriverMethods_->MapLcmError(ReturnValue));
+ IsDying = LCDRIVER_THREAD_STOPPED_AFTER_LCM_ERROR;
+ break;
+ }
+ }
+ }
+
+ OS::Sleep(1);
+ }
+}
+
+void CLCDriverThread::SignalDeath()
+{
+ CLockCS lock(LCMPollCS);
+ shutdown_ = true;
+}
+
+void CLCDriverThread::TimerOn()
+{
+ CLockCS lock(LCMPollCS);
+ timerOn_ = true;
+}
+
+void CLCDriverThread::TimerOff()
+{
+ CLockCS lock(LCMPollCS);
+ timerOn_ = false;
+}
+
+ErrorCode_e CLCDriverThread::SetLcmFamily(Family_t family, Do_CEH_Call_t CEHCallback)
+{
+ CLockCS lock(LCMPollCS);
+ return lcdriverMethods_->m_pLcmInterface->CommunicationSetFamily(family, CEHCallback);
+}
+
+// End of file LCDriverThread.cpp
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/LCDriverThread.h b/source/LCDriverThread.h
new file mode 100644
index 0000000..3bb2e73
--- /dev/null
+++ b/source/LCDriverThread.h
@@ -0,0 +1,55 @@
+/*******************************************************************************
+*
+* File name: LCDriverThread.h
+* Language: Visual C++
+* Description: Active Thread Object class declarations
+*
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*******************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// File LCDriverThread.h
+
+#ifndef _LCDRIVERTHREAD_H_
+#define _LCDRIVERTHREAD_H_
+
+#include "CaptiveThreadObject.h"
+#include "Timer.h"
+#include "Logger.h"
+#include "t_communication_service.h"
+
+class CLCDriverMethods;
+
+class CLCDriverThread: public CCaptiveThreadObject
+{
+public:
+ CLCDriverThread(CLCDriverMethods *lcdriverMethods);
+
+ void ResumeThread() {
+ Thread.ResumeThread();
+ }
+
+ ErrorCode_e SetLcmFamily(Family_t family, Do_CEH_Call_t CEHCallback);
+
+ void TimerOn();
+ void TimerOff();
+private:
+ void InitializeCaptiveThreadObject() {}
+ void MainExecutionLoop();
+ void SignalDeath();
+private:
+ CLCDriverMethods *lcdriverMethods_;
+
+ bool timerOn_;
+ bool shutdown_;
+
+ CCriticalSectionObject LCMPollCS;
+};
+
+#endif // _LCDRIVERTHREAD_H_
+
+// End of file LCDriverThread.h
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/LCM/Buffers.cpp b/source/LCM/Buffers.cpp
new file mode 100644
index 0000000..6e513bf
--- /dev/null
+++ b/source/LCM/Buffers.cpp
@@ -0,0 +1,264 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+/*
+ * \addtogroup ldr_communication_buffer
+ * @{
+ */
+
+/***********************************************************************
+ * Includes
+ **********************************************************************/
+#include "Buffers.h"
+#include "lcdriver_error_codes.h"
+#include "t_r15_network_layer.h"
+#include "Error.h"
+#include <cstdlib>
+using namespace std;
+
+vector<TBulkFile *> Buffers::m_BulkFiles;
+CCriticalSectionObject Buffers::csBulkFiles;
+const uint32 Buffers::MAX_BUFFERS_COUNT = 32;
+
+#define MAX_BUFFER_SIZE BULK_BUFFER_SIZE
+
+TBulkVector::TBulkVector():
+ HeaderBuffer_p(NULL),
+ Data_p(NULL),
+ Offset(0),
+ Length(0),
+ ChunkSize(0)
+{
+}
+
+TBulkVector::~TBulkVector()
+{
+ delete[] HeaderBuffer_p;
+}
+
+TBulkFile::TBulkFile(): refCount(1)
+{
+ iAllSessionsCompleted = 0;
+ pMemMappedFile = 0;
+}
+
+TBulkFile::~TBulkFile()
+{
+ delete pMemMappedFile;
+
+ for (vector<TBulkVector *>::iterator i = bulkVectors.begin(); i != bulkVectors.end(); ++i) {
+ delete *i;
+ }
+}
+
+Buffers::Buffers():
+ buffersCount_(0),
+ logger_(0)
+{
+ m_BulkFile = 0;
+}
+
+Buffers::~Buffers()
+{
+ Deinit();
+}
+
+/***********************************************************************
+ * Definition of internal functions
+ **********************************************************************/
+ErrorCode_e Buffers::Init()
+{
+ return E_SUCCESS;
+}
+
+void *Buffers::Allocate(int Size)
+{
+ void *Buffer_p = 0;
+
+ if (buffersCount_ < MAX_BUFFERS_COUNT) {
+ Buffer_p = static_cast<uint8 *>(new uint8[Size]);
+ ++buffersCount_;
+#ifdef _BUFFERDEBUG
+ PrintF("Buffers: Allocate - Buffer 0x%p", Buffer_p);
+#endif
+ } else {
+#ifdef _BUFFERDEBUG
+ PrintF("Buffers: Allocate - Failed, Count %u", (void *)buffersCount_);
+#endif
+ }
+
+ return Buffer_p;
+}
+
+ErrorCode_e Buffers::Release(void *Buffer_p, int Size)
+{
+#ifdef _BUFFERDEBUG
+ PrintF("Buffers: Release - Buffer 0x%p", Buffer_p);
+#endif
+ delete[] static_cast<uint8 *>(Buffer_p);
+ --buffersCount_;
+ return E_SUCCESS;
+}
+
+uint32 Buffers::Available(int BufferSize)
+{
+#ifdef _BUFFERDEBUG
+ PrintF("Buffers: Available - Available %d", (void *)(MAX_BUFFERS_COUNT - buffersCount_));
+#endif
+ return MAX_BUFFERS_COUNT - buffersCount_;
+}
+
+void Buffers::Deinit()
+{
+#ifdef _BUFFERDEBUG
+
+ if (buffersCount_) {
+ PrintF("Buffers: Deinit - Buffers still allocated %d", (void *)buffersCount_);
+ }
+
+#endif
+}
+
+int Buffers::AllocateBulkFile(string strFile)
+{
+ CLockCS CsLock(csBulkFiles);
+
+ for (vector<TBulkFile *>::iterator i = m_BulkFiles.begin(); i != m_BulkFiles.end(); ++i) {
+ if (strFile.compare((*i)->strFileName) == 0) {
+ m_BulkFile = *i;
+ ++m_BulkFile->refCount;
+ return E_SUCCESS;
+ }
+ }
+
+ TBulkFile *newFile = new TBulkFile;
+ newFile->strFileName = strFile;
+
+ MemMappedFile *file = new MemMappedFile;
+#ifdef _BUFFERDEBUG
+ PrintF("Buffers: LoadFileData %s", (void *)strFile.c_str());
+#endif
+ int iReturn = file->LoadFileData(strFile.c_str());
+
+ if (iReturn) {
+ delete newFile;
+ delete file;
+ return iReturn;
+ }
+
+ newFile->pMemMappedFile = file;
+
+ m_BulkFiles.push_back(newFile);
+ m_BulkFile = newFile;
+
+ return E_SUCCESS;
+}
+
+uint64 Buffers::GetBulkFileLength()
+{
+ return m_BulkFile->pMemMappedFile->GetFileSize();
+}
+
+int Buffers::AllocateBulkVector(TL_BulkVectorList_t *BulkVector_p, uint32 iChunkSize, uint64 lOffset, uint32 iLength)
+{
+ CLockCS CsLock(m_BulkFile->csBulkVectors);
+ int ReturnValue = E_SUCCESS;
+
+ int HeaderBufferSize = HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH + ALIGNED_BULK_EXTENDED_HEADER_LENGTH;
+ int CurrentHeaderBufferSize = (BulkVector_p->Buffers) * HeaderBufferSize;
+
+ TBulkVector *currentVector = NULL;
+
+ //Check that flash buffers have been initialized.
+ VERIFY(0 != m_BulkFile, BUFFER_BULK_FILE_NOT_ALOCATED);
+
+ currentVector = new TBulkVector();
+ currentVector->HeaderBuffer_p = new uint8[CurrentHeaderBufferSize];
+ currentVector->Data_p = m_BulkFile->pMemMappedFile->AllocateFileData(lOffset, iLength);
+ currentVector->Offset = lOffset;
+ currentVector->Length = iLength;
+ currentVector->ChunkSize = iChunkSize;
+ m_BulkFile->bulkVectors.push_back(currentVector);
+ VERIFY(0 != currentVector->Data_p, m_BulkFile->pMemMappedFile->GetError());
+
+#ifdef _BUFFERDEBUG
+ PrintF("Buffers: AllocateFlashBuffers - Created new bulk vector 0x%p", (void *)currentVector);
+#endif
+
+ for (uint32 i = 0; i < BulkVector_p->Buffers; i++) {
+ uint8 *ChunkHeader_p = currentVector->HeaderBuffer_p + i * HeaderBufferSize;
+ uint8 *ChunkPayload_p = currentVector->Data_p + i * iChunkSize;
+
+ PacketMeta_t *Packet_p = BulkVector_p->Entries[i].Buffer_p;
+ Packet_p->Buffer_p = ChunkHeader_p;
+ Packet_p->ExtendedHeader_p = ChunkHeader_p + (uint64)Packet_p->ExtendedHeader_p;
+ Packet_p->Payload_p = ChunkPayload_p;
+
+ BulkVector_p->Entries[i].Payload_p = ChunkPayload_p;
+ }
+
+ErrorExit:
+
+ if ((0 != currentVector) && (0 == currentVector->Data_p)) {
+ m_BulkFile->bulkVectors.pop_back();
+ delete currentVector;
+ }
+
+ return ReturnValue;
+}
+
+void Buffers::ReleaseBulkVector(TL_BulkVectorList_t *BulkVector_p)
+{
+ CLockCS CsLock(m_BulkFile->csBulkVectors);
+
+ for (vector<TBulkVector *>::iterator i = m_BulkFile->bulkVectors.begin(); i != m_BulkFile->bulkVectors.end(); ++i) {
+ if (BulkVector_p->Offset == (*i)->Offset &&
+ BulkVector_p->Length == (*i)->Length &&
+ BulkVector_p->ChunkSize == (*i)->ChunkSize) {
+ m_BulkFile->pMemMappedFile->ReleaseFileData((*i)->Data_p, (*i)->Offset, (*i)->Length);
+ delete *i;
+ m_BulkFile->bulkVectors.erase(i);
+ break;
+ }
+ }
+}
+
+void Buffers::ReleaseAllBulkFiles()
+{
+ CLockCS CsLock(csBulkFiles);
+
+ for (vector<TBulkFile *>::iterator i = m_BulkFiles.begin(); i != m_BulkFiles.end(); ++i) {
+ delete *i;
+ }
+
+ m_BulkFiles.clear();
+}
+
+void Buffers::ReleaseBulkFile()
+{
+ CLockCS CsLock(csBulkFiles);
+
+ if (0 == m_BulkFile || --m_BulkFile->refCount > 0) {
+ return;
+ }
+
+ // remove bulk file from static list
+ for (vector<TBulkFile *>::iterator i = m_BulkFiles.begin(); i != m_BulkFiles.end(); ++i) {
+ if (m_BulkFile == *i) {
+ m_BulkFiles.erase(i);
+ break;
+ }
+ }
+
+ delete m_BulkFile;
+ m_BulkFile = 0;
+}
+
+void Buffers::PrintF(const char *text, void *pVoid)
+{
+ if (NULL != logger_) {
+ logger_->log(text, pVoid);
+ }
+}
diff --git a/source/LCM/Buffers.h b/source/LCM/Buffers.h
new file mode 100644
index 0000000..2a2f213
--- /dev/null
+++ b/source/LCM/Buffers.h
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _BUFFER_H_
+#define _BUFFER_H_
+
+#include "t_bulk_protocol.h"
+#include "MemMappedFile.h"
+#include "Queue.h"
+#include "Logger.h"
+#ifdef _WIN32
+#include "WinApiWrappers.h"
+#else
+#include "LinuxApiWrappers.h"
+#endif
+
+#include <string>
+#include <vector>
+
+struct TBulkVector {
+ uint8 *HeaderBuffer_p;
+ uint8 *Data_p;
+ uint64 Offset;
+ uint32 Length;
+ uint32 ChunkSize;
+
+ TBulkVector();
+ ~TBulkVector();
+};
+
+struct TBulkFile {
+ TBulkFile();
+ ~TBulkFile();
+
+ std::string strFileName;
+ std::vector<TBulkVector *> bulkVectors;
+ size_t refCount;
+ int iAllSessionsCompleted;
+ MemMappedFile *pMemMappedFile;
+
+ CCriticalSectionObject csBulkVectors;
+};
+
+class Buffers
+{
+public:
+ Buffers();
+ ~Buffers();
+
+ void SetLogger(Logger *logger) {
+ logger_ = logger;
+ }
+private:
+ //Member variables for Bulk Flash.
+ static std::vector<TBulkFile *> m_BulkFiles;
+ static CCriticalSectionObject csBulkFiles;
+ TBulkFile *m_BulkFile;
+public:
+ ErrorCode_e Init();
+ void *Allocate(int Size);
+ ErrorCode_e Release(void *Buffer_p, int Size);
+ uint32 Available(int BufferSize);
+ void Deinit();
+
+ //Functions for Bulk Flash
+ int AllocateBulkFile(std::string strFile);
+ uint64 GetBulkFileLength();
+
+ int AllocateBulkVector(TL_BulkVectorList_t *BulkVector_p, uint32 iChunkSize, uint64 lOffset, uint32 iLength);
+ void ReleaseBulkVector(TL_BulkVectorList_t *BulkVector_p);
+
+ void ReleaseBulkFile();
+ static void ReleaseAllBulkFiles();
+private:
+ uint32 buffersCount_;
+ Logger *logger_;
+ static const uint32 MAX_BUFFERS_COUNT;
+ void PrintF(const char *text, void *pVoid);
+};
+
+#endif // _BUFFER_H_
diff --git a/source/LCM/Hash.cpp b/source/LCM/Hash.cpp
new file mode 100644
index 0000000..4f5962c
--- /dev/null
+++ b/source/LCM/Hash.cpp
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/**
+ * \addtogroup ldr_security_algorithms
+ * @{
+ */
+
+/*************************************************************************
+* Includes
+*************************************************************************/
+#include "Hash.h"
+#include "SecurityAlgorithms.h"
+#include <cstdlib>
+#include <cstring>
+
+/***********************************************************************
+ * Declaration of file local functions
+ **********************************************************************/
+/***********************************************************************
+ * Definition of external functions
+ **********************************************************************/
+const uint32 red[16] = {
+ 0,
+ (0x1 << 16) ^(0x1021 << 0), \
+ (0x2 << 16) ^(0x1021 << 1), \
+ (0x3 << 16) ^(0x1021 << 1) ^(0x1021 << 0), \
+ (0x4 << 16) ^(0x1021 << 2), \
+ (0x5 << 16) ^(0x1021 << 2) ^(0x1021 << 0), \
+ (0x6 << 16) ^(0x1021 << 2) ^(0x1021 << 1), \
+ (0x7 << 16) ^(0x1021 << 2) ^(0x1021 << 1) ^(0x1021 << 0), \
+ (0x8 << 16) ^(0x1021 << 3), \
+ (0x9 << 16) ^(0x1021 << 3) ^(0x1021 << 0), \
+ (0xa << 16) ^(0x1021 << 3) ^(0x1021 << 1), \
+ (0xb << 16) ^(0x1021 << 3) ^(0x1021 << 1) ^(0x1021 << 0), \
+ (0xc << 16) ^(0x1021 << 3) ^(0x1021 << 2), \
+ (0xd << 16) ^(0x1021 << 3) ^(0x1021 << 2) ^(0x1021 << 0), \
+ (0xe << 16) ^(0x1021 << 3) ^(0x1021 << 2) ^(0x1021 << 1), \
+ (0xf << 16) ^(0x1021 << 3) ^(0x1021 << 2) ^(0x1021 << 1) ^(0x1021 << 0)
+};
+
+Hash::Hash()
+{
+ m_RequestQueue = new CSemaphoreQueue(16);
+ m_Thread = new CThreadWrapper(WorkerThread, this);
+ m_Thread->ResumeThread();
+}
+
+Hash::~Hash()
+{
+ m_RequestQueue->SignalEvent();
+ m_Thread->WaitToDie();
+ delete m_Thread;
+ delete m_RequestQueue;
+}
+
+/*
+ * Hash device shutdown.
+ *
+ * @param [in] Object_p Initialized buffer context.
+ * @param [in] HashDevice_pp Pointer to hash device descriptor.
+ *
+ * @return none.
+ */
+void Hash::Cancel(HashDevice_t **HashDevice_pp)
+{
+ delete *HashDevice_pp;
+}
+
+#ifdef _WIN32
+unsigned int WINAPI Hash::WorkerThread(void *arg)
+#else
+void *Hash::WorkerThread(void *arg)
+#endif
+{
+ Hash *pThis = (Hash *)arg;
+ HashRequest *request = 0;
+
+ while (true) {
+ RemoveResult result = pThis->m_RequestQueue->RemoveHead(reinterpret_cast<void **>(&request), INFINITE);
+
+ if (REMOVE_SUCCESS != result) {
+ break;
+ }
+
+ switch (request->Type) {
+ case HASH_SHA256:
+ memset(request->Hash_p, 0, SHA256_LENGTH);
+
+ if (request->Length != 0) {
+ SecurityAlgorithms::SHA256(request->Data_p, request->Length, request->Hash_p);
+ }
+
+ break;
+ case HASH_CRC16:
+ memset(request->Hash_p, 0, CRC16_LENGTH);
+
+ if (request->Length != 0) {
+ uint16 CRC16 = crc16(request->Data_p, request->Length, 0);
+ memcpy(request->Hash_p, &CRC16, sizeof(uint16));
+ }
+
+ break;
+ case HASH_SIMPLE_XOR:
+ request->Hash_p[0] = 0;
+
+ if (request->Length != 0) {
+ request->Hash_p[0] = hashxor(request->Data_p, request->Length);
+ }
+
+ break;
+ case HASH_NONE:
+ break;
+ default:
+ // unsupported hash type, nothing to do
+ delete request;
+ continue;
+ }
+
+ request->Callback(request->Data_p, request->Length, request->Hash_p, request->Param_p);
+
+ delete request;
+ }
+
+ return 0;
+}
+
+/**
+ * Asynchronous hashing of data.
+ *
+ * Calculates a hash over the specified block of data, calling the call-
+ * back function on completion. Note that the callback function might
+ * execute in interrupt context, so due care should be taken when
+ * writing it.
+ *
+ * The hashing might be delayed if another operation is currently
+ * running.
+ *
+ * @param [in] Object_p Initialized buffer context.
+ * @param [in] Type Hash type.
+ * @param [in] Data_p Start of the block of data to hash.
+ * @param [in] Length The length in bytes of the block of data to hash.
+ * @param [out] Hash_p Start of the buffer that should hold the hash
+ * value.
+ * @param [in] Callback The function to call when the hash calculation
+ * completes.
+ * @param [in,out] Param_p The value to use as parameter to Param_p.
+ *
+ * @note Hash_p must be large enough to contain the selected hash type.
+ * Use the "HASH"_LENGTH macros when you know beforehand which hash
+ * type to use, or Do_Crypto_GetHashLength() for dynamically selected
+ * hashes.
+ *
+ */
+void Hash::Calculate(HashType_e Type, void *Data_p, uint32 Length, uint8 *Hash_p, HashCallback_fn Callback, void *Param_p)
+{
+ HashRequest *currentRequest = new HashRequest;
+ currentRequest->Type = Type;
+ currentRequest->Data_p = (uint8 *)Data_p;
+ currentRequest->Length = Length;
+ currentRequest->Hash_p = Hash_p;
+ currentRequest->Callback = Callback;
+ currentRequest->Param_p = Param_p;
+
+ m_RequestQueue->AddTail(currentRequest);
+ /* coverity[leaked_storage] */
+}
+
+uint8 Hash::hashxor(const uint8 *Buf_p, uint32 Length)
+{
+ uint8 Value = 0;
+ const uint8 *Stop_p = Buf_p + Length;
+
+ do {
+ Value ^= *Buf_p++;
+ } while (Buf_p < Stop_p);
+
+ return Value;
+}
+
+uint16 Hash::crc16(const uint8 *p, int count, uint16 crc_in)
+{
+ register uint32 crc = crc_in;
+
+ while (--count >= 0) {
+ crc = crc ^(uint8) * p++ << 8;
+ crc ^= red[crc>>16];
+ crc = (crc << 4);
+ crc ^= red[crc>>16];
+ crc = (crc << 4);
+ crc ^= red[crc>>16];
+
+ }
+
+ return (uint16) crc;
+}
diff --git a/source/LCM/Hash.h b/source/LCM/Hash.h
new file mode 100644
index 0000000..e5e5343
--- /dev/null
+++ b/source/LCM/Hash.h
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _HASH_H_
+#define _HASH_H_
+
+#include "t_communication_service.h"
+#ifdef _WIN32
+#include "WinApiWrappers.h"
+#else
+#include "LinuxApiWrappers.h"
+#endif
+
+struct HashRequest {
+ HashType_e Type;
+ uint8 *Data_p;
+ uint32 Length;
+ uint8 *Hash_p;
+ HashCallback_fn Callback;
+ void *Param_p;
+};
+
+class Hash
+{
+public:
+ Hash();
+ ~Hash();
+ void Cancel(HashDevice_t **HashDevice_pp);
+ void Calculate(HashType_e Type, void *Data_p, const uint32 Length, uint8 *Hash_p, HashCallback_fn Callback, void *Param_p);
+ uint32 GetLength(HashType_e Type);
+private:
+ CThreadWrapper *m_Thread;
+ CSemaphoreQueue *m_RequestQueue;
+
+#ifdef _WIN32
+ static unsigned int WINAPI WorkerThread(void *arg);
+#else
+ static void *WorkerThread(void *arg);
+#endif
+
+ static uint8 hashxor(const uint8 *Buf_p, uint32 Length);
+ static uint16 crc16(const uint8 *p, int count, uint16 crc_in);
+};
+
+#endif // _HASH_H_
diff --git a/source/LCM/Queue.cpp b/source/LCM/Queue.cpp
new file mode 100644
index 0000000..d2ef64e
--- /dev/null
+++ b/source/LCM/Queue.cpp
@@ -0,0 +1,291 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/*
+ * @addtogroup ldr_utilities
+ * @{
+ * @addtogroup queue
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "Queue.h"
+#include "LCDriverMethods.h"
+#include <cstdlib>
+#include <cstring>
+
+/*******************************************************************************
+ * Types, constants
+ ******************************************************************************/
+
+typedef struct Queue_s {
+ /* Head index of the buffer. This is where items are inserted.*/
+ uint32 Head;
+ /* Tail index of the buffer. This is where items are removed.*/
+ uint32 Tail;
+ /* Size of the buffer.*/
+ uint32 Size;
+ /* Buffer pointer.*/
+ void **Buffer_pp;
+ /* Empty buffer callback pointer. */
+ void (*EmptyCallback)(const void *const Queue_p, void *Param_p);
+ /* The parameter is used for the empty buffer transition callback.*/
+ void *EmptyParam_p;
+ /* NonEmpty buffer callback pointer. */
+ void (*NonEmptyCallback)(const void *const Queue_p, void *Param_p);
+ /* The parameter used for the non-empty buffer transition callback.*/
+ void *NonEmptyParam_p;
+ /* Pointer to a function for deallocating any resources that are reserved for
+ * the element. This function is provided as an input parameter when the queue
+ * is created.
+ */
+ void (*DestroyElement)(void *Value_p);
+} Queue_t;
+
+Queue::Queue(void)
+{
+ logger_ = NULL;
+}
+
+Queue::~Queue(void)
+{
+}
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+void Queue::Create(void **const Queue_pp, const uint32 MaxLength, void (*DestroyElement)(void *Element_p))
+{
+ Queue_t *Queue_p = new Queue_t;
+
+ if (Queue_p != 0) {
+ Queue_p->Size = MaxLength;
+ Queue_p->Head = 0;
+ Queue_p->Tail = 0;
+ Queue_p->Buffer_pp = new void*[MaxLength + 1];
+ Queue_p->DestroyElement = DestroyElement;
+ Queue_p->NonEmptyCallback = 0;
+ Queue_p->NonEmptyParam_p = 0;
+ Queue_p->EmptyCallback = 0;
+ Queue_p->EmptyParam_p = 0;
+
+ *Queue_pp = Queue_p;
+
+#ifdef _QUEUEDEBUG
+ PrintF("Queue: Create - Queue 0x%p", Queue_p);
+#endif
+ } else {
+#ifdef _QUEUEDEBUG
+ PrintF("Queue: Create - Not enough memory Queue 0x%p", 0);
+#endif
+ }
+}
+
+void Queue::Destroy(void **const Queue_pp)
+{
+ Queue_t *Queue_p = (Queue_t *) * Queue_pp;
+ void *Object_p = 0;
+
+ if (NULL != Queue_p->DestroyElement) {
+ Object_p = Dequeue(Queue_p);
+
+ while (0 != Object_p) {
+ Queue_p->DestroyElement(Object_p);
+ Object_p = Dequeue(Queue_p);
+ }
+ }
+
+#ifdef _QUEUEDEBUG
+ PrintF("Queue: Destroy - Queue 0x%p", Queue_p);
+#endif
+
+ delete[] Queue_p->Buffer_pp;
+ delete Queue_p;
+ *Queue_pp = NULL;
+}
+
+ErrorCode_e Queue::Enqueue(void *const Queue_p, void *const Object_p)
+{
+ Queue_t *TempQueue_p = (Queue_t *)Queue_p;
+ uint32 Head = (TempQueue_p->Head + 1) % TempQueue_p->Size;
+ boolean NonEmptyCall = (TempQueue_p->Head == TempQueue_p->Tail);
+
+ if (Head != TempQueue_p->Tail) {
+#ifdef _QUEUEDEBUG
+ PrintF("Queue: Enqueue - Queue 0x%p", Queue_p);
+ PrintF("Queue: Enqueue - Object 0x%p", Object_p);
+#endif
+ TempQueue_p->Buffer_pp[Head] = Object_p;
+ TempQueue_p->Head = Head;
+
+ if (Head == TempQueue_p->Tail) {
+#ifdef _QUEUEDEBUG
+ PrintF("Queue: Enqueue - return E_FAILED_TO_STORE_IN_FIFO, Object 0x%p", Object_p);
+#endif
+ return E_FAILED_TO_STORE_IN_FIFO;
+ }
+
+ if (NonEmptyCall && NULL != TempQueue_p->NonEmptyCallback) {
+#ifdef _QUEUEDEBUG
+ PrintF("Queue: Enqueue - Executing NonEmptyCallback Queue 0x%p", Queue_p);
+#endif
+ TempQueue_p->NonEmptyCallback(TempQueue_p, TempQueue_p->NonEmptyParam_p);
+ }
+
+ return E_SUCCESS;
+ } else {
+#ifdef _QUEUEDEBUG
+ PrintF("Queue: Enqueue - return E_FAILED_TO_STORE_IN_FIFO, Object 0x%p", Object_p);
+#endif
+ return E_FAILED_TO_STORE_IN_FIFO;
+ }
+}
+
+void *Queue::Dequeue(void *const Queue_p)
+{
+ Queue_t *TempQueue_p = (Queue_t *)Queue_p;
+ uint32 Tail = TempQueue_p->Tail;
+ void *Object_p = NULL;
+
+ if (Tail != TempQueue_p->Head) {
+#ifdef _QUEUEDEBUG
+ PrintF("Queue: Dequeue - Queue 0x%p", Queue_p);
+#endif
+ Tail = (Tail + 1) % TempQueue_p->Size;
+ Object_p = TempQueue_p->Buffer_pp[Tail];
+ TempQueue_p->Tail = Tail;
+
+ if (Tail == TempQueue_p->Head && NULL != TempQueue_p->EmptyCallback) {
+#ifdef _QUEUEDEBUG
+ PrintF("Queue: Dequeue - Executing EmptyCallback Queue 0x%p", Queue_p);
+#endif
+ TempQueue_p->EmptyCallback(TempQueue_p, TempQueue_p->EmptyParam_p);
+ }
+
+#ifdef _QUEUEDEBUG
+ PrintF("Queue: Dequeue - Object 0x%p", Object_p);
+#endif
+ }
+
+ return Object_p;
+}
+
+QueueCallback_fn Queue::SetCallback(void *const Queue_p,
+ const QueueCallbackType_e Type,
+ const QueueCallback_fn Callback,
+ void *const Param_p)
+{
+ Queue_t *TempQueue_p = (Queue_t *)Queue_p;
+ QueueCallback_fn OldCallback;
+
+ if (Type == QUEUE_EMPTY) {
+ OldCallback = TempQueue_p->EmptyCallback;
+ TempQueue_p->EmptyCallback = Callback;
+ TempQueue_p->EmptyParam_p = Param_p;
+ } else {
+ OldCallback = TempQueue_p->NonEmptyCallback;
+ TempQueue_p->NonEmptyCallback = Callback;
+ TempQueue_p->NonEmptyParam_p = Param_p;
+ }
+
+ return OldCallback;
+}
+
+boolean Queue::IsEmpty(const void *const Queue_p)
+{
+ Queue_t *TempQueue_p = (Queue_t *)Queue_p;
+
+ if (TempQueue_p->Tail == TempQueue_p->Head) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+boolean Queue::IsMember(const void *const Queue_p, void *Value_p, boolean(*Match)(void *Value1_p, void *Value2_p))
+{
+ Queue_t *TempQueue_p = (Queue_t *)Queue_p;
+
+ for (size_t i = TempQueue_p->Head; i < TempQueue_p->Tail; i++) {
+ if (Match(Value_p, TempQueue_p->Buffer_pp[i])) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+int Queue::GetNrOfElements(const void *const Queue_p)
+{
+ Queue_t *TempQueue_p = (Queue_t *)Queue_p;
+ int Return = 0;
+
+ if (TempQueue_p->Head >= TempQueue_p->Tail) {
+ Return = TempQueue_p->Head - TempQueue_p->Tail;
+ } else {
+ Return = TempQueue_p->Size - (TempQueue_p->Tail - TempQueue_p->Head);
+ }
+
+ return Return;
+}
+
+void Queue::RCreate(void **const Queue_pp, const uint32 MaxLength, void (*DestroyElement)(void *))
+{
+ CLockCS QueueLock(QueueCSO);
+ Create(Queue_pp, MaxLength, DestroyElement);
+}
+
+void Queue::RDestroy(void **const Queue_pp)
+{
+ CLockCS QueueLock(QueueCSO);
+ Destroy(Queue_pp);
+}
+
+ErrorCode_e Queue::REnqueue(void *const Queue_p, void *const Value_p)
+{
+ CLockCS QueueLock(QueueCSO);
+ return Enqueue(Queue_p, Value_p);
+}
+
+void *Queue::RDequeue(void *const Queue_p)
+{
+ CLockCS QueueLock(QueueCSO);
+ return Dequeue(Queue_p);
+}
+
+QueueCallback_fn Queue::RSetCallback(void *const Queue_p,
+ const QueueCallbackType_e Type,
+ const QueueCallback_fn Callback,
+ void *const Param_p)
+{
+ CLockCS QueueLock(QueueCSO);
+ return SetCallback(Queue_p, Type, Callback, Param_p);
+}
+
+boolean Queue::RIsEmpty(const void *const Queue_p)
+{
+ CLockCS QueueLock(QueueCSO);
+ return IsEmpty(Queue_p);
+}
+
+boolean Queue::RIsMember(const void *const Queue_p, void *Value_p, boolean(*Match)(void *Value1_p, void *Value2_p))
+{
+ CLockCS QueueLock(QueueCSO);
+ return IsMember(Queue_p, Value_p, Match);
+}
+
+int Queue::RGetNrOfElements(const void *const Queue_p)
+{
+ CLockCS QueueLock(QueueCSO);
+ return GetNrOfElements(Queue_p);
+}
+
+void Queue::PrintF(const char *text, void *pVoid)
+{
+ if (NULL != logger_) {
+ logger_->log(text, pVoid);
+ }
+}
diff --git a/source/LCM/Queue.h b/source/LCM/Queue.h
new file mode 100644
index 0000000..838fc05
--- /dev/null
+++ b/source/LCM/Queue.h
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _QUEUE_H_
+#define _QUEUE_H_
+
+#include "t_queue.h"
+#include "error_codes.h"
+#ifdef _WIN32
+#include "WinApiWrappers.h"
+#else
+#include <stdio.h>
+#include "LinuxApiWrappers.h"
+#endif
+#include "Logger.h"
+
+class Queue
+{
+public:
+ Queue(void);
+ ~Queue(void);
+
+ void Create(void **const Queue_pp, const uint32 MaxLength, void (*DestroyElement)(void *Element_p));
+ void Destroy(void **const Queue_pp);
+ ErrorCode_e Enqueue(void *const Queue_p, void *const Value_p);
+ void *Dequeue(void *const Queue_p);
+ QueueCallback_fn SetCallback(void *const Queue_p, const QueueCallbackType_e Type, const QueueCallback_fn Callback, void *const Param_p);
+ boolean IsEmpty(const void *const Queue_p);
+ boolean IsMember(const void *const Queue_p, void *Value_p, boolean(*Match)(void *Value1_p, void *Value2_p));
+ int GetNrOfElements(const void *const Queue_p);
+
+ //Reentrant
+ void RCreate(void **const Queue_pp, const uint32 MaxLength, void (*DestroyElement)(void *Element_p));
+ void RDestroy(void **const Queue_pp);
+ ErrorCode_e REnqueue(void *const Queue_p, void *const Value_p);
+ void *RDequeue(void *const Queue_p);
+ QueueCallback_fn RSetCallback(void *const Queue_p, const QueueCallbackType_e Type, const QueueCallback_fn Callback, void *const Param_p);
+ boolean RIsEmpty(const void *const Queue_p);
+ boolean RIsMember(const void *const Queue_p, void *Value_p, boolean(*Match)(void *Value1_p, void *Value2_p));
+ int RGetNrOfElements(const void *const Queue_p);
+
+ void SetLogger(Logger *logger) {
+ logger_ = logger;
+ }
+private:
+ CCriticalSectionObject QueueCSO;
+ Logger *logger_;
+ void PrintF(const char *text, void *pVoid);
+};
+
+#endif // _QUEUE_H_
diff --git a/source/LCM/Timer.cpp b/source/LCM/Timer.cpp
new file mode 100644
index 0000000..8dd19e4
--- /dev/null
+++ b/source/LCM/Timer.cpp
@@ -0,0 +1,267 @@
+/***********************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ **********************************************************************/
+
+/*************************************************************************
+* Includes
+*************************************************************************/
+#include <stdlib.h>
+#include <string.h>
+#include "Timer.h"
+#include "LCDriverMethods.h"
+
+
+/***********************************************************************
+ * Declaration of file local functions
+ **********************************************************************/
+/* Constructor */
+Timer::Timer(void):
+ systemTime_(0),
+ logger_(0)
+{
+ timers_.Timers_p = NULL;
+ timers_.ActiveTimers = 0;
+ timers_.MaxTimers = 0;
+}
+
+/* Destructor */
+Timer::~Timer(void)
+{
+ delete[] timers_.Timers_p;
+}
+/***********************************************************************
+ * Definition of external functions
+ **********************************************************************/
+
+/*
+ * Initialization of the Timers handler.
+ *
+ * @param [in] Timers Numbers of defined timers.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS If no timer s for initialization.
+ */
+ErrorCode_e Timer::Init(uint32 Timers)
+{
+ /* Check input parameters. */
+ if (0 == Timers) {
+ /* Invalid input parameters! */
+ return E_INVALID_INPUT_PARAMETERS;
+ }
+
+ /* Allocate memory space for timers */
+ timers_.Timers_p = new Timer_t[Timers];
+
+ if (timers_.Timers_p == NULL) {
+ /* Error allocation Timers buffer! */
+ return E_ALLOCATE_FAILED;
+ }
+
+ /* Clear Timers buffer */
+ memset(timers_.Timers_p, 0x00, Timers * sizeof(Timer_t));
+
+ /* Inicialize numbers of defined and activated timers */
+ timers_.MaxTimers = Timers;
+ timers_.ActiveTimers = 0;
+
+ return E_SUCCESS;
+}
+
+/*
+ * Reserve new timer.
+ *
+ * @param [in] Timer_p pointer to the timer data.
+ *
+ * @return Index of reserved timer.
+ * @return Index 0 if no free timers.
+ */
+uint32 Timer::Get(Timer_t *Timer_p)
+{
+ uint32 TimerKey = 0;
+
+ /* Check input parameters */
+ if (0 == Timer_p->Time || NULL == Timer_p->HandleFunction_p) {
+ goto ErrorExit;
+ }
+
+ /* Find free timer */
+ TimerKey = FindFreeTimer();
+
+ if (0 == TimerKey) {
+ goto ErrorExit; // no free timers
+ }
+
+ timers_.ActiveTimers++;
+
+ timers_.Timers_p[TimerKey - 1] = *Timer_p;
+
+#ifdef _TIMERDEBUG
+ logger_->log("Timer: Get - Timer 0x%p", &timers_.Timers_p[TimerKey - 1]);
+#endif
+
+ErrorExit:
+ return TimerKey;
+}
+
+/*
+ * Release reserved timer.
+ *
+ * @param [in] TimerKey Index of reserved timer.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS If one of the input.
+ * @retval E_NONEXIST_TIMER non exist timer.
+ */
+ErrorCode_e Timer::Release(uint32 TimerKey)
+{
+ ErrorCode_e ReturnValue = E_INVALID_INPUT_PARAMETERS;
+ Timer_t *TimerData_p = NULL;
+
+ /* check input parameters */
+ if ((0 == TimerKey) || (timers_.MaxTimers < TimerKey)) {
+ goto ErrorExit;
+ }
+
+ TimerData_p = &timers_.Timers_p[TimerKey - 1];
+
+ if (NULL != TimerData_p->HandleFunction_p) {
+ /* clear timer data */
+ TimerData_p->Time = 0;
+ TimerData_p->HandleFunction_p = NULL;
+
+ /* first check number of active timers */
+ if (0 < timers_.ActiveTimers) {
+ /* remove timer from active timer counter */
+ timers_.ActiveTimers--;
+ }
+
+ ReturnValue = E_SUCCESS;
+
+#ifdef _TIMERDEBUG
+ logger_->log("Timer: Release - Timer 0x%p", (void *)TimerData_p);
+#endif
+ } else {
+ ReturnValue = E_NONEXIST_TIMER;
+ }
+
+ErrorExit:
+ return ReturnValue;
+}
+
+/*
+ * Read the current time of timer.
+ *
+ * @param [in] TimerKey Index of reserved timer.
+ *
+ * @return Current time of the timer.
+ */
+uint32 Timer::ReadTime(uint32 TimerKey)
+{
+ uint32 Time = 0;
+
+ if (TimerKey == 0 || TimerKey > timers_.MaxTimers) {
+ return Time;
+ }
+
+ Timer_t *TimerData_p = &timers_.Timers_p[TimerKey - 1];
+
+ if (NULL != TimerData_p->HandleFunction_p) {
+ /* get timer data */
+ Time = TimerData_p->Time;
+ }
+
+ return Time;
+}
+
+/*
+ * Get current system time.
+ *
+ * @return System Time.
+ */
+uint32 Timer::GetSystemTime()
+{
+ return static_cast<uint32>(systemTime_);
+}
+
+
+/*
+ * The timer handler method which is polled in the main execution thread.
+ * Checks if there is a timer which time has elapsed and calls its callback,
+ * handle the timers time decrementation.
+ *
+ * @param [in] IsTimerOn Determinates if the timers are active to be handled.
+ *
+ * @return Function doesn't return value.
+ */
+void Timer::DoTimerHandler(bool IsTimerOn)
+{
+ uint32 SearchTimerKey = 0;
+ uint32 TimeIncrement = GetIncrement();
+
+ while (timers_.ActiveTimers > 0 && SearchTimerKey < timers_.MaxTimers) {
+ /* get Timer(SearchTimerKey) data */
+ Timer_t *TimerData_p = &timers_.Timers_p[SearchTimerKey];
+
+ if (NULL != TimerData_p->HandleFunction_p) {
+ /* decrement Time */
+ if (IsTimerOn) {
+ TimerData_p->Time -= min(TimerData_p->Time, TimeIncrement);
+ }
+
+ /* check for elapsed time */
+ if (TimerData_p->Time == 0) {
+#ifdef _TIMERDEBUG
+ logger_->log("Timer: DoTimerHandler - callback handle function Timer 0x%p", TimerData_p);
+#endif
+ TimerData_p->HandleFunction_p(TimerData_p->Param_p, TimerData_p, TimerData_p->Data_p);
+
+ /* Check for periodicals of timer */
+ if (TimerData_p->PeriodicalTime != 0) {
+ /* Set again Timer with periodical time */
+ TimerData_p->Time = TimerData_p->PeriodicalTime;
+ } else {
+ /* release current timer */
+ Release(SearchTimerKey + 1);
+ }
+ }
+ }
+
+ /* next timer for check */
+ SearchTimerKey++;
+ }
+}
+
+/*
+ * Get the difference in time from the last call.
+ *
+ * @return increment the duration of time which should be
+ * substracted from the timers.
+ */
+uint32 Timer::GetIncrement()
+{
+ time_t now = OS::GetSystemTimeInMs();
+ time_t increment = now - systemTime_;
+ systemTime_ = now;
+ return static_cast<uint32>(increment);
+}
+
+/*
+ * Find free timer.
+ *
+ * @retval Timer index if free timer exist.
+ * @retval 0 if no free timer.
+ */
+uint32 Timer::FindFreeTimer()
+{
+ uint32 TimerKey = 0;
+
+ for (size_t i = 0; i != timers_.MaxTimers; ++i) {
+ if (timers_.Timers_p[i].HandleFunction_p == NULL) {
+ TimerKey = i + 1;
+ break;
+ }
+ }
+
+ return TimerKey;
+}
diff --git a/source/LCM/Timer.h b/source/LCM/Timer.h
new file mode 100644
index 0000000..2b395b6
--- /dev/null
+++ b/source/LCM/Timer.h
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _TIMER_H_
+#define _TIMER_H_
+
+#include "error_codes.h"
+#include "t_time_utilities.h"
+#include "Logger.h"
+#ifdef _WIN32
+#include "WinApiWrappers.h"
+#else
+#include "LinuxApiWrappers.h"
+#endif
+#include <ctime>
+
+class Timer
+{
+public:
+ Timer();
+ /*
+ * Initialization of the Timers handler.
+ *
+ * @param [in] Timers Numbers of defined timers.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS If no timer s for initialization.
+ */
+ ErrorCode_e Init(uint32 Timers);
+
+ /*
+ * Reserve new timer.
+ *
+ * @param [in] Timer_p pointer to the timer data.
+ *
+ * @return Index of reserved timer.
+ * @return Index 0 if no free timers.
+ */
+ uint32 Get(Timer_t *Timer_p);
+
+ /*
+ * Release reserved timer.
+ *
+ * @param [in] TimerKey Index of reserved timer.
+ *
+ * @retval E_SUCCESS After successful execution.
+ * @retval E_INVALID_INPUT_PARAMETERS If one of the input.
+ * @retval E_NONEXIST_TIMER non exist timer.
+ */
+ ErrorCode_e Release(uint32 TimerKey);
+
+ /*
+ * Read the current time of timer.
+ *
+ * @param [in] TimerKey Index of reserved timer.
+ *
+ * @return Current time of the timer.
+ */
+ uint32 ReadTime(uint32 TimerKey);
+
+ /**
+ * Get current system time.
+ *
+ * @return System Time.
+ */
+ uint32 GetSystemTime(void);
+
+ /*
+ * The timer handler method which is polled in the main execution thread.
+ * Checks if there is a timer which time has elapsed and calls its callback,
+ * handle the timers time decrementation.
+ *
+ * @param [in] IsTimerOn Determinates if the timers are active to be handled.
+ *
+ * @return Function doesn't return value.
+ */
+ void DoTimerHandler(bool IsTimerOn);
+
+public:
+ ~Timer(void);
+ void SetLogger(Logger *logger) {
+ logger_ = logger;
+ }
+
+private:
+ TimerHeader_t timers_;
+ time_t systemTime_;
+
+ Logger *logger_;
+
+ uint32 GetIncrement();
+ uint32 FindFreeTimer();
+};
+
+#endif // _TIMER_H_
diff --git a/source/LCM/include/c_compiler.h b/source/LCM/include/c_compiler.h
new file mode 100644
index 0000000..77cd673
--- /dev/null
+++ b/source/LCM/include/c_compiler.h
@@ -0,0 +1,127 @@
+/******************************************************************************
+*
+* 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: \KIRND_FuncBlocks_Utilities_003\cnh1606432\dependencies\Utils\c_compiler.h $
+ *
+ * Version: ...\cnh1606432\cnh1606432_r1\7 18 Nov 2009 10:18 (GMT) qsjomik
+ * Overwrite merge.
+ * Compiled with _INTERCEPTCALLBACKS pre-compiler directive.
+ * Stability, Multi-Dut and storing BufferVector updates.
+ * Updated for LCM R1B.
+ * R1A027.
+ *
+ * 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(__IAR_SYSTEMS_ASM__)
+#elif defined(_lint)
+#elif defined(__GNUC__)
+#define COMPILER_GNUC
+#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/source/LCM/include/c_system.h b/source/LCM/include/c_system.h
new file mode 100644
index 0000000..0b058ec
--- /dev/null
+++ b/source/LCM/include/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/source/LCM/include/error_codes.h b/source/LCM/include/error_codes.h
new file mode 100644
index 0000000..e71d4b4
--- /dev/null
+++ b/source/LCM/include/error_codes.h
@@ -0,0 +1,740 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/* 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 "t_basicdefinitions.h"
+
+#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
+ */
+
+
+typedef enum {
+ E_SUCCESS = 0, /**< Operation successful. */
+ E_GENERAL_FATAL_ERROR = 1, /**< General Failure. */
+ E_ALLOCATE_FAILED = 2, /**< Failed to allocate memory. */
+ E_INVALID_INPUT_PARAMETERS = 51, /**< The expected value into the function was incorrect. */
+ E_INVALID_CURRDATE_STRING_LENGTH = 52, /**< Indicate that the currdate string array variable has invalid length. */
+ E_UNALIGNED_DATA = 53, /**< Indicate that a variable is not aligned. */
+ E_VECTOR_CREATE_FAIL = 100, /**< Failed to create vector in IO Layer. */
+ E_VECTOR_DESTROY_FAIL = 101, /**< Failed to destroy vector in IO Layer. */
+ E_GENERAL_IO_ERROR = 151, /**< Unknown IO error. */
+ E_IO_FAILED_TO_READ = 152, /**< IO failed to read from source. */
+ E_IO_FAILED_TO_WRITE = 153, /**< IO failed to write to destination. */
+ E_IO_FAILED_TO_CLOSE = 154, /**< IO failed to close media. */
+ E_IO_FAILED_TO_OPEN = 155, /**< IO failed to open media. */
+ E_IO_FAILED_TO_GET_LENGTH = 156, /**< IO failed to get length of media. */
+ E_GENERAL_COMMUNICATION_ERROR = 200, /**< General communication error. */
+ E_FAILED_TO_START_BULK_SESSION = 201, /**< Failed to start bulk session. */
+ E_FAILED_TO_CLOSE_BULK_SESSION = 202, /**< Failed to initialize the transport layer. */
+ E_FAILED_TO_FIND_CHUNK_DATA_BLOCK = 203, /**< Failed to find chunk data block. */
+ E_FAILED_TO_INIT_COM_DEVICE = 204, /**< Failed to reinitialize communication device. */
+ E_FAILED_TO_USE_COM_DEVICE = 205, /**< Failed to use communication device. */
+ E_FAILED_TO_ALLOCATE_COMM_BUFFER = 206, /**< Failed to allocate communication buffer. */
+ E_FAILED_TO_FLUSH_RXFIFO = 207, /**< Failed to flush RX FIFO. */
+ E_RETRANSMITION_FAILED = 208, /**< Retransmission failed. After MAX_RESENDS attempt, failed to send packet. */
+ E_COMMAND_NO_ERROR = 209, /**< */
+ E_FAILED_TO_RELEASE_COMM_BUFFER = 210, /**< Failed to release communication buffer. */
+ E_FAILED_TO_INTIALIZE_TIMER_FUNCTIONS = 211, /**< Failed to initialize timer functions. */
+ E_FAILED_TO_INTIALIZE_QUEUE_FUNCTIONS = 212, /**< Failed to initialize queue functions. */
+ E_INVALID_BULK_MODE = 251, /**< Invalid bulk mode. */
+ E_FAILED_TO_FIND_COMM_BUFFER = 252, /**< Failed to find communication buffer. */
+ E_INVALID_TYPE_OF_BUFFER = 253, /**< Invalid type of buffer. */
+ E_COM_DEVICE_BUSY = 254, /**< */
+ E_NOT_FOUND_ELEMENT_IN_RETRANSMISSION_LIST = 255, /**< The element in retransmission list is not found. */
+ E_FAILED_READING_FROM_BULK = 256, /**< Failed to read from bulk. */
+ E_FAILED_WRITING_TO_BULK = 257, /**< Failed to write to bulk. */
+ E_FAILED_TO_GET_UART_DESCRIPTOR = 258, /**< Failed to get UART descriptor. */
+ E_FAILED_TO_GET_USB_DESCRIPTOR = 259, /**< Failed to get USB descriptor. */
+ E_INVALID_BULK_SESSION_ID = 260, /**< Invalid bulk session ID is used. */
+ E_PREVIOUS_BULK_SESSION_IS_NOT_CLOSED = 261, /**< Previous bulk session not closed. */
+ E_INVALID_BULK_PROTOCOL_STATE = 262, /**< Invalid bulk protocol state. */
+ E_UNKNWON_PROPERTY = 351, /**< Unknown property id. */
+ E_CYCLIC_GRAPH = 451, /**< Cyclic graph in services detected. */
+ E_SERVICE_NOT_SUPPORTED = 452, /**< The service is not supported. */
+ E_INCONSISTENCY_IN_SERVICES = 453, /**< Inconsistency in services is detected. */
+ E_SERVICE_IN_USE = 454, /**< The service is in use and can't be stopped. */
+ E_UNREGISTER_BDM_SERVICE_FAILED = 455, /**< Unregistering of Block Device Manager Service failed. */
+ E_UNREGISTER_BAM_SERVICE_FAILED = 456, /**< Unregistering of Boot Area Manager Service failed. */
+ E_UNREGISTER_COPS_SERVICE_FAILED = 457, /**< Unregistering of COPS Data Manager Service failed. */
+ E_UNREGISTER_FS_SERVICE_FAILED = 458, /**< Unregistering of File System Manager Service failed. */
+ E_UNREGISTER_FPD_SERVICE_FAILED = 459, /**< Unregistering of Flash Physical Driver Service failed. */
+ E_UNREGISTER_GD_SERVICE_FAILED = 460, /**< Unregistering of Global Data Manager Service failed. */
+ E_GENERAL_ZIP_ERROR = 551, /**< */
+ E_ZIP_FAILED_TO_CREATE_CONTEXT = 552, /**< */
+ E_ZIP_FAILED_TO_OPEN_FILE = 553, /**< */
+ E_FILESYS_APP_INIT_FAILURE = 600, /**< */
+ E_NO_FILESYSTEM_PROPERTY = 601, /**< */
+ E_UNDEFINED_AUTHENTICATION_TYPE = 602, /**< */
+ E_RTC_TIME_NOT_ACCURATE = 651, /**< */
+ E_RTC_INTIALIZATION_FAILED = 652, /**< */
+ E_DIFFERENT_FLASHLAYOUT = 751, /**< Different flashlayout. */
+ E_EMPTY_FILE_IN_ARCHIVE = 752, /**< Archive contain empty file. */
+ E_UNKNOWN_COMM_DEVICE = 753, /**< Unknown communication device was detected. */
+ E_FLASH_APP_INTERNAL_ERROR = 754, /**< Internal during execution of flash commands. */
+ E_DEVICE_NAME_TOO_LONG = 755, /**< Device name is too long. */
+ E_FLASH_ARCHIVE_MISMATCH = 756, /**< Mismatch between archieve that is flashed and previosly flashed one. */
+ E_UNSUPPORTED_FLASH_TYPE = 757, /**< Flash memory device type is not supported. */
+ E_FPD_NOT_CONFIGURED = 758, /**< Flash physical driver is not configured. */
+ E_INVALID_SIZE_IN_MEMCONF = 759, /**< MEMCONF boot record contain invalid TotalSize field. */
+ E_ARCHIVE_TO_LARGE = 760, /**< Flash archive larger than available space in BDM. */
+ E_PATH_NOT_EXISTS = 951, /**< Path not exist. */
+ E_CLOSE_FILE = 952, /**< Failed to close a file in the file system. */
+ E_INSUFFICENT_SPACE = 953, /**< Not enough memory space for desired operation. */
+ E_REMOVE_FILE = 954, /**< Failed to remove a file from the file system. */
+ E_RENAME_FILE = 955, /**< Failed to rename a file from the file system. */
+ E_CREATE_DIR = 956, /**< Failed to create a new directory in the file system. */
+ E_REMOVE_DIRECTORY = 957, /**< Failed to remove directory. */
+ E_FREE_SPACE = 958, /**< No free space left. */
+ E_ITEM_STAT = 959, /**< Failed to retrieve status data. */
+ E_CLOSE_DIRECTORY = 960, /**< Failed to close a directory in the file system. */
+ E_MOUNT_VOLUME = 961, /**< Failed to mount volume in the file system. */
+ E_READ_DIRECTORY = 962, /**< Failed to read directory in the file system. */
+ E_FS_IO = 963, /**< Input/output error. */
+ E_FS_ARGUMENT_LIST_2BIG = 964, /**< Argument list too long. */
+ E_FS_BAD_FILE_DESC = 965, /**< Bad file descriptor. */
+ E_FS_ACCESS = 966, /**< Permission denied. */
+ E_FS_BAD_ADDRESS = 967, /**< Bad address. */
+ E_FS_FILE_EXIST = 968, /**< File exists. */
+ E_FS_NOT_DIR = 969, /**< Not a directory. */
+ E_FS_IS_DIR = 970, /**< Is a directory. */
+ E_FS_FILE_TOO_LARGE = 971, /**< File too large. */
+ E_FS_READ_ONLY_FS = 972, /**< Read-only file system. */
+ E_FS_OPER_NOT_SUPP = 973, /**< Operation not supported. */
+ E_FS_NAME_TOO_LONG = 974, /**< File name too long. */
+ E_FS_OPERATION_CANCELED = 975, /**< Operation canceled. */
+ E_FS_FAIL = 976, /**< Cannot start operation. */
+ E_FS_INTERNAL = 977, /**< Internal error. */
+ E_FS_NOT_MOUNTED = 978, /**< Volume not mounted. */
+ E_FS_NOT_PERMITED = 979, /**< Operation not permitted. */
+ E_FS_NO_SUCH_FILE_OR_DIR = 980, /**< No such file or directory. */
+ E_FS_NOT_EXIST = 981, /**< Specified FS does not exist. */
+ E_FS_UNKNOWN_ERROR = 982, /**< Error is unknown. */
+ E_FAILED_WRITING_TO_FILE = 983, /**< Failed to write to file. */
+ E_FAILED_READING_FROM_FILE = 984, /**< Failed to read from the specified file. */
+ E_ACCESS_DENIED = 985, /**< The access permission attributes do not allow operation. */
+ E_CANNOT_OPEN_FILE = 986, /**< Can not open the specified file. */
+ E_FAILED_TO_STOP_FS = 987, /**< Can not stop file system. */
+ E_FILE_NAME_TOO_LONG = 988, /**< File name is too long. */
+ E_FAILED_TO_FIND_ELF_SECTION = 989, /**< Can not find elf section. */
+ E_MAX_NUMBER_OF_MOUNTED_VOLUMES_EXCEEDED = 990, /**< Unable to mount volume due to exceeding the maximum number of allowed volumes. */
+ E_NO_MOUNTED_DEVICES_ARE_FOUND = 991, /**< Information message that no mounted devices are found. */
+ E_NOT_FREE_CMD_SPACE = 1000, /**< Index for new command is not founded in execution queue. */
+ E_INVALID_INPUT_PARAMETER = 1001, /**< Invalid input parameter */
+ E_UNSUPPORTED_CMD = 1002, /**< The loader does not support the requested command. */
+ E_UNSUPPORTED_GROUP = 1003, /**< The loader does not support the requested group. */
+ E_INVALID_COMMAND_SIZE = 1051, /**< */
+ E_OVERLOAD_COMMAND_TABLE = 1052, /**< */
+ E_COMMAND_ALREADY_REGISTERED = 1053, /**< */
+ E_AUDITING_FAILED = 1054, /**< Command auditing failed. */
+ E_NONEXIST_TIMER = 1251, /**< */
+ E_FAILED_TO_SET_TIMER = 1252, /**< */
+ E_TIMER_INIT_FAILED = 1253, /**< */
+ E_TIMER_IRQ_CONF_FAILED = 1254, /**< */
+ E_GD_INVALID_UNIT_SIZE = 1351, /**< GD/GDFS: Error in specifying unit size. */
+ E_GD_LL_ILLEGAL_SIZE = 1352, /**< GD/GDFS: Size too large for the block. */
+ E_GD_LL_WRITE_FAILED = 1353, /**< GD/GDFS: Write failed on FLASH device level. */
+ E_GD_LL_ERASE_FAILED = 1354, /**< GD/GDFS: Erase failed on FLASH device level. */
+ E_GD_LL_UNKNOWN_DEVICE = 1355, /**< GD/GDFS: FLASH device unknown. */
+ E_GD_STARTUP_LOG_BLK_MISSING = 1356, /**< GD/GDFS: Logical block not found during start-up scan. */
+ E_GD_STARTUP_DUPLICATE_LOG_BLK = 1357, /**< GD/GDFS: Duplicate instances of same logical block. */
+ E_GD_ERASE_ILLEGAL_BLK_NR = 1358, /**< GD/GDFS: Attempt to erase non-existing physical block. */
+ E_GD_FG_UNIT_NOT_FOUND = 1359, /**< GD/GDFS: Requested unit not found, probably never written or has been deleted. */
+ E_GD_FG_UNIT_SIZE_MISMATCH = 1360, /**< GD/GDFS: Attempt to access a unit outside its beyond its end. */
+ E_GD_FG_ILLEGAL_LOG_BLK_NR = 1361, /**< GD/GDFS: Attempt to access a logical block that does not exist. (Hardware, fatal). */
+ E_GD_FG_ILLEGAL_PHYS_BLK_NR = 1362, /**< GD/GDFS: Attempt to access a physical block that does not exist (internal error). */
+ E_GD_FG_BLK_FULL = 1363, /**< GD/GDFS: Attempted to write more data to a block than could be fitted into one FLASH block. */
+ E_GD_FG_NO_BLK_FREE = 1364, /**< GD/GDFS: Internal error (no free blocks are available). */
+ E_GD_FG_UNIT_CHECKSUM = 1365, /**< GD/GDFS: The checksum or a unit being read is wrong. */
+ E_GD_FG_NOT_DIRECT_BLOCK = 1366, /**< GD/GDFS: Block is not direct. */
+ E_GD_FG_NOT_FREE_BLOCK = 1367, /**< GD/GDFS: For some reason, a free block could not be properly erased. */
+ E_GD_FG_ILLEGAL_SIZE = 1368, /**< GD/GDFS: The size of a unit being written exceeds the maximum limit of a unit. */
+ E_GD_E_FG_FREE_AREA_DIRTY = 1369, /**< GD/GDFS: The startup check found non-FF bytes in unused range within a block. */
+ E_GD_FG_SYNC_FAILED = 1370, /**< GD/GDFS: Failed to synchronize. */
+ E_GD_NOT_OPEN = 1371, /**< GD/GDFS: Tried to access data although GD was in closed state. */
+ E_GD_NOT_ALLOWED = 1372, /**< GD/GDFS: Operation not allowed in the current mode. */
+ E_GD_ALREADY_OPEN = 1373, /**< GD/GDFS: Tried to open or format when GD was already opened. */
+ E_GD_FRONKENSTIENS_PATTERN_MISMATCH = 1374, /**< GD/GDFS: The id mark of the GDVAR file does not match the data in the flash. Fatal and makes GD read only. */
+ E_GD_ILLEGAL_ALIGNMENT = 1375, /**< GD/GDFS: Tried to erase at an address that was not aligned to a flash block boundary. Internal error. */
+ E_GD_ILLEGAL_SIZE = 1376, /**< GD/GDFS: The operation may not be performed with the specified size. Tried to write a to large unit. */
+ E_GD_ACCESS_DENIED = 1377, /**< GD/GDFS: Operation not allowed. Flash device protected. Possible wrong flash driver configuration. */
+ E_GD_ILLEGAL_INDEX = 1378, /**< GD/GDFS: Illegal GD index. */
+ E_GD_MEMORY_ALLOCATION_FAILED = 1379, /**< GD/GDFS: Fatal. Failed to allocate dynamic memory. */
+ E_GD_MISSING_CONFIG = 1380, /**< GD/GDFS: Missing configuration parameter. */
+ E_GD_ILLEGAL_CONFIG = 1381, /**< GD/GDFS: Illegal configuration. */
+ E_GD_TRANSACTION_LOG_CORRUPT = 1382, /**< GD/GDFS: The transaction log used for tracking updates to GD contents is corrupt and prevents roll-back from working properly. */
+ E_GD_NO_DATA_TO_READ = 1399, /**< GD: No data to read. */
+ E_BDM_W_NO_MORE_GC_POSSIBLE = 1451, /**< BDM: No more garbage collection is possible. */
+ E_BDM_UNIT_STARTED = 1452, /**< BDM: Unit has already been started. */
+ E_BDM_UNIT_NOT_STARTED = 1453, /**< BDM: Unit has not yet been started. */
+ E_BDM_NOT_CONFIGURED = 1454, /**< BDM: Has not been configured yet. */
+ E_BDM_STARTUP_FAILED = 1455, /**< BDM: Startup failed. */
+ E_BDM_SHUTDOWN_FAILED = 1456, /**< BDM: Shutdown failed. */
+ E_BDM_WRITE_FAILED = 1457, /**< BDM: An error occurred while writing. */
+ E_BDM_READ_FAILED = 1458, /**< BDM: An error occurred while reading */
+ E_BDM_ERASE_FAILED = 1459, /**< BDM: An error occurred while erasing. */
+ E_BDM_JUNK_FAILED = 1460, /**< BDM: An error occurred while junking. */
+ E_BDM_GC_FAILED = 1461, /**< BDM: An error occurred while garbage collecting. */
+ E_BDM_GET_INFO_FAILED = 1462, /**< BDM: An error occurred while retrieving info about a BDM unit. */
+ E_BDM_WRITE_NOT_SUPPORTED = 1463, /**< BDM: Write not supported. */
+ E_BDM_JUNK_NOT_SUPPORTED = 1464, /**< BDM: Junk not supported. */
+ E_BDM_GC_NOT_SUPPORTED = 1465, /**< BDM: Garbage collection not supported. */
+ E_BDM_SYNC_FAILED = 1466, /**< BDM: Synchronize failed. */
+ E_BDM_NOT_SUPPORTED = 1467, /**< BDM: Function not supported. */
+ E_BDM_PAUSED = 1468, /**< BDM: Paused. */
+ E_BDM_NOT_PAUSED = 1469, /**< BDM: Not paused. */
+ E_BDM_FINDING_BAM_BLOCKS = 1470, /**< BDM: BAM blocks not found. */
+ E_BDM_BAD_PARAM = 1471, /**< BDM: Argument invalid or out of range. */
+ E_BDM_FORMAT_FAILED = 1472, /**< BDM: Formatting failed. */
+ E_BDM_INVALID_UNIT = 1473, /**< BDM: The unit number is out of range. */
+ E_BDM_INVALID_CONFIG = 1474, /**< BDM: Some part of the configuration is invalid. */
+ E_BDM_PRE_FLASH_FINISHED = 1475, /**< BDM: No more preflash blocks can be fetched. */
+ E_BDM_PRE_FLASH_TERMINATE_FAILED = 1476, /**< BDM: Termination of preflash failed. */
+ E_BDM_OUT_OF_MEM = 1477, /**< BDM: Could not allocate enough memory. */
+ E_BDM_XSR_CRITICAL_ERROR = 1481, /**< BDM XSR: Critical error. */
+ E_BDM_XSR_INVALID_PARAMS = 1482, /**< BDM XSR: Invalid parameters. */
+ E_BDM_XSR_PARTITION_NOT_OPENED = 1483, /**< BDM XSR: Could not open partition. */
+ E_BDM_XSR_UNFORMATTED_FLASH = 1484, /**< BDM XSR: Unformatted flash. */
+ E_BDM_XSR_ALLOCATION_ERROR = 1485, /**< BDM XSR: Failed to allocate. */
+ E_BDM_XSR_INVALID_PARTITION = 1486, /**< BDM XSR: Invalid partition. */
+ E_BDM_XSR_READ_ERROR = 1487, /**< BDM XSR: An error occurred while reading. */
+ E_BDM_XSR_WRITE_ERROR = 1488, /**< BDM XSR: An error occurred while writing. */
+ E_BDM_XSR_ERASE_ERROR = 1489, /**< BDM XSR: An error occurred while erasing. */
+ E_BDM_XSR_DEVICE_ERROR = 1490, /**< BDM XSR: Device error. */
+ E_BDM_XSR_GOODBLOCK = 1491, /**< BDM XSR: Good block. */
+ E_BDM_XSR_BADBLOCK = 1492, /**< BDM XSR: Bad block. */
+ E_BAM_NOT_CONFIGURED = 1551, /**< BAM: Is not configured. */
+ E_BAM_ERR_UNSUPPORTED_PAGE_SIZE = 1552, /**< BAM: Unsupported page size. */
+ E_BAM_ERR_ERASING_BLOCK = 1553, /**< BAM: Erase block could not be properly erased. */
+ E_BAM_ERR_OUT_OF_MEMORY = 1554, /**< BAM: Not enough free memory to serve request. */
+ E_BAM_ERR_CHECKING_BADNESS = 1555, /**< BAM: There was a problem checking if a block was bad or not. */
+ E_BAM_ERR_FINDING_BLOCK = 1556, /**< BAM: Reserved block could not be found. */
+ E_BAM_ERR_READING_PAGE = 1557, /**< BAM: An error occurred while reading a page in a block. */
+ E_BAM_ERR_MARKING_BLOCK_BAD = 1558, /**< BAM: A block went bad and BAM could not mark it as bad properly. */
+ E_BAM_ERR_READING_OUTSIDE_BLOCK = 1559, /**< BAM: Read would result in a read beyond end of reserved block. */
+ E_BAM_ERR_UNCORRECTABLE_ERROR = 1560, /**< BAM: An uncorrectable read error occurred while reading block. */
+ E_BAM_ERR_WRITING_PAGE = 1561, /**< BAM: An error occurred while writing a page to a reserved block. */
+ E_BAM_ERR_WRITING_BLOCK = 1562, /**< BAM: An error occurred while writing to a reserved block. */
+ E_BAM_ERR_RESCUING_BLOCK = 1563, /**< BAM: There was a problem rescuing a block that went bad during the request. */
+ E_BAM_ERR_CONFIG_MISSING = 1564, /**< BAM: No configuration was given. */
+ E_BAM_ERR_ALREADY_STARTED = 1565, /**< BAM: Has already been started. */
+ E_BAM_ERR_NOT_STARTED = 1566, /**< BAM: Has not been started yet. */
+ E_BAM_ERR_UNSUPPORTED_OPERATION = 1567, /**< BAM: Requested operation is not supported. */
+ E_BAM_ERR_CORRUPT_STATE = 1568, /**< BAM: Internal state has been corrupted. */
+ E_BAM_ERR_UNSUPPORTED_MEDIA = 1569, /**< BAM: The configured media type is not supported. */
+ E_BAM_ERR_UNSUPPORTED_REDUNDANT_AREA_SIZE = 1570, /**< BAM: Unsupported redundant area size. */
+ E_BAM_ERR_READING_BLOCK = 1571, /**< BAM: Reading block failed. */
+ E_BAM_ERR_SHUTTING_DOWN = 1572, /**< BAM: Shutting down failed. */
+ E_BAM_ERR_UNINITIALIZING = 1573, /**< BAM: An error occurred with uninitializing. */
+ E_BAM_ERR_INVALID_OFFSET = 1574, /**< BAM: Invalid offset. */
+ E_BAM_ERR_INVALID_SIZE = 1575, /**< BAM: Invalid size. */
+ E_BAM_ERR_RETRIEVING_INFO = 1576, /**< BAM: Retrieving info failed. */
+ E_BAM_ERR_INVALID_CONFIG = 1577, /**< BAM: Invalid configuration. */
+ E_BAM_ERR_ERASING_ALL_BLOCKS = 1578, /**< BAM: An error occurred while erasing all blocks. */
+ E_BAM_ERR_BLOCK_MARKED_BAD = 1579, /**< BAM: Block was marked as bad while doing an operation. */
+ E_BAM_ERR_VALIDATING_START_BLOCK = 1580, /**< BAM: Can not assure that start block configuration refers to a block boundary. */
+ E_BAM_ERR_FAILED_TO_GET_MEMORYTECHNOLOGY = 1581, /**< BAM: Unable the query FAM about the memory technology used in the memory we are trying to initialize BAM on. */
+ E_BAM_ERR_BLOCK_RESCUED = 1582, /**< BAM: Block rescue failed. */
+ E_BAM_ERR_DETERMINING_BBM = 1583, /**< BAM: Failed to determine what BBM type configuration has been written to flash. */
+ E_BAM_ERR_SET_ECC_LENGTH = 1584, /**< BAM: Failed to set the length to use with HW ECC acceleration. */
+ E_BAM_ERR_INVALID_BBM_TYPE = 1585, /**< BAM: Invalid BBM type. */
+ E_BAM_ERR_BOOT_BDM_CONFIG_FAILED = 1586, /**< BAM: Failed to configure boot block device management. */
+ E_BAM_ERR_BOOT_BDM_STARTUP_FAILED = 1587, /**< BAM: Failed to startup boot block device management. */
+ E_BAM_ERR_BOOT_BDM_INSTANCE_NOT_FOUND = 1588, /**< BAM: Boot block device management instance not found. */
+ E_BAM_ERR_BOOT_BDM_BLOCKS_NOT_FOUND = 1589, /**< BAM: Boot block device management blocks not found. */
+ E_BAM_ERR_BOOT_BDM_NOT_STARTED = 1590, /**< BAM: Boot block device management not started. Requested operation require BDM to be started. */
+ E_BAM_ERR_UNIT_OUT_OF_RANGE = 1591, /**< BAM: Unit is out of range. */
+ E_BAM_ERR_BDM_STARTUP_FAILED = 1592, /**< BAM: Block device management startup failed. */
+ E_BAM_ERR_BLOCK_NOT_ERASED = 1593, /**< BAM: Block not erased. */
+ E_BAM_ONLD_CRITICAL_ERROR = 1601, /**< BAM ONLD: Critical error. */
+ E_BAM_ONLD_INVALID_PARAMS = 1602, /**< BAM ONLD: Invalid parameters. */
+ E_BAM_ONLD_INITIALISATION_ERROR = 1603, /**< BAM ONLD: Initialisation error. */
+ E_BAM_ONLD_READ_ERROR = 1604, /**< BAM ONLD: An error occurred while reading. */
+ E_BAM_ONLD_WRITE_ERROR = 1605, /**< BAM ONLD: An error occurred while writing. */
+ E_BAM_ONLD_ERASE_ERROR = 1606, /**< BAM ONLD: An error occurred while erasing. */
+ E_BAM_ONLD_DEVICE_ERROR = 1607, /**< BAM ONLD: Device error. */
+ E_BAM_ONLD_GOODBLOCK = 1608, /**< BAM ONLD: Good block. */
+ E_BAM_ONLD_BADBLOCK = 1609, /**< BAM ONLD: Bad block. */
+ E_COPS_MEMORY_ALLOC_FAILED = 1651, /**< COPS: Memory allocation failed. */
+ E_COPS_DATA_TAMPERED = 1652, /**< COPS: Data is tempered. */
+ E_COPS_IMEI_MISSMATCH = 1653, /**< COPS: IMEI missmatch. */
+ E_COPS_OTP_LOCKED = 1654, /**< COPS: OTP is locked. */
+ E_COPS_MAC_FUNCTION_LOCKED_DOWN = 1655, /**< COPS: Function for calculating MAC is locked down. */
+ E_COPS_AUTHENTICATION_FAILED = 1656, /**< COPS: Authentication failed. */
+ E_COPS_DATA_NOT_PRESENT = 1657, /**< COPS: Default Data is not present. */
+ E_COPS_IMEI_UPDATE_NOT_ALLOWED = 1658, /**< COPS: IMEI update is not allowed. */
+ E_COPS_LOCK_PERMANENTLY_DISABLED = 1659, /**< COPS: Locking of SIMLocks is disabled. */
+ E_COPS_NO_ATTEMPTS_LEFT = 1660, /**< COPS: No more attempts for verification left. */
+ E_COPS_INCORRECT_CONTROLKEY = 1661, /**< COPS: Control key is not correct. */
+ E_COPS_TOO_SHORT_CONTROLKEY = 1662, /**< COPS: Control key is too short. */
+ E_COPS_TOO_LONG_CONTROLKEY = 1663, /**< COPS: Control key is too long. */
+ E_COPS_INVALID_CONTROLKEY = 1664, /**< COPS: Control key is not valid. */
+ E_COPS_TIMER_RUNNING = 1665, /**< COPS: Timer is running. */
+ E_COPS_SIM_ERROR = 1666, /**< COPS: SIM error. */
+ E_COPS_LOCKING_FAILED = 1667, /**< COPS: Locking failed. */
+ E_COPS_OTA_UNLOCK_IMEI_MISMATCH = 1668, /**< COPS: OTA unlock IMEI mismatch. */
+ E_COPS_INCORRECT_IMSI = 1669, /**< COPS: Incorrect IMSI. */
+ E_COPS_PARAMETER_ERROR = 1670, /**< COPS: Parameter error. */
+ E_COPS_BUFFER_TOO_SMALL = 1671, /**< COPS: Memory buffer is too small. */
+ E_COPS_FORBIDDEN_PARAMETER_ID = 1672, /**< COPS: Parameter is not allowed. */
+ E_COPS_UNKNOWN_PARAMETER_ID = 1673, /**< COPS: Parameter can not be recognised. */
+ E_COPS_ARGUMENT_ERROR = 1674, /**< COPS: Argument error! */
+ E_COPS_VERIFY_FAILED = 1698, /**< COPS: Failed to verify internal data. */
+ E_COPS_UNDEFINED_ERROR = 1699, /**< COPS: Undefined error. */
+ E_PD_NAND_RESULT_BIT_ERROR_CORRECTED = 1751, /**< PD NAND: A bit error was detected and corrected. */
+ E_PD_NAND_RESULT_UNCORRECTABLE_BIT_ERROR = 1752, /**< PD NAND: An uncorrectable bit error was detected. */
+ E_PD_NAND_RESULT_BAD_PARAMETER = 1753, /**< PD NAND: The function could not perform the requested operation due to a bad parameter. */
+ E_PD_NAND_RESULT_HW_ERROR = 1754, /**< PD NAND: A hardware error occurred. */
+ E_PD_NAND_RESULT_INTERNAL_ERROR = 1755, /**< PD NAND: A module internal error has occurred. The module has reach an unexpected state or request. */
+ E_PD_NAND_RESULT_BUSY = 1756, /**< PD NAND: Busy flag was returned. */
+ E_PD_NAND_RESULT_READING_ERASED_PAGE = 1757, /**< PD NAND: Attempting to read erased page. */
+ E_PD_NAND_RESULT_NUMBER_OF_ITEMS = 1758, /**< PD NAND: Number of valid states of this type. */
+ E_PD_NAND_RESULT_UNDEFINED = 1759, /**< PD NAND: Represents an undefined value of this type. */
+ E_GD_TA_BASE = 1851, /**< GD/TA: TA base. */
+ E_GD_TA_UNKNOWN_PARTITION = 1852, /**< GD/TA: Unknown partition. */
+ E_GD_TA_UNKNOWN_CONFIG = 1853, /**< GD/TA: Unknown configuration. */
+ E_GD_TA_ILLOGICAL_CONFIGURATION = 1854, /**< GD/TA: Ilogical configuration. */
+ E_GD_TA_UNKNOWN_MEMORY_TYPE = 1855, /**< GD/TA: Unknown memory type. */
+ E_GD_TA_WRONG_PARAMETER = 1856, /**< GD/TA: Wrong parameter. */
+ E_GD_TA_OUT_OF_MEMORY = 1857, /**< GD/TA: Out of memory. */
+ E_GD_TA_INVALID_ADRESS = 1858, /**< GD/TA: Invalid adress. */
+ E_GD_TA_UNUSED_ADRESS = 1859, /**< GD/TA: Unused adress. */
+ E_GD_TA_UNIT_NOT_FOUND = 1860, /**< GD/TA: Unit not found. */
+ E_GD_TA_NOT_IMPLEMENTED = 1861, /**< GD/TA: TA is not supported. */
+ E_GD_TA_FAIL = 1862, /**< GD/TA: TA fail. */
+ E_GD_UNKNOWN_UNIT_NAME = 1863, /**< GD: Unknown unit name. */
+ E_GD_LAST = 1864, /**< GD: Last enumeration (last valid + 1). */
+ E_FAILED_TO_STORE_IN_FIFO = 1900, /**< Failed to store data in FIFO. */
+ E_FAILED_TO_SET_COMM_DEVICES = 1951, /**< Failed to set parameters of communications devices. */
+ E_FAILED_TO_STORE_IN_STACK = 1952, /**< Failed to store in stack. */
+ E_ZIP_PARSER_FILE_NOT_FOUND = 1954, /**< The requested file is not found in the specified Zip archive. */
+ E_ELF_FILE_FORMAT = 1955, /**< The requested file is not an elf file. */
+ E_ELF_OPEN_SECTION = 1956, /**< Can not open elf section. */
+ E_NAME_TOO_LONG = 1957, /**< The name of parameter is too long. */
+ E_BOOTRECORDS_MISMATCH = 1958, /**< Error in boot records. */
+ E_BOOTRECORD_EMPTY = 1959, /**< Boot record is empty and operation cannot be executed. */
+ E_INVALID_BOOTRECORD_IMAGE = 1960, /**< Boot record image is not valid. */
+ E_BOOTRECORD_FULL = 1961, /**< Boot record has no space to accept new boot record. */
+ E_BOOTRECORD_NOT_EXIST = 1962, /**< Boot record not exist. */
+ E_BOOTRECORD_WRITE_FAILED = 1963, /**< Writing failed. */
+ E_BOOTRECORD_UNALIGNED_DATA = 1964, /**< Boot record data is unaligned. */
+ E_CONTENT_TYPE = 1965, /**< Content type to long. */
+ E_DEVICE_TYPE = 1966, /**< Device type to long. */
+ E_NUMBER_OF_TARGET_DEVICES = 1967, /**< Number of target devices to big. */
+ E_DESCRIPTION_TOO_LONG = 1968, /**< Description field too long. */
+ E_MODULE_NOT_FOUND = 2000, /**< Testing this module currently not supported in ADbg. */
+ E_MODULE_LIST_EMPTY = 2001, /**< There isn't any module available for testing. */
+ E_CASE_NOT_FOUND = 2002, /**< Specified case can not be found. */
+ E_CASE_LIST_EMPTY = 2003, /**< There isn't any test cases in specified module. */
+ E_INT_GROUP_NOT_FOUND = 2004, /**< Specified internal group can not be found. */
+ E_INT_GROUP_LIST_EMPTY = 2005, /**< There isn't any internal group. */
+ E_INT_FUNCTION_NOT_FOUND = 2006, /**< Specified interface function cannot be found. */
+ E_INT_FUNCTION_LIST_EMPTY = 2007, /**< There isn't any interface function in interface group. */
+ E_PRECONDITION_IS_ALREADY_SET = 2008, /**< Request for setting precondition that is already set. */
+ E_PRECONDITION_IS_NOT_SET = 2009, /**< Request to recover condition that is not changed. */
+ E_INIT_OTP_PD_FAILED = 2100, /**< */
+ E_READING_OTP_FAILED = 2101, /**< */
+ E_WRITTING_OTP_FAILED = 2102, /**< */
+ E_INVALID_CID_VALUE = 2103, /**< */
+ E_INIT_OTP_LD_FAILED = 2104, /**< */
+ E_OTP_AREA_LOCKED = 2105, /**< */
+ E_SEC_APP_PROPERTY_NOT_FOUND = 2251, /**< App property cannot be found. */
+ E_SEC_APP_IMEI_NOT_CHANGABLE = 2252, /**< IMEI not changeable. */
+ E_SEC_APP_OPERATION_DENIED = 2253, /**< Security operation denied. */
+ E_SEC_APP_UNABLE_TO_READ_BS_PARAMETERS = 2254, /**< Incorrect Boot Stage Parameter vector. */
+ E_SEC_APP_ROM_ERROR_CRITICAL = 2255, /**< Critical error in ROM has occurred. */
+ E_SEC_APP_ROM_ERROR = 2256, /**< Unexpected ROM error. */
+ E_SEC_APP_PATCH_EXISTS = 2257, /**< ROM Patch is already installed. */
+ E_SEC_APP_PATCH_REINSTALLED = 2258, /**< ROM Patch in Flash is reinstalled. */
+ E_SEC_APP_ROOTKEY_EXISTS = 2259, /**< ROM Patch is already installed. */
+ E_SEC_APP_ROOTKEY_REINSTALLED = 2260, /**< Root Key is reinstalled. */
+ E_TA_WRONG_PARTITION = 2351, /**< TA: Unknown partition. */
+ E_TA_ILLOGICAL_CONFIGURATION = 2352, /**< TA: Configuration error. */
+ E_TA_UNKNOWN_MEMORY_TYPE = 2353, /**< TA: Unsupported memory type. */
+ E_TA_WRONG_PARAMETER = 2354, /**< TA: Wrong parameter. */
+ E_TA_OUT_OF_MEMORY = 2355, /**< TA: No heap memory left. */
+ E_TA_INVALID_ADRESS = 2356, /**< TA: Invalid address. */
+ E_TA_UNUSED_ADRESS = 2357, /**< TA: Unused address. */
+ E_TA_UNIT_NOT_FOUND = 2358, /**< TA: Unit was not found. */
+ E_TA_WRONG_SIZE = 2359, /**< TA: Wrong size when reading unit. */
+ E_TA_INSUFFICIANT_SPACE = 2360, /**< TA: Not enough space to flush the Trim Area. */
+ E_TA_UNKNOWN_PARTITION = 2361, /**< TA: Unknown partition. */
+ E_TA_FAIL = 2362, /**< TA: Fail. */
+ E_TA_MEDIA_ERROR = 2460, /**< TA: Media error. */
+ E_TA_NOT_CONFIGURED = 2461, /**< TA: Error occurs during configuration. */
+ E_REQUEST_DENIED = 2500, /**< Request for change operation denied. */
+ E_UNDEFINED_CHANGE_OPERATION = 2501, /**< Requested change operation is not supported. */
+ E_PD_CFI_IN_PROGRESS = 2651, /**< PD CFI: The operation is in progress. Additional poll calls must be done. */
+ E_PD_CFI_UNKNOWN_REQUEST = 2652, /**< PD CFI: Type not recognized. */
+ E_PD_CFI_HARDWARE_ERROR = 2653, /**< PD CFI: Operation could not be completed because of a hardware malfunction. */
+ E_PD_CFI_NOT_SUPPORTED = 2654, /**< PD CFI: The driver does not implement the requested function. */
+ E_PD_CFI_PARAMETER_ERROR = 2655, /**< PD CFI: Invalid parameter value. */
+ E_PD_CFI_PROTECTED = 2656, /**< PD CFI: The requested flash address is protected from the requested type of access. */
+ E_PD_CFI_UNSUPPORTED_DEVICE = 2657, /**< PD CFI: Flash devices not supported by this driver. */
+ E_PD_CFI_OPERATION_COMPLETE = 2658, /**< PD CFI: Requested operation was not suspended as it has completed. */
+ E_LOADER_SEC_LIB_CHIP_ID_INVALID = 4000, /**< Invalid input parameters. */
+ E_LOADER_SEC_LIB_INVALID_PARAMETER_TO_FUNC = 4096, /**< Invalid input parameters. */
+ E_LOADER_SEC_LIB_FAILURE = 4120, /**< Failure. */
+ E_LOADER_SEC_LIB_HASH_LIST_HASH_FAILURE = 4121, /**< hash list verification failed. */
+ E_LOADER_SEC_LIB_HEADER_VERIFICATION_FAILURE = 4122, /**< Header verification failed. */
+ E_LOADER_SEC_LIB_HEADER_VERIFIED = 4123, /**< Successful verification of the header */
+ E_LOADER_SEC_LIB_VERIFY_FAILURE = 4124, /**< Unsuccessful verification. */
+ E_LOADER_SEC_LIB_INIT_CALLED_TWICE = 4150, /**< The security library init function has been called 2 times. */
+ E_LOADER_SEC_LIB_MEMORY_RELEASE_FAILED = 4180, /**< Memory release failed. */
+ E_LOADER_SEC_LIB_MEMORY_ALLOCATION_FAILED = 4181, /**< Memory allocation failed. */
+ E_LOADER_SEC_LIB_DATA_BLOCK_EXIST = 4182, /**< Data block exist in the linked list. */
+ E_LOADER_SEC_LIB_DATA_BLOCK_DO_NOT_EXIST = 4183, /**< Data block do not exist in the linked list. */
+ E_LOADER_SEC_LIB_INVALID_AUTHENTICATION_TYPE = 4184, /**< Invalid authentication type. */
+ E_LOADER_SEC_LIB_EXCEEDED_NUMBER_OF_AUTHENTICATION = 4185, /**< Exceeded number of authentication. Loader will be shut downed. */
+ E_LOADER_SEC_LIB_ESB_MAC_INIT_FAILED = 4186, /**< Initialization of ESB block for MAC calculation failed. */
+ E_LOADER_SEC_LIB_ESB_MAC_UPDATE_FAILED = 4187, /**< MAC update with ESB block failed. */
+ E_LOADER_SEC_LIB_ESB_MAC_FINAL_FAILED = 4188, /**< MAC finalize with ESB block failed. */
+ E_LOADER_SEC_LIB_ESB_MAC_NOT_VERIFIED = 4189, /**< MAC verification with ESB block failed. */
+ E_LOADER_SEC_LIB_ESB_DOWNLOCK_FAILED = 4190, /**< ESB downlock failed. */
+ E_LOADER_SEC_LIB_CONTROL_KEY_VERIFICATION_FAILURE = 4191, /**< Control key verification failed. */
+ E_LOADER_SEC_LIB_CA_CERTIFICATE_VERIFICATION_FAILURE = 4192, /**< CA certificate verification failed. */
+ E_LOADER_SEC_LIB_X509_ERROR_IN_CERTIFICATE = 4193, /**< X509 certificate error. */
+ E_LOADER_SEC_LIB_COPS_INIT_FAILED = 4194, /**< COPS initialization failed. */
+ E_LOADER_SEC_LIB_COPS_PROTECT_DATA_INIT_FAILED = 4195, /**< COPS protect data initialization failed. */
+ E_LOADER_SEC_LIB_COPS_DATA_READ_FAILED = 4196, /**< COPS data read failed. */
+ E_LOADER_SEC_LIB_COPS_DATA_WRITE_FAILED = 4197, /**< COPS data write failed. */
+ E_LOADER_SEC_LIB_READ_OTP_FAILED = 4198, /**< Reading OTP data failed. */
+ E_LOADER_SEC_LIB_WRITE_OTP_FAILED = 4199, /**< Writing OTP data failed. */
+ E_LOADER_SEC_LIB_LOCK_OTP_FAILED = 4200, /**< Locking OTP data failed. */
+ E_LOADER_SEC_LIB_UNPACKING_IMEI_FAILED = 4201, /**< Unpacking IMEI data failed. */
+ E_LOADER_SEC_LIB_PACKING_IMEI_FAILED = 4202, /**< Packing IMEI data failed. */
+ E_LOADER_SEC_LIB_OTP_ALREADY_LOCKED = 4203, /**< OTP is already locked. */
+ E_LOADER_SEC_LIB_INVALID_CID_VALUE = 4204, /**< CID value is out of range. */
+ E_LOADER_SEC_LIB_OTP_LOCKBITS_MISSMATCH = 4205, /**< OTP lock bits have different values. */
+ E_LOADER_SEC_LIB_WRITING_BOOTRECORD_FAILED = 4206, /**< Failed to write in boot records. */
+ E_LOADER_SEC_LIB_UNSUPPORTED_NO_DEBUG_HW = 4207, /**< No debug hardware detected. */
+ E_LOADER_SEC_LIB_CHANGE_OPERATION_NOT_SUPPORTED = 4208, /**< Requested change operation is not supported or not allowed. */
+ E_LOADER_SEC_LIB_INVALID_CHANGE_OPERATION = 4209, /**< Invalid change operation. */
+ E_LOADER_SEC_LIB_RWIMEI_NOT_ALLOWED = 4210, /**< Rewriteable IMEI is not allowed to change. */
+ E_LOADER_SEC_LIB_REQUEST_DENIED = 4211, /**< Request for change operation is denied. */
+ E_LOADER_SEC_LIB_BOOT_BLOCK_DO_NOT_EXIST = 4212, /**< Boot record do not exist. */
+ E_LOADER_SEC_LIB_CORRUPTED_DOMAIN_DATA = 4213, /**< Corrupted or do not exist domain data in boot block. */
+ E_LOADER_SEC_LIB_INVALID_DOMAIN = 4214, /**< Invalid domain. */
+ E_FIFO_OVERFLOW = 4300, /**< */
+ E_FIFO_UNDERFLOW = 4301, /**< */
+ E_OBJECT_NULL = 4302, /**< */
+ E_POINTER_NOT_NULL = 4303, /**< */
+ E_UNRECOGNIZED_STATE = 4304, /**< */
+ E_UNKNOWN_MANUFACTURER_ID = 4305, /**< */
+ E_UNKNOWN_DEVICE_ID = 4306, /**< */
+ E_INVALID_A01_FORMAT = 4308, /**< */
+ E_A01_BUFFER_FULL = 4309, /**< */
+ E_CONFIG_FILE_NOT_SPECIFIED = 4350, /**< */
+ A2_E_SUCCESS = 5000, /**< Operation successful. */
+ A2_E_PROP_NOT_SUPPORTED = 5001, /**< The property is not supported. */
+ A2_E_PROP_READ_ONLY = 5002, /**< The property is read only. */
+ A2_E_PROP_INVALID = 5003, /**< The property value is invalid. */
+ A2_E_AUTH_DECLINED = 5004, /**< Authentication declined. The ME is automatically shut down after sending this. */
+ A2_E_AUTH_UNSUPPORTED = 5005, /**< The authentication type is not supported. */
+ A2_E_ALLOCATE_FAILED = 5006, /**< Failed to allocate memory. */
+ A2_E_INVALID_TIME = 5007, /**< Invalid time specified. */
+ A2_E_UNKNWON_PROPERTY = 5008, /**< Unknown property id. */
+ A2_E_START_AAIF_FAILED = 5009, /**< Failed to start the AAIF in the loader on loader. */
+ A2_E_UNSUPPORTED_CMD = 5010, /**< Unsupported command. */
+ A2_E_POINTER_NOT_ALIGNED = 5011, /**< Pointer not aligned. */
+ A2_E_ERROR_WRITING_BOOTRECORD = 5012, /**< Writing of the boot record failed. */
+ A2_E_INVALID_CURRDATE_STRING_LENGTH = 5013, /**< String data length is invalid. */
+ A2_E_NO_COMMAND_GROUPS_DEFINED = 5014, /**< Unknown command group. */
+ A2_E_READ_OTP_FAILED = 5015, /**< Read OTP failed. */
+ A2_E_COMMAND_IS_NOT_IMPLEMENTED = 5016, /**< Specified command is not implemented. */
+ A2_E_FAILED_TO_GET_ASIC_COPS_SETTINGS = 5017, /**< Failed to get ASIC COPS setting. */
+ A2_E_FAILED_TO_SET_PLAT_PROP = 5018, /**< Failed to set platform properties. */
+ A2_E_MEMORY_FAILED = 5019, /**< Memory fail. */
+ A2_E_JTAG_UNLOCK_FAILED = 5020, /**< JTAG unlock fail. */
+ A2_E_AUTOCONFIGURE_FLASH = 5021, /**< */
+ A2_E_E_GET_FIRST_FLASH_DEV = 5022, /**< */
+ A2_E_E_FAILED_INIT_COPS_LIB = 5023, /**< Failed to initialize COPS library. */
+ A2_E_OTP_SECURITY_ERROR = 5024, /**< OTP security error. */
+ A2_E_I2C_BUS_SECURITY_ERROR = 5025, /**< I2C bus security error. */
+ A2_E_GET_STATIC_DATA_FAILED = 5026, /**< Can't get static data. */
+ A2_E_STORE_MAC_TO_BOOTIMAGE_FAILED = 5027, /**< Failed to store MAC in boot image. */
+ A2_E_SEC_GENERAL_COPS_LIB_ERROR = 5028, /**< General COPS error. */
+ A2_E_HASH_VERIFICATION_ERROR = 5029, /**< Hash verification failed. */
+ A2_E_READ_FLASH_FAILED = 5030, /**< Failed to read hash. */
+ A2_E_APP_HANDSHAKE_FAILED = 5031, /**< Processors handshake failed. */
+ A2_E_BOOTIMAGE_MEMCONF_INVALID = 5032, /**< Invalid memconfig in boot image. */
+ A2_E_BOOTIMAGE_SIGNATURE_FAILED = 5033, /**< Boot image signature failed. */
+ A2_E_BOOTIMAGE_FAILED_TO_READ_IMAGE = 5034, /**< Failed to read image. */
+ A2_E_BOOTIMAGE_FAILED_ALLOCATE_MEM = 5035, /**< Failed to allocate memory. */
+ A2_E_BOOTIMAGE_INVALID_PARAM = 5036, /**< Boot image invalid parametars. */
+ A2_E_BOOTIMAGE_INVALID_LENGTH = 5037, /**< Boot image has invalid length. */
+ A2_E_BOOTIMAGE_MACED_HEADER_SIZE_ZERO = 5038, /**< Header size is zero. */
+ A2_E_FLASH_RESULT_DEVICE_PROTECTED = 5039, /**< The flash device was protected. */
+ A2_E_FLASH_RESULT_WRITE_SUSPENDED = 5040, /**< The last write process was suspended. */
+ A2_E_FLASH_RESULT_VOLTAGE_RANGE_ERROR = 5041, /**< The voltage range is invalid. */
+ A2_E_FLASH_RESULT_PROGRAM_ERROR = 5042, /**< Failed to write to the flash device. */
+ A2_E_FLASH_RESULT_ERASE_ERROR = 5043, /**< Failed to erase a block in the flash device. */
+ A2_E_FLASH_RESULT_ERASE_SUSPENDED = 5044, /**< The erase process was suspended. */
+ A2_E_FLASH_RESULT_COMMAND_SEQUENCE_ERROR = 5045, /**< The sequence of the flash commands was invalid. */
+ A2_E_FLASH_RESULT_OPERATION_NOT_SUPPORTED = 5046, /**< Operation was not supported in flashdriver. */
+ A2_E_FLASH_RESULT_INVALID_PARAMETER = 5047, /**< Invalid in-parameter specified when reading/writing to flash. */
+ A2_E_FLASH_RESULT_NO_FLASH_DEVICE = 5048, /**< No flash device was found on the physical address. */
+ A2_E_FLASH_RESULT_CONFIGURATION_ERROR = 5049, /**< Configuration error of flash device. */
+ A2_E_FLASH_RESULT_INVALID_STARTADDRESS = 5050, /**< Invalid start address of the parameter. */
+ A2_E_FLASH_RESULT_INVALID_PHYSICAL_ADDRESS = 5051, /**< Invalid physical address of the parameter. */
+ A2_E_FLASH_RESULT_INVALID_DATALENGTH = 5052, /**< The data length of the parameter is invalid. */
+ A2_E_FLASH_RESULT_GETREGION_ERROR = 5053, /**< Invalid flash region specified. */
+ A2_E_FLASH_RESULT_NULL_POINTER_BUF = 5054, /**< A buffer was NULL. */
+ A2_E_FLASH_RESULT_NAND_READ_FAILED = 5055, /**< Failed to read from the NAND flash. */
+ A2_E_FLASH_RESULT_NAND_PAGE_SIZE_UNSUPPORTED = 5056, /**< The nand page size is unsupported. */
+ A2_E_FLASH_RESULT_WRITE_ERROR = 5057, /**< Failed to write to the flash device. */
+ A2_E_FLASH_RESULT_READ_ID_ERROR = 5058, /**< Failed to read the device ID from the flash device. */
+ A2_E_FLASH_RESULT_HARDWARE_ERROR = 5059, /**< Hardware error in the flash status. */
+ A2_E_FLASH_RESULT_READ_FROM_FLASH = 5060, /**< Failed to read from the flash device. */
+ A2_E_FLASH_RESULT_ADD_NEW_DEVICE = 5061, /**< Failed to add a new instance of a flash device. */
+ A2_E_FLASH_RESULT_OTP_UNSUPPORTED_IN_FLASH = 5062, /**< OTP is not support in the current flash device. */
+ A2_E_FLASH_RESULT_OTP_TOO_SMALL = 5063, /**< The OTP size is to small for the length requested. */
+ A2_E_FLASH_RESULT_OTP_READ_FAILED = 5064, /**< Failed to read the OTP area in the flash device. */
+ A2_E_FLASH_RESULT_INVALID_FLASH_TYPE = 5065, /**< The flash type is unknown. */
+ A2_E_FLASH_RESULT_NAND_FLUSH_ERROR = 5066, /**< Failed to flush the NAND write buffer. */
+ A2_E_FLASH_RESULT_NOR_FLUSH_ERROR = 5067, /**< Failed to flush the NOR write buffer. */
+ A2_E_INVALID_LOL_STATE = 5068, /**< Invalid Loader on loader state. */
+ A2_E_INVALID_STATUS_LOLSTATE = 5069, /**< Invalid loader on loader status. */
+ A2_E_WRITE_STATIC_DATA = 5070, /**< Write static data failed. */
+ A2_E_HEADER_NOT_VERIFIED_YET = 5071, /**< Header is still not verified. */
+ A2_E_ALL_BLOCKS_VERIFIED_FAILED = 5072, /**< Blocks verification failed. */
+ A2_E_HANDSHAKE_WITH_APP_SIDE = 5073, /**< Handshake with App side failed. */
+ A2_E_READ_STATIC_DATA = 5074, /**< Failed to read static data. */
+ A2_E_ENABLE_CLOCK_HARDWARE_FAILED = 5075, /**< Failed to enable clock hardware. */
+ A2_E_ENABLE_BLOCK_HARDWARE_FAILED = 5076, /**< Failed to enable block hardware. */
+ A2_E_NO_HEADER_TO_MAC_IN_BOOT = 5077, /**< Indicates that the loader did not find any header in the bootimage records that could be MAC'ed. */
+ A2_E_MMU_SETUP = 5078, /**< MMU setup failed. */
+ A2_E_INVALID_COMMAND_SIZE = 5079, /**< Invalid command size. */
+ A2_E_HASH_LIST_LENGTH_INVALID = 5080, /**< Invalid hash list length. */
+ A2_E_INVALID_INPUT_PARAMETERS = 5081, /**< Invalid input parameters. */
+ A2_E_FAILED_SETUP_MSL_DRIVER = 5082, /**< MSL driver setup failed. */
+ A2_E_REQUEST_DENIED = 5083, /**< Request denied. */
+ A2_E_ASIC_FUSES_INVALID = 5084, /**< Fuses for the ASIC are invalid. */
+ A2_E_STATIC_DATA_NOT_CHECKED = 5085, /**< Static data is not checked. */
+ A2_E_COPS_DATA_MAN_INIT = 5086, /**< 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. */
+ A2_E_UART_DRIVER_ERROR = 5087, /**< UART driver error. */
+ A2_E_INVALID_DOMAIN_FOR_LOADER_TYPE = 5088, /**< Loader type is not compatible with this domain. */
+ A2_E_FUNCTIONALITY_NOT_IN_PRODUCT = 5089, /**< Functionality not supported. */
+ A2_E_DEFALT_DATA_NOT_FOUND = 5090, /**< Default data can not be found. */
+ A2_E_FAILED_TO_MAC_HEADER = 5091, /**< Failed to send the header to access side to be MAC'ed, could be something wrong with the header. */
+ A2_E_APP_PRELOADER_NOT_STARTED = 5092, /**< App preloader not started. */
+ A2_E_INVALID_DEST_ADDRESS = 5093, /**< Invalid destination address. */
+ A2_E_SYS_APP_INIT_FAILURE = 5094, /**< Failed to initialize the system application. */
+ A2_E_FLASH_APP_INIT_FAILURE = 5095, /**< Failed to initialize the flash application. */
+ A2_E_SIGNATURE_APP_INIT_FAILURE = 5096, /**< Failed to initialize the signature application. */
+ A2_E_RESET_APP_INIT_FAILURE = 5097, /**< Failed to initialize the reset application. */
+ A2_E_INT_SEC_APP_INIT_FAILURE = 5098, /**< Failed to initialize the internal security application. */
+ A2_E_COPS_DATA_MAN_FORMAT = 5099, /**< COPS data man Format. */
+ A2_E_COPS_DATA_MAN_WRITE = 5100, /**< COPS data man write. */
+ A2_E_COPS_DATA_MAN_FLUSH = 5101, /**< Failed to Flush the memory into the security partition. */
+ A2_E_COPS_DATA_MAN_GETBLOCKSIZE = 5102, /**< Failed to get the block size of a unit in the security partition. */
+ A2_E_COPS_DATA_MAN_READBLOCK = 5103, /**< Failed to read an index from the security partition. */
+ A2_E_INVALID_FLASH_VAR_LENGTH = 5104, /**< The bytes left to program should be less than a NAND page. */
+ A2_E_BOOTIMAGE_TOO_BIG = 5105, /**< Boot image is too big. */
+ A2_E_GDFS_APP_INIT_FAILURE = 5106, /**< App GD init failed. */
+ A2_E_FILESYS_APP_INIT_FAILURE = 5107, /**< Failed to initialize the file system. */
+ A2_E_INVALID_SOURCE_DEST_ADDRESS = 5108, /**< Invalid source or destination address. */
+ A2_E_INVALID_RESPONSE_COMMAND = 5109, /**< Invalid Response command number on the internal security command group, was expecting command 0xFF. */
+ A2_E_INVALID_RESP_TO_CMD = 5110, /**< The internal sec command response should have responded to another command. */
+ A2_E_VERIFICATION_OF_WRITTEN_DATA_FAILED = 5111, /**< The data programmed into flash was not the same as the data received! */
+ A2_E_INVALID_NAND_PADMUX_SETTING = 5112, /**< The PADMUX configuration has not been set. */
+ A2_E_FLASH_DRIVER_FAILED_SET_BOOT_ADDR = 5113, /**< Failed to set the start boot address, this address are used to read the static data. */
+ A2_E_FLASH_BOOT_IS_NOT_EMPTY = 5114, /**< if the static data was not found, the flash should be empty! */
+ A2_E_BOOTIMAGE_PMC_NOT_NEEDED = 5115, /**< This error code informs that found boot container holds information that is not PMC protected. */
+ A2_E_UNSUPPORTED_PMC = 5116, /**< The PMC ID is not supported. */
+ A2_E_FSVN_VS_PMC = 5117, /**< The PMC ID is not coordinated with FSVN. */
+ A2_E_WRONG_PMC_START_COUNT = 5118, /**< PMC start count to high or zero. */
+ A2_E_UNSUITABLE_PMC_FOR_LOCATION = 5119, /**< Unsuitable PMC for the location. */
+ A2_E_PMC_MISSING = 5120, /**< The PMC can not be found. */
+ A2_E_VERSION_NOT_ACCEPTED = 5121, /**< FSVN is too low. */
+ A2_E_PMC_OVERFLOWN = 5122, /**< All steps of the PMC are destroyed. */
+ A2_E_PMC_ONCE_REQUIRED = 5123, /**< New version of once protected module attempted to be loaded without ARB flag set. */
+ A2_E_PMC_BAD_N_OF_STEPS = 5124, /**< Unsuitable number of steps within PMC. */
+ A2_E_UNIT_MISSING = 5125, /**< Dynamyc variable is missing. */
+ A2_E_UNIT_TO_BIG = 5126, /**< Dynamyc variable found is to big. */
+ A2_E_PARTMAN_READ_ERROR = 5127, /**< Error reading partition manger status. */
+ A2_E_PARTMAN_INIT_ERROR = 5128, /**< Error initializing partition manger. */
+ A2_E_BOOTIMAGE_INVALID_ALLIGNMENT = 5129, /**< Boot container size is not word alligned. */
+ A2_E_BOOTIMAGE_INSUFFICIENT_CONTAINERS = 5130, /**< Not enough boot containers are allocated. */
+ A2_E_BOOTIMAGE_INVALID_CONTAINER_TYPE = 5131, /**< Invalid boot container type. At this position other type of container is expected. */
+ A2_E_DATA_LENGTH_IS_NOT_ALIGNED = 5132, /**< The data size must be aligned to 512 bytes when reading or writing pages to/from the NAND. */
+ A2_E_LOADER_SWINIT_JTAG_UNLOCK_FAILED = 5133, /**< TEST JTAG EANBLENODEBUG. */
+ A2_E_BOOTIMAGE_RECORD_NOT_FOUND = 5134, /**< Required record is not found in the boot containers. */
+ A2_E_BUFFER_OVERFLOW = 5135, /**< Buffer overflow. */
+ A2_E_BUFFER_NOT_ALLOCATED = 5136, /**< Buffer has not been allocated. */
+ A2_E_WRONG_DATA_SIZE = 5137, /**< Size of data has an unexpected value. */
+ A2_E_NO_STATIC_DATA_IN_BOOTIMAGE = 5138, /**< Static data in boot record is corrupted. */
+ A2_E_NOT_ALLOWED_TO_FLASH = 5139, /**< Not allowed to flash this block. */
+ A2_E_UNABLE_TO_CHANGE_MMU_SETTINGS = 5140, /**< Unable to change MMU settings. */
+ A2_E_INVALID_HW_FOR_LOADER_SETTINGS = 5141, /**< Loader settings are not compatible with loader settings. */
+ A2_E_CABS_START_FAILED = 5142, /**< */
+ A2_E_CABS_READ_ERROR = 5143, /**< */
+ A2_E_CABS_WRITE_ERROR = 5144, /**< */
+ A2_E_ELF_DECODE_GENERAL_ERROR = 5145, /**< */
+ A2_E_ELF_INVALID_PARAMETER = 5146, /**< */
+ A2_E_PARTMAN_INIT_FAILED = 5147, /**< */
+ A2_E_PARTMAN_WRITE_FAILED = 5148, /**< */
+ A2_E_PARTMAN_READ_FAILED = 5149, /**< */
+ A2_E_PARTMAN_ERASE_ERROR = 5150, /**< */
+ A2_E_MBBS_CONFIG_ERROR = 5151, /**< */
+ A2_E_MBBS_READ_ERROR = 5152, /**< */
+ A2_E_MBBS_WRITE_ERROR = 5153, /**< */
+ A2_E_MBBS_ERASE_ERROR = 5154, /**< */
+ A2_E_FLASH_HW_CONFIG = 5155, /**< */
+ A2_E_VSP_IS_NOT_ALLOWED = 5156, /**< Virtual security partition is not allowed in this configuration. */
+ A2_E_VSP_WRITE_STATIC_DATA = 5157, /**< Failed to write static data to virtual security partition. */
+ A2_E_VSP_READ_STATIC_DATA = 5158, /**< Failed to read static data from virtual security partition. */
+ A2_E_VSP_NOT_FORMATED = 5159, /**< Virtual security partition is not initialized. */
+ A2_E_VSP_UNSUPPORTED_UNIT_TYPE = 5160, /**< Unit type is out of range in virtual security partition. */
+ A2_E_GET_DYNAMIC_DATA_FAILED = 5161, /**< Could not get the dynamic data from the security library. */
+ A2_E_FLASH_RESULT_PARTITION_TABLE_FLASHED = 5162, /**< Partition table repaired!! Please load file again. */
+ A2_E_FLASH_RESULT_PARTITION_TABLE_NOT_FLASHED = 5163, /**< Partition table is damaged! */
+ A2_E_FLASH_RESULT_READ_FROM_PARTITION_TABLE = 5164, /**< Partition table is damaged. */
+ A2_E_BOOTIMAGE_PARTITION_RECORD_NOT_FOUND = 5165, /**< Partition table record is not found in the boot containers. */
+ A2_E_CORRUPT_STATIC_DATA_IN_BOOT_BLOCK = 5166, /**< Static data in boot block is corrupt. */
+ A2_E_MBBS_BBM_TYPE_CONFLICT = 5167, /**< MBBS and BBM type conflict. */
+ A2_E_EXECUTION_NOT_PERMITTED = 5168, /**< Execution of this command is not allowed in the current domain with current authentication state. */
+ A2_E_EXECUTION_NOT_PERMITTED_WARNING = 5169, /**< Execution of this command is not allowed in the current domain with current authentication state. */
+ A2_E_UNABLE_TO_INITIALIZE_LCD = 5171, /**< Error during initialization of LCD drivers. */
+ A2_E_LCD_NOT_INITIALIZED = 5172, /**< LCD is not initialized. */
+ A2_E_UNABLE_TO_DISPLAY_DATA_ON_LCD = 5173, /**< Unrecoverable error during BMP image is processed. */
+ A2_E_NETWORK_BUFFER_CORRUPTED = 5174, /**< The network buffer area is corrupted. */
+ A2_E_TOO_MENY_FRAGMENTS = 5200, /**< */
+ A2_E_FAILED_TO_GET_APPLICATION = 5201, /**< */
+ A2_E_SECURITY_LIBRARY_ERROR_BEGIN = 9096, /**< */
+ A2_E_SECURITY_LIBRARY_ERROR_END = 9300, /**< */
+ A2_E_UNSUPPORTED_PROPERTY = 5301, /**< Unsupported file system property. */
+ A2_E_READ_ONLY = 5302, /**< The property is read only. */
+ A2_E_INVALLID_PROPERTY_SPECIFIED = 5303, /**< The specified property value was invalid. */
+ A2_E_ACCESS_DENIED = 5304, /**< The access permission attributes do not allow operation. */
+ A2_E_FORMATTING_FS = 5305, /**< The file system is formatting. */
+ A2_E_PATH_NOT_EXISTS = 5306, /**< The path does not exist. */
+ A2_E_PATH_ALREADY_EXISTS = 5307, /**< The path already exists. */
+ A2_E_PATH_READ_ONLY = 5308, /**< The path is read only. */
+ A2_E_INSUFFICENT_SPACE = 5309, /**< Insufficient space. */
+ A2_E_DIRECTORY_NOT_EMPTY = 5310, /**< The directory is not empty. */
+ A2_E_INVALID_RESTRICTION_SPECIFIED = 5311, /**< Invalid access restrictions specified. */
+ A2_E_NO_FILESYSTEM_PROPERTY = 5312, /**< No file system property. */
+ A2_E_FILE_NOT_EXISTS = 5313, /**< The file does not exist. */
+ A2_E_CHANGE_DIR = 5314, /**< Failed to change directory. */
+ A2_E_CHMOD = 5315, /**< Failed to set new CH mod. */
+ A2_E_GWD = 5316, /**< Failed to get the current directory. */
+ A2_E_OPEN_FILE = 5317, /**< Failed to open a file in the file system. */
+ A2_E_ITEM_STAT = 5318, /**< Failed to read the stat from file. */
+ A2_E_LIST_VOL = 5319, /**< Failed to list volumes. */
+ A2_E_FREE_SPACE = 5320, /**< No free space left. */
+ A2_E_CLOSE_FILE = 5321, /**< Failed to close a file in the filesystem. */
+ A2_E_CLOSE_DIRECTORY = 5322, /**< Failed to close the directory. */
+ A2_E_REMOVE_FILE = 5323, /**< Failed to remove a file from the filesystem. */
+ A2_E_RENAME_FILE = 5324, /**< Failed to rename a file in the filesystem. */
+ A2_E_CREATE_DIR = 5325, /**< Failed to create a new directory in the filesystem. */
+ A2_E_REMOVE_DIRECTORY = 5326, /**< Failed to remove a directory from the file system. */
+ A2_E_WRITE_FILE = 5327, /**< Failed to write a file to the file system. */
+ A2_E_INVALID_SFA_STATE = 5328, /**< The state of the SFA programming is incorrect. */
+ A2_E_READ_FILE = 5329, /**< Failed to read a file from the file system. */
+ A2_E_CORE_SUPERV = 61797, /**< */
+ A2_E_MEM_ALLOC = 66166, /**< */
+ A2_E_GDFS_UNSUPPORTED_PROPERTY = 5401, /**< Unsupported GDFS property. */
+ A2_E_GDFS_READ_ONLY = 5402, /**< The GDFS property is read only. */
+ A2_E_GDFS_PROPERTY_VALUE_INVALID = 5403, /**< The property value is invalid. */
+ A2_E_GDFS_INVALID_START_PROPERTY = 5404, /**< Invalid start property. */
+ A2_E_GDFS_NOT_STARTED = 5405, /**< GDFS has not been started yet. */
+ A2_E_GDFS_FAILED_TO_FORMAT = 5406, /**< Failed to format the GDFS area. */
+ A2_E_GDFS_NOT_FORMATTED = 5407, /**< GDFS is not formatted, as it should be. */
+ A2_E_GDFS_INVALID_BLOCK_UNIT_SPECIFIED = 5408, /**< Invalid Block unit number. */
+ A2_E_GDFS_NO_CONFIGURATION_FOUND = 5409, /**< Could not find any GDFS configuration from the platform software in flash. */
+ A2_E_GDFS_CLOSE = 5410, /**< Failed to close the GDFS area. */
+ A2_E_GDFS_OPEN = 5411, /**< Failed to open the GDFS area. */
+ A2_E_GDFS_INVALID_UNIT_SIZE = 5412, /**< Invalid GDFS UNIT size(size=0). */
+ A2_E_GDFS_WRITE_TO_UNIT_FAILED = 5413, /**< Failed to write to the specified unit. */
+ A2_E_GDFS_FAILED_TO_READ_FROM_UNIT = 5414, /**< Failed to read from the specified unit. */
+ A2_E_GDFS_EMPTY = 5415, /**< Failed read access on an empty GDFS. */
+ A2_E_GENERAL_FATAL_ERROR = 70535, /**< */
+ E_DUMMY_CODE = 80009 /**< */
+} ErrorCode_e;
+
+#endif /* _ERRORCODE_H */
diff --git a/source/LCM/include/t_a2_protocol.h b/source/LCM/include/t_a2_protocol.h
new file mode 100755
index 0000000..23add7e
--- /dev/null
+++ b/source/LCM/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/source/LCM/include/t_basicdefinitions.h b/source/LCM/include/t_basicdefinitions.h
new file mode 100644
index 0000000..4d5b0ee
--- /dev/null
+++ b/source/LCM/include/t_basicdefinitions.h
@@ -0,0 +1,286 @@
+#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
+#elif defined(__linux__)
+#define SINT64_SUPPORTED
+#define UINT64_SUPPORTED
+#define INT64_BASE_TYPE long long
+#else
+#error "Unknown platform"
+#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_GNUC)
+/** 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/source/LCM/include/t_bulk_protocol.h b/source/LCM/include/t_bulk_protocol.h
new file mode 100644
index 0000000..fabc1a4
--- /dev/null
+++ b/source/LCM/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/source/LCM/include/t_command_protocol.h b/source/LCM/include/t_command_protocol.h
new file mode 100644
index 0000000..2ca51c6
--- /dev/null
+++ b/source/LCM/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/source/LCM/include/t_communication_service.h b/source/LCM/include/t_communication_service.h
new file mode 100644
index 0000000..74e72a9
--- /dev/null
+++ b/source/LCM/include/t_communication_service.h
@@ -0,0 +1,344 @@
+/*******************************************************************************
+ * 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 {
+ ErrorCode_e(*FamilyInit_fn)(Communication_t *Communication_p);
+ /**< Pointer to Interface function for protocol family initialization. */
+ ErrorCode_e(*FamilyShutdown_fn)(Communication_t *Communication_p);
+ /**< Pointer to Interface function for protocol family de-initialization. */
+ ErrorCode_e(*Process_fn)(Communication_t *Communication_p);
+ /**< Pointer to Pooling function in curren protocol family. */
+ ErrorCode_e(*Send_fn)(Communication_t *Communication_p, void *InputData_p);
+ /**< Pointer to function for sending packets.*/
+ ErrorCode_e(*SetProtocolTimeouts_fn)(Communication_t *Communication_p, void *TimeoutData_p);
+ /**< Pointer to function for setting communication timeouts for current protocol family. */
+ ErrorCode_e(*GetProtocolTimeouts_fn)(Communication_t *Communication_p, void *TimeoutData_p);
+ /**< Pointer to function for getting communication timeouts from current protocol family. */
+} FamilyDescriptor_t;
+
+/** @} */
+#endif // _INCLUSION_GUARD_T_COMMUNICATION_SERVICE_H_
+
diff --git a/source/LCM/include/t_protrom_header.h b/source/LCM/include/t_protrom_header.h
new file mode 100644
index 0000000..63ae6ef
--- /dev/null
+++ b/source/LCM/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/source/LCM/include/t_protrom_network.h b/source/LCM/include/t_protrom_network.h
new file mode 100644
index 0000000..c33deac
--- /dev/null
+++ b/source/LCM/include/t_protrom_network.h
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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_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];
+ /** 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/source/LCM/include/t_protrom_transport.h b/source/LCM/include/t_protrom_transport.h
new file mode 100644
index 0000000..20eef29
--- /dev/null
+++ b/source/LCM/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/source/LCM/include/t_queue.h b/source/LCM/include/t_queue.h
new file mode 100644
index 0000000..f6250b6
--- /dev/null
+++ b/source/LCM/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/source/LCM/include/t_r15_header.h b/source/LCM/include/t_r15_header.h
new file mode 100644
index 0000000..55b717b
--- /dev/null
+++ b/source/LCM/include/t_r15_header.h
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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"
+#include "command_ids.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 */
+ GroupId_e 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/source/LCM/include/t_r15_network_layer.h b/source/LCM/include/t_r15_network_layer.h
new file mode 100644
index 0000000..c99d073
--- /dev/null
+++ b/source/LCM/include/t_r15_network_layer.h
@@ -0,0 +1,309 @@
+/*******************************************************************************
+ * 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 (1000)
+/** Default time(mS) out for receiving bulk command */
+#define BULK_COMMAND_RECEIVING_TIMEOUT (1000)
+/** 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.*/
+} 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;
+ /** 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/source/LCM/include/t_security_algorithms.h b/source/LCM/include/t_security_algorithms.h
new file mode 100644
index 0000000..5bae6c1
--- /dev/null
+++ b/source/LCM/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/source/LCM/include/t_time_utilities.h b/source/LCM/include/t_time_utilities.h
new file mode 100644
index 0000000..bcc8254
--- /dev/null
+++ b/source/LCM/include/t_time_utilities.h
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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. */
+} 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/source/LcmInterface.cpp b/source/LcmInterface.cpp
new file mode 100644
index 0000000..5b07ed5
--- /dev/null
+++ b/source/LcmInterface.cpp
@@ -0,0 +1,260 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include "lcdriver_error_codes.h"
+#include "LcmInterface.h"
+#include "Error.h"
+#ifdef _WIN32
+#include "WinApiWrappers.h"
+#else
+#include "LinuxApiWrappers.h"
+#include <dlfcn.h>
+#define GetProcAddress dlsym
+#endif
+
+char *LcmInterface::m_pchLCMLibPath = 0;
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+//***********************************************************************************************
+// Name: LcmInterface()
+// Desc: Constructor.
+//**********************************************************************************************/
+LcmInterface::LcmInterface() : m_pCommunication(NULL) , lcmError_(E_SUCCESS)
+{
+}
+
+//***********************************************************************************************
+// Name: ~LcmInterface()
+// Desc: Destructor.
+//**********************************************************************************************/
+LcmInterface::~LcmInterface()
+{
+}
+
+HMODULE LcmInterface::m_hDLL = 0;
+R15BulkInterface_t LcmInterface::R15Bulk;
+R15CommandInterface_t LcmInterface::R15Command;
+A2CommandInterface_t LcmInterface::A2Command;
+CommunicationInterface_t LcmInterface::Communication;
+CCriticalSectionObject LcmInterface::m_CriticalSection;
+
+//***********************************************************************************************
+// Name: RunOnce()
+// Desc: Load LCM module and initialize function pointers once only.
+//**********************************************************************************************/
+int LcmInterface::LoadLCMLibrary()
+{
+ if (m_pchLCMLibPath == NULL) {
+#ifdef _WIN32
+ m_hDLL = LoadLibrary("LCM");
+#else
+ m_hDLL = dlopen("./lcm_linux/liblcm.so.1", RTLD_LAZY);
+#endif
+ } else {
+#ifdef _WIN32
+ m_hDLL = LoadLibrary(m_pchLCMLibPath);
+#else
+ m_hDLL = dlopen(m_pchLCMLibPath, RTLD_LAZY);
+#endif
+ }
+
+ if (m_hDLL == NULL) {
+ return LCM_DLL_LOAD_LOADLIBRARY_ERROR;
+ }
+
+ // Link to all necessary methods in the LCM DLL
+ Communication.Initialize_Fn = (CommunicationInitialize_t)GetProcAddress(m_hDLL, "Do_Communication_Initialize");
+ Communication.Shutdown_Fn = (CommunicationShutdown_t)GetProcAddress(m_hDLL, "Do_Communication_Shutdown");
+ Communication.Poll_Fn = (CommunicationPoll_t)GetProcAddress(m_hDLL, "Do_Communication_Poll");
+ Communication.SetFamily_Fn = (CommunicationSetFamily_t)GetProcAddress(m_hDLL, "Do_Communication_SetFamily");
+ Communication.Send_Fn = (CommunicationSend_t)GetProcAddress(m_hDLL, "Do_Communication_Send");
+ Communication.SetProtocolTimeouts_Fn = (CommunicationSetProtocolTimeouts_t)GetProcAddress(m_hDLL, "Do_Communication_SetProtocolTimeouts");
+ Communication.GetProtocolTimeouts_Fn = (CommunicationGetProtocolTimeouts_t)GetProcAddress(m_hDLL, "Do_Communication_GetProtocolTimeouts");
+ Communication.CancelReceiver_Fn = (CommunicationCancelReceiver_t)GetProcAddress(m_hDLL, "Do_Communication_Cancel_Receiver");
+
+ R15Command.Send_Fn = (R15CommandSend_t)GetProcAddress(m_hDLL, "Do_R15_Command_Send");
+ R15Command.ResetSessionCounters_Fn = (R15CommandResetSessionCounters_t)GetProcAddress(m_hDLL, "Do_R15_Command_ResetSessionCounters");
+
+ R15Bulk.OpenSession_Fn = (R15BulkOpenSession_t)GetProcAddress(m_hDLL, "Do_R15_Bulk_OpenSession");
+ R15Bulk.CreateVector_Fn = (R15BulkCreateVector_t)GetProcAddress(m_hDLL, "Do_R15_Bulk_CreateVector");
+ R15Bulk.DestroyVector_Fn = (R15BulkDestroyVector_t)GetProcAddress(m_hDLL, "Do_R15_Bulk_DestroyVector");
+ R15Bulk.StartSession_Fn = (R15BulkStartSession_t)GetProcAddress(m_hDLL, "Do_R15_Bulk_StartSession");
+ R15Bulk.GetStatusSession_Fn = (R15BulkGetStatusSession_t)GetProcAddress(m_hDLL, "Do_R15_Bulk_GetStatusSession");
+ R15Bulk.CloseSession_Fn = (R15BulkCloseSession_t)GetProcAddress(m_hDLL, "Do_R15_Bulk_CloseSession");
+ R15Bulk.SetCallbacks_Fn = (R15BulkSetCallbacks_t)GetProcAddress(m_hDLL, "Do_R15_Bulk_SetCallbacks");
+
+ A2Command.Send_Fn = (A2CommandSend_t)GetProcAddress(m_hDLL, "Do_A2_Command_Send");
+ A2Command.SpeedflashStart_Fn = (A2SpeedflashStart_t)GetProcAddress(m_hDLL, "Do_A2_Speedflash_Start");
+ A2Command.SpeedflashSetLastBlock_Fn = (A2SpeedflashSetLastBlock_t)GetProcAddress(m_hDLL, "Do_A2_Speedflash_SetLastBlock");
+ A2Command.SpeedflashWriteBlock_Fn = (A2SpeedflashWriteBlock_t)GetProcAddress(m_hDLL, "Do_A2_Speedflash_WriteBlock");
+
+ if (
+ Communication.Initialize_Fn == 0 ||
+ Communication.Shutdown_Fn == 0 ||
+ Communication.Poll_Fn == 0 ||
+ Communication.SetFamily_Fn == 0 ||
+ Communication.Send_Fn == 0 ||
+ Communication.SetProtocolTimeouts_Fn == 0 ||
+ Communication.GetProtocolTimeouts_Fn == 0 ||
+ R15Command.Send_Fn == 0 ||
+ R15Command.ResetSessionCounters_Fn == 0 ||
+ R15Bulk.OpenSession_Fn == 0 ||
+ R15Bulk.CreateVector_Fn == 0 ||
+ R15Bulk.DestroyVector_Fn == 0 ||
+ R15Bulk.StartSession_Fn == 0 ||
+ R15Bulk.GetStatusSession_Fn == 0 ||
+ R15Bulk.CloseSession_Fn == 0 ||
+ R15Bulk.SetCallbacks_Fn == 0 ||
+ A2Command.Send_Fn == 0 ||
+ A2Command.SpeedflashStart_Fn == 0 ||
+ A2Command.SpeedflashSetLastBlock_Fn == 0 ||
+ A2Command.SpeedflashWriteBlock_Fn == 0
+ ) {
+ return LCM_DLL_LOAD_FUNCTION_NOT_FOUND;
+ }
+
+ return E_SUCCESS;
+}
+
+void LcmInterface::SetLCMLibPath(const char *lcmLibPath)
+{
+ size_t pathLength = strlen(lcmLibPath);
+
+ if (0 != m_pchLCMLibPath) {
+ delete[] m_pchLCMLibPath;
+ }
+
+ m_pchLCMLibPath = new char[pathLength + 1];
+ strcpy_s(m_pchLCMLibPath, pathLength + 1, lcmLibPath);
+ m_pchLCMLibPath[pathLength] = '\0';
+}
+
+void LcmInterface::CloseLCMLibrary()
+{
+ if (0 != m_pchLCMLibPath) {
+ delete[] m_pchLCMLibPath;
+ }
+
+#ifdef _WIN32
+ FreeLibrary(m_hDLL);
+#else
+ dlclose(m_hDLL);
+#endif
+}
+
+ErrorCode_e LcmInterface::CommunicationInitialize(void *Object_p, 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)
+{
+ int ReturnValue = E_SUCCESS;
+
+ if (m_hDLL == NULL) {
+ CLockCS lock(m_CriticalSection);
+
+ if (m_hDLL == NULL) {
+ VERIFY_SUCCESS(LoadLCMLibrary());
+ }
+ }
+
+ ReturnValue = Communication.Initialize_Fn(Object_p, &m_pCommunication, Family, HashDevice_p, CommunicationDevice_p, CommandCallback_p, Buffers_p, Timers_p, Queue_p);
+
+ErrorExit:
+ return static_cast<ErrorCode_e>(ReturnValue);
+}
+
+ErrorCode_e LcmInterface::CommunicationSend(void *InputData_p)
+{
+ return Communication.Send_Fn(m_pCommunication, InputData_p);
+}
+
+ErrorCode_e LcmInterface::CommunicationSetFamily(Family_t family, Do_CEH_Call_t CEHCallback)
+{
+ return Communication.SetFamily_Fn(m_pCommunication, family, CEHCallback);
+}
+
+ErrorCode_e LcmInterface::CommunicationSetProtocolTimeouts(void *TimeoutData_p)
+{
+ return Communication.SetProtocolTimeouts_Fn(m_pCommunication, TimeoutData_p);
+}
+
+ErrorCode_e LcmInterface::CommunicationGetProtocolTimeouts(void *TimeoutData_p)
+{
+ return Communication.GetProtocolTimeouts_Fn(m_pCommunication, TimeoutData_p);
+}
+
+ErrorCode_e LcmInterface::CommunicationShutdown()
+{
+ return Communication.Shutdown_Fn(&m_pCommunication);
+}
+
+ErrorCode_e LcmInterface::CommunicationCancelReceiver(uint8 PacketsBeforeReceiverStop)
+{
+ return Communication.CancelReceiver_Fn(m_pCommunication, PacketsBeforeReceiverStop);
+}
+ErrorCode_e LcmInterface::CommandSend(CommandData_t *CmdData_p)
+{
+ return R15Command.Send_Fn(m_pCommunication, CmdData_p);
+}
+
+ErrorCode_e LcmInterface::CommunicationPoll()
+{
+ return Communication.Poll_Fn(m_pCommunication);
+}
+
+ErrorCode_e LcmInterface::CommandResetSessionCounters()
+{
+ return R15Command.ResetSessionCounters_Fn(m_pCommunication);
+}
+
+void LcmInterface::BulkSetCallbacks(void *BulkCommandCallback_p, void *BulkDataCallback_p, void *BulkDataEndOfDump_p)
+{
+ R15Bulk.SetCallbacks_Fn(m_pCommunication, BulkCommandCallback_p, BulkDataCallback_p, BulkDataEndOfDump_p);
+}
+
+uint32 LcmInterface::BulkOpenSession(const uint16 SessionId, const TL_SessionMode_t Mode, uint32 Length)
+{
+ return R15Bulk.OpenSession_Fn(m_pCommunication, SessionId, Mode, Length);
+}
+
+TL_BulkVectorList_t *LcmInterface::BulkCreateVector(const uint32 BulkVector, uint32 Length, const uint32 BuffSize, TL_BulkVectorList_t *CreatedBulkVector_p)
+{
+ return R15Bulk.CreateVector_Fn(m_pCommunication, BulkVector, Length, BuffSize, CreatedBulkVector_p);
+}
+
+ErrorCode_e LcmInterface::BulkStartSession(TL_BulkVectorList_t *BulkVector_p, const uint64 Offset)
+{
+ return R15Bulk.StartSession_Fn(m_pCommunication, BulkVector_p, Offset);
+}
+
+uint32 LcmInterface::BulkDestroyVector(TL_BulkVectorList_t *BulkVector_p, boolean ReqReleaseBuffer)
+{
+ return R15Bulk.DestroyVector_Fn(m_pCommunication, BulkVector_p, ReqReleaseBuffer);
+}
+
+ErrorCode_e LcmInterface::BulkCloseSession(TL_BulkVectorList_t *BulkVector_p)
+{
+ return R15Bulk.CloseSession_Fn(m_pCommunication, BulkVector_p);
+}
+
+ErrorCode_e LcmInterface::A2CommandSend(A2_CommandData_t *CmdData_p)
+{
+ return A2Command.Send_Fn(m_pCommunication, CmdData_p);
+}
+
+void LcmInterface::A2SpeedflashStart()
+{
+ A2Command.SpeedflashStart_Fn(m_pCommunication);
+}
+
+void LcmInterface::A2SpeedflashSetLastBlock()
+{
+ A2Command.SpeedflashSetLastBlock_Fn(m_pCommunication);
+}
+
+ErrorCode_e LcmInterface::A2SpeedflashWriteBlock(const void *Buffer, const size_t BufferSize)
+{
+ return A2Command.SpeedflashWriteBlock_Fn(m_pCommunication, Buffer, BufferSize);
+}
diff --git a/source/LcmInterface.h b/source/LcmInterface.h
new file mode 100644
index 0000000..074cdda
--- /dev/null
+++ b/source/LcmInterface.h
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _LCMINTERFACE_H_
+#define _LCMINTERFACE_H_
+
+#include "t_communication_service.h"
+#include "t_bulk_protocol.h"
+#include "t_a2_protocol.h"
+
+#ifdef _WIN32
+#include "WinApiWrappers.h"
+#else
+#include "LinuxApiWrappers.h"
+typedef void *HMODULE;
+#endif
+
+typedef ErrorCode_e(*CommunicationInitialize_t)(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);
+typedef ErrorCode_e(*CommunicationShutdown_t)(Communication_t **Communication_pp);
+typedef ErrorCode_e(*CommunicationPoll_t)(Communication_t *Communication_p);
+typedef ErrorCode_e(*CommunicationSetFamily_t)(Communication_t *Communication_p, Family_t Family, Do_CEH_Call_t CEHCallback);
+typedef ErrorCode_e(*CommunicationSend_t)(Communication_t *Communication_p, void *InputData_p);
+typedef ErrorCode_e(*CommunicationSetProtocolTimeouts_t)(Communication_t *Communication_p, void *TimeoutData_p);
+typedef ErrorCode_e(*CommunicationGetProtocolTimeouts_t)(Communication_t *Communication_p, void *TimeoutData_p);
+typedef ErrorCode_e(*CommunicationCancelReceiver_t)(Communication_t *Communication_p, uint8 PacketsBeforeTransferStop);
+
+typedef ErrorCode_e(*R15CommandSend_t)(Communication_t *Communication_p, CommandData_t *CmdData_p);
+typedef ErrorCode_e(*R15CommandResetSessionCounters_t)(const Communication_t *const Communication_p);
+
+typedef ErrorCode_e(*R15BulkStartSession_t)(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p, const uint64 Offset);
+typedef ErrorCode_e(*R15BulkCloseSession_t)(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p);
+typedef TL_BulkVectorList_t*(*R15BulkCreateVector_t)(const Communication_t *const Communication_p, const uint32 BulkVector, uint32 Length, const uint32 BuffSize, TL_BulkVectorList_t *CreatedBulkVector_p);
+typedef TL_BulkSessionState_t (*R15BulkGetStatusSession_t)(const Communication_t *const Communication_p, const TL_BulkVectorList_t *BulkVector_p);
+typedef uint32(*R15BulkDestroyVector_t)(const Communication_t *const Communication_p, TL_BulkVectorList_t *BulkVector_p, boolean ReqReleaseBuffer);
+typedef uint32(*R15BulkOpenSession_t)(const Communication_t *const Communication_p, const uint16 SessionId, const TL_SessionMode_t Mode, uint32 Length);
+typedef void (*R15BulkSetCallbacks_t)(Communication_t *Communication_p, void *BulkCommandCallback_p, void *BulkDataCallback_p, void *BulkDataEndOfDump_p);
+
+typedef ErrorCode_e(*A2CommandSend_t)(Communication_t *Communication_p, A2_CommandData_t *CmdData_p);
+typedef void (*A2SpeedflashStart_t)(Communication_t *Communication_p);
+typedef void (*A2SpeedflashSetLastBlock_t)(Communication_t *Communication_p);
+typedef ErrorCode_e(*A2SpeedflashWriteBlock_t)(Communication_t *Communication_p, const void *Buffer, const size_t BufferSize);
+
+typedef struct {
+ CommunicationInitialize_t Initialize_Fn;
+ CommunicationShutdown_t Shutdown_Fn;
+ CommunicationPoll_t Poll_Fn;
+ CommunicationSetFamily_t SetFamily_Fn;
+ CommunicationSend_t Send_Fn;
+ CommunicationSetProtocolTimeouts_t SetProtocolTimeouts_Fn;
+ CommunicationGetProtocolTimeouts_t GetProtocolTimeouts_Fn;
+ CommunicationCancelReceiver_t CancelReceiver_Fn;
+} CommunicationInterface_t;
+
+typedef struct {
+ R15CommandSend_t Send_Fn;
+ R15CommandResetSessionCounters_t ResetSessionCounters_Fn;
+} R15CommandInterface_t;
+
+typedef struct {
+ R15BulkStartSession_t StartSession_Fn;
+ R15BulkCloseSession_t CloseSession_Fn;
+ R15BulkCreateVector_t CreateVector_Fn;
+ R15BulkGetStatusSession_t GetStatusSession_Fn;
+ R15BulkDestroyVector_t DestroyVector_Fn;
+ R15BulkOpenSession_t OpenSession_Fn;
+ R15BulkSetCallbacks_t SetCallbacks_Fn;
+} R15BulkInterface_t;
+
+typedef struct {
+ A2CommandSend_t Send_Fn;
+ A2SpeedflashStart_t SpeedflashStart_Fn;
+ A2SpeedflashSetLastBlock_t SpeedflashSetLastBlock_Fn;
+ A2SpeedflashWriteBlock_t SpeedflashWriteBlock_Fn;
+} A2CommandInterface_t;
+
+class LcmInterface
+{
+public:
+ LcmInterface();
+ virtual ~LcmInterface();
+
+ ErrorCode_e CommunicationInitialize(void *Object_p, 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 CommunicationPoll();
+ ErrorCode_e CommunicationSend(void *InputData_p);
+ ErrorCode_e CommunicationSetFamily(Family_t family, Do_CEH_Call_t CEHCallback);
+ ErrorCode_e CommunicationSetProtocolTimeouts(void *TimeoutData_p);
+ ErrorCode_e CommunicationGetProtocolTimeouts(void *TimeoutData_p);
+ ErrorCode_e CommunicationShutdown();
+ ErrorCode_e CommunicationCancelReceiver(uint8 PacketsBeforeReceiverStop);
+
+ ErrorCode_e CommandSend(CommandData_t *CmdData_p);
+ ErrorCode_e CommandResetSessionCounters();
+
+ void BulkSetCallbacks(void *BulkCommandCallback_p, void *BulkDataCallback_p, void *BulkDataEndOfDump_p);
+ uint32 BulkOpenSession(const uint16 SessionId, const TL_SessionMode_t Mode, uint32 Length);
+ TL_BulkVectorList_t *BulkCreateVector(const uint32 BulkVector, uint32 Length, const uint32 BuffSize, TL_BulkVectorList_t *CreatedBulkVector_p);
+ ErrorCode_e BulkStartSession(TL_BulkVectorList_t *BulkVector_p, const uint64 Offset);
+ uint32 BulkDestroyVector(TL_BulkVectorList_t *BulkVector_p, boolean ReqReleaseBuffer);
+ ErrorCode_e BulkCloseSession(TL_BulkVectorList_t *BulkVector_p);
+
+ ErrorCode_e A2CommandSend(A2_CommandData_t *CmdData_p);
+ void A2SpeedflashStart();
+ void A2SpeedflashSetLastBlock();
+ ErrorCode_e A2SpeedflashWriteBlock(const void *Buffer, const size_t BufferSize);
+
+ void *getLCMContext() {
+ return m_pCommunication;
+ }
+private:
+ Communication_t *m_pCommunication;
+ ErrorCode_e lcmError_;
+public:
+ static void SetLCMLibPath(const char *lcmLibPath);
+ static int LoadLCMLibrary();
+ static void CloseLCMLibrary();
+private:
+ static CommunicationInterface_t Communication;
+ static R15CommandInterface_t R15Command;
+ static R15BulkInterface_t R15Bulk;
+ static A2CommandInterface_t A2Command;
+
+ static HMODULE m_hDLL;
+ static char *m_pchLCMLibPath;
+ static CCriticalSectionObject m_CriticalSection;
+};
+
+#endif // _LCMINTERFACE_H_
diff --git a/source/api_wrappers/linux/CCriticalSection.h b/source/api_wrappers/linux/CCriticalSection.h
new file mode 100644
index 0000000..bbe95c4
--- /dev/null
+++ b/source/api_wrappers/linux/CCriticalSection.h
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _CCRITICALSECTION_H
+#define _CCRITICALSECTION_H
+
+#include "pthread.h"
+class CCriticalSectionObject
+{
+ friend class CLockCS;
+public:
+ CCriticalSectionObject() {
+ pthread_mutexattr_init(&recursivem);
+ pthread_mutexattr_settype(&recursivem, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&m_CriticalSection, &recursivem);
+ }
+ ~CCriticalSectionObject() {
+ pthread_mutexattr_destroy(&recursivem);
+ pthread_mutex_destroy(&m_CriticalSection);
+ }
+ inline void Enter() {
+ pthread_mutex_lock(&m_CriticalSection);
+ }
+ inline void Leave() {
+ pthread_mutex_unlock(&m_CriticalSection);
+ }
+private:
+ pthread_mutexattr_t recursivem;
+ mutable pthread_mutex_t m_CriticalSection;
+};
+
+// Basic lock class used to enter and leave the CRITICAL_SECTION private member of a
+// CCriticalSection object. Create a CLock object in scope that needs to be
+// synchronized and pass the shared CCriticalSection object used to synchronize the
+// resource to protect. The destructor calls the Leave method when leaving scope.
+class CLockCS
+{
+public:
+ CLockCS(CCriticalSectionObject &cs) : m_CriticalSectionObject(cs) {
+ m_CriticalSectionObject.Enter();
+ }
+ ~CLockCS() {
+ m_CriticalSectionObject.Leave();
+ }
+private:
+ CCriticalSectionObject &m_CriticalSectionObject;
+};
+
+#endif /* _CCRITICALSECTION_H */
+
diff --git a/source/api_wrappers/linux/CEventObject.cpp b/source/api_wrappers/linux/CEventObject.cpp
new file mode 100644
index 0000000..5f5acda
--- /dev/null
+++ b/source/api_wrappers/linux/CEventObject.cpp
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include <errno.h>
+#include <sys/time.h>
+
+#include "Types.h"
+#include "CEventObject.h"
+#include "OS.h"
+
+// ******************************************************************************
+// Name: CEventObject()
+// Desc: CEventObject constructor which initializes the m_sem member
+// Ret:
+// ******************************************************************************
+CEventObject::CEventObject()
+{
+ sem_init(&m_sem, 0, 0);
+}
+
+// ******************************************************************************
+// Name: ~CEventObject()
+// Desc: CEventObject destructor
+// Ret:
+// ******************************************************************************
+CEventObject::~CEventObject()
+{
+ sem_destroy(&m_sem);
+}
+
+// ******************************************************************************
+// Name: SetEvent()
+// Desc: Sets an event by post-ing the member semaphore m_sem
+// Ret:
+// ******************************************************************************
+void CEventObject::SetEvent()
+{
+ sem_post(&m_sem);
+}
+
+// ******************************************************************************
+// Name: Wait()
+// Desc: implementation of the pure virtual base class member Wait()
+// Ret: WAIT_OBJECT_0 when event occurs, or WAIT_TIMEOUT on timeout
+// ******************************************************************************
+DWORD CEventObject::Wait(DWORD dwTimeout)
+{
+ if (INFINITE == dwTimeout) {
+ sem_wait(&m_sem);
+ return WAIT_OBJECT_0;
+ } else {
+ timespec absolute_time = OS::GetAbsoluteTime(dwTimeout);
+ int ret;
+
+ /* coverity[returned_null] */
+ while (-1 == (ret = sem_timedwait(&m_sem, &absolute_time)) && errno == EINTR);
+
+ if (0 == ret) {
+ return WAIT_OBJECT_0;
+ } else {
+ return WAIT_TIMEOUT;
+ }
+ }
+}
diff --git a/source/api_wrappers/linux/CEventObject.h b/source/api_wrappers/linux/CEventObject.h
new file mode 100644
index 0000000..9c86087
--- /dev/null
+++ b/source/api_wrappers/linux/CEventObject.h
@@ -0,0 +1,40 @@
+/*******************************************************************************
+*
+* File name: CEventObjectObject.h
+* Language: Visual C++
+* Description: CEventObjectObject class declarations
+*
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*******************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+
+#ifndef _CEVENTOBJECT_H
+#define _CEVENTOBJECT_H
+
+#include <semaphore.h>
+
+#include "Types.h"
+#include "CWaitableObject.h"
+
+//class used to wrap the OS methods for even signaling
+//implements Wait() method used when waiting for event to occur
+
+class CEventObject : public CWaitableObject
+{
+public:
+ CEventObject();
+ virtual ~CEventObject();
+ void SetEvent();
+ void UnsetEvent();
+ DWORD Wait(DWORD dwTimeout = INFINITE);
+private:
+ sem_t m_sem;
+};
+
+#endif /* _CEVENTOBJECT_H */
+
diff --git a/source/api_wrappers/linux/CSemaphore.cpp b/source/api_wrappers/linux/CSemaphore.cpp
new file mode 100644
index 0000000..0246091
--- /dev/null
+++ b/source/api_wrappers/linux/CSemaphore.cpp
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include <errno.h>
+#include <semaphore.h>
+#include <sys/time.h>
+#include "Types.h"
+#include "CSemaphore.h"
+#include "OS.h"
+
+CSemaphore::CSemaphore(unsigned int initial_count)
+{
+ sem_init(&m_semaphore, 0, initial_count);
+}
+
+CSemaphore::~CSemaphore()
+{
+ sem_destroy(&m_semaphore);
+}
+
+bool CSemaphore::Release(unsigned int count)
+{
+ if (!count) {
+ return false;
+ }
+
+ for (unsigned int i = 0; i < count; ++i) {
+ if (sem_post(&m_semaphore)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+DWORD CSemaphore::Wait(DWORD timeout)
+{
+ if (INFINITE == timeout) {
+ sem_wait(&m_semaphore);
+ } else {
+ timespec absoulute_time = OS::GetAbsoluteTime(timeout);
+ int ret;
+
+ /* coverity[returned_null] */
+ while (-1 == (ret = sem_timedwait(&m_semaphore, &absoulute_time)) && errno == EINTR);
+
+ if (0 != ret) {
+ return WAIT_TIMEOUT;
+ }
+ }
+
+ return WAIT_OBJECT_0;
+}
diff --git a/source/api_wrappers/linux/CSemaphore.h b/source/api_wrappers/linux/CSemaphore.h
new file mode 100644
index 0000000..24af4ad
--- /dev/null
+++ b/source/api_wrappers/linux/CSemaphore.h
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _CSEMAPHORE_H
+#define _CSEMAPHORE_H
+
+#include <pthread.h>
+#include <semaphore.h>
+#include "CWaitableObject.h"
+
+class CSemaphore : public CWaitableObject
+{
+public:
+ CSemaphore(unsigned int initial_count = 0);
+ virtual ~CSemaphore();
+ bool Release(unsigned int count = 1);
+ DWORD Wait(DWORD timeout = INFINITE);
+
+private:
+ sem_t m_semaphore;
+};
+
+#endif /* _CSEMAPHORE_H */
+
diff --git a/source/api_wrappers/linux/CSemaphoreQueue.cpp b/source/api_wrappers/linux/CSemaphoreQueue.cpp
new file mode 100644
index 0000000..0a2f573
--- /dev/null
+++ b/source/api_wrappers/linux/CSemaphoreQueue.cpp
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include <pthread.h>
+#include <assert.h>
+#include "Types.h"
+#include "CEventObject.h"
+#include "CSemaphore.h"
+#include "CSemaphoreQueue.h"
+
+CSemaphoreQueue::CSemaphoreQueue(unsigned int MaxCount) : m_MaximumCount(MaxCount)
+{
+ m_pEventObject = new CEventObject();
+ m_pSemaphore = new CSemaphore();
+
+ m_ObjectCollection.Add(m_pEventObject);
+ m_ObjectCollection.Add(m_pSemaphore);
+
+ m_Queue = new void*[MaxCount];
+ m_CurrentHead = 0;
+ m_CurrentTail = 0;
+ m_CurrentCount = 0;
+}
+
+CSemaphoreQueue::~CSemaphoreQueue()
+{
+ delete m_pEventObject;
+ delete m_pSemaphore;
+ delete[] m_Queue;
+}
+
+bool CSemaphoreQueue::AddTail(void *pObject)
+{
+ bool result = false;
+ CLockCS LocalCSLock(m_CSLock);
+ AddToQueueTail(pObject);
+ result = m_pSemaphore->Release(1);
+
+ if (!result) {
+ // Error : use ::GetLastError for cause of error
+ RemoveFromQueueTail(); // Not really necessary but keep,
+ // everything's gone pear-shaped anyway
+ }
+
+ return result;
+}
+
+RemoveResult CSemaphoreQueue::RemoveHead(void **ppObject, size_t mSecTimeout)
+{
+ CWaitableObject *pWaitableObject = m_ObjectCollection.Wait(mSecTimeout);
+
+ if (pWaitableObject == m_pEventObject) {
+ return REMOVE_CANCEL;
+ } else if (pWaitableObject == m_pSemaphore) {
+ CLockCS LocalCSLock(m_CSLock);
+ *ppObject = RemoveFromQueueHead(); // Remove pObject from pObjectQueue head
+ return REMOVE_SUCCESS;
+ } else if (NULL == pWaitableObject) {
+ return REMOVE_TIMEOUT;;
+ } else {
+ // Should never occur
+ assert(false);
+ return REMOVE_CANCEL;;
+ }
+}
+
+void CSemaphoreQueue::SignalEvent()
+{
+ CEventObject *pEvent = m_pEventObject;
+ pEvent->SetEvent();
+}
+
+void CSemaphoreQueue::IncrementHead()
+{
+ ++m_CurrentHead;
+
+ if (m_CurrentHead == m_MaximumCount) {
+ m_CurrentHead = 0;
+ }
+}
+
+void CSemaphoreQueue::IncrementTail()
+{
+ ++m_CurrentTail;
+
+ if (m_CurrentTail == m_MaximumCount) {
+ m_CurrentTail = 0;
+ }
+}
+
+void CSemaphoreQueue::AddToQueueTail(void *pObject)
+{
+ m_Queue[m_CurrentTail] = pObject;
+ IncrementTail();
+}
+
+void *CSemaphoreQueue::RemoveFromQueueHead()
+{
+ void *Object;
+ Object = m_Queue[m_CurrentHead];
+ IncrementHead();
+ return Object;
+}
+
+// Next 2 functions not really necessary - for error case only
+void CSemaphoreQueue::DecrementTail()
+{
+ if (m_CurrentTail == 0) {
+ m_CurrentTail = m_MaximumCount - 1;
+ } else {
+ --m_CurrentTail;
+ }
+}
+
+void CSemaphoreQueue::RemoveFromQueueTail()
+{
+ DecrementTail();
+ m_Queue[m_CurrentTail] = 0;
+}
diff --git a/source/api_wrappers/linux/CSemaphoreQueue.h b/source/api_wrappers/linux/CSemaphoreQueue.h
new file mode 100644
index 0000000..712d697
--- /dev/null
+++ b/source/api_wrappers/linux/CSemaphoreQueue.h
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _CSEMAPHOREQUEUE_H
+#define _CSEMAPHOREQUEUE_H
+#include "Types.h"
+#include "CEventObject.h"
+#include "CSemaphore.h"
+#include "pthread.h"
+#include "CCriticalSection.h"
+#include "CWaitableObject.h"
+#include "CWaitableObjectCollection.h"
+
+class CSemaphore;
+
+enum RemoveResult {
+ REMOVE_SUCCESS,
+ REMOVE_TIMEOUT,
+ REMOVE_CANCEL
+};
+
+// An object queue implementation using WinAPI's Semaphore.
+// For multi-threaded multi-processor applications with multiple producers and multiple consumers
+class CSemaphoreQueue
+{
+public:
+ CSemaphoreQueue(unsigned int MaxCount);
+ ~CSemaphoreQueue();
+ bool AddTail(void *pObject);
+ RemoveResult RemoveHead(void **ppRequest, size_t mSecTimeout);
+ void SignalEvent();
+private:
+ CEventObject *m_pEventObject;
+ CSemaphore *m_pSemaphore;
+ CCriticalSectionObject m_CSLock;
+ void **m_Queue;
+ const unsigned int m_MaximumCount;
+ unsigned int m_CurrentCount;
+ unsigned int m_CurrentHead;
+ unsigned int m_CurrentTail;
+ void IncrementHead();
+ void IncrementTail();
+ void AddToQueueTail(void *pObject);
+ void *RemoveFromQueueHead();
+ unsigned int GetIndex(CWaitableObject *Object) const;
+ // Next 2 functions not really necessary - for error case only
+ void DecrementTail();
+ void RemoveFromQueueTail();
+ CWaitableObjectCollection m_ObjectCollection;
+};
+
+class CPollQueue : public CSemaphoreQueue
+{
+public:
+ CPollQueue() : CSemaphoreQueue(256) {}
+ RemoveResult RemovePollRequest(void **pTO, int mSecTimeout = INFINITE) {
+ return RemoveHead(pTO, mSecTimeout);
+ }
+ bool AddPollRequest(void *pObject) {
+ return AddTail(pObject);
+ }
+};
+
+#endif /* _CSEMAPHOREQUEUE_H */
+
diff --git a/source/api_wrappers/linux/CSimpleQueue.h b/source/api_wrappers/linux/CSimpleQueue.h
new file mode 100644
index 0000000..18a0478
--- /dev/null
+++ b/source/api_wrappers/linux/CSimpleQueue.h
@@ -0,0 +1,26 @@
+/******************************************************************************
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+******************************************************************************/
+
+#ifndef _CSIMPLEQUEUE_H_
+#define _CSIMPLEQUEUE_H_
+
+#include "Types.h"
+#include "CSemaphoreQueue.h"
+
+class CSimpleQueue : public CSemaphoreQueue
+{
+public:
+ CSimpleQueue(): CSemaphoreQueue(256) {}
+ RemoveResult RemoveRequest(void **ppRequest, int mSecTimeout = INFINITE) {
+ return RemoveHead(ppRequest, mSecTimeout);
+ }
+ bool AddRequest(void *pRequest) {
+ return AddTail(pRequest);
+ }
+};
+
+#endif // _CSIMPLEQUEUE_H_
diff --git a/source/api_wrappers/linux/CThreadWrapper.cpp b/source/api_wrappers/linux/CThreadWrapper.cpp
new file mode 100644
index 0000000..3e95da8
--- /dev/null
+++ b/source/api_wrappers/linux/CThreadWrapper.cpp
@@ -0,0 +1,119 @@
+/*******************************************************************************
+*
+* File name: CThreadWrapper.cpp
+* Language: Visual C++
+* Description: CThreadWrapper class definitions
+* The class implements OS independent thread wrapper.
+* The class contains methods for suspending resuming and waiting for threads.
+* The implementations of the methods is linux dependent,
+* but the interface of the functions is same as the appropriate
+* WIN32 implementation.
+*
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*******************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+
+#include <string>
+#include <signal.h>
+
+#include "Types.h"
+#include "CThreadWrapper.h"
+#include "CCriticalSection.h"
+
+// ******************************************************************************
+// Name: CThreadWrapper()
+// Desc: CEventObject constructor which initializes the class members
+// Ret:
+// ******************************************************************************
+CThreadWrapper::CThreadWrapper(void*(*pStartAddress)(void *), void *pArgument)
+{
+ m_pStartAddress = pStartAddress;
+ m_pArgument = pArgument;
+ m_tid = (pthread_t)0;
+}
+
+// ******************************************************************************
+// Name: ~CThreadWrapper()
+// Desc: CEventObject destructor
+// Ret:
+// ******************************************************************************
+CThreadWrapper::~CThreadWrapper()
+{
+}
+
+// ******************************************************************************
+// Name: Wait()
+// Desc: Waits for the thread to finish its job
+// Ret: WAIT_OBJECT_0 on success and EAIT_TIMEOUT otherwise
+// ******************************************************************************
+DWORD CThreadWrapper::Wait(DWORD dwMilliseconds)
+{
+ if ((int)m_tid != 0) {
+ return m_ThreadEndedEvt.Wait(dwMilliseconds);
+ } else {
+ return WAIT_OBJECT_0;
+ }
+}
+
+// ******************************************************************************
+// Name: ResumeThread()
+// Desc: Resumes the thread. Should be called after the thread is created
+// Ret:
+// ******************************************************************************
+void CThreadWrapper::ResumeThread()
+{
+ pthread_create(&m_tid, NULL, CThreadWrapper::ThreadFunc, this);
+}
+
+// ******************************************************************************
+// Name: ResumeThread()
+// Desc: Suspends the running thread.
+// Ret:
+// ******************************************************************************
+void CThreadWrapper::SuspendThread()
+{
+ // this will stop all active threads
+ pthread_kill(m_tid, SIGSTOP);
+}
+
+// ******************************************************************************
+// Name: WaitToDie()
+// Desc: Waits 1000ms for thread to die
+// Ret:
+// ******************************************************************************
+void CThreadWrapper::WaitToDie(DWORD dwMilliseconds)
+{
+ CThreadWrapper::Wait(dwMilliseconds);
+}
+// ******************************************************************************
+// Name: ThreadFunc()
+// Desc: Sets event when the thread finishes its job
+// Ret:
+// ******************************************************************************
+void *CThreadWrapper::ThreadFunc(void *arg)
+{
+ CThreadWrapper *pthis = (CThreadWrapper *)arg;
+
+ pthis->m_pStartAddress(pthis->m_pArgument);
+
+ // Thread has finished, set appropriate event here
+ pthis->m_ThreadEndedEvt.SetEvent();
+ pthread_detach(pthread_self());
+ pthis->m_tid = (pthread_t)0;
+ return NULL;
+}
+
+// ******************************************************************************
+// Name: GetThreadId()
+// Desc: Returns the thread ID
+// Ret: Thread ID
+// ******************************************************************************
+DWORD CThreadWrapper::GetThreadId()
+{
+ return (DWORD)m_tid;
+}
diff --git a/source/api_wrappers/linux/CThreadWrapper.h b/source/api_wrappers/linux/CThreadWrapper.h
new file mode 100644
index 0000000..aabadcc
--- /dev/null
+++ b/source/api_wrappers/linux/CThreadWrapper.h
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _CTHREADWRAPPER_H
+#define _CTHREADWRAPPER_H
+
+#include "CWaitableObject.h"
+#include "CEventObject.h"
+#include <pthread.h>
+
+typedef void*(*StartAddress_t)(void *);
+
+class CThreadWrapper : public CWaitableObject
+{
+public:
+ CThreadWrapper(void*(* pStartAddress)(void *), void *pArgument);
+ ~CThreadWrapper();
+ void ResumeThread();
+ void SuspendThread();
+ void WaitToDie(DWORD dwMilliseconds = 1000);
+ DWORD GetThreadId();
+ DWORD Wait(DWORD dwMilliseconds = INFINITE);
+private:
+ pthread_t m_tid;
+ StartAddress_t m_pStartAddress;
+ void *m_pArgument;
+ CEventObject m_ThreadEndedEvt;
+
+protected:
+ static void *ThreadFunc(void *Arg);
+};
+
+#endif /* _CTHREADWRAPPER_H */
+
diff --git a/source/api_wrappers/linux/CWaitableObject.cpp b/source/api_wrappers/linux/CWaitableObject.cpp
new file mode 100644
index 0000000..918dd6f
--- /dev/null
+++ b/source/api_wrappers/linux/CWaitableObject.cpp
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include "Types.h"
+#include "CWaitableObject.h"
+
+CWaitableObject::CWaitableObject()
+{
+}
+
+
+CWaitableObject::~CWaitableObject()
+{
+}
+
diff --git a/source/api_wrappers/linux/CWaitableObject.h b/source/api_wrappers/linux/CWaitableObject.h
new file mode 100644
index 0000000..93cd638
--- /dev/null
+++ b/source/api_wrappers/linux/CWaitableObject.h
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _CWAITABLEOBJECT_H
+#define _CWAITABLEOBJECT_H
+
+#include "Types.h"
+
+class CWaitableObject
+{
+public:
+ CWaitableObject();
+ virtual ~CWaitableObject();
+ virtual DWORD Wait(DWORD dwTimeout = INFINITE) = 0;
+private:
+
+};
+
+typedef CWaitableObject *HANDLE;
+
+#endif /* _CWAITABLEOBJECT_H */
+
diff --git a/source/api_wrappers/linux/CWaitableObjectCollection.cpp b/source/api_wrappers/linux/CWaitableObjectCollection.cpp
new file mode 100644
index 0000000..e48fd1c
--- /dev/null
+++ b/source/api_wrappers/linux/CWaitableObjectCollection.cpp
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include <time.h>
+#include <errno.h>
+
+#include "Types.h"
+#include "CWaitableObjectCollection.h"
+#include <assert.h>
+
+CWaitableObjectCollection::CWaitableObjectCollection()
+{
+ m_objs.clear();
+}
+
+CWaitableObjectCollection::~CWaitableObjectCollection()
+{
+ m_objs.clear();
+}
+
+void CWaitableObjectCollection::Add(CWaitableObject *obj)
+{
+ m_objs.push_back(obj);
+}
+
+CWaitableObject *CWaitableObjectCollection::Wait(DWORD dwTimeout)
+{
+ vector<CWaitableObject *>::iterator it;
+ DWORD dwTimePassed = 0;
+ struct timespec ts;
+ struct timespec curr_time, start_time;
+
+ if (-1 == clock_gettime(CLOCK_REALTIME, &start_time)) {
+ return NULL;
+ }
+
+ do {
+ for (it = m_objs.begin(); it != m_objs.end(); ++it) {
+ assert(*it);
+
+ if (WAIT_OBJECT_0 == (*it)->Wait(0)) {
+ return (*it);
+ }
+ }
+
+ ts.tv_sec = 0;
+ ts.tv_nsec = 10000000L; // 10 milliseconds
+
+ // There isn't any possiblity of errno returning NULL, mean is not defined. Even if
+ // errno is not defined this is the least thing that we should care for.
+
+ // coverity[returned_null]
+ while (-1 == nanosleep(&ts, &ts) && EINTR == errno);
+
+ if (-1 == clock_gettime(CLOCK_REALTIME, &curr_time)) {
+ return NULL;
+ }
+
+ dwTimePassed = 1000 * (curr_time.tv_sec - start_time.tv_sec) + \
+ (curr_time.tv_nsec - start_time.tv_nsec) / 1000000;
+
+ } while (dwTimePassed < dwTimeout);
+
+ return NULL;
+}
diff --git a/source/api_wrappers/linux/CWaitableObjectCollection.h b/source/api_wrappers/linux/CWaitableObjectCollection.h
new file mode 100644
index 0000000..f5edfa7
--- /dev/null
+++ b/source/api_wrappers/linux/CWaitableObjectCollection.h
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _CWAITABLEOBJECTCOLLECTION_H
+#define _CWAITABLEOBJECTCOLLECTION_H
+
+#include <vector>
+#include "CWaitableObject.h"
+
+using namespace std;
+
+class CWaitableObjectCollection
+{
+public:
+ CWaitableObjectCollection();
+ virtual ~CWaitableObjectCollection();
+ void Add(CWaitableObject *obj);
+ CWaitableObject *Wait(DWORD dwTimeout = INFINITE);
+private:
+ vector<CWaitableObject *>m_objs;
+};
+
+#endif /* _CWAITABLEOBJECTCOLLECTION_H */
+
diff --git a/source/api_wrappers/linux/LinuxApiWrappers.h b/source/api_wrappers/linux/LinuxApiWrappers.h
new file mode 100644
index 0000000..b63b840
--- /dev/null
+++ b/source/api_wrappers/linux/LinuxApiWrappers.h
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _LINUXAPIWRAPPERS_H
+#define _LINUXAPIWRAPPERS_H
+
+#include "Types.h"
+#include "CCriticalSection.h"
+#include "CEventObject.h"
+#include "CSemaphore.h"
+#include "CSemaphoreQueue.h"
+#include "CThreadWrapper.h"
+#include "CWaitableObject.h"
+#include "CWaitableObjectCollection.h"
+#include "OS.h"
+
+#endif /* _LINUXAPIWRAPPERS_H */
+
diff --git a/source/api_wrappers/linux/OS.cpp b/source/api_wrappers/linux/OS.cpp
new file mode 100644
index 0000000..55c82bd
--- /dev/null
+++ b/source/api_wrappers/linux/OS.cpp
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include <time.h>
+#include <errno.h>
+#include "Types.h"
+#include "OS.h"
+
+DWORD OS::ErrorCode = 0;
+
+OS::OS()
+{
+}
+
+OS::~OS()
+{
+}
+
+void OS::Sleep(DWORD dwMilliseconds)
+{
+ struct timespec ts;
+
+ ts.tv_sec = dwMilliseconds / 1000;
+ ts.tv_nsec = (dwMilliseconds % 1000) * 1000000L;
+
+ /* coverity[returned_null] */
+ while (-1 == nanosleep(&ts, &ts) && errno == EINTR);
+}
+
+time_t OS::GetSystemTimeInMs()
+{
+ timespec systemTime;
+ clock_gettime(CLOCK_REALTIME, &systemTime);
+ return (systemTime.tv_sec * 1000) + (systemTime.tv_nsec / 1000000);
+}
+
+timespec OS::GetAbsoluteTime(DWORD dwTimeout)
+{
+ timespec absolute_time;
+ timespec current_time;
+
+ long timeout_nsec;
+
+ clock_gettime(CLOCK_REALTIME, &current_time);
+
+ absolute_time.tv_sec = current_time.tv_sec + (dwTimeout / 1000);
+ timeout_nsec = (dwTimeout % 1000) * 1000000L;
+
+ if ((1000000000 - current_time.tv_nsec) < timeout_nsec) {
+ // overflow will occur!
+ absolute_time.tv_sec++;
+ }
+
+ absolute_time.tv_nsec = (current_time.tv_nsec + timeout_nsec) % 1000000000;
+
+ return absolute_time;
+}
+
+
+char *strcpy_s(char *dst, size_t _Size, const char *src)
+{
+ return strncpy(dst, src, _Size);
+}
+
+int sprintf_s(char *dst, size_t _Size, const char *format, ...)
+{
+ va_list l;
+ int ReturnValue;
+
+ va_start(l, format);
+ ReturnValue = vsnprintf(dst, _Size, format, l);
+ va_end(l);
+
+ return ReturnValue;
+}
+
+char *strncpy_s(char *dst, const char *src, size_t _Size)
+{
+ return strncpy(dst, src, _Size);
+}
+
+int _stricmp(const char *s1, const char *s2)
+{
+ return strcasecmp(s1, s2);
+}
+
diff --git a/source/api_wrappers/linux/OS.h b/source/api_wrappers/linux/OS.h
new file mode 100644
index 0000000..cd219b9
--- /dev/null
+++ b/source/api_wrappers/linux/OS.h
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _OS_H
+#define _OS_H
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include "Types.h"
+
+#include "CWaitableObject.h"
+
+class OS
+{
+public:
+ OS();
+ virtual ~OS();
+
+ static void Sleep(DWORD dwMilliseconds);
+ static time_t GetSystemTimeInMs();
+
+ static DWORD GetErrorCode() {
+ return OS::ErrorCode;
+ }
+ static void SetErrorCode(DWORD dwErrorCode) {
+ OS::ErrorCode = dwErrorCode;
+ }
+
+ static timespec GetAbsoluteTime(DWORD dwTimeout);
+private:
+
+ static DWORD ErrorCode;
+};
+
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
+/*
+ * str manipulation functions used in windows build
+ */
+
+char *strcpy_s(char *dst, size_t _Size, const char *src);
+char *strncpy_s(char *dst, const char *src, size_t _Size);
+int _stricmp(const char *s1, const char *s2);
+int sprintf_s(char *dst, size_t _Size, const char *format, ...);
+
+#define _snprintf snprintf
+
+template <size_t _Size>
+char *strcpy_s(char(&dst)[_Size], const char src[])
+{
+ return strncpy(dst, src, _Size);
+}
+
+template<size_t _Size>
+int sprintf_s(char(&dst)[_Size], const char *format, ...)
+{
+ int ReturnValue;
+ va_list l;
+ va_start(l, format);
+ ReturnValue = vsnprintf(dst, _Size, format, l);
+ va_end(l);
+ return ReturnValue;
+}
+
+template <size_t _Size>
+char *strcat_s(char(&dst)[_Size], const char src[])
+{
+ return strncat(dst, src, _Size);
+}
+
+template <size_t _Size>
+int _ultoa_s(unsigned long value, char(&str)[_Size], int radix)
+{
+ switch (radix) {
+ case 10:
+ return sprintf_s(str, "%ul", value);
+ case 16:
+ return sprintf_s(str, "%ulX", value);
+ default:
+ return -1;
+ }
+}
+
+template<size_t _Size>
+int _snprintf_s(char(&dst)[_Size], size_t _MaxCount, const char *format, ...)
+{
+ int ReturnValue;
+ va_list l;
+ va_start(l, format);
+ ReturnValue = vsnprintf(dst, MAX(_MaxCount, _Size), format, l);
+ va_end(l);
+ return ReturnValue;
+}
+
+template<size_t _Size>
+int vsprintf_s(char(&dst)[_Size], const char *format, va_list l)
+{
+ return vsnprintf(dst, _Size, format, l);
+}
+
+#endif /* _OS_H */
+
diff --git a/source/api_wrappers/linux/Types.h b/source/api_wrappers/linux/Types.h
new file mode 100644
index 0000000..14929b4
--- /dev/null
+++ b/source/api_wrappers/linux/Types.h
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _TYPES_H
+#define _TYPES_H
+
+const unsigned int os_minus_one = ~0;
+#define INFINITE os_minus_one
+
+#define WAIT_OBJECT_0 0
+#define WAIT_TIMEOUT 0x00000102L
+#define WAIT_FAILED (DWORD)0xFFFFFFFF
+
+typedef unsigned int DWORD;
+
+#define WINAPI
+
+#endif /* _TYPES_H */
+
diff --git a/source/api_wrappers/windows/WinApiWrappers.h b/source/api_wrappers/windows/WinApiWrappers.h
new file mode 100644
index 0000000..65fca8b
--- /dev/null
+++ b/source/api_wrappers/windows/WinApiWrappers.h
@@ -0,0 +1,347 @@
+/*******************************************************************************
+*
+* File name: WinApiWrappers.h
+* Language: Visual C++
+* Description: WinAPI encapsulation class declarations
+*
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*******************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// File WinApiWrappers.h
+
+#ifndef __WINAPIWRAPPERS_H__
+#define __WINAPIWRAPPERS_H__
+
+#pragma once
+
+#include <windows.h>
+#include <process.h>
+#include <assert.h>
+#include <vector>
+using namespace std;
+
+class CWaitableObject
+{
+public:
+ CWaitableObject() {}
+ virtual ~CWaitableObject() {}
+ virtual DWORD Wait(DWORD dwTimeout = INFINITE) = 0;
+private:
+
+};
+
+// Thin encapsulation of WinAPI's CRITICAL_SECTION
+class CCriticalSectionObject
+{
+ friend class CLockCS;
+public:
+ CCriticalSectionObject() {
+ ::InitializeCriticalSection(&m_CriticalSection);
+ }
+ ~CCriticalSectionObject() {
+ ::DeleteCriticalSection(&m_CriticalSection);
+ }
+private:
+ void Enter() {
+ ::EnterCriticalSection(&m_CriticalSection);
+ }
+ void Leave() {
+ ::LeaveCriticalSection(&m_CriticalSection);
+ }
+ CRITICAL_SECTION m_CriticalSection;
+};
+
+// Basic lock class used to enter and leave the CRITICAL_SECTION private member of a
+// CCriticalSection object. Create a CLock object in scope that needs to be
+// synchronized and pass the shared CCriticalSection object used to synchronize the
+// resource to protect. The destructor calls the Leave method when leaving scope.
+class CLockCS
+{
+public:
+ CLockCS(CCriticalSectionObject &cs) : m_CriticalSectionObject(cs) {
+ m_CriticalSectionObject.Enter();
+ }
+ ~CLockCS() {
+ m_CriticalSectionObject.Leave();
+ }
+private:
+ CCriticalSectionObject &m_CriticalSectionObject;
+};
+
+// Thin encapsulation of WinAPI's Events
+class CEventObject : public CWaitableObject
+{
+public:
+ CEventObject() {
+ m_Handle = ::CreateEvent(
+ 0, // LPSECURITY_ATTRIBUTES
+ FALSE, // bManualReset i.e. Use auto-reset functionality
+ FALSE, // bInitialState i.e. In non-signalled state initially
+ 0);
+ } // lpName
+ ~CEventObject() {
+ ::CloseHandle(m_Handle);
+ }
+ void SetEvent() {
+ ::SetEvent(m_Handle);
+ }
+ void UnsetEvent() {
+ ::ResetEvent(m_Handle);
+ }
+ DWORD Wait(DWORD milliseconds = INFINITE) {
+ return ::WaitForSingleObject(m_Handle, milliseconds);
+ }
+ void WaitForAllEvents(HANDLE *pHandles, int iHandles, DWORD msec = INFINITE) {
+ ::WaitForMultipleObjects(
+ iHandles, // Number of objects in handles
+ pHandles,
+ TRUE, // Wait all events
+ msec);
+ } // Wait indefinitely default i.e. INFINITE
+ int WaitForFirstEvent(HANDLE *pHandles, int iHandles, DWORD msec = INFINITE) {
+ ::WaitForMultipleObjects(
+ iHandles, // Number of objects in handles
+ pHandles,
+ FALSE, // Wait for first event object
+ msec);
+ } // Wait indefinitely default i.e. INFINITE
+ HANDLE GetHandle() {
+ return m_Handle;
+ }
+private:
+ HANDLE m_Handle;
+};
+
+// A thin encapsulation of WinAPI's Thread
+class CThreadWrapper
+{
+public:
+ CThreadWrapper(unsigned int (WINAPI *pStartAddress)(void *), void *pArgument) {
+ m_Handle = (HANDLE)_beginthreadex(
+ 0, // LPSECURITY_ATTRIBUTES
+ 0, // dwStackSize - default
+ pStartAddress, // lpStartAddress
+ pArgument, // lpParameter
+ CREATE_SUSPENDED, // dwCreationFlags
+ 0); // lpThreadId
+ }
+ ~CThreadWrapper() {
+ ::CloseHandle(m_Handle);
+ }
+ void ResumeThread() {
+ ::ResumeThread(m_Handle);
+ }
+ void SuspendThread() {
+ ::SuspendThread(m_Handle);
+ }
+ void WaitToDie(DWORD dwMilliseconds = 1000) {
+ ::WaitForSingleObject(m_Handle, dwMilliseconds);
+ }
+private:
+ HANDLE m_Handle;
+ DWORD m_ThreadId;
+};
+
+//class that encapsulates the OS methods for Object signaling
+//it contains functions for registering signal objects.
+//the main function is the wait method which interface is platform independent.
+class CWaitableObjectCollection
+{
+public:
+ CWaitableObjectCollection() {
+ m_objs.clear();
+ }
+
+ virtual ~CWaitableObjectCollection() {
+ m_objs.clear();
+ }
+
+ //adds object to the collection
+ void Add(CWaitableObject *obj) {
+ m_objs.push_back(obj);
+ }
+
+ //waits for multiple objects
+ //this function returns the object that signaled the end of its job
+ //or null if dwTimeout occur
+ CWaitableObject *Wait(DWORD dwTimeout = INFINITE) {
+ vector<CWaitableObject *>::iterator it;
+ DWORD dwTimePassed = 0;
+ DWORD curr_time, start_time;
+
+ start_time = ::GetTickCount();
+
+ do {
+ for (it = m_objs.begin(); it != m_objs.end(); ++it) {
+ assert(*it);
+
+ if ((*it)->Wait(0) == 0) {
+ return (*it);
+ }
+ }
+
+ Sleep(10);
+
+ curr_time = ::GetTickCount();
+
+ dwTimePassed = curr_time - start_time;
+ } while (dwTimePassed < dwTimeout);
+
+ return NULL;
+ }
+private:
+ vector<CWaitableObject *>m_objs;
+};
+
+enum RemoveResult {
+ REMOVE_SUCCESS,
+ REMOVE_TIMEOUT,
+ REMOVE_CANCEL
+};
+
+// An object queue implementation using WinAPI's Semaphore.
+// For multi-threaded multi-processor applications with multiple producers and multiple consumers
+class CSemaphoreQueue
+{
+public:
+ CSemaphoreQueue(unsigned int MaxCount) : m_MaximumCount(MaxCount) {
+ m_Handles[0] = ::CreateEvent(NULL, FALSE, FALSE, NULL);
+ m_Handles[1] = ::CreateSemaphore(NULL, 0, MaxCount, NULL);
+ m_Queue = new void*[MaxCount];
+ m_CurrentHead = 0;
+ m_CurrentTail = 0;
+ m_CurrentCount = 0;
+ }
+
+ ~CSemaphoreQueue() {
+ ::CloseHandle(m_Handles[0]);
+ ::CloseHandle(m_Handles[1]);
+ delete m_Queue;
+ }
+
+ bool AddTail(void *pObject) {
+ bool result;
+ CLockCS LocalCSLock(m_CSLock);
+ AddToQueueTail(pObject);
+ result = ::ReleaseSemaphore(m_Handles[1], 1, 0) ? true : false;
+
+ if (!result) {
+ RemoveFromQueueTail(); // Not really necessary but keep, everything's gone pear-shaped anyway
+ }
+
+ return result;
+ }
+
+ RemoveResult RemoveHead(void **ppObject, int mSecTimeout) {
+ switch (::WaitForMultipleObjects(2, m_Handles, FALSE, mSecTimeout)) {
+ case WAIT_OBJECT_0 + 0:
+ return REMOVE_CANCEL;
+ case WAIT_OBJECT_0 + 1: {
+ CLockCS LocalCSLock(m_CSLock);
+ *ppObject = RemoveFromQueueHead(); // Remove pObject from pObjectQueue head
+ return REMOVE_SUCCESS;
+ }
+ case WAIT_TIMEOUT:
+ return REMOVE_TIMEOUT;
+ default:
+ assert(false);
+ return REMOVE_CANCEL;
+ }
+ }
+
+ void SignalEvent() {
+ ::SetEvent(m_Handles[0]);
+ }
+private:
+ HANDLE m_Handles[2];
+ CCriticalSectionObject m_CSLock;
+ void **m_Queue;
+ const unsigned int m_MaximumCount;
+ unsigned int m_CurrentCount;
+ unsigned int m_CurrentHead;
+ unsigned int m_CurrentTail;
+ void IncrementHead() {
+ ++m_CurrentHead;
+
+ if (m_CurrentHead == m_MaximumCount) {
+ m_CurrentHead = 0;
+ }
+ }
+ void IncrementTail() {
+ ++m_CurrentTail;
+
+ if (m_CurrentTail == m_MaximumCount) {
+ m_CurrentTail = 0;
+ }
+ }
+ void AddToQueueTail(LPVOID pObject) {
+ m_Queue[m_CurrentTail] = pObject;
+ IncrementTail();
+ }
+ void *RemoveFromQueueHead() {
+ void *Object;
+ Object = m_Queue[m_CurrentHead];
+ IncrementHead();
+ return Object;
+ }
+ // Next 2 functions not really necessary - for error case only
+ void DecrementTail() {
+ if (m_CurrentTail == 0) {
+ m_CurrentTail = m_MaximumCount - 1;
+ } else {
+ --m_CurrentTail;
+ }
+ }
+ void RemoveFromQueueTail() {
+ DecrementTail();
+ m_Queue[m_CurrentTail] = 0;
+ }
+};
+
+class CSimpleQueue : public CSemaphoreQueue
+{
+public:
+ CSimpleQueue(): CSemaphoreQueue(256) {}
+ RemoveResult RemoveRequest(void **ppRequest, unsigned int mSecTimeout = INFINITE) {
+ return RemoveHead(ppRequest, mSecTimeout);
+ }
+
+ bool AddRequest(void *pRequest) {
+ return AddTail(pRequest);
+ }
+};
+
+class OS
+{
+public:
+ OS();
+ virtual ~OS();
+
+ static void Sleep(DWORD dwMilliseconds) {
+ ::Sleep(dwMilliseconds);
+ }
+ static time_t GetSystemTimeInMs() {
+ FILETIME systemTime;
+ ::GetSystemTimeAsFileTime(&systemTime);
+ ULARGE_INTEGER time;
+ time.LowPart = systemTime.dwLowDateTime;
+ time.HighPart = systemTime.dwHighDateTime;
+ // file time is in 100 ns intervals, convert to ms
+ return time.QuadPart / 10000;
+ }
+ static DWORD GetErrorCode() {
+ return ::GetLastError();
+ }
+ static void SetErrorCode(DWORD dwErrorCode) {
+ ::SetLastError(dwErrorCode);
+ }
+};
+
+#endif // !defined(__WINAPIWRAPPERS_H__)
+
+// End of file WinApiWrappers.h
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/config/a2_command_ids_h.xsl b/source/config/a2_command_ids_h.xsl
new file mode 100644
index 0000000..d04a32d
--- /dev/null
+++ b/source/config/a2_command_ids_h.xsl
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="2.0" xmlns="http://www.w3.org/1999/XSL/Transform">
+
+<import href="a2_common.xsl"/>
+
+<output method="text" indent="no"/>
+<strip-space elements="*"/>
+<param name="target" />
+
+<template match="/commandspec">/* $Copyright ST-Ericsson 2010$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _A2_COMMAND_IDS_H
+#define _A2_COMMAND_IDS_H
+#include &quot;t_basicdefinitions.h&quot;
+
+typedef enum {
+<apply-templates select="group" mode="id"/>} 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">
+<choose>
+<when test="@type='char_array'"> char <text></text><value-of select="@name" />[<text></text><value-of select="@size" />]; /**&lt; <value-of select="text()" /> */
+</when>
+<when test="@type='string'"> char *<text></text><value-of select="@name" />; /**&lt; <value-of select="text()" /> */
+</when>
+<when test="@type='uint32'">
+<text> </text><value-of select="@type" /><text> </text><value-of select="@name" />; /**&lt; <value-of select="text()" /> */
+</when>
+<when test="@type='uint64'">
+<text> </text><value-of select="@type" /><text> </text><value-of select="@name" />; /**&lt; <value-of select="text()" /> */
+</when>
+</choose>
+</template>
+
+<template match="group" 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>
+
+</stylesheet>
diff --git a/source/config/a2_commands.xml b/source/config/a2_commands.xml
new file mode 100644
index 0000000..01803a1
--- /dev/null
+++ b/source/config/a2_commands.xml
@@ -0,0 +1,1259 @@
+<?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>
+
+ <!--
+ 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="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>
+ </input>
+ <output>
+ </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>
+ </input>
+ <output>
+ <value type="buffer" name="LoaderVersionOut" length="*">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>
+ </input>
+ <output>
+ <value type="buffer" name="ProtocolVersionOut" length="*">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>
+ </input>
+ <output>
+ <value type="buffer" name="CommandGroupsOut" length="*">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="PayloadSize"/>
+ </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="PayloadSize"/>
+ </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="PayloadSize">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="PayloadSize"/>
+ </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="Payload" length="PayloadSize"/>
+ </input>
+ <output>
+ </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="Timeout">Timeout in ms.</value>
+ </input>
+ <output>
+ </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="PayloadSize">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="PayloadSize"/>
+ </input>
+ <output>
+ </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="StartAddress">Start address of the block.</value>
+ <value type="uint32" name="BlockSize">Size of the block.</value>
+ </input>
+ <output>
+ </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="Payload" length="PayloadSize"/>
+ </input>
+ <output>
+ </output>
+ </command>
+
+ <command number="4" name="Verify Software Flash" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="VerifySoftwareFlash"/>
+ <input>
+ </input>
+ <output>
+ </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="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="DumpFlashImageOutLength"/>
+ <value type="buffer" name="DumpFlashImageOut" length="DumpFlashImageOutLength"/>
+ </output>
+ </command>
+
+ <command number="6" name="Read PMC Status" flag="true1" source="PC">
+ <documentation>
+ The Read PMC Status command is used to read the value and status of a Protected Monotonic Counter.
+ </documentation>
+ <interface type="loader" name="ReadPmcStatus"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ReadPmcStatusIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="ReadPmcStatusOutLength"/>
+ <value type="buffer" name="ReadPmcStatusOut" length="ReadPmcStatusOutLength"/>
+ </output>
+ </command>
+-->
+ <command number="7" name="Erase Flash" flag="true1" source="PC">
+ <documentation>
+ The Erase flash command is used to erase the complete flash memory.
+ </documentation>
+ <interface type="loader" name="EraseFlash"/>
+ <input>
+ </input>
+ <output>
+ </output>
+ </command>
+<!--
+ <command number="8" name="Program Without Erase Flash" flag="true1" source="PC">
+ <documentation>
+ The Program without erase flash command is sent by the PC to write a block of data into the flash memory, but, to save time, without checking if the flash is empty and without erasing the flash.
+ </documentation>
+ <interface type="loader" name="ProgramWithoutEraseFlash"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ProgramWithoutEraseIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="buffer" name="ProgramWithoutEraseFlashOut" length="*"/>
+ </output>
+ </command>
+
+ <command number="9" name="Dump Physical Flash Image" flag="true1" source="PC">
+ <documentation>
+ The Dump physical flash image command is used to read data from a physical flash location (physical addresses) and send it to the PC.
+ </documentation>
+ <interface type="loader" name="DumpPhysicalFlashImage"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="DumpPhysicalFlashImageIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="DumpPhysicalFlashImageOutLength"/>
+ <value type="buffer" name="DumpPhysicalFlashImageOut" length="DumpPhysicalFlashImageOutLength"/>
+ </output>
+ </command>
+-->
+ <command number="10" name="Speedflash" flag="true1" source="PC">
+ <documentation>
+ The Dump physical flash image command is used to read data from a physical flash location (physical addresses) and send it to the PC.
+ </documentation>
+ <interface type="loader" name="Speedflash"/>
+ <input>
+ <value type="uint32" name="StartAddress">Start address of the block to be flashed</value>
+ <value type="uint32" name="EndAddress">End address of the block to be flashed</value>
+ <value type="uint32" name="SubBlockSize">Size of the single block to be transfered</value>
+ </input>
+ <output>
+ </output>
+ </command>
+<!--
+ <command number="11" name="Write Preflash Image Using Speedflash" flag="true1" source="PC">
+ <documentation>
+ The Write preflash speedflash command is used to write a preflash image to a flash memory.
+ </documentation>
+ <interface type="loader" name="WritePreflashImageUsingSpeedflash"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="WritePreflashImageUsingSpeedflashIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="WritePreflashImageUsingSpeedflashOutLength"/>
+ <value type="buffer" name="WritePreflashImageUsingSpeedflashOut" length="WritePreflashImageUsingSpeedflashOutLength"/>
+ </output>
+ </command>
+
+ <command number="19" name="Dump Preflash Image" flag="true1" source="PC">
+ <documentation>
+ This command reads all data from flash (both flash page data and corresponding redundant data) and dumps the data in a file from which a preflash image can be created.
+ </documentation>
+ <interface type="loader" name="DumpPreflashImage"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="DumpPreflashImageIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="DumpPreflashImageOutLength"/>
+ <value type="buffer" name="DumpPreflashImageOut" length="DumpPreflashImageOutLength"/>
+ </output>
+ </command>
+
+ <command number="20" name="Write Preflash Image" flag="true1" source="PC">
+ <documentation>
+ This command is used to write a preflashed image to a flash memory.
+ </documentation>
+ <interface type="loader" name="WritePreflashImage"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="WritePreflashImageIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="WritePreflashImageOutLength"/>
+ <value type="buffer" name="WritePreflashImageOut" length="WritePreflashImageOutLength"/>
+ </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>
+ The Get GDFS property command reads a GDFS setting on the access side.
+ </documentation>
+ <interface type="loader" name="GetGdfsPropertyAcc"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="GetGdfsPropertyAccIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="GetGdfsPropertyAccOutLength"/>
+ <value type="buffer" name="GetGdfsPropertyAccOut" length="GetGdfsPropertyAccOutLength"/>
+ </output>
+ </command>
+
+ <command number="2" name="Force start GDFS" flag="true1" source="PC">
+ <documentation>
+ The Force start GDFS command starts GDFS on the access side using the configuration sent in the data field.
+ </documentation>
+ <interface type="loader" name="ForceStartGdfsAcc"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ForceStartGdfsAccIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="ForceStartGdfsAccOutLength"/>
+ <value type="buffer" name="ForceStartGdfsAccOut" length="ForceStartGdfsAccOutLength"/>
+ </output>
+ </command>
+
+ <command number="3" name="Auto start GDFS" flag="true1" source="PC">
+ <documentation>
+ The Auto start GDFS command tries to find the currently used GDFS configuration inside the platform software on the flash.
+ </documentation>
+ <interface type="loader" name="AutoStartGdfsAcc"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="AutoStartGdfsAccIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="AutoStartGdfsAccOutLength"/>
+ <value type="buffer" name="AutoStartGdfsAccOut" length="AutoStartGdfsAccOutLength"/>
+ </output>
+ </command>
+
+ <command number="4" name="Format GDFS" flag="true1" source="PC">
+ <documentation>
+ The Format GDFS command is sent to the loader to format the GDFS.
+ </documentation>
+ <interface type="loader" name="FormatGdfsAcc"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="FormatGdfsAccIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="FormatGdfsAccOutLength"/>
+ <value type="buffer" name="FormatGdfsAccOut" length="FormatGdfsAccOutLength"/>
+ </output>
+ </command>
+
+ <command number="5" name="Read GDFS unit" flag="true1" source="PC">
+ <documentation>
+ The Read GDFS unit command retrieves a unit from GDFS on the access side.
+ </documentation>
+ <interface type="loader" name="ReadGdfsUnitAcc"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ReadGdfsUnitAccIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="ReadGdfsUnitAccOutLength"/>
+ <value type="buffer" name="ReadGdfsUnitAccOut" length="ReadGdfsUnitAccOutLength"/>
+ </output>
+ </command>
+
+ <command number="6" name="Read entire GDFS" flag="true1" source="PC">
+ <documentation>
+ The Read entire GDFS command is used to read all GDFS units in the ME on the access side.
+ </documentation>
+ <interface type="loader" name="ReadEntireGdfsAcc"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ReadEntireGdfsAccIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="ReadEntireGdfsAccOutLength"/>
+ <value type="buffer" name="ReadEntireGdfsAccOut" length="ReadEntireGdfsAccOutLength"/>
+ </output>
+ </command>
+
+ <command number="7" name="Write GDFS unit" flag="true1" source="PC">
+ <documentation>
+ The Write GDFS unit command is used to write one or more GDFS units on the access side.
+ </documentation>
+ <interface type="loader" name="WriteGdfsUnitAcc"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="WriteGdfsUnitAccIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="WriteGdfsUnitAccOutLength"/>
+ <value type="buffer" name="WriteGdfsUnitAccOut" length="WriteGdfsUnitAccOutLength"/>
+ </output>
+ </command>
+
+ <command number="10" name="Write entire GDFS" flag="true1" source="PC">
+ <documentation>
+ The Write entire GDFS command is used to write all GDFS units on the access side.
+ </documentation>
+ <interface type="loader" name="WriteEntireGdfsAcc"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="WriteEntireGdfsAccIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="WriteEntireGdfsAccOutLength"/>
+ <value type="buffer" name="WriteEntireGdfsAccOut" length="WriteEntireGdfsAccOutLength"/>
+ </output>
+ </command>
+
+ <command number="11" name="Dump entire GDFS" flag="true1" source="PC">
+ <documentation>
+ The Dump entire GDFS command is used to dump all GDFS units on the access side.
+ </documentation>
+ <interface type="loader" name="DumpEntireGdfsAcc"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="DumpEntireGdfsAccIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="DumpEntireGdfsAccOutLength"/>
+ <value type="buffer" name="DumpEntireGdfsAccOut" length="DumpEntireGdfsAccOutLength"/>
+ </output>
+ </command>
+
+ <command number="49" name="Get GDFS property" flag="true1" source="PC">
+ <documentation>
+ The Get GDFS property command reads a GDFS setting on the application side.
+ </documentation>
+ <interface type="loader" name="GetGdfsPropertyApp"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="GetGdfsPropertyAppIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="GetGdfsPropertyAppOutLength"/>
+ <value type="buffer" name="GetGdfsPropertyAppOut" length="GetGdfsPropertyAppOutLength"/>
+ </output>
+ </command>
+
+ <command number="50" name="Force start GDFS" flag="true1" source="PC">
+ <documentation>
+ The Force start GDFS command starts GDFS on the application side using the configuration sent in the data field.
+ </documentation>
+ <interface type="loader" name="ForceStartGdfsApp"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ForceStartGdfsAppIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="ForceStartGdfsAppOutLength"/>
+ <value type="buffer" name="ForceStartGdfsAppOut" length="ForceStartGdfsAppOutLength"/>
+ </output>
+ </command>
+
+ <command number="51" name="Auto start GDFS" flag="true1" source="PC">
+ <documentation>
+ The Auto start GDFS command tries to find the currently used GDFS configuration inside the platform software on the flash.
+ </documentation>
+ <interface type="loader" name="AutoStartGdfsApp"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="AutoStartGdfsAppIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="AutoStartGdfsAppOutLength"/>
+ <value type="buffer" name="AutoStartGdfsAppOut" length="AutoStartGdfsAppOutLength"/>
+ </output>
+ </command>
+
+ <command number="52" name="Format GDFS" flag="true1" source="PC">
+ <documentation>
+ The Format GDFS command is sent to the loader to format the GDFS on the application side.
+ </documentation>
+ <interface type="loader" name="FormatGdfsApp"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="FormatGdfsAppIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="FormatGdfsAppOutLength"/>
+ <value type="buffer" name="FormatGdfsAppOut" length="FormatGdfsAppOutLength"/>
+ </output>
+ </command>
+
+ <command number="53" name="Read GDFS unit" flag="true1" source="PC">
+ <documentation>
+ The Read GDFS unit command retrieves a unit from GDFS on the application side.
+ </documentation>
+ <interface type="loader" name="ReadGdfsUnitApp"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ReadGdfsUnitAppIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="ReadGdfsUnitAppOutLength"/>
+ <value type="buffer" name="ReadGdfsUnitAppOut" length="ReadGdfsUnitAppOutLength"/>
+ </output>
+ </command>
+
+ <command number="54" name="Read entire GDFS" flag="true1" source="PC">
+ <documentation>
+ The Read entire GDFS command is used to read all GDFS units in the ME on the application side.
+ </documentation>
+ <interface type="loader" name="ReadEntireGdfsApp"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ReadEntireGdfsAppIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="ReadEntireGdfsAppOutLength"/>
+ <value type="buffer" name="ReadEntireGdfsAppOut" length="ReadEntireGdfsAppOutLength"/>
+ </output>
+ </command>
+
+ <command number="55" name="Write GDFS unit" flag="true1" source="PC">
+ <documentation>
+ The Write GDFS unit command is used to write one or more GDFS units on the application side.
+ </documentation>
+ <interface type="loader" name="WriteGdfsUnitApp"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="WriteGdfsUnitAppIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="WriteGdfsUnitAppOutLength"/>
+ <value type="buffer" name="WriteGdfsUnitAppOut" length="WriteGdfsUnitAppOutLength"/>
+ </output>
+ </command>
+
+ <command number="58" name="Write entire GDFS" flag="true1" source="PC">
+ <documentation>
+ The Write entire GDFS command is used to write all GDFS units on the application side.
+ </documentation>
+ <interface type="loader" name="WriteEntireGdfsApp"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="WriteEntireGdfsAppIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="WriteEntireGdfsAppOutLength"/>
+ <value type="buffer" name="WriteEntireGdfsAppOut" length="WriteEntireGdfsAppOutLength"/>
+ </output>
+ </command>
+
+ <command number="59" name="Dump entire GDFS" flag="true1" source="PC">
+ <documentation>
+ The Dump Entire GDFS command is used to dump all GDFS units on the application side.
+ </documentation>
+ <interface type="loader" name="DumpEntireGdfsApp"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="DumpEntireGdfsAppIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="DumpEntireGdfsAppOutLength"/>
+ <value type="buffer" name="DumpEntireGdfsAppOut" length="DumpEntireGdfsAppOutLength"/>
+ </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="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="GetFSPropertyOutLength"/>
+ <value type="buffer" name="GetFSPropertyOut" length="GetFSPropertyOutLength"/>
+ </output>
+ </command>
+
+ <command number="2" name="Force Start File System" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="ForceStartFileSystem"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ForceStartFSIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="ForceStartFSOutLength"/>
+ <value type="buffer" name="ForceStartFSOut" length="ForceStartFSOutLength"/>
+ </output>
+ </command>
+
+ <command number="3" name="Set File System Property" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="SetFileSystemProperty"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="SetFSPropertyIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="SetFSPropertyOutLength"/>
+ <value type="buffer" name="SetFSPropertyOut" length="SetFSPropertyOutLength"/>
+ </output>
+ </command>
+
+ <command number="4" name="Copy File" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="CopyFile"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="CopyFileIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="CopyFileOutLength"/>
+ <value type="buffer" name="CopyFileOut" length="CopyFileOutLength"/>
+ </output>
+ </command>
+
+ <command number="5" name="Move File" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="MoveFile"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="MoveFileIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="MoveFileOutLength"/>
+ <value type="buffer" name="MoveFileOut" length="MoveFileOutLength"/>
+ </output>
+ </command>
+
+ <command number="6" name="Rename" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="Rename"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="RenameIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="RenameOutLength"/>
+ <value type="buffer" name="RenameOut" length="RenameOutLength"/>
+ </output>
+ </command>
+
+ <command number="7" name="Delete File" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="DeleteFile"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="DeleteFileIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="DeleteFileOutLength"/>
+ <value type="buffer" name="DeleteFileOut" length="DeleteFileOutLength"/>
+ </output>
+ </command>
+
+ <command number="8" name="Make Directory" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="MakeDirectory"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="MakeDirectoryIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="MakeDirectoryOutLength"/>
+ <value type="buffer" name="MakeDirectoryOut" length="MakeDirectoryOutLength"/>
+ </output>
+ </command>
+
+ <command number="9" name="Change Directory" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="ChangeDirectory"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ChangeDirectoryIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="ChangeDirectoryOutLength"/>
+ <value type="buffer" name="ChangeDirectoryOut" length="ChangeDirectoryOutLength"/>
+ </output>
+ </command>
+
+ <command number="10" name="Get Current Directory" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="GetCurrentDirectory"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="GetCurrentDirectoryIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="GetCurrentDirectoryOutLength"/>
+ <value type="buffer" name="GetCurrentDirectoryOut" length="GetCurrentDirectoryOutLength"/>
+ </output>
+ </command>
+
+ <command number="11" name="Remove Directory" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="RemoveDirectory"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="RemoveDirectoryIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="RemoveDirectoryOutLength"/>
+ <value type="buffer" name="RemoveDirectoryOut" length="RemoveDirectoryOutLength"/>
+ </output>
+ </command>
+
+ <command number="12" name="List Subdirectories" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="ListSubdirectories"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ListSubdirectoriesIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="ListSubdirectoriesOutLength"/>
+ <value type="buffer" name="ListSubdirectoriesOut" length="ListSubdirectoriesOutLength"/>
+ </output>
+ </command>
+
+ <command number="13" name="List Files" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="ListFiles"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ListFilesIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="ListFilesOutLength"/>
+ <value type="buffer" name="ListFilesOut" length="ListFilesOutLength"/>
+ </output>
+ </command>
+
+ <command number="14" name="Stat" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="Stat"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="StatIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="StatOutLength"/>
+ <value type="buffer" name="StatOut" length="StatOutLength"/>
+ </output>
+ </command>
+
+ <command number="15" name="Chmod" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="Chmod"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ChmodIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="ChmodOutLength"/>
+ <value type="buffer" name="ChmodOut" length="ChmodOutLength"/>
+ </output>
+ </command>
+
+ <command number="16" name="Put File" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="PutFile"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="PutFileIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="PutFileOutLength"/>
+ <value type="buffer" name="PutFileOut" length="PutFileOutLength"/>
+ </output>
+ </command>
+
+ <command number="17" name="Get File" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="GetFile"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="GetFileIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="GetFileOutLength"/>
+ <value type="buffer" name="GetFileOut" length="GetFileOutLength"/>
+ </output>
+ </command>
+
+ <command number="18" name="List Volumes" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="ListVolumes"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="ListVolumesIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="ListVolumesOutLength"/>
+ <value type="buffer" name="ListVolumesOut" length="ListVolumesOutLength"/>
+ </output>
+ </command>
+
+ <command number="19" name="Format Volume" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="FormatVolume"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="FormatVolumeIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="FormatVolumeOutLength"/>
+ <value type="buffer" name="FormatVolumeOut" length="FormatVolumeOutLength"/>
+ </output>
+ </command>
+
+ <command number="20" name="Get Free Space" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="GetFreeSpace"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="GetFreeSpaceIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="GetFreeSpaceOutLength"/>
+ <value type="buffer" name="GetFreeSpaceOut" length="GetFreeSpaceOutLength"/>
+ </output>
+ </command>
+
+ <command number="21" name="Verify Signed Archive Header" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="VerifySignedArchiveHeader"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="VerifySignedArchiveHeaderIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="VerifySignedArchiveHeaderOutLength"/>
+ <value type="buffer" name="VerifySignedArchiveHeaderOut" length="VerifySignedArchiveHeaderOutLength"/>
+ </output>
+ </command>
+
+ <command number="22" name="Verify Signed Archive Data" flag="true1" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="VerifySignedArchiveData"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="VerifySignedArchiveDataIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="VerifySignedArchiveDataOutLength"/>
+ <value type="buffer" name="VerifySignedArchiveDataOut" length="VerifySignedArchiveDataOutLength"/>
+ </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="PayloadSize">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="PayloadSize">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="WriteAndLockOTPLength">The length of Write And Lock OTP command buffer</value>
+ <value type="buffer" name="WriteAndLockOTPBuffer" length="WriteAndLockOTPLength">The buffer with Write And Lock OTP command application data</value>
+ </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="PayloadSize">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="WriteFullSignatureLength">The length of Write Full Signature command buffer</value>
+ <value type="buffer" name="WriteFullSignatureBuffer" length="WriteFullSignatureLength">The buffer with Write Full Signature command application data</value>
+ </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="PayloadSize"/>
+ </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="PayloadSize"/>
+ </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="PayloadSize"/>
+ </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="PayloadSize">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="PayloadSize">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="PayloadSize">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="PayloadSize"/>
+ </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="PayloadSize">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="PayloadSize"/>
+ </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">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="InitRequest"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="InitRequestIn" length="PayloadSize"/>
+ </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">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="UpdateRequest"/>
+ <input>
+ <value type="uint32" name="PayloadSize">Application packet length</value>
+ <value type="buffer" name="UpdateRequestIn" length="PayloadSize"/>
+ </input>
+ <output>
+ <value type="uint32" name="UpdateRequestOutLength"/>
+ <value type="buffer" name="UpdateRequestOut" length="UpdateRequestOutLength"/>
+ </output>
+ </command>
+
+ </group>
+-->
+ <group number="16" name="Control message">
+ <documentation>
+ A2 Control message (0x10)
+ </documentation>
+ <interface type="loader" name="A2_Control"/>
+
+ <command number="1" name="Loader Started" source="ME">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="LoaderStarted"/>
+ <input>
+ <value type="uint32" name="MaxLoaderPacketSize"/>
+ </input>
+ <output>
+ </output>
+ </command>
+
+ <command number="2" name="Ping" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="Ping"/>
+ <input>
+ </input>
+ <output>
+ </output>
+ </command>
+
+ <command number="3" name="Pong" source="ME">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="Pong"/>
+ <input>
+ </input>
+ <output>
+ </output>
+ </command>
+
+ <command number="4" name="Max Packet Size" source="PC">
+ <documentation>
+ </documentation>
+ <interface type="loader" name="MaxPacketSize"/>
+ <input>
+ </input>
+ <output>
+ <value type="uint16" name="MaxPacketSize"/>
+ </output>
+ </command>
+
+ <command number="5" name="Loader Not Started" source="ME">
+ <interface type="loader" name="LoaderNotStarted"/>
+ <documentation>
+ </documentation>
+ <input>
+ <value type="uint16" name="ErrorCode"/>
+ </input>
+ <output>
+ </output>
+ </command>
+
+ </group>
+</commandspec>
diff --git a/source/config/a2_commands_h.xsl b/source/config/a2_commands_h.xsl
new file mode 100644
index 0000000..230083d
--- /dev/null
+++ b/source/config/a2_commands_h.xsl
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="2.0" xmlns="http://www.w3.org/1999/XSL/Transform">
+
+<import href="a2_common.xsl"/>
+
+<output method="text" indent="no"/>
+<strip-space elements="*"/>
+<param name="target" />
+
+<template match="/commandspec">/* $Copyright ST-Ericsson 2010$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _A2_COMMANDS_H_
+#define _A2_COMMANDS_H_
+
+#include &quot;LCDriver.h&quot;
+#include &quot;LcmInterface.h&quot;
+#include &quot;t_basicdefinitions.h&quot;
+#include &quot;CmdResult.h&quot;
+//#include &quot;error_codes.h&quot;
+//#include &quot;t_a2_protocol.h&quot;
+//#include "a2_command_ids.h"
+
+class CLCDriverMethods;
+
+class A2LoaderRpcInterface
+{
+public:
+ A2LoaderRpcInterface(CLCDriverMethods* lcdMethods, CmdResult* cmdResult, LcmInterface* lcmInterface):
+ lcdMethods_(lcdMethods),
+ cmdResult_(cmdResult),
+ lcmInterface_(lcmInterface),
+ targetCpu_(0),
+ morePackets_(0)
+ {
+ }
+
+ virtual ~A2LoaderRpcInterface()
+ {
+ }
+<apply-templates select="group"/>
+public:
+ void setTargetCpu(uint8 targetCpu) { targetCpu_ = targetCpu; }
+ void setMorePackets(uint8 morePackets) { morePackets_ = morePackets; }
+protected:
+ CLCDriverMethods* lcdMethods_;
+ CmdResult* cmdResult_;
+ LcmInterface* lcmInterface_;
+ uint8 targetCpu_;
+ uint8 morePackets_;
+};
+
+#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;DoneRPC_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name)"/>
+ <with-param name="ref" select="concat(&apos;DoRPC_&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;DoRPC_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name)"/>
+ <with-param name="ref" select="concat(&apos;DoneRPC_&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/source/config/a2_commands_impl_h.xsl b/source/config/a2_commands_impl_h.xsl
new file mode 100644
index 0000000..6fb1631
--- /dev/null
+++ b/source/config/a2_commands_impl_h.xsl
@@ -0,0 +1,72 @@
+<?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 ST-Ericsson 2010$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _A2_COMMANDS_IMPL_H_
+#define _A2_COMMANDS_IMPL_H_
+
+#include &quot;a2_commands.h&quot;
+#include &quot;a2_command_ids.h&quot;
+#include &quot;LCDriver.h&quot;
+#include &quot;LcmInterface.h&quot;
+#include &quot;error_codes.h&quot;
+
+class CLCDriverMethods;
+
+class A2LoaderRpcInterfaceImpl : public A2LoaderRpcInterface
+{
+public:
+ A2LoaderRpcInterfaceImpl(CLCDriverMethods* lcdMethods, CmdResult* cmdResult, LcmInterface* lcmInterface):
+ A2LoaderRpcInterface(lcdMethods, cmdResult, lcmInterface)
+ {
+ }
+
+ ~A2LoaderRpcInterfaceImpl()
+ {
+ }
+
+ ErrorCode_e Do_CEH_Callback(CommandData_t* pCmdData);
+<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, &apos;PC&apos;)">
+ <call-template name="prototype">
+ <with-param name="name" select="concat(&apos;DoneRPC_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name, &apos;Impl&apos;)" />
+ <with-param name="ref" select="concat(&apos;DoRPC_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name)" />
+ <with-param name="direction" select="input" />
+ <with-param name="source" select="&apos;PC&apos;" />
+ </call-template>
+ </if>
+ <if test="contains(@source, &apos;ME&apos;)">
+ <call-template name="prototype">
+ <with-param name="name" select="concat(&apos;DoRPC_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name, &apos;Impl&apos;)" />
+ <with-param name="ref" select="concat(&apos;DoneRPC_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name)" />
+ <with-param name="direction" select="output" />
+ <with-param name="source" select="&apos;ME&apos;" />
+ </call-template>
+ </if>
+</template>
+
+</stylesheet>
diff --git a/source/config/a2_commands_marshal_cpp.xsl b/source/config/a2_commands_marshal_cpp.xsl
new file mode 100644
index 0000000..a30be7b
--- /dev/null
+++ b/source/config/a2_commands_marshal_cpp.xsl
@@ -0,0 +1,236 @@
+<?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="name($direction)='output'">
+ /* 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" /><if test="count(input/value) > 0"> if (0 != PayloadSize)
+ {
+<apply-templates select="input/value" mode="deserialize" /> }
+</if> ReturnValue = <value-of select="$name" />(Session<apply-templates select="input/value" mode="call" />);<apply-templates select="input/value" mode="clean"/>
+ }
+ break;
+ </when>
+ <when test="name($direction)='input'">
+ /* 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"/>):
+ {
+<if test="../@number != 16"> ResponseStatus = (ErrorCode_e)Serialization::get_uint16_le(&amp;Data_p);
+ PayloadSize -= 2;</if><text>
+</text>
+<apply-templates select="output/value" mode="deserialize_size" />
+<if test="count(output/value) > 0"><if test="../@number != 16"> if (E_SUCCESS == ResponseStatus)</if>
+ {
+<apply-templates select="output/value" mode="deserialize" /> }</if>
+ ReturnValue = <value-of select="$name" />(Session<if test="../@number != 16">, ResponseStatus</if><apply-templates select="output/value" mode="call"><with-param name="continue" select="'true'" /></apply-templates>);<apply-templates select="output/value" mode="clean"/>
+ }
+ break;
+ </when>
+ </choose>
+</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 "Serialization.h"
+#include "a2_commands_impl.h"
+#include "t_a2_protocol.h"
+//#include "a2_custom_commands.h" //when customer commands will be implemented
+#include "LCDriverMethods.h"
+
+#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(A2_CommandData_t)); \
+ CmdData.Type = TypeP; \
+ CmdData.ApplicationNr = ApplicationP; \
+ CmdData.CommandNr = CommandP; \
+ CmdData.SessionNr = SessionP; \
+ CmdData.Payload.Size = 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) \
+ { \
+ return E_ALLOCATE_FAILED; \
+ }\
+ }
+
+#define A2_COMMANDDATAOUT(TypeP,ApplicationP,CommandP,SessionP,SizeP,TargetCPU) \
+ memset((uint8*)&amp;CmdData, 0x00, sizeof(A2_CommandData_t)); \
+ CmdData.Type = TypeP; \
+ CmdData.ApplicationNr = ApplicationP; \
+ CmdData.CommandNr = CommandP; \
+ CmdData.SessionNr = SessionP; \
+ CmdData.Payload.Size = SizeP; \
+ CmdData.Payload.Data_p = NULL; \
+ CmdData.DestAddress = TargetCPU; \
+ if(SizeP != 0) \
+ { \
+ CmdData.Payload.Data_p = (uint8*)malloc(SizeP); \
+ if(NULL == CmdData.Payload.Data_p) \
+ { \
+ return E_ALLOCATE_FAILED; \
+ } \
+ }
+
+ErrorCode_e A2LoaderRpcInterfaceImpl::Do_CEH_Callback(CommandData_t* pCmdData)
+{
+ A2_CommandData_t* CmdData_p = (A2_CommandData_t*)pCmdData;
+ ErrorCode_e ReturnValue = E_GENERAL_FATAL_ERROR;
+ ErrorCode_e ResponseStatus = E_GENERAL_FATAL_ERROR;
+ boolean response = FALSE;
+ const void *Data_p = CmdData_p-&gt;Payload.Data_p;
+ uint32 PayloadSize = CmdData_p-&gt;Payload.Size;
+ uint16 Session = CmdData_p-&gt;SessionNr;
+
+ if (A2_GENERAL_RESPONSE == CmdData_p-&gt;Type)
+ {
+ // skip fields already handled by LCM: command group, 0xFF, more packets and original command
+ Data_p = ((uint8*)Data_p) + 4;
+ PayloadSize -= 4;
+ response = TRUE;
+ }
+ else if (A2_COMMAND == CmdData_p-&gt;Type)
+ {
+ // skip fields already handled by LCM: command group, command and more packets fields
+ Data_p = ((uint8*)Data_p) + 3;
+ PayloadSize -= 3;
+ response = FALSE;
+ }
+ else if (A2_CONTROL_MESSAGE == CmdData_p-&gt;Type)
+ {
+ // skip control message ID
+ Data_p = ((uint8*)Data_p) + 1;
+ PayloadSize -= 1;
+ response = FALSE;
+ }
+ else if (A2_SPEEDFLASH_GR == CmdData_p->Type)
+ {
+ uint16 Status = Serialization::get_uint16_le(&amp;Data_p);
+ lcdMethods_-&gt;AddEvent(new Event(EVENT_SPEEDFLASH, Status));
+ return E_SUCCESS;
+ }
+ else
+ {
+ return E_GENERAL_FATAL_ERROR;
+ }
+
+ switch(A2_COMMAND(response, CmdData_p-&gt;ApplicationNr, CmdData_p-&gt;CommandNr))
+ {
+<apply-templates select="group" mode="unmarshal"/>
+ default:
+ {
+ return E_COMMAND_NO_ERROR; // Do_CustomCEH_Call(CmdData_p); // when customer commands will be implemented
+ }
+ }
+
+ if (response)
+ {
+ lcdMethods_-&gt;AddEvent(new Event(EVENT_GR_RECEIVED, ResponseStatus, CmdData_p-&gt;ApplicationNr, CmdData_p-&gt;CommandNr));
+ }
+ else
+ {
+ lcdMethods_-&gt;AddEvent(new Event(EVENT_CMD_RECEIVED, 0, CmdData_p-&gt;ApplicationNr, CmdData_p-&gt;CommandNr));
+ }
+
+ return ReturnValue;
+}
+<apply-templates select="group" mode="marshal"/>
+</template>
+
+<template match="group/command" mode="marshal">
+<if test="contains(@source, &apos;PC&apos;)">
+ErrorCode_e <value-of select="concat('A2LoaderRpcInterface::DoRPC_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />(uint16 SessionOut<apply-templates select="input/value" mode="declare" />)
+{
+ ErrorCode_e Answer;
+ A2_CommandData_t CmdData;
+ void *Data_p;
+ uint32 PLSize = 3;
+<apply-templates select="input/value" mode="serialize_size"/>
+ A2_COMMANDDATAOUT(A2_COMMAND, <call-template name="groupidmain"/>, <call-template name="commandid"/>, SessionOut, PLSize, targetCpu_);
+ Data_p = CmdData.Payload.Data_p;
+
+ // set command group and command
+ Serialization::put_uint8(&amp;Data_p, <call-template name="groupidmain"/>);
+ Serialization::put_uint8(&amp;Data_p, <call-template name="commandid"/>);
+ // set more packets
+ Serialization::put_uint8(&amp;Data_p, morePackets_);
+
+<apply-templates select="input/value" mode="serialize"/>
+ Answer = lcmInterface_->A2CommandSend(&amp;CmdData);
+
+ if(NULL != CmdData.Payload.Data_p)
+ free(CmdData.Payload.Data_p);
+ return Answer;
+}
+</if>
+<if test="contains(@source, &apos;ME&apos;)">
+ErrorCode_e <value-of select="concat('A2LoaderRpcInterface::DoneRPC_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />(uint16 Session<apply-templates select="output/value" mode="declare"><with-param name="continue" select="'true'" /></apply-templates>)
+{
+ ErrorCode_e Answer;
+ A2_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(A2_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 = lcmInterface_->A2CommandSend(&amp;CmdData);
+
+ if(NULL != CmdData.Payload.Data_p)
+ free(CmdData.Payload.Data_p);
+ return Answer;
+}
+</if>
+</template>
+
+<template match="group/command" mode="unmarshal">
+ <if test="contains(@source, &apos;PC&apos;)">
+ <call-template name="unmarshal">
+ <with-param name="name" select="concat('DoneRPC_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="input"/>
+ </call-template>
+ </if>
+ <if test="contains(@source, &apos;ME&apos;)">
+ <call-template name="unmarshal">
+ <with-param name="name" select="concat('DoRPC_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="output"/>
+ </call-template>
+ </if>
+</template>
+
+</stylesheet>
diff --git a/source/config/a2_common.xsl b/source/config/a2_common.xsl
new file mode 100644
index 0000000..721b8cd
--- /dev/null
+++ b/source/config/a2_common.xsl
@@ -0,0 +1,227 @@
+<?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">
+
+<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='uint16'"><text> </text><value-of select="@name" /> = Serialization::get_uint16_le(&amp;Data_p);
+</when>
+<when test="@type='uint32'"><text> </text><value-of select="@name" /> = Serialization::get_uint32_le(&amp;Data_p);
+</when>
+<when test="@type='uint64'"><text> </text><value-of select="@name" /> = Serialization::get_uint64_le(&amp;Data_p);
+</when>
+<when test="@type='string'"><text> </text><value-of select="@name" /> = Serialization::skip_str(&amp;Data_p);
+</when>
+<when test="@type='buffer' and @length!='*'"><text> </text><value-of select="@name" /> = Data_p;
+<text> </text>Serialization::skip_block(&amp;Data_p, <value-of select="@length" />);
+</when>
+<when test="@type='buffer' and @length='*'"><text> </text><value-of select="@name" /> = Data_p;
+<text> </text>Serialization::skip_block(&amp;Data_p, <value-of select="@name" />PLSize);
+</when>
+</choose>
+</template>
+
+<template match="value" mode="deserialize_size">
+<choose>
+<when test="@type='uint16'"> uint16 <value-of select="@name" /> = 0;
+</when>
+<when test="@type='uint32'"> uint32 <value-of select="@name" /> = 0;
+</when>
+<when test="@type='uint64'"> uint64 <value-of select="@name" /> = 0;
+</when>
+<when test="@type='string'"> const char *<value-of select="@name" /> = NULL;
+</when>
+<when test="@type='buffer' and @length!='*'"> const void *<value-of select="@name" /> = NULL;
+</when>
+<when test="@type='buffer' and @length='*'"> const void *<value-of select="@name" /> = NULL;
+ uint32 <value-of select="@name" />PLSize = PayloadSize;
+</when>
+</choose>
+</template>
+
+<template match="value" mode="serialize">
+<choose>
+<when test="@type='uint16'"> Serialization::put_uint16_le(&amp;Data_p, <value-of select="@name" />);
+</when>
+<when test="@type='uint32' and @name!='PayloadSize'"> Serialization::put_uint32_le(&amp;Data_p, <value-of select="@name" />);
+</when>
+<when test="@type='uint64'"> Serialization::put_uint64_le(&amp;Data_p, <value-of select="@name" />);
+</when>
+<when test="@type='string'"> Serialization::put_uint32_le(&amp;Data_p, PLSize<value-of select="@name" />);
+ Serialization::put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);
+</when>
+<when test="@type='buffer' and @length='*'"> Serialization::put_block(&amp;Data_p, <value-of select="@name" />, <value-of select="@name" />PLSize);
+</when>
+<when test="@type='buffer' and @length!='*'"> Serialization::put_block(&amp;Data_p, <value-of select="@name" />, <value-of select="@length" />);
+</when>
+</choose>
+</template>
+
+<template match="value" mode="serialize_size">
+<choose>
+<when test="@type='uint16'"> PLSize += sizeof(uint16);
+</when>
+<when test="@type='uint32' and @name!='PayloadSize'"> PLSize += sizeof(uint32);
+</when>
+<when test="@type='uint64'"> PLSize += sizeof(uint64);
+</when>
+<when test="@type='buffer' and @length!='*'"> PLSize += <value-of select="@length" />;
+</when>
+</choose>
+</template>
+
+<template match="value" mode="serialize_size_declaration">
+<choose>
+<when test="@type='string'"> uint32 PLSize<value-of select="@name" /> = 0;
+</when>
+</choose>
+</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()" />
+</template>
+
+<template match="value" mode="declare">
+<param name="continue" select="'false'" />
+<if test="($continue = 'true') or (position() > 0)">, </if>
+<choose>
+<when test="@type='uint16'">const uint16 <value-of select="@name" /></when>
+<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" />PLSize, 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">
+</template>
+
+<template match="value" mode="call">
+<param name="continue" select="'false'" />
+<if test="($continue = 'true') or (position() > 0)">, </if>
+<choose>
+<when test="@type='uint16'">
+<value-of select="@name" />
+</when>
+<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" />PLSize, <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)='output' and contains(@source, 'PC')">
+ /**
+ * <value-of select="normalize-space(./documentation/text())"/>
+ * \see <value-of select="$ref"/>
+ * Call source: <value-of select="$source"/>
+ * @param [in] SessionOut Output session.<apply-templates select="input/value" mode="document" />
+ *
+ * @return ErrorCode_e ...
+ */
+ ErrorCode_e <value-of select="$name"/>(uint16 SessionOut<apply-templates select="input" mode="declare"/><apply-templates select="input/value" mode="declare"/>);
+ </when>
+ <when test="name($direction)='output' and contains(@source, 'ME')">
+ /**
+ * <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<apply-templates select="input/value" mode="declare"/>);
+ </when>
+ <when test="name($direction)='input' and contains(@source, 'PC')">
+ /**
+ * 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<if test="../@number != 16">, ErrorCode_e Status</if><apply-templates select="output/value" mode="declare">
+ <with-param name="continue" select="'true'" />
+ </apply-templates>);
+ </when>
+ <when test="name($direction)='input' and contains(@source, 'ME')">
+ /**
+ * Response to \see <value-of select="$ref"/>
+ * Call source: <value-of select="$source"/>
+ * @param [in] Session Transfered input session.
+ *
+ * @return ErrorCode_e ...
+ */
+ ErrorCode_e <value-of select="$name"/>(uint16 Session<apply-templates select="output/value" mode="declare">
+ <with-param name="continue" select="'true'" />
+ </apply-templates>);
+ </when>
+</choose>
+</template>
+
+</stylesheet>
diff --git a/source/config/command_ids_h.xsl b/source/config/command_ids_h.xsl
new file mode 100644
index 0000000..02e26b8
--- /dev/null
+++ b/source/config/command_ids_h.xsl
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="2.0" xmlns="http://www.w3.org/1999/XSL/Transform">
+
+<import href="common.xsl"/>
+
+<output method="text" indent="no"/>
+<strip-space elements="*"/>
+<param name="target" />
+
+<template match="/commandspec">/* $Copyright ST-Ericsson 2010$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _COMMAND_IDS_H
+#define _COMMAND_IDS_H
+#include &quot;t_basicdefinitions.h&quot;
+
+typedef enum {
+<apply-templates select="group" mode="id"/>} 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">
+<choose>
+<when test="@type='char_array'"> char <text></text><value-of select="@name" />[<text></text><value-of select="@size" />]; /**&lt; <value-of select="text()" /> */
+</when>
+<when test="@type='string'"> char *<text></text><value-of select="@name" />; /**&lt; <value-of select="text()" /> */
+</when>
+<when test="@type='uint32'">
+<text> </text><value-of select="@type" /><text> </text><value-of select="@name" />; /**&lt; <value-of select="text()" /> */
+</when>
+<when test="@type='uint64'">
+<text> </text><value-of select="@type" /><text> </text><value-of select="@name" />; /**&lt; <value-of select="text()" /> */
+</when>
+</choose>
+</template>
+
+<template match="group" mode="id">
+<if test="interface/@name != 'ADbg'">
+<text> </text><call-template name="groupid" /> = <value-of select="@number" />, /**&lt; <value-of select="@name" /> */
+</if>
+</template>
+
+<template match="command" mode="id">
+<if test="@ADbg!='true'">
+<text> </text><call-template name="commandid" /> = <value-of select="@number" />, /**&lt; <value-of select="@name" /> */
+</if>
+</template>
+
+</stylesheet>
diff --git a/source/config/commands.xml b/source/config/commands.xml
new file mode 100644
index 0000000..a762055
--- /dev/null
+++ b/source/config/commands.xml
@@ -0,0 +1,1165 @@
+<?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="commands_marshal.xsl"?>
+<?xml-stylesheet type="text/xml" href="commands_h.xsl"?>
+<?xml-stylesheet type="text/xml" href="commands_impl_h.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="char_array" name="Path_p" size="256">Absolute device path pointing of the described device</value>
+ <value type="char_array" name="Type_p" size="256">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="1" name="System application">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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="2" name="Flash application">
+ <documentation>
+ Flash Commands group (0x02)
+ </documentation>
+
+ <interface type="loader" name="Flash"/>
+
+ <command number="1" name="Process File" ADbg="false" source="PC">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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="3" name="File system operations">
+ <documentation>
+ File System Commands Group (0x03)
+ </documentation>
+ <interface type="loader" name="File_System_Operations"/>
+ <command number="2" name="Volume Properties" ADbg="false" source="PC">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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="4" name="OTP">
+ <documentation>
+ OTP handling commands Group (0x04)
+ </documentation>
+ <interface type="loader" name="OTP"/>
+
+ <command number="1" name="Read Bits" ADbg="false" source="PC">
+ <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">
+ <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">
+ <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">
+ <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="5" name="Parameter Storage">
+ <documentation>
+ Parameter Storage Commands Group (0x05)
+ </documentation>
+ <interface type="loader" name="ParameterStorage"/>
+
+ <command number="1" name="Read Global Data Unit" ADbg="false" source="PC">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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="6" name="Security">
+ <documentation>
+ Security settings Commands Group (0x06)
+ </documentation>
+ <interface type="loader" name="Security"/>
+
+ <command number="1" name="Set Domain" ADbg="false" source="PC">
+ <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">
+ <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">
+ <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">
+ <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">
+ <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="8" name="ADbg application">
+ <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>
+
+ </group>
+</commandspec>
diff --git a/source/config/commands_h.xsl b/source/config/commands_h.xsl
new file mode 100644
index 0000000..36a2356
--- /dev/null
+++ b/source/config/commands_h.xsl
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<stylesheet version="2.0" xmlns="http://www.w3.org/1999/XSL/Transform">
+
+<import href="common.xsl"/>
+
+<output method="text" indent="no"/>
+<strip-space elements="*"/>
+<param name="target" />
+
+<template match="/commandspec">/* $Copyright ST-Ericsson 2010$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _COMMANDS_H_
+#define _COMMANDS_H_
+
+#include &quot;LCDriver.h&quot;
+#include &quot;LcmInterface.h&quot;
+#include &quot;t_basicdefinitions.h&quot;
+#include &quot;CmdResult.h&quot;
+
+class CLCDriverMethods;
+
+class LoaderRpcInterface
+{
+public:
+ LoaderRpcInterface(CLCDriverMethods* lcdMethods, CmdResult* cmdResult, LcmInterface* lcmInterface):
+ cmdResult_(cmdResult),
+ lcmInterface_(lcmInterface),
+ lcdMethods_(lcdMethods)
+ {
+ }
+
+ virtual ~LoaderRpcInterface()
+ {
+ }
+<apply-templates select="group"/>
+protected:
+ CLCDriverMethods* lcdMethods_;
+ CmdResult* cmdResult_;
+ LcmInterface* lcmInterface_;
+};
+
+#endif /* _COMMANDS_H_ */
+</template>
+
+<template match="group/command">
+<if test="(contains(@source, &apos;ME&apos;)) and (@ADbg!='true')">
+<call-template name="prototype">
+ <with-param name="name" select="concat(&apos;DoneRPC_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name)"/>
+ <with-param name="ref" select="concat(&apos;DoRPC_&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;)) and (@ADbg!='true')">
+<call-template name="prototype">
+ <with-param name="name" select="concat(&apos;DoRPC_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name)"/>
+ <with-param name="ref" select="concat(&apos;DoneRPC_&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/source/config/commands_impl_h.xsl b/source/config/commands_impl_h.xsl
new file mode 100644
index 0000000..afbe846
--- /dev/null
+++ b/source/config/commands_impl_h.xsl
@@ -0,0 +1,67 @@
+<?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" />
+
+<template match="/commandspec">/* $Copyright ST-Ericsson 2010$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _COMMANDS_IMPL_H_
+#define _COMMANDS_IMPL_H_
+
+#include &quot;commands.h&quot;
+#include &quot;command_ids.h&quot;
+#include &quot;LCDriver.h&quot;
+#include &quot;LcmInterface.h&quot;
+#include &quot;error_codes.h&quot;
+
+class LoaderRpcInterfaceImpl : public LoaderRpcInterface
+{
+public:
+ LoaderRpcInterfaceImpl(CLCDriverMethods* lcdMethods, CmdResult* CmdResult, LcmInterface* LcmInterface):
+ LoaderRpcInterface(lcdMethods, CmdResult, LcmInterface) {}
+ ~LoaderRpcInterfaceImpl() {}
+
+ ErrorCode_e Do_CEH_Callback(CommandData_t * pCmdData);
+<apply-templates select="group" />
+};
+
+#endif /* _COMMANDS_IMPL_H_ */
+</template>
+
+<template match="group/documentation">
+<if test="../interface/@name != 'ADbg'">
+ /*
+ * <value-of select="normalize-space(.)"/>
+ */
+</if>
+</template>
+
+<template match="group/command">
+ <if test="(contains(@source, &apos;PC&apos;)) and (@ADbg!=&apos;true&apos;)">
+ <call-template name="prototype">
+ <with-param name="name" select="concat(&apos;DoneRPC_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name, &apos;Impl&apos;)" />
+ <with-param name="ref" select="concat(&apos;DoRPC_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name)" />
+ <with-param name="direction" select="input" />
+ <with-param name="source" select="&apos;PC&apos;" />
+ </call-template>
+ </if>
+ <if test="(contains(@source, &apos;ME&apos;)) and (@ADbg!=&apos;true&apos;)">
+ <call-template name="prototype">
+ <with-param name="name" select="concat(&apos;DoRPC_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name, &apos;Impl&apos;)" />
+ <with-param name="ref" select="concat(&apos;DoneRPC_&apos;, ../interface[@type=&apos;loader&apos;]/@name, &apos;_&apos;, ./interface[@type=&apos;loader&apos;]/@name)" />
+ <with-param name="direction" select="output" />
+ <with-param name="source" select="&apos;ME&apos;" />
+ </call-template>
+ </if>
+</template>
+
+</stylesheet>
diff --git a/source/config/commands_marshal_cpp.xsl b/source/config/commands_marshal_cpp.xsl
new file mode 100644
index 0000000..14a1c3e
--- /dev/null
+++ b/source/config/commands_marshal_cpp.xsl
@@ -0,0 +1,211 @@
+<?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"/>
+
+<template match="group/documentation" mode="marshal">
+<if test="../interface/@name != 'ADbg'">
+/*
+ * <value-of select="normalize-space(.)"/>
+ */
+</if>
+</template>
+
+<template match="group/documentation" mode="unmarshal">
+<if test="../interface/@name != 'ADbg'">
+ /*
+ * <value-of select="normalize-space(.)"/>
+ */
+</if>
+</template>
+
+<template name="unmarshal">
+ <param name="name"/>
+ <param name="direction"/>
+
+ <choose>
+ <when test="name($direction)='output'">
+ /* 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" /> ReturnValue = <value-of select="$name" />(Session<apply-templates select="input/value" mode="call" />);<apply-templates select="input/value" mode="clean"/>
+ }
+ break;
+ </when>
+ <when test="name($direction)='input'">
+ /* 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)Serialization::get_uint32_le(&amp;Data_p);<if test="count(output/value) > 0">
+ if (E_SUCCESS == ResponseStatus)
+ {
+<apply-templates select="output/value" mode="deserialize" /> }</if>
+ ReturnValue = <value-of select="$name" />(Session, ResponseStatus<apply-templates select="output/value" mode="call"><with-param name="continue" select="'true'" /></apply-templates>);<apply-templates select="output/value" mode="clean"/>
+ }
+ break;
+ </when>
+ </choose>
+</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 "commands.h"
+//#include "custom_commands.h" // when customer commands will be implemented
+#include "command_ids.h"
+#include "commands_impl.h"
+#include "error_codes.h"
+#include "Serialization.h"
+#include "t_r15_network_layer.h"
+#include "Event.h"
+#include "LCDriverMethods.h"
+
+#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; \
+ if(SizeP != 0)\
+ {\
+ CmdData.Payload.Data_p = (uint8 *)malloc(sizeof(ErrorCode_e)+SizeP); \
+ if(NULL == CmdData.Payload.Data_p) \
+ { \
+ return E_ALLOCATE_FAILED; \
+ }\
+ }
+
+#define COMMANDDATAOUT(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; \
+ if(SizeP != 0)\
+ {\
+ CmdData.Payload.Data_p = (uint8 *)malloc( SizeP); \
+ if(NULL == CmdData.Payload.Data_p) \
+ { \
+ return E_ALLOCATE_FAILED; \
+ }\
+ }
+
+ ErrorCode_e LoaderRpcInterfaceImpl::Do_CEH_Callback(CommandData_t *CmdData_p)
+ {
+ ErrorCode_e ReturnValue = E_GENERAL_FATAL_ERROR;
+ ErrorCode_e ResponseStatus = E_GENERAL_FATAL_ERROR;
+ boolean response = FALSE;
+ const 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;
+ }
+ else
+ {
+ response = FALSE;
+ }
+
+ Session = CmdData_p-&gt;SessionNr;
+
+ switch(COMMAND(response, CmdData_p-&gt;ApplicationNr, CmdData_p-&gt;CommandNr))
+ {
+<apply-templates select="group" mode="unmarshal"/>
+ default:
+ {
+ return E_COMMAND_NO_ERROR; // Do_CustomCEH_Call(CmdData_p); // when customer commands will be implemented
+ }
+ }
+
+ if (response)
+ {
+ lcdMethods_-&gt;AddEvent(new Event(EVENT_GR_RECEIVED, ResponseStatus, CmdData_p-&gt;ApplicationNr, CmdData_p-&gt;CommandNr));
+ }
+ else
+ {
+ lcdMethods_-&gt;AddEvent(new Event(EVENT_CMD_RECEIVED, 0, CmdData_p-&gt;ApplicationNr, CmdData_p-&gt;CommandNr));
+ }
+
+ return ReturnValue;
+ }
+<apply-templates select="group" mode="marshal"/>
+</template>
+
+<template match="group/command" mode="marshal">
+<if test="(contains(@source, &apos;PC&apos;)) and (@ADbg!='true')">
+ErrorCode_e <value-of select="concat('LoaderRpcInterface::DoRPC_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />(uint16 SessionOut<apply-templates select="input/value" mode="declare" />)
+{
+ 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"/>, SessionOut, PLSize);
+ Data_p = CmdData.Payload.Data_p;
+<apply-templates select="input/value" mode="serialize"/>
+ Answer = lcmInterface_->CommandSend(&amp;CmdData);
+
+ if(NULL != CmdData.Payload.Data_p)
+ free(CmdData.Payload.Data_p);
+ return Answer;
+}
+</if>
+<if test="(contains(@source, &apos;ME&apos;)) and (@ADbg!='true')">
+ErrorCode_e <value-of select="concat('LoaderRpcInterface::DoneRPC_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name)" />(uint16 Session, ErrorCode_e Status<apply-templates select="output/value" mode="declare"><with-param name="continue" select="'true'" /></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;
+
+ Serialization::put_uint32_le(&amp;Data_p, Status);
+<apply-templates select="output/value" mode="serialize"/>
+ Answer = lcmInterface_->CommandSend(&amp;CmdData);
+
+ if(NULL != CmdData.Payload.Data_p)
+ free(CmdData.Payload.Data_p);
+ return Answer;
+}
+</if>
+</template>
+
+<template match="group/command" mode="unmarshal">
+ <if test="(contains(@source, &apos;PC&apos;)) and (@ADbg!='true')">
+ <call-template name="unmarshal">
+ <with-param name="name" select="concat('DoneRPC_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="input"/>
+ </call-template>
+ </if>
+ <if test="(contains(@source, &apos;ME&apos;)) and (@ADbg!='true')">
+ <call-template name="unmarshal">
+ <with-param name="name" select="concat('DoRPC_', ../interface[@type='loader']/@name, '_', ./interface[@type='loader']/@name, 'Impl')" />
+ <with-param name="direction" select="output"/>
+ </call-template>
+ </if>
+</template>
+
+</stylesheet>
diff --git a/source/config/common.xsl b/source/config/common.xsl
new file mode 100644
index 0000000..2072c81
--- /dev/null
+++ b/source/config/common.xsl
@@ -0,0 +1,262 @@
+<?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">
+
+<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" /> = Serialization::get_uint32_le(&amp;Data_p);
+</when>
+<when test="@type='uint64'"><text> </text><value-of select="@name" /> = Serialization::get_uint64_le(&amp;Data_p);
+</when>
+<when test="@type='string'"><text> </text><value-of select="@name" /> = Serialization::skip_str(&amp;Data_p);
+</when>
+<when test="@type='buffer' and @length!='*'"><text> </text><value-of select="@name" /> = Data_p;
+<text> </text>Serialization::skip_block(&amp;Data_p, <value-of select="@length" />);
+</when>
+<when test="@type='SupportedCommand' and @length!='*'"><text> </text><value-of select="@name" /> = Serialization::get_supportedcommands(&amp;Data_p, <value-of select="@length" />);
+</when>
+<when test="@type='ListDevice' and @length!='*'"><text> </text><value-of select="@name" /> = Serialization::get_devices(&amp;Data_p, <value-of select="@length" />);
+</when>
+<when test="@type='DirEntry' and @length!='*'"><text> </text><value-of select="@name" /> = Serialization::get_direntries(&amp;Data_p, <value-of select="@length" />);
+</when>
+<when test="@type='Cipher' and @length!='*'"><text> </text><value-of select="@name" /> = Data_p;
+<text> </text>Serialization::skip_str(&amp;Data_p);
+</when>
+</choose>
+</template>
+
+<template match="value" mode="deserialize_size">
+<choose>
+<when test="@type='uint32'"> uint32 <value-of select="@name" /> = 0;
+</when>
+<when test="@type='uint64'"> uint64 <value-of select="@name" /> = 0;
+</when>
+<when test="@type='string'"> const char *<value-of select="@name" /> = NULL;
+</when>
+<when test="@type='buffer' and @length!='*'"> const void *<value-of select="@name" /> = NULL;
+</when>
+<when test="@type='SupportedCommand' and @length!='*'"> SupportedCommand_t *<value-of select="@name" /> = NULL;
+</when>
+<when test="@type='ListDevice' and @length!='*'"> ListDevice_t *<value-of select="@name" /> = NULL;
+</when>
+<when test="@type='DirEntry' and @length!='*'"> DirEntry_t *<value-of select="@name" /> = NULL;
+</when>
+<when test="@type='Cipher' and @length!='*'"> Cipher_t *<value-of select="@name" /> = NULL;
+</when>
+</choose>
+</template>
+
+<template match="value" mode="serialize">
+<choose>
+<when test="@type='uint32'"> Serialization::put_uint32_le(&amp;Data_p, <value-of select="@name" />);
+</when>
+<when test="@type='uint64'"> Serialization::put_uint64_le(&amp;Data_p, <value-of select="@name" />);
+</when>
+<when test="@type='string'"> Serialization::put_uint32_le(&amp;Data_p, PLSize<value-of select="@name" />);
+ Serialization::put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);
+</when>
+<when test="@type='buffer' and @length='*'"> Serialization::put_block(&amp;Data_p, <value-of select="@name" />, <value-of select="@name" />PLSize);
+</when>
+<when test="@type='buffer' and @length!='*'"> Serialization::put_block(&amp;Data_p, <value-of select="@name" />, <value-of select="@length" />);
+</when>
+<when test="@type='SupportedCommand' and @length!='*'"> Serialization::put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);
+</when>
+<when test="@type='ListDevice' and @length!='*'"> Serialization::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!='*'"> Serialization::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!='*'"> Serialization::put_block(&amp;Data_p, <value-of select="@name" />, PLSize<value-of select="@name" />);
+</when>
+</choose>
+</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 += sizeof(uint32);
+ PLSize<value-of select="@name" /> = strlen(<value-of select="@name" />);
+ PLSize += PLSize<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 += Serialization::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 += Serialization::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>
+</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='Cipher'"> uint32 PLSize<value-of select="@name" /> = 0;
+</when>
+</choose>
+</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()" />
+</template>
+
+<template match="value" mode="declare">
+<param name="continue" select="'false'" />
+<if test="($continue = 'true') or (position() > 0)">, </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!='*'">const 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="input" mode="declare">
+</template>
+
+<template match="value" mode="call">
+<param name="continue" select="'false'" />
+<if test="($continue = 'true') or (position() > 0)">, </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>
+<when test="@type='SupportedCommand' and @length='*'">
+<value-of select="@name" />Count, <value-of select="@name" />
+</when>
+<when test="@type='SupportedCommand' and @length!='*'">
+<value-of select="@name" />
+</when>
+<when test="@type='ListDevice' and @length='*'">
+<value-of select="@name" />Count, <value-of select="@name" />
+</when>
+<when test="@type='ListDevice' and @length!='*'">
+<value-of select="@name" />
+</when>
+<when test="@type='DirEntry' and @length='*'">
+<value-of select="@name" />Count, <value-of select="@name" />
+</when>
+<when test="@type='DirEntry' and @length!='*'">
+<value-of select="@name" />
+</when>
+</choose>
+</template>
+
+<template match="group/documentation">
+<if test="../interface/@name != 'ADbg'">
+ /*
+ * <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)='output' and contains(@source, 'PC')">
+ /**
+ * <value-of select="normalize-space(./documentation/text())"/>
+ * \see <value-of select="$ref"/>
+ * Call source: <value-of select="$source"/>
+ * @param [in] SessionOut Output session.<apply-templates select="input/value" mode="document" />
+ *
+ * @return ErrorCode_e ...
+ */
+ ErrorCode_e <value-of select="$name"/>(uint16 SessionOut<apply-templates select="input" mode="declare"/><apply-templates select="input/value" mode="declare"/>);
+ </when>
+ <when test="name($direction)='output' and contains(@source, 'ME')">
+ /**
+ * <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<apply-templates select="input/value" mode="declare"/>);
+ </when>
+ <when test="name($direction)='input'">
+ /**
+ * 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<apply-templates select="output/value" mode="declare">
+ <with-param name="continue" select="'true'" />
+ </apply-templates>);
+ </when>
+</choose>
+</template>
+
+</stylesheet>
diff --git a/source/config/lcdriver_error_codes.xml b/source/config/lcdriver_error_codes.xml
new file mode 100644
index 0000000..a68d939
--- /dev/null
+++ b/source/config/lcdriver_error_codes.xml
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+-->
+<commandspec>
+ <status>
+ <!--
+ * General Fatal 10001-10025
+ * General Non-Fatal 10026-10050
+ -->
+ <value number="10001" name="TIMEOUT" fatal="false" short="Timeout event occured.">Timeout for previously sent request has occured. Request could be Protrom Command, Bulk transfer, or R15 Command.</value>
+ <value number="10002" name="INVALID_INPUT_PARAMETERS" fatal="false" short="Invalid parameter during Context initialization.">Invalid parameter found during executing LCDriver initialization functions. Failed to initialize Context.</value>
+
+ <!--
+ * Interface Fatal 10051-10075
+ * Interface Non-Fatal 10076-10100
+ -->
+ <value number="10051" name="INTERFACE_COULD_NOT_ADD_OBJECT_TO_LIST" fatal="true" short="Failed to create context for connected device.">Failed to add the LCDriver context for the new device in the devices list. Try to reconnect the device, if the problem is still present report it.</value>
+ <value number="10052" name="INTERFACE_COULD_NOT_CREATE_OBJECT" fatal="true" short="Failed to create loader interface.">Failed to create interface for loader methods, possibly not enough memory to perform the operation. Try to reconnect the device, if the problem is still present report it.</value>
+ <value number="10053" name="INTERFACE_UNKNOWN_EXECPTION_WHILE_ADDING_OBJECT" fatal="true" short="Failed to create context for connected device.">Unknown exception occured while trying to create context for the connected device. Try to reconnect the device, if the problem is still present report it.</value>
+ <value number="10054" name="INTERFACE_COULD_NOT_CREATE_IFC_OBJECT" fatal="true" short="Failed to create context for connected device.">Failed to create LCDriver context for the connected device, possibly not enough memory to perform the operation. Try to reconnect the device, if the problem is still present report it.</value>
+ <value number="10055" name="INTERFACE_OBJECT_POINTER_TO_POINTER_NULL" fatal="true" short="Invalid pointer to interface.">Tried to create LCDriver interface with invalid pointer.</value>
+ <value number="10056" name="INTERFACE_OBJECT_POINTER_NULL" fatal="true" short="Invalid pointer to LCDriver context.">Tried to configure device with invalid pointer to LCDriver interface. Create the LCDriver interface for the conneceted device and try to configure the device later. If the problem is still present report it.</value>
+ <value number="10076" name="INTERFACE_OBJECT_ALREADY_EXISTS" fatal="false" short="LCDriver interface for the device already exists.">The context for the device was previously created.</value>
+ <value number="10077" name="INTERFACE_LC_METHODS_OBJECT_NULL" fatal="false" short="Interface for loader methods is not created.">Tried to execute loader method without creating loader method interface. Create the interface first and retry the same operation. If the problem is still present report it.</value>
+ <value number="10078" name="INTERFACE_INTERFACEID_POINTER_NULL" fatal="false" short="Failed to create LCDriver context.">Tried to create LCDriver context with invalid ID for the context. Try to create context with different context ID, if the problem is still present report it.</value>
+ <value number="10079" name="INTERFACE_CONTEXT_NOT_STARTED" fatal="false" short="LCDriver context is not started.">Tried to call loader method before starting the LCDriver context. Try to start the context before calling loader methods, if the problem is still present report it.</value>
+
+ <!--
+ * System Thread Fatal 10101-10125
+ * System Thread Non-Fatal 10126-10150
+ -->
+ <value number="10126" name="LCDRIVER_THREAD_UNKNOWN_EXCEPTION" fatal="false" short="Unexpexted exit of LCDriver thread.">The LCDriver thread exited in unexpected way. The error is not recognized, if the problem persists report it.</value>
+
+ <!--
+ * Bulk Fatal 10151-10175
+ * Bulk Non-Fatal 10176-10200
+ -->
+ <value number="10176" name="BULK_VECTOR_ID_ERROR" fatal="false" short="Failed to start bulk session.">Failed to open bulk session due to invalid Bulk Vector ID.</value>
+ <value number="10177" name="BULK_ALREADY_IN_PROGRESS" fatal="false" short="Bulk transfer is already in progress.">Bulk transfer is already in progress. Parallel bulk transfers are not supported</value>
+
+ <!--
+ * Hardware Fatal 10201-10225
+ * Hardware Non-Fatal 10226-10250
+ -->
+ <value number="10201" name="PROTROM_STATUS_NOT_OK" fatal="true" short="ROM Code Failure.">Error occured while communicating the ROM code. Possibly there is some security issue with the used SW/HW.</value>
+ <value number="10226" name="TIMEOUT_NO_CHIP_ID_DETECTED" fatal="false" short="Failed to initialize HW.">The HW failed to respond during the initialization sequence. Try with other HW, if the problem still exist report it, otherwise probably it faulty HW.</value>
+ <value number="10227" name="TIMEOUT_NO_Z_DETECTED" fatal="false" short="Failed to start HW initialization.">The HW initialization failed to start. Try with other HW, if the problem still exist report it, otherwise probably it faulty HW.</value>
+
+ <!--
+ * Loader Command Execution Fatal 10251-10275
+ * Loader Command Execution Non-Fatal 10276-10300
+ -->
+ <value number="10276" name="PARALLEL_COMMAND_EXECUTION_NOT_SUPPORTED" fatal="false" short="Command execution failed.">Failed to execute command because there is other active command. Try to execute command again. If the problem persists probably there is some blocked command. Restart the HW.</value>
+ <value number="10277" name="CALLBACKS_NOT_CONFIGURED_CORRECTLY" fatal="false" short="Communication driver configuration failure.">Callbacks for communication decvice are not configured. Try to configure device driver callbacks. If the problem persists report it.</value>
+ <value number="10278" name="GENERAL_RESPONSE_COMMAND_NUMBER_ERROR" fatal="false" short="Failure during command execution.">Recived response for command other than it was expected. Probably there is communication error. Restart the HW, if the problem persists report it.</value>
+ <value number="10279" name="COMMAND_NUMBER_ERROR" fatal="false" short="Failure during command execution.">Command received from ME other than it was expected. Probably there is communication error. Restart the HW, if the problem persists report it.</value>
+ <value number="10280" name="CANCEL_EVENT_RECEIVED" fatal="false" short="Operation execution is canceled.">Canceled execution of active command/communication due to reciving of cancel event.</value>
+ <value number="10281" name="UNEXPECTED_EVENT_RECEIVED" fatal="false" short="Unexpected event during execution.">Unexpected event was received during command execution.</value>
+ <value number="10282" name="INVALID_EXECUTION_MODE" fatal="false" short="Invalid execution mode.">Unexpected event was received during command execution.</value>
+
+ <!--
+ * Buffers Fatal 10301-10325
+ * Buffers Non-Fatal 10326-10350
+ -->
+ <value number="10326" name="BUFFER_BULK_FILE_NOT_ALOCATED" fatal="false" short="Bulk transfer failed.">Failed to load file from local HDD in RAM. Command execution failed.</value>
+
+ <!--
+ * IO File Fatal 10351-10375
+ * IO File Non-Fatal 10376-10400
+ -->
+ <value number="10376" name="FILE_OPENING_ERROR" fatal="false" short="Failed to open file.">Failed to open the file with the given path. Check if the file path is correct.</value>
+ <value number="10377" name="FILE_CREATE_MAPPING_ERROR" fatal="false" short="Failed to load the file in RAM.">Mapping of the file in RAM failed. Try to execute command again, if problem persist try to restart the HW.</value>
+ <value number="10378" name="FILE_MAPPING_VIEW_ERROR" fatal="false" short="Reading of file failed.">Failed to create desired view on RAM area of the mapped file. Try to execute command again, if problem persist try to restart the HW.</value>
+ <value number="10379" name="FILE_FAILED_TO_GET_SIZE" fatal="false" short="Failed to load the file in RAM.">Failed to read file description. Try to execute command again, if problem persist try to restart the HW.</value>
+ <value number="10379" name="FILE_READ_INVALID_OFFSET" fatal="false" short="Invalid data offset requested.">Invalid file offset requested. Try to execute command again, if problem persist try to restart the HW.</value>
+ <value number="10380" name="FILE_READ_ERROR" fatal="false" short="Failed to read from file.">Failed to read data from file. Try to execute command again, if problem persist try to restart the HW.</value>
+
+ <!--
+ * LCM DLL Fatal 10401-10425
+ * LCM DLL Non-Fatal 10426-10450
+ -->
+ <value number="10401" name="LCM_DLL_LOAD_LOADLIBRARY_ERROR" fatal="true" short="Failed to load LCM library.">Loading of dependant library failed. Make sure that it is placed on correct location.</value>
+ <value number="10402" name="LCM_DLL_LOAD_FUNCTION_NOT_FOUND" fatal="true" short="Failed to import LCM functionality.">Some of dependend functions was not found in the given LCM library. Make sure that the version that is used is compatible.</value>
+
+ <!--
+ * Exceptions Fatal 10451-10475
+ * Exceptions Non-Fatal 10476-10500
+ -->
+ <value number="10451" name="UNKNOWN_EXCEPTION" fatal="true" short="Unknown error has stopped the operation.">The active operation was stopped by uknown exception. Repeat the failure procedure, if the problem persists report it.</value>
+ <value number="10476" name="UNKNOWN_WAIT_RETURN_VALUE" fatal="false" short="Operation execution failed.">The activity didn't complete properly. Unhandled event was recieved during execution of command/activity.</value>
+ <value number="10477" name="UNKNOWN_BULK_TRANSFER_EXCEPTION" fatal="false" short="Bulk transfer failed.">The transfer of bulk data was interrpted by unknown exception. Data was not transferred successfuly.</value>
+ <value number="10478" name="UNKNOWN_INTERFACE_EXCEPTION" fatal="false" short="LCDriver context operation failed.">Failed to perform desired operation on the LCDriver context due to unknown exception.</value>
+
+ <!--
+ * LCDriver Thread Fatal 10501-10525
+ * LCDriver Thread Non-Fatal 10526-10550
+ -->
+ <value number="10526" name="LCDRIVER_THREAD_KILLED" fatal="false" short="LCDriver thread stopped.">Execution of LCDriver thread has stopped because the thread was killed with unknown reason.</value>
+ <value number="10527" name="LCDRIVER_THREAD_KILLED_WITH_CANCEL" fatal="false" short="LCDriver thread stopped.">Execution of LCDriver thread has stopped because the thread was killed by cancel event.</value>
+ <value number="10528" name="LCDRIVER_THREAD_KILLED_WITH_SIGNAL_DEATH" fatal="false" short="LCDriver thread stopped.">Execution of LCDriver thread has stopped with shutdown request.</value>
+ <value number="10529" name="LCDRIVER_THREAD_NOT_STARTED" fatal="false" short="Failed to start LCDriver thread.">Starting of LCDriver thread has failed. An error has occured during initialization. Reconnect the device, if the problem persist report it.</value>
+ <value number="10530" name="LCDRIVER_THREAD_STOPPED_AFTER_LCM_ERROR" fatal="false" short="LCDriver thread stopped after receiving LCM error.">LCDriver thread must be stopped due to unrecoverable error state in the LCM. Reconnect the device, if the problem persist report it.</value>
+
+ <!--
+ * LCM Communication Fatal 10551-10575
+ * LCM Communication Non-Fatal 10576-10600
+ -->
+ <value number="10551" name="LCM_RETRANSMISSION_ERROR" fatal="true" short="LCM failed to send packet.">Maximum number of packet retransmission attempts failed. Further communication of device is not possible. Reconnect the device, if the problem persist report it.</value>
+ <value number="10552" name="LCM_DEVICE_WRITE_ERROR" fatal="true" short="LCM failed to write data on communication device.">LCM failed to get response from communication device. Further communication of device is not possible. Reconnect the device, if the problem persist report it.</value>
+
+ </status>
+</commandspec>
diff --git a/source/config/lcdriver_error_codes_h.xsl b/source/config/lcdriver_error_codes_h.xsl
new file mode 100644
index 0000000..55fc0b1
--- /dev/null
+++ b/source/config/lcdriver_error_codes_h.xsl
@@ -0,0 +1,72 @@
+<?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 ST-Ericsson 2010$ */
+/* NOTE: This is an automatically generated file. DO NOT EDIT! */
+
+#ifndef _LCDRIVERERRORCODE_H
+#define _LCDRIVERERRORCODE_H
+
+/**
+ * Error codes for LCDriver.
+ */
+
+/**
+ * Table for Error groups range
+ *
+ * General Fatal 10001-10025
+ * General Non-Fatal 10026-10050
+ *
+ * Interface Fatal 10051-10075
+ * Interface Non-Fatal 10076-10100
+ *
+ * System Thread Fatal 10101-10125
+ * System Thread Non-Fatal 10126-10150
+ *
+ * Bulk Fatal 10151-10175
+ * Bulk Non-Fatal 10176-10200
+ *
+ * Hardware Fatal 10201-10225
+ * Hardware Non-Fatal 10226-10250
+ *
+ * Loader Command Execution Fatal 10251-10275
+ * Loader Command Execution Non-Fatal 10276-10300
+ *
+ * Buffers Fatal 10301-10325
+ * Buffers Non-Fatal 10326-10350
+ *
+ * IO File Fatal 10351-10375
+ * IO File Non-Fatal 10376-10400
+ *
+ * LCM DLL Fatal 10401-10425
+ * LCM DLL Non-Fatal 10426-10450
+ *
+ * Exceptions Fatal 10451-10475
+ * Exceptions Non-Fatal 10476-10500
+ *
+ * LCDriver Thread Fatal 10501-10525
+ * LCDriver Thread Non-Fatal 10526-10550
+ *
+ */
+<apply-templates select="status"/>
+#endif /* _LCDRIVERERRORCODE_H */
+</template>
+
+<template match="status">
+typedef enum {
+<apply-templates select="value"/>} InternalErrorCodes_e;
+</template>
+
+<template match="value">
+ <text> </text><value-of select="@name"/> = <value-of select="@number"/><if test="position() != last()">,</if> /** <value-of select="@short"/> */
+</template>
+
+</stylesheet>
diff --git a/source/resource.h b/source/resource.h
new file mode 100644
index 0000000..26db1bd
--- /dev/null
+++ b/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 LCDriver.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/source/security_algorithms/SecurityAlgorithms.cpp b/source/security_algorithms/SecurityAlgorithms.cpp
new file mode 100644
index 0000000..1d92e57
--- /dev/null
+++ b/source/security_algorithms/SecurityAlgorithms.cpp
@@ -0,0 +1,18 @@
+/******************************************************************************
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+******************************************************************************/
+#include "SecurityAlgorithms.h"
+#include "sha2.h"
+
+int SecurityAlgorithms::SHA256(unsigned char *pData, unsigned long ulDataLen, unsigned char *pDigest)
+{
+ SHA256_CTX c256;
+ SHA256_Init(&c256);
+ SHA256_Update(&c256, pData, ulDataLen);
+ SHA256_Final(pDigest, &c256);
+
+ return 0;
+}
diff --git a/source/security_algorithms/SecurityAlgorithms.h b/source/security_algorithms/SecurityAlgorithms.h
new file mode 100644
index 0000000..51dbcde
--- /dev/null
+++ b/source/security_algorithms/SecurityAlgorithms.h
@@ -0,0 +1,20 @@
+/******************************************************************************
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+******************************************************************************/
+
+#ifndef _SECURITYALGORITHMS_H_
+#define _SECURITYALGORITHMS_H_
+
+class SecurityAlgorithms
+{
+public:
+ static int SHA256(unsigned char *pData, unsigned long ulDataLen, unsigned char *pDigest);
+private:
+ SecurityAlgorithms();
+ ~SecurityAlgorithms();
+};
+
+#endif // _SECURITYALGORITHMS_H_
diff --git a/source/security_algorithms/sha/sha2.cpp b/source/security_algorithms/sha/sha2.cpp
new file mode 100644
index 0000000..af0fb8d
--- /dev/null
+++ b/source/security_algorithms/sha/sha2.cpp
@@ -0,0 +1,1064 @@
+/*
+ * FILE: sha2.c
+ * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/
+ *
+ * Copyright (c) 2000-2001, Aaron D. Gifford
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $
+ */
+
+#include <string.h> /* memcpy()/memset() or bcopy()/bzero() */
+#include <assert.h> /* assert() */
+#include "sha2.h"
+
+/*
+ * ASSERT NOTE:
+ * Some sanity checking code is included using assert(). On my FreeBSD
+ * system, this additional code can be removed by compiling with NDEBUG
+ * defined. Check your own systems manpage on assert() to see how to
+ * compile WITHOUT the sanity checking code on your system.
+ *
+ * UNROLLED TRANSFORM LOOP NOTE:
+ * You can define SHA2_UNROLL_TRANSFORM to use the unrolled transform
+ * loop version for the hash transform rounds (defined using macros
+ * later in this file). Either define on the command line, for example:
+ *
+ * cc -DSHA2_UNROLL_TRANSFORM -o sha2 sha2.c sha2prog.c
+ *
+ * or define below:
+ *
+ * #define SHA2_UNROLL_TRANSFORM
+ *
+ */
+
+
+/*** SHA-256/384/512 Machine Architecture Definitions *****************/
+/*
+ * BYTE_ORDER NOTE:
+ *
+ * Please make sure that your system defines BYTE_ORDER. If your
+ * architecture is little-endian, make sure it also defines
+ * LITTLE_ENDIAN and that the two (BYTE_ORDER and LITTLE_ENDIAN) are
+ * equivilent.
+ *
+ * If your system does not define the above, then you can do so by
+ * hand like this:
+ *
+ * #define LITTLE_ENDIAN 1234
+ * #define BIG_ENDIAN 4321
+ *
+ * And for little-endian machines, add:
+ *
+ * #define BYTE_ORDER LITTLE_ENDIAN
+ *
+ * Or for big-endian machines:
+ *
+ * #define BYTE_ORDER BIG_ENDIAN
+ *
+ * The FreeBSD machine this was written on defines BYTE_ORDER
+ * appropriately by including <sys/types.h> (which in turn includes
+ * <machine/endian.h> where the appropriate definitions are actually
+ * made).
+ */
+#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
+#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
+#endif
+
+/*
+ * Define the followingsha2_* types to types of the correct length on
+ * the native archtecture. Most BSD systems and Linux define u_intXX_t
+ * types. Machines with very recent ANSI C headers, can use the
+ * uintXX_t definintions from inttypes.h by defining SHA2_USE_INTTYPES_H
+ * during compile or in the sha.h header file.
+ *
+ * Machines that support neither u_intXX_t nor inttypes.h's uintXX_t
+ * will need to define these three typedefs below (and the appropriate
+ * ones in sha.h too) by hand according to their system architecture.
+ *
+ * Thank you, Jun-ichiro itojun Hagino, for suggesting using u_intXX_t
+ * types and pointing out recent ANSI C support for uintXX_t in inttypes.h.
+ */
+#ifdef SHA2_USE_INTTYPES_H
+
+typedef uint8_t sha2_byte; /* Exactly 1 byte */
+typedef uint32_t sha2_word32; /* Exactly 4 bytes */
+typedef uint64_t sha2_word64; /* Exactly 8 bytes */
+
+#else /* SHA2_USE_INTTYPES_H */
+
+typedef u_int8_t sha2_byte; /* Exactly 1 byte */
+typedef u_int32_t sha2_word32; /* Exactly 4 bytes */
+typedef u_int64_t sha2_word64; /* Exactly 8 bytes */
+
+#endif /* SHA2_USE_INTTYPES_H */
+
+
+/*** SHA-256/384/512 Various Length Definitions ***********************/
+/* NOTE: Most of these are in sha2.h */
+#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8)
+#define SHA384_SHORT_BLOCK_LENGTH (SHA384_BLOCK_LENGTH - 16)
+#define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16)
+
+
+/*** ENDIAN REVERSAL MACROS *******************************************/
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define REVERSE32(w,x) { \
+ sha2_word32 tmp = (w); \
+ tmp = (tmp >> 16) | (tmp << 16); \
+ (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \
+}
+#define REVERSE64(w,x) { \
+ sha2_word64 tmp = (w); \
+ tmp = (tmp >> 32) | (tmp << 32); \
+ tmp = ((tmp & 0xff00ff00ff00ff00ULL) >> 8) | \
+ ((tmp & 0x00ff00ff00ff00ffULL) << 8); \
+ (x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \
+ ((tmp & 0x0000ffff0000ffffULL) << 16); \
+}
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+
+/*
+ * Macro for incrementally adding the unsigned 64-bit integer n to the
+ * unsigned 128-bit integer (represented using a two-element array of
+ * 64-bit words):
+ */
+#define ADDINC128(w,n) { \
+ (w)[0] += (sha2_word64)(n); \
+ if ((w)[0] < (n)) { \
+ (w)[1]++; \
+ } \
+}
+
+/*
+ * Macros for copying blocks of memory and for zeroing out ranges
+ * of memory. Using these macros makes it easy to switch from
+ * using memset()/memcpy() and using bzero()/bcopy().
+ *
+ * Please define either SHA2_USE_MEMSET_MEMCPY or define
+ * SHA2_USE_BZERO_BCOPY depending on which function set you
+ * choose to use:
+ */
+#if !defined(SHA2_USE_MEMSET_MEMCPY) && !defined(SHA2_USE_BZERO_BCOPY)
+/* Default to memset()/memcpy() if no option is specified */
+#define SHA2_USE_MEMSET_MEMCPY 1
+#endif
+#if defined(SHA2_USE_MEMSET_MEMCPY) && defined(SHA2_USE_BZERO_BCOPY)
+/* Abort with an error if BOTH options are defined */
+#error Define either SHA2_USE_MEMSET_MEMCPY or SHA2_USE_BZERO_BCOPY, not both!
+#endif
+
+#ifdef SHA2_USE_MEMSET_MEMCPY
+#define MEMSET_BZERO(p,l) memset((p), 0, (l))
+#define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l))
+#endif
+#ifdef SHA2_USE_BZERO_BCOPY
+#define MEMSET_BZERO(p,l) bzero((p), (l))
+#define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l))
+#endif
+
+
+/*** THE SIX LOGICAL FUNCTIONS ****************************************/
+/*
+ * Bit shifting and rotation (used by the six SHA-XYZ logical functions:
+ *
+ * NOTE: The naming of R and S appears backwards here (R is a SHIFT and
+ * S is a ROTATION) because the SHA-256/384/512 description document
+ * (see http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf) uses this
+ * same "backwards" definition.
+ */
+/* Shift-right (used in SHA-256, SHA-384, and SHA-512): */
+#define R(b,x) ((x) >> (b))
+/* 32-bit Rotate-right (used in SHA-256): */
+#define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b))))
+/* 64-bit Rotate-right (used in SHA-384 and SHA-512): */
+#define S64(b,x) (((x) >> (b)) | ((x) << (64 - (b))))
+
+/* Two of six logical functions used in SHA-256, SHA-384, and SHA-512: */
+#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
+#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
+
+/* Four of six logical functions used in SHA-256: */
+#define Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x)))
+#define Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x)))
+#define sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x)))
+#define sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x)))
+
+/* Four of six logical functions used in SHA-384 and SHA-512: */
+#define Sigma0_512(x) (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x)))
+#define Sigma1_512(x) (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x)))
+#define sigma0_512(x) (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x)))
+#define sigma1_512(x) (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x)))
+
+/*** INTERNAL FUNCTION PROTOTYPES *************************************/
+/* NOTE: These should not be accessed directly from outside this
+ * library -- they are intended for private internal visibility/use
+ * only.
+ */
+void SHA512_Last(SHA512_CTX*);
+void SHA256_Transform(SHA256_CTX*, const sha2_word32*);
+void SHA512_Transform(SHA512_CTX*, const sha2_word64*);
+
+
+/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/
+/* Hash constant words K for SHA-256: */
+const static sha2_word32 K256[64] = {
+ 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
+ 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
+ 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
+ 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
+ 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
+ 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
+ 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
+ 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL,
+ 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
+ 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
+ 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
+ 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
+ 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
+ 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
+ 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
+ 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
+};
+
+/* Initial hash value H for SHA-256: */
+const static sha2_word32 sha256_initial_hash_value[8] = {
+ 0x6a09e667UL,
+ 0xbb67ae85UL,
+ 0x3c6ef372UL,
+ 0xa54ff53aUL,
+ 0x510e527fUL,
+ 0x9b05688cUL,
+ 0x1f83d9abUL,
+ 0x5be0cd19UL
+};
+
+/* Hash constant words K for SHA-384 and SHA-512: */
+const static sha2_word64 K512[80] = {
+ 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL,
+ 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL,
+ 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
+ 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL,
+ 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL,
+ 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
+ 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL,
+ 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL,
+ 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL,
+ 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL,
+ 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL,
+ 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
+ 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL,
+ 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL,
+ 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL,
+ 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL,
+ 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL,
+ 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL,
+ 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL,
+ 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL,
+ 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL,
+ 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL,
+ 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL,
+ 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
+ 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL,
+ 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL,
+ 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL,
+ 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL,
+ 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL,
+ 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL,
+ 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL,
+ 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL,
+ 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL,
+ 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL,
+ 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL,
+ 0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
+ 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL,
+ 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL,
+ 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
+ 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL
+};
+
+/* Initial hash value H for SHA-384 */
+const static sha2_word64 sha384_initial_hash_value[8] = {
+ 0xcbbb9d5dc1059ed8ULL,
+ 0x629a292a367cd507ULL,
+ 0x9159015a3070dd17ULL,
+ 0x152fecd8f70e5939ULL,
+ 0x67332667ffc00b31ULL,
+ 0x8eb44a8768581511ULL,
+ 0xdb0c2e0d64f98fa7ULL,
+ 0x47b5481dbefa4fa4ULL
+};
+
+/* Initial hash value H for SHA-512 */
+const static sha2_word64 sha512_initial_hash_value[8] = {
+ 0x6a09e667f3bcc908ULL,
+ 0xbb67ae8584caa73bULL,
+ 0x3c6ef372fe94f82bULL,
+ 0xa54ff53a5f1d36f1ULL,
+ 0x510e527fade682d1ULL,
+ 0x9b05688c2b3e6c1fULL,
+ 0x1f83d9abfb41bd6bULL,
+ 0x5be0cd19137e2179ULL
+};
+
+/*
+ * Constant used by SHA256/384/512_End() functions for converting the
+ * digest to a readable hexadecimal character string:
+ */
+static const char *sha2_hex_digits = "0123456789abcdef";
+
+
+/*** SHA-256: *********************************************************/
+void SHA256_Init(SHA256_CTX* context) {
+ if (context == (SHA256_CTX*)0) {
+ return;
+ }
+ MEMCPY_BCOPY(context->state, sha256_initial_hash_value, SHA256_DIGEST_LENGTH);
+ MEMSET_BZERO(context->buffer, SHA256_BLOCK_LENGTH);
+ context->bitcount = 0;
+}
+
+#ifdef SHA2_UNROLL_TRANSFORM
+
+/* Unrolled SHA-256 round macros: */
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+
+#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \
+ REVERSE32(*data++, W256[j]); \
+ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \
+ K256[j] + W256[j]; \
+ (d) += T1; \
+ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
+ j++
+
+
+#else /* BYTE_ORDER == LITTLE_ENDIAN */
+
+#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \
+ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \
+ K256[j] + (W256[j] = *data++); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
+ j++
+
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+
+#define ROUND256(a,b,c,d,e,f,g,h) \
+ s0 = W256[(j+1)&0x0f]; \
+ s0 = sigma0_256(s0); \
+ s1 = W256[(j+14)&0x0f]; \
+ s1 = sigma1_256(s1); \
+ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \
+ (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
+ j++
+
+void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
+ sha2_word32 a, b, c, d, e, f, g, h, s0, s1;
+ sha2_word32 T1, *W256;
+ int j;
+
+ W256 = (sha2_word32*)context->buffer;
+
+ /* Initialize registers with the prev. intermediate value */
+ a = context->state[0];
+ b = context->state[1];
+ c = context->state[2];
+ d = context->state[3];
+ e = context->state[4];
+ f = context->state[5];
+ g = context->state[6];
+ h = context->state[7];
+
+ j = 0;
+ do {
+ /* Rounds 0 to 15 (unrolled): */
+ ROUND256_0_TO_15(a,b,c,d,e,f,g,h);
+ ROUND256_0_TO_15(h,a,b,c,d,e,f,g);
+ ROUND256_0_TO_15(g,h,a,b,c,d,e,f);
+ ROUND256_0_TO_15(f,g,h,a,b,c,d,e);
+ ROUND256_0_TO_15(e,f,g,h,a,b,c,d);
+ ROUND256_0_TO_15(d,e,f,g,h,a,b,c);
+ ROUND256_0_TO_15(c,d,e,f,g,h,a,b);
+ ROUND256_0_TO_15(b,c,d,e,f,g,h,a);
+ } while (j < 16);
+
+ /* Now for the remaining rounds to 64: */
+ do {
+ ROUND256(a,b,c,d,e,f,g,h);
+ ROUND256(h,a,b,c,d,e,f,g);
+ ROUND256(g,h,a,b,c,d,e,f);
+ ROUND256(f,g,h,a,b,c,d,e);
+ ROUND256(e,f,g,h,a,b,c,d);
+ ROUND256(d,e,f,g,h,a,b,c);
+ ROUND256(c,d,e,f,g,h,a,b);
+ ROUND256(b,c,d,e,f,g,h,a);
+ } while (j < 64);
+
+ /* Compute the current intermediate hash value */
+ context->state[0] += a;
+ context->state[1] += b;
+ context->state[2] += c;
+ context->state[3] += d;
+ context->state[4] += e;
+ context->state[5] += f;
+ context->state[6] += g;
+ context->state[7] += h;
+
+ /* Clean up */
+ a = b = c = d = e = f = g = h = T1 = 0;
+}
+
+#else /* SHA2_UNROLL_TRANSFORM */
+
+void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
+ sha2_word32 a, b, c, d, e, f, g, h, s0, s1;
+ sha2_word32 T1, T2, *W256;
+ int j;
+
+ W256 = (sha2_word32*)context->buffer;
+
+ /* Initialize registers with the prev. intermediate value */
+ a = context->state[0];
+ b = context->state[1];
+ c = context->state[2];
+ d = context->state[3];
+ e = context->state[4];
+ f = context->state[5];
+ g = context->state[6];
+ h = context->state[7];
+
+ j = 0;
+ do {
+#if BYTE_ORDER == LITTLE_ENDIAN
+ /* Copy data while converting to host byte order */
+ REVERSE32(*data++,W256[j]);
+ /* Apply the SHA-256 compression function to update a..h */
+ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + W256[j];
+#else /* BYTE_ORDER == LITTLE_ENDIAN */
+ /* Apply the SHA-256 compression function to update a..h with copy */
+ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j] = *data++);
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+ T2 = Sigma0_256(a) + Maj(a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+
+ j++;
+ } while (j < 16);
+
+ do {
+ /* Part of the message block expansion: */
+ s0 = W256[(j+1)&0x0f];
+ s0 = sigma0_256(s0);
+ s1 = W256[(j+14)&0x0f];
+ s1 = sigma1_256(s1);
+
+ /* Apply the SHA-256 compression function to update a..h */
+ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] +
+ (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0);
+ T2 = Sigma0_256(a) + Maj(a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+
+ j++;
+ } while (j < 64);
+
+ /* Compute the current intermediate hash value */
+ context->state[0] += a;
+ context->state[1] += b;
+ context->state[2] += c;
+ context->state[3] += d;
+ context->state[4] += e;
+ context->state[5] += f;
+ context->state[6] += g;
+ context->state[7] += h;
+
+ /* Clean up */
+ a = b = c = d = e = f = g = h = T1 = T2 = 0;
+}
+
+#endif /* SHA2_UNROLL_TRANSFORM */
+
+void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
+ unsigned int freespace, usedspace;
+
+ if (len == 0) {
+ /* Calling with no data is valid - we do nothing */
+ return;
+ }
+
+ /* Sanity check: */
+ assert(context != (SHA256_CTX*)0 && data != (sha2_byte*)0);
+
+ usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH;
+ if (usedspace > 0) {
+ /* Calculate how much free space is available in the buffer */
+ freespace = SHA256_BLOCK_LENGTH - usedspace;
+
+ if (len >= freespace) {
+ /* Fill the buffer completely and process it */
+ MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace);
+ context->bitcount += freespace << 3;
+ len -= freespace;
+ data += freespace;
+ SHA256_Transform(context, (sha2_word32*)context->buffer);
+ } else {
+ /* The buffer is not yet full */
+ MEMCPY_BCOPY(&context->buffer[usedspace], data, len);
+ context->bitcount += len << 3;
+ /* Clean up: */
+ usedspace = freespace = 0;
+ return;
+ }
+ }
+ while (len >= SHA256_BLOCK_LENGTH) {
+ /* Process as many complete blocks as we can */
+ SHA256_Transform(context, (sha2_word32*)data);
+ context->bitcount += SHA256_BLOCK_LENGTH << 3;
+ len -= SHA256_BLOCK_LENGTH;
+ data += SHA256_BLOCK_LENGTH;
+ }
+ if (len > 0) {
+ /* There's left-overs, so save 'em */
+ MEMCPY_BCOPY(context->buffer, data, len);
+ context->bitcount += len << 3;
+ }
+ /* Clean up: */
+ usedspace = freespace = 0;
+}
+
+void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
+ sha2_word32 *d = (sha2_word32*)digest;
+ unsigned int usedspace;
+
+ /* Sanity check: */
+ assert(context != (SHA256_CTX*)0);
+
+ /* If no digest buffer is passed, we don't bother doing this: */
+ if (digest != (sha2_byte*)0) {
+ usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH;
+#if BYTE_ORDER == LITTLE_ENDIAN
+ /* Convert FROM host byte order */
+ REVERSE64(context->bitcount,context->bitcount);
+#endif
+ if (usedspace > 0) {
+ /* Begin padding with a 1 bit: */
+ context->buffer[usedspace++] = 0x80;
+
+ if (usedspace <= SHA256_SHORT_BLOCK_LENGTH) {
+ /* Set-up for the last transform: */
+ MEMSET_BZERO(&context->buffer[usedspace], SHA256_SHORT_BLOCK_LENGTH - usedspace);
+ } else {
+ if (usedspace < SHA256_BLOCK_LENGTH) {
+ MEMSET_BZERO(&context->buffer[usedspace], SHA256_BLOCK_LENGTH - usedspace);
+ }
+ /* Do second-to-last transform: */
+ SHA256_Transform(context, (sha2_word32*)context->buffer);
+
+ /* And set-up for the last transform: */
+ MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH);
+ }
+ } else {
+ /* Set-up for the last transform: */
+ MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH);
+
+ /* Begin padding with a 1 bit: */
+ *context->buffer = 0x80;
+ }
+ /* Set the bit count: */
+ *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
+
+ /* Final transform: */
+ SHA256_Transform(context, (sha2_word32*)context->buffer);
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+ {
+ /* Convert TO host byte order */
+ int j;
+ for (j = 0; j < 8; j++) {
+ REVERSE32(context->state[j],context->state[j]);
+ *d++ = context->state[j];
+ }
+ }
+#else
+ MEMCPY_BCOPY(d, context->state, SHA256_DIGEST_LENGTH);
+#endif
+ }
+
+ /* Clean up state data: */
+ MEMSET_BZERO(context, sizeof(context));
+ usedspace = 0;
+}
+
+char *SHA256_End(SHA256_CTX* context, char buffer[]) {
+ sha2_byte digest[SHA256_DIGEST_LENGTH], *d = digest;
+ int i;
+
+ /* Sanity check: */
+ assert(context != (SHA256_CTX*)0);
+
+ if (buffer != (char*)0) {
+ SHA256_Final(digest, context);
+
+ for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
+ *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
+ *buffer++ = sha2_hex_digits[*d & 0x0f];
+ d++;
+ }
+ *buffer = (char)0;
+ } else {
+ MEMSET_BZERO(context, sizeof(context));
+ }
+ MEMSET_BZERO(digest, SHA256_DIGEST_LENGTH);
+ return buffer;
+}
+
+char* SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) {
+ SHA256_CTX context;
+
+ SHA256_Init(&context);
+ SHA256_Update(&context, data, len);
+ return SHA256_End(&context, digest);
+}
+
+
+/*** SHA-512: *********************************************************/
+void SHA512_Init(SHA512_CTX* context) {
+ if (context == (SHA512_CTX*)0) {
+ return;
+ }
+ MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH);
+ MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH);
+ context->bitcount[0] = context->bitcount[1] = 0;
+}
+
+#ifdef SHA2_UNROLL_TRANSFORM
+
+/* Unrolled SHA-512 round macros: */
+#if BYTE_ORDER == LITTLE_ENDIAN
+
+#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \
+ REVERSE64(*data++, W512[j]); \
+ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \
+ K512[j] + W512[j]; \
+ (d) += T1, \
+ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)), \
+ j++
+
+
+#else /* BYTE_ORDER == LITTLE_ENDIAN */
+
+#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \
+ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \
+ K512[j] + (W512[j] = *data++); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
+ j++
+
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+
+#define ROUND512(a,b,c,d,e,f,g,h) \
+ s0 = W512[(j+1)&0x0f]; \
+ s0 = sigma0_512(s0); \
+ s1 = W512[(j+14)&0x0f]; \
+ s1 = sigma1_512(s1); \
+ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \
+ (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
+ j++
+
+void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
+ sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
+ sha2_word64 T1, *W512 = (sha2_word64*)context->buffer;
+ int j;
+
+ /* Initialize registers with the prev. intermediate value */
+ a = context->state[0];
+ b = context->state[1];
+ c = context->state[2];
+ d = context->state[3];
+ e = context->state[4];
+ f = context->state[5];
+ g = context->state[6];
+ h = context->state[7];
+
+ j = 0;
+ do {
+ ROUND512_0_TO_15(a,b,c,d,e,f,g,h);
+ ROUND512_0_TO_15(h,a,b,c,d,e,f,g);
+ ROUND512_0_TO_15(g,h,a,b,c,d,e,f);
+ ROUND512_0_TO_15(f,g,h,a,b,c,d,e);
+ ROUND512_0_TO_15(e,f,g,h,a,b,c,d);
+ ROUND512_0_TO_15(d,e,f,g,h,a,b,c);
+ ROUND512_0_TO_15(c,d,e,f,g,h,a,b);
+ ROUND512_0_TO_15(b,c,d,e,f,g,h,a);
+ } while (j < 16);
+
+ /* Now for the remaining rounds up to 79: */
+ do {
+ ROUND512(a,b,c,d,e,f,g,h);
+ ROUND512(h,a,b,c,d,e,f,g);
+ ROUND512(g,h,a,b,c,d,e,f);
+ ROUND512(f,g,h,a,b,c,d,e);
+ ROUND512(e,f,g,h,a,b,c,d);
+ ROUND512(d,e,f,g,h,a,b,c);
+ ROUND512(c,d,e,f,g,h,a,b);
+ ROUND512(b,c,d,e,f,g,h,a);
+ } while (j < 80);
+
+ /* Compute the current intermediate hash value */
+ context->state[0] += a;
+ context->state[1] += b;
+ context->state[2] += c;
+ context->state[3] += d;
+ context->state[4] += e;
+ context->state[5] += f;
+ context->state[6] += g;
+ context->state[7] += h;
+
+ /* Clean up */
+ a = b = c = d = e = f = g = h = T1 = 0;
+}
+
+#else /* SHA2_UNROLL_TRANSFORM */
+
+void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
+ sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
+ sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer;
+ int j;
+
+ /* Initialize registers with the prev. intermediate value */
+ a = context->state[0];
+ b = context->state[1];
+ c = context->state[2];
+ d = context->state[3];
+ e = context->state[4];
+ f = context->state[5];
+ g = context->state[6];
+ h = context->state[7];
+
+ j = 0;
+ do {
+#if BYTE_ORDER == LITTLE_ENDIAN
+ /* Convert TO host byte order */
+ REVERSE64(*data++, W512[j]);
+ /* Apply the SHA-512 compression function to update a..h */
+ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + W512[j];
+#else /* BYTE_ORDER == LITTLE_ENDIAN */
+ /* Apply the SHA-512 compression function to update a..h with copy */
+ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++);
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+ T2 = Sigma0_512(a) + Maj(a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+
+ j++;
+ } while (j < 16);
+
+ do {
+ /* Part of the message block expansion: */
+ s0 = W512[(j+1)&0x0f];
+ s0 = sigma0_512(s0);
+ s1 = W512[(j+14)&0x0f];
+ s1 = sigma1_512(s1);
+
+ /* Apply the SHA-512 compression function to update a..h */
+ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] +
+ (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0);
+ T2 = Sigma0_512(a) + Maj(a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+
+ j++;
+ } while (j < 80);
+
+ /* Compute the current intermediate hash value */
+ context->state[0] += a;
+ context->state[1] += b;
+ context->state[2] += c;
+ context->state[3] += d;
+ context->state[4] += e;
+ context->state[5] += f;
+ context->state[6] += g;
+ context->state[7] += h;
+
+ /* Clean up */
+ a = b = c = d = e = f = g = h = T1 = T2 = 0;
+}
+
+#endif /* SHA2_UNROLL_TRANSFORM */
+
+void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
+ unsigned int freespace, usedspace;
+
+ if (len == 0) {
+ /* Calling with no data is valid - we do nothing */
+ return;
+ }
+
+ /* Sanity check: */
+ assert(context != (SHA512_CTX*)0 && data != (sha2_byte*)0);
+
+ usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH;
+ if (usedspace > 0) {
+ /* Calculate how much free space is available in the buffer */
+ freespace = SHA512_BLOCK_LENGTH - usedspace;
+
+ if (len >= freespace) {
+ /* Fill the buffer completely and process it */
+ MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace);
+ ADDINC128(context->bitcount, freespace << 3);
+ len -= freespace;
+ data += freespace;
+ SHA512_Transform(context, (sha2_word64*)context->buffer);
+ } else {
+ /* The buffer is not yet full */
+ MEMCPY_BCOPY(&context->buffer[usedspace], data, len);
+ ADDINC128(context->bitcount, len << 3);
+ /* Clean up: */
+ usedspace = freespace = 0;
+ return;
+ }
+ }
+ while (len >= SHA512_BLOCK_LENGTH) {
+ /* Process as many complete blocks as we can */
+ SHA512_Transform(context, (sha2_word64*)data);
+ ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3);
+ len -= SHA512_BLOCK_LENGTH;
+ data += SHA512_BLOCK_LENGTH;
+ }
+ if (len > 0) {
+ /* There's left-overs, so save 'em */
+ MEMCPY_BCOPY(context->buffer, data, len);
+ ADDINC128(context->bitcount, len << 3);
+ }
+ /* Clean up: */
+ usedspace = freespace = 0;
+}
+
+void SHA512_Last(SHA512_CTX* context) {
+ unsigned int usedspace;
+
+ usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH;
+#if BYTE_ORDER == LITTLE_ENDIAN
+ /* Convert FROM host byte order */
+ REVERSE64(context->bitcount[0],context->bitcount[0]);
+ REVERSE64(context->bitcount[1],context->bitcount[1]);
+#endif
+ if (usedspace > 0) {
+ /* Begin padding with a 1 bit: */
+ context->buffer[usedspace++] = 0x80;
+
+ if (usedspace <= SHA512_SHORT_BLOCK_LENGTH) {
+ /* Set-up for the last transform: */
+ MEMSET_BZERO(&context->buffer[usedspace], SHA512_SHORT_BLOCK_LENGTH - usedspace);
+ } else {
+ if (usedspace < SHA512_BLOCK_LENGTH) {
+ MEMSET_BZERO(&context->buffer[usedspace], SHA512_BLOCK_LENGTH - usedspace);
+ }
+ /* Do second-to-last transform: */
+ SHA512_Transform(context, (sha2_word64*)context->buffer);
+
+ /* And set-up for the last transform: */
+ MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH - 2);
+ }
+ } else {
+ /* Prepare for final transform: */
+ MEMSET_BZERO(context->buffer, SHA512_SHORT_BLOCK_LENGTH);
+
+ /* Begin padding with a 1 bit: */
+ *context->buffer = 0x80;
+ }
+ /* Store the length of input data (in bits): */
+ *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1];
+ *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0];
+
+ /* Final transform: */
+ SHA512_Transform(context, (sha2_word64*)context->buffer);
+}
+
+void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
+ sha2_word64 *d = (sha2_word64*)digest;
+
+ /* Sanity check: */
+ assert(context != (SHA512_CTX*)0);
+
+ /* If no digest buffer is passed, we don't bother doing this: */
+ if (digest != (sha2_byte*)0) {
+ SHA512_Last(context);
+
+ /* Save the hash data for output: */
+#if BYTE_ORDER == LITTLE_ENDIAN
+ {
+ /* Convert TO host byte order */
+ int j;
+ for (j = 0; j < 8; j++) {
+ REVERSE64(context->state[j],context->state[j]);
+ *d++ = context->state[j];
+ }
+ }
+#else
+ MEMCPY_BCOPY(d, context->state, SHA512_DIGEST_LENGTH);
+#endif
+ }
+
+ /* Zero out state data */
+ MEMSET_BZERO(context, sizeof(context));
+}
+
+char *SHA512_End(SHA512_CTX* context, char buffer[]) {
+ sha2_byte digest[SHA512_DIGEST_LENGTH], *d = digest;
+ int i;
+
+ /* Sanity check: */
+ assert(context != (SHA512_CTX*)0);
+
+ if (buffer != (char*)0) {
+ SHA512_Final(digest, context);
+
+ for (i = 0; i < SHA512_DIGEST_LENGTH; i++) {
+ *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
+ *buffer++ = sha2_hex_digits[*d & 0x0f];
+ d++;
+ }
+ *buffer = (char)0;
+ } else {
+ MEMSET_BZERO(context, sizeof(context));
+ }
+ MEMSET_BZERO(digest, SHA512_DIGEST_LENGTH);
+ return buffer;
+}
+
+char* SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) {
+ SHA512_CTX context;
+
+ SHA512_Init(&context);
+ SHA512_Update(&context, data, len);
+ return SHA512_End(&context, digest);
+}
+
+
+/*** SHA-384: *********************************************************/
+void SHA384_Init(SHA384_CTX* context) {
+ if (context == (SHA384_CTX*)0) {
+ return;
+ }
+ MEMCPY_BCOPY(context->state, sha384_initial_hash_value, SHA512_DIGEST_LENGTH);
+ MEMSET_BZERO(context->buffer, SHA384_BLOCK_LENGTH);
+ context->bitcount[0] = context->bitcount[1] = 0;
+}
+
+void SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) {
+ SHA512_Update((SHA512_CTX*)context, data, len);
+}
+
+void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
+ sha2_word64 *d = (sha2_word64*)digest;
+
+ /* Sanity check: */
+ assert(context != (SHA384_CTX*)0);
+
+ /* If no digest buffer is passed, we don't bother doing this: */
+ if (digest != (sha2_byte*)0) {
+ SHA512_Last((SHA512_CTX*)context);
+
+ /* Save the hash data for output: */
+#if BYTE_ORDER == LITTLE_ENDIAN
+ {
+ /* Convert TO host byte order */
+ int j;
+ for (j = 0; j < 6; j++) {
+ REVERSE64(context->state[j],context->state[j]);
+ *d++ = context->state[j];
+ }
+ }
+#else
+ MEMCPY_BCOPY(d, context->state, SHA384_DIGEST_LENGTH);
+#endif
+ }
+
+ /* Zero out state data */
+ MEMSET_BZERO(context, sizeof(context));
+}
+
+char *SHA384_End(SHA384_CTX* context, char buffer[]) {
+ sha2_byte digest[SHA384_DIGEST_LENGTH], *d = digest;
+ int i;
+
+ /* Sanity check: */
+ assert(context != (SHA384_CTX*)0);
+
+ if (buffer != (char*)0) {
+ SHA384_Final(digest, context);
+
+ for (i = 0; i < SHA384_DIGEST_LENGTH; i++) {
+ *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
+ *buffer++ = sha2_hex_digits[*d & 0x0f];
+ d++;
+ }
+ *buffer = (char)0;
+ } else {
+ MEMSET_BZERO(context, sizeof(context));
+ }
+ MEMSET_BZERO(digest, SHA384_DIGEST_LENGTH);
+ return buffer;
+}
+
+char* SHA384_Data(const sha2_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) {
+ SHA384_CTX context;
+
+ SHA384_Init(&context);
+ SHA384_Update(&context, data, len);
+ return SHA384_End(&context, digest);
+}
diff --git a/source/security_algorithms/sha/sha2.h b/source/security_algorithms/sha/sha2.h
new file mode 100644
index 0000000..d7f6110
--- /dev/null
+++ b/source/security_algorithms/sha/sha2.h
@@ -0,0 +1,197 @@
+/*
+ * FILE: sha2.h
+ * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/
+ *
+ * Copyright (c) 2000-2001, Aaron D. Gifford
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $
+ */
+
+#ifndef __SHA2_H__
+#define __SHA2_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * Import u_intXX_t size_t type definitions from system headers. You
+ * may need to change this, or define these things yourself in this
+ * file.
+ */
+#include <sys/types.h>
+
+#ifdef SHA2_USE_INTTYPES_H
+
+#include <inttypes.h>
+
+#endif /* SHA2_USE_INTTYPES_H */
+
+
+/*** SHA-256/384/512 Various Length Definitions ***********************/
+#define SHA256_BLOCK_LENGTH 64
+#define SHA256_DIGEST_LENGTH 32
+#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
+#define SHA384_BLOCK_LENGTH 128
+#define SHA384_DIGEST_LENGTH 48
+#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
+#define SHA512_BLOCK_LENGTH 128
+#define SHA512_DIGEST_LENGTH 64
+#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
+
+
+/*** SHA-256/384/512 Context Structures *******************************/
+/* NOTE: If your architecture does not define either u_intXX_t types or
+ * uintXX_t (from inttypes.h), you may need to define things by hand
+ * for your system:
+ */
+typedef unsigned char u_int8_t; /* 1-byte (8-bits) */
+typedef unsigned int u_int32_t; /* 4-bytes (32-bits) */
+#ifndef LINUX_64
+typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */
+#endif
+
+/*
+ * Most BSD systems already define u_intXX_t types, as does Linux.
+ * Some systems, however, like Compaq's Tru64 Unix instead can use
+ * uintXX_t types defined by very recent ANSI C standards and included
+ * in the file:
+ *
+ * #include <inttypes.h>
+ *
+ * If you choose to use <inttypes.h> then please define:
+ *
+ * #define SHA2_USE_INTTYPES_H
+ *
+ * Or on the command line during compile:
+ *
+ * cc -DSHA2_USE_INTTYPES_H ...
+ */
+#ifdef SHA2_USE_INTTYPES_H
+
+typedef struct _SHA256_CTX {
+ uint32_t state[8];
+ uint64_t bitcount;
+ uint8_t buffer[SHA256_BLOCK_LENGTH];
+} SHA256_CTX;
+typedef struct _SHA512_CTX {
+ uint64_t state[8];
+ uint64_t bitcount[2];
+ uint8_t buffer[SHA512_BLOCK_LENGTH];
+} SHA512_CTX;
+
+#else /* SHA2_USE_INTTYPES_H */
+
+typedef struct _SHA256_CTX {
+ u_int32_t state[8];
+ u_int64_t bitcount;
+ u_int8_t buffer[SHA256_BLOCK_LENGTH];
+} SHA256_CTX;
+typedef struct _SHA512_CTX {
+ u_int64_t state[8];
+ u_int64_t bitcount[2];
+ u_int8_t buffer[SHA512_BLOCK_LENGTH];
+} SHA512_CTX;
+
+#endif /* SHA2_USE_INTTYPES_H */
+
+typedef SHA512_CTX SHA384_CTX;
+
+
+/*** SHA-256/384/512 Function Prototypes ******************************/
+#ifndef NOPROTO
+#ifdef SHA2_USE_INTTYPES_H
+
+void SHA256_Init(SHA256_CTX *);
+void SHA256_Update(SHA256_CTX*, const uint8_t*, size_t);
+void SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
+char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
+char* SHA256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
+
+void SHA384_Init(SHA384_CTX*);
+void SHA384_Update(SHA384_CTX*, const uint8_t*, size_t);
+void SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
+char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
+char* SHA384_Data(const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
+
+void SHA512_Init(SHA512_CTX*);
+void SHA512_Update(SHA512_CTX*, const uint8_t*, size_t);
+void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
+char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
+char* SHA512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
+
+#else /* SHA2_USE_INTTYPES_H */
+
+void SHA256_Init(SHA256_CTX *);
+void SHA256_Update(SHA256_CTX*, const u_int8_t*, size_t);
+void SHA256_Final(u_int8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
+char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
+char* SHA256_Data(const u_int8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
+
+void SHA384_Init(SHA384_CTX*);
+void SHA384_Update(SHA384_CTX*, const u_int8_t*, size_t);
+void SHA384_Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
+char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
+char* SHA384_Data(const u_int8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
+
+void SHA512_Init(SHA512_CTX*);
+void SHA512_Update(SHA512_CTX*, const u_int8_t*, size_t);
+void SHA512_Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
+char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
+char* SHA512_Data(const u_int8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
+
+#endif /* SHA2_USE_INTTYPES_H */
+
+#else /* NOPROTO */
+
+void SHA256_Init();
+void SHA256_Update();
+void SHA256_Final();
+char* SHA256_End();
+char* SHA256_Data();
+
+void SHA384_Init();
+void SHA384_Update();
+void SHA384_Final();
+char* SHA384_End();
+char* SHA384_Data();
+
+void SHA512_Init();
+void SHA512_Update();
+void SHA512_Final();
+char* SHA512_End();
+char* SHA512_Data();
+
+#endif /* NOPROTO */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __SHA2_H__ */
diff --git a/source/utilities/BulkHandler.cpp b/source/utilities/BulkHandler.cpp
new file mode 100644
index 0000000..9dc9169
--- /dev/null
+++ b/source/utilities/BulkHandler.cpp
@@ -0,0 +1,286 @@
+/******************************************************************************
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+******************************************************************************/
+
+#include "BulkHandler.h"
+#include "LCDriverMethods.h"
+#include "Buffers.h"
+#include "LcmInterface.h"
+#include "Logger.h"
+#include "Error.h"
+#include "lcdriver_error_codes.h"
+#include <string>
+#include <cstdio>
+using namespace std;
+
+/// <summary>
+/// BulkHandler constructor
+/// </summary>
+BulkHandler::BulkHandler(CLCDriverMethods *methods, Buffers *buffers, LcmInterface *lcmInterface, Logger *logger):
+ m_Methods(methods),
+ m_ReceiveQueue(32),
+ m_pBuffers(buffers),
+ m_pLcmInterface(lcmInterface),
+ m_pLogger(logger),
+ m_State(BULK_INACTIVE),
+ m_pFileWriteThread(0),
+ m_pBulkVector(0)
+{
+}
+
+/// <summary>
+/// BulkHandler destructor
+/// </summary>
+BulkHandler::~BulkHandler()
+{
+ TL_BulkVectorList_t *bulkVector = 0;
+
+ while (true) {
+ RemoveResult result = m_ReceiveQueue.RemoveHead(reinterpret_cast<void **>(&bulkVector), 0);
+
+ if (REMOVE_TIMEOUT == result) {
+ break;
+ } else if (REMOVE_CANCEL == result) {
+ continue;
+ }
+
+ m_pLcmInterface->BulkDestroyVector(bulkVector, true);
+#ifdef _BULKDEBUG
+ m_pLogger->log("BULK: Vector destroyed BulkVector = 0x%x", m_pBulkVector);
+#endif
+ }
+}
+
+int BulkHandler::Send(const string &sourceFile)
+{
+ if (BULK_INACTIVE != m_State) {
+ return BULK_ALREADY_IN_PROGRESS;
+ }
+
+ m_sFilePath = sourceFile;
+ m_State = BULK_TX;
+ return 0;
+}
+
+int BulkHandler::Receive(const string &destinationFile)
+{
+ if (BULK_INACTIVE != m_State) {
+ return BULK_ALREADY_IN_PROGRESS;
+ }
+
+ m_sFilePath = destinationFile;
+
+ // truncate the file for receiving
+ FILE *file = fopen(m_sFilePath.c_str(), "wb");
+
+ if (!file) {
+ return FILE_OPENING_ERROR;
+ }
+
+ fclose(file);
+
+ m_State = BULK_RX;
+
+ // start bulk file write thread
+ m_pFileWriteThread = new CThreadWrapper(FileWriteThreadFunction, this);
+ m_pFileWriteThread->ResumeThread();
+
+ return 0;
+}
+
+void BulkHandler::Finish()
+{
+ if (BULK_RX == m_State) {
+ m_State = BULK_INACTIVE;
+ m_ReceiveQueue.SignalEvent();
+ m_pFileWriteThread->WaitToDie(INFINITE);
+ } else {
+ m_State = BULK_INACTIVE;
+ }
+}
+
+void BulkHandler::HandleCommandRequest(uint16 session, uint32 chunkSize, uint64 offset, uint32 length, bool acknowledge)
+{
+ switch (SELECT_COMMAND(m_State, acknowledge)) {
+ case BULK_WRITE_REQUEST:
+ HandleWriteRequest(session, chunkSize, offset, length);
+ break;
+ case BULK_READ_REQUEST:
+ HandleReadRequest(session, chunkSize, offset, length);
+ break;
+ case BULK_RX_SESSION_END:
+ HandleRxSessionEnd(session, chunkSize, offset, length);
+ break;
+ case BULK_TX_SESSION_END:
+ HandleTxSessionEnd(session, chunkSize, offset, length);
+ break;
+ default:
+ break;
+ }
+}
+
+void BulkHandler::HandleWriteRequest(uint16 session, uint32 chunkSize, uint64 offset, uint32 length)
+{
+ int ReturnValue = E_SUCCESS;
+
+ uint32 VectorID = m_pLcmInterface->BulkOpenSession(session, BULK_RECEIVE, length);
+ VERIFY(BULK_ERROR != VectorID, BULK_VECTOR_ID_ERROR);
+#ifdef _BULKDEBUG
+ m_pLogger->log("BULK: Session opened with VectorID = %u", VectorID);
+#endif
+ m_pBulkVector = m_pLcmInterface->BulkCreateVector(VectorID, length, chunkSize, NULL);
+ VERIFY_SUCCESS(m_pLcmInterface->BulkStartSession(m_pBulkVector, offset));
+#ifdef _BULKDEBUG
+ m_pLogger->log("BULK: Session %u started with BulkVector = 0x%x", session, m_pBulkVector);
+#endif
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ m_Methods->SignalError(ReturnValue);
+ }
+}
+
+void BulkHandler::HandleReadRequest(uint16 session, uint32 chunkSize, uint64 offset, uint32 length)
+{
+ int ReturnValue = E_SUCCESS;
+
+ uint32 VectorID = m_pLcmInterface->BulkOpenSession(session, BULK_SEND, length);
+ VERIFY(BULK_ERROR != VectorID, BULK_VECTOR_ID_ERROR);
+#ifdef _BULKDEBUG
+ m_pLogger->log("BULK: Session opened with VectorID = %u", VectorID);
+#endif
+ m_pBulkVector = m_pLcmInterface->BulkCreateVector(VectorID, length, chunkSize, NULL);
+
+ VERIFY_SUCCESS(m_pBuffers->AllocateBulkVector(m_pBulkVector, chunkSize, offset, length));
+ VERIFY_SUCCESS(m_pLcmInterface->BulkStartSession(m_pBulkVector, offset));
+#ifdef _BULKDEBUG
+ m_pLogger->log("BULK: Session %u started with BulkVector = 0x%x", session, m_pBulkVector);
+#endif
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ m_Methods->SignalError(ReturnValue);
+ }
+}
+
+void BulkHandler::HandleRxSessionEnd(uint16 session, uint32 chunkSize, uint64 offset, uint32 length)
+{
+ int ReturnValue = E_SUCCESS;
+
+ m_ReceiveQueue.AddTail(m_pBulkVector);
+
+ VERIFY_SUCCESS(m_pLcmInterface->BulkCloseSession(m_pBulkVector));
+#ifdef _BULKDEBUG
+ m_pLogger->log("BULK: Session closed Session = %u", session);
+#endif
+
+ m_Methods->UpdateBulkProgress();
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ m_Methods->SignalError(ReturnValue);
+ }
+}
+
+void BulkHandler::HandleTxSessionEnd(uint16 session, uint32 chunkSize, uint64 offset, uint32 length)
+{
+ int ReturnValue = E_SUCCESS;
+
+ m_pBuffers->ReleaseBulkVector(m_pBulkVector);
+
+ VERIFY_SUCCESS(m_pLcmInterface->BulkDestroyVector(m_pBulkVector, false));
+#ifdef _BULKDEBUG
+ m_pLogger->log("BULK: Vector destroyed BulkVector = 0x%x", m_pBulkVector);
+#endif
+
+ m_Methods->UpdateBulkProgress();
+
+ErrorExit:
+
+ if (E_SUCCESS != ReturnValue) {
+ m_Methods->SignalError(ReturnValue);
+ }
+}
+
+void BulkHandler::FlushReceiveQueue()
+{
+#ifdef _BULKDEBUG
+ m_pLogger->log("BULK: Flush receive queue");
+#endif
+ TL_BulkVectorList_t *bulkVector = 0;
+
+ while (true) {
+ RemoveResult result = m_ReceiveQueue.RemoveHead(reinterpret_cast<void **>(&bulkVector), 0);
+
+ if (REMOVE_TIMEOUT == result) {
+ break;
+ } else if (REMOVE_CANCEL == result) {
+ continue;
+ }
+
+ WriteBulkVector(bulkVector);
+
+ m_pLcmInterface->BulkDestroyVector(bulkVector, true);
+#ifdef _BULKDEBUG
+ m_pLogger->log("BULK: Vector destroyed BulkVector = 0x%x", bulkVector);
+#endif
+ }
+}
+
+void BulkHandler::WriteBulkVector(TL_BulkVectorList_t *bulkVector)
+{
+ FILE *file = fopen(m_sFilePath.c_str(), "ab");
+
+ if (file) {
+ for (size_t i = 0; i != bulkVector->Buffers; ++i) {
+ uint32 currentChunkSize = bulkVector->ChunkSize;
+
+ if (i + 1 == bulkVector->Buffers) { //lastchunk
+ currentChunkSize = bulkVector->Length - (i * bulkVector->ChunkSize);
+ }
+
+ fwrite(bulkVector->Entries[i].Payload_p, currentChunkSize, 1, file);
+ }
+
+ fclose(file);
+#ifdef _BULKDEBUG
+ m_pLogger->log("BULK: Vector written BulkVector = 0x%x", m_pBulkVector);
+#endif
+ }
+}
+
+#ifdef _WIN32
+unsigned int WINAPI BulkHandler::FileWriteThreadFunction(void *arg)
+#else
+void *BulkHandler::FileWriteThreadFunction(void *arg)
+#endif
+{
+ BulkHandler *pThis = static_cast<BulkHandler *>(arg);
+
+ TL_BulkVectorList_t *bulkVector = 0;
+
+ while (true) {
+ RemoveResult result = pThis->m_ReceiveQueue.RemoveHead(reinterpret_cast<void **>(&bulkVector), INFINITE);
+
+ if (REMOVE_SUCCESS == result) {
+ pThis->WriteBulkVector(bulkVector);
+
+ pThis->m_pLcmInterface->BulkDestroyVector(bulkVector, true);
+#ifdef _BULKDEBUG
+ pThis->m_pLogger->log("BULK: Vector destroyed BulkVector = 0x%x", bulkVector);
+#endif
+ } else {
+ break;
+ }
+ }
+
+ pThis->FlushReceiveQueue();
+
+ return 0;
+}
diff --git a/source/utilities/BulkHandler.h b/source/utilities/BulkHandler.h
new file mode 100644
index 0000000..71147ab
--- /dev/null
+++ b/source/utilities/BulkHandler.h
@@ -0,0 +1,81 @@
+/******************************************************************************
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+******************************************************************************/
+
+#ifndef _BULK_HANDLER_H_
+#define _BULK_HANDLER_H_
+
+#ifdef _WIN32
+#include "WinApiWrappers.h"
+#else
+#include "LinuxApiWrappers.h"
+#endif
+#include "Buffers.h"
+#include "LcmInterface.h"
+#include "Logger.h"
+#include <string>
+
+class CLCDriverMethods;
+
+/// <summary>
+/// Bulk handler state.
+/// </summary>
+enum BulkState {
+ BULK_INACTIVE,
+ BULK_RX,
+ BULK_TX
+};
+
+#define SESSION_END_MASK (1 << 4)
+#define SELECT_COMMAND(state, acknowledge) (state | (((uint32)acknowledge) << 4))
+
+enum BulkCommand {
+ BULK_WRITE_REQUEST = BULK_RX,
+ BULK_READ_REQUEST = BULK_TX,
+ BULK_RX_SESSION_END = BULK_WRITE_REQUEST | SESSION_END_MASK,
+ BULK_TX_SESSION_END = BULK_READ_REQUEST | SESSION_END_MASK
+};
+
+/// <summary>
+/// Bulk Buffer class used to manipulate
+/// the bulk buffers linear list filled
+/// with bulk chunks data
+/// </summary>
+class BulkHandler
+{
+public:
+ BulkHandler(CLCDriverMethods *methods, Buffers *buffers, LcmInterface *lcmInterface, Logger *logger);
+ ~BulkHandler();
+
+ int Receive(const std::string &sourceFile);
+ int Send(const std::string &destinationFile);
+ void Finish();
+ void HandleCommandRequest(uint16 session, uint32 chunkSize, uint64 offset, uint32 length, bool acknowledge);
+private:
+ CLCDriverMethods *m_Methods;
+ Buffers *m_pBuffers;
+ LcmInterface *m_pLcmInterface;
+ Logger *m_pLogger;
+ BulkState m_State;
+ TL_BulkVectorList_t *m_pBulkVector;
+ std::string m_sFilePath;
+ CSemaphoreQueue m_ReceiveQueue;
+ CThreadWrapper *m_pFileWriteThread;
+private:
+ void HandleReadRequest(uint16 session, uint32 chunkSize, uint64 offset, uint32 length);
+ void HandleWriteRequest(uint16 session, uint32 chunkSize, uint64 offset, uint32 length);
+ void HandleRxSessionEnd(uint16 session, uint32 chunkSize, uint64 offset, uint32 length);
+ void HandleTxSessionEnd(uint16 session, uint32 chunkSize, uint64 offset, uint32 length);
+#ifdef _WIN32
+ static unsigned int WINAPI FileWriteThreadFunction(void *arg);
+#else
+ static void *FileWriteThreadFunction(void *arg);
+#endif
+ void FlushReceiveQueue();
+ void WriteBulkVector(TL_BulkVectorList_t *bulkVector);
+};
+
+#endif
diff --git a/source/utilities/CaptiveThreadObject.cpp b/source/utilities/CaptiveThreadObject.cpp
new file mode 100644
index 0000000..e9eb472
--- /dev/null
+++ b/source/utilities/CaptiveThreadObject.cpp
@@ -0,0 +1,51 @@
+/*******************************************************************************
+*
+* File name: CaptiveThreadObject.cpp
+* Language: Visual C++
+* Description: Captive Thread Object class definitions
+*
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*******************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// File CaptiveThreadObject.cpp
+
+#include "CaptiveThreadObject.h"
+
+CCaptiveThreadObject::CCaptiveThreadObject()
+ : IsDying(0),
+#pragma warning(disable: 4355) // 'this' used before initialized but ok as thread starts in inactive state
+ Thread(ThreadEntry, this)
+{
+}
+#pragma warning(default: 4355)
+
+CCaptiveThreadObject::~CCaptiveThreadObject()
+{
+}
+
+void CCaptiveThreadObject::EndCaptiveThread()
+{
+ IsDying++;
+ SignalDeath();
+ Thread.WaitToDie();
+}
+
+
+// ThreadEntry - Entry point, executed by captive thread
+#ifdef _WIN32
+unsigned int WINAPI CCaptiveThreadObject::ThreadEntry(void *arg)
+#else
+void *CCaptiveThreadObject::ThreadEntry(void *arg)
+#endif
+{
+ CCaptiveThreadObject *pThis = static_cast<CCaptiveThreadObject *>(arg);
+ pThis->InitializeCaptiveThreadObject();
+ pThis->MainExecutionLoop();
+ return 0;
+}
+// End of file CaptiveThreadObject.cpp
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/utilities/CaptiveThreadObject.h b/source/utilities/CaptiveThreadObject.h
new file mode 100644
index 0000000..12b7b32
--- /dev/null
+++ b/source/utilities/CaptiveThreadObject.h
@@ -0,0 +1,57 @@
+/*******************************************************************************
+*
+* File name: CaptiveThreadObject.h
+* Language: Visual C++
+* Description: Captive Thread Object class declarations
+*
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*******************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// File CaptiveThreadObject.h
+
+#ifndef __CAPTIVE_THREAD_OBJECT_H__
+#define __CAPTIVE_THREAD_OBJECT_H__
+
+#pragma once
+
+#if defined(WIN32)
+#include <windows.h>
+#include "WinApiWrappers.h"
+#elif defined(__linux__)
+#include "LinuxApiWrappers.h"
+#else
+#error "Unknown target"
+#endif
+
+// CCaptiveThreadObject owns the captive thread
+class CCaptiveThreadObject
+{
+public:
+ CCaptiveThreadObject();
+ virtual ~CCaptiveThreadObject();
+ void EndCaptiveThread();
+ int ThreadIsDying() {
+ return IsDying;
+ }
+protected:
+ virtual void InitializeCaptiveThreadObject() = 0;
+ virtual void MainExecutionLoop() = 0;
+
+ virtual void SignalDeath() = 0;
+#ifdef _WIN32
+ static unsigned int WINAPI ThreadEntry(void *arg);
+#else
+ static void *ThreadEntry(void *arg);
+#endif
+ int IsDying;
+ CThreadWrapper Thread;
+};
+
+#endif
+
+// End of file CaptiveThreadObject.h
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/utilities/Error.h b/source/utilities/Error.h
new file mode 100755
index 0000000..0693287
--- /dev/null
+++ b/source/utilities/Error.h
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _ERROR_H_
+#define _ERROR_H_
+
+#define VERIFY(Condition, ErrorCode)\
+ do\
+ {\
+ if(!(Condition))\
+ {\
+ ReturnValue = (ErrorCode);\
+ goto ErrorExit;\
+ }\
+ } while(0)
+
+#define VERIFY_SUCCESS(ErrorCode)\
+ do\
+ {\
+ ReturnValue = (ErrorCode);\
+ VERIFY(E_SUCCESS == ReturnValue, ReturnValue);\
+ } while (0)
+
+#endif // _ERROR_H_
diff --git a/source/utilities/Event.h b/source/utilities/Event.h
new file mode 100644
index 0000000..36d8f3a
--- /dev/null
+++ b/source/utilities/Event.h
@@ -0,0 +1,27 @@
+/******************************************************************************
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+******************************************************************************/
+
+#ifndef _EVENT_H_
+#define _EVENT_H_
+
+enum {
+ EVENT_GR_RECEIVED = 0x00000001,
+ EVENT_CMD_RECEIVED = 0x00000002,
+ EVENT_SPEEDFLASH = 0x00000004,
+ EVENT_ERROR = 0x00000008
+};
+
+struct Event {
+ Event(uint32 ev, uint32 err, uint8 gr = 0, uint8 cmd = 0):
+ event(ev), error(err), group(gr), command(cmd) {}
+ uint32 event;
+ uint32 error;
+ uint8 group;
+ uint8 command;
+};
+
+#endif // _EVENT_H_
diff --git a/source/utilities/LockLessQueue.h b/source/utilities/LockLessQueue.h
new file mode 100644
index 0000000..6f54bda
--- /dev/null
+++ b/source/utilities/LockLessQueue.h
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _LOCKLESSQUEUE_H_
+#define _LOCKLESSQUEUE_H_
+
+/// <summary>
+/// Class for store received data in Z-protocol in a lockless queue.
+/// </summary>
+class LockLessQueue
+{
+ unsigned char *m_puchQueue;
+ unsigned int m_uiHead;
+ unsigned int m_uiTail;
+ unsigned int m_uiSize;
+ unsigned int m_uiMask;
+
+public:
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="uiSize">Size of buffer = 2^uiSize.</param>
+ LockLessQueue(unsigned int uiSize): m_uiHead(0), m_uiTail(0) {
+ m_uiSize = 1 << uiSize;
+ m_uiMask = m_uiSize - 1;
+ m_puchQueue = new unsigned char[m_uiSize];
+ }
+
+ /// <summary>
+ /// Constructor. Default buffer size to 2^20.
+ /// </summary>
+ LockLessQueue(): m_uiHead(0), m_uiTail(0) {
+ m_uiSize = 1 << 20;
+ m_uiMask = m_uiSize - 1;
+ m_puchQueue = new unsigned char[m_uiSize];
+ }
+
+ /// <summary>
+ /// Destructor.
+ /// </summary>
+ ~LockLessQueue() {
+ if (m_puchQueue != 0) {
+ delete [] m_puchQueue;
+ }
+ }
+
+ /// <summary>
+ /// Store one byte in buffer queue.
+ /// </summary>
+ /// <param name="uchData">Data to store in buffer.</param>
+ /// <param name="pbFull">Status of buffer, true = full buffer.</param>
+ void Push(unsigned char uchData, bool *pbFull) {
+ unsigned int uiHead = m_uiHead;
+ uiHead = uiHead & m_uiMask; //(Head++) & m_uiMask -> This does the required roll over to zero at the end of the array.
+ uiHead++;
+
+ if (uiHead == m_uiTail) {
+ *pbFull = true;
+ } else {
+ m_puchQueue[uiHead] = uchData;
+ m_uiHead = uiHead;
+ *pbFull = false;
+ }
+ }
+
+
+ /// <summary>
+ /// Take out one byte from buffer queue.
+ /// </summary>
+ /// <param name="pbEmpty">Status of buffer. pbEmpty = true -> buffer is empty.</param>
+ /// <returns> One byte data from buffer queue.</returns>
+ unsigned char Pop(bool *pbEmpty) {
+ unsigned char uchPopData = 0;
+ unsigned int uiTail = m_uiTail;
+
+ if (m_uiHead != uiTail) {
+ uiTail = (uiTail + 1) & m_uiMask; //This does the required roll over to zero at the end of the array.
+ m_uiTail = uiTail;
+ uchPopData = m_puchQueue[uiTail];
+ *pbEmpty = false;
+ } else {
+ *pbEmpty = true;
+ }
+
+ return uchPopData;
+ }
+
+ /// <summary>
+ /// Reset buffer queue.
+ /// </summary>
+ void Clear() {
+ m_uiTail = m_uiHead;
+ }
+};
+
+#endif // _LOCKLESSQUEUE_H_
diff --git a/source/utilities/Logger.cpp b/source/utilities/Logger.cpp
new file mode 100644
index 0000000..d0370d6
--- /dev/null
+++ b/source/utilities/Logger.cpp
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include "Logger.h"
+using namespace std;
+
+#ifdef _WIN32
+#define flockfile _lock_file
+#define funlockfile _unlock_file
+#else
+#include <cstddef>
+#include "OS.h"
+#endif
+
+Logger::Logger(const void *communication): communication_(communication), messageCallback_(0)
+{
+}
+
+void Logger::log(const char *format, ...)
+{
+#ifdef _MESSAGES
+
+ if (0 != messageCallback_) {
+ CLockCS lock(criticalSection_);
+ va_list args;
+ char message[1024];
+ va_start(args, format);
+ vsprintf_s(message, format, args);
+ va_end(args);
+ messageCallback_(communication_, strlen(message), message);
+ }
+
+#endif
+}
diff --git a/source/utilities/Logger.h b/source/utilities/Logger.h
new file mode 100644
index 0000000..2388bb4
--- /dev/null
+++ b/source/utilities/Logger.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#ifndef _LOGGER_H_
+#define _LOGGER_H_
+
+#include "t_basicdefinitions.h"
+#ifdef _WIN32
+#include "WinApiWrappers.h"
+#else
+#include "LinuxApiWrappers.h"
+#endif
+
+typedef void (*MessageCallback_t)(const void *Communication_p, uint32 MessageLength, const char *MessageText);
+
+class Logger
+{
+public:
+ Logger(const void *communication);
+
+ void log(const char *format, ...);
+ void setMessageCallback(MessageCallback_t messageCallback) {
+ messageCallback_ = messageCallback;
+ }
+private:
+ CCriticalSectionObject criticalSection_;
+ const void *communication_;
+ MessageCallback_t messageCallback_;
+};
+
+#endif // _LOGGER_H_ \ No newline at end of file
diff --git a/source/utilities/MemMappedFile.cpp b/source/utilities/MemMappedFile.cpp
new file mode 100644
index 0000000..287c5b9
--- /dev/null
+++ b/source/utilities/MemMappedFile.cpp
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+
+#include "lcdriver_error_codes.h"
+#include "MemMappedFile.h"
+#if defined(_WIN32)
+#include <windows.h>
+#elif defined(__linux__)
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <string.h>
+using namespace std;
+#else
+#error "Unknown target"
+#endif
+
+MemMappedFile::MemMappedFile(uint32 alignmentLength):
+ size_(0),
+ isMapped_(false),
+ mappedData_(0),
+ error_(0),
+ alignmentLength_(alignmentLength),
+#ifdef _WIN32
+ handle_(INVALID_HANDLE_VALUE),
+ memmap_(INVALID_HANDLE_VALUE)
+#else
+ descriptor_(-1)
+#endif
+{
+}
+
+MemMappedFile::~MemMappedFile()
+{
+#ifdef _WIN32
+
+ if (0 != mappedData_) {
+ UnmapViewOfFile(mappedData_);
+ }
+
+ if (INVALID_HANDLE_VALUE != memmap_) {
+ CloseHandle(memmap_);
+ }
+
+ if (INVALID_HANDLE_VALUE != handle_) {
+ CloseHandle(handle_);
+ }
+
+#else
+
+ if (0 != mappedData_) {
+ munmap(mappedData_, size_);
+ }
+
+ if (-1 != descriptor_) {
+ close(descriptor_);
+ }
+
+#endif
+}
+
+int MemMappedFile::LoadFileData(const char *path)
+{
+ path_ = path;
+#ifdef _WIN32
+ handle_ = CreateFile(path_.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+
+ if (INVALID_HANDLE_VALUE == handle_) {
+ return FILE_OPENING_ERROR;
+ }
+
+ size_ = ::GetFileSize(handle_, NULL);
+
+ if (0 == size_) {
+ return 0;
+ }
+
+ memmap_ = CreateFileMapping(handle_, NULL, PAGE_READONLY, 0, 0, NULL);
+
+ if (INVALID_HANDLE_VALUE == memmap_) {
+ return FILE_CREATE_MAPPING_ERROR;
+ }
+
+ mappedData_ = static_cast<uint8 *>(MapViewOfFile(memmap_, FILE_MAP_READ, 0, 0, 0));
+
+ if (0 != mappedData_) {
+ isMapped_ = true;
+ volatile char tmp;
+
+ for (uint64 i = 0; i < size_; i += 4096) {
+ tmp = mappedData_[i];
+ }
+ } else {
+ isMapped_ = false;
+ CloseHandle(memmap_);
+ memmap_ = INVALID_HANDLE_VALUE;
+ }
+
+#else
+ descriptor_ = open(path_.c_str(), O_RDONLY);
+
+ if (-1 == descriptor_) {
+ return FILE_OPENING_ERROR;
+ }
+
+ struct stat fileStat;
+
+ if (0 != fstat(descriptor_, &fileStat)) {
+ return FILE_FAILED_TO_GET_SIZE;
+ }
+
+ size_ = fileStat.st_size;
+
+ mappedData_ = static_cast<uint8 *>(mmap(0, size_, PROT_READ, MAP_PRIVATE | MAP_POPULATE, descriptor_, 0));
+
+ if (MAP_FAILED != mappedData_) {
+ isMapped_ = true;
+ } else {
+ isMapped_ = false;
+ }
+
+#endif
+ return 0;
+}
+
+uint8 *MemMappedFile::AllocateFileData(uint64 offset, uint64 size)
+{
+ if (size_ < offset + size) {
+ error_ = FILE_READ_INVALID_OFFSET;
+ return 0;
+ }
+
+ uint32 alignedSize = (static_cast<uint32>(size) + (alignmentLength_ - 1)) & (~(alignmentLength_ - 1));
+
+ if (isMapped_) {
+ if (size_ < offset + alignedSize) {
+ uint8 *data = new uint8[alignedSize];
+ memcpy(data, mappedData_ + offset, static_cast<size_t>(size));
+ return data;
+ } else {
+ return mappedData_ + offset;
+ }
+ } else {
+ // file is not memory mapped fall back to plain read
+ uint32 readSize = static_cast<uint32>(size);
+ uint8 *data = new uint8[alignedSize];
+#ifdef _WIN32
+ LARGE_INTEGER liOffset;
+ liOffset.QuadPart = offset;
+
+ if (!SetFilePointerEx(handle_, liOffset, NULL, FILE_BEGIN)) {
+ delete[] data;
+ error_ = FILE_READ_INVALID_OFFSET;
+ return 0;
+ }
+
+ uint32 bytesRead;
+
+ if (ReadFile(handle_, data, readSize, (LPDWORD)&bytesRead, NULL) && bytesRead == size) {
+ return data;
+ } else {
+ delete[] data;
+ error_ = FILE_READ_ERROR;
+ return 0;
+ }
+
+#else
+
+ if (-1 == lseek64(descriptor_, offset, SEEK_SET)) {
+ delete[] data;
+ error_ = FILE_READ_INVALID_OFFSET;
+ return 0;
+ }
+
+ if (readSize == (uint32)read(descriptor_, data, readSize)) {
+ return data;
+ } else {
+ delete[] data;
+ error_ = FILE_READ_ERROR;
+ return 0;
+ }
+
+#endif
+ }
+}
+
+void MemMappedFile::ReleaseFileData(uint8 *data, uint64 offset, uint64 size)
+{
+ uint32 alignedSize = (static_cast<uint32>(size) + (alignmentLength_ - 1)) & (~(alignmentLength_ - 1));
+ if (!isMapped_ || size_ < offset + alignedSize) {
+ delete[] data;
+ }
+}
+
+uint64 MemMappedFile::GetFileSize()
+{
+ return size_;
+}
+
+int MemMappedFile::GetError()
+{
+ return error_;
+}
diff --git a/source/utilities/MemMappedFile.h b/source/utilities/MemMappedFile.h
new file mode 100644
index 0000000..8cc63f5
--- /dev/null
+++ b/source/utilities/MemMappedFile.h
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _MEMMAPPEDFILE_H_
+#define _MEMMAPPEDFILE_H_
+
+#include "t_basicdefinitions.h"
+#include <string>
+
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
+class MemMappedFile
+{
+public:
+ MemMappedFile(uint32 alignmentLength = 512);
+ ~MemMappedFile();
+
+ uint8 *AllocateFileData(uint64 offset, uint64 size);
+ void ReleaseFileData(uint8 *data, uint64 offset, uint64 size);
+ uint64 GetFileSize();
+ int LoadFileData(const char *path);
+ int GetError();
+private:
+ std::string path_;
+ uint64 size_;
+ bool isMapped_;
+ uint32 alignmentLength_;
+ uint8 *mappedData_;
+ int error_;
+#ifdef _WIN32
+ HANDLE handle_;
+ HANDLE memmap_;
+#else
+ int descriptor_;
+#endif
+};
+
+#endif // _MEMMAPPEDFILE_H_
diff --git a/source/utilities/ObjectList.h b/source/utilities/ObjectList.h
new file mode 100644
index 0000000..6151104
--- /dev/null
+++ b/source/utilities/ObjectList.h
@@ -0,0 +1,286 @@
+/*******************************************************************************
+*
+* File name: ObjectList.h
+* Language: Visual C++
+* Description: Template class for manage list of object
+*
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*******************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// File ObjectList.h
+
+#ifndef __OBJECT_LIST_H__
+#define __OBJECT_LIST_H__
+
+#pragma once
+#if defined(_WIN32)
+#include "WinApiWrappers.h"
+#elif defined(__linux__)
+#include "LinuxApiWrappers.h"
+#include <stdio.h>
+#include <stdlib.h>
+#else
+#error "Unknown target"
+#endif
+
+#define ID_STRING_LEN 25
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Template class CObjectList
+
+template < class TemplateClass > class CObjectList
+{
+public:
+ CObjectList();
+ virtual ~CObjectList();
+
+ int Add(TemplateClass *pObject, const char *szObjectId, int nSubPart = -1);
+ TemplateClass *Find(const char *szObjectId, int nSubPart = -1);
+ int Release(TemplateClass *pObject);
+ int GetNumberOfInstances(TemplateClass *pObject);
+
+protected:
+ struct TObjectList {
+ TemplateClass *pObject;
+ char szObjectId[ 25 + 1 ];
+ int nSubPart;
+ int nCounter;
+ TObjectList *pNextObject;
+ } *m_pObjectList;
+ CCriticalSectionObject m_CriticalSectionObject;
+};
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// CObjectList()
+// Constructor
+//
+template < class TemplateClass >
+CObjectList< TemplateClass >::CObjectList()
+{
+ m_pObjectList = NULL;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// ~CObjectList()
+// Destructor
+//
+template < class TemplateClass >
+CObjectList< TemplateClass >::~CObjectList()
+{
+ CLockCS Lock(m_CriticalSectionObject);
+ TObjectList *pCurrentObject;
+
+ // Delete all object that is left.
+ while (m_pObjectList != NULL) {
+ pCurrentObject = m_pObjectList;
+ m_pObjectList = pCurrentObject->pNextObject;
+ free(pCurrentObject);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Add()
+// FUNCTION
+// Add() -- Add object ID to the object list
+//
+// INPUT
+// szId - ID of the object
+// pObject - Object to be assigned to the ID
+//
+// RESULT
+// 0: Success
+// 1: ID string is to long
+// -1: Unable to expand the list.
+// -2: SubParts doesn't match each other.
+//
+// NOTES
+// If no record with the same ID string exist, a new record will be added and the object pointer will be set.
+// If a record with the same ID string already exists in the array, the instance counter will be incremented.
+//
+
+template < class TemplateClass >
+int CObjectList< TemplateClass >::Add(TemplateClass *pObject, const char *szObjectId, int nSubPart)
+{
+ CLockCS Lock(m_CriticalSectionObject);
+ TObjectList *pCurrentObject;
+
+ if (m_pObjectList == NULL) {
+ m_pObjectList = (TObjectList *)malloc(sizeof(TObjectList));
+
+ if (m_pObjectList == NULL) {
+ return -1;
+ }
+
+ m_pObjectList->pObject = pObject;
+ strcpy_s(m_pObjectList->szObjectId, szObjectId);
+ m_pObjectList->nSubPart = nSubPart;
+ m_pObjectList->nCounter = 1;
+ m_pObjectList->pNextObject = NULL;
+ } else { // Is the object allready created ?
+ pCurrentObject = m_pObjectList;
+
+ while (((strcmp(pCurrentObject->szObjectId, szObjectId) != 0) || (pCurrentObject->nSubPart != nSubPart)) && (pCurrentObject->pNextObject != NULL)) {
+ pCurrentObject = pCurrentObject->pNextObject;
+ }
+
+ if ((_stricmp(pCurrentObject->szObjectId, szObjectId) == 0) && (pCurrentObject->nSubPart = nSubPart)) {
+ pCurrentObject->nCounter++; // Found the object!
+ } else {
+ // Add a new object to the end of the list.
+ pCurrentObject->pNextObject = (TObjectList *)malloc(sizeof(TObjectList));
+
+ if (pCurrentObject->pNextObject == NULL) {
+ return -1;
+ }
+
+ pCurrentObject->pNextObject->pObject = pObject;
+ strcpy_s(pCurrentObject->pNextObject->szObjectId, szObjectId);
+ pCurrentObject->pNextObject->nSubPart = nSubPart;
+ pCurrentObject->pNextObject->nCounter = 1;
+ pCurrentObject->pNextObject->pNextObject = NULL;
+ }
+ }
+
+ return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Release()
+// FUNCTION
+// Release() -- Release reference to object from the object list
+//
+// INPUT
+// pObject - Object to release
+//
+// RESULT
+// The number of instances left for this object.
+// If negative the object doesn't exist in the list.
+//
+// NOTES
+// The instance counter for the entry is decremented.
+// If the instance counter reaches 0, the entry will be deleted from the list.
+//
+
+template < class TemplateClass >
+int CObjectList< TemplateClass >::Release(TemplateClass *pObject)
+{
+ CLockCS Lock(m_CriticalSectionObject);
+ TObjectList *pCurrentObject, *pLastObject;
+
+ // Find the right object to delete.
+ if (m_pObjectList != NULL) {
+ pCurrentObject = m_pObjectList;
+ pLastObject = NULL;
+
+ while ((pCurrentObject->pObject != pObject) && (pCurrentObject->pNextObject != NULL)) {
+ pLastObject = pCurrentObject;
+ pCurrentObject = pCurrentObject->pNextObject;
+ }
+
+ if (pCurrentObject->pObject == pObject) {
+ if (pCurrentObject->nCounter > 1) {
+ pCurrentObject->nCounter--;
+ return pCurrentObject->nCounter;
+ } else {
+ // Remove the current record in the global object table.
+ if (pLastObject == NULL) {
+ m_pObjectList = pCurrentObject->pNextObject;
+ } else {
+ pLastObject->pNextObject = pCurrentObject->pNextObject;
+ }
+
+ free(pCurrentObject);
+ return 0;
+ }
+ } else {
+ return -1;
+ }
+ } else {
+ return -1;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Find()
+// FUNCTION
+// Find() -- Search for an object ID in the object list
+//
+// INPUT
+// szObjectId - ID of object
+//
+// RESULT
+// The object pointer to the object assigned to the ID or
+// NULL if the ID was not found
+//
+
+template < class TemplateClass >
+TemplateClass *CObjectList< TemplateClass >::Find(const char *szObjectId, int nSubPart)
+{
+ CLockCS Lock(m_CriticalSectionObject);
+ TObjectList *pCurrentObject;
+
+ // Find the right object
+ if (m_pObjectList != NULL) {
+ pCurrentObject = m_pObjectList;
+
+ while (((strcmp(pCurrentObject->szObjectId, szObjectId) != 0) || (pCurrentObject->nSubPart != nSubPart)) && (pCurrentObject->pNextObject != NULL)) {
+ pCurrentObject = pCurrentObject->pNextObject;
+ }
+
+ if ((_stricmp(pCurrentObject->szObjectId, szObjectId) == 0) && (pCurrentObject->nSubPart = nSubPart)) {
+ return pCurrentObject->pObject;
+ } else {
+ return NULL;
+ }
+ } else {
+ return NULL;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// GetNumberOfInstances()
+// FUNCTION
+// GetNumberOfInstances() -- Search for an object ID in the object list
+//
+// INPUT
+// szObjectId - ID of object
+//
+// RESULT
+// The number of instances of the object assigned to the ID.
+// 0 if the ID was not found.
+//
+
+template < class TemplateClass >
+int CObjectList< TemplateClass >::GetNumberOfInstances(TemplateClass *pObject)
+{
+ CLockCS Lock(m_CriticalSectionObject);
+ TObjectList *pCurrentObject;
+
+ // Find the right object
+ if (m_pObjectList != NULL) {
+ pCurrentObject = m_pObjectList;
+
+ while ((pCurrentObject->pObject != pObject) && (pCurrentObject->pNextObject != NULL)) {
+ pCurrentObject = pCurrentObject->pNextObject;
+ }
+
+ if (pCurrentObject->pObject == pObject) {
+ return pCurrentObject->nCounter;
+ } else {
+ return 0;
+ }
+ } else {
+ return 0;
+ }
+}
+
+#endif
+
+// End of file ObjectList.h
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/utilities/Serialization.cpp b/source/utilities/Serialization.cpp
new file mode 100644
index 0000000..b4daa21
--- /dev/null
+++ b/source/utilities/Serialization.cpp
@@ -0,0 +1,325 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+/*
+ * @addtogroup ldr_utilities
+ * @{
+ * @addtogroup serialization
+ * @{
+ */
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <cstdlib>
+#include <cstring>
+#include "Serialization.h"
+#include "LCDriverMethods.h"
+#include "command_ids.h"
+
+ListDevice_t Devices[MAX_NO_OF_DEVICES];
+uint32 DevicesNumber = 0;
+
+Serialization::Serialization(): logger_(0)
+{
+}
+
+Serialization::~Serialization()
+{
+}
+
+/*******************************************************************************
+ * Definition of external functions
+ ******************************************************************************/
+
+void Serialization::get_block(const void **data_pp, void *target_p, uint32 length)
+{
+ memcpy(target_p, *data_pp, length);
+ *(const uint8 **)data_pp += length;
+#ifdef _SERIALIZATIONDEBUG
+ PrintF("Serialization\tget_block\tLength=%i", (void *)length);
+#endif
+}
+
+SupportedCommand_t *Serialization::get_supportedcommands(const void **data_pp, uint32 CommandsCount)
+{
+ SupportedCommand_t *SupportedCommands = new SupportedCommand_t[CommandsCount];
+
+ for (uint32 i = 0; i < CommandsCount; i++) {
+ SupportedCommands[i].Group = get_uint32_le(data_pp);
+ SupportedCommands[i].Command = get_uint32_le(data_pp);
+ SupportedCommands[i].Permitted = get_uint32_le(data_pp);
+ }
+
+ return SupportedCommands;
+}
+
+ListDevice_t *Serialization::get_devices(const void **data_pp, uint32 DevicesCount)
+{
+ size_t size = 0;
+ const char *str;
+
+ DevicesNumber = DevicesCount;
+
+ for (uint32 i = 0; i < DevicesCount; i++) {
+ str = skip_str(data_pp);
+ size = get_uint32_le((const void **)&str);
+ memset(Devices[i].Path_p, 0, 256);
+ memcpy(Devices[i].Path_p, str, size);
+ Devices[i].Path_p[size] = '\0';
+
+ str = skip_str(data_pp);
+ size = get_uint32_le((const void **)&str);
+ memset(Devices[i].Type_p, 0, 256);
+ memcpy(Devices[i].Type_p, str, size);
+ Devices[i].Type_p[size] = '\0';
+
+ Devices[i].BlockSize = get_uint64_le(data_pp);
+ Devices[i].Start = get_uint64_le(data_pp);
+ Devices[i].Length = get_uint64_le(data_pp);
+ }
+
+ return Devices;
+}
+
+DirEntry_t *Serialization::get_direntries(const void **data_pp, uint32 DirectoriesCount)
+{
+ DirEntry_t *Direntries = new DirEntry_t[DirectoriesCount];
+ size_t size = 0;
+ const char *str;
+
+ for (uint32 i = 0; i < DirectoriesCount; i++) {
+ str = skip_str(data_pp);
+ size = get_uint32_le((const void **)&str);
+ Direntries[i].Name_p = new char[size + 1];
+ memcpy(Direntries[i].Name_p, str, size);
+ Direntries[i].Name_p[size] = '\0';
+
+ Direntries[i].Size = get_uint64_le(data_pp);
+ Direntries[i].Mode = get_uint32_le(data_pp);
+ Direntries[i].Time = get_uint32_le(data_pp);
+ }
+
+ return Direntries;
+}
+
+uint8 Serialization::get_uint8(const void **data_pp)
+{
+ const uint8 *d = *(const uint8 **)data_pp;
+ *(const uint8 **)data_pp += sizeof(uint8);
+#ifdef _SERIALIZATIONDEBUG
+ unsigned char v = d[0];
+ PrintF("Serialization\tget_uint8\tReturned val=0x%x", (void *)v);
+#endif
+ return d[0];
+}
+uint16 Serialization::get_uint16_le(const void **data_pp)
+{
+ const uint8 *d = *(const uint8 **)data_pp;
+ *(const uint8 **)data_pp += sizeof(uint16);
+#ifdef _SERIALIZATIONDEBUG
+ unsigned short v = (d[1] << 8) | d[0];
+ PrintF("Serialization\tget_uint16_le\tReturned val=0x%x", (void *)v);
+#endif
+ return (d[1] << 8) | d[0];
+}
+uint16 Serialization::get_uint16_be(const void **data_pp)
+{
+ const uint8 *d = *(const uint8 **)data_pp;
+ *(const uint8 **)data_pp += sizeof(uint16);
+#ifdef _SERIALIZATIONDEBUG
+ unsigned short v = (d[0] << 8) | d[1];
+ PrintF("Serialization\tget_uint16_be\tReturned val=0x%x", (void *)v);
+#endif
+ return (d[0] << 8) | d[1];
+}
+uint32 Serialization::get_uint32_le(const void **data_pp)
+{
+ const uint8 *d = *(const uint8 **) data_pp;
+ *(const uint8 **)data_pp += sizeof(uint32);
+#ifdef _SERIALIZATIONDEBUG
+ unsigned int v = ((d[3] << 8 | d[2]) << 8 | d[1]) << 8 | d[0];
+ PrintF("Serialization\tget_uint32_le\tReturned val=0x%x", (void *)v);
+#endif
+ return ((d[3] << 8 | d[2]) << 8 | d[1]) << 8 | d[0];
+}
+
+uint64 Serialization::get_uint64_le(const void **data_pp)
+{
+ const uint8 *d = *(const uint8 **) data_pp;
+ *(const uint8 **)data_pp += sizeof(uint64);
+#ifdef _SERIALIZATIONDEBUG
+ uint64 v = (((((((uint64)d[7] << 8 | d[6]) << 8 | d[5]) << 8 | d[4]) << 8 | d[3]) << 8 | d[2]) << 8 | d[1]) << 8 | d[0];
+ PrintF("Serialization\tget_uint64_le\tReturned val=0x%x", (void *)v);
+#endif
+ 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 Serialization::get_uint32_be(const void **data_pp)
+{
+ const uint8 *d = *(const uint8 **) data_pp;
+ *(const uint8 **)data_pp += sizeof(uint32);
+#ifdef _SERIALIZATIONDEBUG
+ unsigned int v = ((d[0] << 8 | d[1]) << 8 | d[2]) << 8 | d[3];
+ PrintF("Serialization\tget_uint32_be\tReturned val=0x%x", (void *)v);
+#endif
+ return ((d[0] << 8 | d[1]) << 8 | d[2]) << 8 | d[3];
+}
+
+void Serialization::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;
+ }
+
+#ifdef _SERIALIZATIONDEBUG
+ PrintF("Serialization\tput_block\tLength=%i", (void *)length);
+#endif
+}
+
+void Serialization::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 Serialization::put_uint8(void **data_pp, uint8 v)
+{
+ **(uint8 **) data_pp = v;
+ *(uint8 **) data_pp += sizeof(uint8);
+#ifdef _SERIALIZATIONDEBUG
+ PrintF("Serialization\tput_uint8\tInput val=0x%x", (void *)v);
+#endif
+}
+
+void Serialization::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);
+#ifdef _SERIALIZATIONDEBUG
+ PrintF("Serialization\tput_uint16_le\tInput val=0x%x", (void *)v);
+#endif
+}
+
+void Serialization::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);
+#ifdef _SERIALIZATIONDEBUG
+ PrintF("Serialization\tput_uint16_be\tInput val=0x%x", (void *)v);
+#endif
+}
+
+void Serialization::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);
+#ifdef _SERIALIZATIONDEBUG
+ PrintF("Serialization\tput_uint32_le\tInput val=0x%x", (void *)v);
+#endif
+}
+
+void Serialization::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);
+#ifdef _SERIALIZATIONDEBUG
+ PrintF("Serialization\tput_uint32_be\tInput val=0x%x", (void *)v);
+#endif
+}
+
+void Serialization::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);
+#ifdef _SERIALIZATIONDEBUG
+ PrintF("Serialization\tput_uint64_le\tInput val=0x%x", (void *)v);
+#endif
+}
+
+void Serialization::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);
+#ifdef _SERIALIZATIONDEBUG
+ PrintF("Serialization\tput_uint64_be\tInput val=0x%x", (void *)v);
+#endif
+}
+
+void Serialization::skip_uint8(const void **data_pp)
+{
+ *(const uint8 **)data_pp += sizeof(uint8);
+}
+
+void Serialization::skip_uint16(const void **data_pp)
+{
+ *(const uint8 **)data_pp += sizeof(uint16);
+}
+
+void Serialization::skip_uint32(const void **data_pp)
+{
+ *(const uint8 **)data_pp += sizeof(uint32);
+}
+
+void Serialization::skip_block(const void **data_pp, uint32 length)
+{
+ *(const uint8 **)data_pp += length;
+}
+
+char *Serialization::skip_str(const void **data_pp)
+{
+ char *Result_p = NULL;
+ uint32 StrLength;
+
+ Result_p = *(char **)data_pp;
+ StrLength = get_uint32_le(data_pp);
+ *(char **)data_pp += StrLength;
+ return Result_p;
+}
+
+void Serialization::PrintF(const char *text, void *pVoid)
+{
+ if (NULL != logger_) {
+ logger_->log(text, pVoid);
+ }
+}
diff --git a/source/utilities/Serialization.h b/source/utilities/Serialization.h
new file mode 100644
index 0000000..7556c1b
--- /dev/null
+++ b/source/utilities/Serialization.h
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (C) ST-Ericsson SA 2011
+ * License terms: 3-clause BSD license
+ ******************************************************************************/
+#ifndef _SERIALIZATION_H_
+#define _SERIALIZATION_H_
+
+#include "t_basicdefinitions.h"
+#include "command_ids.h"
+#ifdef _WIN32
+#include "WinApiWrappers.h"
+#else
+#include "LinuxApiWrappers.h"
+#endif
+#include "Logger.h"
+#include "LCDriver.h"
+#include "commands_types.h"
+
+const uint32 MAX_NO_OF_DEVICES = 1024;
+
+class Serialization
+{
+public:
+ Serialization(void);
+ ~Serialization(void);
+
+ static void put_block(void **data_pp, const void *source_p, uint32 length);
+ static void put_string(void **data_pp, const void *source_p, uint32 length);
+
+ static uint8 get_uint8(const void **data_pp);
+ static uint16 get_uint16_le(const void **data_pp);
+ static uint16 get_uint16_be(const void **data_pp);
+ static uint32 get_uint32_le(const void **data_pp);
+ static uint32 get_uint32_be(const void **data_pp);
+ static uint64 get_uint64_le(const void **data_pp);
+ static void put_uint8(void **data_pp, uint8 v);
+ static void put_uint16_le(void **data_pp, uint16 v);
+ static void put_uint16_be(void **data_pp, uint16 v);
+ static void put_uint32_le(void **data_pp, uint32 v);
+ static void put_uint32_be(void **data_pp, uint32 v);
+ static void put_uint64_le(void **data_pp, uint64 v);
+ static void put_uint64_be(void **data_pp, uint64 v);
+ static void skip_uint8(const void **data_pp);
+ static void skip_uint16(const void **data_pp);
+ static void skip_uint32(const void **data_pp);
+ static void get_block(const void **data_pp, void *target_p, uint32 length);
+ static void skip_block(const void **data_pp, uint32 length);
+ static char *skip_str(const void **data_pp);
+
+ static SupportedCommand_t *get_supportedcommands(const void **data_pp, uint32 CommandsCount);
+ static ListDevice_t *get_devices(const void **data_pp, uint32 DevicesCount);
+ static DirEntry_t *get_direntries(const void **data_pp, uint32 DirectoriesCount);
+
+public:
+ void SetLogger(Logger *logger) {
+ logger_ = logger;
+ }
+private:
+ Logger *logger_;
+ void PrintF(const char *text, void *pVoid);
+};
+
+#endif // _SERIALIZATION_H_
diff --git a/win_binaries/LCDriver_CNH1606432.dll b/win_binaries/LCDriver_CNH1606432.dll
new file mode 100755
index 0000000..826f5f5
--- /dev/null
+++ b/win_binaries/LCDriver_CNH1606432.dll
Binary files differ
diff --git a/win_binaries/LCM.dll b/win_binaries/LCM.dll
new file mode 100755
index 0000000..8bc08ce
--- /dev/null
+++ b/win_binaries/LCM.dll
Binary files differ