Failed attempt at monitoring the SCSI traffic.

This commit is contained in:
akuker 2020-07-07 14:16:02 -05:00
parent c86764c6e7
commit 6fd6fdcc05
5 changed files with 602 additions and 75 deletions

View File

@ -1,8 +1,13 @@
.DEFAULT_GOAL: all
CC = gcc CC = gcc
CFLAGS = -DDISK_LOG -O0 -g -Wall
CXX = g++ CXX = g++
CFLAGS = -DDISK_LOG -O0 -g -Wall
CXXFLAGS = -DDISK_LOG -O0 -g -Wall CXXFLAGS = -DDISK_LOG -O0 -g -Wall
# If its not specified, build for STANDARD configuration # If its not specified, build for STANDARD configuration
CONNECT_TYPE ?= STANDARD CONNECT_TYPE ?= STANDARD
@ -15,9 +20,13 @@ RASCSI = rascsi
RASCTL = rasctl RASCTL = rasctl
RASDUMP = rasdump RASDUMP = rasdump
SASIDUMP = sasidump SASIDUMP = sasidump
SCSIMON = scsimon
#BIN_ALL = $(RASCSI) $(RASCTL) $(RASDUMP) $(SASIDUMP) $(SCSIMON)
# Temporarily remove the RASDUMP and RASDUMP tools, since they're not needed
# for my specific use case. If you need them - add them back in!
BIN_ALL = $(RASCSI) $(RASCTL) $(SCSIMON)
BIN_ALL = $(RASCSI) $(RASCTL) $(RASDUMP) $(SASIDUMP)
SRC_RASCSI = \ SRC_RASCSI = \
rascsi.cpp \ rascsi.cpp \
@ -46,16 +55,29 @@ SRC_SASIDUMP = \
filepath.cpp \ filepath.cpp \
fileio.cpp fileio.cpp
SRC_SCSIMON = \
scsimon.cpp \
scsi.cpp \
disk.cpp \
gpiobus.cpp \
ctapdriver.cpp \
cfilesystem.cpp \
filepath.cpp \
fileio.cpp \
scsimondev.cpp
OBJ_RASCSI := $(SRC_RASCSI:%.cpp=%.o) OBJ_RASCSI := $(SRC_RASCSI:%.cpp=%.o)
OBJ_RASCTL := $(SRC_RASCTL:%.cpp=%.o) OBJ_RASCTL := $(SRC_RASCTL:%.cpp=%.o)
OBJ_RASDUMP := $(SRC_RASDUMP:%.cpp=%.o) OBJ_RASDUMP := $(SRC_RASDUMP:%.cpp=%.o)
OBJ_SASIDUMP := $(SRC_SASIDUMP:%.cpp=%.o) OBJ_SASIDUMP := $(SRC_SASIDUMP:%.cpp=%.o)
OBJ_ALL := $(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_RASDUMP) $(OBJ_SASIDUMP) OBJ_SCSIMON := $(SRC_SCSIMON:%.cpp=%.o)
OBJ_ALL := $(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_RASDUMP) $(OBJ_SASIDUMP) $(OBJ_SCSIMON)
%.o: %.cpp %.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@ $(CXX) $(CXXFLAGS) -c $< -o $@
ALL: $(BIN_ALL) ALL: $(BIN_ALL)
all: $(BIN_ALL)
$(RASCSI): $(OBJ_RASCSI) $(RASCSI): $(OBJ_RASCSI)
$(CXX) -o $@ $(OBJ_RASCSI) -lpthread $(CXX) -o $@ $(OBJ_RASCSI) -lpthread
@ -69,8 +91,14 @@ $(RASDUMP): $(OBJ_RASDUMP)
$(SASIDUMP): $(OBJ_SASIDUMP) $(SASIDUMP): $(OBJ_SASIDUMP)
$(CXX) -o $@ $(OBJ_SASIDUMP) $(CXX) -o $@ $(OBJ_SASIDUMP)
$(SCSIMON): $(OBJ_SCSIMON)
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_SCSIMON) -lpthread
clean: clean:
rm -f $(OBJ_ALL) $(BIN_ALL) rm -f $(OBJ_ALL) $(BIN_ALL)
run: run:
sudo ./$(RASCSI) -ID1 /home/pi/HARDDISK.HDA -ID6 /home/pi/marathon.iso sudo ./$(RASCSI) -ID1 /home/pi/HARDDISK.HDA -ID6 /home/pi/marathon.iso
.PHONY: Debug
Debug: scsimon

