From 52b619facc421dd55f34fd688604cd29a7c8b4a0 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 13 Sep 2019 01:09:44 +1000 Subject: [PATCH] DMA: Implement block transfers --- src/pse/dma.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/pse/dma.h | 4 ++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/pse/dma.cpp b/src/pse/dma.cpp index 053eff6bd..9e0f5260f 100644 --- a/src/pse/dma.cpp +++ b/src/pse/dma.cpp @@ -228,6 +228,43 @@ void DMA::RunDMA(Channel channel) break; case SyncMode::Request: + { + const u32 block_size = cs.block_control.request.GetBlockSize(); + const u32 block_count = cs.block_control.request.GetBlockCount(); + Log_DebugPrintf(" ... copying %u blocks of size %u %s 0x%08X", block_count, block_size, + copy_to_device ? "from" : "to", current_address); + if (copy_to_device) + { + u32 words_remaining = block_size * block_count; + do + { + words_remaining--; + + u32 value = 0; + m_bus->DispatchAccess(current_address, current_address, + value); + DMAWrite(channel, value, current_address, words_remaining); + + current_address = (current_address + increment) & ADDRESS_MASK; + } while (words_remaining > 0); + } + else + { + u32 words_remaining = block_size * block_count; + do + { + words_remaining--; + + u32 value = DMARead(channel, current_address, words_remaining); + m_bus->DispatchAccess(current_address, current_address, + value); + + current_address = (current_address + increment) & ADDRESS_MASK; + } while (words_remaining > 0); + } + } + break; + default: Panic("Unimplemented sync mode"); break; diff --git a/src/pse/dma.h b/src/pse/dma.h index 987fc9624..8a2282c18 100644 --- a/src/pse/dma.h +++ b/src/pse/dma.h @@ -68,13 +68,13 @@ private: union BlockControl { u32 bits; - struct + union { BitField word_count; u32 GetWordCount() const { return (word_count == 0) ? 0x10000 : word_count; } } manual; - struct + union { BitField block_size; BitField block_count;