From 9c8c1a6f406aec432756ca19fdb4b8451bcd7260 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Wed, 2 Apr 2025 21:47:32 +0200 Subject: [PATCH] Trantor SCSI changes of the day (April 2nd, 2025) 1. The PAS SCSI controller driver mamv1.sys dislikes having bits 0-6 set when a transfer has completed, take account from this, fixes mamv1.sys incomplete CD transfers (bits 0-6 get re-enabled when the transfer is ongoing). 2. I now understand why the T128 doesn't have a block count register, it does the block count manually from the SCSI layer directly, this fixes Pseudo-DMA transfers when using, e.g.: CD transfers using a sector size of 2340 bytes. --- src/include/86box/scsi_device.h | 3 ++- src/include/86box/scsi_t128.h | 3 ++- src/scsi/scsi_t128.c | 29 +++++++++++------------------ src/sound/snd_pas16.c | 9 ++++++++- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/include/86box/scsi_device.h b/src/include/86box/scsi_device.h index 62da8b7dc..289201b04 100644 --- a/src/include/86box/scsi_device.h +++ b/src/include/86box/scsi_device.h @@ -467,9 +467,10 @@ typedef struct scsi_bus_t { int msgout_pos; int is_msgout; int state; - int dma_on_pio_enabled; uint32_t bus_phase; + uint32_t total_len; + uint32_t data_repeat; double period; double speed; diff --git a/src/include/86box/scsi_t128.h b/src/include/86box/scsi_t128.h index 65148a5d1..a3bc79335 100644 --- a/src/include/86box/scsi_t128.h +++ b/src/include/86box/scsi_t128.h @@ -30,7 +30,7 @@ typedef struct t128_t { uint8_t status; uint8_t buffer[512]; uint8_t ext_ram[0x80]; - uint8_t block_count; + uint32_t block_count; int block_loaded; int pos, host_pos; @@ -39,6 +39,7 @@ typedef struct t128_t { int bios_enabled; uint8_t pos_regs[8]; + int type; pc_timer_t timer; } t128_t; diff --git a/src/scsi/scsi_t128.c b/src/scsi/scsi_t128.c index 3f273d1bb..94166054c 100644 --- a/src/scsi/scsi_t128.c +++ b/src/scsi/scsi_t128.c @@ -130,12 +130,12 @@ t128_read(uint32_t addr, void *priv) (t128->host_pos < MIN(512, dev->buffer_length))) { ret = t128->buffer[t128->host_pos++]; - t128_log("T128 Read transfer: pos=%i, addr=%x.\n", - t128->host_pos, addr & 0x1ff); + t128_log("T128 Read transfer: pos=%i, addr=%x, enabled timer=%d.\n", + t128->host_pos, addr & 0x1ff, timer_is_enabled(&t128->timer)); if (t128->host_pos == MIN(512, dev->buffer_length)) { - t128_log("T128 Transfer busy read, status=%02x, period=%lf, enabled=%d.\n", - t128->status, scsi_bus->period, timer_is_enabled(&t128->timer)); + t128_log("T128 Transfer busy read, status=%02x, period=%lf, enabled=%d, block=%d.\n", + t128->status, scsi_bus->period, timer_is_enabled(&t128->timer), scsi_bus->data_pos); t128->status &= ~0x04; if (!t128->block_loaded) { @@ -192,10 +192,6 @@ t128_dma_send_ext(void *priv, void *ext_priv) t128_log("T128 DMA OUT, len=%d.\n", dev->buffer_length); memset(t128->buffer, 0, MIN(512, dev->buffer_length)); t128->host_pos = 0; - t128->block_count = dev->buffer_length >> 9; - - if (dev->buffer_length < 512) - t128->block_count = 1; t128->block_loaded = 1; t128->status |= 0x04; @@ -215,10 +211,6 @@ t128_dma_initiator_receive_ext(void *priv, void *ext_priv) t128_log("T128 DMA IN, len=%d.\n", dev->buffer_length); memset(t128->buffer, 0, MIN(512, dev->buffer_length)); t128->host_pos = MIN(512, dev->buffer_length); - t128->block_count = dev->buffer_length >> 9; - - if (dev->buffer_length < 512) - t128->block_count = 1; t128->block_loaded = 1; t128->status &= ~0x04; @@ -295,9 +287,9 @@ t128_callback(void *priv) t128->status &= ~0x02; t128->pos = 0; t128->host_pos = 0; - t128->block_count = (t128->block_count - 1) & 0xff; + scsi_bus->data_repeat = 0; t128_log("T128 Remaining blocks to be written=%d\n", t128->block_count); - if (!t128->block_count) { + if (scsi_bus->data_pos >= dev->buffer_length) { t128->block_loaded = 0; ncr->tcr |= TCR_LAST_BYTE_SENT; ncr->isr |= STATUS_END_OF_DMA; @@ -344,11 +336,11 @@ t128_callback(void *priv) t128->status &= ~0x02; t128->pos = 0; t128->host_pos = 0; - t128->block_count = (t128->block_count - 1) & 0xff; - t128_log("T128 Remaining blocks to be read=%d\n", t128->block_count); - if (!t128->block_count) { - t128->block_loaded = 0; + scsi_bus->data_repeat = 0; + t128_log("T128 blocks read=%d, total len=%d\n", scsi_bus->data_pos, dev->buffer_length); + if (scsi_bus->data_pos >= dev->buffer_length) { scsi_bus->bus_out |= BUS_REQ; + t128->block_loaded = 0; timer_on_auto(&t128->timer, 10.0); t128_log("IO End of read transfer\n"); } @@ -472,6 +464,7 @@ t128_init(const device_t *info) ncr->bus = scsi_get_bus(); scsi_bus = &ncr->scsibus; + t128->type = info->local; if (info->flags & DEVICE_MCA) { rom_init(&t128->bios_rom, T128_ROM, diff --git a/src/sound/snd_pas16.c b/src/sound/snd_pas16.c index 675582367..dd95eac4c 100644 --- a/src/sound/snd_pas16.c +++ b/src/sound/snd_pas16.c @@ -792,7 +792,14 @@ pas16_in(uint16_t port, void *priv) if ((scsi_bus->tx_mode == PIO_TX_BUS) && !(ret & 0x80)) ret |= 0x80; - pas16_log("5C01 read ret=%02x, status=%02x, txmode=%x.\n", ret, pas16->scsi->status & 0x06, scsi_bus->tx_mode); + if (ret & 0x80) { + if (scsi_bus->data_repeat < MIN(511, scsi_bus->total_len)) + scsi_bus->data_repeat++; + } else { + if (scsi_bus->data_repeat == MIN(511, scsi_bus->total_len)) + ret = 0x00; + } + pas16_log("%04X:%08X: Port %04x read ret=%02x, status=%02x, txmode=%x, repeat=%d.\n", CS, cpu_state.pc, port + pas16->base, ret, pas16->scsi->status & 0x06, scsi_bus->tx_mode, scsi_bus->data_repeat); } break; case 0x5c03: