2018-05-03 13:47:57 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// X68000 EMULATOR "XM6"
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2001-2006 PI.(ytanaka@ipc-tokai.or.jp)
|
2020-07-04 14:57:44 +00:00
|
|
|
|
// Copyright (C) 2014-2020 GIMONS
|
2018-05-03 13:47:57 +00:00
|
|
|
|
//
|
2020-07-05 16:47:17 +00:00
|
|
|
|
// [ SCSI Common Functionality ]
|
2018-05-03 13:47:57 +00:00
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
#include "os.h"
|
|
|
|
|
#include "xm6.h"
|
|
|
|
|
#include "scsi.h"
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
2020-07-05 16:47:17 +00:00
|
|
|
|
// Phase Acquisition
|
2018-05-03 13:47:57 +00:00
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
2021-07-26 18:33:36 +00:00
|
|
|
|
BUS::phase_t BUS::GetPhase()
|
2018-05-03 13:47:57 +00:00
|
|
|
|
{
|
2020-07-05 16:47:17 +00:00
|
|
|
|
// Selection Phase
|
2018-05-03 13:47:57 +00:00
|
|
|
|
if (GetSEL()) {
|
|
|
|
|
return selection;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-05 16:47:17 +00:00
|
|
|
|
// Bus busy phase
|
2018-05-03 13:47:57 +00:00
|
|
|
|
if (!GetBSY()) {
|
|
|
|
|
return busfree;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-05 16:47:17 +00:00
|
|
|
|
// Get target phase from bus signal line
|
2021-07-07 21:46:45 +00:00
|
|
|
|
DWORD mci = GetMSG() ? 0x04 : 0x00;
|
2018-05-03 13:47:57 +00:00
|
|
|
|
mci |= GetCD() ? 0x02 : 0x00;
|
|
|
|
|
mci |= GetIO() ? 0x01 : 0x00;
|
|
|
|
|
return GetPhase(mci);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-19 12:31:06 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Determine Phase String phase enum
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
2021-07-26 18:33:36 +00:00
|
|
|
|
const char* BUS::GetPhaseStrRaw(phase_t current_phase){
|
2020-10-19 12:31:06 +00:00
|
|
|
|
if(current_phase <= phase_t::reserved){
|
|
|
|
|
return phase_str_table[current_phase];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "INVALID";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-03 13:47:57 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
2020-07-05 16:47:17 +00:00
|
|
|
|
// Phase Table
|
2020-10-19 12:31:06 +00:00
|
|
|
|
// Reference Table 8: https://www.staff.uni-mainz.de/tacke/scsi/SCSI2-06.html
|
|
|
|
|
// This determines the phase based upon the Msg, C/D and I/O signals.
|
2018-05-03 13:47:57 +00:00
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
const BUS::phase_t BUS::phase_table[8] = {
|
2020-10-19 12:31:06 +00:00
|
|
|
|
// | MSG|C/D|I/O |
|
|
|
|
|
dataout, // | 0 | 0 | 0 |
|
|
|
|
|
datain, // | 0 | 0 | 1 |
|
|
|
|
|
command, // | 0 | 1 | 0 |
|
|
|
|
|
status, // | 0 | 1 | 1 |
|
|
|
|
|
reserved, // | 1 | 0 | 0 |
|
|
|
|
|
reserved, // | 1 | 0 | 1 |
|
|
|
|
|
msgout, // | 1 | 1 | 0 |
|
|
|
|
|
msgin // | 1 | 1 | 1 |
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Phase Table
|
|
|
|
|
// This MUST be kept in sync with the phase_t enum type!
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
const char* BUS::phase_str_table[] = {
|
|
|
|
|
"busfree",
|
|
|
|
|
"arbitration",
|
|
|
|
|
"selection",
|
|
|
|
|
"reselection",
|
|
|
|
|
"command",
|
|
|
|
|
"execute",
|
|
|
|
|
"datain",
|
|
|
|
|
"dataout",
|
|
|
|
|
"status",
|
|
|
|
|
"msgin",
|
|
|
|
|
"msgout",
|
|
|
|
|
"reserved"
|
2018-05-03 13:47:57 +00:00
|
|
|
|
};
|