diff --git a/cpp/base/primary_device.h b/cpp/base/primary_device.h index edbc1183..46578e06 100644 --- a/cpp/base/primary_device.h +++ b/cpp/base/primary_device.h @@ -100,8 +100,8 @@ class PrimaryDevice : public ScsiPrimaryCommands, public Device protected: - PrimaryDevice(PbDeviceType type, scsi_level l, int lun, int delay = SEND_NO_DELAY) - : Device(type, lun), level(l), delay_after_bytes(delay) + PrimaryDevice(PbDeviceType type, int lun, int delay = SEND_NO_DELAY) + : Device(type, lun), delay_after_bytes(delay) { } @@ -198,7 +198,7 @@ class PrimaryDevice : public ScsiPrimaryCommands, public Device DeviceLogger device_logger; - scsi_level level = scsi_level::none; + scsi_level level = scsi_level::scsi_2; enum sense_key sense_key = sense_key::no_sense; enum asc asc = asc::no_additional_sense_information; diff --git a/cpp/devices/daynaport.cpp b/cpp/devices/daynaport.cpp index 6d9732d6..eec13caa 100644 --- a/cpp/devices/daynaport.cpp +++ b/cpp/devices/daynaport.cpp @@ -32,7 +32,7 @@ using namespace s2p_util; // The MacOS DaynaPort driver needs to have a delay after the size/flags field of the read response. // It appears as if the real DaynaPort hardware indeed has this delay. -DaynaPort::DaynaPort(int lun) : PrimaryDevice(SCDP, scsi_level::scsi_2, lun, DAYNAPORT_READ_HEADER_SZ) +DaynaPort::DaynaPort(int lun) : PrimaryDevice(SCDP, lun, DAYNAPORT_READ_HEADER_SZ) { // These data are required by the DaynaPort drivers SetVendor("Dayna"); diff --git a/cpp/devices/disk.cpp b/cpp/devices/disk.cpp index 0bc258de..05845108 100644 --- a/cpp/devices/disk.cpp +++ b/cpp/devices/disk.cpp @@ -21,9 +21,9 @@ using namespace spdlog; using namespace memory_util; using namespace s2p_util; -Disk::Disk(PbDeviceType type, scsi_level level, int lun, bool supports_mode_select, bool supports_save_parameters, +Disk::Disk(PbDeviceType type, int lun, bool supports_mode_select, bool supports_save_parameters, const set &s) -: StorageDevice(type, level, lun, supports_mode_select, supports_save_parameters, s) +: StorageDevice(type, lun, supports_mode_select, supports_save_parameters, s) { SetStoppable(true); } diff --git a/cpp/devices/disk.h b/cpp/devices/disk.h index db235c37..e9ae58c4 100644 --- a/cpp/devices/disk.h +++ b/cpp/devices/disk.h @@ -51,7 +51,7 @@ class Disk : public StorageDevice, public ScsiBlockCommands protected: - Disk(PbDeviceType, scsi_level, int, bool, bool, const set&); + Disk(PbDeviceType, int, bool, bool, const set&); void ValidateFile() override; diff --git a/cpp/devices/host_services.cpp b/cpp/devices/host_services.cpp index 5fc19541..6034f19c 100644 --- a/cpp/devices/host_services.cpp +++ b/cpp/devices/host_services.cpp @@ -96,9 +96,10 @@ using namespace google::protobuf::util; using namespace memory_util; using namespace protobuf_util; -HostServices::HostServices(int lun) : PrimaryDevice(SCHS, scsi_level::spc_3, lun) +HostServices::HostServices(int lun) : PrimaryDevice(SCHS, lun) { SetProduct("Host Services"); + SetScsiLevel(scsi_level::spc_3); SetReady(true); } diff --git a/cpp/devices/optical_memory.cpp b/cpp/devices/optical_memory.cpp index 41be3a6f..b88fb97a 100644 --- a/cpp/devices/optical_memory.cpp +++ b/cpp/devices/optical_memory.cpp @@ -14,7 +14,7 @@ using namespace memory_util; -OpticalMemory::OpticalMemory(int lun) : Disk(SCMO, scsi_level::scsi_2, lun, true, true, { 512, 1024, 2048, 4096 }) +OpticalMemory::OpticalMemory(int lun) : Disk(SCMO, lun, true, true, { 512, 1024, 2048, 4096 }) { // 128 MB, 512 bytes per sector, 248826 sectors geometries[512 * 248826] = { 512, 248826 }; diff --git a/cpp/devices/printer.cpp b/cpp/devices/printer.cpp index 62df7255..8fed6c22 100644 --- a/cpp/devices/printer.cpp +++ b/cpp/devices/printer.cpp @@ -36,7 +36,7 @@ using namespace filesystem; using namespace memory_util; -Printer::Printer(int lun) : PrimaryDevice(SCLP, scsi_level::scsi_2, lun) +Printer::Printer(int lun) : PrimaryDevice(SCLP, lun) { SetProduct("SCSI PRINTER"); SupportsParams(true); diff --git a/cpp/devices/sasi_hd.cpp b/cpp/devices/sasi_hd.cpp index 880fae6f..a03c86eb 100644 --- a/cpp/devices/sasi_hd.cpp +++ b/cpp/devices/sasi_hd.cpp @@ -9,9 +9,10 @@ #include "sasi_hd.h" #include "shared/s2p_exceptions.h" -SasiHd::SasiHd(int lun, const set §or_sizes) : Disk(SAHD, scsi_level::none, lun, false, false, +SasiHd::SasiHd(int lun, const set §or_sizes) : Disk(SAHD, lun, false, false, sector_sizes) { + SetScsiLevel(scsi_level::none); SetProduct("SASI HD"); SetProtectable(true); } diff --git a/cpp/devices/scsi_cd.cpp b/cpp/devices/scsi_cd.cpp index 99a41025..0241cd9a 100644 --- a/cpp/devices/scsi_cd.cpp +++ b/cpp/devices/scsi_cd.cpp @@ -13,10 +13,10 @@ using namespace memory_util; -ScsiCd::ScsiCd(int lun, bool scsi1) : Disk(SCCD, scsi1 ? scsi_level::scsi_1_ccs : scsi_level::scsi_2, lun, true, false, - { 512, 2048 }) +ScsiCd::ScsiCd(int lun, bool scsi1) : Disk(SCCD, lun, true, false, { 512, 2048 }) { SetProduct("SCSI CD-ROM"); + SetScsiLevel(scsi1 ? scsi_level::scsi_1_ccs : scsi_level::scsi_2); SetReadOnly(true); SetRemovable(true); } diff --git a/cpp/devices/scsi_hd.cpp b/cpp/devices/scsi_hd.cpp index b65cabc5..8df63f99 100644 --- a/cpp/devices/scsi_hd.cpp +++ b/cpp/devices/scsi_hd.cpp @@ -12,7 +12,7 @@ using namespace memory_util; ScsiHd::ScsiHd(int lun, bool removable, bool apple, bool scsi1, const set §or_sizes) -: Disk(removable ? SCRM : SCHD, scsi1 ? scsi_level::scsi_1_ccs : scsi_level::scsi_2, lun, true, true, sector_sizes) +: Disk(removable ? SCRM : SCHD, lun, true, true, sector_sizes) { // Some Apple tools require a particular drive identification. // Except for the vendor string .hda is the same as .hds. @@ -22,6 +22,7 @@ ScsiHd::ScsiHd(int lun, bool removable, bool apple, bool scsi1, const set &sizes) - : PrimaryDevice(type, level, lun), supported_block_sizes(sizes), supports_mode_select(s), supports_save_parameters( - p) + StorageDevice(PbDeviceType type, int lun, bool s, bool p, const set &sizes) + : PrimaryDevice(type, lun), supported_block_sizes(sizes), supports_mode_select(s), supports_save_parameters(p) { } diff --git a/cpp/devices/tape.cpp b/cpp/devices/tape.cpp index d6e9163e..30621709 100644 --- a/cpp/devices/tape.cpp +++ b/cpp/devices/tape.cpp @@ -25,7 +25,7 @@ using namespace spdlog; using namespace memory_util; using namespace s2p_util; -Tape::Tape(int lun) : StorageDevice(SCTP, scsi_level::scsi_2, lun, true, false, { 512, 1024, 2048, 4096, 8192 }) +Tape::Tape(int lun) : StorageDevice(SCTP, lun, true, false, { 512, 1024, 2048, 4096, 8192 }) { SetProduct("SCSI TAPE"); SupportsParams(true); diff --git a/cpp/test/mocks.h b/cpp/test/mocks.h index d1d92245..522f6d7e 100644 --- a/cpp/test/mocks.h +++ b/cpp/test/mocks.h @@ -293,7 +293,7 @@ class MockPrimaryDevice : public PrimaryDevice MOCK_METHOD(vector, InquiryInternal, (), (const, override)); MOCK_METHOD(void, FlushCache, (), (override)); - explicit MockPrimaryDevice(int lun) : PrimaryDevice(UNDEFINED, scsi_level::scsi_2, lun) + explicit MockPrimaryDevice(int lun) : PrimaryDevice(UNDEFINED, lun) { } ~MockPrimaryDevice() override = default; @@ -329,7 +329,7 @@ class MockStorageDevice : public StorageDevice MOCK_METHOD(vector, InquiryInternal, (), (const, override)); MOCK_METHOD(void, Open, (), (override)); - MockStorageDevice() : StorageDevice(UNDEFINED, scsi_level::scsi_2, 0, false, false, { 256, 512, 1024, 2048, 4096 }) + MockStorageDevice() : StorageDevice(UNDEFINED, 0, false, false, { 256, 512, 1024, 2048, 4096 }) { } ~MockStorageDevice() override = default; @@ -388,7 +388,7 @@ class MockDisk : public Disk MOCK_METHOD(void, FlushCache, (), (override)); MOCK_METHOD(void, Open, (), (override)); - MockDisk() : Disk(SCHD, scsi_level::scsi_2, 0, false, false, { 512, 1024, 2048, 4096 }) + MockDisk() : Disk(SCHD, 0, false, false, { 512, 1024, 2048, 4096 }) { SetCachingMode(PbCachingMode::LINUX); SetBlockSize(512);