From f3baee2582c38cffcde665334012439b773d6003 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 11 Nov 2019 20:37:11 +1000 Subject: [PATCH] DMA: Hack for self-referencing DMA loops I need to figure how these are being generated in the first place. --- src/core/dma.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core/dma.cpp b/src/core/dma.cpp index 20c0cd27e..2cc78e031 100644 --- a/src/core/dma.cpp +++ b/src/core/dma.cpp @@ -283,10 +283,16 @@ void DMA::TransferChannel(Channel channel) const u32 next_address = header & UINT32_C(0x00FFFFFF); Log_TracePrintf(" .. linked list entry at 0x%08X size=%u(%u words) next=0x%08X", current_address, word_count * UINT32_C(4), word_count, next_address); - current_address += sizeof(header); - if (word_count > 0) - TransferMemoryToDevice(channel, current_address & ADDRESS_MASK, 4, word_count); + TransferMemoryToDevice(channel, (current_address + sizeof(header)) & ADDRESS_MASK, 4, word_count); + + // Self-referencing DMA loops.. not sure how these are happening? + if (current_address == next_address) + { + Log_ErrorPrintf("HACK: Aborting self-referencing DMA loop @ 0x%08X. Something went wrong to generate this.", + current_address); + break; + } current_address = next_address; if (current_address & UINT32_C(0x800000))