Skip to content

Commit

Permalink
Update setting of SCSI level
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Dec 8, 2024
1 parent 0c36098 commit c0a047e
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 21 deletions.
6 changes: 3 additions & 3 deletions cpp/base/primary_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion cpp/devices/daynaport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions cpp/devices/disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t> &s)
: StorageDevice(type, level, lun, supports_mode_select, supports_save_parameters, s)
: StorageDevice(type, lun, supports_mode_select, supports_save_parameters, s)
{
SetStoppable(true);
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/devices/disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Disk : public StorageDevice, public ScsiBlockCommands

protected:

Disk(PbDeviceType, scsi_level, int, bool, bool, const set<uint32_t>&);
Disk(PbDeviceType, int, bool, bool, const set<uint32_t>&);

void ValidateFile() override;

Expand Down
3 changes: 2 additions & 1 deletion cpp/devices/host_services.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/devices/optical_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
2 changes: 1 addition & 1 deletion cpp/devices/printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion cpp/devices/sasi_hd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
#include "sasi_hd.h"
#include "shared/s2p_exceptions.h"

SasiHd::SasiHd(int lun, const set<uint32_t> &sector_sizes) : Disk(SAHD, scsi_level::none, lun, false, false,
SasiHd::SasiHd(int lun, const set<uint32_t> &sector_sizes) : Disk(SAHD, lun, false, false,
sector_sizes)
{
SetScsiLevel(scsi_level::none);
SetProduct("SASI HD");
SetProtectable(true);
}
Expand Down
4 changes: 2 additions & 2 deletions cpp/devices/scsi_cd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion cpp/devices/scsi_hd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using namespace memory_util;

ScsiHd::ScsiHd(int lun, bool removable, bool apple, bool scsi1, const set<uint32_t> &sector_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.
Expand All @@ -22,6 +22,7 @@ ScsiHd::ScsiHd(int lun, bool removable, bool apple, bool scsi1, const set<uint32
} else if (removable) {
SetProduct("SCSI HD (REM.)");
}
SetScsiLevel(scsi1 ? scsi_level::scsi_1_ccs : scsi_level::scsi_2);
SetProtectable(true);
SetRemovable(removable);
}
Expand Down
5 changes: 2 additions & 3 deletions cpp/devices/storage_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ class StorageDevice : public PrimaryDevice

protected:

StorageDevice(PbDeviceType type, scsi_level level, int lun, bool s, bool p, const set<uint32_t> &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<uint32_t> &sizes)
: PrimaryDevice(type, lun), supported_block_sizes(sizes), supports_mode_select(s), supports_save_parameters(p)
{
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/devices/tape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions cpp/test/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class MockPrimaryDevice : public PrimaryDevice
MOCK_METHOD(vector<uint8_t>, 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;
Expand Down Expand Up @@ -329,7 +329,7 @@ class MockStorageDevice : public StorageDevice
MOCK_METHOD(vector<uint8_t>, 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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c0a047e

Please sign in to comment.