From e70193195c45de2ec5cbeabdf106da6d6ea0c17f Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 2 Mar 2021 20:27:05 -0800 Subject: [PATCH] SI: Generate NOREP on timeout instead of generating Dolphin SDK reply --- Source/Core/Core/HW/SI/SI.cpp | 12 +++++++----- Source/Core/Core/HW/SI/SI_DeviceGBA.cpp | 11 +++-------- Source/Core/Core/HW/SI/SI_DeviceGCController.cpp | 6 +----- Source/Core/Core/HW/SI/SI_DeviceNull.cpp | 4 +--- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/Source/Core/Core/HW/SI/SI.cpp b/Source/Core/Core/HW/SI/SI.cpp index ff349c64bf..1f2e95f1ed 100644 --- a/Source/Core/Core/HW/SI/SI.cpp +++ b/Source/Core/Core/HW/SI/SI.cpp @@ -286,7 +286,7 @@ static void GenerateSIInterrupt(SIInterruptType type) constexpr u32 SI_XFER_LENGTH_MASK = 0x7f; // Translate [0,1,2,...,126,127] to [128,1,2,...,126,127] -constexpr u32 ConvertSILengthField(u32 field) +constexpr s32 ConvertSILengthField(u32 field) { return ((field - 1) & SI_XFER_LENGTH_MASK) + 1; } @@ -295,19 +295,19 @@ static void RunSIBuffer(u64 user_data, s64 cycles_late) { if (s_com_csr.TSTART) { - const u32 request_length = ConvertSILengthField(s_com_csr.OUTLNGTH); - const u32 expected_response_length = ConvertSILengthField(s_com_csr.INLNGTH); + const s32 request_length = ConvertSILengthField(s_com_csr.OUTLNGTH); + const s32 expected_response_length = ConvertSILengthField(s_com_csr.INLNGTH); const std::vector request_copy(s_si_buffer.data(), s_si_buffer.data() + request_length); const std::unique_ptr& device = s_channel[s_com_csr.CHANNEL].device; - const u32 actual_response_length = device->RunBuffer(s_si_buffer.data(), request_length); + const s32 actual_response_length = device->RunBuffer(s_si_buffer.data(), request_length); DEBUG_LOG_FMT(SERIALINTERFACE, "RunSIBuffer chan: {} request_length: {} expected_response_length: {} " "actual_response_length: {}", s_com_csr.CHANNEL, request_length, expected_response_length, actual_response_length); - if (expected_response_length != actual_response_length) + if (actual_response_length > 0 && expected_response_length != actual_response_length) { std::ostringstream ss; for (u8 b : request_copy) @@ -331,6 +331,8 @@ static void RunSIBuffer(u64 user_data, s64 cycles_late) if (actual_response_length != 0) { s_com_csr.TSTART = 0; + if (actual_response_length < 0) + SetNoResponse(s_com_csr.CHANNEL); GenerateSIInterrupt(INT_TCINT); } else diff --git a/Source/Core/Core/HW/SI/SI_DeviceGBA.cpp b/Source/Core/Core/HW/SI/SI_DeviceGBA.cpp index 9268ca9127..36561a6ffb 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceGBA.cpp +++ b/Source/Core/Core/HW/SI/SI_DeviceGBA.cpp @@ -332,10 +332,9 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length) } else { - u32 reply = Common::swap32(SI_ERROR_NO_RESPONSE); - std::memcpy(buffer, &reply, sizeof(reply)); - return sizeof(reply); + return -1; } + m_last_cmd = buffer[0]; m_timestamp_sent = CoreTiming::GetTicks(); m_next_action = NextAction::WaitTransferTime; @@ -371,11 +370,7 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length) m_next_action = NextAction::SendCommand; if (num_data_received == 0) - { - u32 reply = Common::swap32(SI_ERROR_NO_RESPONSE); - std::memcpy(buffer, &reply, sizeof(reply)); - return sizeof(reply); - } + return -1; #ifdef _DEBUG const Common::Log::LOG_LEVELS log_level = (m_last_cmd == CMD_STATUS || m_last_cmd == CMD_RESET) ? Common::Log::LERROR : diff --git a/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp b/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp index 4cf332347b..3393a996c4 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp +++ b/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp @@ -43,11 +43,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length) GCPadStatus pad_status = GetPadStatus(); if (!pad_status.isConnected) - { - u32 reply = Common::swap32(SI_ERROR_NO_RESPONSE); - std::memcpy(buffer, &reply, sizeof(reply)); - return sizeof(reply); - } + return -1; // Read the command EBufferCommands command = static_cast(buffer[0]); diff --git a/Source/Core/Core/HW/SI/SI_DeviceNull.cpp b/Source/Core/Core/HW/SI/SI_DeviceNull.cpp index f4ed00e7ae..6a2b16f2a0 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceNull.cpp +++ b/Source/Core/Core/HW/SI/SI_DeviceNull.cpp @@ -16,9 +16,7 @@ CSIDevice_Null::CSIDevice_Null(SIDevices device, int device_number) int CSIDevice_Null::RunBuffer(u8* buffer, int request_length) { - u32 reply = Common::swap32(SI_ERROR_NO_RESPONSE); - std::memcpy(buffer, &reply, sizeof(reply)); - return sizeof(reply); + return -1; } bool CSIDevice_Null::GetData(u32& hi, u32& low)