From 3e4f23d53dbab75437af0d2a2013e6507bb29fb0 Mon Sep 17 00:00:00 2001 From: akuker Date: Tue, 22 Sep 2020 20:57:28 -0500 Subject: [PATCH] Disabled SEL interrupt functionality so we can receive IP packets without delays. Some updates for receiving messages. Appears that the HD functionality still works, but others are untested --- src/raspberrypi/.vscode/launch.json | 3 +- src/raspberrypi/controllers/scsidev_ctrl.cpp | 31 ++++++++++++++++++- src/raspberrypi/controllers/scsidev_ctrl.h | 2 ++ src/raspberrypi/devices/ctapdriver.cpp | 1 + src/raspberrypi/devices/scsi_nuvolink.cpp | 32 ++++++++++++++------ src/raspberrypi/devices/scsi_nuvolink.h | 25 +++++++-------- src/raspberrypi/launch_sudo.sh | 3 ++ src/raspberrypi/rascsi.cpp | 25 +++++++++++++++ src/raspberrypi/xm6.h | 4 ++- 9 files changed, 101 insertions(+), 25 deletions(-) create mode 100755 src/raspberrypi/launch_sudo.sh diff --git a/src/raspberrypi/.vscode/launch.json b/src/raspberrypi/.vscode/launch.json index 4ac5ab4..462204f 100644 --- a/src/raspberrypi/.vscode/launch.json +++ b/src/raspberrypi/.vscode/launch.json @@ -8,13 +8,14 @@ "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", - "program": "${workspaceFolder}/bin/rascsi", + "program": "${workspaceFolder}/bin/fullspec/rascsi", "args": [], "stopAtEntry": true, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", + "miDebuggerPath": "${workspaceFolder}/launch_sudo.sh", "setupCommands": [ { "description": "Enable pretty-printing for gdb", diff --git a/src/raspberrypi/controllers/scsidev_ctrl.cpp b/src/raspberrypi/controllers/scsidev_ctrl.cpp index a13a00e..414e059 100644 --- a/src/raspberrypi/controllers/scsidev_ctrl.cpp +++ b/src/raspberrypi/controllers/scsidev_ctrl.cpp @@ -147,7 +147,7 @@ BUS::phase_t FASTCALL SCSIDEV::Process() //--------------------------------------------------------------------------- // -// Phaes +// Phases // //--------------------------------------------------------------------------- @@ -2083,3 +2083,32 @@ BOOL FASTCALL SCSIDEV::XferMsg(DWORD msg) return TRUE; } + +//--------------------------------------------------------------------------- +// +// Transfer IP packet to the host via SCSI +// +//--------------------------------------------------------------------------- +BOOL FASTCALL SCSIDEV::TransferPacketToHost(int packet_len){ + + // Aquire the bus + + // Reselection + + // Message OUT (expect a "NO OPERATION") + // IF we get a DISCONNECT message, abort sending the message + // Transition to MESSAGE IN and send a DISCONNECT + // then go to BUS FREE + + // DATA IN + // ... send the packet + + // MESSAGE OUT (expect a "NO OPERATION") + + // If more packets, go back to DATA IN + + // Else + // MESSAGE IN (sends DISCONNECT) + + // BUS FREE +} \ No newline at end of file diff --git a/src/raspberrypi/controllers/scsidev_ctrl.h b/src/raspberrypi/controllers/scsidev_ctrl.h index 898eb8e..36e43ac 100644 --- a/src/raspberrypi/controllers/scsidev_ctrl.h +++ b/src/raspberrypi/controllers/scsidev_ctrl.h @@ -102,6 +102,8 @@ public: BOOL FASTCALL IsSCSI() const {return TRUE;} // SCSI check + BOOL FASTCALL TransferPacketToHost(int packet_len); + private: // Phase void FASTCALL BusFree(); diff --git a/src/raspberrypi/devices/ctapdriver.cpp b/src/raspberrypi/devices/ctapdriver.cpp index e06e3eb..3abd7d3 100644 --- a/src/raspberrypi/devices/ctapdriver.cpp +++ b/src/raspberrypi/devices/ctapdriver.cpp @@ -5,6 +5,7 @@ // // Powered by XM6 TypeG Technology. // Copyright (C) 2016-2020 GIMONS +// Copyright akuker // // Imported NetBSD support and some optimisation patch by Rin Okuyama. // diff --git a/src/raspberrypi/devices/scsi_nuvolink.cpp b/src/raspberrypi/devices/scsi_nuvolink.cpp index 7bd6b5d..595c925 100644 --- a/src/raspberrypi/devices/scsi_nuvolink.cpp +++ b/src/raspberrypi/devices/scsi_nuvolink.cpp @@ -460,22 +460,27 @@ void FASTCALL SCSINuvolink::SetMacAddr(BYTE *mac) // Receive Packet // //--------------------------------------------------------------------------- -void FASTCALL SCSINuvolink::ReceivePacket() +int FASTCALL SCSINuvolink::ReceivePacket() { static const BYTE bcast_addr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; ASSERT(this); ASSERT(tap); - LOGTRACE("SCSINuvolink::ReceivePacket"); + //LOGTRACE("SCSINuvolink::ReceivePacket"); - // previous packet has not been received - if (packet_enable) { - return; - } + // // previous packet has not been received + // if (packet_enable) { + // LOGDEBUG("packet not enabled"); + // return; + // } // Receive packet packet_len = tap->Rx(packet_buf); + if(packet_len){ + LOGINFO("Received a packet of size %d",packet_len); + } + // Check if received packet if (memcmp(packet_buf, mac_addr, 6) != 0) { if (memcmp(packet_buf, bcast_addr, 6) != 0) { @@ -486,16 +491,23 @@ void FASTCALL SCSINuvolink::ReceivePacket() // Discard if it exceeds the buffer size if (packet_len > 2048) { + LOGDEBUG("Packet size was too big. Dropping it"); packet_len = 0; return; } - // Store in receive buffer - if (packet_len > 0) { - packet_enable = TRUE; - } + // TransferPacket(packet_len, packet_buff); + return packet_len; + + // // Store in receive buffer + // if (packet_len > 0) { + // packet_enable = TRUE; + // } } + + + //--------------------------------------------------------------------------- // // Get Packet diff --git a/src/raspberrypi/devices/scsi_nuvolink.h b/src/raspberrypi/devices/scsi_nuvolink.h index c67167d..454bd25 100644 --- a/src/raspberrypi/devices/scsi_nuvolink.h +++ b/src/raspberrypi/devices/scsi_nuvolink.h @@ -44,16 +44,18 @@ public: // Destructor // commands - int FASTCALL Inquiry(const DWORD *cdb, BYTE *buf, DWORD major, DWORD minor); + int FASTCALL Inquiry(const DWORD *cdb, BYTE *buffer, DWORD major, DWORD minor); // INQUIRY command BOOL FASTCALL TestUnitReady(const DWORD *cdb); // TEST UNIT READY command - int FASTCALL GetMessage6(const DWORD *cdb, BYTE *buf); + int FASTCALL GetMessage6(const DWORD *cdb, BYTE *buffer); // GET MESSAGE10 command - BOOL FASTCALL SendMessage6(const DWORD *cdb, BYTE *buf); + BOOL FASTCALL SendMessage6(const DWORD *cdb, BYTE *buffer); // SEND MESSAGE10 command - BOOL SendPacket(BYTE *buf, int len); + BOOL SendPacket(BYTE *buffer, int len); // Send a packet + int FASTCALL ReceivePacket(); + // Receive a packet private: @@ -77,17 +79,16 @@ private: static const char* m_revision; #if defined(RASCSI) && !defined(BAREMETAL) - int FASTCALL GetMacAddr(BYTE *buf); + int FASTCALL GetMacAddr(BYTE *buffer); // Get MAC address - void FASTCALL SetMacAddr(BYTE *buf); + void FASTCALL SetMacAddr(BYTE *buffer); // Set MAC address - void FASTCALL ReceivePacket(); - // Receive a packet - void FASTCALL GetPacketBuf(BYTE *buf); + void FASTCALL GetPacketBuf(BYTE *buffer); // Get a packet - void FASTCALL SetMulticastRegisters(BYTE *buf, int len); - // Change the multicast registers - + void FASTCALL SetMulticastRegisters(BYTE *buffer, int len); + // Change the multicast registers + void FASTCALL TransferPacketToHost(BYTE *buffer, int len); + // Transfer the received packet to the host CTapDriver *tap; // TAP driver BOOL m_bTapEnable; diff --git a/src/raspberrypi/launch_sudo.sh b/src/raspberrypi/launch_sudo.sh new file mode 100755 index 0000000..6ce283c --- /dev/null +++ b/src/raspberrypi/launch_sudo.sh @@ -0,0 +1,3 @@ +# This is used for debugging. VisualStudio code will call this file when launching +# the debugger, instead of directly calling GDB. That way we can add the pkexec +sudo /usr/bin/gdb "$@" \ No newline at end of file diff --git a/src/raspberrypi/rascsi.cpp b/src/raspberrypi/rascsi.cpp index af296b9..83b2392 100644 --- a/src/raspberrypi/rascsi.cpp +++ b/src/raspberrypi/rascsi.cpp @@ -1136,6 +1136,31 @@ LOGCRITICAL("LOGCRITICAL"); actid = -1; phase = BUS::busfree; + // If any of the controllers are an Ethernet + // device, check to see if there is new data + // received. + for (int x = 0; x < CtrlMax; x++) { + if (!ctrl[x]){ + continue; + } + + for (int y = 0; y < UnitNum; y++) { + int unitno = x * UnitNum + y; + // branch by unit type + if (disk[unitno]) { + if (disk[unitno]->GetID() == MAKEID('S','C','N','L')) { + // Receive the data.... + int packet_len = ((SCSINuvolink*)disk[unitno])->ReceivePacket(); + if(packet_len > 0){ + ((SCSIDEV*)ctrl[x])->TransferPacketToHost(packet_len); + } + + } + } + } + + } + #ifdef USE_SEL_EVENT_ENABLE // SEL signal polling if (bus->PollSelectEvent() < 0) { diff --git a/src/raspberrypi/xm6.h b/src/raspberrypi/xm6.h index a349b78..9edb544 100644 --- a/src/raspberrypi/xm6.h +++ b/src/raspberrypi/xm6.h @@ -39,7 +39,9 @@ // Various Operation Settings // //--------------------------------------------------------------------------- -#define USE_SEL_EVENT_ENABLE // Check SEL signal by event +// For now, USE_SEL_EVENT_ENABLE is incompatible with the Nuvolink functionality. +// See https://github.com/akuker/RASCSI/issues/27 for more information +//#define USE_SEL_EVENT_ENABLE // Check SEL signal by event #define REMOVE_FIXED_SASIHD_SIZE // remove the size limitation of SASIHD #define USE_MZ1F23_1024_SUPPORT // MZ-1F23 (SASI 20M/sector size 1024)