I was wrong on the CPEnd issue, which reveals CPBreakpoint > CPEnd is possible and that explains why some BPs could never be achieved before.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5705 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
ayuanx 2010-06-15 09:58:43 +00:00
parent cab62472b8
commit 64299206d1
3 changed files with 20 additions and 11 deletions

View File

@ -81,7 +81,7 @@ void STACKALIGN CheckGatherPipe()
m_gatherPipeCount -= GATHER_PIPE_SIZE; m_gatherPipeCount -= GATHER_PIPE_SIZE;
// increase the CPUWritePointer // increase the CPUWritePointer
if (ProcessorInterface::Fifo_CPUWritePointer + GATHER_PIPE_SIZE >= ProcessorInterface::Fifo_CPUEnd) if (ProcessorInterface::Fifo_CPUWritePointer >= ProcessorInterface::Fifo_CPUEnd)
{ {
curMem -= ProcessorInterface::Fifo_CPUWritePointer - ProcessorInterface::Fifo_CPUBase; curMem -= ProcessorInterface::Fifo_CPUWritePointer - ProcessorInterface::Fifo_CPUBase;
ProcessorInterface::Fifo_CPUWritePointer = ProcessorInterface::Fifo_CPUBase; ProcessorInterface::Fifo_CPUWritePointer = ProcessorInterface::Fifo_CPUBase;

View File

@ -158,7 +158,7 @@ void Init()
memset(&fifo,0,sizeof(fifo)); memset(&fifo,0,sizeof(fifo));
fifo.CPCmdIdle = 1 ; fifo.CPCmdIdle = 1 ;
fifo.CPReadIdle = 1; fifo.CPReadIdle = 1; // We use it as UnderFlow flag now, otherwise we need a new volatile variable
fifo.bFF_Breakpoint = 0; fifo.bFF_Breakpoint = 0;
s_fifoIdleEvent.Init(); s_fifoIdleEvent.Init();
@ -394,6 +394,12 @@ void Write16(const u16 _Value, const u32 _Address)
if (!tmpCtrl.BPEnable) if (!tmpCtrl.BPEnable)
Common::AtomicStore(fifo.bFF_Breakpoint, false); Common::AtomicStore(fifo.bFF_Breakpoint, false);
if (tmpCtrl.FifoUnderflowIntEnable)
Common::AtomicStore(fifo.CPReadIdle, false);
if (tmpCtrl.FifoOverflowIntEnable)
m_CPStatusReg.OverflowHiWatermark = false;
fifo.bFF_BPInt = tmpCtrl.BPInt; fifo.bFF_BPInt = tmpCtrl.BPInt;
fifo.bFF_BPEnable = tmpCtrl.BPEnable; fifo.bFF_BPEnable = tmpCtrl.BPEnable;
fifo.bFF_GPReadEnable = tmpCtrl.GPReadEnable; fifo.bFF_GPReadEnable = tmpCtrl.GPReadEnable;
@ -560,10 +566,13 @@ void STACKALIGN GatherPipeBursted()
if (!m_CPCtrlReg.GPLinkEnable) if (!m_CPCtrlReg.GPLinkEnable)
return; return;
_assert_msg_(COMMANDPROCESSOR, fifo.CPReadWriteDistance < fifo.CPEnd - fifo.CPBase, "FIFO is overflown by GatherPipe !");
if (g_VideoInitialize.bOnThread) if (g_VideoInitialize.bOnThread)
{ {
// update the fifo-pointer // update the fifo-pointer
if (fifo.CPWritePointer + GATHER_PIPE_SIZE >= fifo.CPEnd) if (fifo.CPWritePointer >= fifo.CPEnd)
fifo.CPWritePointer = fifo.CPBase; fifo.CPWritePointer = fifo.CPBase;
else else
fifo.CPWritePointer += GATHER_PIPE_SIZE; fifo.CPWritePointer += GATHER_PIPE_SIZE;
@ -611,7 +620,7 @@ void STACKALIGN GatherPipeBursted()
} }
else else
{ {
if (fifo.CPWritePointer + GATHER_PIPE_SIZE >= fifo.CPEnd) if (fifo.CPWritePointer >= fifo.CPEnd)
fifo.CPWritePointer = fifo.CPBase; fifo.CPWritePointer = fifo.CPBase;
else else
fifo.CPWritePointer += GATHER_PIPE_SIZE; fifo.CPWritePointer += GATHER_PIPE_SIZE;
@ -636,7 +645,7 @@ void CatchUpGPU()
while (fifo.bFF_GPReadEnable && fifo.CPReadWriteDistance && (!fifo.bFF_BPEnable || (fifo.bFF_BPEnable && !fifo.bFF_Breakpoint))) while (fifo.bFF_GPReadEnable && fifo.CPReadWriteDistance && (!fifo.bFF_BPEnable || (fifo.bFF_BPEnable && !fifo.bFF_Breakpoint)))
{ {
// check if we are on a breakpoint // check if we are on a breakpoint
if (fifo.bFF_BPEnable && fifo.CPReadPointer == fifo.CPBreakpoint) if (fifo.bFF_BPEnable && ((fifo.CPReadPointer <= fifo.CPBreakpoint) && (fifo.CPReadPointer + 32 > fifo.CPBreakpoint)))
{ {
//_assert_msg_(POWERPC,0,"BP: %08x",fifo.CPBreakpoint); //_assert_msg_(POWERPC,0,"BP: %08x",fifo.CPBreakpoint);
fifo.bFF_Breakpoint = 1; fifo.bFF_Breakpoint = 1;
@ -653,7 +662,7 @@ void CatchUpGPU()
LoadSSEState(); LoadSSEState();
// increase the ReadPtr // increase the ReadPtr
if (fifo.CPReadPointer + 32 >= fifo.CPEnd) if (fifo.CPReadPointer >= fifo.CPEnd)
{ {
fifo.CPReadPointer = fifo.CPBase; fifo.CPReadPointer = fifo.CPBase;
// adjust, take care // adjust, take care

View File

@ -163,7 +163,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
// If we are in BP mode we only send 32B chunks to Video plugin for BP checking // If we are in BP mode we only send 32B chunks to Video plugin for BP checking
if (_fifo.bFF_BPEnable) if (_fifo.bFF_BPEnable)
{ {
if (readPtr == _fifo.CPBreakpoint) if ((readPtr <= _fifo.CPBreakpoint) && (readPtr + 32 > _fifo.CPBreakpoint))
{ {
Common::AtomicStore(_fifo.bFF_Breakpoint, 1); Common::AtomicStore(_fifo.bFF_Breakpoint, 1);
if (_fifo.bFF_BPInt) if (_fifo.bFF_BPInt)
@ -173,7 +173,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
} }
distToSend = 32; distToSend = 32;
if (readPtr + 32 >= _fifo.CPEnd) if (readPtr >= _fifo.CPEnd)
readPtr = _fifo.CPBase; readPtr = _fifo.CPBase;
else else
readPtr += 32; readPtr += 32;
@ -184,9 +184,9 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
distToSend = _fifo.CPReadWriteDistance; distToSend = _fifo.CPReadWriteDistance;
// send 1024B chunk max length to have better control over PeekMessages' period // send 1024B chunk max length to have better control over PeekMessages' period
distToSend = distToSend > 1024 ? 1024 : distToSend; distToSend = distToSend > 1024 ? 1024 : distToSend;
if (readPtr + distToSend >= _fifo.CPEnd) if (readPtr + distToSend >= _fifo.CPEnd + 32)
{ {
distToSend = _fifo.CPEnd - readPtr; distToSend = _fifo.CPEnd + 32 - readPtr;
readPtr = _fifo.CPBase; readPtr = _fifo.CPBase;
} }
else else
@ -208,7 +208,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
VideoFifo_CheckSwapRequest(); VideoFifo_CheckSwapRequest();
} }
if (!_fifo.CPReadIdle && _fifo.CPReadWriteDistance <= _fifo.CPLoWatermark) if (!_fifo.CPReadIdle && _fifo.CPReadWriteDistance < _fifo.CPLoWatermark)
{ {
Common::AtomicStore(_fifo.CPReadIdle, true); Common::AtomicStore(_fifo.CPReadIdle, true);
CommandProcessor::UpdateInterruptsFromVideoPlugin(); CommandProcessor::UpdateInterruptsFromVideoPlugin();