View File

@ -4534,6 +4534,248 @@ void FASTCALL SCSICD::GetBuf(
ASSERT(this); ASSERT(this);
} }
//===========================================================================
//
// SCSI Monitor Device
// This will monitor all of the traffic to this SCSI ID and dump it to
// STDOUT
//
//===========================================================================
//---------------------------------------------------------------------------
//
// Constructor
//
//---------------------------------------------------------------------------
MONITORHD::MONITORHD() : Disk()
{
// SCSI Monitor
disk.id = MAKEID('S', 'M', 'O', 'N');
}
//---------------------------------------------------------------------------
//
// Reset
//
//---------------------------------------------------------------------------
void FASTCALL MONITORHD::Reset()
{
// // Unlock and release attention
// disk.lock = FALSE;
// disk.attn = FALSE;
//
// // No reset, clear code
// disk.reset = FALSE;
// disk.code = 0x00;
}
//---------------------------------------------------------------------------
//
// Open
//
//---------------------------------------------------------------------------
BOOL FASTCALL MONITORHD::Open(const Filepath& path, BOOL /*attn*/)
{
// Fileio fio;
// off64_t size;
//
// ASSERT(this);
// ASSERT(!disk.ready);
//
// // read open required
// if (!fio.Open(path, Fileio::ReadOnly)) {
// return FALSE;
// }
//
// // Get file size
// size = fio.GetFileSize();
// fio.Close();
//
// // Must be 512 bytes
// if (size & 0x1ff) {
// return FALSE;
// }
//
// // 10MB or more
// if (size < 0x9f5400) {
// return FALSE;
// }
// // 2TB according to xm6i
// // There is a similar one in wxw/wxw_cfg.cpp
// if (size > 2LL * 1024 * 1024 * 1024 * 1024) {
// return FALSE;
// }
//
// // sector size and number of blocks
// disk.size = 9;
// disk.blocks = (DWORD)(size >> 9);
//
// // Call base class
// return Disk::Open(path);
}
//---------------------------------------------------------------------------
//
// INQUIRY
//
//---------------------------------------------------------------------------
int FASTCALL MONITORHD::Inquiry(
const DWORD *cdb, BYTE *buf, DWORD major, DWORD minor)
{
//////// char vendor[32];
//////// char product[32];
//////// char rev[32];
int size = 0;
////////
//////// ASSERT(this);
//////// ASSERT(cdb);
//////// ASSERT(buf);
//////// ASSERT(cdb[0] == 0x12);
////////
//////// // EVPD check
//////// if (cdb[1] & 0x01) {
//////// disk.code = DISK_INVALIDCDB;
//////// return 0;
//////// }
////////
//////// // Ready check (Error if no image file)
//////// if (!disk.ready) {
//////// disk.code = DISK_NOTREADY;
//////// return 0;
//////// }
////////
//////// // Basic data
//////// // buf[0] ... Direct Access Device
//////// // buf[2] ... SCSI-2 compliant command system
//////// // buf[3] ... SCSI-2 compliant Inquiry response
//////// // buf[4] ... Inquiry additional data
//////// memset(buf, 0, 8);
////////
//////// // SCSI-2 p.104 4.4.3 Incorrect logical unit handling
//////// if (((cdb[1] >> 5) & 0x07) != disk.lun) {
//////// buf[0] = 0x7f;
//////// }
////////
//////// buf[2] = 0x02;
//////// buf[3] = 0x02;
//////// buf[4] = 122 + 3; // Value close to real HDD
////////
//////// // Fill with blanks
//////// memset(&buf[8], 0x20, buf[4] - 3);
////////
//////// // Determine vendor name/product name
//////// sprintf(vendor, BENDER_SIGNATURE);
//////// size = disk.blocks >> 11;
//////// if (size < 300)
//////// sprintf(product, "PRODRIVE LPS%dS", size);
//////// else if (size < 600)
//////// sprintf(product, "MAVERICK%dS", size);
//////// else if (size < 800)
//////// sprintf(product, "LIGHTNING%dS", size);
//////// else if (size < 1000)
//////// sprintf(product, "TRAILBRAZER%dS", size);
//////// else if (size < 2000)
//////// sprintf(product, "FIREBALL%dS", size);
//////// else
//////// sprintf(product, "FBSE%d.%dS", size / 1000, (size % 1000) / 100);
////////
//////// // Vendor name
//////// memcpy(&buf[8], vendor, strlen(vendor));
////////
//////// // Product name
//////// memcpy(&buf[16], product, strlen(product));
////////
//////// // Revision
//////// sprintf(rev, "0%01d%01d%01d",
//////// (int)major, (int)(minor >> 4), (int)(minor & 0x0f));
//////// memcpy(&buf[32], rev, 4);
////////
//////// // Size of data that can be returned
//////// size = (buf[4] + 5);
////////
//////// // Limit if the other buffer is small
//////// if (size > (int)cdb[4]) {
//////// size = (int)cdb[4];
//////// }
////////
//////// // Success
//////// disk.code = DISK_NOERROR;
return size;
}
//---------------------------------------------------------------------------
//
// MODE SELECT
// *Not affected by disk.code
//
//---------------------------------------------------------------------------
BOOL FASTCALL MONITORHD::ModeSelect(const DWORD *cdb, const BYTE *buf, int length)
{
// int page;
// int size;
//
// ASSERT(this);
// ASSERT(buf);
// ASSERT(length >= 0);
//
// // PF
// if (cdb[1] & 0x10) {
// // Mode Parameter header
// if (length >= 12) {
// // Check the block length bytes
// size = 1 << disk.size;
// if (buf[9] != (BYTE)(size >> 16) ||
// buf[10] != (BYTE)(size >> 8) ||
// buf[11] != (BYTE)size) {
// // currently does not allow changing sector length
// disk.code = DISK_INVALIDPRM;
// return FALSE;
// }
// buf += 12;
// length -= 12;
// }
//
// // Parsing the page
// while (length > 0) {
// // Get page
// page = buf[0];
//
// switch (page) {
// // format device
// case 0x03:
// // check the number of bytes in the physical sector
// size = 1 << disk.size;
// if (buf[0xc] != (BYTE)(size >> 8) ||
// buf[0xd] != (BYTE)size) {
// // currently does not allow changing sector length
// disk.code = DISK_INVALIDPRM;
// return FALSE;
// }
// break;
//
// // Other page
// default:
// break;
// }
//
// // Advance to the next page
// size = buf[1] + 2;
// length -= size;
// buf += size;
// }
// }
//
// // Do not generate an error for the time being (MINIX)
// disk.code = DISK_NOERROR;
return TRUE;
}
//=========================================================================== //===========================================================================
// //
// SCSI Host Bridge // SCSI Host Bridge
@ -6294,19 +6536,20 @@ BUS::phase_t FASTCALL SASIDEV::Process()
// Get bus information // Get bus information
ctrl.bus->Aquire(); ctrl.bus->Aquire();
// Reset // For the monitor tool, we shouldn't need to reset. We're just logging information
if (ctrl.bus->GetRST()) { //////// // Reset
#if defined(DISK_LOG) //////// if (ctrl.bus->GetRST()) {
Log(Log::Normal, "RESET signal received"); ////////#if defined(DISK_LOG)
#endif // DISK_LOG //////// Log(Log::Normal, "RESET signal received");
////////#endif // DISK_LOG
// Reset the controller ////////
Reset(); //////// // Reset the controller
//////// Reset();
// Reset the bus ////////
ctrl.bus->Reset(); //////// // Reset the bus
return ctrl.phase; //////// ctrl.bus->Reset();
} //////// return ctrl.phase;
//////// }
// Phase processing // Phase processing
switch (ctrl.phase) { switch (ctrl.phase) {
@ -6373,12 +6616,12 @@ void FASTCALL SASIDEV::BusFree()
// Phase Setting // Phase Setting
ctrl.phase = BUS::busfree; ctrl.phase = BUS::busfree;
// 信号線 // // Set Signal lines
ctrl.bus->SetREQ(FALSE); // ctrl.bus->SetREQ(FALSE);
ctrl.bus->SetMSG(FALSE); // ctrl.bus->SetMSG(FALSE);
ctrl.bus->SetCD(FALSE); // ctrl.bus->SetCD(FALSE);
ctrl.bus->SetIO(FALSE); // ctrl.bus->SetIO(FALSE);
ctrl.bus->SetBSY(FALSE); // ctrl.bus->SetBSY(FALSE);
// Initialize status and message // Initialize status and message
ctrl.status = 0x00; ctrl.status = 0x00;
@ -6459,10 +6702,10 @@ void FASTCALL SASIDEV::Command()
// Phase Setting // Phase Setting
ctrl.phase = BUS::command; ctrl.phase = BUS::command;
// Signal line operated by the target // // Signal line operated by the target
ctrl.bus->SetMSG(FALSE); // ctrl.bus->SetMSG(FALSE);
ctrl.bus->SetCD(TRUE); // ctrl.bus->SetCD(TRUE);
ctrl.bus->SetIO(FALSE); // ctrl.bus->SetIO(FALSE);
// Data transfer is 6 bytes x 1 block // Data transfer is 6 bytes x 1 block
ctrl.offset = 0; ctrl.offset = 0;
@ -6653,10 +6896,10 @@ void FASTCALL SASIDEV::Status()
// Phase Setting // Phase Setting
ctrl.phase = BUS::status; ctrl.phase = BUS::status;
// Signal line operated by the target //////// // Signal line operated by the target
ctrl.bus->SetMSG(FALSE); //////// ctrl.bus->SetMSG(FALSE);
ctrl.bus->SetCD(TRUE); //////// ctrl.bus->SetCD(TRUE);
ctrl.bus->SetIO(TRUE); //////// ctrl.bus->SetIO(TRUE);
// Data transfer is 1 byte x 1 block // Data transfer is 1 byte x 1 block
ctrl.offset = 0; ctrl.offset = 0;
@ -6666,8 +6909,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);
@ -6714,10 +6957,10 @@ void FASTCALL SASIDEV::MsgIn()
// Phase Setting // Phase Setting
ctrl.phase = BUS::msgin; ctrl.phase = BUS::msgin;
// Signal line operated by the target ////////// // Signal line operated by the target
ctrl.bus->SetMSG(TRUE); ////////// ctrl.bus->SetMSG(TRUE);
ctrl.bus->SetCD(TRUE); ////////// ctrl.bus->SetCD(TRUE);
ctrl.bus->SetIO(TRUE); ////////// ctrl.bus->SetIO(TRUE);
// length, blocks are already set // length, blocks are already set
ASSERT(ctrl.length > 0); ASSERT(ctrl.length > 0);
@ -6798,10 +7041,10 @@ void FASTCALL SASIDEV::DataIn()
// Phase Setting // Phase Setting
ctrl.phase = BUS::datain; ctrl.phase = BUS::datain;
// Signal line operated by the target //////// // Signal line operated by the target
ctrl.bus->SetMSG(FALSE); //////// ctrl.bus->SetMSG(FALSE);
ctrl.bus->SetCD(FALSE); //////// ctrl.bus->SetCD(FALSE);
ctrl.bus->SetIO(TRUE); //////// ctrl.bus->SetIO(TRUE);
// length, blocks are already set // length, blocks are already set
ASSERT(ctrl.length > 0); ASSERT(ctrl.length > 0);
@ -6880,10 +7123,10 @@ void FASTCALL SASIDEV::DataOut()
// Phase Setting // Phase Setting
ctrl.phase = BUS::dataout; ctrl.phase = BUS::dataout;
// Signal line operated by the target //////// // Signal line operated by the target
ctrl.bus->SetMSG(FALSE); //////// ctrl.bus->SetMSG(FALSE);
ctrl.bus->SetCD(FALSE); //////// ctrl.bus->SetCD(FALSE);
ctrl.bus->SetIO(FALSE); //////// ctrl.bus->SetIO(FALSE);
// length, blocks are already calculated // length, blocks are already calculated
ASSERT(ctrl.length > 0); ASSERT(ctrl.length > 0);
@ -8026,6 +8269,7 @@ 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) {
@ -8125,12 +8369,12 @@ void FASTCALL SCSIDEV::BusFree()
// Phase setting // Phase setting
ctrl.phase = BUS::busfree; ctrl.phase = BUS::busfree;
// Signal line //////// // Signal line
ctrl.bus->SetREQ(FALSE); //////// ctrl.bus->SetREQ(FALSE);
ctrl.bus->SetMSG(FALSE); //////// ctrl.bus->SetMSG(FALSE);
ctrl.bus->SetCD(FALSE); //////// ctrl.bus->SetCD(FALSE);
ctrl.bus->SetIO(FALSE); //////// ctrl.bus->SetIO(FALSE);
ctrl.bus->SetBSY(FALSE); //////// ctrl.bus->SetBSY(FALSE);
// Initialize status and message // Initialize status and message
ctrl.status = 0x00; ctrl.status = 0x00;
@ -8399,10 +8643,10 @@ void FASTCALL SCSIDEV::MsgOut()
// Phase Setting // Phase Setting
ctrl.phase = BUS::msgout; ctrl.phase = BUS::msgout;
// Signal line operated by the target //////// // Signal line operated by the target
ctrl.bus->SetMSG(TRUE); //////// ctrl.bus->SetMSG(TRUE);
ctrl.bus->SetCD(TRUE); //////// ctrl.bus->SetCD(TRUE);
ctrl.bus->SetIO(FALSE); //////// ctrl.bus->SetIO(FALSE);
// Data transfer is 1 byte x 1 block // Data transfer is 1 byte x 1 block
ctrl.offset = 0; ctrl.offset = 0;

View File

@ -229,6 +229,8 @@ 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);
@ -399,6 +401,26 @@ public:
// MODE SELECT(6) command // MODE SELECT(6) command
}; };
class MONITORHD : public Disk
{
public:
// Basic Functions
MONITORHD();
// Constructor
void FASTCALL Reset();
// Reset
BOOL FASTCALL Open(const Filepath& path, BOOL attn = TRUE);
// Open
// commands
int FASTCALL Inquiry(
const DWORD *cdb, BYTE *buf, DWORD major, DWORD minor);
// INQUIRY command
BOOL FASTCALL ModeSelect(const DWORD *cdb, const BYTE *buf, int length);
// MODE SELECT(6) command
BOOL FASTCALL IsMonitor() const {return TRUE;}
};
//=========================================================================== //===========================================================================
// //
// SCSI hard disk (PC-9801-55 NEC genuine /Anex86/T98Next) // SCSI hard disk (PC-9801-55 NEC genuine /Anex86/T98Next)
@ -701,6 +723,31 @@ private:
#endif #endif
}; };
//////////===========================================================================
//////////
////////// SCSI Monitor Device (Interits SCSI device)
//////////
//////////===========================================================================
////////class SCSIMONDEV : public Disk
////////{
////////public:
//////// // Basic Functions
//////// SCSIMONDEV();
//////// // Constructor
//////// void FASTCALL Reset();
//////// // Reset
//////// BOOL FASTCALL Open(const Filepath& path, BOOL attn = TRUE);
//////// // Open
////////
//////// // commands
//////// int FASTCALL Inquiry(
//////// const DWORD *cdb, BYTE *buf, DWORD major, DWORD minor);
//////// // INQUIRY command
//////// BOOL FASTCALL ModeSelect(const DWORD *cdb, const BYTE *buf, int length);
//////// // MODE SELECT(6) command
////////};
//=========================================================================== //===========================================================================
// //
// SCSI Host Bridge // SCSI Host Bridge
@ -933,6 +980,8 @@ 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
@ -1141,4 +1190,132 @@ private:
// Internal data // Internal data
}; };
//===========================================================================
//
// SCSI Device (Interits SASI device)
//
//===========================================================================
class SCSIMONDEV : public SASIDEV
{
public:
// Internal data definition
typedef struct {
// Synchronous transfer
BOOL syncenable; // Synchronous transfer possible
int syncperiod; // Synchronous transfer period
int syncoffset; // Synchronous transfer offset
int syncack; // Number of synchronous transfer ACKs
// ATN message
BOOL atnmsg;
int msc;
BYTE msb[256];
} scsi_t;
BOOL FASTCALL IsMonitor() const {return TRUE;}
public:
// Basic Functions
#ifdef RASCSI
SCSIMONDEV();
#else
SCSIMONDEV(Device *dev);
#endif // RASCSI
// Constructor
void FASTCALL Reset();
// Device Reset
// 外部API
BUS::phase_t FASTCALL Process();
// Run
void FASTCALL SyncTransfer(BOOL enable) { scsi.syncenable = enable; }
// Synchronouse transfer enable setting
// Other
BOOL FASTCALL IsSASI() const {return FALSE;}
// SASI Check
BOOL FASTCALL IsSCSI() const {return TRUE;}
// SCSI check
private:
// Phase
void FASTCALL BusFree();
// Bus free phase
void FASTCALL Selection();
// Selection phase
void FASTCALL Execute();
// Execution phase
void FASTCALL MsgOut();
// Message out phase
void FASTCALL Error();
// Common erorr handling
// commands
void FASTCALL CmdInquiry();
// INQUIRY command
void FASTCALL CmdModeSelect();
// MODE SELECT command
void FASTCALL CmdModeSense();
// MODE SENSE command
void FASTCALL CmdStartStop();
// START STOP UNIT command
void FASTCALL CmdSendDiag();
// SEND DIAGNOSTIC command
void FASTCALL CmdRemoval();
// PREVENT/ALLOW MEDIUM REMOVAL command
void FASTCALL CmdReadCapacity();
// READ CAPACITY command
void FASTCALL CmdRead10();
// READ(10) command
void FASTCALL CmdWrite10();
// WRITE(10) command
void FASTCALL CmdSeek10();
// SEEK(10) command
void FASTCALL CmdVerify();
// VERIFY command
void FASTCALL CmdSynchronizeCache();
// SYNCHRONIZE CACHE command
void FASTCALL CmdReadDefectData10();
// READ DEFECT DATA(10) command
void FASTCALL CmdReadToc();
// READ TOC command
void FASTCALL CmdPlayAudio10();
// PLAY AUDIO(10) command
void FASTCALL CmdPlayAudioMSF();
// PLAY AUDIO MSF command
void FASTCALL CmdPlayAudioTrack();
// PLAY AUDIO TRACK INDEX command
void FASTCALL CmdModeSelect10();
// MODE SELECT(10) command
void FASTCALL CmdModeSense10();
// MODE SENSE(10) command
void FASTCALL CmdGetMessage10();
// GET MESSAGE(10) command
void FASTCALL CmdSendMessage10();
// SEND MESSAGE(10) command
// データ転送
void FASTCALL Send();
// Send data
#ifndef RASCSI
void FASTCALL SendNext();
// Continue sending data
#endif // RASCSI
void FASTCALL Receive();
// Receive data
#ifndef RASCSI
void FASTCALL ReceiveNext();
// Continue receiving data
#endif // RASCSI
BOOL FASTCALL XferMsg(DWORD msg);
// Data transfer message
scsi_t scsi;
// Internal data
};
#endif // disk_h #endif // disk_h

