Merge pull request #9551 from endrift/si-norep

SI: Generate NOREP on timeout instead of generating Dolphin SDK reply
This commit is contained in:
JMC47 2021-05-24 00:50:23 -04:00 committed by GitHub
commit 96c1f6298b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 24 deletions

View File

@ -240,7 +240,6 @@ static void SetNoResponse(u32 channel)
s_status_reg.NOREP3 = 1;
break;
}
s_com_csr.COMERR = 1;
}
static void ChangeDeviceCallback(u64 user_data, s64 cycles_late)
@ -286,7 +285,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 +294,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<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 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 +330,9 @@ static void RunSIBuffer(u64 user_data, s64 cycles_late)
if (actual_response_length != 0)
{
s_com_csr.TSTART = 0;
s_com_csr.COMERR = actual_response_length < 0;
if (actual_response_length < 0)
SetNoResponse(s_com_csr.CHANNEL);
GenerateSIInterrupt(INT_TCINT);
}
else
@ -501,8 +503,6 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
s_com_csr.RDSTINTMSK = tmp_com_csr.RDSTINTMSK;
s_com_csr.TCINTMSK = tmp_com_csr.TCINTMSK;
s_com_csr.COMERR = 0;
if (tmp_com_csr.RDSTINT)
s_com_csr.RDSTINT = 0;
if (tmp_com_csr.TCINT)

View File

@ -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 :

View File

@ -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<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)
{
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)