diff --git a/src/raspberrypi/devices/block_device.h b/src/raspberrypi/devices/block_device.h index ef0b69db..8511c227 100644 --- a/src/raspberrypi/devices/block_device.h +++ b/src/raspberrypi/devices/block_device.h @@ -11,22 +11,19 @@ #pragma once -#include "primary_device.h" - class SASIDEV; -// TODO There should also be MMCDevice, and scsicd should be derived from MMCDevice, not from BlockDevice -class BlockDevice : public PrimaryDevice +class BlockDevice { public: - BlockDevice(const string& id) : PrimaryDevice(id) {}; + BlockDevice() {}; virtual ~BlockDevice() {}; // Mandatory commands - virtual void TestUnitReady(SASIDEV *) override = 0; - virtual void Inquiry(SASIDEV *) override = 0; - virtual void ReportLuns(SASIDEV *) override = 0; + virtual void TestUnitReady(SASIDEV *) = 0; + virtual void Inquiry(SASIDEV *) = 0; + virtual void ReportLuns(SASIDEV *) = 0; virtual void FormatUnit(SASIDEV *) = 0; virtual void ReadCapacity10(SASIDEV *) = 0; virtual void ReadCapacity16(SASIDEV *) = 0; @@ -34,15 +31,15 @@ public: virtual void Read16(SASIDEV *) = 0; virtual void Write10(SASIDEV *) = 0; virtual void Write16(SASIDEV *) = 0; - virtual void RequestSense(SASIDEV *) override = 0; + virtual void RequestSense(SASIDEV *) = 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 ModeSense(SASIDEV *) = 0; + virtual void ModeSense10(SASIDEV *) = 0; + virtual void ModeSelect(SASIDEV *) = 0; + virtual void ModeSelect10(SASIDEV *) = 0; virtual void ReassignBlocks(SASIDEV *) = 0; virtual void SendDiagnostic(SASIDEV *) = 0; virtual void StartStopUnit(SASIDEV *) = 0; diff --git a/src/raspberrypi/devices/disk.cpp b/src/raspberrypi/devices/disk.cpp index 2202b253..6be32bb2 100644 --- a/src/raspberrypi/devices/disk.cpp +++ b/src/raspberrypi/devices/disk.cpp @@ -1076,7 +1076,7 @@ void DiskCache::Update() // Constructor // //--------------------------------------------------------------------------- -Disk::Disk(const std::string id) : BlockDevice(id) +Disk::Disk(const std::string id) : Device(id), PrimaryDevice(), BlockDevice() { // Work initialization sector_size_configurable = false; @@ -1211,7 +1211,7 @@ void Disk::Open(const Filepath& path) //--------------------------------------------------------------------------- bool Disk::Eject(bool force) { - bool status = BlockDevice::Eject(force); + bool status = Device::Eject(force); if (status) { // Remove disk cache disk.dcache->Save(); diff --git a/src/raspberrypi/devices/disk.h b/src/raspberrypi/devices/disk.h index 5a0953b2..c7110db2 100644 --- a/src/raspberrypi/devices/disk.h +++ b/src/raspberrypi/devices/disk.h @@ -21,7 +21,9 @@ #include "log.h" #include "scsi.h" #include "controllers/scsidev_ctrl.h" +#include "primary_device.h" #include "block_device.h" +#include "device.h" #include "file_support.h" #include "filepath.h" #include @@ -124,7 +126,7 @@ private: // Disk // //=========================================================================== -class Disk : public BlockDevice +class Disk : public Device, public PrimaryDevice, public BlockDevice { private: enum access_mode { RW6, RW10, RW16 }; diff --git a/src/raspberrypi/devices/mmc_device.h b/src/raspberrypi/devices/mmc_device.h new file mode 100644 index 00000000..deff28d4 --- /dev/null +++ b/src/raspberrypi/devices/mmc_device.h @@ -0,0 +1,25 @@ +//--------------------------------------------------------------------------- +// +// SCSI Target Emulator RaSCSI (*^..^*) +// for Raspberry Pi +// +// Copyright (C) 2021 Uwe Seimet +// +// An MmcDevice supports SCSI MMC commands (see https://www.t10.org/drafts.htm, MMC-6) +// +//--------------------------------------------------------------------------- + +#pragma once + +class SASIDEV; + +class MmcDevice +{ +public: + + MmcDevice() {}; + virtual ~MmcDevice() {}; + + virtual void ReadToc(SASIDEV *) = 0; + virtual void GetEventStatusNotification(SASIDEV *) = 0; +}; diff --git a/src/raspberrypi/devices/primary_device.h b/src/raspberrypi/devices/primary_device.h index 412cd109..7909940e 100644 --- a/src/raspberrypi/devices/primary_device.h +++ b/src/raspberrypi/devices/primary_device.h @@ -11,15 +11,13 @@ #pragma once -#include "device.h" - class SASIDEV; -class PrimaryDevice : public Device +class PrimaryDevice { public: - PrimaryDevice(const string& id) : Device(id) {}; + PrimaryDevice() {}; virtual ~PrimaryDevice() {}; // Mandatory commands diff --git a/src/raspberrypi/devices/scsicd.cpp b/src/raspberrypi/devices/scsicd.cpp index 024fe4db..f4bdb80b 100644 --- a/src/raspberrypi/devices/scsicd.cpp +++ b/src/raspberrypi/devices/scsicd.cpp @@ -224,7 +224,7 @@ bool CDTrack::IsAudio() const // Constructor // //--------------------------------------------------------------------------- -SCSICD::SCSICD() : Disk("SCCD") +SCSICD::SCSICD() : Disk("SCCD"), MmcDevice(), FileSupport() { SetRemovable(true); SetReadOnly(true); diff --git a/src/raspberrypi/devices/scsicd.h b/src/raspberrypi/devices/scsicd.h index dc2c33ca..196e10a3 100644 --- a/src/raspberrypi/devices/scsicd.h +++ b/src/raspberrypi/devices/scsicd.h @@ -16,6 +16,8 @@ #pragma once #include "os.h" +#include "primary_device.h" +#include "mmc_device.h" #include "disk.h" #include "filepath.h" @@ -67,7 +69,7 @@ private: // SCSI CD-ROM // //=========================================================================== -class SCSICD : public Disk, public FileSupport +class SCSICD : public Disk, public MmcDevice, public FileSupport { private: typedef struct _command_t {