View File

@ -169,6 +169,7 @@ BOOL FASTCALL GPIOBUS::Init(mode_e mode)
// Open /dev/mem // Open /dev/mem
fd = open("/dev/mem", O_RDWR | O_SYNC); fd = open("/dev/mem", O_RDWR | O_SYNC);
if (fd == -1) { if (fd == -1) {
printf("Error: Unable to open /dev/mem. Are you running as root?\n");
return FALSE; return FALSE;
} }
@ -274,6 +275,7 @@ BOOL FASTCALL GPIOBUS::Init(mode_e mode)
PinConfig(PIN_DTD, GPIO_OUTPUT); PinConfig(PIN_DTD, GPIO_OUTPUT);
// Set the ENABLE signal // Set the ENABLE signal
// This is used to show that the application is running
PinSetSignal(PIN_ENB, ENB_OFF); PinSetSignal(PIN_ENB, ENB_OFF);
PinConfig(PIN_ENB, GPIO_OUTPUT); PinConfig(PIN_ENB, GPIO_OUTPUT);
@ -373,6 +375,7 @@ BOOL FASTCALL GPIOBUS::Init(mode_e mode)
MakeTable(); MakeTable();
// Finally, enable ENABLE // Finally, enable ENABLE
// Show the user that this app is running
SetControl(PIN_ENB, ENB_ON); SetControl(PIN_ENB, ENB_ON);
return TRUE; return TRUE;
@ -549,9 +552,15 @@ BOOL FASTCALL GPIOBUS::GetBSY()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL GPIOBUS::SetBSY(BOOL ast) void FASTCALL GPIOBUS::SetBSY(BOOL ast)
{ {
if(actmode == MONITOR)
{
printf("WARNING!!! SOMEONE TRIED TO SET BSY IN MONITOR MODE");
}
else
{
// Set BSY signal // Set BSY signal
SetSignal(PIN_BSY, ast); SetSignal(PIN_BSY, ast);
}
if (actmode == TARGET) { if (actmode == TARGET) {
if (ast) { if (ast) {
// Turn on ACTIVE signal // Turn on ACTIVE signal
@ -603,8 +612,14 @@ void FASTCALL GPIOBUS::SetSEL(BOOL ast)
SetControl(PIN_ACT, ACT_ON); SetControl(PIN_ACT, ACT_ON);
} }
if (actmode != MONITOR)
{
// Set SEL signal // Set SEL signal
SetSignal(PIN_SEL, ast); SetSignal(PIN_SEL, ast);
}
else{
printf("WARNING!!! SOMEONE TRIED TO SET SEL IN MONITOR MODE");
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -624,7 +639,14 @@ BOOL FASTCALL GPIOBUS::GetATN()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL GPIOBUS::SetATN(BOOL ast) 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);
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -644,7 +666,14 @@ 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);
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -664,7 +693,14 @@ 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);
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -684,7 +720,13 @@ BOOL FASTCALL GPIOBUS::GetMSG()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL GPIOBUS::SetMSG(BOOL ast) 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);
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -704,7 +746,14 @@ BOOL FASTCALL GPIOBUS::GetCD()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void FASTCALL GPIOBUS::SetCD(BOOL ast) 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);
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -754,6 +803,21 @@ 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) {
@ -802,6 +866,12 @@ 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);
} }
@ -835,6 +905,14 @@ 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

@ -155,7 +155,7 @@ BOOL Init()
bus = new GPIOBUS(); bus = new GPIOBUS();
// GPIO Initialization // GPIO Initialization
if (!bus->Init()) { if (!bus->Init(BUS::TARGET)) {
return FALSE; return FALSE;
} }