From 61ae8a59dbffdae9b0fde37bd47b3a9c2c24e067 Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Sat, 21 May 2022 15:51:07 -0500 Subject: [PATCH] Add constants for SCSI mode page codes --- src/BlueSCSI.cpp | 36 ++++++++++++++++++------------------ src/scsi_sense.h | 13 +++++++++++++ 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/BlueSCSI.cpp b/src/BlueSCSI.cpp index 85b778e..9b919fa 100644 --- a/src/BlueSCSI.cpp +++ b/src/BlueSCSI.cpp @@ -1241,7 +1241,7 @@ byte onModeSenseCommand(byte scsi_cmd, byte dbd, byte cmd2, uint32_t len) int pageCode = cmd2 & 0x3F; int pageControl = cmd2 >> 6; int a = 4; - if(scsi_cmd == 0x5A) a = 8; + if(scsi_cmd == SCSI_MODE_SENSE10) a = 8; if(dbd == 0) { byte c[8] = { @@ -1254,21 +1254,21 @@ byte onModeSenseCommand(byte scsi_cmd, byte dbd, byte cmd2, uint32_t len) a += 8; } switch(pageCode) { - case 0x3F: - case 0x01: // Read/Write Error Recovery - m_buf[a + 0] = 0x01; + case SCSI_SENSE_MODE_ALL: + case SCSI_SENSE_MODE_READ_WRITE_ERROR_RECOVERY: + m_buf[a + 0] = SCSI_SENSE_MODE_READ_WRITE_ERROR_RECOVERY; m_buf[a + 1] = 0x0A; a += 0x0C; - if(pageCode != 0x3F) break; + if(pageCode != SCSI_SENSE_MODE_ALL) break; - case 0x02: // Disconnect-Reconnect page - m_buf[a + 0] = 0x02; + case SCSI_SENSE_MODE_DISCONNECT_RECONNECT: + m_buf[a + 0] = SCSI_SENSE_MODE_DISCONNECT_RECONNECT; m_buf[a + 1] = 0x0A; a += 0x0C; - if(pageCode != 0x3f) break; + if(pageCode != SCSI_SENSE_MODE_ALL) break; - case 0x03: //Drive parameters - m_buf[a + 0] = 0x03; //Page code + case SCSI_SENSE_MODE_FORMAT_DEVICE: //Drive parameters + m_buf[a + 0] = SCSI_SENSE_MODE_FORMAT_DEVICE; //Page code m_buf[a + 1] = 0x16; // Page length if(pageControl != 1) { m_buf[a + 11] = 0x3F;//Number of sectors / track @@ -1277,10 +1277,10 @@ byte onModeSenseCommand(byte scsi_cmd, byte dbd, byte cmd2, uint32_t len) m_buf[a + 15] = 0x1; // Interleave } a += 0x18; - if(pageCode != 0x3F) break; + if(pageCode != SCSI_SENSE_MODE_ALL) break; - case 0x04: //Drive parameters - m_buf[a + 0] = 0x04; //Page code + case SCSI_SENSE_MODE_DISK_GEOMETRY: //Drive parameters + m_buf[a + 0] = SCSI_SENSE_MODE_DISK_GEOMETRY; //Page code m_buf[a + 1] = 0x16; // Page length if(pageControl != 1) { unsigned cylinders = bc / (16 * 63); @@ -1290,19 +1290,19 @@ byte onModeSenseCommand(byte scsi_cmd, byte dbd, byte cmd2, uint32_t len) m_buf[a + 5] = 16; //Number of heads } a += 0x18; - if(pageCode != 0x3F) break; - case 0x30: + if(pageCode != SCSI_SENSE_MODE_ALL) break; + case SCSI_SENSE_MODE_VENDOR_APPLE: { const byte page30[0x14] = {0x41, 0x50, 0x50, 0x4C, 0x45, 0x20, 0x43, 0x4F, 0x4D, 0x50, 0x55, 0x54, 0x45, 0x52, 0x2C, 0x20, 0x49, 0x4E, 0x43, 0x20}; - m_buf[a + 0] = 0x30; // Page code + m_buf[a + 0] = SCSI_SENSE_MODE_VENDOR_APPLE; // Page code m_buf[a + 1] = sizeof(page30); // Page length if(pageControl != 1) { memcpy(&m_buf[a + 2], page30, sizeof(page30)); } a += 2 + sizeof(page30); - if(pageCode != 0x3F) break; + if(pageCode != SCSI_SENSE_MODE_ALL) break; } - break; // Don't want 0x3F falling through to error condition + break; // Don't want SCSI_SENSE_MODE_ALL falling through to error condition default: m_senseKey = SCSI_SENSE_ILLEGAL_REQUEST; diff --git a/src/scsi_sense.h b/src/scsi_sense.h index 15895a8..5a10218 100644 --- a/src/scsi_sense.h +++ b/src/scsi_sense.h @@ -29,4 +29,17 @@ #define SCSI_ASC_CANNOT_READ_MEDIUM_INCOMPATIBLE_FORMAT 0x3002 #define SCSI_ASC_MEDIUM_NOT_PRESENT 0x3A00 #define SCSI_ASC_LUN_NOT_READY_MANUAL_INTERVENTION_REQUIRED 0x0403 + + +// SCSI mode page codes +#define SCSI_SENSE_MODE_VENDOR 0x00 +#define SCSI_SENSE_MODE_READ_WRITE_ERROR_RECOVERY 0x01 +#define SCSI_SENSE_MODE_DISCONNECT_RECONNECT 0x02 +#define SCSI_SENSE_MODE_FORMAT_DEVICE 0x03 +#define SCSI_SENSE_MODE_DISK_GEOMETRY 0x04 +#define SCSI_SENSE_MODE_VENDOR_APPLE 0x30 + +#define SCSI_SENSE_MODE_ALL 0x3F + + #endif \ No newline at end of file