Bladeren bron

Remove initiator code from BS2 target

The BlueSCSIv2 board does not have initiator support so the
initiator code from the ZuluSCSI RP2040 was removed from the
the BS2 target to get rid of bloat.
Morio 2 jaren geleden
bovenliggende
commit
600a7d7ea0

+ 26 - 87
lib/ZuluSCSI_platform_BS2/ZuluSCSI_platform.cpp

@@ -95,55 +95,12 @@ void azplatform_init()
 
 }
 
-static bool read_initiator_dip_switch()
-{
-    /* Revision 2022d hardware has problems reading initiator DIP switch setting.
-     * The 74LVT245 hold current is keeping the GPIO_ACK state too strongly.
-     * Detect this condition by toggling the pin up and down and seeing if it sticks.
-     */
-
-    // Strong output high, then pulldown
-    //        pin             function       pup   pdown   out    state  fast
-    gpio_conf(DIP_INITIATOR,  GPIO_FUNC_SIO, false, false, true,  true,  false);
-    gpio_conf(DIP_INITIATOR,  GPIO_FUNC_SIO, false, true,  false, true,  false);
-    delay(1);
-    bool initiator_state1 = gpio_get(DIP_INITIATOR);
-    
-    // Strong output low, then pullup
-    //        pin             function       pup   pdown   out    state  fast
-    gpio_conf(DIP_INITIATOR,  GPIO_FUNC_SIO, false, false, true,  false, false);
-    gpio_conf(DIP_INITIATOR,  GPIO_FUNC_SIO, true,  false, false, false, false);
-    delay(1);
-    bool initiator_state2 = gpio_get(DIP_INITIATOR);
-
-    if (initiator_state1 == initiator_state2)
-    {
-        // Ok, was able to read the state directly
-        return !initiator_state1;
-    }
-
-    // Enable OUT_BSY for a short time.
-    // If in target mode, this will force GPIO_ACK high.
-    gpio_put(SCSI_OUT_BSY, 0);
-    delay_100ns();
-    gpio_put(SCSI_OUT_BSY, 1);
-
-    return !gpio_get(DIP_INITIATOR);
-}
-
 // late_init() only runs in main application, SCSI not needed in bootloader
 void azplatform_late_init()
 {
-    if (read_initiator_dip_switch())
-    {
-        g_scsi_initiator = true;
-        azlog("SCSI initiator mode selected by DIP switch, expecting SCSI disks on the bus");
-    }
-    else
-    {
-        g_scsi_initiator = false;
-        azlog("SCSI target/disk mode selected by DIP switch, acting as a SCSI disk");
-    }
+
+    g_scsi_initiator = false;
+    azlog("SCSI target/disk mode, acting as a SCSI disk");
 
     /* Initialize SCSI pins to required modes.
      * SCSI pins should be inactive / input at this point.
@@ -162,52 +119,35 @@ void azplatform_late_init()
     gpio_conf(SCSI_IO_DB7,    GPIO_FUNC_SIO, true, false, false, true, true);
     gpio_conf(SCSI_IO_DBP,    GPIO_FUNC_SIO, true, false, false, true, true);
 
-    if (!g_scsi_initiator)
-    {
-        // Act as SCSI device / target
-
-        // SCSI control outputs
-        //        pin             function       pup   pdown  out    state fast
-        gpio_conf(SCSI_OUT_IO,    GPIO_FUNC_SIO, false,false, true,  true, true);
-        gpio_conf(SCSI_OUT_MSG,   GPIO_FUNC_SIO, false,false, true,  true, true);
 
-        // REQ pin is switched between PIO and SIO, pull-up makes sure no glitches
-        gpio_conf(SCSI_OUT_REQ,   GPIO_FUNC_SIO, true ,false, true,  true, true);
+    // Act as SCSI device / target
 
-        // Shared pins are changed to input / output depending on communication phase
-        gpio_conf(SCSI_IN_SEL,    GPIO_FUNC_SIO, true, false, false, true, true);
-        if (SCSI_OUT_CD != SCSI_IN_SEL)
-        {
-            gpio_conf(SCSI_OUT_CD,    GPIO_FUNC_SIO, false,false, true,  true, true);
-        }
+    // SCSI control outputs
+    //        pin             function       pup   pdown  out    state fast
+    gpio_conf(SCSI_OUT_IO,    GPIO_FUNC_SIO, false,false, true,  true, true);
+    gpio_conf(SCSI_OUT_MSG,   GPIO_FUNC_SIO, false,false, true,  true, true);
 
-        gpio_conf(SCSI_IN_BSY,    GPIO_FUNC_SIO, true, false, false, true, true);
-        if (SCSI_OUT_MSG != SCSI_IN_BSY)
-        {
-            gpio_conf(SCSI_OUT_MSG,    GPIO_FUNC_SIO, false,false, true,  true, true);
-        }
+    // REQ pin is switched between PIO and SIO, pull-up makes sure no glitches
+    gpio_conf(SCSI_OUT_REQ,   GPIO_FUNC_SIO, true ,false, true,  true, true);
 
-        // SCSI control inputs
-        //        pin             function       pup   pdown  out    state fast
-        gpio_conf(SCSI_IN_ACK,    GPIO_FUNC_SIO, false, false, false, true, false);
-        gpio_conf(SCSI_IN_ATN,    GPIO_FUNC_SIO, false, false, false, true, false);
-        gpio_conf(SCSI_IN_RST,    GPIO_FUNC_SIO, true, false, false, true, false);
+    // Shared pins are changed to input / output depending on communication phase
+    gpio_conf(SCSI_IN_SEL,    GPIO_FUNC_SIO, true, false, false, true, true);
+    if (SCSI_OUT_CD != SCSI_IN_SEL)
+    {
+        gpio_conf(SCSI_OUT_CD,    GPIO_FUNC_SIO, false,false, true,  true, true);
     }
-    else
+
+    gpio_conf(SCSI_IN_BSY,    GPIO_FUNC_SIO, true, false, false, true, true);
+    if (SCSI_OUT_MSG != SCSI_IN_BSY)
     {
-        // Act as SCSI initiator
-
-        //        pin             function       pup   pdown  out    state fast
-        gpio_conf(SCSI_IN_IO,     GPIO_FUNC_SIO, true ,false, false, true, false);
-        gpio_conf(SCSI_IN_MSG,    GPIO_FUNC_SIO, true ,false, false, true, false);
-        gpio_conf(SCSI_IN_CD,     GPIO_FUNC_SIO, true ,false, false, true, false);
-        gpio_conf(SCSI_IN_REQ,    GPIO_FUNC_SIO, true ,false, false, true, false);
-        gpio_conf(SCSI_IN_BSY,    GPIO_FUNC_SIO, true, false, false, true, false);
-        gpio_conf(SCSI_IN_RST,    GPIO_FUNC_SIO, true, false, false, true, false);
-        gpio_conf(SCSI_OUT_SEL,   GPIO_FUNC_SIO, false,false, true,  true, true);
-        gpio_conf(SCSI_OUT_ACK,   GPIO_FUNC_SIO, false,false, true,  true, true);
-        gpio_conf(SCSI_OUT_ATN,   GPIO_FUNC_SIO, false,false, true,  true, true);
+        gpio_conf(SCSI_OUT_MSG,    GPIO_FUNC_SIO, false,false, true,  true, true);
     }
+
+    // SCSI control inputs
+    //        pin             function       pup   pdown  out    state fast
+    gpio_conf(SCSI_IN_ACK,    GPIO_FUNC_SIO, false, false, false, true, false);
+    gpio_conf(SCSI_IN_ATN,    GPIO_FUNC_SIO, false, false, false, true, false);
+    gpio_conf(SCSI_IN_RST,    GPIO_FUNC_SIO, true, false, false, true, false);
 }
 
 bool azplatform_is_initiator_mode_enabled()
@@ -315,7 +255,7 @@ static void watchdog_callback(unsigned alarm_num)
 
     if (g_watchdog_timeout <= WATCHDOG_CRASH_TIMEOUT - WATCHDOG_BUS_RESET_TIMEOUT)
     {
-        if (!scsiDev.resetFlag || !g_scsiHostPhyReset)
+        if (!scsiDev.resetFlag)
         {
             azlog("--------------");
             azlog("WATCHDOG TIMEOUT, attempting bus reset");
@@ -331,7 +271,6 @@ static void watchdog_callback(unsigned alarm_num)
             }
 
             scsiDev.resetFlag = 1;
-            g_scsiHostPhyReset = true;
         }
 
         if (g_watchdog_timeout <= 0)

+ 0 - 2
lib/ZuluSCSI_platform_BS2/ZuluSCSI_platform.h

@@ -5,7 +5,6 @@
 #include <stdint.h>
 #include <Arduino.h>
 #include "ZuluSCSI_platform_gpio.h"
-#include "scsiHostPhy.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -20,7 +19,6 @@ extern const char *g_azplatform_name;
 #define PLATFORM_OPTIMAL_MAX_SD_WRITE_SIZE 65536
 #define PLATFORM_OPTIMAL_LAST_SD_WRITE_SIZE 8192
 #define SD_USE_SDIO 1
-#define PLATFORM_HAS_INITIATOR_MODE 1
 #define PLATFORM_HAS_PARITY_CHECK 1
 
 // NOTE: The driver supports synchronous speeds higher than 10MB/s, but this

+ 0 - 12
lib/ZuluSCSI_platform_BS2/ZuluSCSI_platform_gpio.h

@@ -38,16 +38,6 @@
 #define SCSI_IN_BSY  20
 #define SCSI_IN_RST  21
 
-// Status line outputs for initiator mode
-#define SCSI_OUT_ACK  10
-#define SCSI_OUT_ATN  29
-
-// Status line inputs for initiator mode
-#define SCSI_IN_IO    12
-#define SCSI_IN_CD    11
-#define SCSI_IN_MSG   13
-#define SCSI_IN_REQ   9
-
 // Status LED pins
 #define LED_PIN      25
 #define LED_ON()     sio_hw->gpio_set = 1 << LED_PIN
@@ -68,8 +58,6 @@
 #define SD_SPI_MISO  12
 #define SD_SPI_CS    15
 
-// Initiator setting PIN
-#define DIP_INITIATOR SCSI_OUT_ATN
 
 // Other pins
 #define SWO_PIN 16

+ 0 - 266
lib/ZuluSCSI_platform_BS2/scsiHostPhy.cpp

@@ -1,266 +0,0 @@
-#include "scsiHostPhy.h"
-#include "ZuluSCSI_platform.h"
-#include "ZuluSCSI_log.h"
-#include "ZuluSCSI_log_trace.h"
-#include "scsi_accel_host.h"
-#include <assert.h>
-
-#include <scsi2sd.h>
-extern "C" {
-#include <scsi.h>
-}
-
-volatile int g_scsiHostPhyReset;
-
-// Release bus and pulse RST signal, initialize PHY to host mode.
-void scsiHostPhyReset(void)
-{
-    SCSI_RELEASE_OUTPUTS();
-    SCSI_ENABLE_INITIATOR();
-
-    scsi_accel_host_init();
-
-    SCSI_OUT(RST, 1);
-    delay(2);
-    SCSI_OUT(RST, 0);
-    delay(250);
-    g_scsiHostPhyReset = false;
-}
-
-// Select a device, id 0-7.
-// Returns true if the target answers to selection request.
-bool scsiHostPhySelect(int target_id)
-{
-    SCSI_RELEASE_OUTPUTS();
-
-    // We can't write individual data bus bits, so use a bit modified
-    // arbitration scheme. We always yield to any other initiator on
-    // the bus.
-    scsiLogInitiatorPhaseChange(BUS_BUSY);
-    SCSI_OUT(BSY, 1);
-    for (int wait = 0; wait < 10; wait++)
-    {
-        delayMicroseconds(1);
-
-        if (SCSI_IN_DATA() != 0)
-        {
-            azdbg("scsiHostPhySelect: bus is busy");
-            scsiLogInitiatorPhaseChange(BUS_FREE);
-            SCSI_RELEASE_OUTPUTS();
-            return false;
-        }
-    }
-
-    // Selection phase
-    scsiLogInitiatorPhaseChange(SELECTION);
-    azdbg("------ SELECTING ", target_id);
-    SCSI_OUT(SEL, 1);
-    delayMicroseconds(5);
-    SCSI_OUT_DATA(1 << target_id);
-    delayMicroseconds(5);
-    SCSI_OUT(BSY, 0);
-
-    // Wait for target to respond
-    for (int wait = 0; wait < 2500; wait++)
-    {
-        delayMicroseconds(100);
-        if (SCSI_IN(BSY))
-        {
-            break;
-        }
-    }
-
-    if (!SCSI_IN(BSY))
-    {
-        // No response
-        SCSI_RELEASE_OUTPUTS();
-        return false;
-    }
-
-    // We need to assert OUT_BSY to enable IO buffer U105 to read status signals.
-    SCSI_RELEASE_DATA_REQ();
-    SCSI_OUT(BSY, 1);
-    SCSI_OUT(SEL, 0);
-    return true;
-}
-
-// Read the current communication phase as signaled by the target
-int scsiHostPhyGetPhase()
-{
-    static absolute_time_t last_online_time;
-
-    if (g_scsiHostPhyReset)
-    {
-        // Reset request from watchdog timer
-        scsiHostPhyRelease();
-        return BUS_FREE;
-    }
-
-    int phase = 0;
-    bool req_in = SCSI_IN(REQ);
-    if (SCSI_IN(CD)) phase |= __scsiphase_cd;
-    if (SCSI_IN(IO)) phase |= __scsiphase_io;
-    if (SCSI_IN(MSG)) phase |= __scsiphase_msg;
-
-    if (phase == 0 && absolute_time_diff_us(last_online_time, get_absolute_time()) > 100)
-    {
-        // Disable OUT_BSY for a short time to see if the target is still on line
-        SCSI_OUT(BSY, 0);
-        delayMicroseconds(1);
-
-        if (!SCSI_IN(BSY))
-        {
-            scsiLogInitiatorPhaseChange(BUS_FREE);
-            return BUS_FREE;
-        }
-
-        // Still online, re-enable OUT_BSY to enable IO buffers
-        SCSI_OUT(BSY, 1);
-        last_online_time = get_absolute_time();
-    }
-    else if (phase != 0)
-    {
-        last_online_time = get_absolute_time();
-    }
-
-    if (!req_in)
-    {
-        // Don't act on phase changes until target asserts request signal.
-        // This filters out any spurious changes on control signals.
-        return BUS_BUSY;
-    }
-    else
-    {
-        scsiLogInitiatorPhaseChange(phase);
-        return phase;
-    }
-}
-
-bool scsiHostRequestWaiting()
-{
-    return SCSI_IN(REQ);
-}
-
-// Blocking data transfer
-#define SCSIHOST_WAIT_ACTIVE(pin) \
-  if (!SCSI_IN(pin)) { \
-    if (!SCSI_IN(pin)) { \
-      while(!SCSI_IN(pin) && !g_scsiHostPhyReset); \
-    } \
-  }
-
-#define SCSIHOST_WAIT_INACTIVE(pin) \
-  if (SCSI_IN(pin)) { \
-    if (SCSI_IN(pin)) { \
-      while(SCSI_IN(pin) && !g_scsiHostPhyReset); \
-    } \
-  }
-
-// Write one byte to SCSI target using the handshake mechanism
-static inline void scsiHostWriteOneByte(uint8_t value)
-{
-    SCSIHOST_WAIT_ACTIVE(REQ);
-    SCSI_OUT_DATA(value);
-    delay_100ns(); // DB setup time before ACK
-    SCSI_OUT(ACK, 1);
-    SCSIHOST_WAIT_INACTIVE(REQ);
-    SCSI_RELEASE_DATA_REQ();
-    SCSI_OUT(ACK, 0);
-}
-
-// Read one byte from SCSI target using the handshake mechanism.
-static inline uint8_t scsiHostReadOneByte(int* parityError)
-{
-    SCSIHOST_WAIT_ACTIVE(REQ);
-    uint16_t r = SCSI_IN_DATA();
-    SCSI_OUT(ACK, 1);
-    SCSIHOST_WAIT_INACTIVE(REQ);
-    SCSI_OUT(ACK, 0);
-
-    if (parityError && r != (g_scsi_parity_lookup[r & 0xFF] ^ SCSI_IO_DATA_MASK))
-    {
-        azlog("Parity error in scsiReadOneByte(): ", (uint32_t)r);
-        *parityError = 1;
-    }
-
-    return (uint8_t)r;
-}
-
-uint32_t scsiHostWrite(const uint8_t *data, uint32_t count)
-{
-    scsiLogDataOut(data, count);
-
-    int cd_start = SCSI_IN(CD);
-    int msg_start = SCSI_IN(MSG);
-
-    for (uint32_t i = 0; i < count; i++)
-    {
-        while (!SCSI_IN(REQ))
-        {
-            if (g_scsiHostPhyReset || SCSI_IN(IO) || SCSI_IN(CD) != cd_start || SCSI_IN(MSG) != msg_start)
-            {
-                // Target switched out of DATA_OUT mode
-                azlog("scsiHostWrite: sent ", (int)i, " bytes, expected ", (int)count);
-                return i;
-            }
-        }
-
-        scsiHostWriteOneByte(data[i]);
-    }
-
-    return count;
-}
-
-uint32_t scsiHostRead(uint8_t *data, uint32_t count)
-{
-    int parityError = 0;
-    uint32_t fullcount = count;
-
-    int cd_start = SCSI_IN(CD);
-    int msg_start = SCSI_IN(MSG);
-
-    if ((count & 1) == 0 && ((uint32_t)data & 1) == 0)
-    {
-        // Even number of bytes, use accelerated routine
-        count = scsi_accel_host_read(data, count, &parityError, &g_scsiHostPhyReset);
-    }
-    else
-    {
-        for (uint32_t i = 0; i < count; i++)
-        {
-            while (!SCSI_IN(REQ))
-            {
-                if (g_scsiHostPhyReset || !SCSI_IN(IO) || SCSI_IN(CD) != cd_start || SCSI_IN(MSG) != msg_start)
-                {
-                    // Target switched out of DATA_IN mode
-                    count = i;
-                }
-            }
-
-            data[i] = scsiHostReadOneByte(&parityError);
-        }
-    }
-
-    scsiLogDataIn(data, count);
-
-    if (g_scsiHostPhyReset || parityError)
-    {
-        return 0;
-    }
-    else
-    {
-        if (count < fullcount)
-        {
-            azlog("scsiHostRead: received ", (int)count, " bytes, expected ", (int)fullcount);
-        }
-
-        return count;
-    }
-}
-
-// Release all bus signals
-void scsiHostPhyRelease()
-{
-    scsiLogInitiatorPhaseChange(BUS_FREE);
-    SCSI_RELEASE_OUTPUTS();
-}

+ 0 - 32
lib/ZuluSCSI_platform_BS2/scsiHostPhy.h

@@ -1,32 +0,0 @@
-// Host side SCSI physical interface.
-// Used in initiator to interface to an SCSI drive.
-
-#pragma once
-
-#include <stdint.h>
-#include <stdbool.h>
-
-// Request to stop activity and reset the bus
-extern volatile int g_scsiHostPhyReset;
-
-// Release bus and pulse RST signal, initialize PHY to host mode.
-void scsiHostPhyReset(void);
-
-// Select a device, id 0-7.
-// Returns true if the target answers to selection request.
-bool scsiHostPhySelect(int target_id);
-
-// Read the current communication phase as signaled by the target
-// Matches SCSI_PHASE enumeration from scsi.h.
-int scsiHostPhyGetPhase();
-
-// Returns true if the device has asserted REQ signal, i.e. data waiting
-bool scsiHostRequestWaiting();
-
-// Blocking data transfer
-// These return the actual number of bytes transferred.
-uint32_t scsiHostWrite(const uint8_t *data, uint32_t count);
-uint32_t scsiHostRead(uint8_t *data, uint32_t count);
-
-// Release all bus signals
-void scsiHostPhyRelease();

+ 0 - 141
lib/ZuluSCSI_platform_BS2/scsi_accel_host.cpp

@@ -1,141 +0,0 @@
-// Accelerated SCSI subroutines for SCSI initiator/host side communication
-
-#include "scsi_accel_host.h"
-#include "ZuluSCSI_platform.h"
-#include "ZuluSCSI_log.h"
-#include "scsi_accel_host.pio.h"
-#include <hardware/pio.h>
-#include <hardware/dma.h>
-#include <hardware/irq.h>
-#include <hardware/structs/iobank0.h>
-#include <hardware/sync.h>
-
-#define SCSI_PIO pio0
-#define SCSI_SM 0
-
-static struct {
-    // PIO configurations
-    uint32_t pio_offset_async_read;
-    pio_sm_config pio_cfg_async_read;
-} g_scsi_host;
-
-enum scsidma_state_t { SCSIHOST_IDLE = 0,
-                       SCSIHOST_READ };
-static volatile scsidma_state_t g_scsi_host_state;
-
-static void scsi_accel_host_config_gpio()
-{
-    if (g_scsi_host_state == SCSIHOST_IDLE)
-    {
-        iobank0_hw->io[SCSI_IO_DB0].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB1].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB2].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB3].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB4].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB5].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB6].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB7].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DBP].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_OUT_ACK].ctrl = GPIO_FUNC_SIO;
-    }
-    else if (g_scsi_host_state == SCSIHOST_READ)
-    {
-        // Data bus and REQ as input, ACK pin as output
-        pio_sm_set_pins(SCSI_PIO, SCSI_SM, 0x7FF);
-        pio_sm_set_consecutive_pindirs(SCSI_PIO, SCSI_SM, 0, 10, false);
-        pio_sm_set_consecutive_pindirs(SCSI_PIO, SCSI_SM, 10, 1, true);
-
-        iobank0_hw->io[SCSI_IO_DB0].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB1].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB2].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB3].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB4].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB5].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB6].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DB7].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_IO_DBP].ctrl  = GPIO_FUNC_SIO;
-        iobank0_hw->io[SCSI_OUT_ACK].ctrl = GPIO_FUNC_PIO0;
-    }
-}
-
-uint32_t scsi_accel_host_read(uint8_t *buf, uint32_t count, int *parityError, volatile int *resetFlag)
-{
-    // Currently this method just reads from the PIO RX fifo directly in software loop.
-    // The SD card access is parallelized using DMA, so there is limited benefit from using DMA here.
-    g_scsi_host_state = SCSIHOST_READ;
-
-    int cd_start = SCSI_IN(CD);
-    int msg_start = SCSI_IN(MSG);
-
-    pio_sm_init(SCSI_PIO, SCSI_SM, g_scsi_host.pio_offset_async_read, &g_scsi_host.pio_cfg_async_read);
-    scsi_accel_host_config_gpio();
-    pio_sm_set_enabled(SCSI_PIO, SCSI_SM, true);
-
-    // Set the number of bytes to read, must be divisible by 2.
-    assert((count & 1) == 0);
-    pio_sm_put(SCSI_PIO, SCSI_SM, count - 1);
-
-    // Read results from PIO RX FIFO
-    uint8_t *dst = buf;
-    uint8_t *end = buf + count;
-    uint32_t paritycheck = 0;
-    while (dst < end)
-    {
-        uint32_t available = pio_sm_get_rx_fifo_level(SCSI_PIO, SCSI_SM);
-
-        if (available == 0)
-        {
-            if (*resetFlag || !SCSI_IN(IO) || SCSI_IN(CD) != cd_start || SCSI_IN(MSG) != msg_start)
-            {
-                // Target switched out of DATA_IN mode
-                count = dst - buf;
-                break;
-            }
-        }
-
-        while (available > 0)
-        {
-            available--;
-            uint32_t word = pio_sm_get(SCSI_PIO, SCSI_SM);
-            paritycheck ^= word;
-            word = ~word;
-            *dst++ = word & 0xFF;
-            *dst++ = word >> 16;
-        }
-    }
-
-    // Check parity errors in whole block
-    // This doesn't detect if there is even number of parity errors in block.
-    uint8_t byte0 = ~(paritycheck & 0xFF);
-    uint8_t byte1 = ~(paritycheck >> 16);
-    if (paritycheck != ((g_scsi_parity_lookup[byte1] << 16) | g_scsi_parity_lookup[byte0]))
-    {
-        azlog("Parity error in scsi_accel_host_read(): ", paritycheck);
-        *parityError = 1;
-    }
-
-    g_scsi_host_state = SCSIHOST_IDLE;
-    SCSI_RELEASE_DATA_REQ();
-    scsi_accel_host_config_gpio();
-    pio_sm_set_enabled(SCSI_PIO, SCSI_SM, false);
-
-    return count;
-}
-
-
-void scsi_accel_host_init()
-{
-    g_scsi_host_state = SCSIHOST_IDLE;
-    scsi_accel_host_config_gpio();
-
-    // Load PIO programs
-    pio_clear_instruction_memory(SCSI_PIO);
-
-    // Asynchronous / synchronous SCSI read
-    g_scsi_host.pio_offset_async_read = pio_add_program(SCSI_PIO, &scsi_host_async_read_program);
-    g_scsi_host.pio_cfg_async_read = scsi_host_async_read_program_get_default_config(g_scsi_host.pio_offset_async_read);
-    sm_config_set_in_pins(&g_scsi_host.pio_cfg_async_read, SCSI_IO_DB0);
-    sm_config_set_sideset_pins(&g_scsi_host.pio_cfg_async_read, SCSI_OUT_ACK);
-    sm_config_set_out_shift(&g_scsi_host.pio_cfg_async_read, true, false, 32);
-    sm_config_set_in_shift(&g_scsi_host.pio_cfg_async_read, true, true, 32);
-}

+ 0 - 11
lib/ZuluSCSI_platform_BS2/scsi_accel_host.h

@@ -1,11 +0,0 @@
-// Accelerated SCSI subroutines for SCSI initiator/host side communication
-
-#pragma once
-
-#include <stdint.h>
-
-void scsi_accel_host_init();
-
-// Read data from SCSI bus.
-// Number of bytes to read must be divisible by two.
-uint32_t scsi_accel_host_read(uint8_t *buf, uint32_t count, int *parityError, volatile int *resetFlag);

+ 0 - 26
lib/ZuluSCSI_platform_BS2/scsi_accel_host.pio

@@ -1,26 +0,0 @@
-; RP2040 PIO program for accelerating SCSI initiator / host function
-; Run "pioasm scsi_accel_host.pio scsi_accel_host.pio.h" to regenerate the C header from this.
-; GPIO mapping:
-; - 0-7: DB0-DB7
-; -   8: DBP
-; Side set is ACK pin
-
-.define REQ 9
-.define ACK 10
-
-; Read from SCSI bus using asynchronous handshake.
-; Data is returned as 16-bit words that contain the 8 data bits + 1 parity bit.
-; Number of bytes to receive minus 1 should be written to TX fifo.
-; Number of bytes to receive must be divisible by 2.
-.program scsi_host_async_read
-    .side_set 1
-
-    pull block                  side 1  ; Get number of bytes to receive
-    mov x, osr                  side 1  ; Store to counter X
-
-start:
-    wait 0 gpio REQ             side 1  ; Wait for REQ low
-    in pins, 9                  side 0  ; Assert ACK, read GPIO
-    in null, 7                  side 0  ; Padding bits
-    wait 1 gpio REQ             side 0  ; Wait for REQ high
-    jmp x-- start               side 1  ; Deassert ACK, decrement byte count and jump to start

+ 0 - 44
lib/ZuluSCSI_platform_BS2/scsi_accel_host.pio.h

@@ -1,44 +0,0 @@
-// -------------------------------------------------- //
-// This file is autogenerated by pioasm; do not edit! //
-// -------------------------------------------------- //
-
-#pragma once
-
-#if !PICO_NO_HARDWARE
-#include "hardware/pio.h"
-#endif
-
-// -------------------- //
-// scsi_host_async_read //
-// -------------------- //
-
-#define scsi_host_async_read_wrap_target 0
-#define scsi_host_async_read_wrap 6
-
-static const uint16_t scsi_host_async_read_program_instructions[] = {
-            //     .wrap_target
-    0x90a0, //  0: pull   block           side 1     
-    0xb027, //  1: mov    x, osr          side 1     
-    0x3009, //  2: wait   0 gpio, 9       side 1     
-    0x4009, //  3: in     pins, 9         side 0     
-    0x4067, //  4: in     null, 7         side 0     
-    0x2089, //  5: wait   1 gpio, 9       side 0     
-    0x1042, //  6: jmp    x--, 2          side 1     
-            //     .wrap
-};
-
-#if !PICO_NO_HARDWARE
-static const struct pio_program scsi_host_async_read_program = {
-    .instructions = scsi_host_async_read_program_instructions,
-    .length = 7,
-    .origin = -1,
-};
-
-static inline pio_sm_config scsi_host_async_read_program_get_default_config(uint offset) {
-    pio_sm_config c = pio_get_default_sm_config();
-    sm_config_set_wrap(&c, offset + scsi_host_async_read_wrap_target, offset + scsi_host_async_read_wrap);
-    sm_config_set_sideset(&c, 1, false, false);
-    return c;
-}
-#endif
-