Extend meaning of switch

This commit is contained in:
Uwe Seimet 2023-11-20 10:01:53 +01:00
parent 8043dd8e6b
commit c5f9e7d99d
3 changed files with 20 additions and 1 deletions

View File

@ -15,7 +15,9 @@
#include "shared/piscsi_exceptions.h" #include "shared/piscsi_exceptions.h"
#include "hal/gpiobus.h" #include "hal/gpiobus.h"
#ifdef NO_SCSI_COMPLIANT_HANDSHAKE
#include "hal/systimer.h" #include "hal/systimer.h"
#endif
#include "controllers/controller_manager.h" #include "controllers/controller_manager.h"
#include "devices/scsi_host_bridge.h" #include "devices/scsi_host_bridge.h"
#include "devices/scsi_daynaport.h" #include "devices/scsi_daynaport.h"
@ -41,7 +43,10 @@ void ScsiController::Reset()
{ {
AbstractController::Reset(); AbstractController::Reset();
#ifdef NO_SCSI_COMPLIANT_HANDSHAKE
execstart = 0; execstart = 0;
#endif
identified_lun = -1; identified_lun = -1;
initiator_id = UNKNOWN_INITIATOR_ID; initiator_id = UNKNOWN_INITIATOR_ID;
@ -191,7 +196,10 @@ void ScsiController::Execute()
// Initialization for data transfer // Initialization for data transfer
ResetOffset(); ResetOffset();
SetBlocks(1); SetBlocks(1);
#ifdef NO_SCSI_COMPLIANT_HANDSHAKE
execstart = SysTimer::GetTimerLow(); execstart = SysTimer::GetTimerLow();
#endif
// Discard pending sense data from the previous command if the current command is not REQUEST SENSE // Discard pending sense data from the previous command if the current command is not REQUEST SENSE
if (GetOpcode() != scsi_command::eCmdRequestSense) { if (GetOpcode() != scsi_command::eCmdRequestSense) {
@ -245,6 +253,7 @@ void ScsiController::Execute()
void ScsiController::Status() void ScsiController::Status()
{ {
if (!IsStatus()) { if (!IsStatus()) {
#ifdef NO_SCSI_COMPLIANT_HANDSHAKE
// Minimum execution time // Minimum execution time
// TODO Why is a delay needed? Is this covered by the SCSI specification? // TODO Why is a delay needed? Is this covered by the SCSI specification?
if (execstart > 0) { if (execstart > 0) {
@ -252,6 +261,7 @@ void ScsiController::Status()
} else { } else {
SysTimer::SleepUsec(5); SysTimer::SleepUsec(5);
} }
#endif
stringstream s; stringstream s;
s << "Status phase, status is $" << setfill('0') << setw(2) << hex << static_cast<int>(GetStatus()); s << "Status phase, status is $" << setfill('0') << setw(2) << hex << static_cast<int>(GetStatus());
@ -323,10 +333,12 @@ void ScsiController::MsgOut()
void ScsiController::DataIn() void ScsiController::DataIn()
{ {
if (!IsDataIn()) { if (!IsDataIn()) {
#ifdef NO_SCSI_COMPLIANT_HANDSHAKE
// Minimum execution time // Minimum execution time
if (execstart > 0) { if (execstart > 0) {
Sleep(); Sleep();
} }
#endif
// If the length is 0, go to the status phase // If the length is 0, go to the status phase
if (!HasValidLength()) { if (!HasValidLength()) {
@ -352,10 +364,12 @@ void ScsiController::DataIn()
void ScsiController::DataOut() void ScsiController::DataOut()
{ {
if (!IsDataOut()) { if (!IsDataOut()) {
#ifdef NO_SCSI_COMPLIANT_HANDSHAKE
// Minimum execution time // Minimum execution time
if (execstart > 0) { if (execstart > 0) {
Sleep(); Sleep();
} }
#endif
// If the length is 0, go to the status phase // If the length is 0, go to the status phase
if (!HasValidLength()) { if (!HasValidLength()) {
@ -984,6 +998,7 @@ int ScsiController::GetEffectiveLun() const
return identified_lun != -1 ? identified_lun : GetLun(); return identified_lun != -1 ? identified_lun : GetLun();
} }
#ifdef NO_SCSI_COMPLIANT_HANDSHAKE
void ScsiController::Sleep() void ScsiController::Sleep()
{ {
if (const uint32_t time = SysTimer::GetTimerLow() - execstart; time < MIN_EXEC_TIME) { if (const uint32_t time = SysTimer::GetTimerLow() - execstart; time < MIN_EXEC_TIME) {
@ -991,3 +1006,4 @@ void ScsiController::Sleep()
} }
execstart = 0; execstart = 0;
} }
#endif

View File

@ -76,8 +76,10 @@ public:
private: private:
#ifdef NO_SCSI_COMPLIANT_HANDSHAKE
// Execution start time // Execution start time
uint32_t execstart = 0; uint32_t execstart = 0;
#endif
// The initiator ID may be unavailable, e.g. with Atari ACSI and old host adapters // The initiator ID may be unavailable, e.g. with Atari ACSI and old host adapters
int initiator_id = UNKNOWN_INITIATOR_ID; int initiator_id = UNKNOWN_INITIATOR_ID;
@ -103,7 +105,9 @@ private:
void ParseMessage(); void ParseMessage();
void ProcessMessage(); void ProcessMessage();
#ifdef NO_SCSI_COMPLIANT_HANDSHAKE
void Sleep(); void Sleep();
#endif
scsi_t scsi = {}; scsi_t scsi = {};
}; };

View File

@ -10,7 +10,6 @@
#include "hal/gpiobus_virtual.h" #include "hal/gpiobus_virtual.h"
#include "hal/gpiobus.h" #include "hal/gpiobus.h"
#include "hal/systimer.h"
#include "hal/log.h" #include "hal/log.h"
#include <cstddef> #include <cstddef>
#include <map> #include <map>