Prechádzať zdrojové kódy

Add log message about synchronous SCSI speed changes (#51)

Petteri Aimonen 3 rokov pred
rodič
commit
409790c7c5
1 zmenil súbory, kde vykonal 18 pridanie a 0 odobranie
  1. 18 0
      src/ZuluSCSI_log_trace.cpp

+ 18 - 0
src/ZuluSCSI_log_trace.cpp

@@ -142,7 +142,9 @@ static void printNewPhase(int phase)
 
 void scsiLogPhaseChange(int new_phase)
 {
+    static int old_scsi_id = 0;
     static int old_phase = BUS_FREE;
+    static int old_sync_period = 0;
 
     if (new_phase != old_phase)
     {
@@ -152,8 +154,24 @@ void scsiLogPhaseChange(int new_phase)
         }
         g_InByteCount = g_OutByteCount = 0;
 
+
+        if (old_phase >= 0 &&
+            old_scsi_id == scsiDev.target->targetId &&
+            old_sync_period != scsiDev.target->syncPeriod)
+        {
+            // Add a log message when negotiated synchronous speed changes.
+            int syncper = scsiDev.target->syncPeriod;
+            int syncoff = scsiDev.target->syncOffset;
+            int mbyte_per_s = (1000 + syncper * 2) / (syncper * 4);
+            azlog("SCSI ID ", (int)scsiDev.target->targetId,
+                  " negotiated synchronous mode ", mbyte_per_s, " MB/s ",
+                  "(period 4x", syncper, " ns, offset ", syncoff, " bytes)");
+        }
+
         printNewPhase(new_phase);
         old_phase = new_phase;
+        old_sync_period = scsiDev.target->syncPeriod;
+        old_scsi_id = scsiDev.target->targetId;
     }
 }