From cbadc2e3533c2e18109a93c090fb5f656207f02f Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Tue, 7 Nov 2023 22:17:33 +0100 Subject: [PATCH] Run TEST UNIT READY, make arbitration optional --- cpp/scsidump/phase_executor.cpp | 2 ++ cpp/scsidump/scsi_executor.cpp | 7 +++++++ cpp/scsidump/scsi_executor.h | 1 + cpp/scsidump/scsidump_core.cpp | 3 +++ 4 files changed, 13 insertions(+) diff --git a/cpp/scsidump/phase_executor.cpp b/cpp/scsidump/phase_executor.cpp index a6a9692f19..1eb0dea98e 100644 --- a/cpp/scsidump/phase_executor.cpp +++ b/cpp/scsidump/phase_executor.cpp @@ -140,6 +140,8 @@ bool PhaseExecutor::Selection() const { bus.SetDAT(static_cast((1 << initiator_id) + (1 << target_id))); + bus.SetSEL(true); + // Request MESSAGE OUT for IDENTIFY bus.SetATN(true); diff --git a/cpp/scsidump/scsi_executor.cpp b/cpp/scsidump/scsi_executor.cpp index 8e42b4f91e..80493d0b22 100644 --- a/cpp/scsidump/scsi_executor.cpp +++ b/cpp/scsidump/scsi_executor.cpp @@ -15,6 +15,13 @@ using namespace std; using namespace spdlog; using namespace scsi_defs; +void ScsiExecutor::TestUnitReady() const +{ + vector cdb(6); + + phase_executor->Execute(scsi_command::eCmdTestUnitReady, cdb, {}, 0); +} + bool ScsiExecutor::Inquiry(span buffer) { vector cdb(6); diff --git a/cpp/scsidump/scsi_executor.h b/cpp/scsidump/scsi_executor.h index 042fe80de1..a8631d140d 100644 --- a/cpp/scsidump/scsi_executor.h +++ b/cpp/scsidump/scsi_executor.h @@ -24,6 +24,7 @@ class ScsiExecutor ScsiExecutor(BUS& bus, int id) { phase_executor = make_unique(bus, id); } ~ScsiExecutor() = default; + void TestUnitReady() const; bool Inquiry(span); pair ReadCapacity(); bool ReadWrite(span, uint32_t, uint32_t, int, bool); diff --git a/cpp/scsidump/scsidump_core.cpp b/cpp/scsidump/scsidump_core.cpp index 5ebd5adb1d..9cbf770c57 100644 --- a/cpp/scsidump/scsidump_core.cpp +++ b/cpp/scsidump/scsidump_core.cpp @@ -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");