Skip to content

Commit

Permalink
Reset bus after phase error
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Dec 11, 2024
1 parent fef0e22 commit f2aff38
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cpp/controllers/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void Controller::Command()
RaiseDeferredError(sense_key::illegal_request, asc::invalid_command_operation_code);
}
else {
GetBus().SetRST(true);
RaiseDeferredError(sense_key::aborted_command, asc::command_phase_error);
}
return;
Expand All @@ -131,6 +132,7 @@ void Controller::Command()
if (actual_count != command_bytes_count) {
LogWarn(fmt::format("Received {0} byte(s) in COMMAND phase for command ${1:02x}, {2} required",
command_bytes_count, GetCdb()[0], actual_count));
GetBus().SetRST(true);
RaiseDeferredError(sense_key::aborted_command, asc::command_phase_error);
return;
}
Expand Down Expand Up @@ -347,6 +349,7 @@ void Controller::Send()
if (const int l = GetBus().SendHandShake(GetBuffer().data() + GetOffset(), length,
GetDeviceForLun(0)->GetDelayAfterBytes()); l != length) {
LogWarn(fmt::format("Sent {0} byte(s), {1} required", l, length));
GetBus().SetRST(true);
Error(sense_key::aborted_command, asc::data_phase_error);
return;
}
Expand Down Expand Up @@ -406,6 +409,7 @@ void Controller::Receive()

if (const int l = GetBus().ReceiveHandShake(GetBuffer().data() + GetOffset(), length); l != length) {
LogWarn(fmt::format("Received {0} byte(s), {1} required", l, length));
GetBus().SetRST(true);
Error(sense_key::aborted_command, asc::data_phase_error);
return;
}
Expand Down Expand Up @@ -492,10 +496,10 @@ bool Controller::TransferFromHost(int length)
// TODO Try to remove this special case
if (cmd == scsi_command::mode_select_6 || cmd == scsi_command::mode_select_10) {
// The offset is the number of bytes transferred, i.e. the length of the parameter list
device->ModeSelect(GetCdb(), GetBuffer(), GetOffset(), -1);
device->ModeSelect(GetCdb(), GetBuffer(), GetOffset(), 0);
}
else {
transferred_length = device->WriteData(GetCdb(), GetBuffer(), -1, length);
transferred_length = device->WriteData(GetCdb(), GetBuffer(), 0, length);
}
}
catch (const scsi_exception &e) {
Expand Down

0 comments on commit f2aff38

Please sign in to comment.