Skip to content

Commit

Permalink
Run TEST UNIT READY, make arbitration optional
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Nov 7, 2023
1 parent 765138d commit cbadc2e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cpp/scsidump/phase_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ bool PhaseExecutor::Selection() const
{
bus.SetDAT(static_cast<uint8_t>((1 << initiator_id) + (1 << target_id)));

bus.SetSEL(true);

// Request MESSAGE OUT for IDENTIFY
bus.SetATN(true);

Expand Down
7 changes: 7 additions & 0 deletions cpp/scsidump/scsi_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ using namespace std;
using namespace spdlog;
using namespace scsi_defs;

void ScsiExecutor::TestUnitReady() const
{
vector<uint8_t> cdb(6);

phase_executor->Execute(scsi_command::eCmdTestUnitReady, cdb, {}, 0);
}

bool ScsiExecutor::Inquiry(span<uint8_t> buffer)
{
vector<uint8_t> cdb(6);
Expand Down
1 change: 1 addition & 0 deletions cpp/scsidump/scsi_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ScsiExecutor
ScsiExecutor(BUS& bus, int id) { phase_executor = make_unique<PhaseExecutor>(bus, id); }
~ScsiExecutor() = default;

void TestUnitReady() const;
bool Inquiry(span<uint8_t>);
pair<uint64_t, uint32_t> ReadCapacity();
bool ReadWrite(span<uint8_t>, uint32_t, uint32_t, int, bool);
Expand Down
3 changes: 3 additions & 0 deletions cpp/scsidump/scsidump_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,9 @@ bool ScsiDump::GetDeviceInfo(ostream& console)
return false;
}

// Clear any pending condition, e.g. medium just having being inserted
scsi_executor->TestUnitReady();

const auto [capacity, sector_size] = scsi_executor->ReadCapacity();
if (!capacity || !sector_size) {
spdlog::trace("Can't get device capacity");
Expand Down

0 comments on commit cbadc2e

Please sign in to comment.