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

View File

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

View File

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

View File

@ -79,7 +79,7 @@ void Banner(int argc, char* argv[])
FPRT(stdout,"Connect type : %s\n", CONNECT_DESC);
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,"Usage: %s [-IDn FILE] ...\n\n", argv[0]);
FPRT(stdout," n is SCSI identification number(0-7).\n");