added tlb checking to syncing the cores

This commit is contained in:
zilmar 2012-09-29 06:17:44 +10:00
parent 42408d5b4b
commit 249d2a33f1
3 changed files with 80 additions and 47 deletions

View File

@ -69,31 +69,6 @@ public:
} EntryLo1;
} TLB_ENTRY;
private:
typedef struct {
DWORD VSTART;
DWORD VEND;
DWORD PHYSSTART;
DWORD PHYSEND;
DWORD Length;
bool VALID;
bool DIRTY;
bool GLOBAL;
bool ValidEntry;
bool Random;
bool Probed;
} FASTTLB;
//friend CC_Core;
friend CDebugTlb; // enable debug window to read class
CTLB_CB * const m_CB;
TLB_ENTRY m_tlb[32];
FASTTLB m_FastTlb[64];
void SetupTLB_Entry ( int index, bool Random );
public:
CTLB ( CTLB_CB * CallBack );
@ -113,28 +88,33 @@ public:
bool PAddrToVAddr ( DWORD PAddr, DWORD & VAddr, DWORD & Index );
//Change the Virtual address to a Phyiscal Address
/*inline bool TranslateVaddr ( DWORD VAddr, DWORD &PAddr) const
{
//Change the Virtual address to a Phyiscal Address
if (TLB_ReadMap[VAddr >> 12] == 0) { return false; }
PAddr = (DWORD)((BYTE *)(TLB_ReadMap[VAddr >> 12] + VAddr) - m_BasePAddr);
return true;
}
inline DWORD TranslateVaddr ( DWORD VAddr ) const
{
//Change the Virtual address to a Phyiscal Address
return (DWORD)((BYTE *)(TLB_ReadMap[VAddr >> 12] + VAddr) - m_BasePAddr);
}
void RecordDifference ( CLog &LogFile, const CTLB& rTLB);
//Change the Virtual address to a pointer to the physical address in memory
bool VAddrToRealAddr ( DWORD VAddr, void * &RealAddress );
// Find a matching Virtual Addres from a phyiscal one
bool PAddrToVAddr ( DWORD PAddr, DWORD & VAddr, DWORD & Index );
bool operator == (const CTLB& rTLB) const;
bool operator != (const CTLB& rTLB) const;
//see if the Vaddr is valid
inline bool ValidVaddr ( DWORD VAddr ) const { return TLB_ReadMap[VAddr >> 12] != 0; }
*/
private:
typedef struct {
DWORD VSTART;
DWORD VEND;
DWORD PHYSSTART;
DWORD PHYSEND;
DWORD Length;
bool VALID;
bool DIRTY;
bool GLOBAL;
bool ValidEntry;
bool Random;
bool Probed;
} FASTTLB;
//friend CC_Core;
friend CDebugTlb; // enable debug window to read class
CTLB_CB * const m_CB;
TLB_ENTRY m_tlb[32];
FASTTLB m_FastTlb[64];
void SetupTLB_Entry ( int index, bool Random );
};

View File

@ -227,3 +227,54 @@ bool CTLB::PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index )
}
return false;
}
void CTLB::RecordDifference( CLog &LogFile, const CTLB& rTLB)
{
for (int i = 0, n = sizeof(m_tlb)/sizeof(m_tlb[0]); i < n; i++)
{
if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined)
{
LogFile.LogF("TLB[%d] Defined: %s %s\r\n",i,m_tlb[i].EntryDefined ? "Yes" : "No",rTLB.m_tlb[i].EntryDefined ? "Yes" : "No");
continue;
}
if (!m_tlb[i].EntryDefined) { continue; }
if (m_tlb[i].PageMask.Value != rTLB.m_tlb[i].PageMask.Value)
{
LogFile.LogF("TLB[%d] PageMask: %X %X\r\n",i,m_tlb[i].PageMask.Value,rTLB.m_tlb[i].PageMask.Value);
}
if (m_tlb[i].EntryHi.Value != rTLB.m_tlb[i].EntryHi.Value)
{
LogFile.LogF("TLB[%d] EntryHi: %X %X\r\n",i,m_tlb[i].EntryHi.Value,rTLB.m_tlb[i].EntryHi.Value);
}
if (m_tlb[i].EntryLo0.Value != rTLB.m_tlb[i].EntryLo0.Value)
{
LogFile.LogF("TLB[%d] EntryLo0: %X %X\r\n",i,m_tlb[i].EntryLo0.Value,rTLB.m_tlb[i].EntryLo0.Value);
}
if (m_tlb[i].EntryLo1.Value != rTLB.m_tlb[i].EntryLo1.Value)
{
LogFile.LogF("TLB[%d] EntryLo1: %X %X\r\n",i,m_tlb[i].EntryLo1.Value,rTLB.m_tlb[i].EntryLo1.Value);
}
}
}
bool CTLB::operator == (const CTLB& rTLB) const
{
for (int i = 0, n = sizeof(m_tlb)/sizeof(m_tlb[0]); i < n; i++)
{
if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined) { return false; }
if (!m_tlb[i].EntryDefined) { continue; }
if (m_tlb[i].PageMask.Value != rTLB.m_tlb[i].PageMask.Value ||
m_tlb[i].EntryHi.Value != rTLB.m_tlb[i].EntryHi.Value ||
m_tlb[i].EntryLo0.Value != rTLB.m_tlb[i].EntryLo0.Value ||
m_tlb[i].EntryLo1.Value != rTLB.m_tlb[i].EntryLo1.Value)
{
return false;
}
}
return true;
}
bool CTLB::operator != (const CTLB& rTLB) const
{
return !(*this == rTLB);
}

View File

@ -923,6 +923,7 @@ void CN64System::SyncCPU (CN64System * const SecondCPU) {
}
}
if (m_TLB != SecondCPU->m_TLB) { ErrorFound = true; }
if (m_Reg.m_FPCR[0] != SecondCPU->m_Reg.m_FPCR[0]) { ErrorFound = true; }
if (m_Reg.m_FPCR[31] != SecondCPU->m_Reg.m_FPCR[31]) { ErrorFound = true; }
if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW) { ErrorFound = true; }
@ -1027,6 +1028,7 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU) {
{
Error.LogF("Current Time: %X %X\r\n",(DWORD)m_NextTimer,(DWORD)SecondCPU->m_NextTimer);
}
m_TLB.RecordDifference(Error,SecondCPU->m_TLB);
m_SystemTimer.RecordDifference(Error,SecondCPU->m_SystemTimer);
if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel)
{