From eabd041b9f33ce220819d5d882edb4a419f70ae2 Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Sat, 11 Sep 2021 19:26:54 +0200 Subject: [PATCH] Comment and logging updates --- src/raspberrypi/controllers/sasidev_ctrl.cpp | 18 +++++----- src/raspberrypi/controllers/sasidev_ctrl.h | 2 +- src/raspberrypi/controllers/scsidev_ctrl.cpp | 35 ++++++-------------- src/raspberrypi/rascsi.cpp | 2 +- 4 files changed, 21 insertions(+), 36 deletions(-) diff --git a/src/raspberrypi/controllers/sasidev_ctrl.cpp b/src/raspberrypi/controllers/sasidev_ctrl.cpp index 7d12db90..6fa38e67 100644 --- a/src/raspberrypi/controllers/sasidev_ctrl.cpp +++ b/src/raspberrypi/controllers/sasidev_ctrl.cpp @@ -123,18 +123,18 @@ void SASIDEV::SetUnit(int no, Disk *dev) //--------------------------------------------------------------------------- // -// Check to see if this has a valid logical unit +// Check to see if this has a valid LUN // //--------------------------------------------------------------------------- bool SASIDEV::HasUnit() { for (int i = 0; i < UnitMax; i++) { if (ctrl.unit[i]) { - return TRUE; + return true; } } - return FALSE; + return false; } //--------------------------------------------------------------------------- @@ -220,7 +220,7 @@ void SASIDEV::BusFree() { // Phase change if (ctrl.phase != BUS::busfree) { - LOGINFO("Bus free phase"); + LOGTRACE("%s Bus free phase", __PRETTY_FUNCTION__); // Phase Setting ctrl.phase = BUS::busfree; @@ -259,7 +259,7 @@ void SASIDEV::Selection() return; } - // Return if there is no unit + // Return if there is no valid LUN if (!HasUnit()) { return; } @@ -282,7 +282,7 @@ void SASIDEV::Selection() //--------------------------------------------------------------------------- // -// Command phase +// Command phase (used by SASI and SCSI) // //--------------------------------------------------------------------------- void SASIDEV::Command() @@ -485,7 +485,7 @@ void SASIDEV::Status() //--------------------------------------------------------------------------- // -// Message in phase +// Message in phase (used by SASI and SCSI) // //--------------------------------------------------------------------------- void SASIDEV::MsgIn() @@ -516,7 +516,7 @@ void SASIDEV::MsgIn() //--------------------------------------------------------------------------- // -// Data-in Phase +// Data-in Phase (used by SASI and SCSI) // //--------------------------------------------------------------------------- void SASIDEV::DataIn() @@ -564,7 +564,7 @@ void SASIDEV::DataIn() //--------------------------------------------------------------------------- // -// Data out phase +// Data out phase (used by SASI and SCSI) // //--------------------------------------------------------------------------- void SASIDEV::DataOut() diff --git a/src/raspberrypi/controllers/sasidev_ctrl.h b/src/raspberrypi/controllers/sasidev_ctrl.h index db3da15f..18083c23 100644 --- a/src/raspberrypi/controllers/sasidev_ctrl.h +++ b/src/raspberrypi/controllers/sasidev_ctrl.h @@ -101,7 +101,7 @@ public: typedef struct { // General BUS::phase_t phase; // Transition phase - int m_scsi_id; // Controller ID (0-7) + int m_scsi_id; // Controller ID (0-7) BUS *bus; // Bus // commands diff --git a/src/raspberrypi/controllers/scsidev_ctrl.cpp b/src/raspberrypi/controllers/scsidev_ctrl.cpp index 13cdef9d..c1808b36 100644 --- a/src/raspberrypi/controllers/scsidev_ctrl.cpp +++ b/src/raspberrypi/controllers/scsidev_ctrl.cpp @@ -95,7 +95,7 @@ BUS::phase_t SCSIDEV::Process() BusFree(); break; - // Selection phase + // Selection case BUS::selection: Selection(); break; @@ -139,12 +139,6 @@ BUS::phase_t SCSIDEV::Process() return ctrl.phase; } -//--------------------------------------------------------------------------- -// -// Phases -// -//--------------------------------------------------------------------------- - //--------------------------------------------------------------------------- // // Bus free phase @@ -154,12 +148,12 @@ void SCSIDEV::BusFree() { // Phase change if (ctrl.phase != BUS::busfree) { - LOGTRACE( "%s Bus free phase", __PRETTY_FUNCTION__); + LOGTRACE("%s Bus free phase", __PRETTY_FUNCTION__); // Phase setting ctrl.phase = BUS::busfree; - // Signal line + // Set Signal lines ctrl.bus->SetREQ(FALSE); ctrl.bus->SetMSG(FALSE); ctrl.bus->SetCD(FALSE); @@ -196,7 +190,7 @@ void SCSIDEV::Selection() return; } - // End if there is no valid unit + // Return if there is no valid LUN if (!HasUnit()) { return; } @@ -357,16 +351,9 @@ void SCSIDEV::Error(ERROR_CODES::sense_key sense_key, ERROR_CODES::asc asc) LOGTRACE("%s Error (to status phase)", __PRETTY_FUNCTION__); - // status phase Status(); } -//=========================================================================== -// -// Data Transfer -// -//=========================================================================== - //--------------------------------------------------------------------------- // // Send data @@ -374,8 +361,6 @@ void SCSIDEV::Error(ERROR_CODES::sense_key sense_key, ERROR_CODES::asc asc) //--------------------------------------------------------------------------- void SCSIDEV::Send() { - int len; - ASSERT(!ctrl.bus->GetREQ()); ASSERT(ctrl.bus->GetIO()); @@ -385,18 +370,18 @@ void SCSIDEV::Send() s << __PRETTY_FUNCTION__ << " sending handhake with offset " << ctrl.offset << ", length " << ctrl.length; LOGTRACE("%s", s.str().c_str()); - // TODO Get rid of Daynaport specific code + // TODO Get rid of Daynaport specific code in this class // The Daynaport needs to have a delay after the size/flags field // of the read response. In the MacOS driver, it looks like the // driver is doing two "READ" system calls. + int len; if (ctrl.unit[0] && ctrl.unit[0]->IsDaynaPort()) { len = ((GPIOBUS*)ctrl.bus)->SendHandShake( - &ctrl.buffer[ctrl.offset], ctrl.length, SCSIDaynaPort::DAYNAPORT_READ_HEADER_SZ); + &ctrl.buffer[ctrl.offset], ctrl.length, SCSIDaynaPort::DAYNAPORT_READ_HEADER_SZ); } else { - len = ctrl.bus->SendHandShake( - &ctrl.buffer[ctrl.offset], ctrl.length, BUS::SEND_NO_DELAY); + len = ctrl.bus->SendHandShake(&ctrl.buffer[ctrl.offset], ctrl.length, BUS::SEND_NO_DELAY); } // If you cannot send all, move to status phase @@ -421,7 +406,7 @@ void SCSIDEV::Send() // set next buffer (set offset, length) result = XferIn(ctrl.buffer); ostringstream s; - s << __PRETTY_FUNCTION__ << " processing after data collection. Blocks: " << ctrl.blocks; + s << __PRETTY_FUNCTION__ << " Processing after data collection. Blocks: " << ctrl.blocks; LOGTRACE("%s", s.str().c_str()); } } @@ -435,7 +420,7 @@ void SCSIDEV::Send() // Continue sending if block !=0 if (ctrl.blocks != 0){ ostringstream s; - s << __PRETTY_FUNCTION__ << " Continuing to send. blocks = " << ctrl.blocks; + s << __PRETTY_FUNCTION__ << " Continuing to send. Blocks: " << ctrl.blocks; LOGTRACE("%s", s.str().c_str()); ASSERT(ctrl.length > 0); ASSERT(ctrl.offset == 0); diff --git a/src/raspberrypi/rascsi.cpp b/src/raspberrypi/rascsi.cpp index e4142dd3..f3c0a94c 100644 --- a/src/raspberrypi/rascsi.cpp +++ b/src/raspberrypi/rascsi.cpp @@ -1619,7 +1619,7 @@ int main(int argc, char* argv[]) } } - // Stop because it the bus is busy or another device responded + // Stop because the bus is busy or another device responded if (bus->GetBSY() || !bus->GetSEL()) { continue; }