Cleanup to merge in with main branch

This commit is contained in:
Tony Kuker
2020-07-09 15:34:29 -05:00
parent 15bd9d7dd4
commit 6bdb841dfc
4 changed files with 100 additions and 183 deletions

View File

@@ -45,7 +45,9 @@
//#define DISK_LOG //#define DISK_LOG
#ifdef RASCSI #ifdef RASCSI
#define BENDER_SIGNATURE "SONY " #define BENDER_SIGNATURE "RaSCSI"
// The following line was to mimic Apple's CDROM ID
// #define BENDER_SIGNATURE "SONY "
#else #else
#define BENDER_SIGNATURE "XM6" #define BENDER_SIGNATURE "XM6"
#endif #endif
@@ -1346,20 +1348,16 @@ int FASTCALL Disk::ModeSense(const DWORD *cdb, BYTE *buf)
// Get changeable flag // Get changeable flag
if ((cdb[2] & 0xc0) == 0x40) { if ((cdb[2] & 0xc0) == 0x40) {
//** printf("MODESENSE: Change = TRUE\n");
change = TRUE; change = TRUE;
} else { } else {
//** printf("MODESENSE: Change = FALSE\n");
change = FALSE; change = FALSE;
} }
// Get page code (0x00 is valid from the beginning) // Get page code (0x00 is valid from the beginning)
page = cdb[2] & 0x3f; page = cdb[2] & 0x3f;
if (page == 0x00) { if (page == 0x00) {
//** printf("MODESENSE: Page code: OK %02X\n", cdb[2]);
valid = TRUE; valid = TRUE;
} else { } else {
//** printf("MODESENSE: Invalid page code received %02X\n", cdb[2]);
valid = FALSE; valid = FALSE;
} }
@@ -1373,7 +1371,6 @@ int FASTCALL Disk::ModeSense(const DWORD *cdb, BYTE *buf)
// DEVICE SPECIFIC PARAMETER // DEVICE SPECIFIC PARAMETER
if (disk.writep) { if (disk.writep) {
//** printf("MODESENSE: Write protect\n");
buf[2] = 0x80; buf[2] = 0x80;
} }
@@ -1384,7 +1381,6 @@ int FASTCALL Disk::ModeSense(const DWORD *cdb, BYTE *buf)
// Only if ready // Only if ready
if (disk.ready) { if (disk.ready) {
//** printf("MODESENSE: Disk is ready\n");
// Block descriptor (number of blocks) // Block descriptor (number of blocks)
buf[5] = (BYTE)(disk.blocks >> 16); buf[5] = (BYTE)(disk.blocks >> 16);
buf[6] = (BYTE)(disk.blocks >> 8); buf[6] = (BYTE)(disk.blocks >> 8);
@@ -1461,13 +1457,10 @@ int FASTCALL Disk::ModeSense(const DWORD *cdb, BYTE *buf)
// Unsupported page // Unsupported page
if (!valid) { if (!valid) {
//** printf("MODESENSE: Something was invalid...\n");
disk.code = DISK_INVALIDCDB; disk.code = DISK_INVALIDCDB;
return 0; return 0;
} }
//** printf("MODESENSE: mode sense length is %d\n",length);
// MODE SENSE success // MODE SENSE success
disk.code = DISK_NOERROR; disk.code = DISK_NOERROR;
return length; return length;
@@ -4135,7 +4128,7 @@ int FASTCALL SCSICD::Inquiry(
buf[1] = 0x80; buf[1] = 0x80;
buf[2] = 0x02; buf[2] = 0x02;
buf[3] = 0x02; buf[3] = 0x02;
buf[4] = 42; // Required buf[4] = 36 - 5; // Required
// Fill with blanks // Fill with blanks
memset(&buf[8], 0x20, buf[4] - 3); memset(&buf[8], 0x20, buf[4] - 3);
@@ -4144,16 +4137,34 @@ int FASTCALL SCSICD::Inquiry(
memcpy(&buf[8], BENDER_SIGNATURE, strlen(BENDER_SIGNATURE)); memcpy(&buf[8], BENDER_SIGNATURE, strlen(BENDER_SIGNATURE));
// Product name // Product name
memcpy(&buf[16], "CD-ROM CDU-8003A", 16); memcpy(&buf[16], "CD-ROM CDU-55S", 14);
// Revision (XM6 version number) // Revision (XM6 version number)
// sprintf(rev, "1.9a", sprintf(rev, "0%01d%01d%01d",
// (int)major, (int)(minor >> 4), (int)(minor & 0x0f)); (int)major, (int)(minor >> 4), (int)(minor & 0x0f));
memcpy(&buf[32], "1.9a", 4); memcpy(&buf[32], rev, 4);
//
//strcpy(&buf[35],"A1.9a"); // The following code worked with the modified Apple CD-ROM drivers. Need to
buf[36]=0x20; // test with the original code to see if it works as well....
memcpy(&buf[37],"1999/01/01",10); // buf[4] = 42; // Required
//
// // Fill with blanks
// memset(&buf[8], 0x20, buf[4] - 3);
//
// // Vendor name
// memcpy(&buf[8], BENDER_SIGNATURE, strlen(BENDER_SIGNATURE));
//
// // Product name
// memcpy(&buf[16], "CD-ROM CDU-8003A", 16);
//
// // Revision (XM6 version number)
//// sprintf(rev, "1.9a",
// //// (int)major, (int)(minor >> 4), (int)(minor & 0x0f));
// memcpy(&buf[32], "1.9a", 4);
//
// //strcpy(&buf[35],"A1.9a");
// buf[36]=0x20;
// memcpy(&buf[37],"1999/01/01",10);
// Size of data that can be returned // Size of data that can be returned
size = (buf[4] + 5); size = (buf[4] + 5);
@@ -4534,7 +4545,6 @@ void FASTCALL SCSICD::GetBuf(
ASSERT(this); ASSERT(this);
} }
//=========================================================================== //===========================================================================
// //
// SCSI Host Bridge // SCSI Host Bridge
@@ -6474,12 +6484,6 @@ void FASTCALL SASIDEV::Command()
#ifdef RASCSI #ifdef RASCSI
// Command reception handshake (10 bytes are automatically received at the first command) // Command reception handshake (10 bytes are automatically received at the first command)
count = ctrl.bus->CommandHandShake(ctrl.buffer); count = ctrl.bus->CommandHandShake(ctrl.buffer);
//** printf("Command received: " );
//** for(int i=0; i< count; i++)
//** {
//** printf("%02X ", ctrl.buffer[i]);
//** }
//** printf("\n");
// If no byte can be received move to the status phase // If no byte can be received move to the status phase
if (count == 0) { if (count == 0) {
@@ -6668,8 +6672,8 @@ void FASTCALL SASIDEV::Status()
#ifndef RASCSI #ifndef RASCSI
// Request status // Request status
// ctrl.bus->SetDAT(ctrl.buffer[0]); ctrl.bus->SetDAT(ctrl.buffer[0]);
// ctrl.bus->SetREQ(TRUE); ctrl.bus->SetREQ(TRUE);
#if defined(DISK_LOG) #if defined(DISK_LOG)
Log(Log::Normal, "Status Phase $%02X", ctrl.status); Log(Log::Normal, "Status Phase $%02X", ctrl.status);
@@ -7302,7 +7306,7 @@ void FASTCALL SASIDEV::CmdAssign()
return; return;
} }
// 4Request 4 bytes of data // Request 4 bytes of data
ctrl.length = 4; ctrl.length = 4;
// Write phase // Write phase
@@ -7713,13 +7717,6 @@ BOOL FASTCALL SASIDEV::XferIn(BYTE *buf)
ctrl.length = ctrl.unit[lun]->Read(buf, ctrl.next); ctrl.length = ctrl.unit[lun]->Read(buf, ctrl.next);
ctrl.next++; ctrl.next++;
//** printf("XferIn read data from disk: ");
//** for (int i=0; i<ctrl.length; i++)
//** {
//** printf("%02X ", ctrl.buffer[i]);
//** }
//** printf("\n");
// If there is an error, go to the status phase // If there is an error, go to the status phase
if (ctrl.length <= 0) { if (ctrl.length <= 0) {
// Cancel data-in // Cancel data-in
@@ -7860,12 +7857,13 @@ void FASTCALL SASIDEV::FlushUnit()
} }
break; break;
default: default:
printf("Received an invalid flush command %02X!!!!!\n",ctrl.cmd[0]); printf("Received an invalid flush command %08X!!!!!\n",ctrl.cmd[0]);
ASSERT(FALSE); ASSERT(FALSE);
break; break;
} }
} }
#ifdef DISK_LOG
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// Get the current phase as a string // Get the current phase as a string
@@ -7913,11 +7911,13 @@ void SASIDEV::GetPhaseStr(char *str)
break; break;
} }
} }
#endif
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// Log output // Log output
// //
// TODO: This function needs some cleanup. Its very kludgey
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL SASIDEV::Log(Log::loglevel level, const char *format, ...) void FASTCALL SASIDEV::Log(Log::loglevel level, const char *format, ...)
{ {
@@ -7942,6 +7942,7 @@ void FASTCALL SASIDEV::Log(Log::loglevel level, const char *format, ...)
#endif // DISK_LOG #endif // DISK_LOG
#endif // RASCSI #endif // RASCSI
#ifdef DISK_LOG
// format // format
vsprintf(buffer, format, args); vsprintf(buffer, format, args);
@@ -7975,6 +7976,7 @@ void FASTCALL SASIDEV::Log(Log::loglevel level, const char *format, ...)
host->GetVM()->GetLog()->Format(level, host, buffer); host->GetVM()->GetLog()->Format(level, host, buffer);
#endif // RASCSI #endif // RASCSI
#endif // BAREMETAL #endif // BAREMETAL
#endif // DISK_LOG
} }
//=========================================================================== //===========================================================================
@@ -8029,7 +8031,6 @@ void FASTCALL SCSIDEV::Reset()
BUS::phase_t FASTCALL SCSIDEV::Process() BUS::phase_t FASTCALL SCSIDEV::Process()
{ {
ASSERT(this); ASSERT(this);
//** printf("SCSIDEV::Process() %d\n", ctrl.id);
// Do nothing if not connected // Do nothing if not connected
if (ctrl.id < 0 || ctrl.bus == NULL) { if (ctrl.id < 0 || ctrl.bus == NULL) {
@@ -8590,13 +8591,6 @@ void FASTCALL SCSIDEV::CmdModeSense()
Log(Log::Normal, "MODE SENSE Command "); Log(Log::Normal, "MODE SENSE Command ");
#endif // DISK_LOG #endif // DISK_LOG
//** printf("Received a Mode Sense command. Contents....");
//** for(int i=0; i<10; i++)
//** {
//** printf("%08X ", ctrl.cmd[i]);
//** }
//** printf("\n");
// Logical Unit // Logical Unit
lun = (ctrl.cmd[1] >> 5) & 0x07; lun = (ctrl.cmd[1] >> 5) & 0x07;
if (!ctrl.unit[lun]) { if (!ctrl.unit[lun]) {

View File

@@ -229,8 +229,6 @@ public:
// NULL check // NULL check
BOOL FASTCALL IsSASI() const; BOOL FASTCALL IsSASI() const;
// SASI Check // SASI Check
virtual BOOL FASTCALL IsMonitor() const {return FALSE;}
// Check if this is a monitor device
// Media Operations // Media Operations
virtual BOOL FASTCALL Open(const Filepath& path, BOOL attn = TRUE); virtual BOOL FASTCALL Open(const Filepath& path, BOOL attn = TRUE);
@@ -922,8 +920,10 @@ public:
// Other // Other
BUS::phase_t FASTCALL GetPhase() {return ctrl.phase;} BUS::phase_t FASTCALL GetPhase() {return ctrl.phase;}
// Get the phase // Get the phase
#ifdef DISK_LOG
// Function to get the current phase as a String.
void FASTCALL GetPhaseStr(char *str); void FASTCALL GetPhaseStr(char *str);
#endif
int FASTCALL GetID() {return ctrl.id;} int FASTCALL GetID() {return ctrl.id;}
// Get the ID // Get the ID
@@ -935,8 +935,6 @@ public:
// SASI Check // SASI Check
virtual BOOL FASTCALL IsSCSI() const {return FALSE;} virtual BOOL FASTCALL IsSCSI() const {return FALSE;}
// SCSI check // SCSI check
virtual BOOL FASTCALL IsMonitor() const {return FALSE;}
// Check to see if this is a monitor device
Disk* FASTCALL GetBusyUnit(); Disk* FASTCALL GetBusyUnit();
// Get the busy unit // Get the busy unit

View File

@@ -552,15 +552,9 @@ BOOL FASTCALL GPIOBUS::GetBSY()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL GPIOBUS::SetBSY(BOOL ast) void FASTCALL GPIOBUS::SetBSY(BOOL ast)
{ {
if(actmode == MONITOR) // Set BSY signal
{ SetSignal(PIN_BSY, ast);
printf("WARNING!!! SOMEONE TRIED TO SET BSY IN MONITOR MODE");
}
else
{
// Set BSY signal
SetSignal(PIN_BSY, ast);
}
if (actmode == TARGET) { if (actmode == TARGET) {
if (ast) { if (ast) {
// Turn on ACTIVE signal // Turn on ACTIVE signal
@@ -612,14 +606,8 @@ void FASTCALL GPIOBUS::SetSEL(BOOL ast)
SetControl(PIN_ACT, ACT_ON); SetControl(PIN_ACT, ACT_ON);
} }
if (actmode != MONITOR) // Set SEL signal
{ SetSignal(PIN_SEL, ast);
// Set SEL signal
SetSignal(PIN_SEL, ast);
}
else{
printf("WARNING!!! SOMEONE TRIED TO SET SEL IN MONITOR MODE");
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -639,14 +627,7 @@ BOOL FASTCALL GPIOBUS::GetATN()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL GPIOBUS::SetATN(BOOL ast) void FASTCALL GPIOBUS::SetATN(BOOL ast)
{ {
if(actmode == MONITOR) SetSignal(PIN_ATN, ast);
{
printf("WARNING!!! SOMEONE TRIED TO SET ATN IN MONITOR MODE");
}
else
{
SetSignal(PIN_ATN, ast);
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -666,14 +647,7 @@ BOOL FASTCALL GPIOBUS::GetACK()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL GPIOBUS::SetACK(BOOL ast) void FASTCALL GPIOBUS::SetACK(BOOL ast)
{ {
if(actmode == MONITOR)
{
printf("WARNING!!! SOMEONE TRIED TO SET ACK IN MONITOR MODE");
}
else
{
SetSignal(PIN_ACK, ast); SetSignal(PIN_ACK, ast);
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -693,14 +667,7 @@ BOOL FASTCALL GPIOBUS::GetRST()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL GPIOBUS::SetRST(BOOL ast) void FASTCALL GPIOBUS::SetRST(BOOL ast)
{ {
if(actmode == MONITOR)
{
printf("WARNING!!! SOMEONE TRIED TO SET RST IN MONITOR MODE");
}
else
{
SetSignal(PIN_RST, ast); SetSignal(PIN_RST, ast);
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -720,13 +687,7 @@ BOOL FASTCALL GPIOBUS::GetMSG()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL GPIOBUS::SetMSG(BOOL ast) void FASTCALL GPIOBUS::SetMSG(BOOL ast)
{ {
if(actmode == MONITOR) SetSignal(PIN_MSG, ast);
{
printf("WARNING!!! SOMEONE TRIED TO SET MSG IN MONITOR MODE");
}
else{
SetSignal(PIN_MSG, ast);
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -746,14 +707,7 @@ BOOL FASTCALL GPIOBUS::GetCD()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL GPIOBUS::SetCD(BOOL ast) void FASTCALL GPIOBUS::SetCD(BOOL ast)
{ {
if(actmode == MONITOR) SetSignal(PIN_CD, ast);
{
printf("WARNING!!! SOMEONE TRIED TO SET CD IN MONITOR MODE");
}
else
{
SetSignal(PIN_CD, ast);
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -803,21 +757,6 @@ BOOL FASTCALL GPIOBUS::GetIO()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL GPIOBUS::SetIO(BOOL ast) void FASTCALL GPIOBUS::SetIO(BOOL ast)
{ {
if(actmode == MONITOR)
{
printf("WARNING!!! SOMEONE TRIED TO SET IO IN MONITOR MODE");
SetControl(PIN_DTD, DTD_IN);
SetMode(PIN_DT0, IN);
SetMode(PIN_DT1, IN);
SetMode(PIN_DT2, IN);
SetMode(PIN_DT3, IN);
SetMode(PIN_DT4, IN);
SetMode(PIN_DT5, IN);
SetMode(PIN_DT6, IN);
SetMode(PIN_DT7, IN);
SetMode(PIN_DP, IN);
}
SetSignal(PIN_IO, ast); SetSignal(PIN_IO, ast);
if (actmode == TARGET) { if (actmode == TARGET) {
@@ -866,12 +805,6 @@ BOOL FASTCALL GPIOBUS::GetREQ()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL GPIOBUS::SetREQ(BOOL ast) void FASTCALL GPIOBUS::SetREQ(BOOL ast)
{ {
if(actmode == MONITOR)
{
printf("WARNING!!! SOMEONE TRIED TO SET REQ IN MONITOR MODE");
return;
}
SetSignal(PIN_REQ, ast); SetSignal(PIN_REQ, ast);
} }
@@ -905,14 +838,6 @@ BYTE FASTCALL GPIOBUS::GetDAT()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL GPIOBUS::SetDAT(BYTE dat) void FASTCALL GPIOBUS::SetDAT(BYTE dat)
{ {
if(actmode == MONITOR)
{
printf("WARNING!!! SOMEONE TRIED TO SET Data IN MONITOR MODE");
return;
}
// Write to port // Write to port
#if SIGNAL_CONTROL_MODE == 0 #if SIGNAL_CONTROL_MODE == 0
DWORD fsel; DWORD fsel;

View File

@@ -79,7 +79,7 @@ void Banner(int argc, char* argv[])
FPRT(stdout,"Connect type : %s\n", CONNECT_DESC); FPRT(stdout,"Connect type : %s\n", CONNECT_DESC);
if ((argc > 1 && strcmp(argv[1], "-h") == 0) || if ((argc > 1 && strcmp(argv[1], "-h") == 0) ||
(argc > 1 && strcmp(argv[1], "--help") == 0)){ (argc > 1 && strcmp(argv[1], "--help") == 0)){
FPRT(stdout,"\n"); FPRT(stdout,"\n");
FPRT(stdout,"Usage: %s [-IDn FILE] ...\n\n", argv[0]); FPRT(stdout,"Usage: %s [-IDn FILE] ...\n\n", argv[0]);
FPRT(stdout," n is SCSI identification number(0-7).\n"); FPRT(stdout," n is SCSI identification number(0-7).\n");