[Project64] Get TLB class to use standard types
This commit is contained in:
parent
cfdb5dc8d0
commit
898f1da74d
|
@ -12,14 +12,16 @@
|
|||
|
||||
class CDebugTlb;
|
||||
|
||||
class CTLB_CB
|
||||
__interface CTLB_CB
|
||||
{
|
||||
public:
|
||||
virtual void TLB_Mapped(DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly) = 0;
|
||||
virtual void TLB_Unmaped(DWORD VAddr, DWORD Len) = 0;
|
||||
virtual void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly) = 0;
|
||||
virtual void TLB_Unmaped(uint32_t VAddr, uint32_t Len) = 0;
|
||||
virtual void TLB_Changed() = 0;
|
||||
};
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union
|
||||
|
||||
class CTLB :
|
||||
protected CSystemRegisters
|
||||
{
|
||||
|
@ -29,8 +31,8 @@ public:
|
|||
bool EntryDefined;
|
||||
union
|
||||
{
|
||||
unsigned long Value;
|
||||
unsigned char A[4];
|
||||
uint32_t Value;
|
||||
uint8_t A[4];
|
||||
|
||||
struct
|
||||
{
|
||||
|
@ -38,13 +40,12 @@ public:
|
|||
unsigned Mask : 12;
|
||||
unsigned zero2 : 7;
|
||||
} ;
|
||||
|
||||
} PageMask;
|
||||
|
||||
union
|
||||
{
|
||||
unsigned long Value;
|
||||
unsigned char A[4];
|
||||
uint32_t Value;
|
||||
uint8_t A[4];
|
||||
|
||||
struct
|
||||
{
|
||||
|
@ -53,13 +54,12 @@ public:
|
|||
unsigned G : 1;
|
||||
unsigned VPN2 : 19;
|
||||
};
|
||||
|
||||
} EntryHi;
|
||||
|
||||
union
|
||||
{
|
||||
unsigned long Value;
|
||||
unsigned char A[4];
|
||||
uint32_t Value;
|
||||
uint8_t A[4];
|
||||
|
||||
struct
|
||||
{
|
||||
|
@ -70,13 +70,12 @@ public:
|
|||
unsigned PFN : 20;
|
||||
unsigned ZERO: 6;
|
||||
} ;
|
||||
|
||||
} EntryLo0;
|
||||
|
||||
union
|
||||
{
|
||||
unsigned long Value;
|
||||
unsigned char A[4];
|
||||
uint32_t Value;
|
||||
uint8_t A[4];
|
||||
|
||||
struct
|
||||
{
|
||||
|
@ -87,7 +86,6 @@ public:
|
|||
unsigned PFN : 20;
|
||||
unsigned ZERO: 6;
|
||||
} ;
|
||||
|
||||
} EntryLo1;
|
||||
};
|
||||
|
||||
|
@ -100,17 +98,17 @@ public:
|
|||
//Used by opcodes of the same name to manipulate the tlb (reads the registers)
|
||||
void Probe();
|
||||
void ReadEntry();
|
||||
void WriteEntry(int index, bool Random);
|
||||
void WriteEntry(int32_t index, bool Random);
|
||||
|
||||
//See if a VAddr has an entry to translate to a PAddr
|
||||
bool AddressDefined(DWORD VAddr);
|
||||
bool AddressDefined(uint32_t VAddr);
|
||||
|
||||
const TLB_ENTRY & TlbEntry(int Entry) const
|
||||
const TLB_ENTRY & TlbEntry(int32_t Entry) const
|
||||
{
|
||||
return m_tlb[Entry];
|
||||
}
|
||||
|
||||
bool PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index);
|
||||
bool PAddrToVAddr(uint32_t PAddr, uint32_t & VAddr, uint32_t & Index);
|
||||
|
||||
void RecordDifference(CLog &LogFile, const CTLB& rTLB);
|
||||
|
||||
|
@ -120,11 +118,11 @@ public:
|
|||
private:
|
||||
struct FASTTLB
|
||||
{
|
||||
DWORD VSTART;
|
||||
DWORD VEND;
|
||||
DWORD PHYSSTART;
|
||||
DWORD PHYSEND;
|
||||
DWORD Length;
|
||||
uint32_t VSTART;
|
||||
uint32_t VEND;
|
||||
uint32_t PHYSSTART;
|
||||
uint32_t PHYSEND;
|
||||
uint32_t Length;
|
||||
bool VALID;
|
||||
bool DIRTY;
|
||||
bool GLOBAL;
|
||||
|
@ -140,5 +138,12 @@ private:
|
|||
TLB_ENTRY m_tlb[32];
|
||||
FASTTLB m_FastTlb[64];
|
||||
|
||||
void SetupTLB_Entry(int index, bool Random);
|
||||
void SetupTLB_Entry(int32_t index, bool Random);
|
||||
|
||||
private:
|
||||
CTLB(); // Disable default constructor
|
||||
CTLB(const CTLB&); // Disable copy constructor
|
||||
CTLB& operator=(const CTLB&); // Disable assignment
|
||||
};
|
||||
|
||||
#pragma warning(pop)
|
||||
|
|
|
@ -28,7 +28,7 @@ CTLB::~CTLB()
|
|||
|
||||
void CTLB::Reset (bool InvalidateTLB)
|
||||
{
|
||||
DWORD count;
|
||||
uint32_t count;
|
||||
|
||||
for (count = 0; count < 64; count++)
|
||||
{
|
||||
|
@ -51,9 +51,9 @@ void CTLB::Reset (bool InvalidateTLB)
|
|||
}
|
||||
}
|
||||
|
||||
bool CTLB::AddressDefined ( DWORD VAddr)
|
||||
bool CTLB::AddressDefined ( uint32_t VAddr)
|
||||
{
|
||||
DWORD i;
|
||||
uint32_t i;
|
||||
|
||||
if (VAddr >= 0x80000000 && VAddr <= 0xBFFFFFFF)
|
||||
{
|
||||
|
@ -85,10 +85,10 @@ void CTLB::Probe()
|
|||
continue;
|
||||
}
|
||||
|
||||
DWORD & TlbEntryHiValue = m_tlb[Counter].EntryHi.Value;
|
||||
DWORD Mask = ~m_tlb[Counter].PageMask.Mask << 13;
|
||||
DWORD TlbValueMasked = TlbEntryHiValue & Mask;
|
||||
DWORD EntryHiMasked = g_Reg->ENTRYHI_REGISTER & Mask;
|
||||
uint32_t & TlbEntryHiValue = m_tlb[Counter].EntryHi.Value;
|
||||
uint32_t Mask = ~m_tlb[Counter].PageMask.Mask << 13;
|
||||
uint32_t TlbValueMasked = TlbEntryHiValue & Mask;
|
||||
uint32_t EntryHiMasked = g_Reg->ENTRYHI_REGISTER & Mask;
|
||||
|
||||
if (TlbValueMasked == EntryHiMasked)
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ void CTLB::Probe()
|
|||
|
||||
void CTLB::ReadEntry()
|
||||
{
|
||||
DWORD index = g_Reg->INDEX_REGISTER & 0x1F;
|
||||
uint32_t index = g_Reg->INDEX_REGISTER & 0x1F;
|
||||
|
||||
g_Reg->PAGE_MASK_REGISTER = m_tlb[index].PageMask.Value ;
|
||||
g_Reg->ENTRYHI_REGISTER = (m_tlb[index].EntryHi.Value & ~m_tlb[index].PageMask.Value) ;
|
||||
|
@ -206,7 +206,6 @@ void CTLB::SetupTLB_Entry (int index, bool Random)
|
|||
m_FastTlb[FastIndx].Random = Random;
|
||||
m_FastTlb[FastIndx].Probed = false;
|
||||
|
||||
|
||||
FastIndx = (index << 1) + 1;
|
||||
if (m_FastTlb[FastIndx].VALID)
|
||||
{
|
||||
|
@ -252,7 +251,7 @@ void CTLB::SetupTLB_Entry (int index, bool Random)
|
|||
}
|
||||
}
|
||||
|
||||
bool CTLB::PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index )
|
||||
bool CTLB::PAddrToVAddr(uint32_t PAddr, uint32_t & VAddr, uint32_t & Index )
|
||||
{
|
||||
for (int i = Index; i < 64; i++)
|
||||
{
|
||||
|
@ -266,7 +265,6 @@ bool CTLB::PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index )
|
|||
Index = i + 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2073,12 +2073,12 @@ bool CN64System::WriteToProtectedMemory (uint32_t Address, int length)
|
|||
return false;
|
||||
}
|
||||
|
||||
void CN64System::TLB_Mapped ( DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly )
|
||||
void CN64System::TLB_Mapped ( uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly )
|
||||
{
|
||||
m_MMU_VM.TLB_Mapped(VAddr,Len,PAddr,bReadOnly);
|
||||
}
|
||||
|
||||
void CN64System::TLB_Unmaped ( DWORD VAddr, DWORD Len )
|
||||
void CN64System::TLB_Unmaped ( uint32_t VAddr, uint32_t Len )
|
||||
{
|
||||
m_MMU_VM.TLB_Unmaped(VAddr,Len);
|
||||
if (m_Recomp && bSMM_TLB())
|
||||
|
|
|
@ -114,8 +114,8 @@ private:
|
|||
virtual bool WriteToProtectedMemory(uint32_t Address, int length);
|
||||
|
||||
//Functions in CTLB_CB
|
||||
void TLB_Mapped(DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly);
|
||||
void TLB_Unmaped(DWORD VAddr, DWORD Len);
|
||||
void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly);
|
||||
void TLB_Unmaped(uint32_t VAddr, uint32_t Len);
|
||||
void TLB_Changed();
|
||||
|
||||
CPlugins * const m_Plugins; //The plugin container
|
||||
|
|
|
@ -908,7 +908,7 @@ void CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON
|
|||
|
||||
if (g_System->bUseTlb())
|
||||
{
|
||||
DWORD VAddr, Index = 0;
|
||||
uint32_t VAddr, Index = 0;
|
||||
while (g_TLB->PAddrToVAddr(Address,VAddr,Index))
|
||||
{
|
||||
WriteTraceF(TraceRecompiler,__FUNCTION__ ": ClearRecompCode Vaddr %X len: %d",VAddr,length);
|
||||
|
|
Loading…
Reference in New Issue