From ad418c19cd4ca9a80820593609b786c6993b2eda Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 29 Jun 2011 14:35:10 +0300 Subject: dma: don't generate irqs after aborted DMA An idea from Shalma. Verified on real thing with DMA2. --- libpcsxcore/cdrom.c | 7 +++++-- libpcsxcore/mdec.c | 34 ++++++++++++++++++---------------- libpcsxcore/psxdma.c | 21 +++++++++++++++------ 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index 33b76fa..1569839 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -2018,8 +2018,11 @@ void psxDma3(u32 madr, u32 bcr, u32 chcr) { void cdrDmaInterrupt() { - HW_DMA3_CHCR &= SWAP32(~0x01000000); - DMA_INTERRUPT(3); + if (HW_DMA3_CHCR & SWAP32(0x01000000)) + { + HW_DMA3_CHCR &= SWAP32(~0x01000000); + DMA_INTERRUPT(3); + } } void cdrReset() { diff --git a/libpcsxcore/mdec.c b/libpcsxcore/mdec.c index b25b961..6cf2886 100644 --- a/libpcsxcore/mdec.c +++ b/libpcsxcore/mdec.c @@ -531,8 +531,11 @@ void psxDma0(u32 adr, u32 bcr, u32 chcr) { void mdec0Interrupt() { - HW_DMA0_CHCR &= SWAP32(~0x01000000); - DMA_INTERRUPT(0); + if (HW_DMA0_CHCR & SWAP32(0x01000000)) + { + HW_DMA0_CHCR &= SWAP32(~0x01000000); + DMA_INTERRUPT(0); + } } #define SIZE_OF_24B_BLOCK (16*16*3) @@ -651,22 +654,21 @@ void mdec1Interrupt() { * */ - /* this else if avoid to read outside memory */ - if(mdec.rl >= mdec.rl_end) { - mdec.reg1 &= ~MDEC1_STP; - HW_DMA0_CHCR &= SWAP32(~0x01000000); - DMA_INTERRUPT(0); - mdec.reg1 &= ~MDEC1_BUSY; - } else if (SWAP16(*(mdec.rl)) == MDEC_END_OF_DATA) { - mdec.reg1 &= ~MDEC1_STP; - HW_DMA0_CHCR &= SWAP32(~0x01000000); - DMA_INTERRUPT(0); - mdec.reg1 &= ~MDEC1_BUSY; + /* MDEC_END_OF_DATA avoids read outside memory */ + if (mdec.rl >= mdec.rl_end || SWAP16(*(mdec.rl)) == MDEC_END_OF_DATA) { + mdec.reg1 &= ~(MDEC1_STP|MDEC1_BUSY); + if (HW_DMA0_CHCR & SWAP32(0x01000000)) + { + HW_DMA0_CHCR &= SWAP32(~0x01000000); + DMA_INTERRUPT(0); + } } - HW_DMA1_CHCR &= SWAP32(~0x01000000); - DMA_INTERRUPT(1); - return; + if (HW_DMA1_CHCR & SWAP32(0x01000000)) + { + HW_DMA1_CHCR &= SWAP32(~0x01000000); + DMA_INTERRUPT(1); + } } int mdecFreeze(gzFile f, int Mode) { diff --git a/libpcsxcore/psxdma.c b/libpcsxcore/psxdma.c index df79b6d..6d7981f 100644 --- a/libpcsxcore/psxdma.c +++ b/libpcsxcore/psxdma.c @@ -27,8 +27,11 @@ // Dma3 in CdRom.c void spuInterrupt() { - HW_DMA4_CHCR &= SWAP32(~0x01000000); - DMA_INTERRUPT(4); + if (HW_DMA4_CHCR & SWAP32(0x01000000)) + { + HW_DMA4_CHCR &= SWAP32(~0x01000000); + DMA_INTERRUPT(4); + } } void psxDma4(u32 madr, u32 bcr, u32 chcr) { // SPU @@ -192,8 +195,11 @@ void psxDma2(u32 madr, u32 bcr, u32 chcr) { // GPU } void gpuInterrupt() { - HW_DMA2_CHCR &= SWAP32(~0x01000000); - DMA_INTERRUPT(2); + if (HW_DMA2_CHCR & SWAP32(0x01000000)) + { + HW_DMA2_CHCR &= SWAP32(~0x01000000); + DMA_INTERRUPT(2); + } } void psxDma6(u32 madr, u32 bcr, u32 chcr) { @@ -239,6 +245,9 @@ void psxDma6(u32 madr, u32 bcr, u32 chcr) { void gpuotcInterrupt() { - HW_DMA6_CHCR &= SWAP32(~0x01000000); - DMA_INTERRUPT(6); + if (HW_DMA6_CHCR & SWAP32(0x01000000)) + { + HW_DMA6_CHCR &= SWAP32(~0x01000000); + DMA_INTERRUPT(6); + } } -- cgit v1.2.3