mirror of
https://github.com/thewesker/RASCSI.git
synced 2025-12-21 12:51:13 -05:00
#27 Added skeleton code for Arbitration and Reselection phases
This commit is contained in:
@@ -80,11 +80,9 @@ BUS::phase_t FASTCALL SCSIDEV::Process()
|
|||||||
// Get bus information
|
// Get bus information
|
||||||
ctrl.bus->Aquire();
|
ctrl.bus->Aquire();
|
||||||
|
|
||||||
// Reset
|
// Check to see if the reset signal was asserted
|
||||||
if (ctrl.bus->GetRST()) {
|
if (ctrl.bus->GetRST()) {
|
||||||
#if defined(DISK_LOG)
|
LOGWARN("RESET signal received!");
|
||||||
Log(Log::Normal, "RESET信号受信");
|
|
||||||
#endif // DISK_LOG
|
|
||||||
|
|
||||||
// Reset the controller
|
// Reset the controller
|
||||||
Reset();
|
Reset();
|
||||||
@@ -192,6 +190,53 @@ void FASTCALL SCSIDEV::BusFree()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Arbitration Phase
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
void FASTCALL SCSIDEV::Arbitration()
|
||||||
|
{
|
||||||
|
|
||||||
|
// TODO: See https://www.staff.uni-mainz.de/tacke/scsi/SCSI2-06.html
|
||||||
|
// DWORD id;
|
||||||
|
|
||||||
|
ASSERT(this);
|
||||||
|
|
||||||
|
// // Phase change
|
||||||
|
// if (ctrl.phase != BUS::reselection) {
|
||||||
|
// // invalid if IDs do not match
|
||||||
|
// id = 1 << ctrl.id;
|
||||||
|
// if ((ctrl.bus->GetDAT() & id) == 0) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // End if there is no valid unit
|
||||||
|
// if (!HasUnit()) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// LOGDEBUG("Reselection phase ID=%d (with device)", ctrl.id);
|
||||||
|
|
||||||
|
// // Phase setting
|
||||||
|
// ctrl.phase = BUS::selection;
|
||||||
|
|
||||||
|
// // Raise BSY and respond
|
||||||
|
// ctrl.bus->SetBSY(TRUE);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Reselection completed
|
||||||
|
// if (!ctrl.bus->GetSEL() && ctrl.bus->GetBSY()) {
|
||||||
|
// // Message out phase if ATN=1, otherwise command phase
|
||||||
|
// if (ctrl.bus->GetATN()) {
|
||||||
|
// MsgOut();
|
||||||
|
// } else {
|
||||||
|
// Command();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Selection Phase
|
// Selection Phase
|
||||||
@@ -240,6 +285,53 @@ void FASTCALL SCSIDEV::Selection()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Reselection Phase
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
void FASTCALL SCSIDEV::Reselection()
|
||||||
|
{
|
||||||
|
// DWORD id;
|
||||||
|
|
||||||
|
ASSERT(this);
|
||||||
|
|
||||||
|
// // Phase change
|
||||||
|
// if (ctrl.phase != BUS::reselection) {
|
||||||
|
// // invalid if IDs do not match
|
||||||
|
// id = 1 << ctrl.id;
|
||||||
|
// if ((ctrl.bus->GetDAT() & id) == 0) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // End if there is no valid unit
|
||||||
|
// if (!HasUnit()) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// LOGDEBUG("Reselection phase ID=%d (with device)", ctrl.id);
|
||||||
|
|
||||||
|
// // Phase setting
|
||||||
|
// ctrl.phase = BUS::selection;
|
||||||
|
|
||||||
|
// // Raise BSY and respond
|
||||||
|
// ctrl.bus->SetBSY(TRUE);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Reselection completed
|
||||||
|
// if (!ctrl.bus->GetSEL() && ctrl.bus->GetBSY()) {
|
||||||
|
// // Message out phase if ATN=1, otherwise command phase
|
||||||
|
// if (ctrl.bus->GetATN()) {
|
||||||
|
// MsgOut();
|
||||||
|
// } else {
|
||||||
|
// Command();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Execution Phase
|
// Execution Phase
|
||||||
@@ -2090,25 +2182,56 @@ BOOL FASTCALL SCSIDEV::XferMsg(DWORD msg)
|
|||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
BOOL FASTCALL SCSIDEV::TransferPacketToHost(int packet_len){
|
BOOL FASTCALL SCSIDEV::TransferPacketToHost(int packet_len){
|
||||||
|
//*****************************
|
||||||
|
// BUS FREE PHASE
|
||||||
|
//*****************************
|
||||||
|
// We should already be in bus free phase when we enter this function
|
||||||
|
|
||||||
|
//*****************************
|
||||||
|
// ARBITRATION PHASE
|
||||||
|
//*****************************
|
||||||
// Aquire the bus
|
// Aquire the bus
|
||||||
|
// ctrl.bus->Aquire();
|
||||||
|
// ctrl.bus->SetIO();
|
||||||
|
|
||||||
|
// if (bus->GetBUSY()) {
|
||||||
|
// #if !defined(BAREMETAL)
|
||||||
|
// usleep(0);
|
||||||
|
// #endif // !BAREMETAL
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// #endif // USE_SEL_EVENT_ENABLE
|
||||||
|
//*****************************
|
||||||
// Reselection
|
// Reselection
|
||||||
|
//*****************************
|
||||||
|
|
||||||
|
//*****************************
|
||||||
// Message OUT (expect a "NO OPERATION")
|
// Message OUT (expect a "NO OPERATION")
|
||||||
// IF we get a DISCONNECT message, abort sending the message
|
// IF we get a DISCONNECT message, abort sending the message
|
||||||
// Transition to MESSAGE IN and send a DISCONNECT
|
// Transition to MESSAGE IN and send a DISCONNECT
|
||||||
// then go to BUS FREE
|
// then go to BUS FREE
|
||||||
|
//*****************************
|
||||||
|
|
||||||
|
//*****************************
|
||||||
// DATA IN
|
// DATA IN
|
||||||
// ... send the packet
|
// ... send the packet
|
||||||
|
//*****************************
|
||||||
|
|
||||||
|
//*****************************
|
||||||
// MESSAGE OUT (expect a "NO OPERATION")
|
// MESSAGE OUT (expect a "NO OPERATION")
|
||||||
|
//*****************************
|
||||||
|
|
||||||
|
//*****************************
|
||||||
// If more packets, go back to DATA IN
|
// If more packets, go back to DATA IN
|
||||||
|
//*****************************
|
||||||
|
|
||||||
|
//*****************************
|
||||||
// Else
|
// Else
|
||||||
// MESSAGE IN (sends DISCONNECT)
|
// MESSAGE IN (sends DISCONNECT)
|
||||||
|
//*****************************
|
||||||
|
|
||||||
|
//*****************************
|
||||||
// BUS FREE
|
// BUS FREE
|
||||||
|
//*****************************
|
||||||
|
BusFree();
|
||||||
}
|
}
|
||||||
@@ -108,8 +108,12 @@ private:
|
|||||||
// Phase
|
// Phase
|
||||||
void FASTCALL BusFree();
|
void FASTCALL BusFree();
|
||||||
// Bus free phase
|
// Bus free phase
|
||||||
|
void FASTCALL Arbitration();
|
||||||
|
// Arbitration phase
|
||||||
void FASTCALL Selection();
|
void FASTCALL Selection();
|
||||||
// Selection phase
|
// Selection phase
|
||||||
|
void FASTCALL Reselection();
|
||||||
|
// Reselection phase
|
||||||
void FASTCALL Execute();
|
void FASTCALL Execute();
|
||||||
// Execution phase
|
// Execution phase
|
||||||
void FASTCALL MsgOut();
|
void FASTCALL MsgOut();
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ int FASTCALL SCSINuvolink::ReceivePacket()
|
|||||||
if (memcmp(packet_buf, mac_addr, 6) != 0) {
|
if (memcmp(packet_buf, mac_addr, 6) != 0) {
|
||||||
if (memcmp(packet_buf, bcast_addr, 6) != 0) {
|
if (memcmp(packet_buf, bcast_addr, 6) != 0) {
|
||||||
packet_len = 0;
|
packet_len = 0;
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,7 +493,7 @@ int FASTCALL SCSINuvolink::ReceivePacket()
|
|||||||
if (packet_len > 2048) {
|
if (packet_len > 2048) {
|
||||||
LOGDEBUG("Packet size was too big. Dropping it");
|
LOGDEBUG("Packet size was too big. Dropping it");
|
||||||
packet_len = 0;
|
packet_len = 0;
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransferPacket(packet_len, packet_buff);
|
// TransferPacket(packet_len, packet_buff);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// 変数宣言
|
// Variable Declaration
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
GPIOBUS bus; // Bus
|
GPIOBUS bus; // Bus
|
||||||
|
|||||||
Reference in New Issue
Block a user