From e0cb5d4d0de752f2bf08ad3070e93a522d068949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= Date: Tue, 26 Dec 2023 16:54:24 +0100 Subject: [PATCH] Implement ModeSelect for scsicd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and honor sector size setting. DEC's VMS can't handle 2k sector sizes and uses ModeSelect6 to set the sector size to 512 bytes. Fixes #1397 Signed-off-by: Klaus Kämpf --- cpp/devices/scsicd.cpp | 19 +++++++++++++++++++ cpp/devices/scsicd.h | 1 + 2 files changed, 20 insertions(+) diff --git a/cpp/devices/scsicd.cpp b/cpp/devices/scsicd.cpp index 27ab23a3..a354a6fe 100644 --- a/cpp/devices/scsicd.cpp +++ b/cpp/devices/scsicd.cpp @@ -165,6 +165,25 @@ vector SCSICD::InquiryInternal() const return HandleInquiry(device_type::cd_rom, scsi_level, true); } +void SCSICD::ModeSelect(scsi_command cmd, cdb_t cdb, span 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); + } + + if (const string result = scsi_command_util::ModeSelect(cmd, cdb, buf, length, sector_size); + !result.empty()) { + LogWarn(result); + } +} + void SCSICD::SetUpModePages(map>& pages, int page, bool changeable) const { Disk::SetUpModePages(pages, page, changeable); diff --git a/cpp/devices/scsicd.h b/cpp/devices/scsicd.h index c2aaf4e3..cb1158dd 100644 --- a/cpp/devices/scsicd.h +++ b/cpp/devices/scsicd.h @@ -34,6 +34,7 @@ public: vector InquiryInternal() const override; int Read(span, uint64_t) override; + void ModeSelect(scsi_defs::scsi_command, cdb_t, span, int) override; protected: