From 408e155a63c3a3b6423a5116f6bffcb9f692df00 Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Tue, 19 Apr 2022 20:42:39 -0500 Subject: [PATCH] Implement Test Unit Ready command --- src/BlueSCSI.cpp | 17 ++++++++++++++++- src/scsi_sense.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/BlueSCSI.cpp b/src/BlueSCSI.cpp index a6f60bb..e36c81c 100644 --- a/src/BlueSCSI.cpp +++ b/src/BlueSCSI.cpp @@ -1351,7 +1351,21 @@ byte onModeSelectCommand(byte scsi_cmd, byte flags, uint32_t len) LOGN(""); return SCSI_STATUS_GOOD; } - + +/* + * Test Unit Ready command processing. +*/ +byte onTestUnitReady() +{ + // Check that image file is present + if(!m_img) { + m_senseKey = SCSI_SENSE_NOT_READY; + m_addition_sense = SCSI_ASC_MEDIUM_NOT_PRESENT; + return SCSI_STATUS_CHECK_CONDITION; + } + return SCSI_STATUS_GOOD; +} + /* * MsgIn2. */ @@ -1516,6 +1530,7 @@ void loop() switch(cmd[0]) { case SCSI_TEST_UNIT_READY: // TODO: Implement me! LOGN("[Test Unit Ready]"); + m_sts |= onTestUnitReady(); break; case SCSI_REZERO_UNIT: // TODO: Implement me! LOGN("[Rezero Unit]"); diff --git a/src/scsi_sense.h b/src/scsi_sense.h index 1664f5d..15895a8 100644 --- a/src/scsi_sense.h +++ b/src/scsi_sense.h @@ -27,5 +27,6 @@ #define SCSI_ASC_WRITE_PROTECTED 0x2700 #define SCSI_ASC_CANNOT_READ_MEDIUM_UNKNOWN_FORMAT 0x3001 #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 #endif \ No newline at end of file