浏览代码

RP2040: Fix SCSI2 mode not getting enabled due to ATN handling

This caused 1 ms of extra latency on requests.
Petteri Aimonen 3 年之前
父节点
当前提交
18f10b1538
共有 1 个文件被更改,包括 10 次插入3 次删除
  1. 10 3
      lib/ZuluSCSI_platform_RP2040/scsiPhy.cpp

+ 10 - 3
lib/ZuluSCSI_platform_RP2040/scsiPhy.cpp

@@ -56,8 +56,9 @@ void scsi_bsy_deassert_interrupt()
 
         if (sel_id >= 0)
         {
-            uint8_t atn_flag = SCSI_IN(ATN) ? SCSI_STS_SELECTION_ATN : 0;
-            g_scsi_sts_selection = SCSI_STS_SELECTION_SUCCEEDED | atn_flag | sel_id;
+            // Set ATN flag here unconditionally, real value is only known after
+            // OUT_BSY is enabled in scsiStatusSEL() below.
+            g_scsi_sts_selection = SCSI_STS_SELECTION_SUCCEEDED | SCSI_STS_SELECTION_ATN | sel_id;
         }
 
         // selFlag is required for Philips P2000C which releases it after 600ns
@@ -80,7 +81,13 @@ extern "C" bool scsiStatusSEL()
         // On RP2040 hardware the ATN signal is only available after OUT_BSY enables
         // the IO buffer U105, so check the signal status here.
         delay_100ns();
-        scsiDev.atnFlag |= scsiStatusATN();
+        if (!scsiStatusATN())
+        {
+            // This is a SCSI1 host that does send IDENTIFY message
+            scsiDev.atnFlag = 0;
+            scsiDev.target->unitAttention = 0;
+            scsiDev.compatMode = COMPAT_SCSI1;
+        }
     }
 
     return SCSI_IN(SEL);