Added command byte count to SCSI command mapping (#966)

* Extended mapping table with command byte count

* Terminate early if command is unknown
This commit is contained in:
Uwe Seimet
2022-11-06 19:44:44 +01:00
committed by GitHub
parent c98c52ffb8
commit 1cae530d42
10 changed files with 121 additions and 101 deletions
+4 -10
View File
@@ -11,24 +11,18 @@
#include "bus.h"
using namespace std;
using namespace scsi_defs;
//---------------------------------------------------------------------------
//
// Get the number of bytes for a command
// TODO Add the byte count to the enum value/command name mapping and remove the comparisons
//
//---------------------------------------------------------------------------
int BUS::GetCommandByteCount(uint8_t opcode)
{
if (opcode == 0x88 || opcode == 0x8A || opcode == 0x8F || opcode == 0x91 || opcode == 0x9E || opcode == 0x9F) {
return 16;
} else if (opcode == 0xA0) {
return 12;
} else if (opcode >= 0x20 && opcode <= 0x7D) {
return 10;
} else {
return 6;
}
const auto& mapping = command_mapping.find(static_cast<scsi_command>(opcode));
return mapping != command_mapping.end() ? mapping->second.first : 0;
}
//---------------------------------------------------------------------------