mirror of
https://github.com/akuker/RASCSI.git
synced 2024-09-27 15:57:52 +00:00
119dd55ef0
* Removed static/global variable * No need for ControllerManager as a singleton * Updated factory handling * Replaced loops * Added const * Added translations, fixed TODO, simplified operation creation * Fixed SonarCloud warnings * Replaced void * by BYTE * * Added explicit mode_page_datetime struct * Unit test updates * Use enum classes * Upddated file size check * Use C++ output formatting * Removed unused code * Use array for garbage buffer * Fixed data returned by READ CAPACITY(10) * For mode pages: Replaced BYTE by std::byte * Use std::byte for INQUIRY * Use std::byte for REQUEST SENSE * Replaced C array by vector * Replaced C style array * Replaced BYTE by std::byte * Replaced DWORD * Use more byte arreys * Updated CTapDriver initialization/deletion * Made status uint32_t instead of DWORD * Replaced command byte array by vector * Updated error handling * Removed obsolete casts * Improved locality of code * rw_command has become obsolete * Dynamically allocate command byte buffer * Simplified receiving commands * Use references * Type safety update, dispatcher update * Removed macros, replaced BOOL/FALSE/TRUE
94 lines
2.4 KiB
C++
94 lines
2.4 KiB
C++
//---------------------------------------------------------------------------
|
||
//
|
||
// X68000 EMULATOR "XM6"
|
||
//
|
||
// Copyright (C) 2001-2006 PI.(ytanaka@ipc-tokai.or.jp)
|
||
// Copyright (C) 2014-2020 GIMONS
|
||
//
|
||
// [ SCSI Common Functionality ]
|
||
//
|
||
//---------------------------------------------------------------------------
|
||
|
||
#include "scsi.h"
|
||
|
||
using namespace std;
|
||
|
||
//---------------------------------------------------------------------------
|
||
//
|
||
// Phase Acquisition
|
||
//
|
||
//---------------------------------------------------------------------------
|
||
BUS::phase_t BUS::GetPhase()
|
||
{
|
||
// Selection Phase
|
||
if (GetSEL()) {
|
||
return phase_t::selection;
|
||
}
|
||
|
||
// Bus busy phase
|
||
if (!GetBSY()) {
|
||
return phase_t::busfree;
|
||
}
|
||
|
||
// Get target phase from bus signal line
|
||
DWORD mci = GetMSG() ? 0x04 : 0x00;
|
||
mci |= GetCD() ? 0x02 : 0x00;
|
||
mci |= GetIO() ? 0x01 : 0x00;
|
||
return GetPhase(mci);
|
||
}
|
||
|
||
//---------------------------------------------------------------------------
|
||
//
|
||
// Determine Phase String phase enum
|
||
//
|
||
//---------------------------------------------------------------------------
|
||
const char* BUS::GetPhaseStrRaw(phase_t current_phase){
|
||
if(current_phase <= phase_t::reserved) {
|
||
return phase_str_table[(int)current_phase];
|
||
}
|
||
else {
|
||
return "INVALID";
|
||
}
|
||
}
|
||
|
||
//---------------------------------------------------------------------------
|
||
//
|
||
// Phase Table
|
||
// 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.
|
||
//
|
||
//---------------------------------------------------------------------------
|
||
const array<BUS::phase_t, 8> BUS::phase_table = {
|
||
// | MSG|C/D|I/O |
|
||
phase_t::dataout, // | 0 | 0 | 0 |
|
||
phase_t::datain, // | 0 | 0 | 1 |
|
||
phase_t::command, // | 0 | 1 | 0 |
|
||
phase_t::status, // | 0 | 1 | 1 |
|
||
phase_t::reserved, // | 1 | 0 | 0 |
|
||
phase_t::reserved, // | 1 | 0 | 1 |
|
||
phase_t::msgout, // | 1 | 1 | 0 |
|
||
phase_t::msgin // | 1 | 1 | 1 |
|
||
};
|
||
|
||
|
||
//---------------------------------------------------------------------------
|
||
//
|
||
// Phase Table
|
||
// This MUST be kept in sync with the phase_t enum type!
|
||
//
|
||
//---------------------------------------------------------------------------
|
||
const array<const char*, 12> BUS::phase_str_table = {
|
||
"busfree",
|
||
"arbitration",
|
||
"selection",
|
||
"reselection",
|
||
"command",
|
||
"execute",
|
||
"datain",
|
||
"dataout",
|
||
"status",
|
||
"msgin",
|
||
"msgout",
|
||
"reserved"
|
||
};
|