Revised dmaGetAddr. Fixed a thread error message.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2337 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-12-11 04:15:50 +00:00
parent 6167067791
commit d7c0cb64d3
9 changed files with 57 additions and 44 deletions

View File

@ -543,26 +543,39 @@ static __forceinline void throwBusError(const char *s)
dmacRegs->stat.BEIS = true;
}
static __forceinline bool inScratchpad(u32 addr)
{
return ((addr >=0x70000000) && (addr <= 0x70003fff));
}
// Note: Dma addresses are guaranteed to be aligned to 16 bytes (128 bits)
static __forceinline void *dmaGetAddr(u32 addr) {
u8 *ptr;
static __forceinline tDMA_TAG *dmaGetAddr(u32 addr)
{
tDMA_TAG *ptr;
// if (addr & 0xf) { DMA_LOG("*PCSX2*: DMA address not 128bit aligned: %8.8x", addr); }
// if (addr & 0xf) { DMA_LOG("*PCSX2*: DMA address not 128bit aligned: %8.8x", addr); }
// Need to check the physical address as well as just the "SPR" flag, as VTLB doesnt seem to handle it
if ((addr & 0x80000000) || (addr & 0x70000000) == 0x70000000) return (void*)&psS[addr & 0x3ff0];
if (DMA_TAG(addr).SPR) return (tDMA_TAG*)&psS[addr & 0x3ff0];
ptr = (u8*)vtlb_GetPhyPtr(addr&0x1FFFFFF0);
if (ptr == NULL) {
// Need to check the physical address as well as just the "SPR" flag, as VTLB doesn't seem to handle it.--refraction
if (inScratchpad(addr))
{
//Console.Warning("Writing to the scratchpad without the SPR flag set!");
return (tDMA_TAG*)&psS[addr & 0x3ff0];
}
ptr = (tDMA_TAG*)vtlb_GetPhyPtr(addr & 0x1FFFFFF0);
if (ptr == NULL)
{
Console.Error( "*PCSX2*: DMA error: %8.8x", addr);
return NULL;
}
return ptr;
}
static __forceinline u32 *_dmaGetAddr(DMACh *dma, u32 addr, u32 num)
static __forceinline tDMA_TAG *safeDmaGetAddr(DMACh *dma, u32 addr, u32 num)
{
u32 *ptr = (u32*)dmaGetAddr(addr);
tDMA_TAG *ptr = dmaGetAddr(addr);
if (ptr == NULL)
{
// DMA Error

View File

@ -116,7 +116,7 @@ int _GIFchain()
u32 qwc = min( gifsplit, (int)gif->qwc );
tDMA_TAG *pMem;
pMem = (tDMA_TAG*)dmaGetAddr(gif->madr);
pMem = dmaGetAddr(gif->madr);
if (pMem == NULL)
{
// reset path3, fixes dark cloud 2
@ -154,7 +154,7 @@ static __forceinline bool checkTieBit(tDMA_TAG* &ptag)
static __forceinline tDMA_TAG* ReadTag()
{
tDMA_TAG* ptag = (tDMA_TAG*)dmaGetAddr(gif->tadr); //Set memory pointer to TADR
tDMA_TAG* ptag = dmaGetAddr(gif->tadr); //Set memory pointer to TADR
if (!(gif->transfer("Gif", ptag))) return NULL;
@ -167,7 +167,7 @@ static __forceinline tDMA_TAG* ReadTag()
static __forceinline tDMA_TAG* ReadTag2()
{
tDMA_TAG* ptag = (tDMA_TAG*)dmaGetAddr(gif->tadr); //Set memory pointer to TADR
tDMA_TAG* ptag = dmaGetAddr(gif->tadr); //Set memory pointer to TADR
gif->unsafeTransfer(ptag);
gif->madr = ptag[1]._u32;
@ -294,7 +294,7 @@ void GIFdma()
if ((!gspath3done) && (gif->qwc == 0))
{
ptag = (tDMA_TAG*)dmaGetAddr(gif->tadr); //Set memory pointer to TADR
ptag = dmaGetAddr(gif->tadr); //Set memory pointer to TADR
gif->unsafeTransfer(ptag);
gif->madr = ptag[1]._u32;
@ -411,7 +411,7 @@ static __forceinline bool mfifoGIFchain()
{
int mfifoqwc;
tDMA_TAG *pMem = (tDMA_TAG*)dmaGetAddr(gif->madr);
tDMA_TAG *pMem = dmaGetAddr(gif->madr);
if (pMem == NULL) return false;
mfifoqwc = WRITERING_DMA(pMem, gif->qwc);
@ -458,7 +458,7 @@ void mfifoGIFtransfer(int qwc)
gif->tadr = qwctag(gif->tadr);
ptag = (tDMA_TAG*)dmaGetAddr(gif->tadr);
ptag = dmaGetAddr(gif->tadr);
gif->unsafeTransfer(ptag);
gif->madr = ptag[1]._u32;

View File

@ -1352,7 +1352,7 @@ static __forceinline bool IPU1chain(int &totalqwc)
int qwc = ipu1dma->qwc;
tDMA_TAG *pMem;
pMem = (tDMA_TAG*)dmaGetAddr(ipu1dma->madr);
pMem = dmaGetAddr(ipu1dma->madr);
if (pMem == NULL)
{
@ -1485,7 +1485,7 @@ int IPU1dma()
if (ipu1dma->chcr.TIE && tag.IRQ)
{
ptag = (tDMA_TAG*)dmaGetAddr(ipu1dma->tadr);
ptag = dmaGetAddr(ipu1dma->tadr);
ipuDmacPartialChain(tag);
@ -1528,7 +1528,7 @@ int IPU1dma()
else
{
// Chain Mode & ipu1dma->qwc is 0
ptag = (tDMA_TAG*)dmaGetAddr(ipu1dma->tadr); //Set memory pointer to TADR
ptag = dmaGetAddr(ipu1dma->tadr); //Set memory pointer to TADR
// Transfer the tag.
if (!ipu1dma->transfer("IPU1", ptag)) return totalqwc;
@ -1553,7 +1553,7 @@ int IPU1dma()
if (done)
{
ptag = (tDMA_TAG*)dmaGetAddr(ipu1dma->tadr);
ptag = dmaGetAddr(ipu1dma->tadr);
ipuDmacPartialChain(ptag[0]);
@ -1665,7 +1665,7 @@ int IPU0dma()
pxAssert(ipu0dma->chcr.MOD == NORMAL_MODE);
pMem = (tDMA_TAG*)dmaGetAddr(ipu0dma->madr);
pMem = dmaGetAddr(ipu0dma->madr);
readsize = min(ipu0dma->qwc, (u16)ipuRegs->ctrl.OFC);
totalsize+=readsize;

View File

@ -52,7 +52,7 @@ int _SPR0chain()
tDMA_TAG *pMem;
if (spr0->qwc == 0) return 0;
pMem = (tDMA_TAG*)dmaGetAddr(spr0->madr);
pMem = dmaGetAddr(spr0->madr);
if (pMem == NULL) return -1;
switch (dmacRegs->ctrl.MFD)
@ -107,7 +107,7 @@ void _SPR0interleave()
{
spr0->qwc = std::min(tqwc, qwc);
qwc -= spr0->qwc;
pMem = (tDMA_TAG*)dmaGetAddr(spr0->madr);
pMem = dmaGetAddr(spr0->madr);
switch (dmacRegs->ctrl.MFD)
{
@ -287,7 +287,7 @@ int _SPR1chain()
if (spr1->qwc == 0) return 0;
pMem = (tDMA_TAG*)dmaGetAddr(spr1->madr);
pMem = dmaGetAddr(spr1->madr);
if (pMem == NULL) return -1;
SPR1transfer((u32*)pMem, spr1->qwc << 2);
@ -317,7 +317,7 @@ void _SPR1interleave()
{
spr1->qwc = std::min(tqwc, qwc);
qwc -= spr1->qwc;
pMem = (tDMA_TAG*)dmaGetAddr(spr1->madr);
pMem = dmaGetAddr(spr1->madr);
memcpy_fast(&psSu8(spr1->sadr), (u8*)pMem, spr1->qwc << 4);
spr1->sadr += spr1->qwc * 16;
spr1->madr += (sqwc + spr1->qwc) * 16;
@ -353,7 +353,7 @@ void _dmaSPR1() // toSPR work function
}
// Chain Mode
ptag = (tDMA_TAG*)dmaGetAddr(spr1->tadr); //Set memory pointer to TADR
ptag = dmaGetAddr(spr1->tadr); //Set memory pointer to TADR
if (!spr1->transfer("SPR1 Tag", ptag))
{
@ -387,7 +387,7 @@ void _dmaSPR1() // toSPR work function
spr1finished = done;
if (!done)
{
ptag = (tDMA_TAG*)dmaGetAddr(spr1->tadr); //Set memory pointer to TADR
ptag = dmaGetAddr(spr1->tadr); //Set memory pointer to TADR
CPU_INT(9, (ptag[0].QWC / BIAS));// the lower 16 bits of the tag / BIAS);
}
break;
@ -411,7 +411,7 @@ void dmaSPR1() // toSPR
if ((spr1->chcr.MOD == CHAIN_MODE) && (spr1->qwc == 0))
{
tDMA_TAG *ptag;
ptag = (tDMA_TAG*)dmaGetAddr(spr1->tadr); //Set memory pointer to TADR
ptag = dmaGetAddr(spr1->tadr); //Set memory pointer to TADR
CPU_INT(9, ptag[0].QWC / BIAS);
return;
}

View File

@ -179,7 +179,7 @@ __forceinline void SIF0Dma()
//SIF_LOG(" EE SIF doing transfer %04Xqw to %08X", readSize, sif0dma->madr);
SIF_LOG("----------- %lX of %lX", readSize << 2, size << 2);
ptag = (tDMA_TAG*)_dmaGetAddr(sif0dma, sif0dma->madr, DMAC_SIF0);
ptag = safeDmaGetAddr(sif0dma, sif0dma->madr, DMAC_SIF0);
if (ptag == NULL) return;
SIF0read((u32*)ptag, readSize << 2);
@ -278,7 +278,7 @@ __forceinline void SIF1Dma()
{
// Process DMA tag at sif1dma->tadr
done = false;
ptag = (tDMA_TAG*)_dmaGetAddr(sif1dma, sif1dma->tadr, DMAC_SIF1);
ptag = safeDmaGetAddr(sif1dma, sif1dma->tadr, DMAC_SIF1);
if (ptag == NULL) return;
sif1dma->unsafeTransfer(ptag);
@ -341,7 +341,7 @@ __forceinline void SIF1Dma()
int qwTransfer = sif1dma->qwc;
tDMA_TAG *data;
data = (tDMA_TAG*)_dmaGetAddr(sif1dma, sif1dma->madr, DMAC_SIF1);
data = safeDmaGetAddr(sif1dma, sif1dma->madr, DMAC_SIF1);
if (data == NULL) return;
if (qwTransfer > (FIFO_SIF1_W - sif1.fifoSize) / 4) // Copy part of sif1dma into FIFO

View File

@ -130,8 +130,8 @@ bool SysThreadBase::Suspend( bool isBlocking )
// to wait, or issue a cancel to the thread.
throw Exception::ThreadTimedOut( *this,
L"Possible deadlock while suspending thread '%s'",
L"'%s' thread is not responding to suspend requests. It may be deadlocked or just running *really* slow."
wxsFormat(L"Possible deadlock while suspending thread '%s'", m_name.c_str()),
wxsFormat(L"'%s' thread is not responding to suspend requests. It may be deadlocked or just running *really* slow.", m_name.c_str())
);
}
}

View File

@ -483,7 +483,7 @@ static __forceinline bool mfifo_VIF1chain()
}
else
{
tDMA_TAG *pMem = (tDMA_TAG*)dmaGetAddr(vif1ch->madr);
tDMA_TAG *pMem = dmaGetAddr(vif1ch->madr);
SPR_LOG("Non-MFIFO Location");
if (pMem == NULL) return false;
@ -527,7 +527,7 @@ void mfifoVIF1transfer(int qwc)
if (vif1ch->qwc == 0 && vifqwc > 0)
{
ptag = (tDMA_TAG*)dmaGetAddr(vif1ch->tadr);
ptag = dmaGetAddr(vif1ch->tadr);
if (vif1ch->chcr.TTE)
{

View File

@ -499,7 +499,7 @@ bool _chainVIF0()
{
tDMA_TAG *ptag;
ptag = (tDMA_TAG*)dmaGetAddr(vif0ch->tadr); //Set memory pointer to TADR
ptag = dmaGetAddr(vif0ch->tadr); //Set memory pointer to TADR
if (!(vif0ch->transfer("Vif0 Tag", ptag))) return false;

View File

@ -802,7 +802,7 @@ __forceinline void vif1SetupTransfer()
break;
case VIF_CHAIN_MODE:
ptag = (tDMA_TAG*)dmaGetAddr(vif1ch->tadr); //Set memory pointer to TADR
ptag = dmaGetAddr(vif1ch->tadr); //Set memory pointer to TADR
if (!(vif1ch->transfer("Vif1 Tag", ptag))) return;