Skip to content

Commit

Permalink
Update phase dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Jan 23, 2024
1 parent e240a74 commit add834c
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions cpp/shared_initiator/phase_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ bool PhaseExecutor::Dispatch(scsi_command cmd, span<uint8_t> cdb, span<uint8_t>
break;

default:
throw phase_exception(string("Ignoring ") + Bus::GetPhaseName(phase) + " phase");
spdlog::error(string("Ignoring ") + Bus::GetPhaseName(phase) + " phase");
return false;
}

return true;
Expand Down Expand Up @@ -198,24 +199,25 @@ void PhaseExecutor::Status()
array<uint8_t, 1> buf;

if (bus.ReceiveHandShake(buf.data(), 1) != static_cast<int>(buf.size())) {
throw phase_exception("STATUS phase failed");
spdlog::error("STATUS phase failed");
}
else {
status = buf[0];
}

status = buf[0];
}

void PhaseExecutor::DataIn(span<uint8_t> buffer, int length)
{
byte_count = bus.ReceiveHandShake(buffer.data(), length);
if (!byte_count) {
throw phase_exception("DATA IN phase failed");
spdlog::error("DATA IN phase failed");
}
}

void PhaseExecutor::DataOut(span<uint8_t> buffer, int length)
{
if (bus.SendHandShake(buffer.data(), length) != length) {
throw phase_exception("DATA OUT phase failed");
spdlog::error("DATA OUT phase failed");
}
}

Expand All @@ -224,10 +226,9 @@ void PhaseExecutor::MsgIn()
array<uint8_t, 1> buf = { };

if (bus.ReceiveHandShake(buf.data(), buf.size()) != buf.size()) {
throw phase_exception("MESSAGE IN phase failed");
spdlog::error("MESSAGE IN phase failed");
}

if (buf[0]) {
else if (buf[0]) {
spdlog::warn(
fmt::format("MESSAGE IN did not report COMMAND COMPLETE, rejecting unsupported message ${:02x}", buf[0]));

Expand All @@ -249,7 +250,7 @@ void PhaseExecutor::MsgOut()
reject = false;

if (bus.SendHandShake(buf.data(), buf.size()) != buf.size()) {
throw phase_exception("MESSAGE OUT phase for IDENTIFY failed");
spdlog::error("MESSAGE OUT phase for IDENTIFY failed");
}
}

Expand Down

0 comments on commit add834c

Please sign in to comment.