SI: Generate NOREP on timeout instead of generating Dolphin SDK reply

This commit is contained in:
Vicki Pfau 2021-03-02 20:27:05 -08:00
parent 509b24a27f
commit e70193195c
4 changed files with 12 additions and 21 deletions

View File

@ -286,7 +286,7 @@ static void GenerateSIInterrupt(SIInterruptType type)
constexpr u32 SI_XFER_LENGTH_MASK = 0x7f; constexpr u32 SI_XFER_LENGTH_MASK = 0x7f;
// Translate [0,1,2,...,126,127] to [128,1,2,...,126,127] // 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; 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) if (s_com_csr.TSTART)
{ {
const u32 request_length = ConvertSILengthField(s_com_csr.OUTLNGTH); const s32 request_length = ConvertSILengthField(s_com_csr.OUTLNGTH);
const u32 expected_response_length = ConvertSILengthField(s_com_csr.INLNGTH); const s32 expected_response_length = ConvertSILengthField(s_com_csr.INLNGTH);
const std::vector<u8> request_copy(s_si_buffer.data(), s_si_buffer.data() + request_length); const std::vector<u8> request_copy(s_si_buffer.data(), s_si_buffer.data() + request_length);
const std::unique_ptr<ISIDevice>& device = s_channel[s_com_csr.CHANNEL].device; const std::unique_ptr<ISIDevice>& 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, DEBUG_LOG_FMT(SERIALINTERFACE,
"RunSIBuffer chan: {} request_length: {} expected_response_length: {} " "RunSIBuffer chan: {} request_length: {} expected_response_length: {} "
"actual_response_length: {}", "actual_response_length: {}",
s_com_csr.CHANNEL, request_length, expected_response_length, s_com_csr.CHANNEL, request_length, expected_response_length,
actual_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; std::ostringstream ss;
for (u8 b : request_copy) for (u8 b : request_copy)
@ -331,6 +331,8 @@ static void RunSIBuffer(u64 user_data, s64 cycles_late)
if (actual_response_length != 0) if (actual_response_length != 0)
{ {
s_com_csr.TSTART = 0; s_com_csr.TSTART = 0;
if (actual_response_length < 0)
SetNoResponse(s_com_csr.CHANNEL);
GenerateSIInterrupt(INT_TCINT); GenerateSIInterrupt(INT_TCINT);
} }
else else

View File

@ -332,10 +332,9 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length)
} }
else else
{ {
u32 reply = Common::swap32(SI_ERROR_NO_RESPONSE); return -1;
std::memcpy(buffer, &reply, sizeof(reply));
return sizeof(reply);
} }
m_last_cmd = buffer[0]; m_last_cmd = buffer[0];
m_timestamp_sent = CoreTiming::GetTicks(); m_timestamp_sent = CoreTiming::GetTicks();
m_next_action = NextAction::WaitTransferTime; m_next_action = NextAction::WaitTransferTime;
@ -371,11 +370,7 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length)
m_next_action = NextAction::SendCommand; m_next_action = NextAction::SendCommand;
if (num_data_received == 0) if (num_data_received == 0)
{ return -1;
u32 reply = Common::swap32(SI_ERROR_NO_RESPONSE);
std::memcpy(buffer, &reply, sizeof(reply));
return sizeof(reply);
}
#ifdef _DEBUG #ifdef _DEBUG
const Common::Log::LOG_LEVELS log_level = const Common::Log::LOG_LEVELS log_level =
(m_last_cmd == CMD_STATUS || m_last_cmd == CMD_RESET) ? Common::Log::LERROR : (m_last_cmd == CMD_STATUS || m_last_cmd == CMD_RESET) ? Common::Log::LERROR :

View File

@ -43,11 +43,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
GCPadStatus pad_status = GetPadStatus(); GCPadStatus pad_status = GetPadStatus();
if (!pad_status.isConnected) if (!pad_status.isConnected)
{ return -1;
u32 reply = Common::swap32(SI_ERROR_NO_RESPONSE);
std::memcpy(buffer, &reply, sizeof(reply));
return sizeof(reply);
}
// Read the command // Read the command
EBufferCommands command = static_cast<EBufferCommands>(buffer[0]); EBufferCommands command = static_cast<EBufferCommands>(buffer[0]);

View File

@ -16,9 +16,7 @@ CSIDevice_Null::CSIDevice_Null(SIDevices device, int device_number)
int CSIDevice_Null::RunBuffer(u8* buffer, int request_length) int CSIDevice_Null::RunBuffer(u8* buffer, int request_length)
{ {
u32 reply = Common::swap32(SI_ERROR_NO_RESPONSE); return -1;
std::memcpy(buffer, &reply, sizeof(reply));
return sizeof(reply);
} }
bool CSIDevice_Null::GetData(u32& hi, u32& low) bool CSIDevice_Null::GetData(u32& hi, u32& low)