From 0677b9f9bf81892fae3e5ce9b1bf15f130040932 Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Mon, 30 Aug 2021 11:09:17 +0200 Subject: [PATCH] SASI Format opcode is 0x06, not 0x04 (see comment in code) --- src/raspberrypi/controllers/sasidev_ctrl.cpp | 4 +- src/raspberrypi/controllers/sasidev_ctrl.h | 4 +- src/raspberrypi/controllers/scsidev_ctrl.h | 4 +- src/raspberrypi/devices/disk.cpp | 45 +++----------------- 4 files changed, 11 insertions(+), 46 deletions(-) diff --git a/src/raspberrypi/controllers/sasidev_ctrl.cpp b/src/raspberrypi/controllers/sasidev_ctrl.cpp index 1f5b63fe..37997f64 100644 --- a/src/raspberrypi/controllers/sasidev_ctrl.cpp +++ b/src/raspberrypi/controllers/sasidev_ctrl.cpp @@ -1122,7 +1122,7 @@ bool SASIDEV::XferOut(bool cont) Disk *device = ctrl.unit[lun]; switch ((SASIDEV::sasi_command) ctrl.cmd[0]) { - case SASIDEV::eCmdModeSelect: + case SASIDEV::eCmdModeSelect6: case SASIDEV::eCmdModeSelect10: if (!device->ModeSelect(ctrl.cmd, ctrl.buffer, ctrl.offset)) { // MODE SELECT failed @@ -1228,7 +1228,7 @@ void SASIDEV::FlushUnit() case SASIDEV::eCmdVerify16: break; - case SASIDEV::eCmdModeSelect: + case SASIDEV::eCmdModeSelect6: case SASIDEV::eCmdModeSelect10: // Debug code related to Issue #2 on github, where we get an unhandled Mode Select when // the mac is rebooted diff --git a/src/raspberrypi/controllers/sasidev_ctrl.h b/src/raspberrypi/controllers/sasidev_ctrl.h index 25c847df..3792926e 100644 --- a/src/raspberrypi/controllers/sasidev_ctrl.h +++ b/src/raspberrypi/controllers/sasidev_ctrl.h @@ -60,13 +60,13 @@ private: eCmdTestUnitReady = 0x00, eCmdRezero = 0x01, eCmdRequestSense = 0x03, - eCmdFormat = 0x04, + eCmdFormat = 0x06, eCmdReassign = 0x07, eCmdRead6 = 0x08, eCmdWrite6 = 0x0A, eCmdSeek6 = 0x0B, eCmdSetMcastAddr = 0x0D, // DaynaPort specific command - eCmdModeSelect = 0x15, + eCmdModeSelect6 = 0x15, eCmdReserve6 = 0x16, eCmdRelease6 = 0x17, eCmdRead10 = 0x28, diff --git a/src/raspberrypi/controllers/scsidev_ctrl.h b/src/raspberrypi/controllers/scsidev_ctrl.h index 2847aabd..8ab40b1d 100644 --- a/src/raspberrypi/controllers/scsidev_ctrl.h +++ b/src/raspberrypi/controllers/scsidev_ctrl.h @@ -40,10 +40,10 @@ public: eCmdSetMcastAddr = 0x0D, // DaynaPort specific command eCmdEnableInterface = 0x0E, // DaynaPort specific command eCmdInquiry = 0x12, - eCmdModeSelect = 0x15, + eCmdModeSelect6 = 0x15, eCmdReserve6 = 0x16, eCmdRelease6 = 0x17, - eCmdModeSense = 0x1A, + eCmdModeSense6 = 0x1A, eCmdStartStop = 0x1B, eCmdSendDiag = 0x1D, eCmdRemoval = 0x1E, diff --git a/src/raspberrypi/devices/disk.cpp b/src/raspberrypi/devices/disk.cpp index f129b6c3..579d6716 100644 --- a/src/raspberrypi/devices/disk.cpp +++ b/src/raspberrypi/devices/disk.cpp @@ -54,10 +54,10 @@ Disk::Disk(const std::string id) : Device(id), ScsiPrimaryCommands(), ScsiBlockC AddCommand(SCSIDEV::eCmdWrite6, "Write6", &Disk::Write6); AddCommand(SCSIDEV::eCmdSeek6, "Seek6", &Disk::Seek6); AddCommand(SCSIDEV::eCmdInquiry, "Inquiry", &Disk::Inquiry); - AddCommand(SCSIDEV::eCmdModeSelect, "ModeSelect", &Disk::ModeSelect); + AddCommand(SCSIDEV::eCmdModeSelect6, "ModeSelect6", &Disk::ModeSelect); AddCommand(SCSIDEV::eCmdReserve6, "Reserve6", &Disk::Reserve6); AddCommand(SCSIDEV::eCmdRelease6, "Release6", &Disk::Release6); - AddCommand(SCSIDEV::eCmdModeSense, "ModeSense", &Disk::ModeSense); + AddCommand(SCSIDEV::eCmdModeSense6, "ModeSense6", &Disk::ModeSense); AddCommand(SCSIDEV::eCmdStartStop, "StartStopUnit", &Disk::StartStopUnit); AddCommand(SCSIDEV::eCmdSendDiag, "SendDiagnostic", &Disk::SendDiagnostic); AddCommand(SCSIDEV::eCmdRemoval, "PreventAllowMediumRemoval", &Disk::PreventAllowMediumRemoval); @@ -732,7 +732,6 @@ int Disk::ModeSense(const DWORD *cdb, BYTE *buf) { ASSERT(cdb); ASSERT(buf); - ASSERT(cdb[0] == 0x1a); // Get length, clear buffer int length = (int)cdb[4]; @@ -854,13 +853,11 @@ int Disk::ModeSense(const DWORD *cdb, BYTE *buf) // MODE SENSE(10) // //--------------------------------------------------------------------------- +// TODO Remove duplicate code, see MODE SENSE above int Disk::ModeSense10(const DWORD *cdb, BYTE *buf) { - int ret; - ASSERT(cdb); ASSERT(buf); - ASSERT(cdb[0] == 0x5a); // Get length, clear buffer int length = cdb[7]; @@ -957,7 +954,7 @@ int Disk::ModeSense10(const DWORD *cdb, BYTE *buf) } // Page (vendor special) - ret = AddVendor(page, change, &buf[size]); + int ret = AddVendor(page, change, &buf[size]); if (ret > 0) { size += ret; valid = true; @@ -988,11 +985,6 @@ int Disk::AddError(bool change, BYTE *buf) buf[0] = 0x01; buf[1] = 0x0a; - // No changeable area - if (change) { - return 12; - } - // Retry count is 0, limit time uses internal default value return 12; } @@ -1004,8 +996,6 @@ int Disk::AddError(bool change, BYTE *buf) //--------------------------------------------------------------------------- int Disk::AddFormat(bool change, BYTE *buf) { - int size; - ASSERT(buf); // Set the message length @@ -1029,7 +1019,7 @@ int Disk::AddFormat(bool change, BYTE *buf) buf[0xb] = 0x19; // Set the number of bytes in the physical sector - size = 1 << disk.size; + int size = 1 << disk.size; buf[0xc] = (BYTE)(size >> 8); buf[0xd] = (BYTE)size; } @@ -1090,11 +1080,6 @@ int Disk::AddOpt(bool change, BYTE *buf) buf[0] = 0x06; buf[1] = 0x02; - // No changeable area - if (change) { - return 4; - } - // Do not report update blocks return 4; } @@ -1112,11 +1097,6 @@ int Disk::AddCache(bool change, BYTE *buf) buf[0] = 0x08; buf[1] = 0x0a; - // No changeable area - if (change) { - return 12; - } - // Only read cache is valid, no prefetch return 12; } @@ -1162,11 +1142,6 @@ int Disk::AddCDDA(bool change, BYTE *buf) buf[0] = 0x0e; buf[1] = 0x0e; - // No changeable area - if (change) { - return 16; - } - // Audio waits for operation completion and allows // PLAY across multiple tracks return 16; @@ -1193,7 +1168,6 @@ int Disk::ReadDefectData10(const DWORD *cdb, BYTE *buf) { ASSERT(cdb); ASSERT(buf); - ASSERT(cdb[0] == 0x37); // Get length, clear buffer DWORD length = cdb[7]; @@ -1224,12 +1198,6 @@ int Disk::ReadDefectData10(const DWORD *cdb, BYTE *buf) return 4; } -//--------------------------------------------------------------------------- -// -// Command -// -//--------------------------------------------------------------------------- - //--------------------------------------------------------------------------- // // FORMAT UNIT @@ -1422,7 +1390,6 @@ bool Disk::Assign(const DWORD* /*cdb*/) bool Disk::StartStop(const DWORD *cdb) { ASSERT(cdb); - ASSERT(cdb[0] == 0x1b); // Look at the eject bit and eject if necessary if (cdb[4] & 0x02) { @@ -1447,7 +1414,6 @@ bool Disk::StartStop(const DWORD *cdb) bool Disk::SendDiag(const DWORD *cdb) { ASSERT(cdb); - ASSERT(cdb[0] == 0x1d); // Do not support PF bit if (cdb[1] & 0x10) { @@ -1472,7 +1438,6 @@ bool Disk::SendDiag(const DWORD *cdb) bool Disk::Removal(const DWORD *cdb) { ASSERT(cdb); - ASSERT(cdb[0] == 0x1e); // Status check if (!CheckReady()) {