mirror of https://github.com/akuker/RASCSI.git
Revert "Honor sector size change via ModeSelect6 in scsicd (#1406)"
This reverts commit b7f65d33e2
.
This commit is contained in:
parent
29d00b36ce
commit
594e5b052a
|
@ -696,17 +696,11 @@ uint32_t Disk::GetSectorSizeInBytes() const
|
||||||
void Disk::SetSectorSizeInBytes(uint32_t size_in_bytes)
|
void Disk::SetSectorSizeInBytes(uint32_t size_in_bytes)
|
||||||
{
|
{
|
||||||
if (!GetSupportedSectorSizes().contains(size_in_bytes)) {
|
if (!GetSupportedSectorSizes().contains(size_in_bytes)) {
|
||||||
throw io_exception("Invalid sector size of " + to_string(size_in_bytes) + " byte(s)");
|
throw io_exception("Invalid sector size of " + to_string(size_in_bytes) + " byte(s)");
|
||||||
}
|
}
|
||||||
uint64_t current_blocks = GetBlockCount();
|
|
||||||
uint32_t current_size_shift_count = size_shift_count;
|
|
||||||
uint64_t current_size = current_blocks << current_size_shift_count;
|
|
||||||
|
|
||||||
size_shift_count = CalculateShiftCount(size_in_bytes);
|
size_shift_count = CalculateShiftCount(size_in_bytes);
|
||||||
assert(size_shift_count);
|
assert(size_shift_count);
|
||||||
if ((current_blocks > 0) && (current_size_shift_count > 0)) {
|
|
||||||
SetBlockCount(current_size >> size_shift_count);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Disk::GetConfiguredSectorSize() const
|
uint32_t Disk::GetConfiguredSectorSize() const
|
||||||
|
@ -720,7 +714,7 @@ bool Disk::SetConfiguredSectorSize(uint32_t configured_size)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
configured_sector_size = configured_size;
|
configured_sector_size = configured_size;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ protected:
|
||||||
|
|
||||||
void SetUpCache(off_t, bool = false);
|
void SetUpCache(off_t, bool = false);
|
||||||
void ResizeCache(const string&, bool);
|
void ResizeCache(const string&, bool);
|
||||||
bool GetRawMode() const { return (cache?cache->GetRawMode():false); }
|
|
||||||
void SetUpModePages(map<int, vector<byte>>&, int, bool) const override;
|
void SetUpModePages(map<int, vector<byte>>&, int, bool) const override;
|
||||||
void AddErrorPage(map<int, vector<byte>>&, bool) const;
|
void AddErrorPage(map<int, vector<byte>>&, bool) const;
|
||||||
virtual void AddFormatPage(map<int, vector<byte>>&, bool) const;
|
virtual void AddFormatPage(map<int, vector<byte>>&, bool) const;
|
||||||
|
|
|
@ -51,7 +51,6 @@ public:
|
||||||
~DiskCache() = default;
|
~DiskCache() = default;
|
||||||
|
|
||||||
void SetRawMode(bool b) { cd_raw = b; } // CD-ROM raw mode setting
|
void SetRawMode(bool b) { cd_raw = b; } // CD-ROM raw mode setting
|
||||||
bool GetRawMode() const { return cd_raw; }
|
|
||||||
|
|
||||||
bool Save(); // Save and release all
|
bool Save(); // Save and release all
|
||||||
bool ReadSector(span<uint8_t>, uint32_t); // Sector Read
|
bool ReadSector(span<uint8_t>, uint32_t); // Sector Read
|
||||||
|
|
|
@ -114,7 +114,7 @@ void ModePageDevice::ModeSense10() const
|
||||||
EnterDataInPhase();
|
EnterDataInPhase();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModePageDevice::ModeSelect(scsi_command, cdb_t, span<const uint8_t>, int)
|
void ModePageDevice::ModeSelect(scsi_command, cdb_t, span<const uint8_t>, int) const
|
||||||
{
|
{
|
||||||
// There is no default implementation of MODE SELECT
|
// There is no default implementation of MODE SELECT
|
||||||
throw scsi_exception(sense_key::illegal_request, asc::invalid_command_operation_code);
|
throw scsi_exception(sense_key::illegal_request, asc::invalid_command_operation_code);
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
|
|
||||||
bool Init(const param_map&) override;
|
bool Init(const param_map&) override;
|
||||||
|
|
||||||
virtual void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int);
|
virtual void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -165,29 +165,6 @@ vector<uint8_t> SCSICD::InquiryInternal() const
|
||||||
return HandleInquiry(device_type::cd_rom, scsi_level, true);
|
return HandleInquiry(device_type::cd_rom, scsi_level, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCSICD::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uint8_t> buf, int length)
|
|
||||||
{
|
|
||||||
int sector_size = 1 << GetSectorSizeShiftCount();
|
|
||||||
int wanted_sector_size;
|
|
||||||
// skip Block Descriptor
|
|
||||||
int offset = 4;
|
|
||||||
// evaluate Mode Parameter Block Descriptor, sector size
|
|
||||||
wanted_sector_size = scsi_command_util::GetInt16(buf, offset + 6);
|
|
||||||
if (wanted_sector_size != sector_size) {
|
|
||||||
LogDebug("Changing sector size from " + to_string(sector_size) + " to " + to_string(wanted_sector_size));
|
|
||||||
SetSectorSizeInBytes(wanted_sector_size);
|
|
||||||
ClearTrack();
|
|
||||||
CreateDataTrack();
|
|
||||||
FlushCache();
|
|
||||||
ResizeCache(GetFilename(), GetRawMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (const string result = scsi_command_util::ModeSelect(cmd, cdb, buf, length, sector_size);
|
|
||||||
!result.empty()) {
|
|
||||||
LogWarn(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SCSICD::SetUpModePages(map<int, vector<byte>>& pages, int page, bool changeable) const
|
void SCSICD::SetUpModePages(map<int, vector<byte>>& pages, int page, bool changeable) const
|
||||||
{
|
{
|
||||||
Disk::SetUpModePages(pages, page, changeable);
|
Disk::SetUpModePages(pages, page, changeable);
|
||||||
|
|
|
@ -34,7 +34,6 @@ public:
|
||||||
|
|
||||||
vector<uint8_t> InquiryInternal() const override;
|
vector<uint8_t> InquiryInternal() const override;
|
||||||
int Read(span<uint8_t>, uint64_t) override;
|
int Read(span<uint8_t>, uint64_t) override;
|
||||||
void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ vector<uint8_t> SCSIHD::InquiryInternal() const
|
||||||
return HandleInquiry(device_type::direct_access, scsi_level, IsRemovable());
|
return HandleInquiry(device_type::direct_access, scsi_level, IsRemovable());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCSIHD::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uint8_t> buf, int length)
|
void SCSIHD::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uint8_t> buf, int length) const
|
||||||
{
|
{
|
||||||
if (const string result = scsi_command_util::ModeSelect(cmd, cdb, buf, length, 1 << GetSectorSizeShiftCount());
|
if (const string result = scsi_command_util::ModeSelect(cmd, cdb, buf, length, 1 << GetSectorSizeShiftCount());
|
||||||
!result.empty()) {
|
!result.empty()) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
vector<uint8_t> InquiryInternal() const override;
|
vector<uint8_t> InquiryInternal() const override;
|
||||||
void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int) override;
|
void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int) const override;
|
||||||
|
|
||||||
void AddFormatPage(map<int, vector<byte>>&, bool) const override;
|
void AddFormatPage(map<int, vector<byte>>&, bool) const override;
|
||||||
void AddVendorPage(map<int, vector<byte>>&, int, bool) const override;
|
void AddVendorPage(map<int, vector<byte>>&, int, bool) const override;
|
||||||
|
|
|
@ -88,7 +88,7 @@ void SCSIMO::AddOptionPage(map<int, vector<byte>>& pages, bool) const
|
||||||
// Do not report update blocks
|
// Do not report update blocks
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCSIMO::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uint8_t> buf, int length)
|
void SCSIMO::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uint8_t> buf, int length) const
|
||||||
{
|
{
|
||||||
if (const string result = scsi_command_util::ModeSelect(cmd, cdb, buf, length, 1 << GetSectorSizeShiftCount());
|
if (const string result = scsi_command_util::ModeSelect(cmd, cdb, buf, length, 1 << GetSectorSizeShiftCount());
|
||||||
!result.empty()) {
|
!result.empty()) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
void Open() override;
|
void Open() override;
|
||||||
|
|
||||||
vector<uint8_t> InquiryInternal() const override;
|
vector<uint8_t> InquiryInternal() const override;
|
||||||
void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int) override;
|
void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,6 @@ class MockSCSICD : public SCSICD //NOSONAR Ignore inheritance hierarchy depth in
|
||||||
FRIEND_TEST(ScsiCdTest, GetSectorSizes);
|
FRIEND_TEST(ScsiCdTest, GetSectorSizes);
|
||||||
FRIEND_TEST(ScsiCdTest, SetUpModePages);
|
FRIEND_TEST(ScsiCdTest, SetUpModePages);
|
||||||
FRIEND_TEST(ScsiCdTest, ReadToc);
|
FRIEND_TEST(ScsiCdTest, ReadToc);
|
||||||
FRIEND_TEST(ScsiCdTest, ModeSelect);
|
|
||||||
|
|
||||||
using SCSICD::SCSICD;
|
using SCSICD::SCSICD;
|
||||||
};
|
};
|
||||||
|
|
|
@ -133,26 +133,3 @@ TEST(ScsiCdTest, ReadToc)
|
||||||
|
|
||||||
// Further testing requires filesystem access
|
// Further testing requires filesystem access
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ScsiCdTest, ModeSelect)
|
|
||||||
{
|
|
||||||
MockSCSICD cd(0);
|
|
||||||
vector<int> cmd(6);
|
|
||||||
vector<uint8_t> buf(255);
|
|
||||||
|
|
||||||
cd.SetSectorSizeInBytes(2048);
|
|
||||||
|
|
||||||
// PF
|
|
||||||
cmd[1] = 0x10;
|
|
||||||
// Length
|
|
||||||
buf[3] = 0x08;
|
|
||||||
// 2048 bytes per sector
|
|
||||||
buf[10] = 0x08;
|
|
||||||
// Page 3 (Device Format Page)
|
|
||||||
buf[12] = 0x01;
|
|
||||||
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6) with sector size 2048 is supported";
|
|
||||||
|
|
||||||
// 512 bytes per sector
|
|
||||||
buf[10] = 0x02;
|
|
||||||
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6) with sector size 512 is supported";
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue