|
|
@@ -12,6 +12,7 @@ extern "C" {
|
|
|
static bool g_LogData = false;
|
|
|
static int g_InByteCount = 0;
|
|
|
static int g_OutByteCount = 0;
|
|
|
+static uint16_t g_DataChecksum = 0;
|
|
|
|
|
|
static const char *getCommandName(uint8_t cmd)
|
|
|
{
|
|
|
@@ -150,10 +151,10 @@ void scsiLogPhaseChange(int new_phase)
|
|
|
{
|
|
|
if (old_phase == DATA_IN || old_phase == DATA_OUT)
|
|
|
{
|
|
|
- azdbg("---- Total IN: ", g_InByteCount, " OUT: ", g_OutByteCount);
|
|
|
+ azdbg("---- Total IN: ", g_InByteCount, " OUT: ", g_OutByteCount, " CHECKSUM: ", (int)g_DataChecksum);
|
|
|
}
|
|
|
g_InByteCount = g_OutByteCount = 0;
|
|
|
-
|
|
|
+ g_DataChecksum = 0;
|
|
|
|
|
|
if (old_phase >= 0 &&
|
|
|
old_scsi_id == scsiDev.target->targetId &&
|
|
|
@@ -182,6 +183,16 @@ void scsiLogDataIn(const uint8_t *buf, uint32_t length)
|
|
|
azdbg("------ IN: ", bytearray(buf, length));
|
|
|
}
|
|
|
|
|
|
+ if (g_azlog_debug)
|
|
|
+ {
|
|
|
+ // BSD checksum algorithm
|
|
|
+ for (uint32_t i = 0; i < length; i++)
|
|
|
+ {
|
|
|
+ g_DataChecksum = (g_DataChecksum >> 1) + ((g_DataChecksum & 1) << 15);
|
|
|
+ g_DataChecksum += buf[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
g_InByteCount += length;
|
|
|
}
|
|
|
|
|
|
@@ -197,5 +208,15 @@ void scsiLogDataOut(const uint8_t *buf, uint32_t length)
|
|
|
azdbg("------ OUT: ", bytearray(buf, length));
|
|
|
}
|
|
|
|
|
|
+ if (g_azlog_debug)
|
|
|
+ {
|
|
|
+ // BSD checksum algorithm
|
|
|
+ for (uint32_t i = 0; i < length; i++)
|
|
|
+ {
|
|
|
+ g_DataChecksum = (g_DataChecksum >> 1) + ((g_DataChecksum & 1) << 15);
|
|
|
+ g_DataChecksum += buf[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
g_OutByteCount += length;
|
|
|
}
|