//--------------------------------------------------------------------------- // // SCSI Target Emulator RaSCSI Reloaded // for Raspberry Pi // // Powered by XM6 TypeG Technology. // Copyright (C) 2016-2020 GIMONS // [ GPIO-SCSI bus ] // //--------------------------------------------------------------------------- #pragma once #include "shared/config.h" #include "shared/scsi.h" #include "bus.h" #include #ifdef __linux__ #include #endif //--------------------------------------------------------------------------- // // Connection method definitions // //--------------------------------------------------------------------------- //#define CONNECT_TYPE_STANDARD // Standard (SCSI logic, standard pin assignment) //#define CONNECT_TYPE_FULLSPEC // Full spec (SCSI logic, standard pin assignment) //#define CONNECT_TYPE_AIBOM // AIBOM version (positive logic, unique pin assignment) //#define CONNECT_TYPE_GAMERNIUM // GAMERnium.com version (standard logic, unique pin assignment) #if defined CONNECT_TYPE_STANDARD #include "hal/gpiobus_standard.h" #elif defined CONNECT_TYPE_FULLSPEC #include "hal/gpiobus_fullspec.h" #elif defined CONNECT_TYPE_AIBOM #include "hal/gpiobus_aibom.h" #elif defined CONNECT_TYPE_GAMERNIUM #include "hal/gpiobus_gamernium.h" #else #error Invalid connection type or none specified #endif using namespace std; //NOSONAR Not relevant for rascsi //--------------------------------------------------------------------------- // // Signal control logic and pin assignment customization // //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // // SIGNAL_CONTROL_MODE: Signal control mode selection // You can customize the signal control logic from Version 1.22 // // 0:SCSI logical specification // Conversion board using 74LS641-1 etc. directly connected or published on HP // True : 0V // False : Open collector output (disconnect from bus) // // 1:Negative logic specification (when using conversion board for negative logic -> SCSI logic) // There is no conversion board with this specification at this time // True : 0V -> (CONVERT) -> 0V // False : 3.3V -> (CONVERT) -> Open collector output // // 2:Positive logic specification (when using the conversion board for positive logic -> SCSI logic) // RaSCSI Adapter Rev.C @132sync etc. // // True : 3.3V -> (CONVERT) -> 0V // False : 0V -> (CONVERT) -> Open collector output // //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // // Control signal pin assignment setting // GPIO pin mapping table for control signals. // // Control signal: // PIN_ACT // Signal that indicates the status of processing SCSI command. // PIN_ENB // Signal that indicates the valid signal from start to finish. // PIN_TAD // Signal that indicates the input/output direction of the target signal (BSY,IO,CD,MSG,REG). // PIN_IND // Signal that indicates the input/output direction of the initiator signal (SEL, ATN, RST, ACK). // PIN_DTD // Signal that indicates the input/output direction of the data lines (DT0...DT7,DP). // //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // // Control signal output logic // 0V:FALSE 3.3V:TRUE // // ACT_ON // PIN_ACT signal // ENB_ON // PIN_ENB signal // TAD_IN // PIN_TAD This is the logic when inputting. // IND_IN // PIN_ENB This is the logic when inputting. // DTD_IN // PIN_ENB This is the logic when inputting. // //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // // SCSI signal pin assignment setting // GPIO pin mapping table for SCSI signals. // PIN_DT0~PIN_SEL // //--------------------------------------------------------------------------- #define ALL_SCSI_PINS \ ((1<&) override; // Command receive handshake int ReceiveHandShake(uint8_t *buf, int count) override; // Data receive handshake int SendHandShake(uint8_t *buf, int count, int delay_after_bytes) override; // Data transmission handshake static BUS::phase_t GetPhaseRaw(uint32_t raw_data); // Get the phase based on raw data #ifdef USE_SEL_EVENT_ENABLE // SEL signal interrupt bool PollSelectEvent() override; // SEL signal event polling void ClearSelectEvent() override; // Clear SEL signal event #endif private: // SCSI I/O signal control void MakeTable(); // Create work data void SetControl(int pin, bool ast); // Set Control Signal void SetMode(int pin, int mode); // Set SCSI I/O mode bool GetSignal(int pin) const override; // Get SCSI input signal value void SetSignal(int pin, bool ast) override; // Set SCSI output signal value bool WaitSignal(int pin, int ast); // Wait for a signal to change // Interrupt control void DisableIRQ(); // IRQ Disabled void EnableIRQ(); // IRQ Enabled // GPIO pin functionality settings void PinConfig(int pin, int mode); // GPIO pin direction setting void PullConfig(int pin, int mode); // GPIO pin pull up/down resistor setting void PinSetSignal(int pin, bool ast); // Set GPIO output signal void DrvConfig(uint32_t drive); // Set GPIO drive strength mode_e actmode = mode_e::TARGET; // Operation mode #if !defined(__x86_64__) && !defined(__X86__) uint32_t baseaddr = 0; // Base address #endif int rpitype = 0; // Type of Raspberry Pi volatile uint32_t *gpio = nullptr; // GPIO register volatile uint32_t *pads = nullptr; // PADS register #if !defined(__x86_64__) && !defined(__X86__) volatile uint32_t *level = nullptr; // GPIO input level #endif volatile uint32_t *irpctl = nullptr; // Interrupt control register volatile uint32_t irptenb; // Interrupt enabled state volatile uint32_t *qa7regs = nullptr; // QA7 register volatile int tintcore; // Interupt control target CPU. volatile uint32_t tintctl; // Interupt control volatile uint32_t giccpmr; // GICC priority setting #if !defined(__x86_64__) && !defined(__X86__) volatile uint32_t *gicd = nullptr; // GIC Interrupt distributor register #endif volatile uint32_t *gicc = nullptr; // GIC CPU interface register array gpfsel; // GPFSEL0-4 backup values uint32_t signals = 0; // All bus signals #ifdef USE_SEL_EVENT_ENABLE struct gpioevent_request selevreq = {}; // SEL signal event request int epfd; // epoll file descriptor #endif // USE_SEL_EVENT_ENABLE #if SIGNAL_CONTROL_MODE == 0 array, 3> tblDatMsk; // Data mask table array, 3> tblDatSet; // Data setting table #else array tblDatMsk = {}; // Data mask table array tblDatSet = {}; // Table setting table #endif static const array SignalTable; // signal table };