From c08b1abfa91aa35bb41e3d9aaad577f0be6064cd Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Mon, 23 Aug 2021 16:04:11 +0200 Subject: [PATCH] SCSI interface updated, added Synchronize16 --- src/raspberrypi/controllers/sasidev_ctrl.cpp | 2 +- src/raspberrypi/controllers/scsidev_ctrl.h | 6 +++--- src/raspberrypi/devices/block_device.h | 13 +++++++++++-- src/raspberrypi/devices/disk.cpp | 20 +++++++++++++------- src/raspberrypi/devices/disk.h | 7 ++++--- src/raspberrypi/devices/primary_device.h | 1 + src/raspberrypi/gpiobus.cpp | 2 +- 7 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/raspberrypi/controllers/sasidev_ctrl.cpp b/src/raspberrypi/controllers/sasidev_ctrl.cpp index f80c99b9..8329c74e 100644 --- a/src/raspberrypi/controllers/sasidev_ctrl.cpp +++ b/src/raspberrypi/controllers/sasidev_ctrl.cpp @@ -720,7 +720,7 @@ void SASIDEV::CmdFormat() LOGTRACE( "%s FORMAT UNIT Command ", __PRETTY_FUNCTION__); // Command processing on drive - ctrl.device->Format(this); + ctrl.device->FormatUnit(this); } //--------------------------------------------------------------------------- diff --git a/src/raspberrypi/controllers/scsidev_ctrl.h b/src/raspberrypi/controllers/scsidev_ctrl.h index a54725ce..c724dff0 100644 --- a/src/raspberrypi/controllers/scsidev_ctrl.h +++ b/src/raspberrypi/controllers/scsidev_ctrl.h @@ -51,9 +51,8 @@ public: eCmdRead10 = 0x28, eCmdWrite10 = 0x2A, eCmdSeek10 = 0x2B, - eCmdVerify10 = 0x2E, - eCmdVerify = 0x2F, - eCmdSynchronizeCache = 0x35, + eCmdVerify10 = 0x2F, + eCmdSynchronizeCache10 = 0x35, eCmdReadDefectData10 = 0x37, eCmdReadToc = 0x43, eCmdPlayAudio10 = 0x45, @@ -67,6 +66,7 @@ public: eCmdRead16 = 0x88, eCmdWrite16 = 0x8A, eCmdVerify16 = 0x8F, + eCmdSynchronizeCache16 = 0x91, eCmdReadCapacity16 = 0x9E, eCmdReportLuns = 0xA0 }; diff --git a/src/raspberrypi/devices/block_device.h b/src/raspberrypi/devices/block_device.h index 9c3ea143..d255ee46 100644 --- a/src/raspberrypi/devices/block_device.h +++ b/src/raspberrypi/devices/block_device.h @@ -26,18 +26,27 @@ public: virtual void TestUnitReady(SASIDEV *) override = 0; virtual void Inquiry(SASIDEV *) override = 0; virtual void ReportLuns(SASIDEV *) override = 0; - virtual void Format(SASIDEV *) = 0; + virtual void FormatUnit(SASIDEV *) = 0; virtual void ReadCapacity10(SASIDEV *) = 0; virtual void ReadCapacity16(SASIDEV *) = 0; virtual void Read10(SASIDEV *) = 0; virtual void Read16(SASIDEV *) = 0; virtual void Write10(SASIDEV *) = 0; virtual void Write16(SASIDEV *) = 0; - virtual void RequestSense(SASIDEV *) override = 0; + + // Implemented optional commands + virtual void Verify10(SASIDEV *) = 0; +// virtual void Verify16(SASIDEV *) = 0; virtual void ModeSense(SASIDEV *) override = 0; virtual void ModeSense10(SASIDEV *) override = 0; virtual void ModeSelect(SASIDEV *) override = 0; + virtual void ModeSelect10(SASIDEV *) override = 0; + virtual void ReassignBlocks(SASIDEV *) = 0; + virtual void SendDiagnostic(SASIDEV *) = 0; + virtual void StartStopUnit(SASIDEV *) = 0; + virtual void SynchronizeCache10(SASIDEV *) = 0; + virtual void SynchronizeCache16(SASIDEV *) = 0; // TODO Add the other optional commands currently implemented }; diff --git a/src/raspberrypi/devices/disk.cpp b/src/raspberrypi/devices/disk.cpp index 651faf90..5a8aebbf 100644 --- a/src/raspberrypi/devices/disk.cpp +++ b/src/raspberrypi/devices/disk.cpp @@ -402,7 +402,7 @@ void Disk::RequestSense(SASIDEV *controller) controller->DataIn(); } -void Disk::Format(SASIDEV *controller) +void Disk::FormatUnit(SASIDEV *controller) { bool status = Format(ctrl->cmd); if (!status) { @@ -654,7 +654,7 @@ void Disk::Write16(SASIDEV *controller) // VERIFY // //--------------------------------------------------------------------------- -void Disk::Verify(SASIDEV *controller) +void Disk::Verify10(SASIDEV *controller) { // Get record number and block number uint64_t record; @@ -819,7 +819,7 @@ void Disk::PreventAllowRemoval(SASIDEV *controller) controller->Status(); } -void Disk::SynchronizeCache(SASIDEV *controller) +void Disk::SynchronizeCache10(SASIDEV *controller) { // Nothing to do @@ -827,6 +827,11 @@ void Disk::SynchronizeCache(SASIDEV *controller) controller->Status(); } +void Disk::SynchronizeCache16(SASIDEV *controller) +{ + return SynchronizeCache10(controller); +} + void Disk::ReadDefectData10(SASIDEV *controller) { ctrl->length = ReadDefectData10(ctrl->cmd, ctrl->buffer); @@ -1161,7 +1166,7 @@ Disk::Disk(const std::string id) : BlockDevice(id) AddCommand(SCSIDEV::eCmdTestUnitReady, "CmdTestUnitReady", &Disk::TestUnitReady); AddCommand(SCSIDEV::eCmdRezero, "CmdRezero", &Disk::Rezero); AddCommand(SCSIDEV::eCmdRequestSense, "CmdRequestSense", &Disk::RequestSense); - AddCommand(SCSIDEV::eCmdFormat, "CmdFormat", &Disk::Format); + AddCommand(SCSIDEV::eCmdFormat, "CmdFormat", &Disk::FormatUnit); AddCommand(SCSIDEV::eCmdReassign, "CmdReassign", &Disk::ReassignBlocks); AddCommand(SCSIDEV::eCmdRead6, "CmdRead6", &Disk::Read6); AddCommand(SCSIDEV::eCmdWrite6, "CmdWrite6", &Disk::Write6); @@ -1179,8 +1184,9 @@ Disk::Disk(const std::string id) : BlockDevice(id) AddCommand(SCSIDEV::eCmdWrite10, "CmdWrite10", &Disk::Write10); AddCommand(SCSIDEV::eCmdVerify10, "CmdVerify10", &Disk::Write10); AddCommand(SCSIDEV::eCmdSeek10, "CmdSeek10", &Disk::Seek10); - AddCommand(SCSIDEV::eCmdVerify, "CmdVerify", &Disk::Verify); - AddCommand(SCSIDEV::eCmdSynchronizeCache, "CmdSynchronizeCache", &Disk::SynchronizeCache); + AddCommand(SCSIDEV::eCmdVerify10, "CmdVerify10", &Disk::Verify10); + AddCommand(SCSIDEV::eCmdSynchronizeCache10, "CmdSynchronizeCache10", &Disk::SynchronizeCache10); + AddCommand(SCSIDEV::eCmdSynchronizeCache16, "CmdSynchronizeCache16", &Disk::SynchronizeCache16); AddCommand(SCSIDEV::eCmdReadDefectData10, "CmdReadDefectData10", &Disk::ReadDefectData10); AddCommand(SCSIDEV::eCmdModeSelect10, "CmdModeSelect10", &Disk::ModeSelect10); AddCommand(SCSIDEV::eCmdReserve10, "CmdReserve10", &Disk::Reserve10); @@ -1188,7 +1194,7 @@ Disk::Disk(const std::string id) : BlockDevice(id) AddCommand(SCSIDEV::eCmdModeSense10, "CmdModeSense10", &Disk::ModeSense10); AddCommand(SCSIDEV::eCmdRead16, "CmdRead16", &Disk::Read16); AddCommand(SCSIDEV::eCmdWrite16, "CmdWrite16", &Disk::Write16); - AddCommand(SCSIDEV::eCmdVerify16, "CmdVerify16", &Disk::Write16); + //AddCommand(SCSIDEV::eCmdVerify16, "CmdVerify16", &Disk::Verify16); AddCommand(SCSIDEV::eCmdReadCapacity16, "CmdReadCapacity16", &Disk::ReadCapacity16); AddCommand(SCSIDEV::eCmdReportLuns, "CmdReportLuns", &Disk::ReportLuns); } diff --git a/src/raspberrypi/devices/disk.h b/src/raspberrypi/devices/disk.h index 0e967b7d..29063e06 100644 --- a/src/raspberrypi/devices/disk.h +++ b/src/raspberrypi/devices/disk.h @@ -172,12 +172,13 @@ public: void ModeSense(SASIDEV *); void ModeSense10(SASIDEV *); void Rezero(SASIDEV *); - void Format(SASIDEV *) override; + void FormatUnit(SASIDEV *) override; void ReassignBlocks(SASIDEV *); void StartStopUnit(SASIDEV *); void SendDiagnostic(SASIDEV *); void PreventAllowRemoval(SASIDEV *); - void SynchronizeCache(SASIDEV *); + void SynchronizeCache10(SASIDEV *); + void SynchronizeCache16(SASIDEV *); void ReadDefectData10(SASIDEV *); void Read6(SASIDEV *); void Read10(SASIDEV *) override; @@ -185,6 +186,7 @@ public: void Write6(SASIDEV *); void Write10(SASIDEV *) override; void Write16(SASIDEV *) override; + void Verify10(SASIDEV *) override; void Seek(SASIDEV *); void Seek6(SASIDEV *); void Seek10(SASIDEV *); @@ -197,7 +199,6 @@ public: void Release10(SASIDEV *); // Command helpers - void Verify(SASIDEV *); // VERIFY command virtual int Inquiry(const DWORD *cdb, BYTE *buf) = 0; // INQUIRY command virtual int WriteCheck(DWORD block); // WRITE check virtual bool Write(const DWORD *cdb, const BYTE *buf, DWORD block); // WRITE command diff --git a/src/raspberrypi/devices/primary_device.h b/src/raspberrypi/devices/primary_device.h index a72dbe4c..412cd109 100644 --- a/src/raspberrypi/devices/primary_device.h +++ b/src/raspberrypi/devices/primary_device.h @@ -32,4 +32,5 @@ public: virtual void ModeSense(SASIDEV *) = 0; virtual void ModeSense10(SASIDEV *) = 0; virtual void ModeSelect(SASIDEV *) = 0; + virtual void ModeSelect10(SASIDEV *) = 0; }; diff --git a/src/raspberrypi/gpiobus.cpp b/src/raspberrypi/gpiobus.cpp index 37adf653..a1f07c1e 100644 --- a/src/raspberrypi/gpiobus.cpp +++ b/src/raspberrypi/gpiobus.cpp @@ -1612,7 +1612,7 @@ BUS::phase_t GPIOBUS::GetPhaseRaw(DWORD raw_data) // //--------------------------------------------------------------------------- int GPIOBUS::GetCommandByteCount(BYTE opcode) { - if (opcode == 0x88 || opcode == 0x8A || opcode == 0x8F || opcode == 0x9E) { + if (opcode == 0x88 || opcode == 0x8A || opcode == 0x8F || opcode == 0x91 || opcode == 0x9E) { return 16; } else if (opcode == 0xA0) {