|
@@ -114,10 +114,45 @@ static struct {
|
|
|
enum scsidma_state_t { SCSIDMA_IDLE = 0,
|
|
enum scsidma_state_t { SCSIDMA_IDLE = 0,
|
|
|
SCSIDMA_WRITE, SCSIDMA_WRITE_DONE,
|
|
SCSIDMA_WRITE, SCSIDMA_WRITE_DONE,
|
|
|
SCSIDMA_READ, SCSIDMA_READ_DONE };
|
|
SCSIDMA_READ, SCSIDMA_READ_DONE };
|
|
|
|
|
+static const char* scsidma_states[5] = {"IDLE", "WRITE", "WRITE_DONE", "READ", "READ_DONE"};
|
|
|
static volatile scsidma_state_t g_scsi_dma_state;
|
|
static volatile scsidma_state_t g_scsi_dma_state;
|
|
|
static bool g_channels_claimed = false;
|
|
static bool g_channels_claimed = false;
|
|
|
static void scsidma_config_gpio();
|
|
static void scsidma_config_gpio();
|
|
|
|
|
|
|
|
|
|
+void scsi_accel_log_state()
|
|
|
|
|
+{
|
|
|
|
|
+ logmsg("SCSI DMA state: ", scsidma_states[g_scsi_dma_state]);
|
|
|
|
|
+ logmsg("Current buffer: ", g_scsi_dma.dma_bytes, "/", g_scsi_dma.app_bytes, ", next ", g_scsi_dma.next_app_bytes, " bytes");
|
|
|
|
|
+ logmsg("SyncOffset: ", g_scsi_dma.syncOffset, " SyncPeriod ", g_scsi_dma.syncPeriod);
|
|
|
|
|
+ logmsg("PIO Parity SM:",
|
|
|
|
|
+ " tx_fifo ", (int)pio_sm_get_tx_fifo_level(SCSI_DMA_PIO, SCSI_PARITY_SM),
|
|
|
|
|
+ ", rx_fifo ", (int)pio_sm_get_rx_fifo_level(SCSI_DMA_PIO, SCSI_PARITY_SM),
|
|
|
|
|
+ ", pc ", (int)pio_sm_get_pc(SCSI_DMA_PIO, SCSI_PARITY_SM),
|
|
|
|
|
+ ", instr ", SCSI_DMA_PIO->sm[SCSI_PARITY_SM].instr);
|
|
|
|
|
+ logmsg("PIO Data SM:",
|
|
|
|
|
+ " tx_fifo ", (int)pio_sm_get_tx_fifo_level(SCSI_DMA_PIO, SCSI_DATA_SM),
|
|
|
|
|
+ ", rx_fifo ", (int)pio_sm_get_rx_fifo_level(SCSI_DMA_PIO, SCSI_DATA_SM),
|
|
|
|
|
+ ", pc ", (int)pio_sm_get_pc(SCSI_DMA_PIO, SCSI_DATA_SM),
|
|
|
|
|
+ ", instr ", SCSI_DMA_PIO->sm[SCSI_DATA_SM].instr);
|
|
|
|
|
+ logmsg("PIO Sync SM:",
|
|
|
|
|
+ " tx_fifo ", (int)pio_sm_get_tx_fifo_level(SCSI_DMA_PIO, SCSI_SYNC_SM),
|
|
|
|
|
+ ", rx_fifo ", (int)pio_sm_get_rx_fifo_level(SCSI_DMA_PIO, SCSI_SYNC_SM),
|
|
|
|
|
+ ", pc ", (int)pio_sm_get_pc(SCSI_DMA_PIO, SCSI_SYNC_SM),
|
|
|
|
|
+ ", instr ", SCSI_DMA_PIO->sm[SCSI_SYNC_SM].instr);
|
|
|
|
|
+ logmsg("DMA CH A:",
|
|
|
|
|
+ " ctrl: ", dma_hw->ch[SCSI_DMA_CH_A].ctrl_trig,
|
|
|
|
|
+ " count: ", dma_hw->ch[SCSI_DMA_CH_A].transfer_count);
|
|
|
|
|
+ logmsg("DMA CH B:",
|
|
|
|
|
+ " ctrl: ", dma_hw->ch[SCSI_DMA_CH_B].ctrl_trig,
|
|
|
|
|
+ " count: ", dma_hw->ch[SCSI_DMA_CH_B].transfer_count);
|
|
|
|
|
+ logmsg("DMA CH C:",
|
|
|
|
|
+ " ctrl: ", dma_hw->ch[SCSI_DMA_CH_C].ctrl_trig,
|
|
|
|
|
+ " count: ", dma_hw->ch[SCSI_DMA_CH_C].transfer_count);
|
|
|
|
|
+ logmsg("DMA CH D:",
|
|
|
|
|
+ " ctrl: ", dma_hw->ch[SCSI_DMA_CH_D].ctrl_trig,
|
|
|
|
|
+ " count: ", dma_hw->ch[SCSI_DMA_CH_D].transfer_count);
|
|
|
|
|
+ logmsg("GPIO states: ", sio_hw->gpio_in);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
/****************************************/
|
|
/****************************************/
|
|
|
/* Accelerated writes to SCSI bus */
|
|
/* Accelerated writes to SCSI bus */
|
|
@@ -371,10 +406,8 @@ static void scsi_accel_rp2040_stopWrite(volatile int *resetFlag)
|
|
|
{
|
|
{
|
|
|
if ((uint32_t)(millis() - start) > 5000)
|
|
if ((uint32_t)(millis() - start) > 5000)
|
|
|
{
|
|
{
|
|
|
- logmsg("scsi_accel_rp2040_stopWrite() timeout, FIFO levels ",
|
|
|
|
|
- (int)pio_sm_get_tx_fifo_level(SCSI_DMA_PIO, SCSI_DATA_SM), " ",
|
|
|
|
|
- (int)pio_sm_get_rx_fifo_level(SCSI_DMA_PIO, SCSI_DATA_SM), " PC ",
|
|
|
|
|
- (int)pio_sm_get_pc(SCSI_DMA_PIO, SCSI_DATA_SM));
|
|
|
|
|
|
|
+ logmsg("scsi_accel_rp2040_stopWrite() timeout");
|
|
|
|
|
+ scsi_accel_log_state();
|
|
|
*resetFlag = 1;
|
|
*resetFlag = 1;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -400,12 +433,8 @@ void scsi_accel_rp2040_finishWrite(volatile int *resetFlag)
|
|
|
{
|
|
{
|
|
|
if ((uint32_t)(millis() - start) > 5000)
|
|
if ((uint32_t)(millis() - start) > 5000)
|
|
|
{
|
|
{
|
|
|
- logmsg("scsi_accel_rp2040_finishWrite() timeout,"
|
|
|
|
|
- " state: ", (int)g_scsi_dma_state, " ", (int)g_scsi_dma.dma_bytes, "/", (int)g_scsi_dma.app_bytes, ", ", (int)g_scsi_dma.next_app_bytes,
|
|
|
|
|
- " PIO PC: ", (int)pio_sm_get_pc(SCSI_DMA_PIO, SCSI_DATA_SM), " ", (int)pio_sm_get_pc(SCSI_DMA_PIO, SCSI_SYNC_SM),
|
|
|
|
|
- " PIO FIFO: ", (int)pio_sm_get_tx_fifo_level(SCSI_DMA_PIO, SCSI_DATA_SM), " ", (int)pio_sm_get_tx_fifo_level(SCSI_DMA_PIO, SCSI_SYNC_SM),
|
|
|
|
|
- " DMA counts: ", dma_hw->ch[SCSI_DMA_CH_A].transfer_count, " ", dma_hw->ch[SCSI_DMA_CH_B].transfer_count,
|
|
|
|
|
- " ", dma_hw->ch[SCSI_DMA_CH_C].transfer_count, " ", dma_hw->ch[SCSI_DMA_CH_D].transfer_count);
|
|
|
|
|
|
|
+ logmsg("scsi_accel_rp2040_finishWrite() timeout");
|
|
|
|
|
+ scsi_accel_log_state();
|
|
|
*resetFlag = 1;
|
|
*resetFlag = 1;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -692,12 +721,8 @@ void scsi_accel_rp2040_finishRead(const uint8_t *data, uint32_t count, int *pari
|
|
|
{
|
|
{
|
|
|
if ((uint32_t)(millis() - start) > 5000)
|
|
if ((uint32_t)(millis() - start) > 5000)
|
|
|
{
|
|
{
|
|
|
- logmsg("scsi_accel_rp2040_finishRead timeout,"
|
|
|
|
|
- " state: ", (int)g_scsi_dma_state, " ", (int)g_scsi_dma.dma_bytes, "/", (int)g_scsi_dma.app_bytes, ", ", (int)g_scsi_dma.next_app_bytes,
|
|
|
|
|
- " PIO PC: ", (int)pio_sm_get_pc(SCSI_DMA_PIO, SCSI_DATA_SM), " ", (int)pio_sm_get_pc(SCSI_DMA_PIO, SCSI_SYNC_SM),
|
|
|
|
|
- " PIO FIFO: ", (int)pio_sm_get_rx_fifo_level(SCSI_DMA_PIO, SCSI_DATA_SM), " ", (int)pio_sm_get_tx_fifo_level(SCSI_DMA_PIO, SCSI_DATA_SM),
|
|
|
|
|
- " DMA counts: ", dma_hw->ch[SCSI_DMA_CH_A].transfer_count, " ", dma_hw->ch[SCSI_DMA_CH_B].transfer_count,
|
|
|
|
|
- " ", dma_hw->ch[SCSI_DMA_CH_C].transfer_count, " ", dma_hw->ch[SCSI_DMA_CH_D].transfer_count);
|
|
|
|
|
|
|
+ logmsg("scsi_accel_rp2040_finishRead timeout");
|
|
|
|
|
+ scsi_accel_log_state();
|
|
|
*resetFlag = 1;
|
|
*resetFlag = 1;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -961,6 +986,7 @@ bool scsi_accel_rp2040_setSyncMode(int syncOffset, int syncPeriod)
|
|
|
if (g_scsi_dma_state != SCSIDMA_IDLE)
|
|
if (g_scsi_dma_state != SCSIDMA_IDLE)
|
|
|
{
|
|
{
|
|
|
logmsg("ERROR: SCSI DMA was in state ", (int)g_scsi_dma_state, " when changing sync mode, forcing bus reset");
|
|
logmsg("ERROR: SCSI DMA was in state ", (int)g_scsi_dma_state, " when changing sync mode, forcing bus reset");
|
|
|
|
|
+ scsi_accel_log_state();
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|