From f2be658909048b1050bf66c14324cccce852a931 Mon Sep 17 00:00:00 2001 From: xmarvla Date: Mon, 26 Dec 2011 11:39:55 +0100 Subject: Flash tool cli cannot work with network path Resolve problems in error handling for process file command when path to non-existing file is given as input paramter to LCDriver. Fix AStyle code formatting. ST-Ericsson ID: 402761 ST-Ericsson FOSS-OUT ID: NA Change-Id: Ia6539a7ebab97a078bc0d105b23b6a0545762194 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/43810 Reviewed-by: QABUILD Tested-by: Aleksandar GASOSKI Reviewed-by: Vlatko PISTOLOV Tested-by: Vlatko PISTOLOV --- lcmodule/source/LCM.rc | 6 +- lcmodule/source/LCM.vcproj | 2 +- .../source/a2_speedflash.c | 3 + .../source/bulk_protocol.c | 8 +- .../source/r15_transport_layer.c | 2 + .../include/t_r15_network_layer.h | 2 +- .../source/a2_network.c | 5 ++ .../source/protrom_network.c | 1 + .../source/r15_network_layer.c | 85 ++++++++++++---------- .../config/commands.xml | 2 +- .../source/lcm_version.c | 2 +- .../source/measurement_tool.c | 9 +++ source/LCDriver.cpp | 1 - source/LCDriver.rc | 6 +- source/LCDriverEntry.cpp | 3 + source/LCDriverMethods.cpp | 26 +++++-- source/LCDriverMethods.h | 2 +- source/LCM/Hash.cpp | 42 ++++++----- source/LCM/include/t_r15_network_layer.h | 2 +- source/LcdVersion.cpp | 2 +- source/LcmInterface.h | 4 +- source/api_wrappers/linux/CThreadWrapper.cpp | 2 +- source/api_wrappers/linux/CThreadWrapper.h | 4 +- source/api_wrappers/linux/OS.h | 2 + source/api_wrappers/windows/WinApiWrappers.h | 3 + source/config/commands.xml | 2 +- source/security_algorithms/sha/sha2.cpp | 22 +++--- source/utilities/BulkHandler.cpp | 6 +- 28 files changed, 159 insertions(+), 97 deletions(-) diff --git a/lcmodule/source/LCM.rc b/lcmodule/source/LCM.rc index 9cbe9af..862bc80 100644 --- a/lcmodule/source/LCM.rc +++ b/lcmodule/source/LCM.rc @@ -69,15 +69,15 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "Comments", "Build date: 2011-12-09" + VALUE "Comments", "Build date: 2011-12-26" VALUE "CompanyName", "STEricsson AB" VALUE "FileDescription", "LCM Dynamic Link Library" VALUE "FileVersion", "1, 0, 0, 1" VALUE "InternalName", "Loader Communication Module" VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2011" - VALUE "PrivateBuild", "Change-Id: If0926da184dfefefcaad0d4e97080de283b7aabd" + VALUE "PrivateBuild", "Change-Id: Ia6539a7ebab97a078bc0d105b23b6a0545762194" VALUE "ProductName", "CXA1104507 Loader Communication Module" - VALUE "ProductVersion", "PX3" + VALUE "ProductVersion", "PX4" END END BLOCK "VarFileInfo" diff --git a/lcmodule/source/LCM.vcproj b/lcmodule/source/LCM.vcproj index 67fb14a..7283845 100644 --- a/lcmodule/source/LCM.vcproj +++ b/lcmodule/source/LCM.vcproj @@ -46,7 +46,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""$(ProjectDir)autogen";"$(ProjectDir)cnh1606344_ldr_communication_module\config";"$(ProjectDir)legacy_compatibility";"$(ProjectDir)cnh1606344_ldr_communication_module\include";"$(ProjectDir)cnh1605721_ldr_security_algorithms\include";"$(ProjectDir)cnh1605720_ldr_time_utilities\include";"$(ProjectDir)cnh1605551_ldr_utilities\include";"$(ProjectDir)cnh1605205_ldr_network_layer\include";"$(ProjectDir)cnh1605204_ldr_transport_layer\include";"$(ProjectDir)cnh1605203_ldr_communication_buffer\include";"$(ProjectDir)cnh1605551_ldr_utilities\critical_section"" - PreprocessorDefinitions="WIN32;_DEBUG;LCM_EXPORTS;PRINT_A_" + PreprocessorDefinitions="WIN32;_DEBUG;ENABLE_DEBUG;LCM_EXPORTS;PRINT_A_" RuntimeLibrary="1" UsePrecompiledHeader="0" PrecompiledHeaderThrough="" diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_speedflash.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_speedflash.c index aea0149..4cd38d3 100644 --- a/lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_speedflash.c +++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/a2_speedflash.c @@ -95,9 +95,11 @@ ErrorCode_e A2_Speedflash_Poll(Communication_t *Communication_p) A2_SPEEDFLASH_REQ_SIZE, A2_Speedflash_ReadCallback, Communication_p->CommunicationDevice_p); #endif break; + case A2_SPEEDFLASH_WAIT_READ_REQ: /* nothing to do */ break; + case A2_SPEEDFLASH_WRITE_BLOCK: if (NULL != A2_SPEEDFLASH(Communication_p)->Outbound_p) { @@ -110,6 +112,7 @@ ErrorCode_e A2_Speedflash_Poll(Communication_t *Communication_p) } break; + case A2_SPEEDFLASH_WAIT_WRITE_BLOCK: /* nothing to do */ break; diff --git a/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c b/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c index 42d3cae..b04d715 100644 --- a/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c +++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c @@ -512,6 +512,7 @@ ErrorCode_e R15_Bulk_Process(Communication_t *Communication_p, PacketMeta_t *Pac break; #ifndef CFG_ENABLE_LOADER_TYPE + case CMD_BULK_WRITE: if (NULL != R15_TRANSPORT(Communication_p)->BulkCommandCallback_p) { @@ -523,6 +524,7 @@ ErrorCode_e R15_Bulk_Process(Communication_t *Communication_p, PacketMeta_t *Pac 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__);) @@ -733,6 +735,7 @@ static ErrorCode_e R15_Bulk_Process_Read(Communication_t *Communication_p, TL_Bu break; #ifndef CFG_ENABLE_LOADER_TYPE + /* coverity[unterminated_case] */ case WAIT_WRITE_REQUEST: BulkVector_p->State = SEND_READ_REQUEST; @@ -961,6 +964,7 @@ ErrorCode_e R15_Bulk_Process_Write(Communication_t *Communication_p, TL_BulkVect break; #ifndef CFG_ENABLE_LOADER_TYPE + case WAIT_TX_DONE: /* Wait for all chunks in the current session to be send before closing @@ -994,6 +998,7 @@ ErrorCode_e R15_Bulk_Process_Write(Communication_t *Communication_p, TL_BulkVect C_(printf("bulk_protocol.c(%d) Write bulk process finished! \n", __LINE__);) break; #ifndef CFG_ENABLE_LOADER_TYPE + case CANCEL_BULK: { uint32 Counter; @@ -1015,6 +1020,7 @@ ErrorCode_e R15_Bulk_Process_Write(Communication_t *Communication_p, TL_BulkVect } break; #endif + default: BulkVector_p->State = BULK_IDLE_STATE; break; @@ -1191,7 +1197,7 @@ static void R15_Bulk_ReadChunkCallBack(Communication_t *Communication_p, const v { TL_BulkVectorList_t *BulkVector_p = R15_TRANSPORT(Communication_p)->BulkHandle.BulkVector_p; - if(NULL == BulkVector_p) { + if (NULL == BulkVector_p) { A_(printf("bulk_protocol.c(%d) Bulk Vector released! \n", __LINE__);) return; } 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 index 925d722..893412f 100644 --- a/lcmodule/source/cnh1605204_ldr_transport_layer/source/r15_transport_layer.c +++ b/lcmodule/source/cnh1605204_ldr_transport_layer/source/r15_transport_layer.c @@ -131,8 +131,10 @@ ErrorCode_e R15_Transport_Poll(Communication_t *Communication_p) 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; } 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 index 7c4f6e1..0bd2944 100644 --- 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 @@ -285,7 +285,7 @@ typedef struct { /** R15 Network context */ typedef struct { - PacketMeta_t *MetaInfoList[COMMAND_BUFFER_COUNT+BULK_BUFFER_COUNT]; + 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 retransmission */ diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/source/a2_network.c b/lcmodule/source/cnh1605205_ldr_network_layer/source/a2_network.c index 417c10b..1aa32a3 100644 --- a/lcmodule/source/cnh1605205_ldr_network_layer/source/a2_network.c +++ b/lcmodule/source/cnh1605205_ldr_network_layer/source/a2_network.c @@ -149,9 +149,11 @@ void A2_Network_ReadCallback(const void *Data_p, const uint32 Length, void *Para 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; @@ -565,9 +567,11 @@ ErrorCode_e A2_Network_TransmiterHandler(Communication_t *Communication_p) } 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; @@ -582,6 +586,7 @@ ErrorCode_e A2_Network_TransmiterHandler(Communication_t *Communication_p) } break; + case A2_SENDING_PAYLOAD: /* nothing to do, wait until sending is finished and state changed when packet ACK is received */ break; diff --git a/lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_network.c b/lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_network.c index 3dc19a4..11410e2 100644 --- a/lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_network.c +++ b/lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_network.c @@ -411,6 +411,7 @@ static ErrorCode_e Protrom_Network_TransmiterHandler(Communication_t *Communicat case PROTROM_SENDING_HEADER: break; + case PROTROM_SEND_PAYLOAD: Out_p->State = PROTROM_SENDING_PAYLOAD; 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 index 7bc4dad..c8347bf 100644 --- a/lcmodule/source/cnh1605205_ldr_network_layer/source/r15_network_layer.c +++ b/lcmodule/source/cnh1605205_ldr_network_layer/source/r15_network_layer.c @@ -226,9 +226,9 @@ ErrorCode_e R15_Network_ReceiverHandler(Communication_t *Communication_p) #ifdef CFG_ENABLE_LOADER_TYPE if (E_SUCCESS != Communication_p->CommunicationDevice_p->Read( - In_p->Target_p + ReqBufferOffset + In_p->RecBackupData, - ReqData - In_p->RecBackupData, R15_Network_ReadCallback, - Communication_p->CommunicationDevice_p)) { + In_p->Target_p + ReqBufferOffset + In_p->RecBackupData, + ReqData - In_p->RecBackupData, R15_Network_ReadCallback, + Communication_p->CommunicationDevice_p)) { /* Read failed! Return to previous state. */ In_p->ReqData = ReqData; In_p->ReqBuffOffset = ReqBufferOffset; @@ -271,8 +271,8 @@ ErrorCode_e R15_Network_ReceiverHandler(Communication_t *Communication_p) #ifdef CFG_ENABLE_LOADER_TYPE if (E_SUCCESS != Communication_p->CommunicationDevice_p->Read( - In_p->Target_p + ReqBufferOffset, ReqData, R15_Network_ReadCallback, - Communication_p->CommunicationDevice_p)) { + In_p->Target_p + ReqBufferOffset, ReqData, R15_Network_ReadCallback, + Communication_p->CommunicationDevice_p)) { /* Read failed! Return to previous state. */ In_p->ReqData = ReqData; In_p->ReqBuffOffset = ReqBufferOffset; @@ -294,15 +294,15 @@ ErrorCode_e R15_Network_ReceiverHandler(Communication_t *Communication_p) #ifdef CFG_ENABLE_LOADER_TYPE if (E_SUCCESS == Communication_p->CommunicationDevice_p->Read(In_p->Target_p, - ALIGNED_HEADER_LENGTH, R15_Network_ReadCallback, - Communication_p->CommunicationDevice_p)) { + ALIGNED_HEADER_LENGTH, R15_Network_ReadCallback, + Communication_p->CommunicationDevice_p)) { In_p->State = RECEIVE_HEADER; } #else (void)Communication_p->CommunicationDevice_p->Read(In_p->Target_p, - ALIGNED_HEADER_LENGTH, R15_Network_ReadCallback, - Communication_p->CommunicationDevice_p); + ALIGNED_HEADER_LENGTH, R15_Network_ReadCallback, + Communication_p->CommunicationDevice_p); In_p->State = RECEIVE_HEADER; #endif } @@ -347,6 +347,7 @@ ErrorCode_e R15_Network_TransmiterHandler(Communication_t *Communication_p) HeaderStartInBuffer_p = Out_p->Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER; #ifdef CFG_ENABLE_LOADER_TYPE + if (Out_p->Packet_p->Header.ExtendedHeaderLength == COMMAND_EXTENDED_HEADER_LENGTH) { ExtHdrLen = ALIGNED_COMMAND_EXTENDED_HEADER_LENGTH; } else { @@ -372,13 +373,14 @@ ErrorCode_e R15_Network_TransmiterHandler(Communication_t *Communication_p) ContinuousBufferLength = ALIGNED_HEADER_LENGTH + ExtHdrLen; Out_p->State = SENDING_HEADER; } + #else ContinuousBufferLength = ALIGNED_HEADER_LENGTH; Out_p->State = SENDING_HEADER; #endif if (E_SUCCESS == Communication_p->CommunicationDevice_p->Write((Out_p->Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER), - ContinuousBufferLength, R15_Network_WriteCallback, Communication_p->CommunicationDevice_p)) { + ContinuousBufferLength, R15_Network_WriteCallback, Communication_p->CommunicationDevice_p)) { C_(printf("r15_network_layer.c (%d) Header Sent to comm device! \n", __LINE__);) } else { Out_p->State = SEND_HEADER; @@ -387,9 +389,11 @@ ErrorCode_e R15_Network_TransmiterHandler(Communication_t *Communication_p) } break; + case SENDING_HEADER: /* nothing to do, wait until sending is finished and state changed by write callback */ break; + case SEND_EX_HEADER: ExHeaderStartInBuffer_p = Out_p->Packet_p->Buffer_p + HEADER_OFFSET_IN_BUFFER + ALIGNED_HEADER_LENGTH; @@ -408,7 +412,7 @@ ErrorCode_e R15_Network_TransmiterHandler(Communication_t *Communication_p) } if (E_SUCCESS == Communication_p->CommunicationDevice_p->Write(ExHeaderStartInBuffer_p, ExtHdrLen, - R15_Network_WriteCallback, Communication_p->CommunicationDevice_p)) { + R15_Network_WriteCallback, Communication_p->CommunicationDevice_p)) { C_(printf("r15_network_layer.c (%d) ExHeader Sent to comm device! \n", __LINE__);) } else { Out_p->State = SEND_EX_HEADER; @@ -417,17 +421,19 @@ ErrorCode_e R15_Network_TransmiterHandler(Communication_t *Communication_p) } break; + case SENDING_EX_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->CommunicationDevice_p)) { + Aligned_Length, + R15_Network_WriteCallback, Communication_p->CommunicationDevice_p)) { RegisterRetransmission = TRUE; C_(printf("r15_network_layer.c (%d) Payload Sent to comm device! \n", __LINE__);) } else { @@ -436,6 +442,7 @@ ErrorCode_e R15_Network_TransmiterHandler(Communication_t *Communication_p) } break; + case SENDING_PAYLOAD: /* nothing to do, wait until sending is finished and state changed by write callback */ break; @@ -485,7 +492,7 @@ ErrorCode_e R15_Network_CancelRetransmission(const Communication_t *const Commun 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] = R15_NETWORK(Communication_p)->RetransmissionList[Index + 1]; } R15_NETWORK(Communication_p)->RetransmissionList[Index] = NULL; @@ -717,15 +724,17 @@ static ErrorCode_e R15_Network_ReceiveHeader(const Communication_t *const Commun } } else { A_( - if(print_header) { - uint32 Counter = 0; - printf("Invalid header! \n"); - for (Counter = 0; Counter < 16; Counter++) { - printf(" %02X", In_p->Scratch[Counter]); - } - printf("\n\n"); + if (print_header) { + uint32 Counter = 0; + printf("Invalid header! \n"); + + for (Counter = 0; Counter < 16; Counter++) { + printf(" %02X", In_p->Scratch[Counter]); } + + printf("\n\n"); + } ) } } @@ -747,12 +756,12 @@ static ErrorCode_e R15_Network_ReceiveExtendedHeader(Communication_t *Communicat R15_DeserializeBulkExtendedHeader(&BulkExtendedHeader, In_p->Target_p); IsValidHeader = R15_IsValidExtendedHeader(In_p->Target_p, - In_p->Header.ExtendedHeaderLength, - In_p->Header.ExtendedHeaderChecksum); + In_p->Header.ExtendedHeaderLength, + In_p->Header.ExtendedHeaderChecksum); if (IsValidHeader) { if (R15Header.Protocol == BULK_PROTOCOL && - (BulkExtendedHeader.TypeFlags & MASK_BULK_COMMAND_SELECT) == CMD_BULK_DATA) { + (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); @@ -793,10 +802,10 @@ static ErrorCode_e R15_Network_ReceiveExtendedHeader(Communication_t *Communicat 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); + 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; @@ -809,10 +818,10 @@ static ErrorCode_e R15_Network_ReceiveExtendedHeader(Communication_t *Communicat uint32 Counter = 0; printf("Invalid exheader! \n"); - for (Counter = 0; Counter < 16; Counter++) { - printf(" %02X", In_p->Target_p[Counter]); - } - printf("\n\n"); + for (Counter = 0; Counter < 16; Counter++) { + printf(" %02X", In_p->Target_p[Counter]); + } + printf("\n\n"); ) RESET_INBOUND(In_p, RECEIVE_HEADER); SYNC_HEADER(In_p, ALIGNED_HEADER_LENGTH, In_p->Scratch); @@ -848,10 +857,10 @@ static ErrorCode_e R15_Network_ReceivePayload(Communication_t *Communication_p) #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); + 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); @@ -896,7 +905,7 @@ static ErrorCode_e R15_Network_RegisterRetransmission(Communication_t *Communica 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[i] = R15_NETWORK(Communication_p)->RetransmissionList[i - 1]; } R15_NETWORK(Communication_p)->RetransmissionList[Index] = R_Ctx_p; @@ -936,7 +945,7 @@ static void R15_Network_RetransmissionCallback(Communication_t *Communication_p, 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] = R15_NETWORK(Communication_p)->RetransmissionList[Index + 1]; } R15_NETWORK(Communication_p)->RetransmissionList[Index] = NULL; diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/config/commands.xml b/lcmodule/source/cnh1606344_ldr_communication_module/config/commands.xml index 4d32f14..52b76e2 100644 --- a/lcmodule/source/cnh1606344_ldr_communication_module/config/commands.xml +++ b/lcmodule/source/cnh1606344_ldr_communication_module/config/commands.xml @@ -389,7 +389,7 @@ - supportedcmdtype="longrunning"> + This command is used by the Loader to deauthenticates the ME from prior authentications to prevent unauthorized access. diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c b/lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c index 8ef2ff3..bd4ebc8 100644 --- a/lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c +++ b/lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c @@ -11,6 +11,6 @@ * brief ASCII string variable holding the LCM version/build time/product number.. */ -char LCM_CurrentVersion[] = "PX2"; +char LCM_CurrentVersion[] = "PX4"; /** @} */ diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/source/measurement_tool.c b/lcmodule/source/cnh1606344_ldr_communication_module/source/measurement_tool.c index 4b42f60..67f730e 100644 --- a/lcmodule/source/cnh1606344_ldr_communication_module/source/measurement_tool.c +++ b/lcmodule/source/cnh1606344_ldr_communication_module/source/measurement_tool.c @@ -382,10 +382,12 @@ ErrorCode_e Do_Measurement_AddMeasurementData(Measurement_t *Measurement_p, uin 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); @@ -395,6 +397,7 @@ ErrorCode_e Do_Measurement_AddMeasurementData(Measurement_t *Measurement_p, uin } break; + case START_FLASH_CHUNK_TIME: ChankDataBlock_p = FindChunkDataBlock(SessionMeasurement_p->ChunkMeasurement_p, ChunkID); @@ -404,6 +407,7 @@ ErrorCode_e Do_Measurement_AddMeasurementData(Measurement_t *Measurement_p, uin } break; + case END_FLASH_CHUNK_TIME: ChankDataBlock_p = FindChunkDataBlock(SessionMeasurement_p->ChunkMeasurement_p, ChunkID); @@ -413,14 +417,17 @@ ErrorCode_e Do_Measurement_AddMeasurementData(Measurement_t *Measurement_p, uin } 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; @@ -462,6 +469,7 @@ ErrorCode_e Do_Measurement_CompleteResults(Measurement_t *Measurement_p) } break; + default: //... break; @@ -646,6 +654,7 @@ static uint32 CalculateSizeOfResults(SessionMeasurement_t *DataMeasurement_p, ui } break; + default: Size = 0; break; diff --git a/source/LCDriver.cpp b/source/LCDriver.cpp index 9c7643b..0754e5e 100644 --- a/source/LCDriver.cpp +++ b/source/LCDriver.cpp @@ -259,7 +259,6 @@ LCDRIVER_API int __cdecl System_Deauthenticate(LCDContext Context, int iType) VERIFY_CONTEXT_STARTED(Context); return Context->m_pObject->Do_System_Deauthenticate(iType); - } LCDRIVER_API int __cdecl System_GetControlKeys(LCDContext Context, TSIMLockKeys *pSIMLockKeys) diff --git a/source/LCDriver.rc b/source/LCDriver.rc index 7b35aa5..679a33a 100644 --- a/source/LCDriver.rc +++ b/source/LCDriver.rc @@ -81,15 +81,15 @@ BEGIN BEGIN BLOCK "000904b0" BEGIN - VALUE "Comments", "Build date: 2011-12-09" + VALUE "Comments", "Build date: 2011-12-26" 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 "PrivateBuild", "Change-Id: If0926da184dfefefcaad0d4e97080de283b7aabd" + VALUE "PrivateBuild", "Change-Id: Ia6539a7ebab97a078bc0d105b23b6a0545762194" VALUE "ProductName", "CXC 173 0865, LCDriver DLL" - VALUE "ProductVersion", "PU3" + VALUE "ProductVersion", "PU4" END END BLOCK "VarFileInfo" diff --git a/source/LCDriverEntry.cpp b/source/LCDriverEntry.cpp index 91bd189..46a588f 100644 --- a/source/LCDriverEntry.cpp +++ b/source/LCDriverEntry.cpp @@ -16,10 +16,13 @@ BOOL APIENTRY DllMain(HMODULE hModule, 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; diff --git a/source/LCDriverMethods.cpp b/source/LCDriverMethods.cpp index 2791c3d..9ce1986 100644 --- a/source/LCDriverMethods.cpp +++ b/source/LCDriverMethods.cpp @@ -52,7 +52,7 @@ extern uint32 DevicesNumber; CLCDriverMethods::CLCDriverMethods(const char *pchInterfaceId): m_EventQueue(256) { - m_pchId = new char[strlen(pchInterfaceId)+1]; + m_pchId = new char[strlen(pchInterfaceId) + 1]; strcpy_s(m_pchId, strlen(pchInterfaceId) + 1, pchInterfaceId); m_pCommunicationDevice = new CommunicationDevice_t; @@ -694,8 +694,6 @@ int CLCDriverMethods::Do_System_ExecuteSoftware(const uint32 ExecuteMode, const ReturnValue = INVALID_EXECUTION_MODE; } - //} - ErrorExit: if (iUseBulk) { @@ -757,7 +755,7 @@ int CLCDriverMethods::Do_System_Deauthenticate(int iType) VERIFY_SUCCESS(IsMainThreadAlive()); VERIFY_SUCCESS(m_pLoaderRpcFunctions->DoRPC_System_Deauthenticate(uiSessionOut, iType)); - VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED | EVENT_CMD_RECEIVED, GROUP_SYSTEM, COMMAND_SYSTEM_DEAUTHENTICATE)); + VERIFY_SUCCESS(WaitForEvent(EVENT_GR_RECEIVED, GROUP_SYSTEM, COMMAND_SYSTEM_DEAUTHENTICATE)); ErrorExit: return ReturnValue; @@ -1948,7 +1946,7 @@ int CLCDriverMethods::Do_A2_System_LoaderOnLoader(const char *pchPath, int iPLOf NumberOfPackets = PL / PacketSize; - if (NumberOfPackets *PacketSize == PL) { + if (NumberOfPackets * PacketSize == PL) { NumberOfPackets--; } @@ -2144,23 +2142,27 @@ int CLCDriverMethods::Do_SwitchProtocolFamily(TFamily family) strcat_s(strMessage, "Do_SetProtocolFamily(R15_FAMILY)"); m_pMainThread->TimerOn(); break; + case PROTROM_PROTOCOL_FAMILY: m_CurrentProtocolFamily = PROTROM_FAMILY; m_CurrentCEHCallback = static_cast(CEH_PROTROM_CallbackFunction); strcat_s(strMessage, "Do_SwitchProtocolFamily(PROTROM_FAMILY)"); break; + case Z_PROTOCOL_FAMILY: m_CurrentProtocolFamily = Z_FAMILY; m_CurrentCEHCallback = static_cast(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(CEH_A2_CallbackFunction); strcat_s(strMessage, "Do_SwitchProtocolFamily(A2_FAMILY)"); //m_pMainThread->TimerOn(); break; + default: return INVALID_INPUT_PARAMETERS; } @@ -2344,7 +2346,7 @@ int CLCDriverMethods::Do_PROTROM_DownloadLoader(const char *pchPath, int iPLOffs //Download all packet beside one NumberOfPackets = PL / PacketSize; - if (NumberOfPackets *PacketSize == PL) { + if (NumberOfPackets * PacketSize == PL) { NumberOfPackets--; } @@ -2425,18 +2427,22 @@ int CLCDriverMethods::SetInitialProtocolFamily(TFamily 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; } @@ -2529,7 +2535,7 @@ int CLCDriverMethods::GetPcTimeouts(TR15Timeouts *R15_TOs, TLCDriverTimeouts *LC /// Size of data to write. /// Void. template -void CLCDriverMethods::CopyVectorToArray(const vector& Source, U *pDestination, int *piSize) +void CLCDriverMethods::CopyVectorToArray(const vector &Source, U *pDestination, int *piSize) { size_t copyLength = *piSize; @@ -2607,6 +2613,7 @@ int CLCDriverMethods::WaitForEvent(uint32 event, int Group, int Command) } break; + case EVENT_CMD_RECEIVED: if ((receivedEvent->group == Group && receivedEvent->command == Command) || @@ -2619,13 +2626,16 @@ int CLCDriverMethods::WaitForEvent(uint32 event, int Group, int Command) } 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; @@ -2716,8 +2726,10 @@ 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; } diff --git a/source/LCDriverMethods.h b/source/LCDriverMethods.h index 6e4ae2a..7033be9 100644 --- a/source/LCDriverMethods.h +++ b/source/LCDriverMethods.h @@ -248,7 +248,7 @@ private: // String and vector copy functions. //----------------------------------------- template - void CopyVectorToArray(const std::vector& Source, U *pDestination, int *piSize); + void CopyVectorToArray(const std::vector &Source, U *pDestination, int *piSize); void CopyStringToArray(std::string &Source, char *pDestination, int *piSize); diff --git a/source/LCM/Hash.cpp b/source/LCM/Hash.cpp index 4f5962c..7836604 100644 --- a/source/LCM/Hash.cpp +++ b/source/LCM/Hash.cpp @@ -23,21 +23,21 @@ **********************************************************************/ 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) + (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() @@ -93,6 +93,7 @@ void *Hash::WorkerThread(void *arg) } break; + case HASH_CRC16: memset(request->Hash_p, 0, CRC16_LENGTH); @@ -102,6 +103,7 @@ void *Hash::WorkerThread(void *arg) } break; + case HASH_SIMPLE_XOR: request->Hash_p[0] = 0; @@ -110,8 +112,10 @@ void *Hash::WorkerThread(void *arg) } break; + case HASH_NONE: break; + default: // unsupported hash type, nothing to do delete request; @@ -184,12 +188,12 @@ 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 ^ (uint8) * p++ << 8; + crc ^= red[crc >> 16]; crc = (crc << 4); - crc ^= red[crc>>16]; + crc ^= red[crc >> 16]; crc = (crc << 4); - crc ^= red[crc>>16]; + crc ^= red[crc >> 16]; } diff --git a/source/LCM/include/t_r15_network_layer.h b/source/LCM/include/t_r15_network_layer.h index 3d48957..fbf1da1 100644 --- a/source/LCM/include/t_r15_network_layer.h +++ b/source/LCM/include/t_r15_network_layer.h @@ -283,7 +283,7 @@ typedef struct { /** R15 Network context */ typedef struct { - PacketMeta_t *MetaInfoList[COMMAND_BUFFER_COUNT+BULK_BUFFER_COUNT]; + 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 retransmission */ diff --git a/source/LcdVersion.cpp b/source/LcdVersion.cpp index ee2bb29..168f0b5 100644 --- a/source/LcdVersion.cpp +++ b/source/LcdVersion.cpp @@ -16,6 +16,6 @@ * var char *LCD_VersionList[] * brief ASCII string list variable holding the LCD version/build time/product number.. */ -char *LCD_VersionList[] = {"PX2", +char *LCD_VersionList[] = {"PX4", NULL }; diff --git a/source/LcmInterface.h b/source/LcmInterface.h index 021559e..be1bc01 100644 --- a/source/LcmInterface.h +++ b/source/LcmInterface.h @@ -24,7 +24,7 @@ typedef ErrorCode_e(*CommunicationSetFamily_t)(Communication_t *Communication_p, 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 char*(*CommunicationGetVersion_t)(Communication_t *Communication_p); +typedef char *(*CommunicationGetVersion_t)(Communication_t *Communication_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); @@ -32,7 +32,7 @@ typedef ErrorCode_e(*R15CommandResetSessionCounters_t)(const Communication_t *co 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_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); diff --git a/source/api_wrappers/linux/CThreadWrapper.cpp b/source/api_wrappers/linux/CThreadWrapper.cpp index 3e95da8..ab3f69b 100644 --- a/source/api_wrappers/linux/CThreadWrapper.cpp +++ b/source/api_wrappers/linux/CThreadWrapper.cpp @@ -30,7 +30,7 @@ // Desc: CEventObject constructor which initializes the class members // Ret: // ****************************************************************************** -CThreadWrapper::CThreadWrapper(void*(*pStartAddress)(void *), void *pArgument) +CThreadWrapper::CThreadWrapper(void * (*pStartAddress)(void *), void *pArgument) { m_pStartAddress = pStartAddress; m_pArgument = pArgument; diff --git a/source/api_wrappers/linux/CThreadWrapper.h b/source/api_wrappers/linux/CThreadWrapper.h index aabadcc..c7bfe01 100644 --- a/source/api_wrappers/linux/CThreadWrapper.h +++ b/source/api_wrappers/linux/CThreadWrapper.h @@ -10,12 +10,12 @@ #include "CEventObject.h" #include -typedef void*(*StartAddress_t)(void *); +typedef void *(*StartAddress_t)(void *); class CThreadWrapper : public CWaitableObject { public: - CThreadWrapper(void*(* pStartAddress)(void *), void *pArgument); + CThreadWrapper(void * (* pStartAddress)(void *), void *pArgument); ~CThreadWrapper(); void ResumeThread(); void SuspendThread(); diff --git a/source/api_wrappers/linux/OS.h b/source/api_wrappers/linux/OS.h index cd219b9..b79c6ea 100644 --- a/source/api_wrappers/linux/OS.h +++ b/source/api_wrappers/linux/OS.h @@ -79,8 +79,10 @@ 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; } diff --git a/source/api_wrappers/windows/WinApiWrappers.h b/source/api_wrappers/windows/WinApiWrappers.h index 65fca8b..f3fbfa1 100644 --- a/source/api_wrappers/windows/WinApiWrappers.h +++ b/source/api_wrappers/windows/WinApiWrappers.h @@ -240,13 +240,16 @@ public: 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; diff --git a/source/config/commands.xml b/source/config/commands.xml index d0c2b24..4c9140a 100644 --- a/source/config/commands.xml +++ b/source/config/commands.xml @@ -387,7 +387,7 @@ - supportedcmdtype="longrunning"> + This command is used by the Loader to deauthenticates the ME from prior authentications to prevent unauthorized access. diff --git a/source/security_algorithms/sha/sha2.cpp b/source/security_algorithms/sha/sha2.cpp index 647bf7d..f3986ca 100644 --- a/source/security_algorithms/sha/sha2.cpp +++ b/source/security_algorithms/sha/sha2.cpp @@ -468,8 +468,8 @@ void SHA256_Transform(SHA256_CTX *context, const sha2_word32 *data) /* 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++); + /* 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; @@ -486,14 +486,14 @@ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j] = *data++); do { /* Part of the message block expansion: */ - s0 = W256[(j+1)&0x0f]; + s0 = W256[(j + 1) & 0x0f]; s0 = sigma0_256(s0); - s1 = W256[(j+14)&0x0f]; + 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); + (W256[j & 0x0f] += s1 + W256[(j + 9) & 0x0f] + s0); T2 = Sigma0_256(a) + Maj(a, b, c); h = g; g = f; @@ -810,8 +810,8 @@ void SHA512_Transform(SHA512_CTX *context, const sha2_word64 *data) /* 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++); + /* 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; @@ -828,14 +828,14 @@ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++); do { /* Part of the message block expansion: */ - s0 = W512[(j+1)&0x0f]; + s0 = W512[(j + 1) & 0x0f]; s0 = sigma0_512(s0); - s1 = W512[(j+14)&0x0f]; + 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); + (W512[j & 0x0f] += s1 + W512[(j + 9) & 0x0f] + s0); T2 = Sigma0_512(a) + Maj(a, b, c); h = g; g = f; @@ -957,7 +957,7 @@ void SHA512_Last(SHA512_CTX *context) /* 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]; + *(sha2_word64 *)&context->buffer[SHA512_SHORT_BLOCK_LENGTH + 8] = context->bitcount[0]; /* Final transform: */ SHA512_Transform(context, (sha2_word64 *)context->buffer); diff --git a/source/utilities/BulkHandler.cpp b/source/utilities/BulkHandler.cpp index eb09fe3..5eebd61 100644 --- a/source/utilities/BulkHandler.cpp +++ b/source/utilities/BulkHandler.cpp @@ -97,7 +97,7 @@ void BulkHandler::Finish(bool ForceFinish) m_State = BULK_INACTIVE; m_ReceiveQueue.SignalEvent(); m_pFileWriteThread->WaitToDie(INFINITE); - } else { + } else if (m_State != BULK_INACTIVE) { m_State = BULK_INACTIVE; if (ForceFinish) { @@ -112,15 +112,19 @@ void BulkHandler::HandleCommandRequest(uint16 session, uint32 chunkSize, uint64 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; } -- cgit v1.2.3